all repos — mgba @ a688e62123738a8a54b6efade0ab2d2515896781

mGBA Game Boy Advance Emulator

DS Slot-1: Correct size and error check SPI
Vicki Pfau vi@endrift.com
Wed, 12 Apr 2017 01:15:39 -0700
commit

a688e62123738a8a54b6efade0ab2d2515896781

parent

5bb811a16e32a8061319af6c772a941aad9bfaa1

1 files changed, 14 insertions(+), 1 deletions(-)

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

@@ -230,6 +230,9 @@ if (!_slot1GuaranteeSize(&dscore->p->memory.slot1)) {

return 0xFF; } } + if (!dscore->p->memory.slot1.spiData) { + return 0xFF; + } switch (dscore->p->memory.slot1.spiCommand) { case 0x03: // RD

@@ -250,6 +253,13 @@ dscore->p->memory.slot1.spiAddress <<= 8;

dscore->p->memory.slot1.spiAddress |= datum; dscore->p->memory.slot1.spiAddressingRemaining -= 8; return 0xFF; + } else if (dscore->p->isHomebrew) { + if (!_slot1GuaranteeSize(&dscore->p->memory.slot1)) { + return 0xFF; + } + } + if (!dscore->p->memory.slot1.spiData) { + return 0xFF; } switch (dscore->p->memory.slot1.spiCommand) {

@@ -277,6 +287,9 @@ } else if (dscore->p->isHomebrew) {

if (!_slot1GuaranteeSize(&dscore->p->memory.slot1)) { return 0xFF; } + } + if (!dscore->p->memory.slot1.spiData) { + return 0xFF; } uint8_t oldValue;

@@ -410,7 +423,7 @@ ds->memory.slot1.savedataType = DS_SAVEDATA_EEPROM512;

} else { ds->memory.slot1.spiAddressingBits = 16; } - ds->memory.slot1.spiAddress = size; + ds->memory.slot1.spiAddress = size - 1; _slot1GuaranteeSize(&ds->memory.slot1); }