Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>main
| @@ -122,6 +122,29 @@ Verifies: R3 | |||||
| Setup: VICE x64sc, NTSC (-ntsc), warp off. | Setup: VICE x64sc, NTSC (-ntsc), warp off. | ||||
| Start: `pwsh -File tools/run.ps1 -Target c64` | Start: `pwsh -File tools/run.ps1 -Target c64` | ||||
| At M3.1 (keys only, no scrolling yet): run `pwsh -File tools/check-keys.ps1` and | |||||
| expect `[PASS] all 8 key scenarios decode correctly`. Then start the program and, | |||||
| while the map is shown, hold each key below for a second or two and release it. | |||||
| Until M3.2 the border colour shows the direction that is held: | |||||
| | Keys held (VICE PC key) | Border | | |||||
| |---|---| | |||||
| | nothing | brown (same as the background) | | |||||
| | CRSR RIGHT (Right arrow) | light green | | |||||
| | SHIFT + CRSR RIGHT (Left arrow) | cyan | | |||||
| | CRSR DOWN (Down arrow) | yellow | | |||||
| | SHIFT + CRSR DOWN (Up arrow) | white | | |||||
| | CRSR RIGHT + CRSR DOWN (Right + Down arrows) | orange | | |||||
| | SHIFT + both (Left + Up arrows) | light blue | | |||||
| Expected at M3.1: the colour stays as long as the key is held and returns to | |||||
| brown on release; both the left and the right SHIFT key work; the dots keep | |||||
| moving smoothly. Tapping SPACE gives a new map; holding SPACE gives exactly one. | |||||
| (Right + Up or Left + Down cannot be told apart on a real C64, because SHIFT | |||||
| reverses both cursor keys; they show grey or one of the colours above.) | |||||
| From M3.2: | |||||
| Steps: | Steps: | ||||
| 1. Hold each cursor key (with SHIFT for up and left) until the view stops. | 1. Hold each cursor key (with SHIFT for up and left) until the view stops. | ||||
| @@ -56,6 +56,7 @@ Starter configurations marked verified were exercised by the Foundry's automated | |||||
| - World generation reached its ready point (`MAP READY`) | - World generation reached its ready point (`MAP READY`) | ||||
| - C64 KERNAL reset vector at $FFFC (machine is in C64 mode) | - C64 KERNAL reset vector at $FFFC (machine is in C64 mode) | ||||
| - World check: `pwsh -File tools/check-world.ps1` validates the tile data saved by the smoke test. | - World check: `pwsh -File tools/check-world.ps1` validates the tile data saved by the smoke test. | ||||
| - Key check: `pwsh -File tools/check-keys.ps1` runs eight headless VICE scenarios. VICE's monitor cannot press keys, so tracepoints on the `key_row_*` instructions in `src/keys.inc` replace the port B row bits with those of held keys (`r a = <bits>`). It checks `scroll_dx`/`scroll_dy` and the border indicator for no key, right, left (right SHIFT), down, up (left SHIFT), down-right and up-left, and that SPACE held from frame 60 regenerates exactly once. Output: `build/check-keys/`. | |||||
| - People check: `pwsh -File tools/check-people.ps1` runs VICE headless (NTSC, warp) for 40,000,000 cycles, logs the people table at the `people_moved` hook every frame through the monitor, and checks that all 16 people stay inside the world, never stand on a water or stone tile, move at most one pixel per step, all move, and start spread over the four screens. It also saves both bitmap buffers before people are drawn and at the last frame, and checks byte for byte that the hidden buffer is the clean map plus the current dots and the visible buffer is the clean map plus the previous frame's dots (no trails, no damaged terrain). It checks that the main loop never misses a frame (x64sc NTSC frame: 263 lines x 65 = 17,095 cycles) and that each people update ends before raster line 51, the first visible line. Output: `build/check-people/`. | - People check: `pwsh -File tools/check-people.ps1` runs VICE headless (NTSC, warp) for 40,000,000 cycles, logs the people table at the `people_moved` hook every frame through the monitor, and checks that all 16 people stay inside the world, never stand on a water or stone tile, move at most one pixel per step, all move, and start spread over the four screens. It also saves both bitmap buffers before people are drawn and at the last frame, and checks byte for byte that the hidden buffer is the clean map plus the current dots and the visible buffer is the clean map plus the previous frame's dots (no trails, no damaged terrain). It checks that the main loop never misses a frame (x64sc NTSC frame: 263 lines x 65 = 17,095 cycles) and that each people update ends before raster line 51, the first visible line. Output: `build/check-people/`. | ||||
| ### How the smoke test works | ### How the smoke test works | ||||
| @@ -14,13 +14,14 @@ manual = `pending`, `confirmed by user (<date>)`, `problem reported (<date>): <n | |||||
| | M1.3 Render the top-left screen of the world into the visible buffer; SPACE regenerates. | passed (2026-12-03, `pwsh -File tools/build.ps1`; `pwsh -File tools/smoke.ps1`; `pwsh -File tools/check-world.ps1`; VICE monitor buffered SPACE and compared all 1,000 visible cells before and after) | confirmed by user (2026-12-03) | | | M1.3 Render the top-left screen of the world into the visible buffer; SPACE regenerates. | passed (2026-12-03, `pwsh -File tools/build.ps1`; `pwsh -File tools/smoke.ps1`; `pwsh -File tools/check-world.ps1`; VICE monitor buffered SPACE and compared all 1,000 visible cells before and after) | confirmed by user (2026-12-03) | | ||||
| | M2.1 People table (world x, y, direction) and movement rules; water and stone block. | passed (2026-12-03, `pwsh -File tools/build.ps1`; `pwsh -File tools/smoke.ps1`; `pwsh -File tools/check-world.ps1`; `pwsh -File tools/check-people.ps1`: 2,106 frames logged, every person stepped 263-264 times, none on water or stone) | confirmed by user (2026-12-03) | | | M2.1 People table (world x, y, direction) and movement rules; water and stone block. | passed (2026-12-03, `pwsh -File tools/build.ps1`; `pwsh -File tools/smoke.ps1`; `pwsh -File tools/check-world.ps1`; `pwsh -File tools/check-people.ps1`: 2,106 frames logged, every person stepped 263-264 times, none on water or stone) | confirmed by user (2026-12-03) | | ||||
| | M2.2 Per-buffer saved-byte lists: restore the bytes under people from two frames ago, draw people in view, flip in vertical blank. | passed (2026-12-03, `pwsh -File tools/build.ps1`; `pwsh -File tools/smoke.ps1`; `pwsh -File tools/check-world.ps1`; `pwsh -File tools/check-people.ps1`: 2,117 frames, 0 missed flips, update done by raster line 26 at the latest, both final bitmaps byte-exact against clean map plus dots) | confirmed by user (2026-12-03) | | | M2.2 Per-buffer saved-byte lists: restore the bytes under people from two frames ago, draw people in view, flip in vertical blank. | passed (2026-12-03, `pwsh -File tools/build.ps1`; `pwsh -File tools/smoke.ps1`; `pwsh -File tools/check-world.ps1`; `pwsh -File tools/check-people.ps1`: 2,117 frames, 0 missed flips, update done by raster line 26 at the latest, both final bitmaps byte-exact against clean map plus dots) | confirmed by user (2026-12-03) | | ||||
| | M3.1 Keyboard matrix reading for the cursor keys with SHIFT, held-key repeat. | not run | pending | | |||||
| | M3.1 Keyboard matrix reading for the cursor keys with SHIFT, held-key repeat. | passed (2026-12-03, `pwsh -File tools/build.ps1`; `pwsh -File tools/smoke.ps1`; `pwsh -File tools/check-world.ps1`; `pwsh -File tools/check-people.ps1`; `pwsh -File tools/check-keys.ps1`: 8 of 8 scenarios, SPACE held = 1 regeneration) | pending | | |||||
| | M3.2 Fine scroll via $D016/$D011 in 38x24 mode; rebuild the hidden buffer from tiles over 8 frames and flip on wrap; stop at world edges. | not run | pending | | | M3.2 Fine scroll via $D016/$D011 in 38x24 mode; rebuild the hidden buffer from tiles over 8 frames and flip on wrap; stop at world edges. | not run | pending | | ||||
| | M3.3 Draw people relative to the view; measure the frame budget with a border-colour timing bar. | not run | pending | | | M3.3 Draw people relative to the view; measure the frame budget with a border-colour timing bar. | not run | pending | | ||||
| ## Notes | ## Notes | ||||
| - 2026-12-03 (M2.2): VICE x64sc NTSC runs 263 lines x 65 cycles = 17,095 cycles per frame (measured with tools/check-people.ps1). The spec's budget said 17,030 (the 262-line 6567R56A figure). The difference does not affect any acceptance criterion. With the user's approval (2026-12-03), docs/spec.md and project.json now say 17,095. | - 2026-12-03 (M2.2): VICE x64sc NTSC runs 263 lines x 65 cycles = 17,095 cycles per frame (measured with tools/check-people.ps1). The spec's budget said 17,030 (the 262-line 6567R56A figure). The difference does not affect any acceptance criterion. With the user's approval (2026-12-03), docs/spec.md and project.json now say 17,095. | ||||
| - 2026-12-03 (M3.1): The KERNAL timer interrupt is now switched off at start-up (keys are read from the matrix directly). RUN/STOP alone no longer breaks out (nothing scans for it); use a VICE reset to leave. RUN/STOP + RESTORE has not been tested. Fixed a parsing bug in tools/check-people.ps1: it could read the monitor's ASCII column as extra bytes when people's coordinates were printable characters. The bug could only cause false failures, so the earlier M2 passes stand. | |||||
| - 2026-12-03 (M2.2): A3 checked in VICE only: flipping the two buffers with the $DD00 bank bits in vertical blank shows the same map in both banks and passes the byte-exact buffer check. The user's MT2.2 visual check is still pending. | - 2026-12-03 (M2.2): A3 checked in VICE only: flipping the two buffers with the $DD00 bank bits in vertical blank shows the same map in both banks and passes the byte-exact buffer check. The user's MT2.2 visual check is still pending. | ||||
| - Generated 2026-12-03. Starter verification at generation time is reported by the Foundry; re-run `pwsh -File tools/smoke.ps1` on your machine and record the result in row M0.1. | - Generated 2026-12-03. Starter verification at generation time is reported by the Foundry; re-run `pwsh -File tools/smoke.ps1` on your machine and record the result in row M0.1. | ||||
| @@ -0,0 +1,137 @@ | |||||
| ; Keyboard matrix reading (CIA 1). Port A selects columns (a 0 bit drives that | |||||
| ; column), port B returns the rows (a 0 bit = key down). Positions checked | |||||
| ; against the KERNAL decode table at $EB81 (keycode = column * 8 + row): | |||||
| ; column 0: CRSR RIGHT row 2 (keycode 2), CRSR DOWN row 7 (keycode 7) | |||||
| ; column 1: left SHIFT row 7 (keycode 15) | |||||
| ; column 6: right SHIFT row 4 (keycode 52) | |||||
| ; column 7: SPACE row 4 (keycode 60) | |||||
| ; SHIFT reverses the cursor keys: SHIFT + CRSR RIGHT = left, SHIFT + CRSR DOWN | |||||
| ; = up. VICE maps the PC arrow keys to these combinations. | |||||
| CIA1_PRA = $DC00 | |||||
| CIA1_PRB = $DC01 | |||||
| CIA1_ICR = $DC0D | |||||
| KEY_COL_CURSOR = %11111110 | |||||
| KEY_COL_LSHIFT = %11111101 | |||||
| KEY_COL_RSHIFT = %10111111 | |||||
| KEY_COL_SPACE = %01111111 | |||||
| KEY_ROW_RIGHT = %00000100 | |||||
| KEY_ROW_DOWN = %10000000 | |||||
| KEY_ROW_LSHIFT = %10000000 | |||||
| KEY_ROW_RSHIFT = %00010000 | |||||
| KEY_ROW_SPACE = %00010000 | |||||
| .export key_row_cursor, key_row_lshift, key_row_rshift, key_row_space | |||||
| .export scroll_dx | |||||
| .segment "CODE" | |||||
| ; Stop the KERNAL timer interrupt: nothing uses it any more, its keyboard scan | |||||
| ; would fight read_keys over port A, and it delayed the buffer flip. CIA 1 | |||||
| ; timer A keeps running, so it still seeds the generator. | |||||
| stop_kernal_irq: | |||||
| lda #%01111111 ; clear all CIA 1 interrupt enables | |||||
| sta CIA1_ICR | |||||
| lda CIA1_ICR ; acknowledge anything pending | |||||
| lda #1 | |||||
| sta space_down ; SPACE must be released before it counts | |||||
| rts | |||||
| ; Read the keys once per frame. Sets scroll_dx and scroll_dy to -1, 0 or +1 | |||||
| ; for as long as a cursor key is held. Returns carry set when SPACE has just | |||||
| ; been pressed (held SPACE counts once). | |||||
| read_keys: | |||||
| lda #KEY_COL_CURSOR | |||||
| sta CIA1_PRA | |||||
| lda CIA1_PRB | |||||
| key_row_cursor: ; check hook: tools/check-keys.ps1 fakes rows here | |||||
| sta keys_cursor | |||||
| lda #KEY_COL_LSHIFT | |||||
| sta CIA1_PRA | |||||
| lda CIA1_PRB | |||||
| key_row_lshift: | |||||
| sta keys_lshift | |||||
| lda #KEY_COL_RSHIFT | |||||
| sta CIA1_PRA | |||||
| lda CIA1_PRB | |||||
| key_row_rshift: | |||||
| sta keys_rshift | |||||
| lda #KEY_COL_SPACE | |||||
| sta CIA1_PRA | |||||
| lda CIA1_PRB | |||||
| key_row_space: | |||||
| sta keys_space | |||||
| lda #$FF ; select no column | |||||
| sta CIA1_PRA | |||||
| ldy #1 ; unshifted: right / down | |||||
| lda keys_lshift | |||||
| and #KEY_ROW_LSHIFT | |||||
| beq @shifted | |||||
| lda keys_rshift | |||||
| and #KEY_ROW_RSHIFT | |||||
| bne @unshifted | |||||
| @shifted: | |||||
| ldy #$FF ; shifted: left / up | |||||
| @unshifted: | |||||
| lda #0 | |||||
| sta scroll_dx | |||||
| sta scroll_dy | |||||
| lda keys_cursor | |||||
| and #KEY_ROW_RIGHT | |||||
| bne @no_horizontal | |||||
| sty scroll_dx | |||||
| @no_horizontal: | |||||
| lda keys_cursor | |||||
| and #KEY_ROW_DOWN | |||||
| bne @no_vertical | |||||
| sty scroll_dy | |||||
| @no_vertical: | |||||
| ldx #0 | |||||
| lda keys_space | |||||
| and #KEY_ROW_SPACE | |||||
| bne @space_up | |||||
| inx ; X = 1: SPACE is down | |||||
| @space_up: | |||||
| lda space_down | |||||
| stx space_down | |||||
| bne @no_press ; already down last frame | |||||
| cpx #1 ; carry set only for a new press | |||||
| rts | |||||
| @no_press: | |||||
| clc | |||||
| rts | |||||
| ; Temporary M3.1 indicator, replaced by real scrolling in M3.2: the border | |||||
| ; colour shows the direction that is held. | |||||
| show_scroll_direction: | |||||
| lda scroll_dx ; index = (dx + 1) * 3 + (dy + 1) | |||||
| clc | |||||
| adc #1 | |||||
| sta direction_index | |||||
| asl a | |||||
| clc | |||||
| adc direction_index | |||||
| clc | |||||
| adc scroll_dy | |||||
| clc | |||||
| adc #1 | |||||
| tax | |||||
| lda direction_colors,x | |||||
| sta VIC_BORDER | |||||
| rts | |||||
| .segment "RODATA" | |||||
| direction_colors: | |||||
| .byte 14, 3, 12 ; dx -1: up-left light blue, left cyan, (down-left) | |||||
| .byte 1, COL_BROWN, 7 ; dx 0: up white, none brown, down yellow | |||||
| .byte 12, 13, 8 ; dx +1: (up-right), right light green, down-right orange | |||||
| .segment "BSS" | |||||
| scroll_dx: .res 1 ; keep scroll_dx and scroll_dy together | |||||
| scroll_dy: .res 1 | |||||
| keys_cursor: .res 1 | |||||
| keys_lshift: .res 1 | |||||
| keys_rshift: .res 1 | |||||
| keys_space: .res 1 | |||||
| space_down: .res 1 | |||||
| direction_index: .res 1 | |||||
| @@ -16,7 +16,7 @@ | |||||
| ; During generation VIC bank 0 displays the message at $0400. In bitmap mode | ; During generation VIC bank 0 displays the message at $0400. In bitmap mode | ||||
| ; that text screen is hidden and holds the smoke test status mirror. | ; that text screen is hidden and holds the smoke test status mirror. | ||||
| .export smoke_ready, visible | |||||
| .export smoke_ready, visible, keys_read, space_ready | |||||
| ; ---------------------------------------------------------------- hardware | ; ---------------------------------------------------------------- hardware | ||||
| VIC_CTRL1 = $D011 ; bit 5 bitmap mode, bit 4 display on, bit 3 25 rows | VIC_CTRL1 = $D011 ; bit 5 bitmap mode, bit 4 display on, bit 3 25 rows | ||||
| @@ -28,9 +28,6 @@ VIC_BG0 = $D021 | |||||
| COLOR_RAM = $D800 | COLOR_RAM = $D800 | ||||
| CIA2_PRA = $DD00 ; bits 0-1: VIC bank, inverted (%10 = bank 1, %01 = bank 2) | CIA2_PRA = $DD00 ; bits 0-1: VIC bank, inverted (%10 = bank 1, %01 = bank 2) | ||||
| CPU_PORT = $01 | CPU_PORT = $01 | ||||
| KEY_REPEAT = $028A ; bit 6 disables KERNAL key repeat | |||||
| GETIN = $FFE4 | |||||
| PETSCII_SPACE = $20 | |||||
| TEXT_SCREEN = $0400 | TEXT_SCREEN = $0400 | ||||
| @@ -66,8 +63,7 @@ start: | |||||
| lda #$36 ; BASIC ROM out, KERNAL and I/O in: the CPU can | lda #$36 ; BASIC ROM out, KERNAL and I/O in: the CPU can | ||||
| sta CPU_PORT ; read buffer B's bitmap at $A000 (needed from M2) | sta CPU_PORT ; read buffer B's bitmap at $A000 (needed from M2) | ||||
| lda #$40 | |||||
| sta KEY_REPEAT | |||||
| jsr stop_kernal_irq | |||||
| lda #0 | lda #0 | ||||
| sta last_seed_low | sta last_seed_low | ||||
| sta last_seed_high | sta last_seed_high | ||||
| @@ -92,9 +88,12 @@ people_moved: ; check hook: hidden buffer holds the new step | |||||
| lda buffer_bank_bits,x | lda buffer_bank_bits,x | ||||
| jsr set_bank | jsr set_bank | ||||
| stx visible | stx visible | ||||
| jsr GETIN | |||||
| cmp #PETSCII_SPACE | |||||
| bne main_loop | |||||
| jsr read_keys ; carry set: SPACE just pressed | |||||
| bcs new_world | |||||
| jsr show_scroll_direction | |||||
| keys_read: ; check hook: scroll_dx and scroll_dy are set | |||||
| jmp main_loop | |||||
| new_world: | |||||
| jsr rebuild_map | jsr rebuild_map | ||||
| space_ready: ; regenerated map is on screen | space_ready: ; regenerated map is on screen | ||||
| jmp main_loop | jmp main_loop | ||||
| @@ -281,3 +280,4 @@ view_column: .res 1 | |||||
| .include "world.inc" | .include "world.inc" | ||||
| .include "people.inc" | .include "people.inc" | ||||
| .include "keys.inc" | |||||
| @@ -0,0 +1,127 @@ | |||||
| <# | |||||
| .SYNOPSIS | |||||
| Check the keyboard matrix decoding of the C64 build headless in VICE. | |||||
| .DESCRIPTION | |||||
| VICE's monitor cannot press keys, so each scenario fakes held keys instead: | |||||
| tracepoints on the instructions that store the port B row bits (key_row_cursor, | |||||
| key_row_lshift, key_row_rshift, key_row_space in src/keys.inc) run "r a = <bits>", | |||||
| as if those keys were held down. At keys_read the script logs scroll_dx, scroll_dy and | |||||
| the border colour (the M3.1 direction indicator); it counts space_ready hits. | |||||
| Scenarios: no key, right, left (right SHIFT), down, up (left SHIFT), down-right, | |||||
| up-left, and SPACE held from frame 60 on (must regenerate exactly once). | |||||
| Exit codes: 0 = pass, 1 = fail, 2 = a tool is missing. | |||||
| .EXAMPLE | |||||
| pwsh -File tools/check-keys.ps1 | |||||
| #> | |||||
| [CmdletBinding()] | |||||
| param([switch]$NoBuild, [int]$TimeoutSeconds = 180) | |||||
| . (Join-Path $PSScriptRoot 'lib.ps1') | |||||
| function Get-Label([hashtable]$Target, [string]$Symbol) { | |||||
| foreach ($line in Get-Content -LiteralPath (Get-RepoPath $Target.build.labels)) { | |||||
| $parts = $line -split '\s+' | |||||
| if ($parts.Count -ge 3 -and $parts[2].TrimStart('.') -eq $Symbol) { return [Convert]::ToInt32($parts[1], 16) } | |||||
| } | |||||
| throw "Symbol '$Symbol' not found in $($Target.build.labels)." | |||||
| } | |||||
| try { | |||||
| $project = Get-ProjectConfig | |||||
| $target = Get-ProjectTargets $project 'c64' | |||||
| if (-not $NoBuild) { Invoke-TargetBuild $project $target @{} } | |||||
| $emu = Get-ToolPath $project $target.emulator.binary | |||||
| } catch [MissingToolException] { | |||||
| Write-Host $_.Exception.Message -ForegroundColor Yellow | |||||
| exit 2 | |||||
| } | |||||
| $hooks = @{} | |||||
| foreach ($s in 'key_row_cursor', 'key_row_lshift', 'key_row_rshift', 'key_row_space', 'keys_read', 'space_ready', 'scroll_dx') { | |||||
| $hooks[$s] = Get-Label $target $s | |||||
| } | |||||
| # Row bits are active low. Cursor column: RIGHT = bit 2, DOWN = bit 7. | |||||
| # Left SHIFT = bit 7 of its column, right SHIFT and SPACE = bit 4 of theirs. | |||||
| # Border colours from src/keys.inc direction_colors. | |||||
| $scenarios = @( | |||||
| @{ name = 'no key'; cursor = 'ff'; lshift = 'ff'; rshift = 'ff'; dx = 0; dy = 0; border = 9 } | |||||
| @{ name = 'CRSR RIGHT'; cursor = 'fb'; lshift = 'ff'; rshift = 'ff'; dx = 1; dy = 0; border = 13 } | |||||
| @{ name = 'right SHIFT+CRSR RIGHT'; cursor = 'fb'; lshift = 'ff'; rshift = 'ef'; dx = -1; dy = 0; border = 3 } | |||||
| @{ name = 'CRSR DOWN'; cursor = '7f'; lshift = 'ff'; rshift = 'ff'; dx = 0; dy = 1; border = 7 } | |||||
| @{ name = 'left SHIFT+CRSR DOWN'; cursor = '7f'; lshift = '7f'; rshift = 'ff'; dx = 0; dy = -1; border = 1 } | |||||
| @{ name = 'CRSR RIGHT+DOWN'; cursor = '7b'; lshift = 'ff'; rshift = 'ff'; dx = 1; dy = 1; border = 8 } | |||||
| @{ name = 'left SHIFT+RIGHT+DOWN'; cursor = '7b'; lshift = '7f'; rshift = 'ff'; dx = -1; dy = -1; border = 14 } | |||||
| @{ name = 'SPACE held'; cursor = 'ff'; lshift = 'ff'; rshift = 'ff'; space = 'ef'; spaceAfter = 60; dx = 0; dy = 0; border = 9; regenerations = 1 } | |||||
| ) | |||||
| $root = Get-RepoPath 'build/check-keys' | |||||
| if (Test-Path -LiteralPath $root) { Remove-Item -LiteralPath $root -Recurse -Force } | |||||
| $failed = 0 | |||||
| $index = 0 | |||||
| foreach ($sc in $scenarios) { | |||||
| $index++ | |||||
| $dir = Join-Path $root ("{0:d2}" -f $index) | |||||
| New-Item -ItemType Directory -Force -Path $dir | Out-Null | |||||
| $mon = [System.Collections.Generic.List[string]]::new() | |||||
| $mon.Add('logname "monitor.log"'); $mon.Add('log on') | |||||
| $n = 0 | |||||
| $add = { | |||||
| param($addr, $cmd) | |||||
| $script:n++ | |||||
| $mon.Add(('trace exec ${0:x4}' -f $addr)); $mon.Add(('command {0} "{1}"' -f $script:n, $cmd)) | |||||
| } | |||||
| & $add $hooks.key_row_cursor "r a = $($sc.cursor)" | |||||
| & $add $hooks.key_row_lshift "r a = $($sc.lshift)" | |||||
| & $add $hooks.key_row_rshift "r a = $($sc.rshift)" | |||||
| if ($sc.space) { | |||||
| & $add $hooks.key_row_space "r a = $($sc.space)" | |||||
| $mon.Add(('ignore {0} {1}' -f $n, $sc.spaceAfter)) | |||||
| } else { | |||||
| & $add $hooks.key_row_space 'r a = ff' | |||||
| } | |||||
| & $add $hooks.keys_read ('m {0:x4} {1:x4}' -f $hooks.scroll_dx, ($hooks.scroll_dx + 1)) | |||||
| & $add $hooks.keys_read 'm d020 d020' | |||||
| $spaceCheckpoint = $n + 1 | |||||
| & $add $hooks.space_ready 'm d020 d020' | |||||
| Set-Content -LiteralPath (Join-Path $dir 'monitor.txt') -Value $mon | |||||
| Set-Content -LiteralPath (Join-Path $dir 'vicerc') -Value '' | |||||
| $cycles = if ($sc.space) { 20000000 } else { 6000000 } | |||||
| $vargs = @('-config', 'vicerc', '-default', '-sounddev', 'dummy', '-warp', '-minimized') + (Get-VideoArgs $target) | |||||
| $vargs += @('-limitcycles', [string]$cycles, '-moncommands', 'monitor.txt', '-autostartprgmode', '1', '-autostart', (Get-AutostartFile $target)) | |||||
| $quoted = $vargs | ForEach-Object { if ($_ -match '[\s"]') { '"' + $_ + '"' } else { $_ } } | |||||
| $p = Start-Process -FilePath $emu -ArgumentList $quoted -WorkingDirectory $dir -PassThru ` | |||||
| -RedirectStandardOutput (Join-Path $dir 'vice.log') -RedirectStandardError (Join-Path $dir 'vice.err') | |||||
| if (-not $p.WaitForExit($TimeoutSeconds * 1000)) { $p.Kill($true) } | |||||
| $log = Join-Path $dir 'monitor.log' | |||||
| $scroll = $null; $border = $null; $frames = 0; $regenerations = 0 | |||||
| if (Test-Path -LiteralPath $log) { | |||||
| foreach ($line in Get-Content -LiteralPath $log) { | |||||
| if ($line -match ('^#{0} \(Trace' -f $spaceCheckpoint)) { $regenerations++ } | |||||
| elseif ($line -match ('^>C:{0:x4}\s+([0-9a-f]{{2}}) ([0-9a-f]{{2}})' -f $hooks.scroll_dx)) { | |||||
| $scroll = @([Convert]::ToByte($Matches[1], 16), [Convert]::ToByte($Matches[2], 16)) | ForEach-Object { if ($_ -ge 128) { $_ - 256 } else { [int]$_ } }; $frames++ | |||||
| } elseif ($line -match '^>C:d020\s+([0-9a-f]{2})') { $border = [Convert]::ToByte($Matches[1], 16) -band 0x0F } | |||||
| } | |||||
| } | |||||
| $problems = @() | |||||
| if ($frames -lt 30) { $problems += "only $frames frames reached keys_read" } | |||||
| elseif ($scroll[0] -ne $sc.dx -or $scroll[1] -ne $sc.dy) { $problems += "scroll ($($scroll[0]),$($scroll[1])), expected ($($sc.dx),$($sc.dy))" } | |||||
| if ($null -ne $border -and $border -ne $sc.border) { $problems += "border colour $border, expected $($sc.border)" } | |||||
| $wantRegen = if ($sc.regenerations) { $sc.regenerations } else { 0 } | |||||
| if ($regenerations -ne $wantRegen) { $problems += "$regenerations regenerations, expected $wantRegen" } | |||||
| if ($problems.Count -gt 0) { | |||||
| $failed++ | |||||
| Write-Host (" FAIL {0}: {1}" -f $sc.name, ($problems -join '; ')) -ForegroundColor Red | |||||
| } else { | |||||
| $extra = if ($sc.space) { ", $regenerations regeneration while held" } else { '' } | |||||
| Write-Host (" ok {0}: scroll ({1},{2}), border {3}, {4} frames{5}" -f $sc.name, $scroll[0], $scroll[1], $border, $frames, $extra) | |||||
| } | |||||
| } | |||||
| if ($failed -gt 0) { Write-Host "[FAIL] $failed of $($scenarios.Count) key scenarios" -ForegroundColor Red; exit 1 } | |||||
| Write-Host "[PASS] all $($scenarios.Count) key scenarios decode correctly" -ForegroundColor Green | |||||
| exit 0 | |||||
| @@ -112,12 +112,14 @@ $lines = [System.Collections.Generic.List[int]]::new() | |||||
| foreach ($line in Get-Content -LiteralPath $logFile) { | foreach ($line in Get-Content -LiteralPath $logFile) { | ||||
| if ($line -match "^#$peopleCheckpoint \(Trace\s+exec [0-9a-fA-F]+\)\s+(\d+)/") { $lines.Add([int]$Matches[1]); $wantClock = $true; continue } | if ($line -match "^#$peopleCheckpoint \(Trace\s+exec [0-9a-fA-F]+\)\s+(\d+)/") { $lines.Add([int]$Matches[1]); $wantClock = $true; continue } | ||||
| if ($wantClock -and $line -match '^\.C:.*\s(\d+)\s*$') { $clocks.Add([long]$Matches[1]); $wantClock = $false; continue } | if ($wantClock -and $line -match '^\.C:.*\s(\d+)\s*$') { $clocks.Add([long]$Matches[1]); $wantClock = $false; continue } | ||||
| if ($line -notmatch '^>C:([0-9a-fA-F]{4})\s+(.*)$') { continue } | |||||
| # Hex column only: each byte is two digits and one space; the ASCII column | |||||
| # after it can itself look like hex (for example bytes $34 $42 print as "4B"). | |||||
| if ($line -notmatch '^>C:([0-9a-fA-F]{4}) ((?:[0-9a-fA-F]{2} )+)') { continue } | |||||
| $addr = [Convert]::ToInt32($Matches[1], 16) | $addr = [Convert]::ToInt32($Matches[1], 16) | ||||
| if ($addr -eq $visibleFlag) { $visibleLog.Add([Convert]::ToInt32(($Matches[2] -split '\s+')[0], 16)); continue } | |||||
| $hexBytes = $Matches[2].Trim() -split ' ' | |||||
| if ($addr -eq $visibleFlag) { $visibleLog.Add([Convert]::ToInt32($hexBytes[0], 16)); continue } | |||||
| if ($addr -eq $people) { $current.Clear() } | if ($addr -eq $people) { $current.Clear() } | ||||
| foreach ($hex in ($Matches[2] -split '\s+')) { | |||||
| if ($hex -notmatch '^[0-9a-fA-F]{2}$') { break } | |||||
| foreach ($hex in $hexBytes) { | |||||
| if ($current.Count -lt 5 * $count) { $current.Add([Convert]::ToByte($hex, 16)) } | if ($current.Count -lt 5 * $count) { $current.Add([Convert]::ToByte($hex, 16)) } | ||||
| } | } | ||||
| if ($current.Count -eq 5 * $count) { $frames.Add($current.ToArray()); $current.Clear() } | if ($current.Count -eq 5 * $count) { $frames.Add($current.ToArray()); $current.Clear() } | ||||
Powered by TurnKey Linux.