DS Slot-1: Reply to IR 0x08 command properly (fixes #666)

This commit is contained in:
Vicki Pfau 2017-07-31 14:50:20 -07:00
parent 394a2e0bb8
commit bfb8e02ea2
3 changed files with 15 additions and 4 deletions

View File

@ -12,6 +12,7 @@ Bugfixes:
- DS GX: Fix incorrect W values - DS GX: Fix incorrect W values
- DS Video: Fix 2D/3D blending alpha values - DS Video: Fix 2D/3D blending alpha values
- DS I/O: Enable POWCNT1 bit 1 at boot (fixes mgba.io/i/616) - DS I/O: Enable POWCNT1 bit 1 at boot (fixes mgba.io/i/616)
- DS Slot-1: Reply to IR 0x08 command properly (fixes mgba.io/i/666)
Misc: Misc:
- DS GX: Clean up and unify texture mapping - DS GX: Clean up and unify texture mapping
- DS Core: Add symbol loading - DS Core: Add symbol loading
@ -23,11 +24,8 @@ Features:
Bugfixes: Bugfixes:
- GB Audio: Make audio unsigned with bias (fixes mgba.io/i/749) - GB Audio: Make audio unsigned with bias (fixes mgba.io/i/749)
- Python: Fix importing .gb or .gba before .core - Python: Fix importing .gb or .gba before .core
<<<<<<< HEAD
=======
- GBA: Reset active region as needed when loading a ROM - GBA: Reset active region as needed when loading a ROM
- Qt: Fix command line debugger closing second game - Qt: Fix command line debugger closing second game
>>>>>>> feature/input-revamp
Misc: Misc:
- GBA Timer: Use global cycles for timers - GBA Timer: Use global cycles for timers
- GBA: Extend oddly-sized ROMs to full address space (fixes mgba.io/i/722) - GBA: Extend oddly-sized ROMs to full address space (fixes mgba.io/i/722)

View File

@ -51,6 +51,7 @@ struct DSSlot1 {
int dmaSource; int dmaSource;
enum DSSavedataType savedataType; enum DSSavedataType savedataType;
bool hasIR;
struct mTimingEvent spiEvent; struct mTimingEvent spiEvent;
bool spiHoldEnabled; bool spiHoldEnabled;
uint8_t spiCommand; uint8_t spiCommand;

View File

@ -27,6 +27,7 @@ void DSSlot1SPIInit(struct DS* ds, struct VFile* vf) {
ds->memory.slot1.transferEvent.context = ds; ds->memory.slot1.transferEvent.context = ds;
ds->memory.slot1.transferEvent.callback = _transferEvent; ds->memory.slot1.transferEvent.callback = _transferEvent;
ds->memory.slot1.savedataType = DS_SAVEDATA_AUTODETECT; ds->memory.slot1.savedataType = DS_SAVEDATA_AUTODETECT;
ds->memory.slot1.hasIR = false;
ds->memory.slot1.spiVf = vf; ds->memory.slot1.spiVf = vf;
ds->memory.slot1.spiRealVf = vf; ds->memory.slot1.spiRealVf = vf;
ds->memory.slot1.spiData = NULL; ds->memory.slot1.spiData = NULL;
@ -358,7 +359,11 @@ static void _slot1SPI(struct mTiming* timing, void* context, uint32_t cyclesLate
} else { } else {
dscore->p->memory.slot1.spiAddress = 0; dscore->p->memory.slot1.spiAddress = 0;
} }
if (oldValue == 0x08 && dscore->p->memory.slot1.hasIR) {
dscore->p->memory.slot1.spiCommand |= 0x80; // TODO: Move to a separate variable
} else {
dscore->p->memory.slot1.spiAddressingRemaining = dscore->p->memory.slot1.spiAddressingBits; dscore->p->memory.slot1.spiAddressingRemaining = dscore->p->memory.slot1.spiAddressingBits;
}
} else { } else {
switch (dscore->p->memory.slot1.spiCommand) { switch (dscore->p->memory.slot1.spiCommand) {
case 0x04: // WRDI case 0x04: // WRDI
@ -371,6 +376,10 @@ static void _slot1SPI(struct mTiming* timing, void* context, uint32_t cyclesLate
dscore->p->memory.slot1.statusReg |= 2; dscore->p->memory.slot1.statusReg |= 2;
break; break;
default: default:
if (dscore->p->memory.slot1.hasIR && dscore->p->memory.slot1.spiCommand == 0x88) {
newValue = 0xAA;
break;
}
switch (dscore->p->memory.slot1.savedataType) { switch (dscore->p->memory.slot1.savedataType) {
case DS_SAVEDATA_AUTODETECT: case DS_SAVEDATA_AUTODETECT:
newValue = _slot1SPIAutodetect(dscore, oldValue); newValue = _slot1SPIAutodetect(dscore, oldValue);
@ -449,6 +458,9 @@ void DSSlot1ConfigureSPI(struct DS* ds, uint32_t paramPtr) {
} else { } else {
ds->memory.slot1.spiAddressingBits = 16; ds->memory.slot1.spiAddressingBits = 16;
} }
if (saveParams & 0xFF0000) {
ds->memory.slot1.hasIR = true;
}
ds->memory.slot1.spiAddress = size - 1; ds->memory.slot1.spiAddress = size - 1;
ds->memory.slot1.spiSize = size; ds->memory.slot1.spiSize = size;
_slot1GuaranteeSize(&ds->memory.slot1); _slot1GuaranteeSize(&ds->memory.slot1);