From 422c948692d3354f40e71d9844d18dcab497c78a Mon Sep 17 00:00:00 2001 From: Daniel Covington Date: Wed, 25 Nov 2026 11:24:01 -0500 Subject: [PATCH] Make every example buildable and verified; rewrite AGENTS.md and README. Examples: - The four .asm examples used generic period syntax no installed assembler accepts. They are now ca65 with BASIC stubs, and pass c64 test. - bitmap-demo: SET_PIXEL clobbered the loop counter, colors went to $0400 while $D018 pointed at $8400, the clear missed 64 bytes, and ORA under BASIC ROM copied ROM bytes into the bitmap. It now draws 200 clean pixels. - kernal-io: GETIN clobbers X; the line index now lives in memory. The stray SETLFS is replaced by a real drive-status read. - irq-handler: the raster IRQ exits via $EA81 instead of re-running the Kernal handler (which double-counted the jiffy clock). - sound-demo: NOTE% and WAVEFORM tokenized as NOT/FOR (SYNTAX error). - disk-access: closing channel 15 closed the data files, the error path left file 1 open, LOAD "$" replaced the running program, and the read loop tested ST too early. It now writes, reads, lists, and renames. Toolchain: BASIC builds sort lines like the C64 editor and warn about variable names that contain keywords; BASIC errors report their line; -Disk attaches an image; each target gets build/test//; -refreshonbreak keeps screenshots in step with the dump; absolute paths resolve. tools/regress.ps1 runs all 17 cases (all pass). AGENTS.md is now a short entry point (workflow, rules, skill/reference/ project indexes); README describes the commands and layout. newLang's regression suite gives the same 22 pass / 4 fail as on cfa64d1 (map-artifact baselines and a Get-FileHash lookup in prepare-disk.ps1). Co-Authored-By: Claude Opus 5.5 --- .claude/skills/c64-workflow/SKILL.md | 25 +- .claude/skills/vice-emulator/SKILL.md | 2 +- AGENTS.md | 425 +++++++------------------- README.md | 183 +++++------ examples/bitmap-demo.asm | 424 +++++++++++-------------- examples/disk-access.bas | 52 ++-- examples/hello-world.asm | 44 ++- examples/irq-handler.asm | 161 +++++----- examples/kernal-io.asm | 334 ++++++++++---------- examples/sound-demo.bas | 24 +- tools/C64Tools.psm1 | 91 +++++- tools/c64.ps1 | 16 +- tools/regress.ps1 | 59 ++++ 13 files changed, 843 insertions(+), 997 deletions(-) create mode 100644 tools/regress.ps1 diff --git a/.claude/skills/c64-workflow/SKILL.md b/.claude/skills/c64-workflow/SKILL.md index cbf33d3..23b316b 100644 --- a/.claude/skills/c64-workflow/SKILL.md +++ b/.claude/skills/c64-workflow/SKILL.md @@ -85,9 +85,15 @@ fires it dumps RAM and I/O, decodes the text screen, and closes VICE. If a program replaces the Kernal IRQ (`$0314` to code that never reaches `$EA31`), the jiffy trigger never fires. Pass `-TickAddress ` instead. +Disk I/O also stops the jiffy count: the Kernal's serial routines run with IRQs off +while the C64 waits on the drive. Programs that use the disk should report through +`$D7FF` instead. + +`-Disk ` attaches a disk image to drive 8 for programs that use files (make a +blank one with `c1541 -format "work,01" d64 work.d64`). A manifest can set `"disk"` under `test`. Verdict: FAIL on timeout, on a non-zero `$D7FF` code, on a BASIC error (the runner -breaks on `$A437` and names the error, e.g. `BASIC error 11 (SYNTAX)`), or when any +breaks on `$A437` and names the error and line, e.g. `BASIC error 11 (SYNTAX) in line 40`), or when any `-Expect "TEXT"` is missing from the screen (case-insensitive; repeat `-Expect` for several strings). @@ -110,7 +116,7 @@ On real hardware `$D7FF` is an unused SID register image, so these stores do not and can stay in shipped code. `x64sc -debugcart` uses the same register (VICE exits with the stored value) if you need a bare-VICE check. -### Artifacts (`/build/test/`) +### Artifacts (`/build/test//`) | File | Contents | |------|----------| @@ -123,7 +129,7 @@ with the stored value) if you need a bare-VICE check. Inspect a variable: find it in `build/.lbl`, then read `ram.bin` at `2 + address`. For example, with pwsh: -`$r=[IO.File]::ReadAllBytes("build/test/ram.bin"); $r[2+0x0834]`. +`$r=[IO.File]::ReadAllBytes("build/test//ram.bin"); $r[2+0x0834]`. ### Testing patterns that work @@ -135,6 +141,7 @@ Inspect a variable: find it in `build/.lbl`, then read `ram.bin` at scripted moves) or check the state after a fixed number of jiffies. - **Regression set**: `c64 test projects/a projects/b examples/x.c` runs several and prints `n/m passed`. +- **Toolchain changes**: `pwsh tools/regress.ps1` runs the repository's full suite. ## Live debugging: `c64 run -Monitor` + `c64 mon` @@ -158,6 +165,15 @@ leading dot. Use `watch store ` to find who corrupts a variable, and `bank | BASIC (`.bas` via petcat) | either; it is lowered by default | petcat tokenizes lower-case keywords; `{clr}`, `{wht}`, `{down}` are control codes | | Screen RAM pokes | screen codes, not PETSCII | `A` = 1, `@` = 0, space = 32 | +BASIC builds sort lines by number, as the C64 editor does when you type them in (petcat +alone keeps file order, which breaks `GOTO` to a line placed earlier in the file). The +build warns about variable names that contain a keyword: `NOTE` tokenizes as `NOT E`, +and `WAVEFORM` as `WAVE FOR M` (even `SCORE` hides `OR`). Only the first two characters +of a variable name count, so `PLAYER1` and `PLAYER2` are the same variable `PL`. + +1541 gotcha: closing channel 15 makes the drive close every other open file. Open 15 +once, send commands with `PRINT#15,"S0:NAME"`, and close it last (`examples/disk-access.bas`). + ## Memory and build gotchas - cc65 C programs load at `$0801`. The C stack and heap sit below `$D000` by default. @@ -182,6 +198,9 @@ These shaped `tools/C64Tools.psm1`. Read them before you script VICE yourself: - `quit` is ignored inside a `command` string but works from a playback file. Quitting cleanly flushes `-monlog` and writes `-exitscreenshot`; killing the process loses both. - The monitor `screenshot` command hangs when it runs from a checkpoint. Use `-exitscreenshot`. +- Warp mode skips rendering frames, so `-exitscreenshot` can show a frame from well + before the trigger. `-refreshonbreak` redraws the display when the checkpoint hits, + which makes the screenshot match the dump. VICE 3.10 has no `-refresh` option. - `ignore ` on `break exec ea31` gives a deterministic "after N jiffies" trigger. A full-range `break exec 0000 ffff` with an ignore count never fired. - Autostarting a `.d64` is about 10 s slower than injecting the PRG diff --git a/.claude/skills/vice-emulator/SKILL.md b/.claude/skills/vice-emulator/SKILL.md index dd5e224..fb77ca8 100644 --- a/.claude/skills/vice-emulator/SKILL.md +++ b/.claude/skills/vice-emulator/SKILL.md @@ -344,7 +344,7 @@ The VICE manual explicitly warns that snapshot compatibility is not reliable acr Use the repository toolchain (`.claude/skills/c64-workflow/SKILL.md`) instead of raw command lines: 1. `c64 test `: headless run. Prints the decoded screen and PASS/FAIL, and leaves - `ram.bin`, `io.bin`, `screenshot.png`, and `monitor.log` in `build/test/`. + `ram.bin`, `io.bin`, `screenshot.png`, and `monitor.log` in `build/test//`. 2. `c64 test -Until