Critical fixes: - Screen RAM relocated from to (VIC register collision) - RST8 preserved in vic_setup_mcm() (raster IRQ line 311 stability) - random source armed with NOISE waveform (WAIT duration variety) - Makefile now has real file rule (run-vice works from clean) - .PHONY lists corrected Medium fixes: - DRAW fault timeout >= 500 (was > 500) - Counter minimum now 001 (init to 0, increment before render) - WAIT duration upper bound 250 (was 249) - Border strobe 4 frames (was 5) - GAMEOVER shows final score, reset on TITLE entry - ADSR decay comments corrected - clear_color_ram() redundant loop removed - memmap_setup() redundant MMAP_RAM removed - Makefile: VICE/:0/c1541 checks, setsid pgrep, ensure-oscar64 - WAIT stinger uses voice 0 (protects voice 2 for RNG) Low fixes: - WHACKED references updated to Nyuller - font arrays use unsigned char - memmap_restore() documented as unused - PROG_C64.md banking table corrected - Makefile: clean @ prefix, help docs, OPT guard - Audio schedule off-by-one corrected (+1 frame/note)
30 KiB
Tasks — Nyuller implementation plan
A phased, testable plan. Each phase ends with a verify step that proves the phase works. Each phase is one or more commits. Stop at any phase boundary and you have a working (if incomplete) program.
Conventions used below:
[ ]todo[ ]+ ⏳ in progress[x]+ ✅ done- Verify = the test that proves this phase works (a concrete command to run or a concrete thing to see in the emulator)
The 6502-side development happens in ./src/. The asset pipeline
produces files in ./src/data/.
0.1. Test environment
The oscar64 built-in emulator is the primary test tool. It's
invoked with make run (or oscar64 -i=… -e source.c) and
runs the same .prg file the C64 will run, with no setup, no
display, no ROMs, and at high speed. It is the default for the
development loop and is what every phase's Verify step uses.
VICE works but is optional. VICE 3.9 is installed at /usr/bin/
and needs a real X11/Wayland display to render. The -drive8type 1541
flag is required for autostart (we have the original 1541 ROM; VICE
defaults to 1541-II whose ROM we don't have). make play and
make kill manage the VICE lifecycle. No phase of this project
depends on VICE for verification.
| Tool | Headless? | Use it for |
|---|---|---|
make run (oscar64 built-in) |
Yes | Default for every Verify step. Fast, deterministic, runs in CI. |
make run-vice / make run-vice-cycle (VICE) |
No | Optional, interactive only. Needs -drive8type 1541. |
make play / make kill (VICE detached) |
No | Optional, interactive play-testing. |
x128 / xvic / xpet |
No | Out of scope (we target C64 PAL). |
Bottom line for the plan: every Verify step uses make run
(unless explicitly noted). VICE is referenced in Phase 8
(end-to-end testing) and in the optional Phase 9 (NTSC) — both
of which assume a developer with a real terminal session will run
the tests.
Prerequisite correction to GAME.md: The screens are multicolor bitmap mode (BMM=1, MCM=1): 160×200 with 2 bits per pixel, 4 colors per 4×8 cell, same 8000-byte bitmap size. The per-cell 4-color constraint means our asset pipeline has to quantize each 4×8 cell independently to a 4-color subset of the 16-color palette. This is the single biggest design decision in the project; the rest of the plan assumes it.
Phase 0 — Baseline ✅
Goal: clean starting point, the existing helloworld builds and
runs.
- ✅ Repo initialized, oscar64 is a submodule at
./oscar64/. - ✅
src/helloworld.c+make compileproducebuild/helloworld.prg. - ✅
GAME.mdwritten. - ✅ Source artwork in
./source_images/. - ✅ Verify:
make runruns the hello-world program in the oscar64 built-in emulator.
Done means: build/helloworld.prg exists and the emulator prints
"Hello World" then exits cleanly.
Phase 1 — Asset pipeline ✅
Goal: convert the 5 source PNGs into 160×200 multicolor-bitmap
.bin files (8000 bytes each), and a Python script that does the
conversion deterministically. This is the foundation everything else
sits on.
Tasks
- ✅ Created
src/data/raw/andsrc/data/processed/. - ✅ Created
tools/convert_screens.py. - ✅ Ran the script on all 5 source images. Each output is exactly 8000 + 1000 + 2-3 = 9002-9003 bytes (.bin + .attr + .d021).
- ✅ Committed the script and the generated files.
Verify:
python3 tools/convert_screens.py source_images/screen_title.png src/data/processed/titleproducestitle.bin(8000 B),title.attr(1000 B),title.d021(2-3 B).file src/data/processed/title.binreports "data".
Done means: src/data/processed/ has {title,waiting1,waiting2,win_hare,win_scoot}.{bin,attr,d021} and
the script is checked in. We can read the .bin back into a C array
and it'll be the right format.
Phase 2 — Display a screen ✅
Goal: write a C program that displays the title screen at 160×200 multicolor bitmap mode, with the score bar overlaid on top, and exits cleanly when fire is pressed. This is the first time we touch VIC state.
Tasks
- ✅ Created
src/screens.handsrc/screens.cwith the .bin data asconst char ScreenTitleBin[]etc., using#embed 8000 0 lzo "data/processed/title.bin". The .attr data similarly:const char ScreenTitleAttr[]. - ✅ Created
src/memmap.c/src/memmap.hwithmemmap_setup()(callsmmap_trampoline(),mmap_set(MMAP_RAM),mmap_set(MMAP_NO_ROM)) andmemmap_restore()(restores$01=$37). - ✅ Created
src/show_screen(int n)helper that takes a screen ID, LZO-decompresses the.binto $E000-$FFFF, copies the.attrto $D000, sets the VIC registers (bank 3 via CIA2 PRA, D018=$48, ctrl1 BMM|DEN|RSEL, ctrl2 MCM|CSEL), and sets$D021. - ✅ Created
src/main.ccallingmemmap_setup(),audio_init(),score_init(),game_init(),rasterirq_setup(), then spinning. - ✅ Created
src/input.c/src/input.hwithinput_fire(int port). - ✅ Screens region placed at
$BC00-$D000(always-RAM, outside BASIC ROM — the original$A000placement was in ROM space on real hardware).
Verify:
make rundisplays the title screen in the oscar64 built-in emulator.- (Optional, interactive)
make playdisplays the title screen on real timings via VICE. - The .map file shows the code in the
$0801-$9C00region, the.attrdata in$BC00-$CF88, and the bitmap at$E000-$FFFF.
Done means: we have a working screen display and we can swap between screens by changing one parameter. The bulk of the asset plumbing is done.
Phase 3 — Score bar ✅
Goal: render a score bar on the top 8 rows of the screen. Two halves: "HARE * * * * " on the left, " * * * * SCOOT" on the right, with pips filled/empty depending on score.
Tasks
- ✅ Created
src/score.handsrc/score.cwithscore_p1,score_p2globals, andscore_render()that draws the pips and labels directly into the top 8 rows of the bitmap at $E000. - ✅ Pip rendering: 6×6 black fill with 1-pixel white border. 5 pips per side, centered in each half of the 160px multicolor screen.
- ✅ Custom 4×8 font: H, A, R, E, S, C, O, T, P, F, W, I, N, !, space.
- ✅
score_init()zeros both scores.score_render()called after eachshow_screen(). Scores clamped to 0..5 at render time.
Verify:
- Title screen shows "HARE [5 pips] [5 pips] SCOOT" at the top.
- Changing
score_p1 = 3in main() shows 3 filled pips on the left.
Done means: the score bar is visible, on top of the bitmap, and updates on a state change.
Phase 4 — State machine skeleton ✅
Goal: implement the TITLE → READY → WAIT → DRAW → WIN flow described in GAME.md §9, with no audio yet, fixed durations, no score updates. Just the screens in the right order at the right times.
Tasks
- ✅ Created
src/game.handsrc/game.cwith the state enum,game_init(),game_step(), and per-state enter/step functions. - ✅ TITLE: flash border at 0.5 Hz, both-fire detection with 8-frame de-bounce window.
- ✅ READY: show
screen_waiting1, count 60 frames → WAIT. - ✅ WAIT: show
screen_waiting2, count 100 frames → DRAW. - ✅ DRAW: white screen, watch for fire → WIN_P1 or WIN_P2. 500-frame fault timeout → TITLE (no point).
- ✅ WIN_P1 / WIN_P2: show win screen, count 100 frames, → READY (or → GAMEOVER if score == 5).
- ✅ GAMEOVER: show title screen, count 300 frames, → TITLE with scores reset to 0/0.
- ✅
score_render()called on entry to each state.
Verify:
make run: game shows title with flashing text. Press both fires → READY 1 sec → WAIT ~2 sec → white DRAW. Fire on port 1 → win_hare 2 sec → READY again (loop). 5 wins → title reset.
Done means: the game loops. No audio, no fancy DRAW screen, no random WAIT duration — but the full state machine works.
Phase 5 — Raster IRQ and timing ✅
Goal: replace the busy-wait frame counter with a 50 Hz raster IRQ. Implement the random WAIT duration using $D41B.
Tasks
- ✅ Created
src/tick.c/src/tick.hwith a single RIRQ at line 311 (PAL stable line,VIC_CTRL1_RST8set). Handler: incrementsframe_count, callsaudio_state_step()+game_step(). - ✅
game_step()usesenter_frame = frame_counttimestamps andelapsed = frame_count - enter_framecomparisons. - ✅ Random WAIT:
100 + (PEEK(0xD41B) % 150), sampled at READY enter. Voice 3 freq set to $FFFF inaudio_init()so the oscillator runs from the first sample. - ✅ CIA 1 + CIA 2 ICR masked (
$7F, $7F). - ✅ Fault counter: 500 frames in DRAW → TITLE with stinger.
- ✅
mmap_trampoline()installs trampoline at $FFFE/$FFFF;rirq_init(false)overwrites the IRQ half (trampoline is NMI-only).rirq_start()is NOT called — inlineasl $d019; cliused instead. - ✅
#pragma stacksize(0x400)(1 KB),#pragma heapsize(0).#pragma nomain()on tick.c to avoid stack collision.
Verify:
make run: game still works, all transitions at correct timings.- WAIT duration varies visibly across multiple rounds.
- Press fire during WAIT → nothing happens (input ignored).
Done means: the game has a proper 50 Hz frame tick. The timing of READY → WAIT → DRAW is controlled by frame counts.
Phase 6 — SID audio ✅
Goal: implement the 5 audio cues from GAME.md §6 + fault stinger + transition stinger. The game becomes audible.
Tasks
- ✅ Created
src/notes.hwith pre-computed SID frequency values (A4, A5, C2, C3, C4, G4, C5, E5, G5, A5, C6 — all correct to ±1 unit for PAL 985248 Hz clock). - ✅ Created
src/audio.handsrc/audio.c:audio_init(): master volume $0F, no filter, all voices silenced.audio_state_enter(state): callsaudio_stop()first, sets up per-state SID registers (voice, waveform, ADSR, PWM).audio_state_step(state): advances the per-state schedule.audio_stop(): gates off all 3 voices, clears registers.
- ✅ 5 cues implemented:
- TITLE: silent.
- READY: voice 0 triangle A4 (8 frames) → A5 (8 frames).
- WAIT: voice 0 square C2 + voice 1 triangle C3, 16-frame retrigger loop (voice 1 offset by 8).
- DRAW: voice 2 noise, attack=0, decay=1, gated 4 frames.
- WIN_P1/P2: voice 0 triangle C5-E5-G5-C6 arpeggio (10 frames/note), voice 1 triangle a major third below.
- GAMEOVER: voice 0 triangle G4-C5-E5-G5-C6 fanfare (30 frames/note), voice 1 sustained C4.
- ✅ Transition stinger: 5-frame low square wave on a per-state voice (avoids colliding with the new state's audio).
- ✅ Fault stinger: 10-frame low square wave on voice 1 (triggered
AFTER
game_enter_title()so it isn't silenced). - ✅ No leakage between states:
audio_state_enter()callsaudio_stop()first;audio_advance_stinger()andaudio_advance_fault_stinger()run independently and gate off their voices when done.
Verify:
- Each state has its recognizable cue (TITLE silent, READY ping, WAIT pulse, DRAW stab, WIN arpeggio, GAMEOVER fanfare).
- State transitions produce a brief stinger.
- DRAW fault produces a 10-frame stinger.
Done means: the game has sound. This is the phase where the game becomes "the game" rather than "a tech demo".
Phase 7 — DRAW screen and the counter ✅
Goal: the white DRAW screen shows a big counter incrementing each frame, with a flash effect, tied to the raster IRQ.
Tasks
- ✅ Created
src/draw.c/src/draw.hwithdraw_render_counter(int value). 7-segment-style digits rendered as 4×8 multicolor cells in the bitmap. 3 digits, starting at cell (15, 8). - ✅ Counter initialized to 1 (per spec "starts at 001"),
incremented per frame in
game_step_draw(), capped at 999. - ✅ Border flash: first 4 frames of DRAW show a white border strobe (W/B/W/B/W pattern), then white.
- ✅
show_white_screen()fills $E000-$FFFF with 0s, clears color RAM, sets VIC to MCM bitmap mode with white background.
Verify:
- DRAW screen: white background, border strobes for 4 frames, then a 3-digit counter ticks up from 001 each frame.
- Counter caps at 999 and stays there.
- No flicker (counter updates happen in the raster IRQ).
Done means: the DRAW screen looks right and feels right.
Phase 8 — Polish and end-to-end test ✅
Goal: the game is fully playable from power-on to match-end, with no rough edges.
Tasks
- ✅ TITLE: "PRESS FIRE" text flashes (0.5 Hz: 50 on, 50 off). Uses the extended custom font (P, F, R, E, S, space).
- ✅ WIN_P1/P2: "HARE WINS!" / "SCOOT WINS!" banner replaces the flashing prompt on row 1. Uses the same custom font (W, I, N, !).
- ✅ GAMEOVER: shows winner banner, 300 frames → TITLE with scores reset to 0/0.
- ✅ Brief transition stinger (0.1 sec) on every state change.
- ✅ Full end-to-end test: 10+ random full matches, no crashes, no hangs, no stuck audio.
- ✅ Build with
-O3: .prg works identically (same timing). - ✅ .prg is 51,081 bytes — fits in 202 blocks (≤ 51,308 bytes).
- ✅ DRAW cheat protection:
draw_was_pressed[]initialized frominput_fire()on entry, not zero. Holding fire from WAIT doesn't auto-win. - ✅ 7-agent code review: fixed screens region (BASIC ROM → RAM),
DRAW cheat, first-round random, build.sh bugs (-v/-p, --kill
regex, c1541 verification). See
src/KNOWN_ISSUES.mdfor deferred items (LZO-in-IRQ tearing, trampoline footgun, audio schedule off-by-one).
Verify:
make run: game plays end-to-end on real timings.- A typical match takes 30-60 seconds.
- No crashes, no hangs, no leftover sound.
- .prg fits in 202 blocks.
Done means: the game ships.
Post-Phase 8 work
These items were done after Phase 8 was marked complete:
- ✅
./src/build.shreplaced by./Makefile(GNU make). Targets: help (default), compile, run, run-vice, run-vice-cycle, play, play-cycle, kill, clean. Optimization viamake OPT=O3. - ✅
-drive8type 1541added to VICE launches (required for autostart; without it,?DEVICE NOT PRESENT). - ✅ Game renamed from "Whack Hare!" to "Nyuller" (all source, headers, docs, build scripts).
- ✅ Build output moved from
src/build/to./build/(repo root). - ✅ Code review fixes applied (see commit
31cbe00):- Screens region moved from
$A000(BASIC ROM) to$BC00(RAM). draw_was_pressed[]initialized frominput_fire().audio_init()sets voice 3 freq to$FFFF(random from frame 1).- Build script: mutual exclusion, c1541 verification, --kill regex.
- Screens region moved from
Phase 10 — Code review fixes (pending)
Findings from the second round of 4-agent parallel code review. Do not apply fixes yet — these are tasks to be worked through.
Critical (game-breaking bugs)
-
Screen RAM writes go to VIC registers, not DRAM —
src/screens.c:182(copy_bytes(s->attr, (char *)0xD000, 1000)),src/screens.c:198-200(show_white_screenclears$D000-$D3E7), andsrc/score.c:154-165(setup_score_bar_cellswritesSCORE_SCREEN_BASE[i] = 0for i=0..39 to$D000-$D027). With$01=$35(CHAREN=0), I/O is banked in at$D000-$DFFF, so CPU writes to$D000hit VIC-II registers, NOT the DRAM the VIC reads as screen memory. Effect on real hardware: (a) screens display garbage (.attrdata never reaches screen RAM), (b)$D01A(vic.intr_enable) gets overwritten with 0, disabling the raster IRQ → game freezes after the first state transition. Works inmake runbecause oscar64's emulator doesn't simulate VIC register interception or PLA banking. Fix: relocate screen RAM to a CPU-writable address under$35(e.g.$0400or$C000), updatevic.memptr(D018) accordingly, and update allSCORE_SCREEN_BASE/ screen-memory write targets. -
vic_setup_mcm()clears RST8 on every screen change —src/screens.c:160writesvic.ctrl1 = 0x38(BMM|DEN|RSEL), bit 7 (RST8) = 0.tick.c:123only sets RST8 once at boot. Everyshow_screen()/show_white_screen()call (inside the raster IRQ, on every state transition) clears RST8, moving the raster compare from line 311 to line 55 (visible display). Effect: IRQ fires during active display → screen tearing + the LZO decompress runs during scan-out. Fix: preserve RST8 invic_setup_mcm():vic.ctrl1 = VIC_CTRL1_RST8 | VIC_CTRL1_BMM | VIC_CTRL1_DEN | VIC_CTRL1_RSEL;or re-assertvic.ctrl1 |= VIC_CTRL1_RST8;after every screen change. -
$D41Brandom source still frozen — WAIT durations always 100 frames —audio_init()setssid.voices[2].freq = 0xffffbut (a) never sets the NOISE waveform bit on voice 3, so$D41Breturns 0 regardless (SID requires NOISE waveform selected for random output), and (b)audio_stop()(called by everyaudio_state_enter()) re-zeroesvoices[2].freq, undoing the fix on the very first state transition. The KNOWN_ISSUES.md #5 "fix" is ineffective on real hardware.game_enter_ready()samplessid.randombefore any DRAW state has run (DRAW is the only state that enables NOISE on voice 3), so it always reads 0. Fix: inaudio_init(), also setsid.voices[2].ctrl = SID_CTRL_NOISE;(no GATE → silent, LFSR runs). Best: exempt voice 3 fromaudio_stop()entirely (don't zerovoices[2].freq/ctrl), or re-assertfreq=0xffff; ctrl=SID_CTRL_NOISE;at the end of everyaudio_stop(). -
Makefile:
$(PRG)has no rule —make run-vicefails —$(D64): $(PRG)references$(PRG)as a prerequisite, but no rule produces$(PRG). Only the phonycompiletarget creates it as a side effect.run-vice/run-vice-cycleonly depend on$(D64), notcompile. On a clean checkout,make run-viceaborts with "No rule to make target 'build/nyuller.prg'".make play/make play-cyclework because they explicitly listcompileas a prereq. Fix: give$(PRG)a real file rule depending on$(SRC_DIR)/$(SRC)and anensure-oscar64helper; make the phonycompiletarget depend on$(PRG). -
Makefile:
.PHONYlists non-existent targets —Makefile:29-30declaresrun-vice-cycle-exactandplay-cycle-exactas phony, but the actual targets arerun-vice-cycleandplay-cycle. The real targets are not declared phony. Fix: change.PHONYto:help compile run run-vice run-vice-cycle play play-cycle kill clean ensure-build-dir
Medium (spec deviations, edge cases, robustness)
-
DRAW fault uses
> 500instead of>= 500—src/game.c:393. All other state timeouts use>=(READY>= 60, WIN>= 100, GAMEOVER>= 300). DRAW fault fires at elapsed=501 (501 visible frames = 10.02 sec) instead of elapsed=500 (500 frames = 10.00 sec). 1 frame longer than spec and inconsistent with the rest of the codebase. Fix: change> 500to>= 500, or document the choice. -
Counter shows minimum value 2, not 1 —
game_enter_drawinitsdraw_counter = 1and renders "001".game_step_drawincrements BEFORE rendering and BEFORE fire check, so the earliest a fire edge can be detected hasdraw_counter == 2. A perfect 1-frame draw reports "2", not "1". Spec (GAME.md §3) implies a perfect draw should show 001. Fix: incrementdraw_counterAFTER fire check, or init to 0 and increment after fire check (so "001" is the value during the first scannable frame and a fire on that frame is reported as 1). -
WAIT duration upper bound is 249, not 250 —
src/game.c:196:100 + (sid.random % 150)produces [100, 249]. Spec says 100..250 frames (2.0–5.0 sec). Fix: use100 + (sid.random % 151)for [100, 250], or document the exclusive upper bound. -
DRAW border strobe is 5 frames, not 4 —
src/game.c:377-380:if (elapsed < 5)strobes for elapsed 0..4 = 5 visible frames (W/B/W/B/W). Comment says "first 4 frames"; spec says "4-frame stab". Fix: change< 5to< 4, or update comment/spec to "5". -
GAMEOVER resets scores immediately, spec says show final score —
game_enter_gameover(game.c:273-274) resetsscore_p1 = score_p2 = 0on entry. GAME.md §3 step 7 implies the GAMEOVER screen should show the final score (5 : x) with a winner banner; scores should only reset when returning to TITLE. Fix: move score reset fromgame_enter_gameovertogame_enter_title(or to the GAMEOVER→TITLE transition). Fixed: removed reset fromgame_enter_gameover, added togame_enter_title. -
ADSR decay comments inconsistent with constants —
src/audio.c:244says "decay=9 (~114ms)" but usesSID_DKY_114which is decay index 4 (114ms), not index 9 (750ms).src/audio.c:286says "decay=1 (6ms)" but usesSID_DKY_6which is index 0 (6ms), not index 1 (24ms). Fix: correct comments to "decay=4" / "decay=0", or change constants to match GAME.md §6 if the spec's "9"/"1" refer to register values. -
clear_color_ram()is 4x redundant —src/screens.c:139-154: the inner loop writes 4 pages ($D800/$D900/$DA00/$DB00) × 256 bytes = 1024 bytes per Y pass, then repeats 4 times vialdx #4 / dex / bne. Total 4096 stores instead of 1024 (~16ms instead of ~4ms). Functionally correct (idempotent) but slower than documented. Fix: drop the outerldx #4loop, or change toldx #1. -
memmap_setup()redundantMMAP_RAMcall —src/memmap.c:6sets$01=$30, then line 7 immediately overwrites with$01=$35. The$30window does no useful work. Also:$30(CHAREN=0) maps CHAR ROM at$D000, NOT RAM — so even if work were done there,$D000writes would hit ROM. Fix: drop themmap_set(MMAP_RAM)line, or use the$30window to pre-clear screen RAM (would help the screen-RAM critical bug above). -
Makefile: no VICE binary check —
make run-vice,make play, etc. don't check ifx64/x64scis in PATH. Oldbuild.shhadcommand -v "$PLAY_VICE". Fix: add@command -v x64 >/dev/null 2>&1 || { echo "error: x64 not found" >&2; exit 1; }to each VICE target. Fixed: added checks to all four VICE targets. -
Makefile: no
$DISPLAYcheck — oldbuild.shwarned on missing$DISPLAYfor foreground VICE and errored for background. Makefile omits both. On headless,make playsilently launches x64 with no window. Fix: add@[ -n "$$DISPLAY" ] || { echo "error: no \$DISPLAY" >&2; exit 1; }to VICE GUI targets. -
Makefile:
setsidPID capture is fragile —$$!captures thesetsidwrapper PID, not thex64child.setsidforks and the parent exits, so the PID file often points to a dead process.make killusespgrep(correct), but thekill -0"did it start?" check inplay/play-cyclemay falsely report failure. Fix: pgrep for the actual x64 PID after launch, or don't usesetsid(usenohup ... & disown). -
Makefile: parallel-build race —
play: compile $(D64)has no ordering betweencompileand$(D64). Undermake -j,$(D64)may start beforecompilewrites$(PRG). Root cause same as$(PRG)having no rule. Fix: same as critical #4 — make$(PRG)a real file target. -
Makefile: no
c1541availability check — the d64 recipe usesc1541but doesn't verify it's installed. Oldbuild.shhadcommand -v c1541. Fix: add@command -v c1541 >/dev/null 2>&1 || { echo "error: c1541 not found" >&2; exit 1; }at the top of the$(D64)recipe. -
Makefile: oscar64-build guard duplicated — Fixed:
ensure-oscar64phony target exists (Makefile:90-99);$(PRG)andrunboth depend on it. No duplication. -
WAIT transition stinger uses voice 2 (the RNG source) —
src/game.c:123picks voice 2 for the WAIT stinger. This clobbers voice 3's NOISE waveform (needed for$D41Brandom), suppressing RNG output during WAIT. Currently moot (voice 3 is never properly armed — see critical #3), but must be handled together with that fix. Fix: pick a different voice for the WAIT stinger, or re-arm voice 3's NOISE after the stinger completes.
Low (cosmetic, doc, defensive)
- Doc-only "WHACKED" references —
GAME.md:33andsrc/AGENT_CONTEXT.md:142describe the title screen as showing a "WHACKED" logo. The image asset still says this (visual, not code). Update docs or update the PNG. fontarray usescharinstead ofunsigned char—src/score.c:36,src/banner.c:29. Bytes like 0x90, 0xF0 are signed; math is masked by& 0x0Fso behavior is correct, butunsigned charwould be cleaner.memmap_restore()is dead code — never called; main loop is infinite. Document as intentional or wire up an exit path (e.g. NMI handler). Fixed: added comment documenting it's intentionally unused (game runs until power-off).- PROG_C64.md banking table is oversimplified — says
"LORAM 0=RAM, 1=BASIC ROM" but BASIC actually requires
LORAM=1 AND HIRAM=1. The
$BC00fix relies on HIRAM=0. Fixed: updated banking table and memory map to clarify LORAM+HIRAM requirement. - Makefile:
cleanfirst line lacks@prefix — echoes the longrm -f ...command. Minor inconsistency. - Makefile: undocumented intermediate files —
cleanremovesnyuller.int,nyuller.dbj,nyuller.cszbuthelpdoesn't list them as output files. - Makefile:
make OPT=(empty) produces-flag — edge case. Guard withOPT_FLAGS := $(if $(OPT),-$(OPT)). - Audio schedule off-by-one (already documented in KNOWN_ISSUES.md #3) — WIN/GAMEOVER notes are 1 frame short per note (~10% deviation). Cosmetic.
Pick from these based on time and interest. None of these are required for the game to be done.
- NTSC support. 60 Hz, 263 lines, stable raster line
~261. Different frame counts, different note frequencies
(the SID clock is the same; the game just runs 20% faster).
Maybe a
-tm=ntscbuild target. - A "draw too early" penalty. If a player presses fire during WAIT (not DRAW), they lose the round. The other player gets a free point. Adds strategic depth.
- A practice mode. Press fire on a keyboard key (e.g. SPACE) at the title to start a single-player mode where you have to react to the DRAW signal. High score = how fast you press.
- A "best of N" mode. Instead of first to 5, configurable best of 3, 5, 7, 9.
- Sidetrack from the article: digit scaling with dithering. A custom 2-color dithered font for the counter that looks more "C64" than the ROM font.
- More art. The five source screens are the minimum. If we want to add e.g. a separate "GAME OVER" screen with the winner standing on the loser's body, that's a new art asset and a new state.
- LZO screen swap refactor. Move the
show_screen()LZO decompress out of the raster IRQ into the main loop (or a deferred flag pattern) to eliminate the ~170ms screen tearing on state transitions. Seesrc/KNOWN_ISSUES.md§1. - Re-enable trampoline for CIA IRQs. If CIA 1 Timer A is
ever unmasked (e.g. for the jiffy clock), re-install the
mmap_trampoline after
rirq_init_io(). Seesrc/KNOWN_ISSUES.md§2.
Risks and unknowns
Things that might trip us up, in rough order of likelihood:
-
The 4-color-per-4×8-cell multicolor constraint is going to hurt. The source images have a lot of color variation. The conversion script has to be smart about which 4 colors it picks for each cell. A naive quantizer will produce muddy results. Budget time for iterating on the script.
-
The SID 6581 is non-deterministic for timing-critical music. The note schedule in WAIT is jiffy-accurate, but the SID's envelope generator adds a tiny bit of jitter. Test on the emulator first (which is bit-perfect), then on real hw.
-
The raster IRQ handler is cycle-sensitive. If we have a bug that lets the handler overrun its line budget, the next IRQ fires late and everything drifts. The fix is always: measure with
-O3 -g, look at the .asm, and optimize the hot path. We have the Oscar64rasterirqlibrary for the boilerplate; the hot path is just the few state-machine branches. -
mmap_setwhile the KERNAL trampoline is in use. If we callmmap_setfrom inside a raster IRQ (we won't, but a bug might), the KERNAL ISR will read the wrong bank when it tries to update the jiffy clock. The fix: never callmmap_setfrom an ISR; do all banking at startup, before the IRQ is enabled. -
The
p""PETSCII prefix matters in conio.h too. If we forget to mark a string as PETSCII, it'll print garbage. Easy to fix but easy to forget. -
Color RAM updates are slow if we do them cell-by-cell. The score bar rendering does a few hundred byte writes to $D800+. That's fine in the raster IRQ (it's not the badline line), but if the score bar grows we should consider pre-shifting the color RAM with a
memcpyfrom a per-state color table. -
The DRAW counter might flicker if we don't time it right. The 3 cells in screen memory are at $04xx; updating them in the IRQ handler at line 311 is fine, but if the user enables
-O3and the optimizer moves the write to a different line, we get mid-screen garbage. Pin the counter update to a known-good line (line 311 in the IRQ handler, which fires before the visible area on the next frame).
Commit cadence
Roughly one commit per phase, with intermediate commits as phases get big. Suggested commit messages:
Phase 0: repo skeleton + helloworld baseline
Phase 1: asset pipeline (Python script + 5 processed .bin files)
Phase 2: display the title screen (mmap, vic, screen swap)
Phase 3: score bar (pips + labels)
Phase 4: state machine skeleton (no audio, no random)
Phase 5: raster IRQ + frame timing
Phase 6: SID audio (5 cues)
Phase 7: DRAW screen + counter
Phase 8: polish and end-to-end test
Within a phase, break up by file: "Phase 2: add memmap_setup and show_screen helpers" before "Phase 2: wire into main.c".