mirror of https://github.com/mgba-emu/mgba.git
DS Slot-1: Emulate initial SPI command delay
This commit is contained in:
parent
c2f43bc503
commit
b796a689cb
1
CHANGES
1
CHANGES
|
@ -20,6 +20,7 @@ Bugfixes:
|
|||
- 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
|
||||
|
|
|
@ -41,7 +41,7 @@ void DSSlot1Reset(struct DS* ds) {
|
|||
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 @@ static void _scheduleTransfer(struct DS* ds, struct mTiming* timing, uint32_t cy
|
|||
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 @@ static void DSSlot1StartTransfer(struct DS* ds) {
|
|||
}
|
||||
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,8 +186,10 @@ DSSlot1ROMCNT DSSlot1Control(struct DS* ds, DSSlot1ROMCNT control) {
|
|||
if (DSSlot1ROMCNTIsBlockBusy(control)) {
|
||||
DSSlot1StartTransfer(ds);
|
||||
// TODO: timing
|
||||
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;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue