public function setupRAM()
{
//Setup the auxilliary/switchable RAM to their maximum possible size (Bad headers can lie).
if ($this->cMBC2) {
$this->numRAMBanks = 1 / 16;
} elseif ($this->cMBC1 || $this->cRUMBLE || $this->cMBC3 || $this->cHuC3) {
$this->numRAMBanks = 4;
} elseif ($this->cMBC5) {
$this->numRAMBanks = 16;
} elseif ($this->cSRAM) {
$this->numRAMBanks = 1;
}
if ($this->numRAMBanks > 0) {
if (!$this->MBCRAMUtilized()) {
//For ROM and unknown MBC cartridges using the external RAM:
$this->MBCRAMBanksEnabled = true;
}
//Switched RAM Used
$this->MBCRam = $this->getTypedArray($this->numRAMBanks * 0x2000, 0, 'uint8');
}
echo 'Actual bytes of MBC RAM allocated: ' . $this->numRAMBanks * 0x2000 . PHP_EOL;
//Setup the RAM for GBC mode.
if ($this->cGBC) {
$this->VRAM = $this->getTypedArray(0x2000, 0, 'uint8');
$this->GBCMemory = $this->getTypedArray(0x7000, 0, 'uint8');
$this->tileCount *= 2;
$this->tileCountInvalidator = $this->tileCount * 4;
$this->colorCount = 64;
$this->transparentCutoff = 32;
}
$this->tileData = $this->arrayPad($this->tileCount * $this->colorCount, null);
$this->tileReadState = $this->getTypedArray($this->tileCount, 0, 'uint8');
}