all repos — mgba @ 7879736a44c167373c04c9381218a131ee1bd5c5

mGBA Game Boy Advance Emulator

DS Slot-1: Fix SPI addressing wrap
Vicki Pfau vi@endrift.com
Mon, 24 Apr 2017 19:29:29 -0700
commit

7879736a44c167373c04c9381218a131ee1bd5c5

parent

fd7d85c1403b70c7fa5a562ee1694333aa559c6c

1 files changed, 4 insertions(+), 12 deletions(-)

jump to
M src/ds/slot1.csrc/ds/slot1.c

@@ -276,9 +276,7 @@ ++dscore->p->memory.slot1.spiAddress;

return oldValue; case 0x02: // WRLO case 0x0A: // WRHI - if (dscore->p->memory.slot1.spiAddress >= dscore->p->memory.slot1.spiSize) { - break; - } + dscore->p->memory.slot1.spiAddress &= dscore->p->memory.slot1.spiSize - 1; dscore->p->memory.slot1.spiData[dscore->p->memory.slot1.spiAddress] = datum; ++dscore->p->memory.slot1.spiAddress; break;

@@ -306,23 +304,17 @@

uint8_t oldValue; switch (dscore->p->memory.slot1.spiCommand) { case 0x03: // RD - if (dscore->p->memory.slot1.spiAddress >= dscore->p->memory.slot1.spiSize) { - return 0xFF; - } + dscore->p->memory.slot1.spiAddress &= dscore->p->memory.slot1.spiSize - 1; oldValue = dscore->p->memory.slot1.spiData[dscore->p->memory.slot1.spiAddress]; ++dscore->p->memory.slot1.spiAddress; return oldValue; case 0x02: // PP - if (dscore->p->memory.slot1.spiAddress >= dscore->p->memory.slot1.spiSize) { - break; - } + dscore->p->memory.slot1.spiAddress &= dscore->p->memory.slot1.spiSize - 1; dscore->p->memory.slot1.spiData[dscore->p->memory.slot1.spiAddress] = datum; ++dscore->p->memory.slot1.spiAddress; break; case 0x0A: // PW - if (dscore->p->memory.slot1.spiAddress >= dscore->p->memory.slot1.spiSize) { - break; - } + dscore->p->memory.slot1.spiAddress &= dscore->p->memory.slot1.spiSize - 1; oldValue = dscore->p->memory.slot1.spiData[dscore->p->memory.slot1.spiAddress]; dscore->p->memory.slot1.spiData[dscore->p->memory.slot1.spiAddress] = datum; ++dscore->p->memory.slot1.spiAddress;