mirror of
https://github.com/libretro/mgba.git
synced 2024-11-27 10:11:00 +00:00
GB: Add support for sleep and shutdown callbacks
This commit is contained in:
parent
a8999958da
commit
30e0be098f
1
CHANGES
1
CHANGES
@ -74,6 +74,7 @@ Misc:
|
|||||||
- Core: Add savedataUpdated callback
|
- Core: Add savedataUpdated callback
|
||||||
- Core: Add shutdown callback
|
- Core: Add shutdown callback
|
||||||
- GB: Allow pausing event loop while CPU is blocked
|
- GB: Allow pausing event loop while CPU is blocked
|
||||||
|
- GB: Add support for sleep and shutdown callbacks
|
||||||
- GBA: Allow pausing event loop while CPU is blocked
|
- GBA: Allow pausing event loop while CPU is blocked
|
||||||
- Debugger: Keep track of global cycle count
|
- Debugger: Keep track of global cycle count
|
||||||
- FFmpeg: Add looping option for GIF/APNG
|
- FFmpeg: Add looping option for GIF/APNG
|
||||||
|
28
src/gb/gb.c
28
src/gb/gb.c
@ -783,29 +783,23 @@ void GBHalt(struct SM83Core* cpu) {
|
|||||||
|
|
||||||
void GBStop(struct SM83Core* cpu) {
|
void GBStop(struct SM83Core* cpu) {
|
||||||
struct GB* gb = (struct GB*) cpu->master;
|
struct GB* gb = (struct GB*) cpu->master;
|
||||||
if (cpu->bus) {
|
if (gb->model >= GB_MODEL_CGB && gb->memory.io[REG_KEY1] & 1) {
|
||||||
mLOG(GB, GAME_ERROR, "Hit illegal stop at address %04X:%02X", cpu->pc, cpu->bus);
|
|
||||||
}
|
|
||||||
if (gb->memory.io[REG_KEY1] & 1) {
|
|
||||||
gb->doubleSpeed ^= 1;
|
gb->doubleSpeed ^= 1;
|
||||||
gb->audio.timingFactor = gb->doubleSpeed + 1;
|
gb->audio.timingFactor = gb->doubleSpeed + 1;
|
||||||
gb->memory.io[REG_KEY1] = 0;
|
gb->memory.io[REG_KEY1] = 0;
|
||||||
gb->memory.io[REG_KEY1] |= gb->doubleSpeed << 7;
|
gb->memory.io[REG_KEY1] |= gb->doubleSpeed << 7;
|
||||||
} else if (cpu->bus) {
|
} else {
|
||||||
#ifdef USE_DEBUGGERS
|
int sleep = ~(gb->memory.io[REG_JOYP] & 0x30);
|
||||||
if (cpu->components && cpu->components[CPU_COMPONENT_DEBUGGER]) {
|
size_t c;
|
||||||
struct mDebuggerEntryInfo info = {
|
for (c = 0; c < mCoreCallbacksListSize(&gb->coreCallbacks); ++c) {
|
||||||
.address = cpu->pc - 1,
|
struct mCoreCallbacks* callbacks = mCoreCallbacksListGetPointer(&gb->coreCallbacks, c);
|
||||||
.type.bp.opcode = 0x1000 | cpu->bus,
|
if (sleep && callbacks->sleep) {
|
||||||
};
|
callbacks->sleep(callbacks->context);
|
||||||
mDebuggerEnter((struct mDebugger*) cpu->components[CPU_COMPONENT_DEBUGGER], DEBUGGER_ENTER_ILLEGAL_OP, &info);
|
} else if (callbacks->shutdown) {
|
||||||
|
callbacks->shutdown(callbacks->context);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
// Hang forever
|
|
||||||
gb->memory.ime = 0;
|
|
||||||
cpu->pc -= 2;
|
|
||||||
}
|
}
|
||||||
// TODO: Actually stop
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void GBIllegal(struct SM83Core* cpu) {
|
void GBIllegal(struct SM83Core* cpu) {
|
||||||
|
Loading…
Reference in New Issue
Block a user