DS Slot-1: Fix SPI addressing wrap

This commit is contained in:
Vicki Pfau 2017-04-24 19:29:29 -07:00
parent fd7d85c140
commit 7879736a44
1 changed files with 4 additions and 12 deletions

View File

@ -276,9 +276,7 @@ static uint8_t _slot1SPIEEPROM(struct DSCommon* dscore, uint8_t datum) {
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 @@ static uint8_t _slot1SPIFlash(struct DSCommon* dscore, uint8_t datum) {
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;