public function setCurrentMBC1ROMBank()
{
//Read the cartridge ROM data from RAM memory:
switch ($this->ROMBank1offs) {
case 0x0:
case 0x20:
case 0x40:
case 0x60:
//Bank calls for 0x00, 0x20, 0x40, and 0x60 are really for 0x01, 0x21, 0x41, and 0x61.
$this->currentROMBank = $this->ROMBank1offs * 0x4000;
break;
default:
$this->currentROMBank = ($this->ROMBank1offs - 1) * 0x4000;
}
while ($this->currentROMBank + 0x4000 >= count($this->ROM)) {
$this->currentROMBank -= count($this->ROM);
}
}