diff --git a/desmume/src/MMU.cpp b/desmume/src/MMU.cpp index e64288945..cb2d8b63a 100644 --- a/desmume/src/MMU.cpp +++ b/desmume/src/MMU.cpp @@ -2973,6 +2973,9 @@ void FASTCALL _MMU_ARM9_write32(u32 adr, u32 val) case 0x40005A: case 0x40005B: case 0x40005C: // Individual Commands + if (gxFIFO.size > 254) + nds.freezeBus = TRUE; + ((u32 *)(MMU.MMU_MEM[ARMCPU_ARM9][0x40]))[(adr & 0xFFF) >> 2] = val; gfx3d_sendCommand(adr, val); return; diff --git a/desmume/src/NDSSystem.cpp b/desmume/src/NDSSystem.cpp index 76a05afc3..a2ecf79c9 100644 --- a/desmume/src/NDSSystem.cpp +++ b/desmume/src/NDSSystem.cpp @@ -1190,6 +1190,8 @@ template struct TSequenceItem_DMA : public TSequenceItem { IF_DEVELOPER(DEBUG_statistics.sequencerExecutionCounters[5+procnum*4+chan]++); + //if (nds.freezeBus) return; + //printf("exec from TSequenceItem_DMA: %d %d\n",procnum,chan); controller->exec(); // //give gxfifo dmas a chance to re-trigger @@ -1847,7 +1849,7 @@ static /*donotinline*/ std::pair armInnerLoop( { if(doarm9 && (!doarm7 || arm9 <= timer)) { - if(!NDS_ARM9.waitIRQ) + if(!NDS_ARM9.waitIRQ&&!nds.freezeBus) { arm9log(); arm9 += armcpu_exec(); @@ -1860,11 +1862,12 @@ static /*donotinline*/ std::pair armInnerLoop( s32 temp = arm9; arm9 = min(s32next, arm9 + kIrqWait); nds.idleCycles += arm9-temp; + if (gxFIFO.size < 255) nds.freezeBus = FALSE; } } if(doarm7 && (!doarm9 || arm7 <= timer)) { - if(!NDS_ARM7.waitIRQ) + if(!NDS_ARM7.waitIRQ&&!nds.freezeBus) { arm7log(); arm7 += (armcpu_exec()<<1); @@ -2080,6 +2083,7 @@ void NDS_Reset() nds.sleeping = FALSE; nds.cardEjected = FALSE; + nds.freezeBus = FALSE; nds.power1.lcd = nds.power1.gpuMain = nds.power1.gfx3d_render = nds.power1.gfx3d_geometry = nds.power1.gpuSub = nds.power1.dispswap = 1; nds.power2.speakers = 1; nds.power2.wifi = 0; diff --git a/desmume/src/NDSSystem.h b/desmume/src/NDSSystem.h index 3b0cb9624..7ca7b1eab 100644 --- a/desmume/src/NDSSystem.h +++ b/desmume/src/NDSSystem.h @@ -180,6 +180,7 @@ struct NDSSystem BOOL sleeping; BOOL cardEjected; + BOOL freezeBus; //this is not essential NDS runtime state. //it was perhaps a mistake to put it here. diff --git a/desmume/src/saves.cpp b/desmume/src/saves.cpp index 948df4432..59a7d8a8a 100644 --- a/desmume/src/saves.cpp +++ b/desmume/src/saves.cpp @@ -172,6 +172,7 @@ SFORMAT SF_NDS[]={ { "_ENH", 4, 1, &nds.ensataHandshake}, { "_ENI", 4, 1, &nds.ensataIpcSyncCounter}, { "_SLP", 4, 1, &nds.sleeping}, + { "_FBS", 4, 1, &nds.freezeBus}, { "_CEJ", 4, 1, &nds.cardEjected}, { "_P00", 1, 1, &nds.power1.lcd}, { "_P01", 1, 1, &nds.power1.gpuMain},