# Toolchain selection guide How the Foundry chooses a language, toolchain and emulator configuration, and what each verified starter configuration contains. The machine-readable version is [catalog/recipes.json](../catalog/recipes.json). ## 1. Decide the target first | Need | Platform / display | |---|---| | Runs on a C64 | `c64` / `vicii-40` | | Native C128 mode, 40 columns (VIC-II, composite/RF) | `c128-native` / `vicii-40` | | Native C128 mode, 80 columns (VDC, RGBI) | `c128-native` / `vdc-80` | | The same C64 program on a C128 | add `c128-c64mode` / `vicii-40` with `dualTarget.strategy = c64-mode-on-both` | | C64 build and a native C128 build | `c64` + `c128-native` with `native-per-target` | 80-column output exists only in native C128 mode. A C64 (or a C128 in C64 mode) cannot use the VDC. ## 2. Choose the simplest language that meets the brief Work down this list and stop at the first language that meets every requirement: 1. **BASIC** (V2 on C64, 7.0 on C128): text menus, quizzes, turn-based games, small utilities where a response of about a second is fine. It can be edited on the machine. 2. **C (cc65)**: anything that needs speed, more structure, file processing, or several objects moving every few frames. It also covers C64 and C128 builds from one source. 3. **C + ca65 assembly (mixed)**: as C, plus a named subsystem that needs exact timing or maximum speed (raster-synchronised frame loop, raster interrupts, SID driver, a hot inner loop). 4. **ca65 assembly only**: demos and effects that are mostly timing-critical, or when the user wants assembly. Check each criterion that applies: | Criterion | BASIC V2 / 7.0 | C (cc65) | C + asm | ca65 asm | |---|---|---|---|---| | CPU timing (frame-locked updates, many movers) | poor | fair-good | good | best | | Raster interrupts / cycle-exact effects | no | no | yes (asm part) | yes | | Memory and code size | compact source, slow; about 38 KB free (C64) | larger code; runtime about 2-4 KB | as C | smallest | | Display: 40-col text, sprites, charset | yes (POKEs) | yes | yes | yes | | Display: 80-col VDC | BASIC 7.0 prints directly | conio `videomode()` | yes | manual VDC access | | Sound (SID) | POKE / BASIC 7 `SOUND`/`PLAY` | yes | yes | yes | | Disk I/O (SEQ/PRG) | `OPEN`/`GET#`/`INPUT#` (slow byte loops) | `cbm_open`/`cbm_read`, stdio | yes | KERNAL calls | | C64/C128 portability | separate dialects | one source, `-t c64` / `-t c128` | yes | per-target code | | Maintainability | easy to read, hard to structure | good | good, if the asm stays small | hardest | | On-machine editing | yes | no | no | only with a native assembler | | Commodore 1351 mouse (`mouse-1351`) | no (conflict) | Foundry reader `src/mouse1351.s` (added automatically on C64 / C128-in-C64-mode); **not** cc65s `c64_1351_mou`, which wanders under VICE 3.10 | yes (same reader) | yes (read POTX/POTY with port 1 settled for > 512 cycles, as in `templates/capabilities/mouse-1351`) | The capability names in the brief (`smooth-animation`, `raster-interrupts`, `vdc-80col`, `mouse-1351`, ...) are checked against these limits by the validator. A user override that breaks one is reported as a **conflict**, and the user decides which constraint to change. ## 3. Verified starter configurations All configurations marked **verified** were built, run headless in VICE and checked automatically by `tests/Run-FoundryTests.ps1` on 2026-11-26 with: - cc65 `cl65 V2.19 - Git cc3c40c` (Windows x64 snapshot) - VICE 3.10 GTK3 win64 (`x64sc`, `x128`, `c1541`, `petcat`) - PowerShell 7.6.7 and git 2.53.0 on Windows 11 Pro 10.0.26200 | Recipe | Language | Platform / display | Emulator | Status | Exercised by (test brief) | |---|---|---|---|---|---| | `cc65` | C | c64 / vicii-40 | `x64sc` | verified | dual-native (c64) | | `cc65` | C + ca65 | c64 / vicii-40 | `x64sc` | verified | examples/traffic-control-64 | | `cc65` | ca65 | c64 / vicii-40 | `x64sc` | verified | override-asm | | `cc65` | C | c128-native / vicii-40 | `x128 -40col` | verified | multi-display-c (c128-40) | | `cc65` | ca65 | c128-native / vicii-40 | `x128 -40col` | verified | c128-40-asm | | `cc65` | C | c128-native / vdc-80 | `x128 -80col` | verified | examples/c128-text-viewer (disk autostart), dual-native, multi-display-c | | `cc65` | C | c128-c64mode / vicii-40 | `x128 -go64` | verified | dual-c64mode-c | | `cc65` | C + 1351 mouse | c64 / vicii-40 | `x64sc -controlport1device 3` | verified (Foundry reader; no drift over 100 idle frames; pointer movement is a manual check) | mouse-1351-c | | `cc65` | ca65 | c128-native / vdc-80 | `x128 -80col` | **unverified** | validation plan in the catalog | | `basic-petcat` | BASIC V2 | c64 / vicii-40 | `x64sc` | verified | dual-c64mode (c64) | | `basic-petcat` | BASIC V2 | c128-c64mode / vicii-40 | `x128 -go64` | verified | dual-c64mode (c128-in-c64-mode) | | `basic-petcat` | BASIC 7.0 | c128-native / vicii-40 | `x128 -40col` | verified | c128-40-basic7 | | `basic-petcat` | BASIC 7.0 | c128-native / vdc-80 | `x128 -80col` | verified | c128-80-basic7 (mode flag automated; text by screenshot) | | `basic-onboard` | BASIC V2 | c64 / vicii-40 | `x64sc` (disk load-and-run) | verified | on-commodore-basic + transfer round trip | | `basic-onboard` | BASIC 7.0 | c128-native / vdc-80 | `x128 -80col` (disk load-and-run) | verified | on-commodore-basic7 | | `basic-onboard` | BASIC 7.0 | c128-native / vicii-40 | `x128 -40col` | verified | same scripts as the 80-column row and c128-40-basic7 | | `asm-onboard` | native assembler | c64, c128-native | `x64sc` / `x128` | **unverified** | unverified-onboard-asm (generation and manual-only path) | Combinations of mixed C + ca65 on the C128 use the same build command as the C and ca65 rows above. `docs/verification-log.md` lists exactly what ran and its results. ### Commands per recipe | Recipe | Build | Run (VICE) | |---|---|---| | `cc65` C / mixed | `cl65 -t c64\|c128 -g -O -I src -o build/x.prg -Ln build/x.lbl -m build/x.map src/*.c src/*.s` | `x64sc -autostart build/x.prg` or `x128 -40col\|-80col -autostart build/x.prg` | | `cc65` asm only | `cl65 -t c64 -C c64-asm.cfg -u __EXEHDR__ -g -o build/x.prg -Ln build/x.lbl src/*.s` (c128: `c128-asm.cfg`) | same | | `basic-petcat` | `petcat -w2 -f -o build/x.prg -- src/main.bas` (7.0: `-w70`) | same | | disk image | `c1541 -format "name,id" d64 build/x.d64 -write build/x.prg x -write sample.petscii "sample,s"` | `x128 -80col -autostart build/x.d64` | | on-Commodore BASIC | to target: `tools/to-commodore.ps1` (petcat + c1541); back: `tools/from-commodore.ps1` (`c1541 -read`, `petcat -nh -2 -f -o src/main.bas -- x.prg`) | `LOAD"X",8` then `RUN` | C128 note: cc65 c128 programs load at `$1C01`. `videomode(VIDEOMODE_80COL)` switches conio to the VDC. A C64 started with `x128 -go64` reports the C64 KERNAL reset vector `$FCE2`, which the smoke test checks. ## 4. Emulator options used (VICE 3.10) | Option | Used for | Source | |---|---|---| | `-autostart ` | Load and run a PRG or disk image | [VICE manual 2.1](https://vice-emu.sourceforge.io/vice_2.html#SEC50) | | `-autostartprgmode 1` | Inject the PRG into RAM (fast, no drive) | [VICE manual 6.3.2](https://vice-emu.sourceforge.io/vice_6.html#SEC89) | | `-8 ` | Attach a disk image to drive 8 | VICE `-help` | | `-40col` / `-80col` / `-go64` | x128 display key / C64 mode | [VICE manual 7.2.4.2](https://vice-emu.sourceforge.io/vice_7.html#SEC194) | | `-pal` / `-ntsc` | Video standard | VICE `-help` | | `-controlport1device 3` | Commodore 1351 mouse in control port 1; added automatically for briefs with the `mouse-1351` capability | `x64sc -help` / `x128 -help` (VICE 3.10) | | `-mouse` / hotkey Alt+M | Grab the host mouse so it drives the emulated 1351 (GTK3 default hotkey; the WinVICE legacy hotkey file uses Alt+Q) | `x64sc -help`; `hotkeys/hotkeys.vhk` in the VICE 3.10 install | | `-limitcycles ` | Exit after n cycles (smoke runs end this way) | [VICE manual 2.1](https://vice-emu.sourceforge.io/vice_2.html#SEC50) | | `-exitscreenshot` / `-exitscreenshotvicii` | Screenshot on exit (x128: VDC / VIC-II window) | [VICE manual 2.1](https://vice-emu.sourceforge.io/vice_2.html#SEC50) | | `-moncommands ` | Monitor commands at start (tracepoints) | [VICE manual 6.17.2](https://vice-emu.sourceforge.io/vice_6.html#SEC139) | | monitor `trace exec\|store `, `command "..."`, `bsave` | Save memory when the program reaches its ready point, without stopping | [VICE manual 12.7-12.8](https://vice-emu.sourceforge.io/vice_12.html#SEC339) | | `-config -default -warp -minimized -sounddev dummy` | Isolated, fast, quiet smoke runs | [VICE manual 2.1, 6.4.2, 6.9.2, 8.1.1](https://vice-emu.sourceforge.io/vice_toc.html) | Observed in VICE 3.10 (not stated in the manual): `c1541 -write ",s"` writes a SEQ file; `petcat -w...` needs `-f` to overwrite an existing output; the x128 `-exitscreenshot` captures the VDC window when started with `-80col`. When VICE quits through `-limitcycles`, its exit code is 1; smoke scripts ignore it and judge only the saved memory. ## 5. On-Commodore workflows The Git repository always stays on the Windows host. - **BASIC (`basic-onboard`)**, verified: `tools/to-commodore.ps1` tokenizes `src/main.bas` and writes a D64 transfer image. The user attaches it in VICE (or copies it to an SD2IEC / 1541 Ultimate / real floppy), types `LOAD"NAME",8`, `RUN`, edits, and `SAVE"@0:NAME",8`. `tools/from-commodore.ps1` reads the PRG back and detokenizes it into `src/main.bas` for review and commit. The round trip is byte-identical (tested). Disk format: D64. Target-side tool: the ROM BASIC screen editor. - **Native assembler (`asm-onboard`)**, unverified: same transfer mechanics; the target-side tool is supplied by the user (for example Turbo Macro Pro). No smoke automation; `docs/toolchain.md` in the generated repo carries the validation plan. Mark the combination verified in the catalog once the plan has been carried out, with date and versions. ## 6. Configurations without a verified starter When a brief needs a combination marked `unverified` (or one missing from the catalog): 1. Tell the user during the toolchain step. 2. Generate anyway if they agree. The generated `docs/toolchain.md` shows status **unverified** and the validation plan. `tools/smoke.ps1` reports `MANUAL` (exit 3) for that target. 3. To promote it, carry out the plan, add an automated check (a test brief in `tests/briefs/`), run `tests/Run-FoundryTests.ps1`, and set `"status": "verified"` in the catalog. ## 7. Real hardware VICE is the default reference. Real hardware is recorded in the brief (`testing.realHardware`) when the user asks for it or a requirement depends on it (exact timing, a specific drive, REU, RGBI monitor). Every generated `docs/manual-tests.md` includes transfer and load steps for real machines. Results are recorded only when the user reports them. ## Sources - cc65: , , , , install - VICE: manual , c1541 , petcat , monitor , download (winget id `VICE-Team.VICE.GTK3`)