summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGabriel Rodrigues Couto <gabrielrcouto@gmail.com>2016-03-03 09:17:39 -0300
committerGabriel Rodrigues Couto <gabrielrcouto@gmail.com>2016-03-03 09:17:39 -0300
commitff7b65b7195b319624bff76f26e5a8d239bdc335 (patch)
tree3b5ece4c50dabf4d03498861547e3e71bc1e4111
parent765a7b77dd7f0e188da328d274c37622aba4a169 (diff)
downloadphp-terminal-gameboy-emulator-ff7b65b7195b319624bff76f26e5a8d239bdc335.zip
php-terminal-gameboy-emulator-ff7b65b7195b319624bff76f26e5a8d239bdc335.tar.gz
php-terminal-gameboy-emulator-ff7b65b7195b319624bff76f26e5a8d239bdc335.tar.bz2
Memory Reader refactored
Some cleaning on Core
-rw-r--r--src/Cbopcode.php64
-rw-r--r--src/Core.php893
-rw-r--r--src/Opcode.php662
3 files changed, 753 insertions, 866 deletions
diff --git a/src/Cbopcode.php b/src/Cbopcode.php
index 37a6942..b363cba 100644
--- a/src/Cbopcode.php
+++ b/src/Cbopcode.php
@@ -102,7 +102,7 @@ class Cbopcode
*/
private static function cbopcode6(Core $core)
{
- $temp_var = $core->memoryReader[$core->registersHL]($core, $core->registersHL);
+ $temp_var = $core->memoryRead($core->registersHL);
$core->FCarry = (($temp_var & 0x80) == 0x80);
$temp_var = (($temp_var << 1) & 0xFF) + (($core->FCarry) ? 1 : 0);
$core->memoryWrite($core->registersHL, $temp_var);
@@ -208,7 +208,7 @@ class Cbopcode
*/
private static function cbopcode14(Core $core)
{
- $temp_var = $core->memoryReader[$core->registersHL]($core, $core->registersHL);
+ $temp_var = $core->memoryRead($core->registersHL);
$core->FCarry = (($temp_var & 0x01) == 0x01);
$temp_var = (($core->FCarry) ? 0x80 : 0) + ($temp_var >> 1);
$core->memoryWrite($core->registersHL, $temp_var);
@@ -320,7 +320,7 @@ class Cbopcode
*/
private static function cbopcode22(Core $core)
{
- $temp_var = $core->memoryReader[$core->registersHL]($core, $core->registersHL);
+ $temp_var = $core->memoryRead($core->registersHL);
$newFCarry = (($temp_var & 0x80) == 0x80);
$temp_var = (($temp_var << 1) & 0xFF) + (($core->FCarry) ? 1 : 0);
$core->FCarry = $newFCarry;
@@ -434,7 +434,7 @@ class Cbopcode
*/
private static function cbopcode30(Core $core)
{
- $temp_var = $core->memoryReader[$core->registersHL]($core, $core->registersHL);
+ $temp_var = $core->memoryRead($core->registersHL);
$newFCarry = (($temp_var & 0x01) == 0x01);
$temp_var = (($core->FCarry) ? 0x80 : 0) + ($temp_var >> 1);
$core->FCarry = $newFCarry;
@@ -542,7 +542,7 @@ class Cbopcode
*/
private static function cbopcode38(Core $core)
{
- $temp_var = $core->memoryReader[$core->registersHL]($core, $core->registersHL);
+ $temp_var = $core->memoryRead($core->registersHL);
$core->FCarry = (($temp_var & 0x80) == 0x80);
$temp_var = ($temp_var << 1) & 0xFF;
$core->memoryWrite($core->registersHL, $temp_var);
@@ -649,7 +649,7 @@ class Cbopcode
*/
private static function cbopcode46(Core $core)
{
- $temp_var = $core->memoryReader[$core->registersHL]($core, $core->registersHL);
+ $temp_var = $core->memoryRead($core->registersHL);
$core->FCarry = (($temp_var & 0x01) == 0x01);
$temp_var = ($temp_var & 0x80) + ($temp_var >> 1);
$core->memoryWrite($core->registersHL, $temp_var);
@@ -749,7 +749,7 @@ class Cbopcode
*/
private static function cbopcode54(Core $core)
{
- $temp_var = $core->memoryReader[$core->registersHL]($core, $core->registersHL);
+ $temp_var = $core->memoryRead($core->registersHL);
$temp_var = (($temp_var & 0xF) << 4) + ($temp_var >> 4);
$core->memoryWrite($core->registersHL, $temp_var);
$core->FZero = ($temp_var == 0);
@@ -853,7 +853,7 @@ class Cbopcode
*/
private static function cbopcode62(Core $core)
{
- $temp_var = $core->memoryReader[$core->registersHL]($core, $core->registersHL);
+ $temp_var = $core->memoryRead($core->registersHL);
$core->FCarry = (($temp_var & 0x01) == 0x01);
$core->memoryWrite($core->registersHL, $temp_var >>= 1);
$core->FHalfCarry = $core->FSubtract = false;
@@ -954,7 +954,7 @@ class Cbopcode
{
$core->FHalfCarry = true;
$core->FSubtract = false;
- $core->FZero = (($core->memoryReader[$core->registersHL]($core, $core->registersHL) & 0x01) == 0);
+ $core->FZero = (($core->memoryRead($core->registersHL) & 0x01) == 0);
}
/**
@@ -1050,7 +1050,7 @@ class Cbopcode
{
$core->FHalfCarry = true;
$core->FSubtract = false;
- $core->FZero = (($core->memoryReader[$core->registersHL]($core, $core->registersHL) & 0x02) == 0);
+ $core->FZero = (($core->memoryRead($core->registersHL) & 0x02) == 0);
}
/**
@@ -1146,7 +1146,7 @@ class Cbopcode
{
$core->FHalfCarry = true;
$core->FSubtract = false;
- $core->FZero = (($core->memoryReader[$core->registersHL]($core, $core->registersHL) & 0x04) == 0);
+ $core->FZero = (($core->memoryRead($core->registersHL) & 0x04) == 0);
}
/**
@@ -1242,7 +1242,7 @@ class Cbopcode
{
$core->FHalfCarry = true;
$core->FSubtract = false;
- $core->FZero = (($core->memoryReader[$core->registersHL]($core, $core->registersHL) & 0x08) == 0);
+ $core->FZero = (($core->memoryRead($core->registersHL) & 0x08) == 0);
}
/**
@@ -1338,7 +1338,7 @@ class Cbopcode
{
$core->FHalfCarry = true;
$core->FSubtract = false;
- $core->FZero = (($core->memoryReader[$core->registersHL]($core, $core->registersHL) & 0x10) == 0);
+ $core->FZero = (($core->memoryRead($core->registersHL) & 0x10) == 0);
}
/**
@@ -1434,7 +1434,7 @@ class Cbopcode
{
$core->FHalfCarry = true;
$core->FSubtract = false;
- $core->FZero = (($core->memoryReader[$core->registersHL]($core, $core->registersHL) & 0x20) == 0);
+ $core->FZero = (($core->memoryRead($core->registersHL) & 0x20) == 0);
}
/**
@@ -1530,7 +1530,7 @@ class Cbopcode
{
$core->FHalfCarry = true;
$core->FSubtract = false;
- $core->FZero = (($core->memoryReader[$core->registersHL]($core, $core->registersHL) & 0x40) == 0);
+ $core->FZero = (($core->memoryRead($core->registersHL) & 0x40) == 0);
}
/**
@@ -1626,7 +1626,7 @@ class Cbopcode
{
$core->FHalfCarry = true;
$core->FSubtract = false;
- $core->FZero = (($core->memoryReader[$core->registersHL]($core, $core->registersHL) & 0x80) == 0);
+ $core->FZero = (($core->memoryRead($core->registersHL) & 0x80) == 0);
}
/**
@@ -1708,7 +1708,7 @@ class Cbopcode
*/
private static function cbopcode134(Core $core)
{
- $core->memoryWrite($core->registersHL, $core->memoryReader[$core->registersHL]($core, $core->registersHL) & 0xFE);
+ $core->memoryWrite($core->registersHL, $core->memoryRead($core->registersHL) & 0xFE);
}
/**
@@ -1788,7 +1788,7 @@ class Cbopcode
*/
private static function cbopcode142(Core $core)
{
- $core->memoryWrite($core->registersHL, $core->memoryReader[$core->registersHL]($core, $core->registersHL) & 0xFD);
+ $core->memoryWrite($core->registersHL, $core->memoryRead($core->registersHL) & 0xFD);
}
/**
@@ -1868,7 +1868,7 @@ class Cbopcode
*/
private static function cbopcode150(Core $core)
{
- $core->memoryWrite($core->registersHL, $core->memoryReader[$core->registersHL]($core, $core->registersHL) & 0xFB);
+ $core->memoryWrite($core->registersHL, $core->memoryRead($core->registersHL) & 0xFB);
}
/**
@@ -1948,7 +1948,7 @@ class Cbopcode
*/
private static function cbopcode158(Core $core)
{
- $core->memoryWrite($core->registersHL, $core->memoryReader[$core->registersHL]($core, $core->registersHL) & 0xF7);
+ $core->memoryWrite($core->registersHL, $core->memoryRead($core->registersHL) & 0xF7);
}
/**
@@ -2028,7 +2028,7 @@ class Cbopcode
*/
private static function cbopcode166(Core $core)
{
- $core->memoryWrite($core->registersHL, $core->memoryReader[$core->registersHL]($core, $core->registersHL) & 0xEF);
+ $core->memoryWrite($core->registersHL, $core->memoryRead($core->registersHL) & 0xEF);
}
/**
@@ -2108,7 +2108,7 @@ class Cbopcode
*/
private static function cbopcode174(Core $core)
{
- $core->memoryWrite($core->registersHL, $core->memoryReader[$core->registersHL]($core, $core->registersHL) & 0xDF);
+ $core->memoryWrite($core->registersHL, $core->memoryRead($core->registersHL) & 0xDF);
}
/**
@@ -2188,7 +2188,7 @@ class Cbopcode
*/
private static function cbopcode182(Core $core)
{
- $core->memoryWrite($core->registersHL, $core->memoryReader[$core->registersHL]($core, $core->registersHL) & 0xBF);
+ $core->memoryWrite($core->registersHL, $core->memoryRead($core->registersHL) & 0xBF);
}
/**
@@ -2268,7 +2268,7 @@ class Cbopcode
*/
private static function cbopcode190(Core $core)
{
- $core->memoryWrite($core->registersHL, $core->memoryReader[$core->registersHL]($core, $core->registersHL) & 0x7F);
+ $core->memoryWrite($core->registersHL, $core->memoryRead($core->registersHL) & 0x7F);
}
/**
@@ -2348,7 +2348,7 @@ class Cbopcode
*/
private static function cbopcode198(Core $core)
{
- $core->memoryWrite($core->registersHL, $core->memoryReader[$core->registersHL]($core, $core->registersHL) | 0x01);
+ $core->memoryWrite($core->registersHL, $core->memoryRead($core->registersHL) | 0x01);
}
/**
@@ -2428,7 +2428,7 @@ class Cbopcode
*/
private static function cbopcode206(Core $core)
{
- $core->memoryWrite($core->registersHL, $core->memoryReader[$core->registersHL]($core, $core->registersHL) | 0x02);
+ $core->memoryWrite($core->registersHL, $core->memoryRead($core->registersHL) | 0x02);
}
/**
@@ -2508,7 +2508,7 @@ class Cbopcode
*/
private static function cbopcode214(Core $core)
{
- $core->memoryWrite($core->registersHL, $core->memoryReader[$core->registersHL]($core, $core->registersHL) | 0x04);
+ $core->memoryWrite($core->registersHL, $core->memoryRead($core->registersHL) | 0x04);
}
/**
@@ -2588,7 +2588,7 @@ class Cbopcode
*/
private static function cbopcode222(Core $core)
{
- $core->memoryWrite($core->registersHL, $core->memoryReader[$core->registersHL]($core, $core->registersHL) | 0x08);
+ $core->memoryWrite($core->registersHL, $core->memoryRead($core->registersHL) | 0x08);
}
/**
@@ -2668,7 +2668,7 @@ class Cbopcode
*/
private static function cbopcode230(Core $core)
{
- $core->memoryWrite($core->registersHL, $core->memoryReader[$core->registersHL]($core, $core->registersHL) | 0x10);
+ $core->memoryWrite($core->registersHL, $core->memoryRead($core->registersHL) | 0x10);
}
/**
@@ -2748,7 +2748,7 @@ class Cbopcode
*/
private static function cbopcode238(Core $core)
{
- $core->memoryWrite($core->registersHL, $core->memoryReader[$core->registersHL]($core, $core->registersHL) | 0x20);
+ $core->memoryWrite($core->registersHL, $core->memoryRead($core->registersHL) | 0x20);
}
/**
@@ -2828,7 +2828,7 @@ class Cbopcode
*/
private static function cbopcode246(Core $core)
{
- $core->memoryWrite($core->registersHL, $core->memoryReader[$core->registersHL]($core, $core->registersHL) | 0x40);
+ $core->memoryWrite($core->registersHL, $core->memoryRead($core->registersHL) | 0x40);
}
/**
@@ -2908,7 +2908,7 @@ class Cbopcode
*/
private static function cbopcode254(Core $core)
{
- $core->memoryWrite($core->registersHL, $core->memoryReader[$core->registersHL]($core, $core->registersHL) | 0x80);
+ $core->memoryWrite($core->registersHL, $core->memoryRead($core->registersHL) | 0x80);
}
/**
diff --git a/src/Core.php b/src/Core.php
index 4c9a9b0..ebe8ad1 100644
--- a/src/Core.php
+++ b/src/Core.php
@@ -16,9 +16,6 @@ class Core
//Whether we're in the GBC boot ROM.
public $inBootstrap = true;
- //Updated upon ROM loading...
- public $usedBootROM = false;
-
// Accumulator (default is GB mode)
public $registerA = 0x01;
@@ -49,9 +46,6 @@ class Core
// Registers H and L
public $registersHL = 0x014D;
- //Array of functions mapped to read back memory
- public $memoryReader = [];
-
//Array of functions mapped to write to memory
public $memoryWriter = [];
@@ -492,7 +486,6 @@ class Core
$this->RTCDayOverFlow,
$this->RTCHALT,
$this->gbColorizedPalette,
- $this->usedBootROM,
$this->skipPCIncrement,
$this->STATTracker,
$this->gbcRamBankPositionECHO,
@@ -502,111 +495,109 @@ class Core
public function returnFromState($returnedFrom)
{
- $index = 0;
+ $address = 0;
$state = $returnedFrom->slice(0);
- $this->ROM = $this->toTypedArray($state[$index++], false, false);
- $this->inBootstrap = $state[$index++];
- $this->registerA = $state[$index++];
- $this->FZero = $state[$index++];
- $this->FSubtract = $state[$index++];
- $this->FHalfCarry = $state[$index++];
- $this->FCarry = $state[$index++];
- $this->registerB = $state[$index++];
- $this->registerC = $state[$index++];
- $this->registerD = $state[$index++];
- $this->registerE = $state[$index++];
- $this->registersHL = $state[$index++];
- $this->stackPointer = $state[$index++];
- $this->programCounter = $state[$index++];
- $this->halt = $state[$index++];
- $this->IME = $state[$index++];
- $this->hdmaRunning = $state[$index++];
- $this->CPUTicks = $state[$index++];
- $this->multiplier = $state[$index++];
- $this->memory = $this->toTypedArray($state[$index++], false, false);
- $this->MBCRam = $this->toTypedArray($state[$index++], false, false);
- $this->VRAM = $this->toTypedArray($state[$index++], false, false);
- $this->currVRAMBank = $state[$index++];
- $this->GBCMemory = $this->toTypedArray($state[$index++], false, false);
- $this->MBC1Mode = $state[$index++];
- $this->MBCRAMBanksEnabled = $state[$index++];
- $this->currMBCRAMBank = $state[$index++];
- $this->currMBCRAMBankPosition = $state[$index++];
- $this->cGBC = $state[$index++];
- $this->gbcRamBank = $state[$index++];
- $this->gbcRamBankPosition = $state[$index++];
- $this->ROMBank1offs = $state[$index++];
- $this->currentROMBank = $state[$index++];
- $this->cartridgeType = $state[$index++];
- $this->name = $state[$index++];
- $this->gameCode = $state[$index++];
- $this->modeSTAT = $state[$index++];
- $this->LYCMatchTriggerSTAT = $state[$index++];
- $this->mode2TriggerSTAT = $state[$index++];
- $this->mode1TriggerSTAT = $state[$index++];
- $this->mode0TriggerSTAT = $state[$index++];
- $this->LCDisOn = $state[$index++];
- $this->gfxWindowY = $state[$index++];
- $this->gfxWindowDisplay = $state[$index++];
- $this->gfxSpriteShow = $state[$index++];
- $this->gfxSpriteDouble = $state[$index++];
- $this->gfxBackgroundY = $state[$index++];
- $this->gfxBackgroundX = $state[$index++];
- $this->TIMAEnabled = $state[$index++];
- $this->DIVTicks = $state[$index++];
- $this->LCDTicks = $state[$index++];
- $this->timerTicks = $state[$index++];
- $this->TACClocker = $state[$index++];
- $this->untilEnable = $state[$index++];
- $this->lastIteration = $state[$index++];
- $this->cMBC1 = $state[$index++];
- $this->cMBC2 = $state[$index++];
- $this->cMBC3 = $state[$index++];
- $this->cMBC5 = $state[$index++];
- $this->cSRAM = $state[$index++];
- $this->cMMMO1 = $state[$index++];
- $this->cRUMBLE = $state[$index++];
- $this->cCamera = $state[$index++];
- $this->cTAMA5 = $state[$index++];
- $this->cHuC3 = $state[$index++];
- $this->cHuC1 = $state[$index++];
- $this->drewBlank = $state[$index++];
- $this->tileData = $state[$index++];
- $this->frameBuffer = $this->toTypedArray($state[$index++], true, false);
- $this->tileCount = $state[$index++];
- $this->colorCount = $state[$index++];
- $this->gbPalette = $state[$index++];
- $this->gbcRawPalette = $state[$index++];
- $this->gbcPalette = $state[$index++];
- $this->transparentCutoff = $state[$index++];
- $this->bgEnabled = $state[$index++];
- $this->spritePriorityEnabled = $state[$index++];
- $this->tileReadState = $this->toTypedArray($state[$index++], false, false);
- $this->windowSourceLine = $state[$index++];
- $this->actualScanLine = $state[$index++];
- $this->RTCisLatched = $state[$index++];
- $this->latchedSeconds = $state[$index++];
- $this->latchedMinutes = $state[$index++];
- $this->latchedHours = $state[$index++];
- $this->latchedLDays = $state[$index++];
- $this->latchedHDays = $state[$index++];
- $this->RTCSeconds = $state[$index++];
- $this->RTCMinutes = $state[$index++];
- $this->RTCHours = $state[$index++];
- $this->RTCDays = $state[$index++];
- $this->RTCDayOverFlow = $state[$index++];
- $this->RTCHALT = $state[$index++];
- $this->gbColorizedPalette = $state[$index++];
- $this->usedBootROM = $state[$index++];
- $this->skipPCIncrement = $state[$index++];
- $this->STATTracker = $state[$index++];
- $this->gbcRamBankPositionECHO = $state[$index++];
- $this->numRAMBanks = $state[$index];
+ $this->ROM = $this->toTypedArray($state[$address++], false, false);
+ $this->inBootstrap = $state[$address++];
+ $this->registerA = $state[$address++];
+ $this->FZero = $state[$address++];
+ $this->FSubtract = $state[$address++];
+ $this->FHalfCarry = $state[$address++];
+ $this->FCarry = $state[$address++];
+ $this->registerB = $state[$address++];
+ $this->registerC = $state[$address++];
+ $this->registerD = $state[$address++];
+ $this->registerE = $state[$address++];
+ $this->registersHL = $state[$address++];
+ $this->stackPointer = $state[$address++];
+ $this->programCounter = $state[$address++];
+ $this->halt = $state[$address++];
+ $this->IME = $state[$address++];
+ $this->hdmaRunning = $state[$address++];
+ $this->CPUTicks = $state[$address++];
+ $this->multiplier = $state[$address++];
+ $this->memory = $this->toTypedArray($state[$address++], false, false);
+ $this->MBCRam = $this->toTypedArray($state[$address++], false, false);
+ $this->VRAM = $this->toTypedArray($state[$address++], false, false);
+ $this->currVRAMBank = $state[$address++];
+ $this->GBCMemory = $this->toTypedArray($state[$address++], false, false);
+ $this->MBC1Mode = $state[$address++];
+ $this->MBCRAMBanksEnabled = $state[$address++];
+ $this->currMBCRAMBank = $state[$address++];
+ $this->currMBCRAMBankPosition = $state[$address++];
+ $this->cGBC = $state[$address++];
+ $this->gbcRamBank = $state[$address++];
+ $this->gbcRamBankPosition = $state[$address++];
+ $this->ROMBank1offs = $state[$address++];
+ $this->currentROMBank = $state[$address++];
+ $this->cartridgeType = $state[$address++];
+ $this->name = $state[$address++];
+ $this->gameCode = $state[$address++];
+ $this->modeSTAT = $state[$address++];
+ $this->LYCMatchTriggerSTAT = $state[$address++];
+ $this->mode2TriggerSTAT = $state[$address++];
+ $this->mode1TriggerSTAT = $state[$address++];
+ $this->mode0TriggerSTAT = $state[$address++];
+ $this->LCDisOn = $state[$address++];
+ $this->gfxWindowY = $state[$address++];
+ $this->gfxWindowDisplay = $state[$address++];
+ $this->gfxSpriteShow = $state[$address++];
+ $this->gfxSpriteDouble = $state[$address++];
+ $this->gfxBackgroundY = $state[$address++];
+ $this->gfxBackgroundX = $state[$address++];
+ $this->TIMAEnabled = $state[$address++];
+ $this->DIVTicks = $state[$address++];
+ $this->LCDTicks = $state[$address++];
+ $this->timerTicks = $state[$address++];
+ $this->TACClocker = $state[$address++];
+ $this->untilEnable = $state[$address++];
+ $this->lastIteration = $state[$address++];
+ $this->cMBC1 = $state[$address++];
+ $this->cMBC2 = $state[$address++];
+ $this->cMBC3 = $state[$address++];
+ $this->cMBC5 = $state[$address++];
+ $this->cSRAM = $state[$address++];
+ $this->cMMMO1 = $state[$address++];
+ $this->cRUMBLE = $state[$address++];
+ $this->cCamera = $state[$address++];
+ $this->cTAMA5 = $state[$address++];
+ $this->cHuC3 = $state[$address++];
+ $this->cHuC1 = $state[$address++];
+ $this->drewBlank = $state[$address++];
+ $this->tileData = $state[$address++];
+ $this->frameBuffer = $this->toTypedArray($state[$address++], true, false);
+ $this->tileCount = $state[$address++];
+ $this->colorCount = $state[$address++];
+ $this->gbPalette = $state[$address++];
+ $this->gbcRawPalette = $state[$address++];
+ $this->gbcPalette = $state[$address++];
+ $this->transparentCutoff = $state[$address++];
+ $this->bgEnabled = $state[$address++];
+ $this->spritePriorityEnabled = $state[$address++];
+ $this->tileReadState = $this->toTypedArray($state[$address++], false, false);
+ $this->windowSourceLine = $state[$address++];
+ $this->actualScanLine = $state[$address++];
+ $this->RTCisLatched = $state[$address++];
+ $this->latchedSeconds = $state[$address++];
+ $this->latchedMinutes = $state[$address++];
+ $this->latchedHours = $state[$address++];
+ $this->latchedLDays = $state[$address++];
+ $this->latchedHDays = $state[$address++];
+ $this->RTCSeconds = $state[$address++];
+ $this->RTCMinutes = $state[$address++];
+ $this->RTCHours = $state[$address++];
+ $this->RTCDays = $state[$address++];
+ $this->RTCDayOverFlow = $state[$address++];
+ $this->RTCHALT = $state[$address++];
+ $this->gbColorizedPalette = $state[$address++];
+ $this->skipPCIncrement = $state[$address++];
+ $this->STATTracker = $state[$address++];
+ $this->gbcRamBankPositionECHO = $state[$address++];
+ $this->numRAMBanks = $state[$address];
$this->tileCountInvalidator = $this->tileCount * 4;
$this->fromSaveState = true;
$this->checkPaletteType();
- $this->memoryReadJumpCompile();
$this->memoryWriteJumpCompile();
$this->initLCD();
$this->drawToCanvas();
@@ -631,11 +622,11 @@ class Core
$this->gbcRawPalette = $this->arrayPad(0x80, -1000); //32-bit signed
$this->gbcPalette = [0x40]; //32-bit signed
//Initialize the GBC Palette:
- $index = 0x3F;
+ $address = 0x3F;
- while ($index >= 0) {
- $this->gbcPalette[$index] = ($index < 0x20) ? -1 : 0;
- --$index;
+ while ($address >= 0) {
+ $this->gbcPalette[$address] = ($address < 0x20) ? -1 : 0;
+ --$address;
}
}
@@ -662,13 +653,13 @@ class Core
//Fill in the boot ROM set register values
//Default values to the GB boot ROM values, then fill in the GBC boot ROM values after ROM loading
- $index = 0xFF;
+ $address = 0xFF;
- while ($index >= 0) {
- if ($index >= 0x30 && $index < 0x40) {
- $this->memoryWrite(0xFF00 + $index, $this->ffxxDump[$index]);
+ while ($address >= 0) {
+ if ($address >= 0x30 && $address < 0x40) {
+ $this->memoryWrite(0xFF00 + $address, $this->ffxxDump[$address]);
} else {
- switch ($index) {
+ switch ($address) {
case 0x00:
case 0x01:
case 0x02:
@@ -676,13 +667,13 @@ class Core
case 0x0F:
case 0x40:
case 0xFF:
- $this->memoryWrite(0xFF00 + $index, $this->ffxxDump[$index]);
+ $this->memoryWrite(0xFF00 + $address, $this->ffxxDump[$address]);
break;
default:
- $this->memory[0xFF00 + $index] = $this->ffxxDump[$index];
+ $this->memory[0xFF00 + $address] = $this->ffxxDump[$address];
}
}
- --$index;
+ --$address;
}
}
@@ -711,30 +702,23 @@ class Core
//Load the first two ROM banks (0x0000 - 0x7FFF) into regular gameboy memory:
$this->ROM = $this->getTypedArray(strlen($this->ROMImage), 0, 'uint8');
- $this->usedBootROM = Settings::$settings[16];
-
for ($romIndex = 0; $romIndex < strlen($this->ROMImage); ++$romIndex) {
$this->ROM[$romIndex] = (ord($this->ROMImage[$romIndex]) & 0xFF);
if ($romIndex < 0x8000) {
- if (!$this->usedBootROM || $romIndex >= 0x900 || ($romIndex >= 0x100 && $romIndex < 0x200)) {
- $this->memory[$romIndex] = $this->ROM[$romIndex]; //Load in the game ROM.
- } else {
- // Removed GBCROM due copyright ;-)
- // $this->memory[$romIndex] = $this->GBCBOOTROM[$romIndex]; //Load in the GameBoy Color BOOT ROM.
- }
+ $this->memory[$romIndex] = $this->ROM[$romIndex]; //Load in the game ROM.
}
}
// ROM name
- for ($index = 0x134; $index < 0x13F; ++$index) {
- if (ord($this->ROMImage[$index]) > 0) {
- $this->name .= $this->ROMImage[$index];
+ for ($address = 0x134; $address < 0x13F; ++$address) {
+ if (ord($this->ROMImage[$address]) > 0) {
+ $this->name .= $this->ROMImage[$address];
}
}
// ROM game code (for newer games)
- for ($index = 0x13F; $index < 0x143; ++$index) {
- if (ord($this->ROMImage[$index]) > 0) {
- $this->gameCode .= $this->ROMImage[$index];
+ for ($address = 0x13F; $address < 0x143; ++$address) {
+ if (ord($this->ROMImage[$address]) > 0) {
+ $this->gameCode .= $this->ROMImage[$address];
}
}
@@ -881,10 +865,7 @@ class Core
break;
default:
$MBCType = 'Unknown';
- echo 'Cartridge type is unknown.'.PHP_EOL;
-
- // @TODO
- //pause();
+ throw new RuntimeException('Cartridge type is unknown.');
}
echo 'Cartridge Type: '.$MBCType.PHP_EOL;
@@ -912,33 +893,28 @@ class Core
}
//Check the GB/GBC mode byte:
- if (!$this->usedBootROM) {
- switch ($this->ROM[0x143]) {
- case 0x00: //Only GB mode
- $this->cGBC = false;
- echo 'Only GB mode detected.'.PHP_EOL;
- break;
- case 0x80: //Both GB + GBC modes
- $this->cGBC = !Settings::$settings[2];
- echo 'GB and GBC mode detected.'.PHP_EOL;
- break;
- case 0xC0: //Only GBC mode
- $this->cGBC = true;
- echo 'Only GBC mode detected.'.PHP_EOL;
- break;
- default:
- $this->cGBC = false;
- echo 'Unknown GameBoy game type code #'.$this->ROM[0x143].", defaulting to GB mode (Old games don't have a type code).".PHP_EOL;
- }
-
- $this->inBootstrap = false;
- $this->setupRAM(); //CPU/(V)RAM initialization.
- $this->initSkipBootstrap();
- } else {
- $this->cGBC = true; //Allow the GBC boot ROM to run in GBC mode...
- $this->setupRAM(); //CPU/(V)RAM initialization.
- $this->initBootstrap();
+ switch ($this->ROM[0x143]) {
+ case 0x00: //Only GB mode
+ $this->cGBC = false;
+ echo 'Only GB mode detected.'.PHP_EOL;
+ break;
+ case 0x80: //Both GB + GBC modes
+ $this->cGBC = !Settings::$settings[2];
+ echo 'GB and GBC mode detected.'.PHP_EOL;
+ break;
+ case 0xC0: //Only GBC mode
+ $this->cGBC = true;
+ echo 'Only GBC mode detected.'.PHP_EOL;
+ break;
+ default:
+ $this->cGBC = false;
+ echo 'Unknown GameBoy game type code #'.$this->ROM[0x143].", defaulting to GB mode (Old games don't have a type code).".PHP_EOL;
}
+
+ $this->inBootstrap = false;
+ $this->setupRAM(); //CPU/(V)RAM initialization.
+ $this->initSkipBootstrap();
+
$this->checkPaletteType();
//License Code Lookup:
$cOldLicense = $this->ROM[0x14B];
@@ -955,10 +931,10 @@ class Core
public function disableBootROM()
{
//Remove any traces of the boot ROM from ROM memory.
- for ($index = 0; $index < 0x900; ++$index) {
+ for ($address = 0; $address < 0x900; ++$address) {
//Skip the already loaded in ROM header.
- if ($index < 0x100 || $index >= 0x200) {
- $this->memory[$index] = $this->ROM[$index]; //Replace the GameBoy Color boot ROM with the game ROM.
+ if ($address < 0x100 || $address >= 0x200) {
+ $this->memory[$address] = $this->ROM[$address]; //Replace the GameBoy Color boot ROM with the game ROM.
}
}
$this->checkPaletteType();
@@ -981,7 +957,6 @@ class Core
//Possible Extra: shorten some gfx arrays to the length that we need (Remove the unused indices)
}
- $this->memoryReadJumpCompile();
$this->memoryWriteJumpCompile();
}
@@ -1017,7 +992,6 @@ class Core
}
$this->tileData = $this->arrayPad($this->tileCount * $this->colorCount, null);
$this->tileReadState = $this->getTypedArray($this->tileCount, 0, 'uint8');
- $this->memoryReadJumpCompile();
$this->memoryWriteJumpCompile();
}
@@ -1048,15 +1022,15 @@ class Core
if ($this->drawContext->colorEnabled) {
$this->canvasBuffer = array_fill(0, 4 * $this->width * $this->height, 255);
- $index = $this->pixelCount;
- $index2 = $this->rgbCount;
+ $address = $this->pixelCount;
+ $address2 = $this->rgbCount;
- while ($index > 0) {
- $this->frameBuffer[--$index] = 0x00FFFFFF;
- $this->canvasBuffer[$index2 -= 4] = 0xFF;
- $this->canvasBuffer[$index2 + 1] = 0xFF;
- $this->canvasBuffer[$index2 + 2] = 0xFF;
- $this->canvasBuffer[$index2 + 3] = 0xFF;
+ while ($address > 0) {
+ $this->frameBuffer[--$address] = 0x00FFFFFF;
+ $this->canvasBuffer[$address2 -= 4] = 0xFF;
+ $this->canvasBuffer[$address2 + 1] = 0xFF;
+ $this->canvasBuffer[$address2 + 2] = 0xFF;
+ $this->canvasBuffer[$address2 + 3] = 0xFF;
}
} else {
$this->canvasBuffer = array_fill(0, 4 * $this->width * $this->height, false);
@@ -1127,7 +1101,7 @@ class Core
//Get how many CPU cycles the current op code counts for:
$this->CPUTicks = $this->TICKTable[$op];
//Execute the OP code instruction:
- Opcode::run($this, $op);
+ Opcode::{'opcode'.$op}($this);
//Interrupt Arming:
switch ($this->untilEnable) {
case 1:
@@ -1441,26 +1415,26 @@ class Core
}
}
- public function setGBCPalettePre($index_, $data)
+ public function setGBCPalettePre($address_, $data)
{
- if ($this->gbcRawPalette[$index_] == $data) {
+ if ($this->gbcRawPalette[$address_] == $data) {
return;
}
- $this->gbcRawPalette[$index_] = $data;
- if ($index_ >= 0x40 && ($index_ & 0x6) == 0) {
+ $this->gbcRawPalette[$address_] = $data;
+ if ($address_ >= 0x40 && ($address_ & 0x6) == 0) {
// stay transparent
return;
}
- $value = ($this->gbcRawPalette[$index_ | 1] << 8) + $this->gbcRawPalette[$index_ & -2];
- $this->gbcPalette[$index_ >> 1] = 0x80000000 + (($value & 0x1F) << 19) + (($value & 0x3E0) << 6) + (($value & 0x7C00) >> 7);
- $this->invalidateAll($index_ >> 3);
+ $value = ($this->gbcRawPalette[$address_ | 1] << 8) + $this->gbcRawPalette[$address_ & -2];
+ $this->gbcPalette[$address_ >> 1] = 0x80000000 + (($value & 0x1F) << 19) + (($value & 0x3E0) << 6) + (($value & 0x7C00) >> 7);
+ $this->invalidateAll($address_ >> 3);
}
- public function setGBCPalette($index_, $data)
+ public function setGBCPalette($address_, $data)
{
- $this->setGBCPalettePre($index_, $data);
- if (($index_ & 0x6) == 0) {
- $this->gbcPalette[$index_ >> 1] &= 0x00FFFFFF;
+ $this->setGBCPalettePre($address_, $data);
+ if (($address_ & 0x6) == 0) {
+ $this->gbcPalette[$address_ >> 1] &= 0x00FFFFFF;
}
}
@@ -1472,19 +1446,6 @@ class Core
$this->gbPalette[$startIndex + 2] = $this->colors[($data >> 4) & 0x03];
$this->gbPalette[$startIndex + 3] = $this->colors[$data >> 6];
- //Do palette conversions if we did the GBC bootup:
- if ($this->usedBootROM) {
- //GB colorization:
- $startOffset = ($startIndex >= 4) ? 0x20 : 0;
- $pal2 = $this->gbcPalette[$startOffset + (($data >> 2) & 0x03)];
- $pal3 = $this->gbcPalette[$startOffset + (($data >> 4) & 0x03)];
- $pal4 = $this->gbcPalette[$startOffset + ($data >> 6)];
- $this->gbColorizedPalette[$startIndex] = $this->gbcPalette[$startOffset + ($data & 0x03)] & 0x00FFFFFF;
- $this->gbColorizedPalette[$startIndex + 1] = ($pal2 >= 0x80000000) ? $pal2 : 0xFFFFFFFF;
- $this->gbColorizedPalette[$startIndex + 2] = ($pal3 >= 0x80000000) ? $pal3 : 0xFFFFFFFF;
- $this->gbColorizedPalette[$startIndex + 3] = ($pal4 >= 0x80000000) ? $pal4 : 0xFFFFFFFF;
- }
-
//@PHP - Need to copy the new palette
$this->checkPaletteType();
}
@@ -1586,12 +1547,12 @@ class Core
public function checkPaletteType()
{
//Reference the correct palette ahead of time...
- $this->palette = ($this->cGBC) ? $this->gbcPalette : (($this->usedBootROM && Settings::$settings[17]) ? $this->gbColorizedPalette : $this->gbPalette);
+ $this->palette = ($this->cGBC) ? $this->gbcPalette : ((Settings::$settings[17]) ? $this->gbColorizedPalette : $this->gbPalette);
}
public function updateImage($tileIndex, $attribs)
{
- $index_ = $tileIndex + $this->tileCount * $attribs;
+ $address_ = $tileIndex + $this->tileCount * $attribs;
$otherBank = ($tileIndex >= 384);
$offset = $otherBank ? (($tileIndex - 384) << 4) : ($tileIndex << 4);
$paletteStart = $attribs & 0xFC;
@@ -1621,11 +1582,11 @@ class Core
}
$pixix += $pixixdy;
}
- $this->tileData[$index_] = ($transparent) ? true : $tempPix;
+ $this->tileData[$address_] = ($transparent) ? true : $tempPix;
$this->tileReadState[$tileIndex] = 1;
- return $this->tileData[$index_];
+ return $this->tileData[$address_];
}
public function drawSpritesForLine($line)
@@ -1739,248 +1700,174 @@ class Core
//Memory Reading:
public function memoryRead($address)
{
- //Act as a wrapper for reading the returns from the compiled jumps to memory.
- return $this->memoryReader[$address]($this, $address); //This seems to be faster than the usual if/else.
- }
-
- public function memoryReadJumpCompile()
- {
- //Faster in some browsers, since we are doing less conditionals overall by implementing them in advance.
- for ($index = 0x0000; $index <= 0xFFFF; ++$index) {
- if ($index < 0x4000) {
- $this->memoryReader[$index] = function ($parentObj, $address) { //memoryReadNormal
- return $parentObj->memory[$address];
- };
- } elseif ($index < 0x8000) {
- $this->memoryReader[$index] = function ($parentObj, $address) { //memoryReadROM
- return $parentObj->ROM[$parentObj->currentROMBank + $address];
- };
- } elseif ($index >= 0x8000 && $index < 0xA000) {
- $VRAMReadCGBCPU = function ($parentObj, $address) {
- //CPU Side Reading The VRAM (Optimized for GameBoy Color)
- return ($parentObj->modeSTAT > 2) ? 0xFF : (($parentObj->currVRAMBank == 0) ? $parentObj->memory[$address] : $parentObj->VRAM[$address - 0x8000]);
- };
-
- $VRAMReadDMGCPU = function ($parentObj, $address) {
- //CPU Side Reading The VRAM (Optimized for classic GameBoy)
- return ($parentObj->modeSTAT > 2) ? 0xFF : $parentObj->memory[$address];
- };
+ if ($address < 0x4000) {
+ return $this->memory[$address];
+ } elseif ($address < 0x8000) {
+ return $this->ROM[$this->currentROMBank + $address];
+ } elseif ($address >= 0x8000 && $address < 0xA000) {
+ if ($this->cGBC) {
+ //CPU Side Reading The VRAM (Optimized for GameBoy Color)
+ return ($this->modeSTAT > 2) ? 0xFF : (($this->currVRAMBank == 0) ? $this->memory[$address] : $this->VRAM[$address - 0x8000]);
+ }
- $this->memoryReader[$index] = ($this->cGBC) ? $VRAMReadCGBCPU : $VRAMReadDMGCPU;
- } elseif ($index >= 0xA000 && $index < 0xC000) {
- if (($this->numRAMBanks == 1 / 16 && $index < 0xA200) || $this->numRAMBanks >= 1) {
- if (!$this->cMBC3) {
- $this->memoryReader[$index] = function ($parentObj, $address) { //memoryReadMBC
- //Switchable RAM
- if ($parentObj->MBCRAMBanksEnabled || Settings::$settings[10]) {
- return $parentObj->MBCRam[$address + $parentObj->currMBCRAMBankPosition];
- }
- //cout("Reading from disabled RAM.", 1);
- return 0xFF;
- };
- } else {
- //MBC3 RTC + RAM:
- $this->memoryReader[$index] = function ($parentObj, $address) { //memoryReadMBC3
- //Switchable RAM
- if ($parentObj->MBCRAMBanksEnabled || Settings::$settings[10]) {
- switch ($parentObj->currMBCRAMBank) {
- case 0x00:
- case 0x01:
- case 0x02:
- case 0x03:
- return $parentObj->MBCRam[$address + $parentObj->currMBCRAMBankPosition];
- break;
- case 0x08:
- return $parentObj->latchedSeconds;
- break;
- case 0x09:
- return $parentObj->latchedMinutes;
- break;
- case 0x0A:
- return $parentObj->latchedHours;
- break;
- case 0x0B:
- return $parentObj->latchedLDays;
- break;
- case 0x0C:
- return ((($parentObj->RTCDayOverFlow) ? 0x80 : 0) + (($parentObj->RTCHALT) ? 0x40 : 0)) + $parentObj->latchedHDays;
- }
- }
- //cout("Reading from invalid or disabled RAM.", 1);
- return 0xFF;
- };
+ //CPU Side Reading The VRAM (Optimized for classic GameBoy)
+ return ($this->modeSTAT > 2) ? 0xFF : $this->memory[$address];
+ } elseif ($address >= 0xA000 && $address < 0xC000) {
+ if (($this->numRAMBanks == 1 / 16 && $address < 0xA200) || $this->numRAMBanks >= 1) {
+ if (!$this->cMBC3) {
+ //memoryReadMBC
+ //Switchable RAM
+ if ($this->MBCRAMBanksEnabled || Settings::$settings[10]) {
+ return $this->MBCRam[$address + $this->currMBCRAMBankPosition];
}
+ //cout("Reading from disabled RAM.", 1);
+ return 0xFF;
} else {
- $this->memoryReader[$index] = function ($parentObj, $address) { //memoryReadBAD
- return 0xFF;
- };
- }
- } elseif ($index >= 0xC000 && $index < 0xE000) {
- if (!$this->cGBC || $index < 0xD000) {
- $this->memoryReader[$index] = function ($parentObj, $address) { //memoryReadNormal
- return $parentObj->memory[$address];
- };
- } else {
- $this->memoryReader[$index] = function ($parentObj, $address) { //memoryReadGBCMemory
- return $parentObj->GBCMemory[$address + $parentObj->gbcRamBankPosition];
- };
- }
- } elseif ($index >= 0xE000 && $index < 0xFE00) {
- if (!$this->cGBC || $index < 0xF000) {
- $this->memoryReader[$index] = function ($parentObj, $address) { //memoryReadECHONormal
- return $parentObj->memory[$address - 0x2000];
- };
- } else {
- $this->memoryReader[$index] = function ($parentObj, $address) { //memoryReadECHOGBCMemory
- return $parentObj->GBCMemory[$address + $parentObj->gbcRamBankPositionECHO];
- };
- }
- } elseif ($index < 0xFEA0) {
- $this->memoryReader[$index] = function ($parentObj, $address) { //memoryReadOAM
- return ($parentObj->modeSTAT > 1) ? 0xFF : $parentObj->memory[$address];
- };
- } elseif ($this->cGBC && $index >= 0xFEA0 && $index < 0xFF00) {
- $this->memoryReader[$index] = function ($parentObj, $address) { //memoryReadNormal
- return $parentObj->memory[$address];
- };
- } elseif ($index >= 0xFF00) {
- switch ($index) {
- case 0xFF00:
- $this->memoryReader[0xFF00] = function ($parentObj, $address) {
- return 0xC0 | $parentObj->memory[0xFF00]; //Top nibble returns as set.
- };
- break;
- case 0xFF01:
- $this->memoryReader[0xFF01] = function ($parentObj, $address) {
- return (($parentObj->memory[0xFF02] & 0x1) == 0x1) ? 0xFF : $parentObj->memory[0xFF01];
- };
- break;
- case 0xFF02:
- if ($this->cGBC) {
- $this->memoryReader[0xFF02] = function ($parentObj, $address) {
- return 0x7C | $parentObj->memory[0xFF02];
- };
- } else {
- $this->memoryReader[0xFF02] = function ($parentObj, $address) {
- return 0x7E | $parentObj->memory[0xFF02];
- };
+ //MBC3 RTC + RAM:
+ //memoryReadMBC3
+ //Switchable RAM
+ if ($this->MBCRAMBanksEnabled || Settings::$settings[10]) {
+ switch ($this->currMBCRAMBank) {
+ case 0x00:
+ case 0x01:
+ case 0x02:
+ case 0x03:
+ return $this->MBCRam[$address + $this->currMBCRAMBankPosition];
+ break;
+ case 0x08:
+ return $this->latchedSeconds;
+ break;
+ case 0x09:
+ return $this->latchedMinutes;
+ break;
+ case 0x0A:
+ return $this->latchedHours;
+ break;
+ case 0x0B:
+ return $this->latchedLDays;
+ break;
+ case 0x0C:
+ return ((($this->RTCDayOverFlow) ? 0x80 : 0) + (($this->RTCHALT) ? 0x40 : 0)) + $this->latchedHDays;
}
- break;
- case 0xFF07:
- $this->memoryReader[0xFF07] = function ($parentObj, $address) {
- return 0xF8 | $parentObj->memory[0xFF07];
- };
- break;
- case 0xFF0F:
- $this->memoryReader[0xFF0F] = function ($parentObj, $address) {
- return 0xE0 | $parentObj->memory[0xFF0F];
- };
- break;
- case 0xFF10:
- $this->memoryReader[0xFF10] = function ($parentObj, $address) {
- return 0x80 | $parentObj->memory[0xFF10];
- };
- break;
- case 0xFF11:
- $this->memoryReader[0xFF11] = function ($parentObj, $address) {
- return 0x3F | $parentObj->memory[0xFF11];
- };
- break;
- case 0xFF14:
- $this->memoryReader[0xFF14] = function ($parentObj, $address) {
- return 0xBF | $parentObj->memory[0xFF14];
- };
- break;
- case 0xFF16:
- $this->memoryReader[0xFF16] = function ($parentObj, $address) {
- return 0x3F | $parentObj->memory[0xFF16];
- };
- break;
- case 0xFF19:
- $this->memoryReader[0xFF19] = function ($parentObj, $address) {
- return 0xBF | $parentObj->memory[0xFF19];
- };
- break;
- case 0xFF1A:
- $this->memoryReader[0xFF1A] = function ($parentObj, $address) {
- return 0x7F | $parentObj->memory[0xFF1A];
- };
- break;
- case 0xFF1B:
- $this->memoryReader[0xFF1B] = function ($parentObj, $address) {
- return 0xFF;
- };
- break;
- case 0xFF1C:
- $this->memoryReader[0xFF1C] = function ($parentObj, $address) {
- return 0x9F | $parentObj->memory[0xFF1C];
- };
- break;
- case 0xFF1E:
- $this->memoryReader[0xFF1E] = function ($parentObj, $address) {
- return 0xBF | $parentObj->memory[0xFF1E];
- };
- break;
- case 0xFF20:
- $this->memoryReader[0xFF20] = function ($parentObj, $address) {
- return 0xFF;
- };
- break;
- case 0xFF23:
- $this->memoryReader[0xFF23] = function ($parentObj, $address) {
- return 0xBF | $parentObj->memory[0xFF23];
- };
- break;
- case 0xFF26:
- $this->memoryReader[0xFF26] = function ($parentObj, $address) {
- return 0x70 | $parentObj->memory[0xFF26];
- };
- break;
- case 0xFF30:
- case 0xFF31:
- case 0xFF32:
- case 0xFF33:
- case 0xFF34:
- case 0xFF35:
- case 0xFF36:
- case 0xFF37:
- case 0xFF38:
- case 0xFF39:
- case 0xFF3A:
- case 0xFF3B:
- case 0xFF3C:
- case 0xFF3D:
- case 0xFF3E:
- case 0xFF3F:
- $this->memoryReader[$index] = function ($parentObj, $address) {
- return (($parentObj->memory[0xFF26] & 0x4) == 0x4) ? 0xFF : $parentObj->memory[$address];
- };
- break;
- case 0xFF41:
- $this->memoryReader[0xFF41] = function ($parentObj, $address) {
- return 0x80 | $parentObj->memory[0xFF41] | $parentObj->modeSTAT;
- };
- break;
- case 0xFF44:
- $this->memoryReader[0xFF44] = function ($parentObj, $address) {
- return ($parentObj->LCDisOn) ? $parentObj->memory[0xFF44] : 0;
- };
- break;
- case 0xFF4F:
- $this->memoryReader[0xFF4F] = function ($parentObj, $address) {
- return $parentObj->currVRAMBank;
- };
- break;
- default:
- $this->memoryReader[$index] = function ($parentObj, $address) { //memoryReadNormal
- return $parentObj->memory[$address];
- };
+ }
+ //cout("Reading from invalid or disabled RAM.", 1);
+ return 0xFF;
}
} else {
- $this->memoryReader[$index] = function ($parentObj, $address) { //memoryReadBAD
+ return 0xFF;
+ }
+ } elseif ($address >= 0xC000 && $address < 0xE000) {
+ if (!$this->cGBC || $address < 0xD000) {
+ return $this->memory[$address];
+ } else {
+ //memoryReadGBCMemory
+ return $this->GBCMemory[$address + $this->gbcRamBankPosition];
+ }
+ } elseif ($address >= 0xE000 && $address < 0xFE00) {
+ if (!$this->cGBC || $address < 0xF000) {
+ //memoryReadECHONormal
+ return $this->memory[$address - 0x2000];
+ } else {
+ //memoryReadECHOGBCMemory
+ return $this->GBCMemory[$address + $this->gbcRamBankPositionECHO];
+ }
+ } elseif ($address < 0xFEA0) {
+ //memoryReadOAM
+ return ($this->modeSTAT > 1) ? 0xFF : $this->memory[$address];
+ } elseif ($this->cGBC && $address >= 0xFEA0 && $address < 0xFF00) {
+ //memoryReadNormal
+ return $this->memory[$address];
+ } elseif ($address >= 0xFF00) {
+ switch ($address) {
+ case 0xFF00:
+ return 0xC0 | $this->memory[0xFF00]; //Top nibble returns as set.
+ break;
+ case 0xFF01:
+ return (($this->memory[0xFF02] & 0x1) == 0x1) ? 0xFF : $this->memory[0xFF01];
+ break;
+ case 0xFF02:
+ if ($this->cGBC) {
+ return 0x7C | $this->memory[0xFF02];
+ } else {
+ return 0x7E | $this->memory[0xFF02];
+ }
+ break;
+ case 0xFF07:
+ return 0xF8 | $this->memory[0xFF07];
+ break;
+ case 0xFF0F:
+ return 0xE0 | $this->memory[0xFF0F];
+ break;
+ case 0xFF10:
+ return 0x80 | $this->memory[0xFF10];
+ break;
+ case 0xFF11:
+ return 0x3F | $this->memory[0xFF11];
+ break;
+ case 0xFF14:
+ return 0xBF | $this->memory[0xFF14];
+ break;
+ case 0xFF16:
+ return 0x3F | $this->memory[0xFF16];
+ break;
+ case 0xFF19:
+ return 0xBF | $this->memory[0xFF19];
+ break;
+ case 0xFF1A:
+ return 0x7F | $this->memory[0xFF1A];
+ break;
+ case 0xFF1B:
return 0xFF;
- };
+ break;
+ case 0xFF1C:
+ return 0x9F | $this->memory[0xFF1C];
+ break;
+ case 0xFF1E:
+ return 0xBF | $this->memory[0xFF1E];
+ break;
+ case 0xFF20:
+ return 0xFF;
+ break;
+ case 0xFF23:
+ return 0xBF | $this->memory[0xFF23];
+ break;
+ case 0xFF26:
+ return 0x70 | $this->memory[0xFF26];
+ break;
+ case 0xFF30:
+ case 0xFF31:
+ case 0xFF32:
+ case 0xFF33:
+ case 0xFF34:
+ case 0xFF35:
+ case 0xFF36:
+ case 0xFF37:
+ case 0xFF38:
+ case 0xFF39:
+ case 0xFF3A:
+ case 0xFF3B:
+ case 0xFF3C:
+ case 0xFF3D:
+ case 0xFF3E:
+ case 0xFF3F:
+ return (($this->memory[0xFF26] & 0x4) == 0x4) ? 0xFF : $this->memory[$address];
+ break;
+ case 0xFF41:
+ return 0x80 | $this->memory[0xFF41] | $this->modeSTAT;
+ break;
+ case 0xFF44:
+ return ($this->LCDisOn) ? $this->memory[0xFF44] : 0;
+ break;
+ case 0xFF4F:
+ return $this->currVRAMBank;
+ break;
+ default:
+ //memoryReadNormal
+ return $this->memory[$address];
}
+ } else {
+ //memoryReadBAD
+ return 0xFF;
}
}
@@ -2052,19 +1939,19 @@ class Core
};
//Faster in some browsers, since we are doing less conditionals overall by implementing them in advance.
- for ($index = 0x0000; $index <= 0xFFFF; ++$index) {
- if ($index < 0x8000) {
+ for ($address = 0x0000; $address <= 0xFFFF; ++$address) {
+ if ($address < 0x8000) {
if ($this->cMBC1) {
- if ($index < 0x2000) {
- $this->memoryWriter[$index] = $MBCWriteEnable;
- } elseif ($index < 0x4000) {
- $this->memoryWriter[$index] = function ($parentObj, $address, $data) { // MBC1WriteROMBank
+ if ($address < 0x2000) {
+ $this->memoryWriter[$address] = $MBCWriteEnable;
+ } elseif ($address < 0x4000) {
+ $this->memoryWriter[$address] = function ($parentObj, $address, $data) { // MBC1WriteROMBank
//MBC1 ROM bank switching:
$parentObj->ROMBank1offs = ($parentObj->ROMBank1offs & 0x60) | ($data & 0x1F);
$parentObj->setCurrentMBC1ROMBank();
};
- } elseif ($index < 0x6000) {
- $this->memoryWriter[$index] = function ($parentObj, $address, $data) { //MBC1WriteRAMBank
+ } elseif ($address < 0x6000) {
+ $this->memoryWriter[$address] = function ($parentObj, $address, $data) { //MBC1WriteRAMBank
//MBC1 RAM bank switching
if ($parentObj->MBC1Mode) {
//4/32 Mode
@@ -2077,30 +1964,30 @@ class Core
}
};
} else {
- $this->memoryWriter[$index] = function ($parentObj, $address, $data) { //MBC1WriteType
+ $this->memoryWriter[$address] = function ($parentObj, $address, $data) { //MBC1WriteType
//MBC1 mode setting:
$parentObj->MBC1Mode = (($data & 0x1) == 0x1);
};
}
} elseif ($this->cMBC2) {
- if ($index < 0x1000) {
- $this->memoryWriter[$index] = $MBCWriteEnable;
- } elseif ($index >= 0x2100 && $index < 0x2200) {
- $this->memoryWriter[$index] = function ($parentObj, $address, $data) { //MBC2WriteROMBank
+ if ($address < 0x1000) {
+ $this->memoryWriter[$address] = $MBCWriteEnable;
+ } elseif ($address >= 0x2100 && $address < 0x2200) {
+ $this->memoryWriter[$address] = function ($parentObj, $address, $data) { //MBC2WriteROMBank
//MBC2 ROM bank switching:
$parentObj->ROMBank1offs = $data & 0x0F;
$parentObj->setCurrentMBC2AND3ROMBank();
};
} else {
- $this->memoryWriter[$index] = $cartIgnoreWrite;
+ $this->memoryWriter[$address] = $cartIgnoreWrite;
}
} elseif ($this->cMBC3) {
- if ($index < 0x2000) {
- $this->memoryWriter[$index] = $MBCWriteEnable;
- } elseif ($index < 0x4000) {
- $this->memoryWriter[$index] = $MBC3WriteROMBank;
- } elseif ($index < 0x6000) {
- $this->memoryWriter[$index] = function ($parentObj, $address, $data) { //MBC3WriteRAMBank
+ if ($address < 0x2000) {
+ $this->memoryWriter[$address] = $MBCWriteEnable;
+ } elseif ($address < 0x4000) {
+ $this->memoryWriter[$address] = $MBC3WriteROMBank;
+ } elseif ($address < 0x6000) {
+ $this->memoryWriter[$address] = function ($parentObj, $address, $data) { //MBC3WriteRAMBank
$parentObj->currMBCRAMBank = $data;
if ($data < 4) {
//MBC3 RAM bank switching
@@ -2108,7 +1995,7 @@ class Core
}
};
} else {
- $this->memoryWriter[$index] = function ($parentObj, $address, $data) { //MBC3WriteRTCLatch
+ $this->memoryWriter[$address] = function ($parentObj, $address, $data) { //MBC3WriteRTCLatch
if ($data == 0) {
$parentObj->RTCisLatched = false;
} elseif (!$parentObj->RTCisLatched) {
@@ -2123,21 +2010,21 @@ class Core
};
}
} elseif ($this->cMBC5 || $this->cRUMBLE) {
- if ($index < 0x2000) {
- $this->memoryWriter[$index] = $MBCWriteEnable;
- } elseif ($index < 0x3000) {
- $this->memoryWriter[$index] = function ($parentObj, $address, $data) { //MBC5WriteROMBankLow
+ if ($address < 0x2000) {
+ $this->memoryWriter[$address] = $MBCWriteEnable;
+ } elseif ($address < 0x3000) {
+ $this->memoryWriter[$address] = function ($parentObj, $address, $data) { //MBC5WriteROMBankLow
//MBC5 ROM bank switching:
$parentObj->ROMBank1offs = ($parentObj->ROMBank1offs & 0x100) | $data;
$parentObj->setCurrentMBC5ROMBank();
};
- } elseif ($index < 0x4000) {
- $this->memoryWriter[$index] = function ($parentObj, $address, $data) { //MBC5WriteROMBankHigh
+ } elseif ($address < 0x4000) {
+ $this->memoryWriter[$address] = function ($parentObj, $address, $data) { //MBC5WriteROMBankHigh
//MBC5 ROM bank switching (by least significant bit):
$parentObj->ROMBank1offs = (($data & 0x01) << 8) | ($parentObj->ROMBank1offs & 0xFF);
$parentObj->setCurrentMBC5ROMBank();
};
- } elseif ($index < 0x6000) {
+ } elseif ($address < 0x6000) {
$RUMBLEWriteRAMBank = function ($parentObj, $address, $data) {
//MBC5 RAM bank switching
//Like MBC5, but bit 3 of the lower nibble is used for rumbling and bit 2 is ignored.
@@ -2151,31 +2038,31 @@ class Core
$parentObj->currMBCRAMBankPosition = ($parentObj->currMBCRAMBank << 13) - 0xA000;
};
- $this->memoryWriter[$index] = ($this->cRUMBLE) ? $RUMBLEWriteRAMBank : $MBC5WriteRAMBank;
+ $this->memoryWriter[$address] = ($this->cRUMBLE) ? $RUMBLEWriteRAMBank : $MBC5WriteRAMBank;
} else {
- $this->memoryWriter[$index] = $cartIgnoreWrite;
+ $this->memoryWriter[$address] = $cartIgnoreWrite;
}
} elseif ($this->cHuC3) {
- if ($index < 0x2000) {
- $this->memoryWriter[$index] = $MBCWriteEnable;
- } elseif ($index < 0x4000) {
- $this->memoryWriter[$index] = $MBC3WriteROMBank;
- } elseif ($index < 0x6000) {
+ if ($address < 0x2000) {
+ $this->memoryWriter[$address] = $MBCWriteEnable;
+ } elseif ($address < 0x4000) {
+ $this->memoryWriter[$address] = $MBC3WriteROMBank;
+ } elseif ($address < 0x6000) {
//HuC3WriteRAMBank
- $this->memoryWriter[$index] = function ($parentObj, $address, $data) {
+ $this->memoryWriter[$address] = function ($parentObj, $address, $data) {
//HuC3 RAM bank switching
$parentObj->currMBCRAMBank = $data & 0x03;
$parentObj->currMBCRAMBankPosition = ($parentObj->currMBCRAMBank << 13) - 0xA000;
};
} else {
- $this->memoryWriter[$index] = $cartIgnoreWrite;
+ $this->memoryWriter[$address] = $cartIgnoreWrite;
}
} else {
- $this->memoryWriter[$index] = $cartIgnoreWrite;
+ $this->memoryWriter[$address] = $cartIgnoreWrite;
}
- } elseif ($index < 0xA000) {
+ } elseif ($address < 0xA000) {
// VRAMWrite
- $this->memoryWriter[$index] = function ($parentObj, $address, $data) {
+ $this->memoryWriter[$address] = function ($parentObj, $address, $data) {
//VRAM cannot be written to during mode 3
if ($parentObj->modeSTAT < 3) {
// Bkg Tile data area
@@ -2197,17 +2084,17 @@ class Core
}
}
};
- } elseif ($index < 0xC000) {
- if (($this->numRAMBanks == 1 / 16 && $index < 0xA200) || $this->numRAMBanks >= 1) {
+ } elseif ($address < 0xC000) {
+ if (($this->numRAMBanks == 1 / 16 && $address < 0xA200) || $this->numRAMBanks >= 1) {
if (!$this->cMBC3) {
- $this->memoryWriter[$index] = function ($parentObj, $address, $data) { //memoryWriteMBCRAM
+ $this->memoryWriter[$address] = function ($parentObj, $address, $data) { //memoryWriteMBCRAM
if ($parentObj->MBCRAMBanksEnabled || Settings::$settings[10]) {
$parentObj->MBCRam[$address + $parentObj->currMBCRAMBankPosition] = $data;
}
};
} else {
//MBC3 RTC + RAM:
- $this->memoryWriter[$index] = function ($parentObj, $address, $data) { //memoryWriteMBC3RAM
+ $this->memoryWriter[$address] = function ($parentObj, $address, $data) { //memoryWriteMBC3RAM
if ($parentObj->MBCRAMBanksEnabled || Settings::$settings[10]) {
switch ($parentObj->currMBCRAMBank) {
case 0x00:
@@ -2252,52 +2139,52 @@ class Core
};
}
} else {
- $this->memoryWriter[$index] = $cartIgnoreWrite;
+ $this->memoryWriter[$address] = $cartIgnoreWrite;
}
- } elseif ($index < 0xE000) {
- if ($this->cGBC && $index >= 0xD000) {
- $this->memoryWriter[$index] = function ($parentObj, $address, $data) { //memoryWriteGBCRAM
+ } elseif ($address < 0xE000) {
+ if ($this->cGBC && $address >= 0xD000) {
+ $this->memoryWriter[$address] = function ($parentObj, $address, $data) { //memoryWriteGBCRAM
$parentObj->GBCMemory[$address + $parentObj->gbcRamBankPosition] = $data;
};
} else {
- $this->memoryWriter[$index] = function ($parentObj, $address, $data) { //memoryWriteNormal
+ $this->memoryWriter[$address] = function ($parentObj, $address, $data) { //memoryWriteNormal
$parentObj->memory[$address] = $data;
};
}
- } elseif ($index < 0xFE00) {
- if ($this->cGBC && $index >= 0xF000) {
+ } elseif ($address < 0xFE00) {
+ if ($this->cGBC && $address >= 0xF000) {
//memoryWriteECHOGBCRAM
- $this->memoryWriter[$index] = function ($parentObj, $address, $data) {
+ $this->memoryWriter[$address] = function ($parentObj, $address, $data) {
$parentObj->GBCMemory[$address + $parentObj->gbcRamBankPositionECHO] = $data;
};
} else {
//memoryWriteECHONormal
- $this->memoryWriter[$index] = function ($parentObj, $address, $data) {
+ $this->memoryWriter[$address] = function ($parentObj, $address, $data) {
$parentObj->memory[$address - 0x2000] = $data;
};
}
- } elseif ($index <= 0xFEA0) {
+ } elseif ($address <= 0xFEA0) {
//memoryWriteOAMRAM
- $this->memoryWriter[$index] = function ($parentObj, $address, $data) {
+ $this->memoryWriter[$address] = function ($parentObj, $address, $data) {
//OAM RAM cannot be written to in mode 2 & 3
if ($parentObj->modeSTAT < 2) {
$parentObj->memory[$address] = $data;
}
};
- } elseif ($index < 0xFF00) {
+ } elseif ($address < 0xFF00) {
//Only GBC has access to this RAM.
if ($this->cGBC) {
//memoryWriteNormal
- $this->memoryWriter[$index] = function ($parentObj, $address, $data) {
+ $this->memoryWriter[$address] = function ($parentObj, $address, $data) {
$parentObj->memory[$address] = $data;
};
} else {
- $this->memoryWriter[$index] = $cartIgnoreWrite;
+ $this->memoryWriter[$address] = $cartIgnoreWrite;
}
} else {
//Start the I/O initialization by filling in the slots as normal memory:
//memoryWriteNormal
- $this->memoryWriter[$index] = function ($parentObj, $address, $data) {
+ $this->memoryWriter[$address] = function ($parentObj, $address, $data) {
$parentObj->memory[$address] = $data;
};
}
@@ -2343,7 +2230,7 @@ class Core
$data <<= 8;
$address = 0xFE00;
while ($address < 0xFEA0) {
- $parentObj->memory[$address++] = $parentObj->memoryReader[$data]($parentObj, $data++);
+ $parentObj->memory[$address++] = $parentObj->memoryRead($data++);
}
}
};
@@ -2625,8 +2512,8 @@ class Core
{
try {
$typedArrayTemp = ($bit32) ? (($unsigned) ? new Uint32Array(count($baseArray)) : new Int32Array(count($baseArray))) : new Uint8Array(count($baseArray));
- for ($index = 0; $index < count($baseArray); ++$index) {
- $typedArrayTemp[$index] = $baseArray[$index];
+ for ($address = 0; $address < count($baseArray); ++$address) {
+ $typedArrayTemp[$address] = $baseArray[$address];
}
return $typedArrayTemp;
@@ -2641,8 +2528,8 @@ class Core
{
try {
$arrayTemp = array_fill(0, count($baseArray), 0);
- for ($index = 0; $index < count($baseArray); ++$index) {
- $arrayTemp[$index] = $baseArray[$index];
+ for ($address = 0; $address < count($baseArray); ++$address) {
+ $arrayTemp[$address] = $baseArray[$address];
}
return $arrayTemp;
diff --git a/src/Opcode.php b/src/Opcode.php
index cf767ef..8746b99 100644
--- a/src/Opcode.php
+++ b/src/Opcode.php
@@ -26,7 +26,7 @@ class Opcode
*
* @param Core $core
*/
- private static function opcode0(Core $core)
+ public static function opcode0(Core $core)
{
// Do Nothing...
}
@@ -38,9 +38,9 @@ class Opcode
*
* @param Core $core
*/
- private static function opcode1(Core $core)
+ public static function opcode1(Core $core)
{
- $core->registerC = $core->memoryReader[$core->programCounter]($core, $core->programCounter);
+ $core->registerC = $core->memoryRead($core->programCounter);
$core->registerB = $core->memoryRead(($core->programCounter + 1) & 0xFFFF);
$core->programCounter = ($core->programCounter + 2) & 0xFFFF;
}
@@ -52,7 +52,7 @@ class Opcode
*
* @param Core $core
*/
- private static function opcode2(Core $core)
+ public static function opcode2(Core $core)
{
$core->memoryWrite(($core->registerB << 8) + $core->registerC, $core->registerA);
}
@@ -64,7 +64,7 @@ class Opcode
*
* @param Core $core
*/
- private static function opcode3(Core $core)
+ public static function opcode3(Core $core)
{
$temp_var = ((($core->registerB << 8) + $core->registerC) + 1);
$core->registerB = (($temp_var >> 8) & 0xFF);
@@ -78,7 +78,7 @@ class Opcode
*
* @param Core $core
*/
- private static function opcode4(Core $core)
+ public static function opcode4(Core $core)
{
$core->registerB = (($core->registerB + 1) & 0xFF);
$core->FZero = ($core->registerB == 0);
@@ -93,7 +93,7 @@ class Opcode
*
* @param Core $core
*/
- private static function opcode5(Core $core)
+ public static function opcode5(Core $core)
{
$core->registerB = $core->unsbtub($core->registerB - 1);
$core->FZero = ($core->registerB == 0);
@@ -108,9 +108,9 @@ class Opcode
*
* @param Core $core
*/
- private static function opcode6(Core $core)
+ public static function opcode6(Core $core)
{
- $core->registerB = $core->memoryReader[$core->programCounter]($core, $core->programCounter);
+ $core->registerB = $core->memoryRead($core->programCounter);
$core->programCounter = ($core->programCounter + 1) & 0xFFFF;
}
@@ -121,7 +121,7 @@ class Opcode
*
* @param Core $core
*/
- private static function opcode7(Core $core)
+ public static function opcode7(Core $core)
{
$core->FCarry = (($core->registerA & 0x80) == 0x80);
$core->registerA = (($core->registerA << 1) & 0xFF) | ($core->registerA >> 7);
@@ -135,9 +135,9 @@ class Opcode
*
* @param Core $core
*/
- private static function opcode8(Core $core)
+ public static function opcode8(Core $core)
{
- $temp_var = ($core->memoryRead(($core->programCounter + 1) & 0xFFFF) << 8) + $core->memoryReader[$core->programCounter]($core, $core->programCounter);
+ $temp_var = ($core->memoryRead(($core->programCounter + 1) & 0xFFFF) << 8) + $core->memoryRead($core->programCounter);
$core->memoryWrite($temp_var, $core->stackPointer & 0xFF);
$core->memoryWrite(($temp_var + 1) & 0xFFFF, $core->stackPointer >> 8);
$core->programCounter = ($core->programCounter + 2) & 0xFFFF;
@@ -150,7 +150,7 @@ class Opcode
*
* @param Core $core
*/
- private static function opcode9(Core $core)
+ public static function opcode9(Core $core)
{
$n2 = ($core->registerB << 8) + $core->registerC;
$dirtySum = $core->registersHL + $n2;
@@ -167,7 +167,7 @@ class Opcode
*
* @param Core $core
*/
- private static function opcode10(Core $core)
+ public static function opcode10(Core $core)
{
$core->registerA = $core->memoryRead(($core->registerB << 8) + $core->registerC);
}
@@ -179,7 +179,7 @@ class Opcode
*
* @param Core $core
*/
- private static function opcode11(Core $core)
+ public static function opcode11(Core $core)
{
$temp_var = $core->unswtuw((($core->registerB << 8) + $core->registerC) - 1);
$core->registerB = ($temp_var >> 8);
@@ -193,7 +193,7 @@ class Opcode
*
* @param Core $core
*/
- private static function opcode12(Core $core)
+ public static function opcode12(Core $core)
{
$core->registerC = (($core->registerC + 1) & 0xFF);
$core->FZero = ($core->registerC == 0);
@@ -208,7 +208,7 @@ class Opcode
*
* @param Core $core
*/
- private static function opcode13(Core $core)
+ public static function opcode13(Core $core)
{
$core->registerC = $core->unsbtub($core->registerC - 1);
$core->FZero = ($core->registerC == 0);
@@ -223,9 +223,9 @@ class Opcode
*
* @param Core $core
*/
- private static function opcode14(Core $core)
+ public static function opcode14(Core $core)
{
- $core->registerC = $core->memoryReader[$core->programCounter]($core, $core->programCounter);
+ $core->registerC = $core->memoryRead($core->programCounter);
$core->programCounter = ($core->programCounter + 1) & 0xFFFF;
}
@@ -236,7 +236,7 @@ class Opcode
*
* @param Core $core
*/
- private static function opcode15(Core $core)
+ public static function opcode15(Core $core)
{
$core->FCarry = (($core->registerA & 1) == 1);
$core->registerA = ($core->registerA >> 1) + (($core->registerA & 1) << 7);
@@ -250,7 +250,7 @@ class Opcode
*
* @param Core $core
*/
- private static function opcode16(Core $core)
+ public static function opcode16(Core $core)
{
if ($core->cGBC) {
/*TODO: Emulate the speed switch delay:
@@ -285,9 +285,9 @@ class Opcode
*
* @param Core $core
*/
- private static function opcode17(Core $core)
+ public static function opcode17(Core $core)
{
- $core->registerE = $core->memoryReader[$core->programCounter]($core, $core->programCounter);
+ $core->registerE = $core->memoryRead($core->programCounter);
$core->registerD = $core->memoryRead(($core->programCounter + 1) & 0xFFFF);
$core->programCounter = ($core->programCounter + 2) & 0xFFFF;
}
@@ -299,7 +299,7 @@ class Opcode
*
* @param Core $core
*/
- private static function opcode18(Core $core)
+ public static function opcode18(Core $core)
{
$core->memoryWrite(($core->registerD << 8) + $core->registerE, $core->registerA);
}
@@ -311,7 +311,7 @@ class Opcode
*
* @param Core $core
*/
- private static function opcode19(Core $core)
+ public static function opcode19(Core $core)
{
$temp_var = ((($core->registerD << 8) + $core->registerE) + 1);
$core->registerD = (($temp_var >> 8) & 0xFF);
@@ -325,7 +325,7 @@ class Opcode
*
* @param Core $core
*/
- private static function opcode20(Core $core)
+ public static function opcode20(Core $core)
{
$core->registerD = (($core->registerD + 1) & 0xFF);
$core->FZero = ($core->registerD == 0);
@@ -340,7 +340,7 @@ class Opcode
*
* @param Core $core
*/
- private static function opcode21(Core $core)
+ public static function opcode21(Core $core)
{
$core->registerD = $core->unsbtub($core->registerD - 1);
$core->FZero = ($core->registerD == 0);
@@ -355,9 +355,9 @@ class Opcode
*
* @param Core $core
*/
- private static function opcode22(Core $core)
+ public static function opcode22(Core $core)
{
- $core->registerD = $core->memoryReader[$core->programCounter]($core, $core->programCounter);
+ $core->registerD = $core->memoryRead($core->programCounter);
$core->programCounter = ($core->programCounter + 1) & 0xFFFF;
}
@@ -368,7 +368,7 @@ class Opcode
*
* @param Core $core
*/
- private static function opcode23(Core $core)
+ public static function opcode23(Core $core)
{
$carry_flag = ($core->FCarry) ? 1 : 0;
$core->FCarry = (($core->registerA & 0x80) == 0x80);
@@ -383,9 +383,9 @@ class Opcode
*
* @param Core $core
*/
- private static function opcode24(Core $core)
+ public static function opcode24(Core $core)
{
- $core->programCounter = $core->nswtuw($core->programCounter + $core->usbtsb($core->memoryReader[$core->programCounter]($core, $core->programCounter)) + 1);
+ $core->programCounter = $core->nswtuw($core->programCounter + $core->usbtsb($core->memoryRead($core->programCounter)) + 1);
}
/**
@@ -395,7 +395,7 @@ class Opcode
*
* @param Core $core
*/
- private static function opcode25(Core $core)
+ public static function opcode25(Core $core)
{
$n2 = ($core->registerD << 8) + $core->registerE;
$dirtySum = $core->registersHL + $n2;
@@ -412,7 +412,7 @@ class Opcode
*
* @param Core $core
*/
- private static function opcode26(Core $core)
+ public static function opcode26(Core $core)
{
$core->registerA = $core->memoryRead(($core->registerD << 8) + $core->registerE);
}
@@ -424,7 +424,7 @@ class Opcode
*
* @param Core $core
*/
- private static function opcode27(Core $core)
+ public static function opcode27(Core $core)
{
$temp_var = $core->unswtuw((($core->registerD << 8) + $core->registerE) - 1);
$core->registerD = ($temp_var >> 8);
@@ -438,7 +438,7 @@ class Opcode
*
* @param Core $core
*/
- private static function opcode28(Core $core)
+ public static function opcode28(Core $core)
{
$core->registerE = (($core->registerE + 1) & 0xFF);
$core->FZero = ($core->registerE == 0);
@@ -453,7 +453,7 @@ class Opcode
*
* @param Core $core
*/
- private static function opcode29(Core $core)
+ public static function opcode29(Core $core)
{
$core->registerE = $core->unsbtub($core->registerE - 1);
$core->FZero = ($core->registerE == 0);
@@ -468,9 +468,9 @@ class Opcode
*
* @param Core $core
*/
- private static function opcode30(Core $core)
+ public static function opcode30(Core $core)
{
- $core->registerE = $core->memoryReader[$core->programCounter]($core, $core->programCounter);
+ $core->registerE = $core->memoryRead($core->programCounter);
$core->programCounter = ($core->programCounter + 1) & 0xFFFF;
}
@@ -481,7 +481,7 @@ class Opcode
*
* @param Core $core
*/
- private static function opcode31(Core $core)
+ public static function opcode31(Core $core)
{
$carry_flag = ($core->FCarry) ? 0x80 : 0;
$core->FCarry = (($core->registerA & 1) == 1);
@@ -496,10 +496,10 @@ class Opcode
*
* @param Core $core
*/
- private static function opcode32(Core $core)
+ public static function opcode32(Core $core)
{
if (!$core->FZero) {
- $core->programCounter = $core->nswtuw($core->programCounter + $core->usbtsb($core->memoryReader[$core->programCounter]($core, $core->programCounter)) + 1);
+ $core->programCounter = $core->nswtuw($core->programCounter + $core->usbtsb($core->memoryRead($core->programCounter)) + 1);
++$core->CPUTicks;
} else {
$core->programCounter = ($core->programCounter + 1) & 0xFFFF;
@@ -513,9 +513,9 @@ class Opcode
*
* @param Core $core
*/
- private static function opcode33(Core $core)
+ public static function opcode33(Core $core)
{
- $core->registersHL = ($core->memoryRead(($core->programCounter + 1) & 0xFFFF) << 8) + $core->memoryReader[$core->programCounter]($core, $core->programCounter);
+ $core->registersHL = ($core->memoryRead(($core->programCounter + 1) & 0xFFFF) << 8) + $core->memoryRead($core->programCounter);
$core->programCounter = ($core->programCounter + 2) & 0xFFFF;
}
@@ -526,7 +526,7 @@ class Opcode
*
* @param Core $core
*/
- private static function opcode34(Core $core)
+ public static function opcode34(Core $core)
{
$core->memoryWrite($core->registersHL, $core->registerA);
$core->registersHL = (($core->registersHL + 1) & 0xFFFF);
@@ -539,7 +539,7 @@ class Opcode
*
* @param Core $core
*/
- private static function opcode35(Core $core)
+ public static function opcode35(Core $core)
{
$core->registersHL = (($core->registersHL + 1) & 0xFFFF);
}
@@ -551,7 +551,7 @@ class Opcode
*
* @param Core $core
*/
- private static function opcode36(Core $core)
+ public static function opcode36(Core $core)
{
$H = ((($core->registersHL >> 8) + 1) & 0xFF);
$core->FZero = ($H == 0);
@@ -567,7 +567,7 @@ class Opcode
*
* @param Core $core
*/
- private static function opcode37(Core $core)
+ public static function opcode37(Core $core)
{
$H = $core->unsbtub(($core->registersHL >> 8) - 1);
$core->FZero = ($H == 0);
@@ -583,9 +583,9 @@ class Opcode
*
* @param Core $core
*/
- private static function opcode38(Core $core)
+ public static function opcode38(Core $core)
{
- $core->registersHL = ($core->memoryReader[$core->programCounter]($core, $core->programCounter) << 8) + ($core->registersHL & 0xFF);
+ $core->registersHL = ($core->memoryRead($core->programCounter) << 8) + ($core->registersHL & 0xFF);
$core->programCounter = ($core->programCounter + 1) & 0xFFFF;
}
@@ -596,7 +596,7 @@ class Opcode
*
* @param Core $core
*/
- private static function opcode39(Core $core)
+ public static function opcode39(Core $core)
{
$temp_var = $core->registerA;
if ($core->FCarry) {
@@ -622,10 +622,10 @@ class Opcode
*
* @param Core $core
*/
- private static function opcode40(Core $core)
+ public static function opcode40(Core $core)
{
if ($core->FZero) {
- $core->programCounter = $core->nswtuw($core->programCounter + $core->usbtsb($core->memoryReader[$core->programCounter]($core, $core->programCounter)) + 1);
+ $core->programCounter = $core->nswtuw($core->programCounter + $core->usbtsb($core->memoryRead($core->programCounter)) + 1);
++$core->CPUTicks;
} else {
$core->programCounter = ($core->programCounter + 1) & 0xFFFF;
@@ -639,7 +639,7 @@ class Opcode
*
* @param Core $core
*/
- private static function opcode41(Core $core)
+ public static function opcode41(Core $core)
{
;
$core->FHalfCarry = (($core->registersHL & 0xFFF) > 0x7FF);
@@ -655,9 +655,9 @@ class Opcode
*
* @param Core $core
*/
- private static function opcode42(Core $core)
+ public static function opcode42(Core $core)
{
- $core->registerA = $core->memoryReader[$core->registersHL]($core, $core->registersHL);
+ $core->registerA = $core->memoryRead($core->registersHL);
$core->registersHL = (($core->registersHL + 1) & 0xFFFF);
}
@@ -668,7 +668,7 @@ class Opcode
*
* @param Core $core
*/
- private static function opcode43(Core $core)
+ public static function opcode43(Core $core)
{
$core->registersHL = $core->unswtuw($core->registersHL - 1);
}
@@ -680,7 +680,7 @@ class Opcode
*
* @param Core $core
*/
- private static function opcode44(Core $core)
+ public static function opcode44(Core $core)
{
$L = (($core->registersHL + 1) & 0xFF);
$core->FZero = ($L == 0);
@@ -696,7 +696,7 @@ class Opcode
*
* @param Core $core
*/
- private static function opcode45(Core $core)
+ public static function opcode45(Core $core)
{
$L = $core->unsbtub(($core->registersHL & 0xFF) - 1);
$core->FZero = ($L == 0);
@@ -712,9 +712,9 @@ class Opcode
*
* @param Core $core
*/
- private static function opcode46(Core $core)
+ public static function opcode46(Core $core)
{
- $core->registersHL = ($core->registersHL & 0xFF00) + $core->memoryReader[$core->programCounter]($core, $core->programCounter);
+ $core->registersHL = ($core->registersHL & 0xFF00) + $core->memoryRead($core->programCounter);
$core->programCounter = ($core->programCounter + 1) & 0xFFFF;
}
@@ -725,7 +725,7 @@ class Opcode
*
* @param Core $core
*/
- private static function opcode47(Core $core)
+ public static function opcode47(Core $core)
{
$core->registerA ^= 0xFF;
$core->FSubtract = $core->FHalfCarry = true;
@@ -738,10 +738,10 @@ class Opcode
*
* @param Core $core
*/
- private static function opcode48(Core $core)
+ public static function opcode48(Core $core)
{
if (!$core->FCarry) {
- $core->programCounter = $core->nswtuw($core->programCounter + $core->usbtsb($core->memoryReader[$core->programCounter]($core, $core->programCounter)) + 1);
+ $core->programCounter = $core->nswtuw($core->programCounter + $core->usbtsb($core->memoryRead($core->programCounter)) + 1);
++$core->CPUTicks;
} else {
$core->programCounter = ($core->programCounter + 1) & 0xFFFF;
@@ -755,9 +755,9 @@ class Opcode
*
* @param Core $core
*/
- private static function opcode49(Core $core)
+ public static function opcode49(Core $core)
{
- $core->stackPointer = ($core->memoryRead(($core->programCounter + 1) & 0xFFFF) << 8) + $core->memoryReader[$core->programCounter]($core, $core->programCounter);
+ $core->stackPointer = ($core->memoryRead(($core->programCounter + 1) & 0xFFFF) << 8) + $core->memoryRead($core->programCounter);
$core->programCounter = ($core->programCounter + 2) & 0xFFFF;
}
@@ -768,7 +768,7 @@ class Opcode
*
* @param Core $core
*/
- private static function opcode50(Core $core)
+ public static function opcode50(Core $core)
{
$core->memoryWrite($core->registersHL, $core->registerA);
$core->registersHL = $core->unswtuw($core->registersHL - 1);
@@ -781,7 +781,7 @@ class Opcode
*
* @param Core $core
*/
- private static function opcode51(Core $core)
+ public static function opcode51(Core $core)
{
$core->stackPointer = ($core->stackPointer + 1) & 0xFFFF;
}
@@ -793,9 +793,9 @@ class Opcode
*
* @param Core $core
*/
- private static function opcode52(Core $core)
+ public static function opcode52(Core $core)
{
- $temp_var = (($core->memoryReader[$core->registersHL]($core, $core->registersHL) + 1) & 0xFF);
+ $temp_var = (($core->memoryRead($core->registersHL) + 1) & 0xFF);
$core->FZero = ($temp_var == 0);
$core->FHalfCarry = (($temp_var & 0xF) == 0);
$core->FSubtract = false;
@@ -809,9 +809,9 @@ class Opcode
*
* @param Core $core
*/
- private static function opcode53(Core $core)
+ public static function opcode53(Core $core)
{
- $temp_var = $core->unsbtub($core->memoryReader[$core->registersHL]($core, $core->registersHL) - 1);
+ $temp_var = $core->unsbtub($core->memoryRead($core->registersHL) - 1);
$core->FZero = ($temp_var == 0);
$core->FHalfCarry = (($temp_var & 0xF) == 0xF);
$core->FSubtract = true;
@@ -825,9 +825,9 @@ class Opcode
*
* @param Core $core
*/
- private static function opcode54(Core $core)
+ public static function opcode54(Core $core)
{
- $core->memoryWrite($core->registersHL, $core->memoryReader[$core->programCounter]($core, $core->programCounter));
+ $core->memoryWrite($core->registersHL, $core->memoryRead($core->programCounter));
$core->programCounter = ($core->programCounter + 1) & 0xFFFF;
}
@@ -838,7 +838,7 @@ class Opcode
*
* @param Core $core
*/
- private static function opcode55(Core $core)
+ public static function opcode55(Core $core)
{
$core->FCarry = true;
$core->FSubtract = $core->FHalfCarry = false;
@@ -851,10 +851,10 @@ class Opcode
*
* @param Core $core
*/
- private static function opcode56(Core $core)
+ public static function opcode56(Core $core)
{
if ($core->FCarry) {
- $core->programCounter = $core->nswtuw($core->programCounter + $core->usbtsb($core->memoryReader[$core->programCounter]($core, $core->programCounter)) + 1);
+ $core->programCounter = $core->nswtuw($core->programCounter + $core->usbtsb($core->memoryRead($core->programCounter)) + 1);
++$core->CPUTicks;
} else {
$core->programCounter = ($core->programCounter + 1) & 0xFFFF;
@@ -868,7 +868,7 @@ class Opcode
*
* @param Core $core
*/
- private static function opcode57(Core $core)
+ public static function opcode57(Core $core)
{
$dirtySum = $core->registersHL + $core->stackPointer;
$core->FHalfCarry = (($core->registersHL & 0xFFF) + ($core->stackPointer & 0xFFF) > 0xFFF);
@@ -884,9 +884,9 @@ class Opcode
*
* @param Core $core
*/
- private static function opcode58(Core $core)
+ public static function opcode58(Core $core)
{
- $core->registerA = $core->memoryReader[$core->registersHL]($core, $core->registersHL);
+ $core->registerA = $core->memoryRead($core->registersHL);
$core->registersHL = $core->unswtuw($core->registersHL - 1);
}
@@ -897,7 +897,7 @@ class Opcode
*
* @param Core $core
*/
- private static function opcode59(Core $core)
+ public static function opcode59(Core $core)
{
$core->stackPointer = $core->unswtuw($core->stackPointer - 1);
}
@@ -909,7 +909,7 @@ class Opcode
*
* @param Core $core
*/
- private static function opcode60(Core $core)
+ public static function opcode60(Core $core)
{
$core->registerA = (($core->registerA + 1) & 0xFF);
$core->FZero = ($core->registerA == 0);
@@ -924,7 +924,7 @@ class Opcode
*
* @param Core $core
*/
- private static function opcode61(Core $core)
+ public static function opcode61(Core $core)
{
$core->registerA = $core->unsbtub($core->registerA - 1);
$core->FZero = ($core->registerA == 0);
@@ -939,9 +939,9 @@ class Opcode
*
* @param Core $core
*/
- private static function opcode62(Core $core)
+ public static function opcode62(Core $core)
{
- $core->registerA = $core->memoryReader[$core->programCounter]($core, $core->programCounter);
+ $core->registerA = $core->memoryRead($core->programCounter);
$core->programCounter = ($core->programCounter + 1) & 0xFFFF;
}
@@ -952,7 +952,7 @@ class Opcode
*
* @param Core $core
*/
- private static function opcode63(Core $core)
+ public static function opcode63(Core $core)
{
$core->FCarry = !$core->FCarry;
$core->FSubtract = $core->FHalfCarry = false;
@@ -965,7 +965,7 @@ class Opcode
*
* @param Core $core
*/
- private static function opcode64(Core $core)
+ public static function opcode64(Core $core)
{
//Do nothing...
}
@@ -977,7 +977,7 @@ class Opcode
*
* @param Core $core
*/
- private static function opcode65(Core $core)
+ public static function opcode65(Core $core)
{
$core->registerB = $core->registerC;
}
@@ -989,7 +989,7 @@ class Opcode
*
* @param Core $core
*/
- private static function opcode66(Core $core)
+ public static function opcode66(Core $core)
{
$core->registerB = $core->registerD;
}
@@ -1001,7 +1001,7 @@ class Opcode
*
* @param Core $core
*/
- private static function opcode67(Core $core)
+ public static function opcode67(Core $core)
{
$core->registerB = $core->registerE;
}
@@ -1013,7 +1013,7 @@ class Opcode
*
* @param Core $core
*/
- private static function opcode68(Core $core)
+ public static function opcode68(Core $core)
{
$core->registerB = ($core->registersHL >> 8);
}
@@ -1025,7 +1025,7 @@ class Opcode
*
* @param Core $core
*/
- private static function opcode69(Core $core)
+ public static function opcode69(Core $core)
{
$core->registerB = ($core->registersHL & 0xFF);
}
@@ -1037,9 +1037,9 @@ class Opcode
*
* @param Core $core
*/
- private static function opcode70(Core $core)
+ public static function opcode70(Core $core)
{
- $core->registerB = $core->memoryReader[$core->registersHL]($core, $core->registersHL);
+ $core->registerB = $core->memoryRead($core->registersHL);
}
/**
@@ -1049,7 +1049,7 @@ class Opcode
*
* @param Core $core
*/
- private static function opcode71(Core $core)
+ public static function opcode71(Core $core)
{
$core->registerB = $core->registerA;
}
@@ -1061,7 +1061,7 @@ class Opcode
*
* @param Core $core
*/
- private static function opcode72(Core $core)
+ public static function opcode72(Core $core)
{
$core->registerC = $core->registerB;
}
@@ -1073,7 +1073,7 @@ class Opcode
*
* @param Core $core
*/
- private static function opcode73(Core $core)
+ public static function opcode73(Core $core)
{
//Do nothing...
}
@@ -1085,7 +1085,7 @@ class Opcode
*
* @param Core $core
*/
- private static function opcode74(Core $core)
+ public static function opcode74(Core $core)
{
$core->registerC = $core->registerD;
}
@@ -1097,7 +1097,7 @@ class Opcode
*
* @param Core $core
*/
- private static function opcode75(Core $core)
+ public static function opcode75(Core $core)
{
$core->registerC = $core->registerE;
}
@@ -1109,7 +1109,7 @@ class Opcode
*
* @param Core $core
*/
- private static function opcode76(Core $core)
+ public static function opcode76(Core $core)
{
$core->registerC = ($core->registersHL >> 8);
}
@@ -1121,7 +1121,7 @@ class Opcode
*
* @param Core $core
*/
- private static function opcode77(Core $core)
+ public static function opcode77(Core $core)
{
$core->registerC = ($core->registersHL & 0xFF);
}
@@ -1133,9 +1133,9 @@ class Opcode
*
* @param Core $core
*/
- private static function opcode78(Core $core)
+ public static function opcode78(Core $core)
{
- $core->registerC = $core->memoryReader[$core->registersHL]($core, $core->registersHL);
+ $core->registerC = $core->memoryRead($core->registersHL);
}
/**
@@ -1145,7 +1145,7 @@ class Opcode
*
* @param Core $core
*/
- private static function opcode79(Core $core)
+ public static function opcode79(Core $core)
{
$core->registerC = $core->registerA;
}
@@ -1157,7 +1157,7 @@ class Opcode
*
* @param Core $core
*/
- private static function opcode80(Core $core)
+ public static function opcode80(Core $core)
{
$core->registerD = $core->registerB;
}
@@ -1169,7 +1169,7 @@ class Opcode
*
* @param Core $core
*/
- private static function opcode81(Core $core)
+ public static function opcode81(Core $core)
{
$core->registerD = $core->registerC;
}
@@ -1181,7 +1181,7 @@ class Opcode
*
* @param Core $core
*/
- private static function opcode82(Core $core)
+ public static function opcode82(Core $core)
{
//Do nothing...
}
@@ -1193,7 +1193,7 @@ class Opcode
*
* @param Core $core
*/
- private static function opcode83(Core $core)
+ public static function opcode83(Core $core)
{
$core->registerD = $core->registerE;
}
@@ -1205,7 +1205,7 @@ class Opcode
*
* @param Core $core
*/
- private static function opcode84(Core $core)
+ public static function opcode84(Core $core)
{
$core->registerD = ($core->registersHL >> 8);
}
@@ -1217,7 +1217,7 @@ class Opcode
*
* @param Core $core
*/
- private static function opcode85(Core $core)
+ public static function opcode85(Core $core)
{
$core->registerD = ($core->registersHL & 0xFF);
}
@@ -1229,9 +1229,9 @@ class Opcode
*
* @param Core $core
*/
- private static function opcode86(Core $core)
+ public static function opcode86(Core $core)
{
- $core->registerD = $core->memoryReader[$core->registersHL]($core, $core->registersHL);
+ $core->registerD = $core->memoryRead($core->registersHL);
}
/**
@@ -1241,7 +1241,7 @@ class Opcode
*
* @param Core $core
*/
- private static function opcode87(Core $core)
+ public static function opcode87(Core $core)
{
$core->registerD = $core->registerA;
}
@@ -1253,7 +1253,7 @@ class Opcode
*
* @param Core $core
*/
- private static function opcode88(Core $core)
+ public static function opcode88(Core $core)
{
$core->registerE = $core->registerB;
}
@@ -1265,7 +1265,7 @@ class Opcode
*
* @param Core $core
*/
- private static function opcode89(Core $core)
+ public static function opcode89(Core $core)
{
$core->registerE = $core->registerC;
}
@@ -1277,7 +1277,7 @@ class Opcode
*
* @param Core $core
*/
- private static function opcode90(Core $core)
+ public static function opcode90(Core $core)
{
$core->registerE = $core->registerD;
}
@@ -1289,7 +1289,7 @@ class Opcode
*
* @param Core $core
*/
- private static function opcode91(Core $core)
+ public static function opcode91(Core $core)
{
//Do nothing...
}
@@ -1301,7 +1301,7 @@ class Opcode
*
* @param Core $core
*/
- private static function opcode92(Core $core)
+ public static function opcode92(Core $core)
{
$core->registerE = ($core->registersHL >> 8);
}
@@ -1313,7 +1313,7 @@ class Opcode
*
* @param Core $core
*/
- private static function opcode93(Core $core)
+ public static function opcode93(Core $core)
{
$core->registerE = ($core->registersHL & 0xFF);
}
@@ -1325,9 +1325,9 @@ class Opcode
*
* @param Core $core
*/
- private static function opcode94(Core $core)
+ public static function opcode94(Core $core)
{
- $core->registerE = $core->memoryReader[$core->registersHL]($core, $core->registersHL);
+ $core->registerE = $core->memoryRead($core->registersHL);
}
/**
@@ -1337,7 +1337,7 @@ class Opcode
*
* @param Core $core
*/
- private static function opcode95(Core $core)
+ public static function opcode95(Core $core)
{
$core->registerE = $core->registerA;
}
@@ -1349,7 +1349,7 @@ class Opcode
*
* @param Core $core
*/
- private static function opcode96(Core $core)
+ public static function opcode96(Core $core)
{
$core->registersHL = ($core->registerB << 8) + ($core->registersHL & 0xFF);
}
@@ -1361,7 +1361,7 @@ class Opcode
*
* @param Core $core
*/
- private static function opcode97(Core $core)
+ public static function opcode97(Core $core)
{
$core->registersHL = ($core->registerC << 8) + ($core->registersHL & 0xFF);
}
@@ -1373,7 +1373,7 @@ class Opcode
*
* @param Core $core
*/
- private static function opcode98(Core $core)
+ public static function opcode98(Core $core)
{
$core->registersHL = ($core->registerD << 8) + ($core->registersHL & 0xFF);
}
@@ -1385,7 +1385,7 @@ class Opcode
*
* @param Core $core
*/
- private static function opcode99(Core $core)
+ public static function opcode99(Core $core)
{
$core->registersHL = ($core->registerE << 8) + ($core->registersHL & 0xFF);
}
@@ -1397,7 +1397,7 @@ class Opcode
*
* @param Core $core
*/
- private static function opcode100(Core $core)
+ public static function opcode100(Core $core)
{
//Do nothing...
}
@@ -1409,7 +1409,7 @@ class Opcode
*
* @param Core $core
*/
- private static function opcode101(Core $core)
+ public static function opcode101(Core $core)
{
$core->registersHL = (($core->registersHL & 0xFF) << 8) + ($core->registersHL & 0xFF);
}
@@ -1421,9 +1421,9 @@ class Opcode
*
* @param Core $core
*/
- private static function opcode102(Core $core)
+ public static function opcode102(Core $core)
{
- $core->registersHL = ($core->memoryReader[$core->registersHL]($core, $core->registersHL) << 8) + ($core->registersHL & 0xFF);
+ $core->registersHL = ($core->memoryRead($core->registersHL) << 8) + ($core->registersHL & 0xFF);
}
/**
@@ -1433,7 +1433,7 @@ class Opcode
*
* @param Core $core
*/
- private static function opcode103(Core $core)
+ public static function opcode103(Core $core)
{
$core->registersHL = ($core->registerA << 8) + ($core->registersHL & 0xFF);
}
@@ -1445,7 +1445,7 @@ class Opcode
*
* @param Core $core
*/
- private static function opcode104(Core $core)
+ public static function opcode104(Core $core)
{
$core->registersHL = ($core->registersHL & 0xFF00) + $core->registerB;
}
@@ -1457,7 +1457,7 @@ class Opcode
*
* @param Core $core
*/
- private static function opcode105(Core $core)
+ public static function opcode105(Core $core)
{
$core->registersHL = ($core->registersHL & 0xFF00) + $core->registerC;
}
@@ -1469,7 +1469,7 @@ class Opcode
*
* @param Core $core
*/
- private static function opcode106(Core $core)
+ public static function opcode106(Core $core)
{
$core->registersHL = ($core->registersHL & 0xFF00) + $core->registerD;
}
@@ -1481,7 +1481,7 @@ class Opcode
*
* @param Core $core
*/
- private static function opcode107(Core $core)
+ public static function opcode107(Core $core)
{
$core->registersHL = ($core->registersHL & 0xFF00) + $core->registerE;
}
@@ -1493,7 +1493,7 @@ class Opcode
*
* @param Core $core
*/
- private static function opcode108(Core $core)
+ public static function opcode108(Core $core)
{
$core->registersHL = ($core->registersHL & 0xFF00) + ($core->registersHL >> 8);
}
@@ -1505,7 +1505,7 @@ class Opcode
*
* @param Core $core
*/
- private static function opcode109(Core $core)
+ public static function opcode109(Core $core)
{
//Do nothing...
}
@@ -1517,9 +1517,9 @@ class Opcode
*
* @param Core $core
*/
- private static function opcode110(Core $core)
+ public static function opcode110(Core $core)
{
- $core->registersHL = ($core->registersHL & 0xFF00) + $core->memoryReader[$core->registersHL]($core, $core->registersHL);
+ $core->registersHL = ($core->registersHL & 0xFF00) + $core->memoryRead($core->registersHL);
}
/**
@@ -1529,7 +1529,7 @@ class Opcode
*
* @param Core $core
*/
- private static function opcode111(Core $core)
+ public static function opcode111(Core $core)
{
$core->registersHL = ($core->registersHL & 0xFF00) + $core->registerA;
}
@@ -1541,7 +1541,7 @@ class Opcode
*
* @param Core $core
*/
- private static function opcode112(Core $core)
+ public static function opcode112(Core $core)
{
$core->memoryWrite($core->registersHL, $core->registerB);
}
@@ -1553,7 +1553,7 @@ class Opcode
*
* @param Core $core
*/
- private static function opcode113(Core $core)
+ public static function opcode113(Core $core)
{
$core->memoryWrite($core->registersHL, $core->registerC);
}
@@ -1565,7 +1565,7 @@ class Opcode
*
* @param Core $core
*/
- private static function opcode114(Core $core)
+ public static function opcode114(Core $core)
{
$core->memoryWrite($core->registersHL, $core->registerD);
}
@@ -1577,7 +1577,7 @@ class Opcode
*
* @param Core $core
*/
- private static function opcode115(Core $core)
+ public static function opcode115(Core $core)
{
$core->memoryWrite($core->registersHL, $core->registerE);
}
@@ -1589,7 +1589,7 @@ class Opcode
*
* @param Core $core
*/
- private static function opcode116(Core $core)
+ public static function opcode116(Core $core)
{
$core->memoryWrite($core->registersHL, ($core->registersHL >> 8));
}
@@ -1601,7 +1601,7 @@ class Opcode
*
* @param Core $core
*/
- private static function opcode117(Core $core)
+ public static function opcode117(Core $core)
{
$core->memoryWrite($core->registersHL, ($core->registersHL & 0xFF));
}
@@ -1614,7 +1614,7 @@ class Opcode
* @param \GameBoy\Core $core
* @throws Exception
*/
- private static function opcode118(Core $core)
+ public static function opcode118(Core $core)
{
if ($core->untilEnable == 1) {
/*VBA-M says this fixes Torpedo Range (Seems to work):
@@ -1622,11 +1622,11 @@ class Opcode
EI in this case actually is immediate, so we adjust (Hacky?).*/
$core->programCounter = $core->nswtuw($core->programCounter - 1);
} else {
- if (!$core->halt && !$core->IME && !$core->cGBC && !$core->usedBootROM && ($core->memory[0xFF0F] & $core->memory[0xFFFF] & 0x1F) > 0) {
+ if (!$core->halt && !$core->IME && !$core->cGBC && ($core->memory[0xFF0F] & $core->memory[0xFFFF] & 0x1F) > 0) {
$core->skipPCIncrement = true;
}
$core->halt = true;
- while ($core->halt && ($core->stopEmulator & 1) == 0) {
+ while ($core->halt && ($core->stopEmulator & 1) === 0) {
/*We're hijacking the main interpreter loop to do this dirty business
in order to not slow down the main interpreter loop code with halt state handling.*/
$bitShift = 0;
@@ -1634,7 +1634,7 @@ class Opcode
$interrupts = $core->memory[0xFFFF] & $core->memory[0xFF0F];
while ($bitShift < 5) {
//Check to see if an interrupt is enabled AND requested.
- if (($testbit & $interrupts) == $testbit) {
+ if (($testbit & $interrupts) === $testbit) {
$core->halt = false; //Get out of halt state if in halt state.
return; //Let the main interrupt handler compute the interrupt.
}
@@ -1657,7 +1657,7 @@ class Opcode
*
* @param Core $core
*/
- private static function opcode119(Core $core)
+ public static function opcode119(Core $core)
{
$core->memoryWrite($core->registersHL, $core->registerA);
}
@@ -1669,7 +1669,7 @@ class Opcode
*
* @param Core $core
*/
- private static function opcode120(Core $core)
+ public static function opcode120(Core $core)
{
$core->registerA = $core->registerB;
}
@@ -1681,7 +1681,7 @@ class Opcode
*
* @param Core $core
*/
- private static function opcode121(Core $core)
+ public static function opcode121(Core $core)
{
$core->registerA = $core->registerC;
}
@@ -1693,7 +1693,7 @@ class Opcode
*
* @param Core $core
*/
- private static function opcode122(Core $core)
+ public static function opcode122(Core $core)
{
$core->registerA = $core->registerD;
}
@@ -1705,7 +1705,7 @@ class Opcode
*
* @param Core $core
*/
- private static function opcode123(Core $core)
+ public static function opcode123(Core $core)
{
$core->registerA = $core->registerE;
}
@@ -1717,7 +1717,7 @@ class Opcode
*
* @param Core $core
*/
- private static function opcode124(Core $core)
+ public static function opcode124(Core $core)
{
$core->registerA = ($core->registersHL >> 8);
}
@@ -1729,7 +1729,7 @@ class Opcode
*
* @param Core $core
*/
- private static function opcode125(Core $core)
+ public static function opcode125(Core $core)
{
$core->registerA = ($core->registersHL & 0xFF);
}
@@ -1741,9 +1741,9 @@ class Opcode
*
* @param Core $core
*/
- private static function opcode126(Core $core)
+ public static function opcode126(Core $core)
{
- $core->registerA = $core->memoryReader[$core->registersHL]($core, $core->registersHL);
+ $core->registerA = $core->memoryRead($core->registersHL);
}
/**
@@ -1753,7 +1753,7 @@ class Opcode
*
* @param Core $core
*/
- private static function opcode127(Core $core)
+ public static function opcode127(Core $core)
{
//Do Nothing...
}
@@ -1765,7 +1765,7 @@ class Opcode
*
* @param Core $core
*/
- private static function opcode128(Core $core)
+ public static function opcode128(Core $core)
{
$dirtySum = $core->registerA + $core->registerB;
$core->FHalfCarry = ($dirtySum & 0xF) < ($core->registerA & 0xF);
@@ -1782,7 +1782,7 @@ class Opcode
*
* @param Core $core
*/
- private static function opcode129(Core $core)
+ public static function opcode129(Core $core)
{
$dirtySum = $core->registerA + $core->registerC;
$core->FHalfCarry = ($dirtySum & 0xF) < ($core->registerA & 0xF);
@@ -1799,7 +1799,7 @@ class Opcode
*
* @param Core $core
*/
- private static function opcode130(Core $core)
+ public static function opcode130(Core $core)
{
$dirtySum = $core->registerA + $core->registerD;
$core->FHalfCarry = ($dirtySum & 0xF) < ($core->registerA & 0xF);
@@ -1816,7 +1816,7 @@ class Opcode
*
* @param Core $core
*/
- private static function opcode131(Core $core)
+ public static function opcode131(Core $core)
{
$dirtySum = $core->registerA + $core->registerE;
$core->FHalfCarry = ($dirtySum & 0xF) < ($core->registerA & 0xF);
@@ -1833,7 +1833,7 @@ class Opcode
*
* @param Core $core
*/
- private static function opcode132(Core $core)
+ public static function opcode132(Core $core)
{
$dirtySum = $core->registerA + ($core->registersHL >> 8);
$core->FHalfCarry = ($dirtySum & 0xF) < ($core->registerA & 0xF);
@@ -1850,7 +1850,7 @@ class Opcode
*
* @param Core $core
*/
- private static function opcode133(Core $core)
+ public static function opcode133(Core $core)
{
$dirtySum = $core->registerA + ($core->registersHL & 0xFF);
$core->FHalfCarry = ($dirtySum & 0xF) < ($core->registerA & 0xF);
@@ -1867,9 +1867,9 @@ class Opcode
*
* @param Core $core
*/
- private static function opcode134(Core $core)
+ public static function opcode134(Core $core)
{
- $dirtySum = $core->registerA + $core->memoryReader[$core->registersHL]($core, $core->registersHL);
+ $dirtySum = $core->registerA + $core->memoryRead($core->registersHL);
$core->FHalfCarry = ($dirtySum & 0xF) < ($core->registerA & 0xF);
$core->FCarry = ($dirtySum > 0xFF);
$core->registerA = $dirtySum & 0xFF;
@@ -1884,7 +1884,7 @@ class Opcode
*
* @param Core $core
*/
- private static function opcode135(Core $core)
+ public static function opcode135(Core $core)
{
$dirtySum = $core->registerA * 2;
$core->FHalfCarry = ($dirtySum & 0xF) < ($core->registerA & 0xF);
@@ -1901,7 +1901,7 @@ class Opcode
*
* @param Core $core
*/
- private static function opcode136(Core $core)
+ public static function opcode136(Core $core)
{
$dirtySum = $core->registerA + $core->registerB + (($core->FCarry) ? 1 : 0);
$core->FHalfCarry = (($core->registerA & 0xF) + ($core->registerB & 0xF) + (($core->FCarry) ? 1 : 0) > 0xF);
@@ -1918,7 +1918,7 @@ class Opcode
*
* @param Core $core
*/
- private static function opcode137(Core $core)
+ public static function opcode137(Core $core)
{
$dirtySum = $core->registerA + $core->registerC + (($core->FCarry) ? 1 : 0);
$core->FHalfCarry = (($core->registerA & 0xF) + ($core->registerC & 0xF) + (($core->FCarry) ? 1 : 0) > 0xF);
@@ -1935,7 +1935,7 @@ class Opcode
*
* @param Core $core
*/
- private static function opcode138(Core $core)
+ public static function opcode138(Core $core)
{
$dirtySum = $core->registerA + $core->registerD + (($core->FCarry) ? 1 : 0);
$core->FHalfCarry = (($core->registerA & 0xF) + ($core->registerD & 0xF) + (($core->FCarry) ? 1 : 0) > 0xF);
@@ -1952,7 +1952,7 @@ class Opcode
*
* @param Core $core
*/
- private static function opcode139(Core $core)
+ public static function opcode139(Core $core)
{
$dirtySum = $core->registerA + $core->registerE + (($core->FCarry) ? 1 : 0);
$core->FHalfCarry = (($core->registerA & 0xF) + ($core->registerE & 0xF) + (($core->FCarry) ? 1 : 0) > 0xF);
@@ -1969,7 +1969,7 @@ class Opcode
*
* @param Core $core
*/
- private static function opcode140(Core $core)
+ public static function opcode140(Core $core)
{
$tempValue = ($core->registersHL >> 8);
$dirtySum = $core->registerA + $tempValue + (($core->FCarry) ? 1 : 0);
@@ -1987,7 +1987,7 @@ class Opcode
*
* @param Core $core
*/
- private static function opcode141(Core $core)
+ public static function opcode141(Core $core)
{
$tempValue = ($core->registersHL & 0xFF);
$dirtySum = $core->registerA + $tempValue + (($core->FCarry) ? 1 : 0);
@@ -2005,9 +2005,9 @@ class Opcode
*
* @param Core $core
*/
- private static function opcode142(Core $core)
+ public static function opcode142(Core $core)
{
- $tempValue = $core->memoryReader[$core->registersHL]($core, $core->registersHL);
+ $tempValue = $core->memoryRead($core->registersHL);
$dirtySum = $core->registerA + $tempValue + (($core->FCarry) ? 1 : 0);
$core->FHalfCarry = (($core->registerA & 0xF) + ($tempValue & 0xF) + (($core->FCarry) ? 1 : 0) > 0xF);
$core->FCarry = ($dirtySum > 0xFF);
@@ -2023,7 +2023,7 @@ class Opcode
*
* @param Core $core
*/
- private static function opcode143(Core $core)
+ public static function opcode143(Core $core)
{
$dirtySum = ($core->registerA * 2) + (($core->FCarry) ? 1 : 0);
$core->FHalfCarry = (($core->registerA & 0xF) + ($core->registerA & 0xF) + (($core->FCarry) ? 1 : 0) > 0xF);
@@ -2040,7 +2040,7 @@ class Opcode
*
* @param Core $core
*/
- private static function opcode144(Core $core)
+ public static function opcode144(Core $core)
{
$dirtySum = $core->registerA - $core->registerB;
$core->FHalfCarry = ($core->registerA & 0xF) < ($core->registerB & 0xF);
@@ -2057,7 +2057,7 @@ class Opcode
*
* @param Core $core
*/
- private static function opcode145(Core $core)
+ public static function opcode145(Core $core)
{
$dirtySum = $core->registerA - $core->registerC;
$core->FHalfCarry = ($core->registerA & 0xF) < ($core->registerC & 0xF);
@@ -2074,7 +2074,7 @@ class Opcode
*
* @param Core $core
*/
- private static function opcode146(Core $core)
+ public static function opcode146(Core $core)
{
$dirtySum = $core->registerA - $core->registerD;
$core->FHalfCarry = ($core->registerA & 0xF) < ($core->registerD & 0xF);
@@ -2091,7 +2091,7 @@ class Opcode
*
* @param Core $core
*/
- private static function opcode147(Core $core)
+ public static function opcode147(Core $core)
{
$dirtySum = $core->registerA - $core->registerE;
$core->FHalfCarry = ($core->registerA & 0xF) < ($core->registerE & 0xF);
@@ -2108,7 +2108,7 @@ class Opcode
*
* @param Core $core
*/
- private static function opcode148(Core $core)
+ public static function opcode148(Core $core)
{
$temp_var = $core->registersHL >> 8;
$dirtySum = $core->registerA - $temp_var;
@@ -2126,7 +2126,7 @@ class Opcode
*
* @param Core $core
*/
- private static function opcode149(Core $core)
+ public static function opcode149(Core $core)
{
$dirtySum = $core->registerA - ($core->registersHL & 0xFF);
$core->FHalfCarry = ($core->registerA & 0xF) < ($core->registersHL & 0xF);
@@ -2143,9 +2143,9 @@ class Opcode
*
* @param Core $core
*/
- private static function opcode150(Core $core)
+ public static function opcode150(Core $core)
{
- $temp_var = $core->memoryReader[$core->registersHL]($core, $core->registersHL);
+ $temp_var = $core->memoryRead($core->registersHL);
$dirtySum = $core->registerA - $temp_var;
$core->FHalfCarry = ($core->registerA & 0xF) < ($temp_var & 0xF);
$core->FCarry = ($dirtySum < 0);
@@ -2161,7 +2161,7 @@ class Opcode
*
* @param Core $core
*/
- private static function opcode151(Core $core)
+ public static function opcode151(Core $core)
{
//number - same number == 0
$core->registerA = 0;
@@ -2176,7 +2176,7 @@ class Opcode
*
* @param Core $core
*/
- private static function opcode152(Core $core)
+ public static function opcode152(Core $core)
{
$dirtySum = $core->registerA - $core->registerB - (($core->FCarry) ? 1 : 0);
$core->FHalfCarry = (($core->registerA & 0xF) - ($core->registerB & 0xF) - (($core->FCarry) ? 1 : 0) < 0);
@@ -2193,7 +2193,7 @@ class Opcode
*
* @param Core $core
*/
- private static function opcode153(Core $core)
+ public static function opcode153(Core $core)
{
$dirtySum = $core->registerA - $core->registerC - (($core->FCarry) ? 1 : 0);
$core->FHalfCarry = (($core->registerA & 0xF) - ($core->registerC & 0xF) - (($core->FCarry) ? 1 : 0) < 0);
@@ -2210,7 +2210,7 @@ class Opcode
*
* @param Core $core
*/
- private static function opcode154(Core $core)
+ public static function opcode154(Core $core)
{
$dirtySum = $core->registerA - $core->registerD - (($core->FCarry) ? 1 : 0);
$core->FHalfCarry = (($core->registerA & 0xF) - ($core->registerD & 0xF) - (($core->FCarry) ? 1 : 0) < 0);
@@ -2227,7 +2227,7 @@ class Opcode
*
* @param Core $core
*/
- private static function opcode155(Core $core)
+ public static function opcode155(Core $core)
{
$dirtySum = $core->registerA - $core->registerE - (($core->FCarry) ? 1 : 0);
$core->FHalfCarry = (($core->registerA & 0xF) - ($core->registerE & 0xF) - (($core->FCarry) ? 1 : 0) < 0);
@@ -2244,7 +2244,7 @@ class Opcode
*
* @param Core $core
*/
- private static function opcode156(Core $core)
+ public static function opcode156(Core $core)
{
$temp_var = $core->registersHL >> 8;
$dirtySum = $core->registerA - $temp_var - (($core->FCarry) ? 1 : 0);
@@ -2262,7 +2262,7 @@ class Opcode
*
* @param Core $core
*/
- private static function opcode157(Core $core)
+ public static function opcode157(Core $core)
{
$dirtySum = $core->registerA - ($core->registersHL & 0xFF) - (($core->FCarry) ? 1 : 0);
$core->FHalfCarry = (($core->registerA & 0xF) - ($core->registersHL & 0xF) - (($core->FCarry) ? 1 : 0) < 0);
@@ -2279,9 +2279,9 @@ class Opcode
*
* @param Core $core
*/
- private static function opcode158(Core $core)
+ public static function opcode158(Core $core)
{
- $temp_var = $core->memoryReader[$core->registersHL]($core, $core->registersHL);
+ $temp_var = $core->memoryRead($core->registersHL);
$dirtySum = $core->registerA - $temp_var - (($core->FCarry) ? 1 : 0);
$core->FHalfCarry = (($core->registerA & 0xF) - ($temp_var & 0xF) - (($core->FCarry) ? 1 : 0) < 0);
$core->FCarry = ($dirtySum < 0);
@@ -2297,7 +2297,7 @@ class Opcode
*
* @param Core $core
*/
- private static function opcode159(Core $core)
+ public static function opcode159(Core $core)
{
//Optimized SBC A:
if ($core->FCarry) {
@@ -2318,7 +2318,7 @@ class Opcode
*
* @param Core $core
*/
- private static function opcode160(Core $core)
+ public static function opcode160(Core $core)
{
$core->registerA &= $core->registerB;
$core->FZero = ($core->registerA == 0);
@@ -2333,7 +2333,7 @@ class Opcode
*
* @param Core $core
*/
- private static function opcode161(Core $core)
+ public static function opcode161(Core $core)
{
$core->registerA &= $core->registerC;
$core->FZero = ($core->registerA == 0);
@@ -2348,7 +2348,7 @@ class Opcode
*
* @param Core $core
*/
- private static function opcode162(Core $core)
+ public static function opcode162(Core $core)
{
$core->registerA &= $core->registerD;
$core->FZero = ($core->registerA == 0);
@@ -2363,7 +2363,7 @@ class Opcode
*
* @param Core $core
*/
- private static function opcode163(Core $core)
+ public static function opcode163(Core $core)
{
$core->registerA &= $core->registerE;
$core->FZero = ($core->registerA == 0);
@@ -2378,7 +2378,7 @@ class Opcode
*
* @param Core $core
*/
- private static function opcode164(Core $core)
+ public static function opcode164(Core $core)
{
$core->registerA &= ($core->registersHL >> 8);
$core->FZero = ($core->registerA == 0);
@@ -2393,7 +2393,7 @@ class Opcode
*
* @param Core $core
*/
- private static function opcode165(Core $core)
+ public static function opcode165(Core $core)
{
$core->registerA &= ($core->registersHL & 0xFF);
$core->FZero = ($core->registerA == 0);
@@ -2408,9 +2408,9 @@ class Opcode
*
* @param Core $core
*/
- private static function opcode166(Core $core)
+ public static function opcode166(Core $core)
{
- $core->registerA &= $core->memoryReader[$core->registersHL]($core, $core->registersHL);
+ $core->registerA &= $core->memoryRead($core->registersHL);
$core->FZero = ($core->registerA == 0);
$core->FHalfCarry = true;
$core->FSubtract = $core->FCarry = false;
@@ -2423,7 +2423,7 @@ class Opcode
*
* @param Core $core
*/
- private static function opcode167(Core $core)
+ public static function opcode167(Core $core)
{
//number & same number = same number
$core->FZero = ($core->registerA == 0);
@@ -2438,7 +2438,7 @@ class Opcode
*
* @param Core $core
*/
- private static function opcode168(Core $core)
+ public static function opcode168(Core $core)
{
$core->registerA ^= $core->registerB;
$core->FZero = ($core->registerA == 0);
@@ -2452,7 +2452,7 @@ class Opcode
*
* @param Core $core
*/
- private static function opcode169(Core $core)
+ public static function opcode169(Core $core)
{
$core->registerA ^= $core->registerC;
$core->FZero = ($core->registerA == 0);
@@ -2466,7 +2466,7 @@ class Opcode
*
* @param Core $core
*/
- private static function opcode170(Core $core)
+ public static function opcode170(Core $core)
{
$core->registerA ^= $core->registerD;
$core->FZero = ($core->registerA == 0);
@@ -2480,7 +2480,7 @@ class Opcode
*
* @param Core $core
*/
- private static function opcode171(Core $core)
+ public static function opcode171(Core $core)
{
$core->registerA ^= $core->registerE;
$core->FZero = ($core->registerA == 0);
@@ -2494,7 +2494,7 @@ class Opcode
*
* @param Core $core
*/
- private static function opcode172(Core $core)
+ public static function opcode172(Core $core)
{
$core->registerA ^= ($core->registersHL >> 8);
$core->FZero = ($core->registerA == 0);
@@ -2508,7 +2508,7 @@ class Opcode
*
* @param Core $core
*/
- private static function opcode173(Core $core)
+ public static function opcode173(Core $core)
{
$core->registerA ^= ($core->registersHL & 0xFF);
$core->FZero = ($core->registerA == 0);
@@ -2522,9 +2522,9 @@ class Opcode
*
* @param Core $core
*/
- private static function opcode174(Core $core)
+ public static function opcode174(Core $core)
{
- $core->registerA ^= $core->memoryReader[$core->registersHL]($core, $core->registersHL);
+ $core->registerA ^= $core->memoryRead($core->registersHL);
$core->FZero = ($core->registerA == 0);
$core->FSubtract = $core->FHalfCarry = $core->FCarry = false;
}
@@ -2536,7 +2536,7 @@ class Opcode
*
* @param Core $core
*/
- private static function opcode175(Core $core)
+ public static function opcode175(Core $core)
{
//number ^ same number == 0
$core->registerA = 0;
@@ -2551,7 +2551,7 @@ class Opcode
*
* @param Core $core
*/
- private static function opcode176(Core $core)
+ public static function opcode176(Core $core)
{
$core->registerA |= $core->registerB;
$core->FZero = ($core->registerA == 0);
@@ -2565,7 +2565,7 @@ class Opcode
*
* @param Core $core
*/
- private static function opcode177(Core $core)
+ public static function opcode177(Core $core)
{
$core->registerA |= $core->registerC;
$core->FZero = ($core->registerA == 0);
@@ -2579,7 +2579,7 @@ class Opcode
*
* @param Core $core
*/
- private static function opcode178(Core $core)
+ public static function opcode178(Core $core)
{
$core->registerA |= $core->registerD;
$core->FZero = ($core->registerA == 0);
@@ -2593,7 +2593,7 @@ class Opcode
*
* @param Core $core
*/
- private static function opcode179(Core $core)
+ public static function opcode179(Core $core)
{
$core->registerA |= $core->registerE;
$core->FZero = ($core->registerA == 0);
@@ -2607,7 +2607,7 @@ class Opcode
*
* @param Core $core
*/
- private static function opcode180(Core $core)
+ public static function opcode180(Core $core)
{
$core->registerA |= ($core->registersHL >> 8);
$core->FZero = ($core->registerA == 0);
@@ -2621,7 +2621,7 @@ class Opcode
*
* @param Core $core
*/
- private static function opcode181(Core $core)
+ public static function opcode181(Core $core)
{
$core->registerA |= ($core->registersHL & 0xFF);
$core->FZero = ($core->registerA == 0);
@@ -2635,9 +2635,9 @@ class Opcode
*
* @param Core $core
*/
- private static function opcode182(Core $core)
+ public static function opcode182(Core $core)
{
- $core->registerA |= $core->memoryReader[$core->registersHL]($core, $core->registersHL);
+ $core->registerA |= $core->memoryRead($core->registersHL);
$core->FZero = ($core->registerA == 0);
$core->FSubtract = $core->FCarry = $core->FHalfCarry = false;
}
@@ -2649,7 +2649,7 @@ class Opcode
*
* @param Core $core
*/
- private static function opcode183(Core $core)
+ public static function opcode183(Core $core)
{
//number | same number == same number
$core->FZero = ($core->registerA == 0);
@@ -2663,7 +2663,7 @@ class Opcode
*
* @param Core $core
*/
- private static function opcode184(Core $core)
+ public static function opcode184(Core $core)
{
$dirtySum = $core->registerA - $core->registerB;
$core->FHalfCarry = ($core->unsbtub($dirtySum) & 0xF) > ($core->registerA & 0xF);
@@ -2679,7 +2679,7 @@ class Opcode
*
* @param Core $core
*/
- private static function opcode185(Core $core)
+ public static function opcode185(Core $core)
{
$dirtySum = $core->registerA - $core->registerC;
$core->FHalfCarry = ($core->unsbtub($dirtySum) & 0xF) > ($core->registerA & 0xF);
@@ -2695,7 +2695,7 @@ class Opcode
*
* @param Core $core
*/
- private static function opcode186(Core $core)
+ public static function opcode186(Core $core)
{
$dirtySum = $core->registerA - $core->registerD;
$core->FHalfCarry = ($core->unsbtub($dirtySum) & 0xF) > ($core->registerA & 0xF);
@@ -2711,7 +2711,7 @@ class Opcode
*
* @param Core $core
*/
- private static function opcode187(Core $core)
+ public static function opcode187(Core $core)
{
$dirtySum = $core->registerA - $core->registerE;
$core->FHalfCarry = ($core->unsbtub($dirtySum) & 0xF) > ($core->registerA & 0xF);
@@ -2727,7 +2727,7 @@ class Opcode
*
* @param Core $core
*/
- private static function opcode188(Core $core)
+ public static function opcode188(Core $core)
{
$dirtySum = $core->registerA - ($core->registersHL >> 8);
$core->FHalfCarry = ($core->unsbtub($dirtySum) & 0xF) > ($core->registerA & 0xF);
@@ -2743,7 +2743,7 @@ class Opcode
*
* @param Core $core
*/
- private static function opcode189(Core $core)
+ public static function opcode189(Core $core)
{
$dirtySum = $core->registerA - ($core->registersHL & 0xFF);
$core->FHalfCarry = ($core->unsbtub($dirtySum) & 0xF) > ($core->registerA & 0xF);
@@ -2759,9 +2759,9 @@ class Opcode
*
* @param Core $core
*/
- private static function opcode190(Core $core)
+ public static function opcode190(Core $core)
{
- $dirtySum = $core->registerA - $core->memoryReader[$core->registersHL]($core, $core->registersHL);
+ $dirtySum = $core->registerA - $core->memoryRead($core->registersHL);
$core->FHalfCarry = ($core->unsbtub($dirtySum) & 0xF) > ($core->registerA & 0xF);
$core->FCarry = ($dirtySum < 0);
$core->FZero = ($dirtySum == 0);
@@ -2775,7 +2775,7 @@ class Opcode
*
* @param Core $core
*/
- private static function opcode191(Core $core)
+ public static function opcode191(Core $core)
{
$core->FHalfCarry = $core->FCarry = false;
$core->FZero = $core->FSubtract = true;
@@ -2788,10 +2788,10 @@ class Opcode
*
* @param Core $core
*/
- private static function opcode192(Core $core)
+ public static function opcode192(Core $core)
{
if (!$core->FZero) {
- $core->programCounter = ($core->memoryRead(($core->stackPointer + 1) & 0xFFFF) << 8) + $core->memoryReader[$core->stackPointer]($core, $core->stackPointer);
+ $core->programCounter = ($core->memoryRead(($core->stackPointer + 1) & 0xFFFF) << 8) + $core->memoryRead($core->stackPointer);
$core->stackPointer = ($core->stackPointer + 2) & 0xFFFF;
$core->CPUTicks += 3;
}
@@ -2804,9 +2804,9 @@ class Opcode
*
* @param Core $core
*/
- private static function opcode193(Core $core)
+ public static function opcode193(Core $core)
{
- $core->registerC = $core->memoryReader[$core->stackPointer]($core, $core->stackPointer);
+ $core->registerC = $core->memoryRead($core->stackPointer);
$core->registerB = $core->memoryRead(($core->stackPointer + 1) & 0xFFFF);
$core->stackPointer = ($core->stackPointer + 2) & 0xFFFF;
}
@@ -2818,10 +2818,10 @@ class Opcode
*
* @param Core $core
*/
- private static function opcode194(Core $core)
+ public static function opcode194(Core $core)
{
if (!$core->FZero) {
- $core->programCounter = ($core->memoryRead(($core->programCounter + 1) & 0xFFFF) << 8) + $core->memoryReader[$core->programCounter]($core, $core->programCounter);
+ $core->programCounter = ($core->memoryRead(($core->programCounter + 1) & 0xFFFF) << 8) + $core->memoryRead($core->programCounter);
++$core->CPUTicks;
} else {
$core->programCounter = ($core->programCounter + 2) & 0xFFFF;
@@ -2835,9 +2835,9 @@ class Opcode
*
* @param Core $core
*/
- private static function opcode195(Core $core)
+ public static function opcode195(Core $core)
{
- $core->programCounter = ($core->memoryRead(($core->programCounter + 1) & 0xFFFF) << 8) + $core->memoryReader[$core->programCounter]($core, $core->programCounter);
+ $core->programCounter = ($core->memoryRead(($core->programCounter + 1) & 0xFFFF) << 8) + $core->memoryRead($core->programCounter);
}
/**
@@ -2847,10 +2847,10 @@ class Opcode
*
* @param Core $core
*/
- private static function opcode196(Core $core)
+ public static function opcode196(Core $core)
{
if (!$core->FZero) {
- $temp_pc = ($core->memoryRead(($core->programCounter + 1) & 0xFFFF) << 8) + $core->memoryReader[$core->programCounter]($core, $core->programCounter);
+ $temp_pc = ($core->memoryRead(($core->programCounter + 1) & 0xFFFF) << 8) + $core->memoryRead($core->programCounter);
$core->programCounter = ($core->programCounter + 2) & 0xFFFF;
$core->stackPointer = $core->unswtuw($core->stackPointer - 1);
$core->memoryWrite($core->stackPointer, $core->programCounter >> 8);
@@ -2870,7 +2870,7 @@ class Opcode
*
* @param Core $core
*/
- private static function opcode197(Core $core)
+ public static function opcode197(Core $core)
{
$core->stackPointer = $core->unswtuw($core->stackPointer - 1);
$core->memoryWrite($core->stackPointer, $core->registerB);
@@ -2885,9 +2885,9 @@ class Opcode
*
* @param Core $core
*/
- private static function opcode198(Core $core)
+ public static function opcode198(Core $core)
{
- $dirtySum = $core->registerA + $core->memoryReader[$core->programCounter]($core, $core->programCounter);
+ $dirtySum = $core->registerA + $core->memoryRead($core->programCounter);
$core->FHalfCarry = ($dirtySum & 0xF) < ($core->registerA & 0xF);
$core->FCarry = ($dirtySum > 0xFF);
$core->registerA = $dirtySum & 0xFF;
@@ -2903,7 +2903,7 @@ class Opcode
*
* @param Core $core
*/
- private static function opcode199(Core $core)
+ public static function opcode199(Core $core)
{
$core->stackPointer = $core->unswtuw($core->stackPointer - 1);
$core->memoryWrite($core->stackPointer, $core->programCounter >> 8);
@@ -2919,10 +2919,10 @@ class Opcode
*
* @param Core $core
*/
- private static function opcode200(Core $core)
+ public static function opcode200(Core $core)
{
if ($core->FZero) {
- $core->programCounter = ($core->memoryRead(($core->stackPointer + 1) & 0xFFFF) << 8) + $core->memoryReader[$core->stackPointer]($core, $core->stackPointer);
+ $core->programCounter = ($core->memoryRead(($core->stackPointer + 1) & 0xFFFF) << 8) + $core->memoryRead($core->stackPointer);
$core->stackPointer = ($core->stackPointer + 2) & 0xFFFF;
$core->CPUTicks += 3;
}
@@ -2935,9 +2935,9 @@ class Opcode
*
* @param Core $core
*/
- private static function opcode201(Core $core)
+ public static function opcode201(Core $core)
{
- $core->programCounter = ($core->memoryRead(($core->stackPointer + 1) & 0xFFFF) << 8) + $core->memoryReader[$core->stackPointer]($core, $core->stackPointer);
+ $core->programCounter = ($core->memoryRead(($core->stackPointer + 1) & 0xFFFF) << 8) + $core->memoryRead($core->stackPointer);
$core->stackPointer = ($core->stackPointer + 2) & 0xFFFF;
}
@@ -2948,10 +2948,10 @@ class Opcode
*
* @param Core $core
*/
- private static function opcode202(Core $core)
+ public static function opcode202(Core $core)
{
if ($core->FZero) {
- $core->programCounter = ($core->memoryRead(($core->programCounter + 1) & 0xFFFF) << 8) + $core->memoryReader[$core->programCounter]($core, $core->programCounter);
+ $core->programCounter = ($core->memoryRead(($core->programCounter + 1) & 0xFFFF) << 8) + $core->memoryRead($core->programCounter);
++$core->CPUTicks;
} else {
$core->programCounter = ($core->programCounter + 2) & 0xFFFF;
@@ -2965,9 +2965,9 @@ class Opcode
*
* @param Core $core
*/
- private static function opcode203(Core $core)
+ public static function opcode203(Core $core)
{
- $opcode = $core->memoryReader[$core->programCounter]($core, $core->programCounter);
+ $opcode = $core->memoryRead($core->programCounter);
//Increment the program counter to the next instruction:
$core->programCounter = ($core->programCounter + 1) & 0xFFFF;
//Get how many CPU cycles the current 0xCBXX op code counts for:
@@ -2983,10 +2983,10 @@ class Opcode
*
* @param Core $core
*/
- private static function opcode204(Core $core)
+ public static function opcode204(Core $core)
{
if ($core->FZero) {
- $temp_pc = ($core->memoryRead(($core->programCounter + 1) & 0xFFFF) << 8) + $core->memoryReader[$core->programCounter]($core, $core->programCounter);
+ $temp_pc = ($core->memoryRead(($core->programCounter + 1) & 0xFFFF) << 8) + $core->memoryRead($core->programCounter);
$core->programCounter = ($core->programCounter + 2) & 0xFFFF;
$core->stackPointer = $core->unswtuw($core->stackPointer - 1);
$core->memoryWrite($core->stackPointer, $core->programCounter >> 8);
@@ -3006,9 +3006,9 @@ class Opcode
*
* @param Core $core
*/
- private static function opcode205(Core $core)
+ public static function opcode205(Core $core)
{
- $temp_pc = ($core->memoryRead(($core->programCounter + 1) & 0xFFFF) << 8) + $core->memoryReader[$core->programCounter]($core, $core->programCounter);
+ $temp_pc = ($core->memoryRead(($core->programCounter + 1) & 0xFFFF) << 8) + $core->memoryRead($core->programCounter);
$core->programCounter = ($core->programCounter + 2) & 0xFFFF;
$core->stackPointer = $core->unswtuw($core->stackPointer - 1);
$core->memoryWrite($core->stackPointer, $core->programCounter >> 8);
@@ -3024,9 +3024,9 @@ class Opcode
*
* @param Core $core
*/
- private static function opcode206(Core $core)
+ public static function opcode206(Core $core)
{
- $tempValue = $core->memoryReader[$core->programCounter]($core, $core->programCounter);
+ $tempValue = $core->memoryRead($core->programCounter);
$dirtySum = $core->registerA + $tempValue + (($core->FCarry) ? 1 : 0);
$core->FHalfCarry = (($core->registerA & 0xF) + ($tempValue & 0xF) + (($core->FCarry) ? 1 : 0) > 0xF);
$core->FCarry = ($dirtySum > 0xFF);
@@ -3043,7 +3043,7 @@ class Opcode
*
* @param Core $core
*/
- private static function opcode207(Core $core)
+ public static function opcode207(Core $core)
{
$core->stackPointer = $core->unswtuw($core->stackPointer - 1);
$core->memoryWrite($core->stackPointer, $core->programCounter >> 8);
@@ -3059,10 +3059,10 @@ class Opcode
*
* @param Core $core
*/
- private static function opcode208(Core $core)
+ public static function opcode208(Core $core)
{
if (!$core->FCarry) {
- $core->programCounter = ($core->memoryRead(($core->stackPointer + 1) & 0xFFFF) << 8) + $core->memoryReader[$core->stackPointer]($core, $core->stackPointer);
+ $core->programCounter = ($core->memoryRead(($core->stackPointer + 1) & 0xFFFF) << 8) + $core->memoryRead($core->stackPointer);
$core->stackPointer = ($core->stackPointer + 2) & 0xFFFF;
$core->CPUTicks += 3;
}
@@ -3075,9 +3075,9 @@ class Opcode
*
* @param Core $core
*/
- private static function opcode209(Core $core)
+ public static function opcode209(Core $core)
{
- $core->registerE = $core->memoryReader[$core->stackPointer]($core, $core->stackPointer);
+ $core->registerE = $core->memoryRead($core->stackPointer);
$core->registerD = $core->memoryRead(($core->stackPointer + 1) & 0xFFFF);
$core->stackPointer = ($core->stackPointer + 2) & 0xFFFF;
}
@@ -3089,10 +3089,10 @@ class Opcode
*
* @param Core $core
*/
- private static function opcode210(Core $core)
+ public static function opcode210(Core $core)
{
if (!$core->FCarry) {
- $core->programCounter = ($core->memoryRead(($core->programCounter + 1) & 0xFFFF) << 8) + $core->memoryReader[$core->programCounter]($core, $core->programCounter);
+ $core->programCounter = ($core->memoryRead(($core->programCounter + 1) & 0xFFFF) << 8) + $core->memoryRead($core->programCounter);
++$core->CPUTicks;
} else {
$core->programCounter = ($core->programCounter + 2) & 0xFFFF;
@@ -3106,7 +3106,7 @@ class Opcode
*
* @param Core $core
*/
- private static function opcode211(Core $core)
+ public static function opcode211(Core $core)
{
// @TODO
// cout("Illegal op code 0xD3 called, pausing emulation.", 2);
@@ -3120,10 +3120,10 @@ class Opcode
*
* @param Core $core
*/
- private static function opcode212(Core $core)
+ public static function opcode212(Core $core)
{
if (!$core->FCarry) {
- $temp_pc = ($core->memoryRead(($core->programCounter + 1) & 0xFFFF) << 8) + $core->memoryReader[$core->programCounter]($core, $core->programCounter);
+ $temp_pc = ($core->memoryRead(($core->programCounter + 1) & 0xFFFF) << 8) + $core->memoryRead($core->programCounter);
$core->programCounter = ($core->programCounter + 2) & 0xFFFF;
$core->stackPointer = $core->unswtuw($core->stackPointer - 1);
$core->memoryWrite($core->stackPointer, $core->programCounter >> 8);
@@ -3143,7 +3143,7 @@ class Opcode
*
* @param Core $core
*/
- private static function opcode213(Core $core)
+ public static function opcode213(Core $core)
{
$core->stackPointer = $core->unswtuw($core->stackPointer - 1);
$core->memoryWrite($core->stackPointer, $core->registerD);
@@ -3158,9 +3158,9 @@ class Opcode
*
* @param Core $core
*/
- private static function opcode214(Core $core)
+ public static function opcode214(Core $core)
{
- $temp_var = $core->memoryReader[$core->programCounter]($core, $core->programCounter);
+ $temp_var = $core->memoryRead($core->programCounter);
$dirtySum = $core->registerA - $temp_var;
$core->FHalfCarry = ($core->registerA & 0xF) < ($temp_var & 0xF);
$core->FCarry = ($dirtySum < 0);
@@ -3177,7 +3177,7 @@ class Opcode
*
* @param Core $core
*/
- private static function opcode215(Core $core)
+ public static function opcode215(Core $core)
{
$core->stackPointer = $core->unswtuw($core->stackPointer - 1);
$core->memoryWrite($core->stackPointer, $core->programCounter >> 8);
@@ -3193,10 +3193,10 @@ class Opcode
*
* @param Core $core
*/
- private static function opcode216(Core $core)
+ public static function opcode216(Core $core)
{
if ($core->FCarry) {
- $core->programCounter = ($core->memoryRead(($core->stackPointer + 1) & 0xFFFF) << 8) + $core->memoryReader[$core->stackPointer]($core, $core->stackPointer);
+ $core->programCounter = ($core->memoryRead(($core->stackPointer + 1) & 0xFFFF) << 8) + $core->memoryRead($core->stackPointer);
$core->stackPointer = ($core->stackPointer + 2) & 0xFFFF;
$core->CPUTicks += 3;
}
@@ -3209,9 +3209,9 @@ class Opcode
*
* @param Core $core
*/
- private static function opcode217(Core $core)
+ public static function opcode217(Core $core)
{
- $core->programCounter = ($core->memoryRead(($core->stackPointer + 1) & 0xFFFF) << 8) + $core->memoryReader[$core->stackPointer]($core, $core->stackPointer);
+ $core->programCounter = ($core->memoryRead(($core->stackPointer + 1) & 0xFFFF) << 8) + $core->memoryRead($core->stackPointer);
$core->stackPointer = ($core->stackPointer + 2) & 0xFFFF;
//$core->IME = true;
$core->untilEnable = 2;
@@ -3224,10 +3224,10 @@ class Opcode
*
* @param Core $core
*/
- private static function opcode218(Core $core)
+ public static function opcode218(Core $core)
{
if ($core->FCarry) {
- $core->programCounter = ($core->memoryRead(($core->programCounter + 1) & 0xFFFF) << 8) + $core->memoryReader[$core->programCounter]($core, $core->programCounter);
+ $core->programCounter = ($core->memoryRead(($core->programCounter + 1) & 0xFFFF) << 8) + $core->memoryRead($core->programCounter);
++$core->CPUTicks;
} else {
$core->programCounter = ($core->programCounter + 2) & 0xFFFF;
@@ -3241,7 +3241,7 @@ class Opcode
*
* @param Core $core
*/
- private static function opcode219(Core $core)
+ public static function opcode219(Core $core)
{
echo 'Illegal op code 0xDB called, pausing emulation.';
exit();
@@ -3254,10 +3254,10 @@ class Opcode
*
* @param Core $core
*/
- private static function opcode220(Core $core)
+ public static function opcode220(Core $core)
{
if ($core->FCarry) {
- $temp_pc = ($core->memoryRead(($core->programCounter + 1) & 0xFFFF) << 8) + $core->memoryReader[$core->programCounter]($core, $core->programCounter);
+ $temp_pc = ($core->memoryRead(($core->programCounter + 1) & 0xFFFF) << 8) + $core->memoryRead($core->programCounter);
$core->programCounter = ($core->programCounter + 2) & 0xFFFF;
$core->stackPointer = $core->unswtuw($core->stackPointer - 1);
$core->memoryWrite($core->stackPointer, $core->programCounter >> 8);
@@ -3277,7 +3277,7 @@ class Opcode
*
* @param Core $core
*/
- private static function opcode221(Core $core)
+ public static function opcode221(Core $core)
{
echo 'Illegal op code 0xDD called, pausing emulation.';
exit();
@@ -3290,9 +3290,9 @@ class Opcode
*
* @param Core $core
*/
- private static function opcode222(Core $core)
+ public static function opcode222(Core $core)
{
- $temp_var = $core->memoryReader[$core->programCounter]($core, $core->programCounter);
+ $temp_var = $core->memoryRead($core->programCounter);
$dirtySum = $core->registerA - $temp_var - (($core->FCarry) ? 1 : 0);
$core->FHalfCarry = (($core->registerA & 0xF) - ($temp_var & 0xF) - (($core->FCarry) ? 1 : 0) < 0);
$core->FCarry = ($dirtySum < 0);
@@ -3309,7 +3309,7 @@ class Opcode
*
* @param Core $core
*/
- private static function opcode223(Core $core)
+ public static function opcode223(Core $core)
{
$core->stackPointer = $core->unswtuw($core->stackPointer - 1);
$core->memoryWrite($core->stackPointer, $core->programCounter >> 8);
@@ -3325,9 +3325,9 @@ class Opcode
*
* @param Core $core
*/
- private static function opcode224(Core $core)
+ public static function opcode224(Core $core)
{
- $core->memoryWrite(0xFF00 + $core->memoryReader[$core->programCounter]($core, $core->programCounter), $core->registerA);
+ $core->memoryWrite(0xFF00 + $core->memoryRead($core->programCounter), $core->registerA);
$core->programCounter = ($core->programCounter + 1) & 0xFFFF;
}
@@ -3338,9 +3338,9 @@ class Opcode
*
* @param Core $core
*/
- private static function opcode225(Core $core)
+ public static function opcode225(Core $core)
{
- $core->registersHL = ($core->memoryRead(($core->stackPointer + 1) & 0xFFFF) << 8) + $core->memoryReader[$core->stackPointer]($core, $core->stackPointer);
+ $core->registersHL = ($core->memoryRead(($core->stackPointer + 1) & 0xFFFF) << 8) + $core->memoryRead($core->stackPointer);
$core->stackPointer = ($core->stackPointer + 2) & 0xFFFF;
}
@@ -3351,7 +3351,7 @@ class Opcode
*
* @param Core $core
*/
- private static function opcode226(Core $core)
+ public static function opcode226(Core $core)
{
$core->memoryWrite(0xFF00 + $core->registerC, $core->registerA);
}
@@ -3363,7 +3363,7 @@ class Opcode
*
* @param Core $core
*/
- private static function opcode227(Core $core)
+ public static function opcode227(Core $core)
{
echo 'Illegal op code 0xE3 called, pausing emulation.';
exit();
@@ -3376,7 +3376,7 @@ class Opcode
*
* @param Core $core
*/
- private static function opcode228(Core $core)
+ public static function opcode228(Core $core)
{
echo 'Illegal op code 0xE4 called, pausing emulation.';
exit();
@@ -3389,7 +3389,7 @@ class Opcode
*
* @param Core $core
*/
- private static function opcode229(Core $core)
+ public static function opcode229(Core $core)
{
$core->stackPointer = $core->unswtuw($core->stackPointer - 1);
$core->memoryWrite($core->stackPointer, $core->registersHL >> 8);
@@ -3404,9 +3404,9 @@ class Opcode
*
* @param Core $core
*/
- private static function opcode230(Core $core)
+ public static function opcode230(Core $core)
{
- $core->registerA &= $core->memoryReader[$core->programCounter]($core, $core->programCounter);
+ $core->registerA &= $core->memoryRead($core->programCounter);
$core->programCounter = ($core->programCounter + 1) & 0xFFFF;
$core->FZero = ($core->registerA == 0);
$core->FHalfCarry = true;
@@ -3420,7 +3420,7 @@ class Opcode
*
* @param Core $core
*/
- private static function opcode231(Core $core)
+ public static function opcode231(Core $core)
{
$core->stackPointer = $core->unswtuw($core->stackPointer - 1);
$core->memoryWrite($core->stackPointer, $core->programCounter >> 8);
@@ -3436,9 +3436,9 @@ class Opcode
*
* @param Core $core
*/
- private static function opcode232(Core $core)
+ public static function opcode232(Core $core)
{
- $signedByte = $core->usbtsb($core->memoryReader[$core->programCounter]($core, $core->programCounter));
+ $signedByte = $core->usbtsb($core->memoryRead($core->programCounter));
$temp_value = $core->nswtuw($core->stackPointer + $signedByte);
$core->FCarry = ((($core->stackPointer ^ $signedByte ^ $temp_value) & 0x100) == 0x100);
$core->FHalfCarry = ((($core->stackPointer ^ $signedByte ^ $temp_value) & 0x10) == 0x10);
@@ -3454,7 +3454,7 @@ class Opcode
*
* @param Core $core
*/
- private static function opcode233(Core $core)
+ public static function opcode233(Core $core)
{
$core->programCounter = $core->registersHL;
}
@@ -3466,9 +3466,9 @@ class Opcode
*
* @param Core $core
*/
- private static function opcode234(Core $core)
+ public static function opcode234(Core $core)
{
- $core->memoryWrite(($core->memoryRead(($core->programCounter + 1) & 0xFFFF) << 8) + $core->memoryReader[$core->programCounter]($core, $core->programCounter), $core->registerA);
+ $core->memoryWrite(($core->memoryRead(($core->programCounter + 1) & 0xFFFF) << 8) + $core->memoryRead($core->programCounter), $core->registerA);
$core->programCounter = ($core->programCounter + 2) & 0xFFFF;
}
@@ -3479,7 +3479,7 @@ class Opcode
*
* @param Core $core
*/
- private static function opcode235(Core $core)
+ public static function opcode235(Core $core)
{
echo 'Illegal op code 0xEB called, pausing emulation.';
exit();
@@ -3492,7 +3492,7 @@ class Opcode
*
* @param Core $core
*/
- private static function opcode236(Core $core)
+ public static function opcode236(Core $core)
{
echo 'Illegal op code 0xEC called, pausing emulation.';
exit();
@@ -3505,7 +3505,7 @@ class Opcode
*
* @param Core $core
*/
- private static function opcode237(Core $core)
+ public static function opcode237(Core $core)
{
echo 'Illegal op code 0xED called, pausing emulation.';
exit();
@@ -3518,9 +3518,9 @@ class Opcode
*
* @param Core $core
*/
- private static function opcode238(Core $core)
+ public static function opcode238(Core $core)
{
- $core->registerA ^= $core->memoryReader[$core->programCounter]($core, $core->programCounter);
+ $core->registerA ^= $core->memoryRead($core->programCounter);
$core->FZero = ($core->registerA == 0);
$core->programCounter = ($core->programCounter + 1) & 0xFFFF;
$core->FSubtract = $core->FHalfCarry = $core->FCarry = false;
@@ -3533,7 +3533,7 @@ class Opcode
*
* @param Core $core
*/
- private static function opcode239(Core $core)
+ public static function opcode239(Core $core)
{
$core->stackPointer = $core->unswtuw($core->stackPointer - 1);
$core->memoryWrite($core->stackPointer, $core->programCounter >> 8);
@@ -3549,9 +3549,9 @@ class Opcode
*
* @param Core $core
*/
- private static function opcode240(Core $core)
+ public static function opcode240(Core $core)
{
- $core->registerA = $core->memoryRead(0xFF00 + $core->memoryReader[$core->programCounter]($core, $core->programCounter));
+ $core->registerA = $core->memoryRead(0xFF00 + $core->memoryRead($core->programCounter));
$core->programCounter = ($core->programCounter + 1) & 0xFFFF;
}
@@ -3562,9 +3562,9 @@ class Opcode
*
* @param Core $core
*/
- private static function opcode241(Core $core)
+ public static function opcode241(Core $core)
{
- $temp_var = $core->memoryReader[$core->stackPointer]($core, $core->stackPointer);
+ $temp_var = $core->memoryRead($core->stackPointer);
$core->FZero = (($temp_var & 0x80) == 0x80);
$core->FSubtract = (($temp_var & 0x40) == 0x40);
$core->FHalfCarry = (($temp_var & 0x20) == 0x20);
@@ -3580,7 +3580,7 @@ class Opcode
*
* @param Core $core
*/
- private static function opcode242(Core $core)
+ public static function opcode242(Core $core)
{
$core->registerA = $core->memoryRead(0xFF00 + $core->registerC);
}
@@ -3592,7 +3592,7 @@ class Opcode
*
* @param Core $core
*/
- private static function opcode243(Core $core)
+ public static function opcode243(Core $core)
{
$core->IME = false;
$core->untilEnable = 0;
@@ -3605,7 +3605,7 @@ class Opcode
*
* @param Core $core
*/
- private static function opcode244(Core $core)
+ public static function opcode244(Core $core)
{
// @TODO
// cout("Illegal op code 0xF4 called, pausing emulation.", 2);
@@ -3619,7 +3619,7 @@ class Opcode
*
* @param Core $core
*/
- private static function opcode245(Core $core)
+ public static function opcode245(Core $core)
{
$core->stackPointer = $core->unswtuw($core->stackPointer - 1);
$core->memoryWrite($core->stackPointer, $core->registerA);
@@ -3634,9 +3634,9 @@ class Opcode
*
* @param Core $core
*/
- private static function opcode246(Core $core)
+ public static function opcode246(Core $core)
{
- $core->registerA |= $core->memoryReader[$core->programCounter]($core, $core->programCounter);
+ $core->registerA |= $core->memoryRead($core->programCounter);
$core->FZero = ($core->registerA == 0);
$core->programCounter = ($core->programCounter + 1) & 0xFFFF;
$core->FSubtract = $core->FCarry = $core->FHalfCarry = false;
@@ -3649,7 +3649,7 @@ class Opcode
*
* @param Core $core
*/
- private static function opcode247(Core $core)
+ public static function opcode247(Core $core)
{
$core->stackPointer = $core->unswtuw($core->stackPointer - 1);
$core->memoryWrite($core->stackPointer, $core->programCounter >> 8);
@@ -3665,9 +3665,9 @@ class Opcode
*
* @param Core $core
*/
- private static function opcode248(Core $core)
+ public static function opcode248(Core $core)
{
- $signedByte = $core->usbtsb($core->memoryReader[$core->programCounter]($core, $core->programCounter));
+ $signedByte = $core->usbtsb($core->memoryRead($core->programCounter));
$core->registersHL = $core->nswtuw($core->stackPointer + $signedByte);
$core->FCarry = ((($core->stackPointer ^ $signedByte ^ $core->registersHL) & 0x100) == 0x100);
$core->FHalfCarry = ((($core->stackPointer ^ $signedByte ^ $core->registersHL) & 0x10) == 0x10);
@@ -3682,7 +3682,7 @@ class Opcode
*
* @param Core $core
*/
- private static function opcode249(Core $core)
+ public static function opcode249(Core $core)
{
$core->stackPointer = $core->registersHL;
}
@@ -3694,9 +3694,9 @@ class Opcode
*
* @param Core $core
*/
- private static function opcode250(Core $core)
+ public static function opcode250(Core $core)
{
- $core->registerA = $core->memoryRead(($core->memoryRead(($core->programCounter + 1) & 0xFFFF) << 8) + $core->memoryReader[$core->programCounter]($core, $core->programCounter));
+ $core->registerA = $core->memoryRead(($core->memoryRead(($core->programCounter + 1) & 0xFFFF) << 8) + $core->memoryRead($core->programCounter));
$core->programCounter = ($core->programCounter + 2) & 0xFFFF;
}
@@ -3707,7 +3707,7 @@ class Opcode
*
* @param Core $core
*/
- private static function opcode251(Core $core)
+ public static function opcode251(Core $core)
{
$core->untilEnable = 2;
}
@@ -3719,7 +3719,7 @@ class Opcode
*
* @param Core $core
*/
- private static function opcode252(Core $core)
+ public static function opcode252(Core $core)
{
echo 'Illegal op code 0xFC called, pausing emulation.';
exit();
@@ -3732,7 +3732,7 @@ class Opcode
*
* @param Core $core
*/
- private static function opcode253(Core $core)
+ public static function opcode253(Core $core)
{
echo 'Illegal op code 0xFD called, pausing emulation.';
exit();
@@ -3745,9 +3745,9 @@ class Opcode
*
* @param Core $core
*/
- private static function opcode254(Core $core)
+ public static function opcode254(Core $core)
{
- $dirtySum = $core->registerA - $core->memoryReader[$core->programCounter]($core, $core->programCounter);
+ $dirtySum = $core->registerA - $core->memoryRead($core->programCounter);
$core->FHalfCarry = ($core->unsbtub($dirtySum) & 0xF) > ($core->registerA & 0xF);
$core->FCarry = ($dirtySum < 0);
$core->FZero = ($dirtySum == 0);
@@ -3762,7 +3762,7 @@ class Opcode
*
* @param Core $core
*/
- private static function opcode255(Core $core)
+ public static function opcode255(Core $core)
{
$core->stackPointer = $core->unswtuw($core->stackPointer - 1);
$core->memoryWrite($core->stackPointer, $core->programCounter >> 8);