all repos — mgba @ b796a689cbbb6e320654d03d2e8a300072d256ec

mGBA Game Boy Advance Emulator

DS Slot-1: Emulate initial SPI command delay
Vicki Pfau vi@endrift.com
Sat, 15 Apr 2017 12:08:02 -0700
commit

b796a689cbbb6e320654d03d2e8a300072d256ec

parent

c2f43bc503e1bfd181fdd76ead42dc67eea0b4f1

2 files changed, 10 insertions(+), 6 deletions(-)

jump to
M CHANGESCHANGES

@@ -20,6 +20,7 @@ - DS GX: Fix bitmap textures when no palette is mapped (fixes mgba.io/i/628)

- DS GX: Don't reset state between buffer swaps (fixes mgba.io/i/642) - DS GX: Allow viewport to change in the middle of a frame - DS GX: Properly mask address for slot 2 4x4-texel textures + - DS Slot-1: Emulate initial SPI command delay Misc: - DS: Set boot complete bit in RAM on boot (fixes mgba.io/i/576, mgba.io/i/580, mgba.io/i/586) - DS Memory: Ensure DS9 I/O is 8-byte aligned
M src/ds/slot1.csrc/ds/slot1.c

@@ -41,7 +41,7 @@ ds->memory.slot1.dmaSource = -1;

ds->memory.slot1.spiAddressingBits = 16; } -static void _scheduleTransfer(struct DS* ds, struct mTiming* timing, uint32_t cyclesLate) { +static void _scheduleTransfer(struct DS* ds, struct mTiming* timing, uint32_t bytes, uint32_t cyclesLate) { DSSlot1ROMCNT romcnt = ds->memory.io7[DS_REG_ROMCNT_HI >> 1] << 16; uint32_t cycles; if (DSSlot1ROMCNTIsTransferRate(romcnt)) {

@@ -52,6 +52,7 @@ }

if (!ds->ds7.memory.slot1Access) { cycles <<= 1; } + cycles *= bytes / 4; cycles -= cyclesLate; mTimingDeschedule(timing, &ds->memory.slot1.transferEvent); mTimingSchedule(timing, &ds->memory.slot1.transferEvent, cycles);

@@ -142,9 +143,9 @@ ds->romVf->seek(ds->romVf, ds->memory.slot1.address, SEEK_SET);

} ds->memory.slot1.transferRemaining = ds->memory.slot1.transferSize; if (ds->ds7.memory.slot1Access) { - _scheduleTransfer(ds, &ds->ds7.timing, 0); + _scheduleTransfer(ds, &ds->ds7.timing, 12, 0); } else { - _scheduleTransfer(ds, &ds->ds9.timing, 0); + _scheduleTransfer(ds, &ds->ds9.timing, 12, 0); } break; case 0xB8:

@@ -185,7 +186,9 @@ }

if (DSSlot1ROMCNTIsBlockBusy(control)) { DSSlot1StartTransfer(ds); // TODO: timing - control = DSSlot1ROMCNTFillWordReady(control); + if (ds->memory.slot1.command[0] != 0xB7) { + control = DSSlot1ROMCNTFillWordReady(control); + } } return control; }

@@ -194,9 +197,9 @@ uint32_t DSSlot1Read(struct DS* ds) {

uint32_t result; LOAD_32(result, 0, ds->memory.slot1.readBuffer); if (ds->ds7.memory.slot1Access) { - _scheduleTransfer(ds, &ds->ds7.timing, 0); + _scheduleTransfer(ds, &ds->ds7.timing, 4, 0); } else { - _scheduleTransfer(ds, &ds->ds9.timing, 0); + _scheduleTransfer(ds, &ds->ds9.timing, 4, 0); } return result; }