diff --git a/src/gb/GB.cpp b/src/gb/GB.cpp index 6d177894..55563e56 100644 --- a/src/gb/GB.cpp +++ b/src/gb/GB.cpp @@ -586,17 +586,12 @@ bool gbIsGameboyRom(char * file) void gbCopyMemory(u16 d, u16 s, int count) { - if (s>=0xE000 && s<0xFE00) - { - s-=0x2000; - } - while(count) - { - gbMemoryMap[d>>12][d & 0x0fff] = gbMemoryMap[s>>12][s & 0x0fff]; - s++; - d++; - count--; - } + while(count) { + gbMemoryMap[d>>12][d & 0x0fff] = gbMemoryMap[s>>12][s & 0x0fff]; + s++; + d++; + count--; + } } void gbDoHdma() @@ -674,16 +669,10 @@ void gbWriteMemory(register u16 address, register u8 value) return; } - if (address<0xE000) - { - gbMemoryMap[address>>12][address & 0x0fff] = value; - return; - } - if(address < 0xfe00) - { - gbMemoryMap[(address-0x2000)>>12][address & 0x0fff] = value; - return; - } + if(address < 0xfe00) { + gbMemoryMap[address>>12][address & 0x0fff] = value; + return; + } if(address < 0xff00) { gbMemory[address] = value; @@ -1166,7 +1155,7 @@ u8 gbReadOpcode(register u16 address) if(gbCheatMap[address]) return gbCheatRead(address); - switch((address>>12) & 0x000f) { + switch(address & 0xf000) { case 0x0a: case 0x0b: if(mapperReadRAM) @@ -1226,10 +1215,6 @@ u8 gbReadOpcode(register u16 address) } } break; -if (address>=0xE000 && address<0xFE00) - { - return gbMemoryMap[(address-0x2000)>>12][address & 0x0fff]; - } } return gbMemoryMap[address>>12][address & 0x0fff]; } @@ -1395,11 +1380,8 @@ u8 gbReadMemory(register u16 address) case 0xff: return register_IE; } - if (address>=0xE000 && address<0xFE00) - { - return gbMemoryMap[(address-0x2000)>>12][address & 0x0fff]; - } } + return gbMemoryMap[address>>12][address & 0x0fff]; }