Handle zero page wraparound in ($xx,X)

* fixes line #1100: CFF4  C9 5D     CMP
This commit is contained in:
Rob McMullen 2017-12-18 11:48:56 -08:00
parent 44dfdfaca5
commit 986a9f33b6
1 changed files with 9 additions and 3 deletions

8
6502.c
View File

@ -528,7 +528,13 @@ uint8_t * get_IND()
uint8_t * get_XIND()
{
uint16_t ptr;
memcpy(&ptr, get_ZPX(), sizeof(ptr));
ptr = ((* get_IMM()) + X) & 0xFF;
if (ptr == 0xff) { // check for wraparound in zero page
ptr = memory[ptr] + (memory[ptr & 0xff00] << 8);
}
else {
memcpy(&ptr, &memory[ptr], sizeof(ptr));
}
return &memory[ptr];
}