Commit 78aa032
Let the STAT line dip between mode-0 and the next line's LYC term
Ken Griffey Jr.'s Slugfest (issue #68) paces a per-band palette engine
with chained STAT interrupts: an LYC interrupt at the band line arms a
mode-0 interrupt, whose handler streams the next 8-line band's palettes
during HBlank, reprograms LYC and re-arms. The game keeps both sources
enabled across the frame start, so the chain relies on the LYC interrupt
of the band line firing while the previous line's mode-0 term is still
enabled.
Our STAT interrupt line never dipped there: the mode-0 term stays high
through the last tick of a line and the coincidence term went high at
tick 0 of the next line, so the line stayed high across the boundary and
the rising edge - and with it the LYC interrupt - was swallowed. The
game's engine then aborted, leaving an interrupt storm (a mode-0 int on
all 143 other lines) and only the static VBlank palette load, which
painted the perspective-warped field with the wrong per-band colours -
the "garbled crowd". On hardware the comparator output feeding the
interrupt line settles one machine cycle after the line-start latch, so
the line dips for 4 ticks and the LYC edge fires.
The readable STAT.2 flag keeps the existing timing (valid at tick 0,
pinned by lcdon_timing-GS); only the interrupt-line term gets the 4-tick
settling delay. Lines 0 and 153 are excluded, preserving the single
LYC=0 interrupt per frame across the 153->0 transition (Altered Space)
and the short LYC=153 window.
Verified: the palette engine now runs on every frame (408 mid-frame BGPD
writes, matching SameBoy exactly); the Home Run Derby field renders
pixel-clean. Full battery (unit, mooneye 98, dmg-acid2, blargg 46+8,
mealybug 24, controller 12) green; Bug's Life, Altered Space and Zerd no
Densetsu re-verified by screenshot.
Fixes #68
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01J1wLWscyUGS7CFwc3CjJR81 parent b3d42c7 commit 78aa032
1 file changed
Lines changed: 23 additions & 3 deletions
Lines changed: 23 additions & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
38 | 38 | | |
39 | 39 | | |
40 | 40 | | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
41 | 45 | | |
42 | 46 | | |
43 | 47 | | |
| |||
67 | 71 | | |
68 | 72 | | |
69 | 73 | | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
70 | 89 | | |
71 | 90 | | |
72 | 91 | | |
| |||
81 | 100 | | |
82 | 101 | | |
83 | 102 | | |
84 | | - | |
| 103 | + | |
85 | 104 | | |
86 | 105 | | |
87 | 106 | | |
| |||
119 | 138 | | |
120 | 139 | | |
121 | 140 | | |
122 | | - | |
| 141 | + | |
123 | 142 | | |
124 | 143 | | |
125 | 144 | | |
| |||
130 | 149 | | |
131 | 150 | | |
132 | 151 | | |
| 152 | + | |
133 | 153 | | |
134 | 154 | | |
135 | 155 | | |
136 | 156 | | |
137 | | - | |
| 157 | + | |
138 | 158 | | |
139 | 159 | | |
0 commit comments