DS Slot-1: Correct size and error check SPI
Vicki Pfau vi@endrift.com
Wed, 12 Apr 2017 01:15:39 -0700
1 files changed,
14 insertions(+),
1 deletions(-)
jump to
M
src/ds/slot1.c
→
src/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); }