aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorgbc dev <gbc@localhost>2026-07-17 19:47:02 +0200
committergbc dev <gbc@localhost>2026-07-17 19:47:02 +0200
commitef07ad11bb0a20f137682e901a0a6beacfc08968 (patch)
tree1d8b4236ac273fa220bf267d512b15e65b402fe8 /src
parentgb: auto-reconnect a dead --serial-sock link instead of going silent (diff)
downloadsl0pboy-ef07ad11bb0a20f137682e901a0a6beacfc08968.tar.gz
sl0pboy-ef07ad11bb0a20f137682e901a0a6beacfc08968.tar.xz
sl0pboy-ef07ad11bb0a20f137682e901a0a6beacfc08968.zip
cpu: log the $ED poweroff opcode with pc/registers
The clean-exit opcode used to print nothing, so any guest crash that walked into a stray $ED byte was indistinguishable from a silent socket death (one of the kill vectors in the link-drop investigation). Now it identifies itself on stderr with pc/af/bc/de/hl/sp.
Diffstat (limited to 'src')
-rw-r--r--src/cpu.c7
1 files changed, 6 insertions, 1 deletions
diff --git a/src/cpu.c b/src/cpu.c
index 5b73724..e2f0ad0 100644
--- a/src/cpu.c
+++ b/src/cpu.c
@@ -1,4 +1,5 @@
#include "cpu.h"
+#include <stdio.h>
#define FZ 0x80
#define FN 0x40
@@ -407,7 +408,11 @@ int cpu_step(GB *gb) {
case 0xCB: do_cb(gb); break;
- case 0xED: gb->poweroff = true; break; // (illegal on HW) clean-exit signal
+ case 0xED: gb->poweroff = true; // (illegal on HW) clean-exit signal
+ fprintf(stderr, "[sl0pboy] poweroff opcode $ED at pc=%04X (af=%04X bc=%04X "
+ "de=%04X hl=%04X sp=%04X)\n", (unsigned)(c->pc - 1), c->af, c->bc,
+ c->de, c->hl, c->sp);
+ break;
default:
// 0x40-0xBF block: LD r,r' and ALU A,r