Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>main
| @@ -80,11 +80,18 @@ Setup: VICE x64sc, NTSC (-ntsc), warp off. | |||||
| Start: `pwsh -File tools/run.ps1 -Target c64` | Start: `pwsh -File tools/run.ps1 -Target c64` | ||||
| Steps: | Steps: | ||||
| 1. Watch the visible dots for 30 seconds. | |||||
| 1. Run `pwsh -File tools/check-people.ps1` and note the result. | |||||
| 2. Start the program and wait for the map view. | |||||
| 3. Watch the visible dots for 30 seconds. Pay attention to dots near the blue pool and the grey stone patch. | |||||
| 4. Tap SPACE, wait for the new map, and watch the dots for another 10 seconds. | |||||
| Expected: | Expected: | ||||
| - Dots move at least once per second | |||||
| - No dot enters blue or grey pixels | |||||
| - `tools/check-people.ps1` prints `[PASS]`. | |||||
| - About four light red dots are visible (16 people are spread over the four screens of the world; until scrolling arrives in M3 only the top-left screen is shown). | |||||
| - Dots move at least once per second (each takes about 7 small steps a second and sometimes changes direction). | |||||
| - No dot enters blue or grey pixels. A dot that reaches water or stone turns away. | |||||
| - After SPACE, dots appear on the new map and keep moving. | |||||
| - At M2.1 the dots are drawn straight into the visible buffer during vertical blank; small flicker or a missed frame is not a failure until M2.2 adds the buffer flip (MT2.2). | |||||
| Verifies: R2 | Verifies: R2 | ||||
| @@ -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. | ||||
| - 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. Output: `build/check-people/`. | |||||
| ### How the smoke test works | ### How the smoke test works | ||||
| @@ -12,7 +12,7 @@ manual = `pending`, `confirmed by user (<date>)`, `problem reported (<date>): <n | |||||
| | M1.1 Tile set: 8-byte multicolour patterns for land, grass, trees, stone, water and roads, including edge and corner patterns, with per-tile screen-RAM colour pairs. | passed (2026-12-03, `pwsh -File tools/build.ps1`; `pwsh -File tools/smoke.ps1`) | confirmed by user (2026-12-03) | | | M1.1 Tile set: 8-byte multicolour patterns for land, grass, trees, stone, water and roads, including edge and corner patterns, with per-tile screen-RAM colour pairs. | passed (2026-12-03, `pwsh -File tools/build.ps1`; `pwsh -File tools/smoke.ps1`) | confirmed by user (2026-12-03) | | ||||
| | M1.2 Seeded generator: 80x50 tile world with water, stone, grass with trees, and connected roads; enforce the at-most-two-colours-per-cell rule. | passed (2026-12-03, `pwsh -File tools/build.ps1`; `pwsh -File tools/smoke.ps1`; `pwsh -File tools/check-world.ps1`) | confirmed by user (2026-12-03) | | | M1.2 Seeded generator: 80x50 tile world with water, stone, grass with trees, and connected roads; enforce the at-most-two-colours-per-cell rule. | passed (2026-12-03, `pwsh -File tools/build.ps1`; `pwsh -File tools/smoke.ps1`; `pwsh -File tools/check-world.ps1`) | 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) | | | 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. | not run | pending | | |||||
| | 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) | pending | | |||||
| | M2.2 Per-buffer saved-byte lists: restore the bytes under people from two frames ago, draw people in view, flip in vertical blank. | not run | pending | | | M2.2 Per-buffer saved-byte lists: restore the bytes under people from two frames ago, draw people in view, flip in vertical blank. | not run | pending | | ||||
| | 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. | 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.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 | | ||||
| @@ -268,7 +268,7 @@ | |||||
| }, | }, | ||||
| "starter": { | "starter": { | ||||
| "screenTitle": "LAND MAP 64", | "screenTitle": "LAND MAP 64", | ||||
| "expectedScreen": "After a short generating message, VICE shows the top-left view of the generated terrain in multicolour bitmap mode. SPACE generates a different map. The hidden text screen shows \"LAND MAP 64\" and \"MAP READY\".", | |||||
| "expectedScreen": "After a short generating message, VICE shows the top-left view of the generated terrain in multicolour bitmap mode, with light red dots (people) walking on it. SPACE generates a different map. The hidden text screen shows \"LAND MAP 64\" and \"MAP READY\".", | |||||
| "smokeChecks": [ | "smokeChecks": [ | ||||
| { | { | ||||
| "row": 0, | "row": 0, | ||||
| @@ -656,7 +656,7 @@ | |||||
| "description": "C64 KERNAL reset vector at $FFFC (machine is in C64 mode)" | "description": "C64 KERNAL reset vector at $FFFC (machine is in C64 mode)" | ||||
| } | } | ||||
| ], | ], | ||||
| "expectedScreen": "After a short generating message, VICE shows the top-left view of the generated terrain in multicolour bitmap mode. SPACE generates a different map. The hidden text screen shows \"LAND MAP 64\" and \"MAP READY\"." | |||||
| "expectedScreen": "After a short generating message, VICE shows the top-left view of the generated terrain in multicolour bitmap mode, with light red dots (people) walking on it. SPACE generates a different map. The hidden text screen shows \"LAND MAP 64\" and \"MAP READY\"." | |||||
| }, | }, | ||||
| "recipeStatus": "verified", | "recipeStatus": "verified", | ||||
| "validationPlan": [] | "validationPlan": [] | ||||
| @@ -1,4 +1,4 @@ | |||||
| ; Land Map 64 - generated terrain view (ca65). | |||||
| ; Land Map 64 - generated terrain view with walking people (ca65). | |||||
| ; Built with: cl65 -t c64 -C c64-asm.cfg -u __EXEHDR__ (BASIC SYS line included). | ; Built with: cl65 -t c64 -C c64-asm.cfg -u __EXEHDR__ (BASIC SYS line included). | ||||
| ; | ; | ||||
| ; Multicolour bitmap palette and VIC bank layout: | ; Multicolour bitmap palette and VIC bank layout: | ||||
| @@ -74,6 +74,11 @@ smoke_ready: ; first generated world is on screen | |||||
| nop | nop | ||||
| main_loop: | main_loop: | ||||
| jsr wait_frame ; people are redrawn below the visible area | |||||
| jsr restore_people | |||||
| jsr draw_people | |||||
| jsr move_people | |||||
| people_moved: ; smoke hook: one movement step done | |||||
| jsr GETIN | jsr GETIN | ||||
| cmp #PETSCII_SPACE | cmp #PETSCII_SPACE | ||||
| bne main_loop | bne main_loop | ||||
| @@ -99,6 +104,7 @@ rebuild_map: | |||||
| sta VIC_CTRL1 | sta VIC_CTRL1 | ||||
| jsr generate_world_from_timer | jsr generate_world_from_timer | ||||
| jsr place_people | |||||
| jsr draw_world_view | jsr draw_world_view | ||||
| jsr wait_frame ; switch banks and modes below the visible area | jsr wait_frame ; switch banks and modes below the visible area | ||||
| @@ -249,3 +255,4 @@ view_row: .res 1 | |||||
| view_column: .res 1 | view_column: .res 1 | ||||
| .include "world.inc" | .include "world.inc" | ||||
| .include "people.inc" | |||||
| @@ -0,0 +1,283 @@ | |||||
| ; People: 16 walkers stored as world positions, one multicolour pixel each. | |||||
| ; A position is a world cell (cx 0-79, cy 0-49) plus the pixel inside it | |||||
| ; (sx 0-3 across, sy 0-7 down). Water and stone tiles block movement. | |||||
| PEOPLE_COUNT = 16 | |||||
| DIR_N = 0 | |||||
| DIR_E = 1 | |||||
| DIR_S = 2 | |||||
| DIR_W = 3 | |||||
| TURN_TRIES = 5 ; current direction, then all four from a random start | |||||
| .assert STONE + 1 = WATER, error, "Blocking tiles must be contiguous" | |||||
| .assert WATER_SE + 1 = ROAD_H, error, "Blocking tiles must be contiguous" | |||||
| .export people_cx, people_moved | |||||
| .segment "CODE" | |||||
| ; Put each person on a random walkable cell; person N goes in sector N mod 4, | |||||
| ; so the 16 people are spread over all four screens of the world. | |||||
| place_people: | |||||
| lda #0 | |||||
| sta drawn_count | |||||
| sta move_frame | |||||
| tax | |||||
| @person: | |||||
| stx person | |||||
| @retry_x: | |||||
| jsr random_byte | |||||
| and #63 | |||||
| cmp #SECTOR_WIDTH | |||||
| bcs @retry_x | |||||
| sta cand_cx | |||||
| txa | |||||
| and #3 | |||||
| tax | |||||
| lda cand_cx | |||||
| clc | |||||
| adc sector_left,x | |||||
| sta cand_cx | |||||
| @retry_y: | |||||
| jsr random_byte | |||||
| and #31 | |||||
| cmp #SECTOR_HEIGHT | |||||
| bcs @retry_y | |||||
| clc | |||||
| adc sector_top,x | |||||
| sta cand_cy | |||||
| jsr candidate_blocked | |||||
| ldx person | |||||
| bcs @person | |||||
| lda cand_cx | |||||
| sta people_cx,x | |||||
| lda cand_cy | |||||
| sta people_cy,x | |||||
| jsr random_byte | |||||
| and #3 | |||||
| sta people_sx,x | |||||
| jsr random_byte | |||||
| and #7 | |||||
| sta people_sy,x | |||||
| jsr random_byte | |||||
| and #3 | |||||
| sta people_dir,x | |||||
| inx | |||||
| cpx #PEOPLE_COUNT | |||||
| bne @person | |||||
| rts | |||||
| ; Move two people per frame: each person takes one pixel step every 8 frames. | |||||
| move_people: | |||||
| inc move_frame | |||||
| lda move_frame | |||||
| and #7 | |||||
| tax | |||||
| jsr move_person | |||||
| lda move_frame | |||||
| and #7 | |||||
| ora #8 | |||||
| tax | |||||
| ; fall through | |||||
| ; X = person. Occasionally pick a new direction; if the step is blocked by | |||||
| ; water, stone or the world edge, try other directions. Never steps onto a | |||||
| ; blocking tile. | |||||
| move_person: | |||||
| stx person | |||||
| jsr random_byte | |||||
| and #15 | |||||
| bne @start | |||||
| jsr random_byte | |||||
| and #3 | |||||
| sta people_dir,x | |||||
| @start: lda #TURN_TRIES | |||||
| sta tries | |||||
| @try: ldx person | |||||
| lda people_cx,x | |||||
| sta cand_cx | |||||
| lda people_sx,x | |||||
| sta cand_sx | |||||
| lda people_cy,x | |||||
| sta cand_cy | |||||
| lda people_sy,x | |||||
| sta cand_sy | |||||
| lda people_dir,x | |||||
| beq @north | |||||
| cmp #DIR_E | |||||
| beq @east | |||||
| cmp #DIR_S | |||||
| beq @south | |||||
| dec cand_sx ; west | |||||
| bpl @check | |||||
| lda #3 | |||||
| sta cand_sx | |||||
| dec cand_cx | |||||
| bpl @check | |||||
| bmi @blocked | |||||
| @east: inc cand_sx | |||||
| lda cand_sx | |||||
| cmp #4 | |||||
| bne @check | |||||
| lda #0 | |||||
| sta cand_sx | |||||
| inc cand_cx | |||||
| lda cand_cx | |||||
| cmp #WORLD_WIDTH | |||||
| bne @check | |||||
| beq @blocked | |||||
| @north: dec cand_sy | |||||
| bpl @check | |||||
| lda #7 | |||||
| sta cand_sy | |||||
| dec cand_cy | |||||
| bpl @check | |||||
| bmi @blocked | |||||
| @south: inc cand_sy | |||||
| lda cand_sy | |||||
| cmp #8 | |||||
| bne @check | |||||
| lda #0 | |||||
| sta cand_sy | |||||
| inc cand_cy | |||||
| lda cand_cy | |||||
| cmp #WORLD_HEIGHT | |||||
| beq @blocked | |||||
| @check: jsr candidate_blocked | |||||
| bcs @blocked | |||||
| ldx person | |||||
| lda cand_cx | |||||
| sta people_cx,x | |||||
| lda cand_sx | |||||
| sta people_sx,x | |||||
| lda cand_cy | |||||
| sta people_cy,x | |||||
| lda cand_sy | |||||
| sta people_sy,x | |||||
| rts | |||||
| @blocked: | |||||
| ldx person | |||||
| lda tries | |||||
| cmp #TURN_TRIES | |||||
| bne @rotate | |||||
| jsr random_byte ; first block: random direction | |||||
| jmp @turn | |||||
| @rotate: | |||||
| lda people_dir,x | |||||
| clc | |||||
| adc #1 | |||||
| @turn: and #3 | |||||
| sta people_dir,x | |||||
| dec tries | |||||
| beq @stay | |||||
| jmp @try | |||||
| @stay: rts ; boxed in: stay put this step | |||||
| ; Carry set if the tile at (cand_cx, cand_cy) is water or stone. | |||||
| candidate_blocked: | |||||
| ldx cand_cy | |||||
| ldy cand_cx | |||||
| jsr point_world_row | |||||
| lda (world_ptr),y | |||||
| cmp #STONE | |||||
| bcc @open | |||||
| cmp #WATER_SE+1 | |||||
| bcs @open | |||||
| sec | |||||
| rts | |||||
| @open: clc | |||||
| rts | |||||
| ; Put back the bitmap bytes saved by draw_people, newest first, so people that | |||||
| ; share a byte restore correctly. | |||||
| restore_people: | |||||
| ldx drawn_count | |||||
| beq @done | |||||
| @loop: dex | |||||
| lda drawn_low,x | |||||
| sta bmp | |||||
| lda drawn_high,x | |||||
| sta bmp+1 | |||||
| lda drawn_byte,x | |||||
| ldy #0 | |||||
| sta (bmp),y | |||||
| txa | |||||
| bne @loop | |||||
| stx drawn_count | |||||
| @done: rts | |||||
| ; Draw every person inside the view (the top-left screen) into buffer A, | |||||
| ; saving the byte under each one. Call restore_people first. | |||||
| draw_people: | |||||
| ldx #0 | |||||
| @person: | |||||
| lda people_cy,x | |||||
| cmp #VIEW_HEIGHT | |||||
| bcs @next | |||||
| tay | |||||
| lda people_cx,x | |||||
| cmp #VIEW_WIDTH | |||||
| bcs @next | |||||
| lda #0 ; bmp = row base + cx * 8 + sy | |||||
| sta bmp+1 | |||||
| lda people_cx,x | |||||
| asl a | |||||
| rol bmp+1 | |||||
| asl a | |||||
| rol bmp+1 | |||||
| asl a | |||||
| rol bmp+1 | |||||
| ora people_sy,x | |||||
| clc | |||||
| adc bitmap_row_low,y | |||||
| sta bmp | |||||
| lda bmp+1 | |||||
| adc bitmap_row_high,y | |||||
| sta bmp+1 | |||||
| ldy #0 | |||||
| lda (bmp),y | |||||
| ldy drawn_count | |||||
| sta drawn_byte,y | |||||
| lda bmp | |||||
| sta drawn_low,y | |||||
| lda bmp+1 | |||||
| sta drawn_high,y | |||||
| lda drawn_byte,y | |||||
| ldy people_sx,x | |||||
| ora pixel_masks,y ; pixel %11 = colour RAM = light red | |||||
| ldy #0 | |||||
| sta (bmp),y | |||||
| inc drawn_count | |||||
| @next: inx | |||||
| cpx #PEOPLE_COUNT | |||||
| bne @person | |||||
| rts | |||||
| .segment "RODATA" | |||||
| pixel_masks: .byte $C0, $30, $0C, $03 | |||||
| bitmap_row_low: | |||||
| .repeat VIEW_HEIGHT, row | |||||
| .byte <(BITMAP_A + 320 * row) | |||||
| .endrepeat | |||||
| bitmap_row_high: | |||||
| .repeat VIEW_HEIGHT, row | |||||
| .byte >(BITMAP_A + 320 * row) | |||||
| .endrepeat | |||||
| .segment "BSS" | |||||
| ; Keep these five tables together: tools/check-people.ps1 saves them as one block. | |||||
| people_cx: .res PEOPLE_COUNT | |||||
| people_sx: .res PEOPLE_COUNT | |||||
| people_cy: .res PEOPLE_COUNT | |||||
| people_sy: .res PEOPLE_COUNT | |||||
| people_dir: .res PEOPLE_COUNT | |||||
| move_frame: .res 1 | |||||
| person: .res 1 | |||||
| tries: .res 1 | |||||
| cand_cx: .res 1 | |||||
| cand_sx: .res 1 | |||||
| cand_cy: .res 1 | |||||
| cand_sy: .res 1 | |||||
| drawn_count: .res 1 | |||||
| drawn_low: .res PEOPLE_COUNT | |||||
| drawn_high: .res PEOPLE_COUNT | |||||
| drawn_byte: .res PEOPLE_COUNT | |||||
| .assert * <= SCREEN_A, lderror, "People data must fit below VIC bank 1" | |||||
| @@ -0,0 +1,135 @@ | |||||
| <# | |||||
| .SYNOPSIS | |||||
| Run the C64 build headless in VICE and check that the 16 people move and never | |||||
| stand on water or stone. | |||||
| .DESCRIPTION | |||||
| Starts x64sc (NTSC, warp, private config) like tools/smoke.ps1. Monitor tracepoints: | |||||
| - at smoke_ready: save the world tiles (world.bin); | |||||
| - at people_moved (once per frame): print the people table to the monitor log. | |||||
| VICE quits after -Cycles cycles. The script then checks every logged frame: | |||||
| 16 people inside the 80x50 world, every one on a walkable tile (not water or stone), | |||||
| every step at most one pixel, and every person moving during the run. | |||||
| Exit codes: 0 = pass, 1 = fail, 2 = a tool is missing. | |||||
| .EXAMPLE | |||||
| pwsh -File tools/check-people.ps1 | |||||
| #> | |||||
| [CmdletBinding()] | |||||
| param( | |||||
| [int]$Cycles = 40000000, | |||||
| [switch]$NoBuild, | |||||
| [int]$TimeoutSeconds = 180 | |||||
| ) | |||||
| . (Join-Path $PSScriptRoot 'lib.ps1') | |||||
| $count = 16 | |||||
| $width = 80 | |||||
| $height = 50 | |||||
| $blocking = 3..12 # STONE..WATER_SE in src/tiles.inc | |||||
| 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 | |||||
| } | |||||
| $dir = Get-RepoPath 'build/check-people' | |||||
| if (Test-Path -LiteralPath $dir) { Remove-Item -LiteralPath $dir -Recurse -Force } | |||||
| New-Item -ItemType Directory -Force -Path $dir | Out-Null | |||||
| $ready = Get-Label $target 'smoke_ready' | |||||
| $moved = Get-Label $target 'people_moved' | |||||
| $world = Get-Label $target 'world_tiles' | |||||
| $people = Get-Label $target 'people_cx' | |||||
| $tableEnd = $people + 5 * $count - 1 | |||||
| Set-Content -LiteralPath (Join-Path $dir 'monitor.txt') -Value @( | |||||
| 'logname "monitor.log"' | |||||
| 'log on' | |||||
| ('trace exec ${0:x4}' -f $ready) | |||||
| ('command 1 "bsave \"world.bin\" 0 {0:x4} {1:x4}"' -f $world, ($world + $width * $height - 1)) | |||||
| ('trace exec ${0:x4}' -f $moved) | |||||
| ('command 2 "m {0:x4} {1:x4}"' -f $people, $tableEnd) | |||||
| ) | |||||
| Set-Content -LiteralPath (Join-Path $dir 'vicerc') -Value '' | |||||
| $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 { $_ } } | |||||
| Write-Host "[c64] running x64sc headless for $Cycles cycles" | |||||
| $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); Write-Host '[FAIL] VICE did not exit in time.' -ForegroundColor Red; exit 1 } | |||||
| $failures = [System.Collections.Generic.List[string]]::new() | |||||
| $worldFile = Join-Path $dir 'world.bin' | |||||
| if (-not (Test-Path -LiteralPath $worldFile)) { Write-Host '[FAIL] Program never reached smoke_ready.' -ForegroundColor Red; exit 1 } | |||||
| $tiles = [IO.File]::ReadAllBytes($worldFile) | |||||
| # Monitor memory dumps look like ">C:1e4c 00 01 02 ... text". Collect bytes per dump. | |||||
| $logFile = @('monitor.log', 'vice.log') | ForEach-Object { Join-Path $dir $_ } | | |||||
| Where-Object { (Test-Path -LiteralPath $_) -and (Select-String -LiteralPath $_ -Pattern '^>C:' -Quiet) } | Select-Object -First 1 | |||||
| if (-not $logFile) { Write-Host '[FAIL] No people table was logged (people_moved never reached?).' -ForegroundColor Red; exit 1 } | |||||
| $frames = [System.Collections.Generic.List[byte[]]]::new() | |||||
| $current = [System.Collections.Generic.List[byte]]::new() | |||||
| foreach ($line in Get-Content -LiteralPath $logFile) { | |||||
| if ($line -notmatch '^>C:([0-9a-fA-F]{4})\s+(.*)$') { continue } | |||||
| $addr = [Convert]::ToInt32($Matches[1], 16) | |||||
| if ($addr -eq $people) { $current.Clear() } | |||||
| foreach ($hex in ($Matches[2] -split '\s+')) { | |||||
| if ($hex -notmatch '^[0-9a-fA-F]{2}$') { break } | |||||
| 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 ($frames.Count -lt 60) { Write-Host "[FAIL] Only $($frames.Count) frames logged." -ForegroundColor Red; exit 1 } | |||||
| $first = $frames[0] | |||||
| $moves = [int[]]::new($count) | |||||
| $previous = $null | |||||
| foreach ($f in $frames) { | |||||
| for ($i = 0; $i -lt $count; $i++) { | |||||
| $cx = $f[$i]; $sx = $f[16 + $i]; $cy = $f[32 + $i]; $sy = $f[48 + $i]; $dir = $f[64 + $i] | |||||
| if ($cx -ge $width -or $cy -ge $height -or $sx -gt 3 -or $sy -gt 7 -or $dir -gt 3) { | |||||
| $failures.Add("person $i out of range: cell ($cx,$cy) pixel ($sx,$sy) dir $dir"); continue | |||||
| } | |||||
| $tile = $tiles[$cy * $width + $cx] | |||||
| if ($tile -in $blocking) { $failures.Add("person $i on blocking tile $tile at cell ($cx,$cy)") } | |||||
| if ($previous) { | |||||
| $x0 = $previous[$i] * 4 + $previous[16 + $i]; $y0 = $previous[32 + $i] * 8 + $previous[48 + $i] | |||||
| $dx = [Math]::Abs($cx * 4 + $sx - $x0); $dy = [Math]::Abs($cy * 8 + $sy - $y0) | |||||
| if ($dx + $dy -gt 1) { $failures.Add("person $i jumped $dx,$dy pixels") } | |||||
| if ($dx + $dy -eq 1) { $moves[$i]++ } | |||||
| } | |||||
| } | |||||
| $previous = $f | |||||
| if ($failures.Count -gt 10) { break } | |||||
| } | |||||
| for ($i = 0; $i -lt $count; $i++) { | |||||
| if ($moves[$i] -eq 0) { $failures.Add("person $i never moved") } | |||||
| } | |||||
| $sectors = @(0..($count - 1) | ForEach-Object { [int]($first[$_] -ge 40) + 2 * [int]($first[32 + $_] -ge 25) } | Sort-Object -Unique) | |||||
| if ($sectors.Count -ne 4) { $failures.Add("people start in only $($sectors.Count) of 4 screens") } | |||||
| $seconds = [Math]::Round($frames.Count / 60.0, 1) | |||||
| Write-Host ("Logged {0} movement frames (~{1} s NTSC). Steps per person: {2}" -f $frames.Count, $seconds, ($moves -join ' ')) | |||||
| if ($failures.Count -gt 0) { | |||||
| $failures | Select-Object -First 10 | ForEach-Object { Write-Host " $_" } | |||||
| Write-Host '[FAIL] people check' -ForegroundColor Red | |||||
| exit 1 | |||||
| } | |||||
| Write-Host '[PASS] 16 people spread over 4 screens move one pixel at a time and never stand on water or stone.' -ForegroundColor Green | |||||
| exit 0 | |||||
Powered by TurnKey Linux.