all repos — mgba @ 287fd86e6adc4ddc7209596495e1843c0bc503d8

mGBA Game Boy Advance Emulator

GBA: Allow pausing event loop while CPU is blocked
Vicki Pfau vi@endrift.com
Sun, 12 Jul 2020 23:51:04 -0700
commit

287fd86e6adc4ddc7209596495e1843c0bc503d8

parent

ba2175f5c513288d7c1feba3dad6a964cb7a22b4

5 files changed, 7 insertions(+), 4 deletions(-)

jump to
M CHANGESCHANGES

@@ -56,6 +56,7 @@ - SM83: Simplify register pair access on big endian

- Wii: Fix pixelated filtering on interframe blending (fixes mgba.io/i/1830) Misc: - GB: Allow pausing event loop while CPU is blocked + - GBA: Allow pausing event loop while CPU is blocked - Debugger: Keep track of global cycle count - FFmpeg: Add looping option for GIF/APNG - FFmpeg: Use range coder for FFV1 to reduce output size
M include/mgba/internal/gba/serialize.hinclude/mgba/internal/gba/serialize.h

@@ -236,6 +236,7 @@ DECL_BITFIELD(GBASerializedMiscFlags, uint32_t);

DECL_BIT(GBASerializedMiscFlags, Halted, 0); DECL_BIT(GBASerializedMiscFlags, POSTFLG, 1); DECL_BIT(GBASerializedMiscFlags, IrqPending, 2); +DECL_BIT(GBASerializedMiscFlags, Blocked, 3); struct GBASerializedState { uint32_t versionMagic;
M src/gba/gba.csrc/gba/gba.c

@@ -286,7 +286,7 @@ mLOG(GBA, FATAL, "Negative cycles passed: %i", cycles);

} #endif nextEvent = mTimingTick(&gba->timing, cycles < nextEvent ? nextEvent : cycles); - } while (gba->cpuBlocked); + } while (gba->cpuBlocked && !gba->earlyExit); cpu->nextEvent = nextEvent; if (cpu->halted) {

@@ -305,11 +305,9 @@ break;

} } gba->earlyExit = false; -#ifndef NDEBUG if (gba->cpuBlocked) { - mLOG(GBA, FATAL, "CPU is blocked!"); + cpu->cycles = cpu->nextEvent; } -#endif } #ifdef USE_DEBUGGERS
M src/gba/serialize.csrc/gba/serialize.c

@@ -67,6 +67,7 @@ if (mTimingIsScheduled(&gba->timing, &gba->irqEvent)) {

miscFlags = GBASerializedMiscFlagsFillIrqPending(miscFlags); STORE_32(gba->irqEvent.when - mTimingCurrentTime(&gba->timing), 0, &state->nextIrq); } + miscFlags = GBASerializedMiscFlagsSetBlocked(miscFlags, gba->cpuBlocked); STORE_32(miscFlags, 0, &state->miscFlags); GBAMemorySerialize(&gba->memory, state);

@@ -185,6 +186,7 @@ int32_t when;

LOAD_32(when, 0, &state->nextIrq); mTimingSchedule(&gba->timing, &gba->irqEvent, when); } + gba->cpuBlocked = GBASerializedMiscFlagsGetBlocked(miscFlags); GBAVideoDeserialize(&gba->video, state); GBAMemoryDeserialize(&gba->memory, state);
M src/gba/video.csrc/gba/video.c

@@ -175,6 +175,7 @@ if (video->frameskipCounter < 0) {

video->frameskipCounter = video->frameskip; } ++video->frameCounter; + video->p->earlyExit = true; break; case VIDEO_VERTICAL_TOTAL_PIXELS - 1: video->p->memory.io[REG_DISPSTAT >> 1] = GBARegisterDISPSTATClearInVblank(dispstat);