aboutsummaryrefslogtreecommitdiffstats
path: root/src/gb.h
diff options
context:
space:
mode:
authorgbc dev <gbc@localhost>2026-07-16 12:49:02 +0200
committergbc dev <gbc@localhost>2026-07-16 12:49:02 +0200
commitca6f9bb91893cf50c8e09bf7396085a7d69e80ab (patch)
tree64ccd983aaf5322f423489caf4c68d4949dab1bb /src/gb.h
parentheadless: interactive TTY mode (raw stdin) for driving a guest OS live (diff)
downloadsl0pboy-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/gb.h')
-rw-r--r--src/gb.h1
1 files changed, 1 insertions, 0 deletions
diff --git a/src/gb.h b/src/gb.h
index 7218648..7959e60 100644
--- a/src/gb.h
+++ b/src/gb.h
@@ -116,6 +116,7 @@ struct GB {
bool serial_log; // print serial output to stderr (blargg tests)
int serial_out_fd; // if >=0, transmitted serial bytes written here (stdout)
int serial_in_fd; // if >=0, received serial bytes read here (stdin), else 0xFF
+ bool poweroff; // set by the $ED opcode: request a clean emulator exit
};
void gb_init(GB *gb);