diff options
| author | gbc dev <gbc@localhost> | 2026-07-16 12:49:02 +0200 |
|---|---|---|
| committer | gbc dev <gbc@localhost> | 2026-07-16 12:49:02 +0200 |
| commit | ca6f9bb91893cf50c8e09bf7396085a7d69e80ab (patch) | |
| tree | 64ccd983aaf5322f423489caf4c68d4949dab1bb /src/cpu.c | |
| parent | headless: interactive TTY mode (raw stdin) for driving a guest OS live (diff) | |
| download | sl0pboy-ca6f9bb91893cf50c8e09bf7396085a7d69e80ab.tar.gz sl0pboy-ca6f9bb91893cf50c8e09bf7396085a7d69e80ab.tar.xz sl0pboy-ca6f9bb91893cf50c8e09bf7396085a7d69e80ab.zip | |
headless: $ED opcode = clean power-off (exit + battery save)
The unused SM83 opcode $ED now sets gb->poweroff, which breaks the headless
loop so the normal cart_free()->cart_save() path runs. Lets a guest OS shut the
emulator down cleanly (and flush its .sav) instead of relying on an external
timeout/SIGTERM, which could SIGKILL before the save. run_frame() also stops on
poweroff so exit is immediate.
Diffstat (limited to 'src/cpu.c')
| -rw-r--r-- | src/cpu.c | 2 |
1 files changed, 2 insertions, 0 deletions
@@ -407,6 +407,8 @@ int cpu_step(GB *gb) { case 0xCB: do_cb(gb); break; + case 0xED: gb->poweroff = true; break; // (illegal on HW) clean-exit signal + default: // 0x40-0xBF block: LD r,r' and ALU A,r if (op >= 0x40 && op < 0x80) { |
