aboutsummaryrefslogtreecommitdiffstats
path: root/src/gb.h
diff options
context:
space:
mode:
authorgbc dev <gbc@localhost>2026-07-15 00:37:04 +0200
committergbc dev <gbc@localhost>2026-07-15 00:37:04 +0200
commit12e67588053160d2f9599a09ef932f9b37b1b873 (patch)
treef1db2e3e8fb585bc76610995d2437aeb6ee9e51a /src/gb.h
parentcontrol: socket-based debug channel + gbctl CLI driver (diff)
downloadsl0pboy-12e67588053160d2f9599a09ef932f9b37b1b873.tar.gz
sl0pboy-12e67588053160d2f9599a09ef932f9b37b1b873.tar.xz
sl0pboy-12e67588053160d2f9599a09ef932f9b37b1b873.zip
apu: register-level emulation of 0xFF10-0xFF3F (fixes music fades)
The APU was a black hole: reads returned 0xFF, writes were dropped. That hangs any game that fades music out by decrementing the NR50/rAUDVOL volume register until it reads 0 (Pokemon's StopMusic spin-wait) - the write never stuck, the read never hit 0, infinite loop. Store the 48 sound registers and return them with the standard hardware read-back OR-masks (NR50 mask 0x00 = exact readback). No synthesis, just correct register behavior.
Diffstat (limited to 'src/gb.h')
-rw-r--r--src/gb.h5
1 files changed, 5 insertions, 0 deletions
diff --git a/src/gb.h b/src/gb.h
index 806daba..7439615 100644
--- a/src/gb.h
+++ b/src/gb.h
@@ -94,6 +94,11 @@ struct GB {
// serial
u8 sb, sc;
+ // APU registers 0xFF10-0xFF3F. We don't synthesize sound, but games read
+ // these back (e.g. the music fade-out decrements NR50/rAUDVOL until it
+ // reads 0), so they must behave as real storage, not a 0xFF black hole.
+ u8 apu[0x30];
+
// DMA
u8 dma;