cc65's c64_1351_mou wanders under VICE 3.10 with no input (775 pointer moves in 780 idle frames, headless). Add templates/capabilities/mouse-1351 (src/mouse1351.s/.h from stonehold-64 M2.2: control port 1 selected and settled for 12 raster lines before POTX/POTY are read; 0 moves in 810 idle frames) and a catalog capabilityFiles entry, so generated C and mixed C + ca65 repos on c64/c128-c64mode that list mouse-1351 get it. Other languages/platforms get a doc note pointing to the method. The mouse-1351-c fixture uses the reader and checks MOUSE STILL (no drift over 100 idle frames); a new test covers when the reader is copied. Docs and verification log updated. Test suite: 117 passed, 0 failed. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>main
| @@ -96,12 +96,21 @@ | |||||
| "smooth-animation": "Several objects updated every frame or every few frames in a steady frame-locked loop.", | "smooth-animation": "Several objects updated every frame or every few frames in a steady frame-locked loop.", | ||||
| "raster-interrupts": "Cycle-sensitive raster interrupts, raster splits or stable raster timing.", | "raster-interrupts": "Cycle-sensitive raster interrupts, raster splits or stable raster timing.", | ||||
| "vdc-80col": "Native C128 80-column output through the VDC (8563/8568).", | "vdc-80col": "Native C128 80-column output through the VDC (8563/8568).", | ||||
| "mouse-1351": "Commodore 1351 mouse in proportional mode in control port 1 (cc65 drivers c64_1351_mou / c128_1351_mou, or POT reads in assembly). VICE emulates it on control port 1." | |||||
| "mouse-1351": "Commodore 1351 mouse in proportional mode in control port 1, read by the Foundry's src/mouse1351.s (port 1 selected and settled before POTX/POTY are read). Do not use cc65's c64_1351_mou driver: under VICE 3.10 its pointer wanders with no input. VICE emulates the mouse on control port 1." | |||||
| }, | |||||
| "capabilityFiles": { | |||||
| "mouse-1351": { | |||||
| "dir": "capabilities/mouse-1351", | |||||
| "languages": ["c", "mixed-c-asm"], | |||||
| "platforms": ["c64", "c128-c64mode"], | |||||
| "note": "src/mouse1351.s + src/mouse1351.h: call ms_init() once, then ms_poll() once per frame (IRQs off for about 12 raster lines); ms_x/ms_y = pointer tip 0..319/0..199, ms_buttons = MS_LEFT|MS_RIGHT; sprite 0 is the pointer (shape at $0340, pointer at $07F8). Do not use cc65's c64_1351_mou driver: under VICE 3.10 it reads stale/cross-port POT samples and the pointer wanders with no input.", | |||||
| "sources": ["stonehold-64 M2.2 (b28dde6): own POT reader after cc65 driver failed", "Foundry verification log 2026-11-26: idle test, cc65 driver 775 pointer moves in 780 frames, mouse1351.s 0 in 810"] | |||||
| } | |||||
| }, | }, | ||||
| "capabilityEmulator": { | "capabilityEmulator": { | ||||
| "mouse-1351": { | "mouse-1351": { | ||||
| "args": ["-controlport1device", "3"], | "args": ["-controlport1device", "3"], | ||||
| "note": "Control port 1 = Mouse (1351). Grab the host mouse in VICE with Alt+M (default GTK3 hotkeys; Alt+Q with the WinVICE legacy hotkey file) or start VICE with -mouse; without a grab the C64 pointer does not move. Press Alt+M again to release it.", | |||||
| "note": "Control port 1 = Mouse (1351). Grab the host mouse in VICE with Alt+M (default GTK3 hotkeys; Alt+Q with the WinVICE legacy hotkey file) or start VICE with -mouse; without a grab the C64 pointer does not move. Press Alt+M again to release it. Read the mouse with src/mouse1351.s, not cc65's c64_1351_mou driver (it wanders under VICE 3.10).", | |||||
| "sources": ["x64sc -help / x128 -help (VICE 3.10): -controlport1device 3 = Mouse (1351); -mouse = Enable mouse grab", "VICE 3.10 hotkeys/hotkeys.vhk: mouse-grab-toggle <Alt>m","https://cc65.github.io/doc/c64.html#toc6.3 (c64-1351.mou: standard mouse in port #0, i.e. control port 1)"] | "sources": ["x64sc -help / x128 -help (VICE 3.10): -controlport1device 3 = Mouse (1351); -mouse = Enable mouse grab", "VICE 3.10 hotkeys/hotkeys.vhk: mouse-grab-toggle <Alt>m","https://cc65.github.io/doc/c64.html#toc6.3 (c64-1351.mou: standard mouse in port #0, i.e. control port 1)"] | ||||
| } | } | ||||
| }, | }, | ||||
| @@ -94,7 +94,7 @@ The **resume stage** is the first interview stage with missing fields. If nothin | |||||
| | `scope.firstRelease` | One paragraph | | | `scope.firstRelease` | One paragraph | | ||||
| | `scope.inScope[]`, `scope.outOfScope[]` | Both non-empty | | | `scope.inScope[]`, `scope.outOfScope[]` | Both non-empty | | ||||
| | `requirements[]` | `{ id: R1.., title, priority: must/should/could, text, acceptance[] (observable), capabilities[] }` | | | `requirements[]` | `{ id: R1.., title, priority: must/should/could, text, acceptance[] (observable), capabilities[] }` | | ||||
| | `capabilities[]` | Union of what the project needs; names from `catalog/recipes.json` (`text-ui`, `keyboard-input`, `joystick-input`, `disk-seq-io`, `sprites`, `custom-charset`, `sid-sound`, `smooth-animation`, `raster-interrupts`, `vdc-80col`, `mouse-1351`). The validator checks them against the language and display. Capabilities listed under `capabilityEmulator` in the catalog also add emulator options to every target (`mouse-1351`: VICE `-controlport1device 3`). | | |||||
| | `capabilities[]` | Union of what the project needs; names from `catalog/recipes.json` (`text-ui`, `keyboard-input`, `joystick-input`, `disk-seq-io`, `sprites`, `custom-charset`, `sid-sound`, `smooth-animation`, `raster-interrupts`, `vdc-80col`, `mouse-1351`). The validator checks them against the language and display. Capabilities listed under `capabilityEmulator` in the catalog also add emulator options to every target (`mouse-1351`: VICE `-controlport1device 3`). Capabilities under `capabilityFiles` also add source files to the generated repo when the language and every target platform fit (`mouse-1351`: `src/mouse1351.s` / `.h` from `templates/capabilities/mouse-1351` for C and mixed C + ca65 on `c64` / `c128-c64mode`). | | |||||
| ### `design` | ### `design` | ||||
| @@ -38,7 +38,7 @@ Check each criterion that applies: | |||||
| | C64/C128 portability | separate dialects | one source, `-t c64` / `-t c128` | yes | per-target code | | | 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 | | | 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 | | | On-machine editing | yes | no | no | only with a native assembler | | ||||
| | Commodore 1351 mouse (`mouse-1351`) | no (conflict) | cc65 driver `c64_1351_mou` / `c128_1351_mou` | yes | yes (link the cc65 driver or read the SID POT registers) | | |||||
| | 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`, ...) | 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 | are checked against these limits by the validator. A user override that breaks one is reported | ||||
| @@ -62,7 +62,7 @@ by `tests/Run-FoundryTests.ps1` on 2026-11-26 with: | |||||
| | `cc65` | ca65 | c128-native / vicii-40 | `x128 -40col` | verified | c128-40-asm | | | `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-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 | c128-c64mode / vicii-40 | `x128 -go64` | verified | dual-c64mode-c | | ||||
| | `cc65` | C + 1351 mouse | c64 / vicii-40 | `x64sc -controlport1device 3` | verified (driver install; pointer movement is a manual check) | mouse-1351-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 | | | `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 | 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 V2 | c128-c64mode / vicii-40 | `x128 -go64` | verified | dual-c64mode (c128-in-c64-mode) | | ||||
| @@ -95,3 +95,26 @@ Outcome: **116 passed, 0 failed, 0 skipped**. | |||||
| Still manual: pointer movement and button presses with a grabbed host mouse (headless VICE has no host mouse), | Still manual: pointer movement and button presses with a grabbed host mouse (headless VICE has no host mouse), | ||||
| and the C128 driver `c128_1351_mou` (present in the cc65 snapshot, not exercised by a test brief). | and the C128 driver `c128_1351_mou` (present in the cc65 snapshot, not exercised by a test brief). | ||||
| ## 6. Addendum 2026-11-26: Foundry 1351 reader replaces cc65's driver | |||||
| cc65's `c64_1351_mou` wanders under VICE 3.10 with no mouse input. Headless x64sc with | |||||
| `-controlport1device 3` and nothing touching the mouse: | |||||
| | Reader | Frames | Pointer moves with no input | | |||||
| |---|---|---| | |||||
| | cc65 `c64_1351_mou` (`mouse_install` + `mouse_info` once per frame) | 780 | 775 (159,99 -> 221,165) | | |||||
| | `templates/capabilities/mouse-1351/src/mouse1351.s` (`ms_poll` once per frame) | 810 | 0 | | |||||
| Raw POTX/POTY read once per frame at raster 100 without settling: mostly $40/$41 with spikes such | |||||
| as $72/$77, which the cc65 delta maths turns into jumps. The Foundry reader (from stonehold-64 | |||||
| M2.2) selects control port 1 and waits 12 raster lines (> one 512-cycle SID POT sample) with IRQs | |||||
| off before reading. It is now added to generated C / mixed C + ca65 repos on `c64` / | |||||
| `c128-c64mode` that list `mouse-1351` (`capabilityFiles` in the catalog). | |||||
| ```powershell | |||||
| pwsh -File tests/Run-FoundryTests.ps1 | |||||
| ``` | |||||
| Outcome: **117 passed, 0 failed, 0 skipped**. `mouse-1351-c` now also checks `MOUSE STILL` | |||||
| (no pointer movement over 100 idle frames). Still manual: movement with a grabbed host mouse. | |||||
| @@ -0,0 +1,17 @@ | |||||
| #ifndef FOUNDRY_MOUSE1351_H | |||||
| #define FOUNDRY_MOUSE1351_H | |||||
| /* Commodore 1351 mouse in control port 1, read once per frame (mouse1351.s). | |||||
| ** Pointer = sprite 0, tip at its top-left pixel. */ | |||||
| #define MS_LEFT 0x10 | |||||
| #define MS_RIGHT 0x01 | |||||
| extern int ms_x, ms_y; /* pointer tip in screen pixels: 0..319, 0..199 */ | |||||
| extern unsigned char ms_buttons; /* MS_LEFT | MS_RIGHT while held */ | |||||
| void ms_init(void); /* sprite set-up, first sample, pointer at (160, 100) */ | |||||
| void ms_poll(void); /* call once per frame: IRQs off for about 12 raster lines */ | |||||
| void __fastcall__ ms_move(int x, int y); | |||||
| #endif | |||||
| @@ -0,0 +1,289 @@ | |||||
| ; Commodore 1351 mouse in control port 1, read once per frame. | |||||
| ; | |||||
| ; Why not cc65's c64-1351 driver: in VICE 3.10 its IRQ read the SID POT registers while | |||||
| ; they held stale or cross-port samples (255 in ~30% of reads), so the pointer wandered | |||||
| ; with no input (Foundry docs/verification-log.md, mouse addendum). This reader keeps | |||||
| ; control port 1 selected with IRQs off for SETTLE_LINES raster lines, which is longer than | |||||
| ; one 512-cycle SID POT sample, and only then reads POTX/POTY. | |||||
| ; | |||||
| ; Movement maths as in cc65's driver: 7-bit wrapped difference, halved, +-1 ignored, and the | |||||
| ; old value kept until the pointer moves, so slow movement still adds up. | |||||
| ; | |||||
| ; Buttons are read from CIA1 port B with no keyboard column selected (left = bit 4, | |||||
| ; right = bit 0). While a button is held, port B is switched to output with all bits low, | |||||
| ; so the KERNAL keyboard scan sees every key held and decodes nothing. Otherwise a click | |||||
| ; would look like SPACE and similar keys. | |||||
| ; | |||||
| ; The pointer is sprite 0: shape at SPR_MEM ($0340, cassette buffer, VIC bank 0), | |||||
| ; sprite pointer at $07F8 (screen $0400), tip = top-left pixel. | |||||
| ; | |||||
| ; C interface (mouse1351.h): | |||||
| ; void ms_init(void); sprite set-up, first sample, pointer at (160,100) | |||||
| ; void ms_poll(void); once per frame: move pointer, read buttons | |||||
| ; void __fastcall__ ms_move(int x, int y); place the pointer | |||||
| ; extern int ms_x, ms_y; pointer tip, 0..319 / 0..199 | |||||
| ; extern unsigned char ms_buttons; MS_LEFT ($10) | MS_RIGHT ($01) | |||||
| .export _ms_init, _ms_poll, _ms_move | |||||
| .export _ms_x, _ms_y, _ms_buttons | |||||
| .import popax | |||||
| SPR_MEM = $0340 | |||||
| SPR_PTR0 = $07F8 | |||||
| VIC_SPR0_X = $D000 | |||||
| VIC_SPR0_Y = $D001 | |||||
| VIC_SPR_HI_X = $D010 | |||||
| VIC_RASTER = $D012 | |||||
| VIC_SPR_ENA = $D015 | |||||
| VIC_SPR_EXPY = $D017 | |||||
| VIC_SPR_BG = $D01B | |||||
| VIC_SPR_MCOL = $D01C | |||||
| VIC_SPR_EXPX = $D01D | |||||
| VIC_SPR0_COL = $D027 | |||||
| SID_POTX = $D419 | |||||
| SID_POTY = $D41A | |||||
| CIA1_PRA = $DC00 | |||||
| CIA1_PRB = $DC01 | |||||
| CIA1_DDRA = $DC02 | |||||
| CIA1_DDRB = $DC03 | |||||
| MAX_X = 319 | |||||
| MAX_Y = 199 | |||||
| SETTLE_LINES = 12 ; 12 lines = 756 cycles PAL, 780 NTSC (> 512-cycle sample) | |||||
| POINTER_COL = 1 ; white | |||||
| .segment "BSS" | |||||
| _ms_x: .res 2 | |||||
| _ms_y: .res 2 | |||||
| _ms_buttons: .res 1 | |||||
| pot_x: .res 1 | |||||
| pot_y: .res 1 | |||||
| old_x: .res 1 | |||||
| old_y: .res 1 | |||||
| tmp: .res 1 | |||||
| .segment "RODATA" | |||||
| ; Arrow pointer, tip at the top-left pixel. 21 rows x 3 bytes. | |||||
| arrow: | |||||
| .byte %11000000, 0, 0 | |||||
| .byte %11100000, 0, 0 | |||||
| .byte %11110000, 0, 0 | |||||
| .byte %11111000, 0, 0 | |||||
| .byte %11111100, 0, 0 | |||||
| .byte %11111110, 0, 0 | |||||
| .byte %11111111, 0, 0 | |||||
| .byte %11111000, 0, 0 | |||||
| .byte %11011000, 0, 0 | |||||
| .byte %10001100, 0, 0 | |||||
| .byte %00001100, 0, 0 | |||||
| .byte %00000110, 0, 0 | |||||
| .res 9 * 3, 0 | |||||
| .segment "CODE" | |||||
| _ms_init: | |||||
| ldx #62 | |||||
| @copy: lda arrow,x | |||||
| sta SPR_MEM,x | |||||
| dex | |||||
| bpl @copy | |||||
| lda #<(SPR_MEM / 64) | |||||
| sta SPR_PTR0 | |||||
| lda #POINTER_COL | |||||
| sta VIC_SPR0_COL | |||||
| lda #$FE ; sprite 0: no expansion, hi-res, in front of text | |||||
| and VIC_SPR_EXPY | |||||
| sta VIC_SPR_EXPY | |||||
| lda #$FE | |||||
| and VIC_SPR_EXPX | |||||
| sta VIC_SPR_EXPX | |||||
| lda #$FE | |||||
| and VIC_SPR_MCOL | |||||
| sta VIC_SPR_MCOL | |||||
| lda #$FE | |||||
| and VIC_SPR_BG | |||||
| sta VIC_SPR_BG | |||||
| jsr sample | |||||
| lda pot_x | |||||
| sta old_x | |||||
| lda pot_y | |||||
| sta old_y | |||||
| lda #<160 | |||||
| sta _ms_x | |||||
| lda #>160 | |||||
| sta _ms_x+1 | |||||
| lda #100 | |||||
| sta _ms_y | |||||
| lda #0 | |||||
| sta _ms_y+1 | |||||
| jsr place | |||||
| lda VIC_SPR_ENA | |||||
| ora #$01 | |||||
| sta VIC_SPR_ENA | |||||
| rts | |||||
| ; ms_move(x, y): y in A/X, x on the C stack. | |||||
| _ms_move: | |||||
| sta _ms_y | |||||
| stx _ms_y+1 | |||||
| jsr popax | |||||
| sta _ms_x | |||||
| stx _ms_x+1 | |||||
| jmp place | |||||
| _ms_poll: | |||||
| jsr sample | |||||
| lda pot_x ; X: right = POTX up | |||||
| ldy old_x | |||||
| jsr delta | |||||
| beq @no_x | |||||
| jsr add_x | |||||
| lda pot_x | |||||
| sta old_x | |||||
| @no_x: | |||||
| lda pot_y ; Y: the 1351 counts up when moved away (up) | |||||
| ldy old_y | |||||
| jsr delta | |||||
| beq @no_y | |||||
| eor #$FF ; negate: screen y grows downwards | |||||
| clc | |||||
| adc #1 | |||||
| jsr add_y | |||||
| lda pot_y | |||||
| sta old_y | |||||
| @no_y: | |||||
| jmp place | |||||
| ; Read POTX/POTY with port 1 selected long enough, then the buttons. | |||||
| sample: | |||||
| php | |||||
| sei | |||||
| lda #$FF | |||||
| sta CIA1_DDRA ; port A output (KERNAL default) | |||||
| lda #$7F ; bit 6 = 1: POT lines see control port 1 | |||||
| sta CIA1_PRA | |||||
| ldx #SETTLE_LINES | |||||
| @line: lda VIC_RASTER | |||||
| @same: cmp VIC_RASTER | |||||
| beq @same | |||||
| dex | |||||
| bne @line | |||||
| lda SID_POTX | |||||
| sta pot_x | |||||
| lda SID_POTY | |||||
| sta pot_y | |||||
| lda #$00 ; port B input, no keyboard column selected: | |||||
| sta CIA1_DDRB ; only control port 1 can pull port B low | |||||
| lda #$FF | |||||
| sta CIA1_PRA | |||||
| lda CIA1_PRB | |||||
| eor #$FF | |||||
| and #$11 ; bit 4 left button, bit 0 right button | |||||
| sta _ms_buttons | |||||
| lda #$7F | |||||
| sta CIA1_PRA | |||||
| lda _ms_buttons | |||||
| beq @done | |||||
| lda #$FF ; button held: blind the keyboard scan | |||||
| sta CIA1_DDRB | |||||
| lda #$00 | |||||
| sta CIA1_PRB | |||||
| @done: plp | |||||
| rts | |||||
| ; A = new POT value, Y = old. Returns the signed movement in A (Z set if none). | |||||
| delta: | |||||
| sty tmp | |||||
| sec | |||||
| sbc tmp | |||||
| and #%01111111 | |||||
| cmp #%01000000 | |||||
| bcs @neg | |||||
| lsr a ; 0..31 | |||||
| rts | |||||
| @neg: ora #%11000000 ; -64..-1 | |||||
| sec | |||||
| ror a ; -32..-1 | |||||
| cmp #$FF | |||||
| bne @ret | |||||
| lda #0 ; -1 counts as noise | |||||
| @ret: rts | |||||
| ; Add signed A to ms_x and clamp to 0..MAX_X. | |||||
| add_x: | |||||
| ldx #0 | |||||
| cmp #$80 | |||||
| bcc :+ | |||||
| dex | |||||
| : clc | |||||
| adc _ms_x | |||||
| sta _ms_x | |||||
| txa | |||||
| adc _ms_x+1 | |||||
| sta _ms_x+1 | |||||
| bmi @zero | |||||
| cmp #>MAX_X | |||||
| bcc @ok | |||||
| bne @max | |||||
| lda _ms_x | |||||
| cmp #<MAX_X + 1 | |||||
| bcc @ok | |||||
| @max: lda #<MAX_X | |||||
| sta _ms_x | |||||
| lda #>MAX_X | |||||
| sta _ms_x+1 | |||||
| @ok: rts | |||||
| @zero: lda #0 | |||||
| sta _ms_x | |||||
| sta _ms_x+1 | |||||
| rts | |||||
| ; Add signed A to ms_y and clamp to 0..MAX_Y. | |||||
| add_y: | |||||
| ldx #0 | |||||
| cmp #$80 | |||||
| bcc :+ | |||||
| dex | |||||
| : clc | |||||
| adc _ms_y | |||||
| sta _ms_y | |||||
| txa | |||||
| adc _ms_y+1 | |||||
| sta _ms_y+1 | |||||
| bmi @zero | |||||
| bne @max | |||||
| lda _ms_y | |||||
| cmp #MAX_Y + 1 | |||||
| bcc @ok | |||||
| @max: lda #MAX_Y | |||||
| sta _ms_y | |||||
| lda #0 | |||||
| sta _ms_y+1 | |||||
| @ok: rts | |||||
| @zero: lda #0 | |||||
| sta _ms_y | |||||
| sta _ms_y+1 | |||||
| rts | |||||
| ; Put sprite 0 at the pointer position (tip = sprite top-left). | |||||
| place: | |||||
| lda _ms_x | |||||
| clc | |||||
| adc #24 | |||||
| sta VIC_SPR0_X | |||||
| lda _ms_x+1 | |||||
| adc #0 | |||||
| beq @lo | |||||
| lda VIC_SPR_HI_X | |||||
| ora #$01 | |||||
| bne @hi | |||||
| @lo: lda VIC_SPR_HI_X | |||||
| and #$FE | |||||
| @hi: sta VIC_SPR_HI_X | |||||
| lda _ms_y | |||||
| clc | |||||
| adc #50 | |||||
| sta VIC_SPR0_Y | |||||
| rts | |||||
| @@ -132,6 +132,19 @@ if ('validation' -in $Group) { | |||||
| Assert (-not ((@($r2.targets[0].emulator.args) -join ' ') -match 'controlport')) 'mouse args added without the capability' | Assert (-not ((@($r2.targets[0].emulator.args) -join ' ') -match 'controlport')) 'mouse args added without the capability' | ||||
| $emuArgs | $emuArgs | ||||
| } | } | ||||
| Invoke-Check 'validation: mouse-1351 brings the Foundry 1351 reader (not cc65''s driver) for C on the C64 only' { | |||||
| $r = Resolve-FoundryProject -Brief (Read-FoundryJson (Join-Path $root 'tests/briefs/mouse-1351-c.json')) | |||||
| $cf = @($r.capabilityFiles) | |||||
| Assert ($cf.Count -eq 1 -and $cf[0].dir -eq 'capabilities/mouse-1351') "capability files: $($cf | ConvertTo-Json -Compress)" | |||||
| Assert (Test-Path -LiteralPath (Join-Path $root 'templates/capabilities/mouse-1351/src/mouse1351.s')) 'reader template missing' | |||||
| $r2 = Resolve-FoundryProject -Brief (Read-FoundryJson (Join-Path $root 'tests/briefs/dual-c64mode-c.json')) | |||||
| Assert (@($r2.capabilityFiles).Count -eq 0) 'reader added without the capability' | |||||
| $b = Read-FoundryJson (Join-Path $root 'tests/briefs/c128-40-asm.json') | |||||
| $b.capabilities = @(@($b.capabilities) + 'mouse-1351') | |||||
| $r3 = Resolve-FoundryProject -Brief $b | |||||
| Assert (@($r3.capabilityFiles).Count -eq 1 -and -not $r3.capabilityFiles[0].dir) 'reader copied for an assembly C128 project' | |||||
| $cf[0].dir | |||||
| } | |||||
| Invoke-Check 'validation: dual-target strategy must match the targets' { | Invoke-Check 'validation: dual-target strategy must match the targets' { | ||||
| $b = Read-FoundryJson (Join-Path $root 'tests/briefs/dual-native.json') | $b = Read-FoundryJson (Join-Path $root 'tests/briefs/dual-native.json') | ||||
| $b.dualTarget.strategy = 'c64-mode-on-both' | $b.dualTarget.strategy = 'c64-mode-on-both' | ||||
| @@ -1,50 +1,42 @@ | |||||
| /* Mouse Probe - Foundry test fixture for the mouse-1351 capability. | /* Mouse Probe - Foundry test fixture for the mouse-1351 capability. | ||||
| ** Installs the statically linked cc65 1351 driver (control port 1), shows sprite 0 | |||||
| ** as the pointer and reports the install result on row 3. | |||||
| ** Uses the Foundry's src/mouse1351.s (added for briefs with mouse-1351): sprite 0 is the | |||||
| ** pointer. With no input the pointer must not move: 100 polled frames, then row 4 says | |||||
| ** MOUSE STILL (or MOUSE DRIFT if the reader returned movement without input). | |||||
| */ | */ | ||||
| #include <conio.h> | #include <conio.h> | ||||
| #include <string.h> | |||||
| #include <mouse.h> | |||||
| #include <c64.h> | |||||
| #include "smoke.h" | #include "smoke.h" | ||||
| #include "mouse1351.h" | |||||
| #define SPRITE_BLOCK 13 /* $0340: cassette buffer, free while the program runs */ | |||||
| static const unsigned char arrow[21] = { | |||||
| 0xC0, 0xE0, 0xF0, 0xF8, 0xFC, 0xFE, 0xF8, 0xD8, 0x8C, 0x0C, 0x06, | |||||
| 0x06, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 | |||||
| }; | |||||
| #define RASTER (*(volatile unsigned char *)0xD012) | |||||
| int main(void) | int main(void) | ||||
| { | { | ||||
| unsigned char *spr = (unsigned char *)(SPRITE_BLOCK * 64); | |||||
| unsigned char i, rc; | |||||
| memset(spr, 0, 64); | |||||
| for (i = 0; i < sizeof arrow; ++i) { | |||||
| spr[i * 3] = arrow[i]; | |||||
| } | |||||
| *(unsigned char *)0x07F8 = SPRITE_BLOCK; | |||||
| VIC.spr0_color = COLOR_WHITE; | |||||
| unsigned char i; | |||||
| int x0, y0; | |||||
| clrscr(); | clrscr(); | ||||
| cputsxy(0, 0, "MOUSE PROBE"); | cputsxy(0, 0, "MOUSE PROBE"); | ||||
| cputsxy(0, 2, "STARTER OK"); | cputsxy(0, 2, "STARTER OK"); | ||||
| rc = mouse_install(&mouse_def_callbacks, c64_1351_mou); | |||||
| if (rc == MOUSE_ERR_OK) { | |||||
| mouse_show(); | |||||
| cputsxy(0, 3, "MOUSE OK"); | |||||
| } else { | |||||
| cputsxy(0, 3, "MOUSE ERROR"); | |||||
| ms_init(); | |||||
| cputsxy(0, 3, "MOUSE OK"); | |||||
| x0 = ms_x; | |||||
| y0 = ms_y; | |||||
| for (i = 0; i < 100; ++i) { | |||||
| while (RASTER != 250) { } | |||||
| while (RASTER == 250) { } | |||||
| ms_poll(); | |||||
| } | } | ||||
| cputsxy(0, 4, (ms_x == x0 && ms_y == y0) ? "MOUSE STILL" : "MOUSE DRIFT"); | |||||
| cputsxy(0, 5, "ANY KEY EXITS"); | cputsxy(0, 5, "ANY KEY EXITS"); | ||||
| smoke_capture(); | smoke_capture(); | ||||
| smoke_ready(); | smoke_ready(); | ||||
| while (!kbhit()) { } | |||||
| cgetc(); | |||||
| if (rc == MOUSE_ERR_OK) { | |||||
| mouse_uninstall(); | |||||
| while (!kbhit()) { | |||||
| while (RASTER != 250) { } | |||||
| while (RASTER == 250) { } | |||||
| ms_poll(); | |||||
| } | } | ||||
| cgetc(); | |||||
| *(unsigned char *)0xD015 &= 0xFE; | |||||
| clrscr(); | clrscr(); | ||||
| return 0; | return 0; | ||||
| } | } | ||||
| @@ -16,7 +16,7 @@ | |||||
| "name": "Mouse Probe", | "name": "Mouse Probe", | ||||
| "slug": "mouse-probe", | "slug": "mouse-probe", | ||||
| "idea": "Test idea for Mouse Probe.", | "idea": "Test idea for Mouse Probe.", | ||||
| "summary": "Test project: a C64 C program that installs the cc65 1351 mouse driver.", | |||||
| "summary": "Test project: a C64 C program that reads the 1351 mouse with the Foundry reader.", | |||||
| "kind": "other", | "kind": "other", | ||||
| "smallestUsefulVersion": "Shows its title screen and waits for a key." | "smallestUsefulVersion": "Shows its title screen and waits for a key." | ||||
| }, | }, | ||||
| @@ -27,7 +27,7 @@ | |||||
| "platform": "c64", | "platform": "c64", | ||||
| "display": "vicii-40", | "display": "vicii-40", | ||||
| "video": "pal", | "video": "pal", | ||||
| "expectedBehavior": "Installs the 1351 mouse driver and reports the result." | |||||
| "expectedBehavior": "Reads the 1351 mouse with the Foundry reader and reports that the pointer stays still with no input." | |||||
| } | } | ||||
| ], | ], | ||||
| "dualTarget": null, | "dualTarget": null, | ||||
| @@ -78,7 +78,7 @@ | |||||
| "id": "R3", | "id": "R3", | ||||
| "title": "1351 mouse", | "title": "1351 mouse", | ||||
| "priority": "must", | "priority": "must", | ||||
| "text": "Installs the cc65 1351 mouse driver (control port 1) and shows MOUSE OK when it reports no error.", | |||||
| "text": "Reads the 1351 mouse in control port 1 with the Foundry reader (src/mouse1351.s), shows MOUSE OK, and MOUSE STILL when the pointer stays put with no input.", | |||||
| "acceptance": [ | "acceptance": [ | ||||
| "Row 3 shows MOUSE OK", | "Row 3 shows MOUSE OK", | ||||
| "Moving the grabbed host mouse in VICE moves the sprite pointer" | "Moving the grabbed host mouse in VICE moves the sprite pointer" | ||||
| @@ -154,7 +154,7 @@ | |||||
| }, | }, | ||||
| "starter": { | "starter": { | ||||
| "screenTitle": "MOUSE PROBE", | "screenTitle": "MOUSE PROBE", | ||||
| "expectedScreen": "MOUSE PROBE on row 0, STARTER OK on row 2, MOUSE OK on row 3; the mouse pointer (sprite 0) follows the grabbed host mouse.", | |||||
| "expectedScreen": "MOUSE PROBE on row 0, STARTER OK on row 2, MOUSE OK on row 3, MOUSE STILL on row 4 (no drift over 100 idle frames); the mouse pointer (sprite 0) follows the grabbed host mouse.", | |||||
| "requirements": [ | "requirements": [ | ||||
| "R1", | "R1", | ||||
| "R3" | "R3" | ||||
| @@ -174,7 +174,13 @@ | |||||
| "row": 3, | "row": 3, | ||||
| "col": 0, | "col": 0, | ||||
| "text": "MOUSE OK", | "text": "MOUSE OK", | ||||
| "description": "cc65 1351 driver installed (mouse_install returned MOUSE_ERR_OK)" | |||||
| "description": "Foundry 1351 reader set up (ms_init)" | |||||
| }, | |||||
| { | |||||
| "row": 4, | |||||
| "col": 0, | |||||
| "text": "MOUSE STILL", | |||||
| "description": "Pointer did not move during 100 polled frames with no mouse input" | |||||
| } | } | ||||
| ], | ], | ||||
| "filesDir": "mouse-1351-c-files" | "filesDir": "mouse-1351-c-files" | ||||
| @@ -423,6 +423,14 @@ function Resolve-FoundryProject([hashtable]$Brief, [hashtable]$Catalog = (Get-Fo | |||||
| $ce = if ($Catalog.Contains('capabilityEmulator')) { $Catalog.capabilityEmulator["$c"] } else { $null } | $ce = if ($Catalog.Contains('capabilityEmulator')) { $Catalog.capabilityEmulator["$c"] } else { $null } | ||||
| if ($ce) { $capEmuArgs += @($ce.args); if ($ce.note) { $capEmuNotes += "${c}: $($ce.note)" } } | if ($ce) { $capEmuArgs += @($ce.args); if ($ce.note) { $capEmuNotes += "${c}: $($ce.note)" } } | ||||
| } | } | ||||
| # Source files a capability brings along (for example the 1351 mouse reader), when the language and every platform fit. | |||||
| $capFiles = foreach ($c in Get-List $Brief.capabilities) { | |||||
| $cf = if ($Catalog.Contains('capabilityFiles')) { $Catalog.capabilityFiles["$c"] } else { $null } | |||||
| if (-not $cf) { continue } | |||||
| $fits = ($langId -in @($cf.languages)) -and -not @(Get-List $Brief.targets | Where-Object { $_.platform -notin @($cf.platforms) }) | |||||
| if ($fits) { [ordered]@{ capability = "$c"; dir = $cf.dir; note = $cf.note } } | |||||
| else { [ordered]@{ capability = "$c"; dir = $null; note = "Not added automatically (it is for $(@($cf.languages) -join '/') on $(@($cf.platforms) -join '/'); see the Foundry's templates/$($cf.dir) for the method). $($cf.note)" } } | |||||
| } | |||||
| $toolUse = [ordered]@{} | $toolUse = [ordered]@{} | ||||
| $addUse = { param($tool, $what) if (-not $toolUse.Contains($tool)) { $toolUse[$tool] = [System.Collections.Generic.List[string]]::new() }; if ($what -notin $toolUse[$tool]) { $toolUse[$tool].Add($what) } } | $addUse = { param($tool, $what) if (-not $toolUse.Contains($tool)) { $toolUse[$tool] = [System.Collections.Generic.List[string]]::new() }; if ($what -notin $toolUse[$tool]) { $toolUse[$tool].Add($what) } } | ||||
| @@ -538,6 +546,7 @@ function Resolve-FoundryProject([hashtable]$Brief, [hashtable]$Catalog = (Get-Fo | |||||
| language = $langId | language = $langId | ||||
| languageTitle = $lang.title | languageTitle = $lang.title | ||||
| starter = $recipe.starters[$langId] | starter = $recipe.starters[$langId] | ||||
| capabilityFiles = @($capFiles) | |||||
| tools = @($tools) | tools = @($tools) | ||||
| targets = @($targets) | targets = @($targets) | ||||
| onCommodore = $onCommodore | onCommodore = $onCommodore | ||||
| @@ -690,6 +699,7 @@ function New-DocVariables([hashtable]$Brief, $Resolved, [hashtable]$Catalog, [st | |||||
| if ($t.disk) { $lines += "- Disk image: ``$($t.disk.image)`` ($($t.disk.format), header ``$($t.disk.name)``), files: $((@($t.disk.files) | ForEach-Object { "$($_.name) ($($_.type))" }) -join ', ')" } | if ($t.disk) { $lines += "- Disk image: ``$($t.disk.image)`` ($($t.disk.format), header ``$($t.disk.name)``), files: $((@($t.disk.files) | ForEach-Object { "$($_.name) ($($_.type))" }) -join ', ')" } | ||||
| $lines += "- Emulator: ``$($t.emulator.binary) $emuArgs -autostart $runFile``" | $lines += "- Emulator: ``$($t.emulator.binary) $emuArgs -autostart $runFile``" | ||||
| foreach ($note in @(Get-List $t.emulator.notes)) { $lines += "- Emulator note - $note" } | foreach ($note in @(Get-List $t.emulator.notes)) { $lines += "- Emulator note - $note" } | ||||
| foreach ($cf in @(Get-List $Resolved.capabilityFiles)) { $lines += "- Capability $($cf.capability) - $($cf.note)" } | |||||
| if ($t.smoke) { | if ($t.smoke) { | ||||
| $readyText = if ($t.smoke.ready.symbol) { '`' + $t.smoke.ready.symbol + '`' } else { 'its marker store to $' + $t.smoke.ready.address } | $readyText = if ($t.smoke.ready.symbol) { '`' + $t.smoke.ready.symbol + '`' } else { 'its marker store to $' + $t.smoke.ready.address } | ||||
| $lines += "- Smoke test: ``pwsh -File tools/smoke.ps1 -Target $($t.id)``. It runs VICE headless for $($t.smoke.limitCycles) cycles, saves memory when the program reaches $readyText, and checks:" | $lines += "- Smoke test: ``pwsh -File tools/smoke.ps1 -Target $($t.id)``. It runs VICE headless for $($t.smoke.limitCycles) cycles, saves memory when the program reaches $readyText, and checks:" | ||||
| @@ -906,6 +916,7 @@ function New-FoundryProject { | |||||
| foreach ($inc in (Read-FoundryJson $manifest).include) { Copy-TemplateTree (Join-Path $tpl "starters/$inc") $staging $vars } | foreach ($inc in (Read-FoundryJson $manifest).include) { Copy-TemplateTree (Join-Path $tpl "starters/$inc") $staging $vars } | ||||
| } | } | ||||
| Copy-TemplateTree $starterDir $staging $vars | Copy-TemplateTree $starterDir $staging $vars | ||||
| foreach ($cf in @(Get-List $resolved.capabilityFiles | Where-Object { $_.dir })) { Copy-TemplateTree (Join-Path $tpl $cf.dir) $staging $vars } | |||||
| if ($brief.starter.filesDir) { | if ($brief.starter.filesDir) { | ||||
| $filesDir = (Resolve-Path -LiteralPath (Join-Path (Split-Path $BriefPath -Parent) $brief.starter.filesDir)).ProviderPath | $filesDir = (Resolve-Path -LiteralPath (Join-Path (Split-Path $BriefPath -Parent) $brief.starter.filesDir)).ProviderPath | ||||
| Copy-TemplateTree $filesDir $staging $vars | Copy-TemplateTree $filesDir $staging $vars | ||||
Powered by TurnKey Linux.