Correct some memory access issues in LR35902

Signed-off-by: Adrian.Conlon <adrian.conlon@gmail.com>
This commit is contained in:
Adrian.Conlon 2017-06-23 21:23:20 +01:00
parent af375ab10f
commit 67174d74af

View File

@ -538,23 +538,23 @@ void EightBit::LR35902::executeOther(int x, int y, int z, int p, int q) {
case 0: case 0:
switch (p) { switch (p) {
case 0: // LD (BC),A case 0: // LD (BC),A
MEMPTR() = BC(); m_memory.ADDRESS() = BC();
MEMPTR().high = memptrReference() = A(); m_memory.reference() = A();
cycles += 2; cycles += 2;
break; break;
case 1: // LD (DE),A case 1: // LD (DE),A
MEMPTR() = DE(); m_memory.ADDRESS() = DE();
MEMPTR().high = memptrReference() = A(); m_memory.reference() = A();
cycles += 2; cycles += 2;
break; break;
case 2: // GB: LDI (HL),A case 2: // GB: LDI (HL),A
MEMPTR().word = HL().word++; m_memory.ADDRESS().word = HL().word++;
MEMPTR().high = memptrReference() = A(); m_memory.reference() = A();
cycles += 2; cycles += 2;
break; break;
case 3: // GB: LDD (HL),A case 3: // GB: LDD (HL),A
MEMPTR().word = HL().word--; m_memory.ADDRESS().word = HL().word--;
MEMPTR().high = memptrReference() = A(); m_memory.reference() = A();
cycles += 2; cycles += 2;
break; break;
} }
@ -562,22 +562,22 @@ void EightBit::LR35902::executeOther(int x, int y, int z, int p, int q) {
case 1: case 1:
switch (p) { switch (p) {
case 0: // LD A,(BC) case 0: // LD A,(BC)
MEMPTR() = BC(); m_memory.ADDRESS() = BC();
A() = memptrReference(); A() = m_memory.reference();
cycles += 2; cycles += 2;
break; break;
case 1: // LD A,(DE) case 1: // LD A,(DE)
MEMPTR() = DE(); m_memory.ADDRESS() = DE();
A() = memptrReference(); A() = m_memory.reference();
cycles += 2; cycles += 2;
break; break;
case 2: // GB: LDI A,(HL) case 2: // GB: LDI A,(HL)
MEMPTR().word = HL().word++; m_memory.ADDRESS().word = HL().word++;
A() = m_memory.reference(); A() = m_memory.reference();
cycles += 2; cycles += 2;
break; break;
case 3: // GB: LDD A,(HL) case 3: // GB: LDD A,(HL)
MEMPTR().word = HL().word--; m_memory.ADDRESS().word = HL().word--;
A() = m_memory.reference(); A() = m_memory.reference();
cycles += 2; cycles += 2;
break; break;