Преглед изворни кода

M4.1: people no longer walk on the water pixels of bridges

candidate_blocked checks the pixel on bridge tiles; place_people picks the
pixel before the check. check-people now fails a dot on a blue or grey pixel.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
main
Daniel Covington пре 2 дана
родитељ
комит
ab279c2308
4 измењених фајлова са 69 додато и 11 уклоњено
  1. +1
    -0
      docs/manual-tests.md
  2. +6
    -1
      docs/verification-status.md
  3. +27
    -7
      src/people.inc
  4. +35
    -3
      tools/check-people.ps1

+ 1
- 0
docs/manual-tests.md Прегледај датотеку

@@ -260,6 +260,7 @@ Expected:
water it continues as a bridge (black over blue), with no gap.
- No colour clash, no stray pixels at shores, bridges or crossings.
- Dots walk on land, grass, trees, roads and bridges, and never step onto water or stone.
On a bridge a dot stays on the black road and never touches the blue water on either side.
- Scrolling stays smooth over textured terrain (no regular stutter at each cell step). A short
hesitation when a scroll starts from rest is acceptable, as before.



+ 6
- 1
docs/verification-status.md Прегледај датотеку

@@ -18,10 +18,15 @@ manual = `pending`, `confirmed by user (<date>)`, `problem reported (<date>): <n
| M3.2 Split screen: raster interrupts switch to text below a 20-row map and back at the top of the frame; status text screen and ROM font copy in both banks; status lines with the people-in-view count. | passed (2026-12-03, `pwsh -File tools/build.ps1`; `pwsh -File tools/smoke.ps1` incl. status text in both banks; `pwsh -File tools/check-world.ps1`; `pwsh -File tools/check-people.ps1`; `pwsh -File tools/check-keys.ps1`; `pwsh -File tools/check-split.ps1`: 955 splits in 955 frames, writes start at 210:55-61, digits right in every frame) | confirmed by user (2026-12-03) |
| M3.3 Fine scroll via $D016/$D011 in the 38-column, 20-row map area; rebuild the hidden buffer from tiles over 8 frames and flip on wrap; stop at world edges; show the view position in the status area; draw people relative to the view (in the shown buffer during vertical blank while a rebuild runs). | 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,127 frames, 0 missed, update done by line 36; `pwsh -File tools/check-keys.ps1`: 8 of 8; `pwsh -File tools/check-split.ps1`: 964 splits in 964 frames, all y-scroll values 0-7, starts 210:55-64, digits right after 240 of 240 status updates; `pwsh -File tools/check-scroll.ps1`: 3 of 3 scenarios, edges reached and held, 1-5 stall frames per scenario, both buffers byte-exact at the end) | confirmed by user (2026-12-03), after the fix for the reported tear ("the top of the screen tears a little when I go left or right") |
| M3.4 Check that people stay aligned with the terrain over long scrolling runs; measure the frame budget with a border-colour timing bar. | 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,130 frames, update done by line 21; `pwsh -File tools/check-keys.ps1`: 8 of 8; `pwsh -File tools/check-split.ps1`: 962 splits, digits 241/241; `pwsh -File tools/check-scroll.ps1 -Long`: 4 of 4, tour 23,195 frames (about 6.4 minutes NTSC) with 21 stops byte-exact, people update done by line 45 at the latest; timing build `--asm-define TIMING_BAR` built and screenshot in VICE) | confirmed by user (2026-12-03), with the light brown background (colour 8, pepto-pal palette); dots visible |
| M4.1 Region generator: each world rolls its own terrain mix; jittered seeds on a grid give every class areas all over the world, shaped by noisy distances, smoothing and removal of thin water; shores from the neighbours; trees on grass. Roads stay a grid of two rows and two columns and become bridges over water. The scroll rebuild skips cells whose tile is already drawn, to keep the 8-frame rebuild with textured terrain everywhere. | passed (2026-12-03, `pwsh -File tools/build.ps1` (4,647 bytes); `pwsh -File tools/smoke.ps1`; `pwsh -File tools/check-world.ps1 -Runs 10`: 10 of 10 worlds, every 40x20 view with 3+ terrain kinds, map ready 7.1-7.3 s after power-on (generation 4.0-4.1 s), mix spread land 14 / grass-trees 8 / water 13 / stone 16 percentage points; `pwsh -File tools/check-people.ps1`: 1,919 frames, 0 missed, update done by line 20; `pwsh -File tools/check-keys.ps1`: 8 of 8; `pwsh -File tools/check-split.ps1`: 734 splits, digits right after 183 of 183 updates; `pwsh -File tools/check-scroll.ps1 -Long`: 4 of 4, tour 22,966 frames with 21 stops byte-exact, 116 stall frames in 15,216 moving frames) | pending |
| M4.1 Region generator: each world rolls its own terrain mix; jittered seeds on a grid give every class areas all over the world, shaped by noisy distances, smoothing and removal of thin water; shores from the neighbours; trees on grass. Roads stay a grid of two rows and two columns and become bridges over water. The scroll rebuild skips cells whose tile is already drawn, to keep the 8-frame rebuild with textured terrain everywhere. | passed (2026-12-03, `pwsh -File tools/build.ps1` (4,647 bytes); `pwsh -File tools/smoke.ps1`; `pwsh -File tools/check-world.ps1 -Runs 10`: 10 of 10 worlds, every 40x20 view with 3+ terrain kinds, map ready 7.1-7.3 s after power-on (generation 4.0-4.1 s), mix spread land 14 / grass-trees 8 / water 13 / stone 16 percentage points; `pwsh -File tools/check-people.ps1`: 1,919 frames, 0 missed, update done by line 20; `pwsh -File tools/check-keys.ps1`: 8 of 8; `pwsh -File tools/check-split.ps1`: 734 splits, digits right after 183 of 183 updates; `pwsh -File tools/check-scroll.ps1 -Long`: 4 of 4, tour 22,966 frames with 21 stops byte-exact, 116 stall frames in 15,216 moving frames; fix for walking on bridge water, 2026-12-03: `pwsh -File tools/build.ps1` (4,683 bytes); `pwsh -File tools/smoke.ps1`; `pwsh -File tools/check-world.ps1` and `-Runs 10`: 10 of 10; `pwsh -File tools/check-keys.ps1`: 8 of 8; `pwsh -File tools/check-split.ps1`; `pwsh -File tools/check-scroll.ps1`: 3 of 3; `pwsh -File tools/check-people.ps1 -Cycles 300000000`: 17,119 frames, 1,408 person-frames on bridges, no dot on a blue or grey pixel; the same check fails on the old code (person 9 on a blue pixel of bridge tile 20)) | problem reported (2026-12-03): people walked in the water (the blue pixels of bridge tiles). Fixed; waiting for the user to check again. |

## Notes

- 2026-12-03 (M4.1 fix, problem reported by the user: "people can walk in the water"):
- Cause: the M4.1 bridge tiles (BRIDGE_H, BRIDGE_V, BRIDGE_X) were walkable as whole tiles, but their %01 pixels are blue water. Dots walked along a bridge's water edge, and place_people could also put a dot there at the start. This broke R2.3.
- Fix (src/people.inc): candidate_blocked now checks the pixel. On a bridge tile it reads the tile's pattern byte for row cand_sy and blocks a %01 pixel at cand_sx. place_people picks the pixel position before the check. An assert keeps the bridges as the last tiles.
- tools/check-people.ps1 now also checks the colour of the pixel under every dot (from the patterns and colours in src/tiles.inc): blue (6) or grey (12) fails. It reports the person-frames on bridges. The default 40M-cycle run may see none, so the fix was also checked with -Cycles 300000000 (1,408 person-frames on bridges, pass). On the old code the same run failed.

- 2026-12-03 (M4.1, spec change approved by the user: terrain all over the world, random mix per world, roads as a grid with bridges):
- Generator (src/world.inc): per-world class weights and tree threshold; 8x5 jittered seeds on 10x10-cell squares (a class never repeats the previous two seeds; every class appears at least once); each cell takes the nearest seed among the 2x2 nearest squares (distance max + min/2 + noise 0-3); two smoothing passes; thin water removed; shores from the four neighbours; trees on grass; roads as two rows and two columns, bridge tiles (BRIDGE_H, BRIDGE_V, BRIDGE_X; src/tiles.inc) over water. Generation takes about 4 s behind the generating message (the 3x3 seed search took about 6 s and looked the same).
- tools/check-world.ps1 rewritten for the new rules (R1.3-R1.6): tile IDs, all classes present, exactly the road grid with crossings, bridges beside water, no one-cell-thin water, shores matching their neighbours, every 40x20 view with 3+ classes of 8+ cells, map ready within 15 s; -Runs N checks N VICE runs and the spread of the mix. Its first version wrongly required a bridge wherever a road had water on both sides; a road on a one-cell land causeway between lakes is correct, so the rule is now "a bridge has water beside it".


+ 27
- 7
src/people.inc Прегледај датотеку

@@ -10,6 +10,7 @@ TURN_TRIES = 5 ; current direction, then all four from a random

.assert STONE + 1 = WATER, error, "Blocking tiles must be contiguous"
.assert WATER_SE + 1 = ROAD_H, error, "Blocking tiles must be contiguous"
.assert BRIDGE_X + 1 = TILE_COUNT, error, "Bridge tiles must come last"

.export people_cx, people_moved, people_in_view

@@ -45,18 +46,22 @@ place_people:
clc
adc sector_top,x
sta cand_cy
jsr random_byte
and #3
sta cand_sx
jsr random_byte
and #7
sta cand_sy
jsr candidate_blocked
ldx person
bcs @person
lda cand_cx
sta people_cx,x
lda cand_sx
sta people_sx,x
lda cand_cy
sta people_cy,x
jsr random_byte
and #3
sta people_sx,x
jsr random_byte
and #7
lda cand_sy
sta people_sy,x
jsr random_byte
and #3
@@ -176,7 +181,9 @@ move_person:
jmp @try
@stay: rts ; boxed in: stay put this step

; Carry set if the tile at (cand_cx, cand_cy) is water or stone.
; Carry set if the pixel at (cand_cx/cand_sx, cand_cy/cand_sy) is water or
; stone: a water or stone tile, or a blue %01 water pixel of a bridge tile
; (bridges are walkable only on their road pixels). Changes A, X and Y.
candidate_blocked:
ldx cand_cy
ldy cand_cx
@@ -185,7 +192,20 @@ candidate_blocked:
cmp #STONE
bcc @open
cmp #WATER_SE+1
bcs @open
bcc @blocked
cmp #BRIDGE_H
bcc @open
asl a ; tile * 8 (TILE_COUNT <= 32)
asl a
asl a
ora cand_sy
tax
lda tile_patterns,x
ldy cand_sx
and pixel_masks,y
and #$55 ; a set low bit of the pair = %01 = water
beq @open
@blocked:
sec
rts
@open: clc


+ 35
- 3
tools/check-people.ps1 Прегледај датотеку

@@ -10,7 +10,8 @@
before the flip): print the people table and the visible-buffer flag to the
monitor log, and save both bitmaps (each frame overwrites the last).
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),
16 people inside the 80x50 world, every one on a walkable tile (not water or stone)
and on a pixel that is not blue or grey (the water pixels of bridge tiles),
every step at most one pixel, and every person moving during the run. It checks
that the main loop never misses a frame (x64sc NTSC frame = 263 lines x 65 =
17,095 cycles; a gap over 1.5 frames fails), and that
@@ -35,6 +36,29 @@ $count = 16
$width = 80
$height = 50
$blocking = 3..12 # STONE..WATER_SE in src/tiles.inc
$waterColors = 6, 12 # blue and grey: no dot may stand on these pixels

function Get-TileData {
$src = Get-Content -LiteralPath (Get-RepoPath 'src/tiles.inc') -Raw
$block = $src.Substring($src.IndexOf('tile_patterns:'))
$block = $block.Substring(0, $block.IndexOf('.assert * - tile_patterns'))
$patterns = @(foreach ($m in [regex]::Matches($block, '(?m)^\s*\.byte\s+([^;\r\n]+)')) {
, @($m.Groups[1].Value -split ',' | ForEach-Object { [Convert]::ToByte($_.Trim().TrimStart('$'), 16) })
})
$colors = [System.Collections.Generic.List[byte]]::new()
$cblock = $src.Substring($src.IndexOf('tile_colors:'))
$cblock = $cblock.Substring(0, $cblock.IndexOf('.assert * - tile_colors'))
$repeat = 1
foreach ($line in $cblock -split "`n") {
if ($line -match '\.repeat\s+(\d+)') { $repeat = [int]$Matches[1]; continue }
if ($line -match '\.endrepeat') { $repeat = 1; continue }
if ($line -match '\.byte\s+([^;\r\n]+)') {
$vals = $Matches[1] -split ',' | ForEach-Object { [Convert]::ToByte($_.Trim().TrimStart('$'), 16) }
for ($r = 0; $r -lt $repeat; $r++) { foreach ($v in $vals) { $colors.Add($v) } }
}
}
@{ patterns = $patterns; colors = $colors.ToArray() }
}

function Get-Label([hashtable]$Target, [string]$Symbol) {
foreach ($line in Get-Content -LiteralPath (Get-RepoPath $Target.build.labels)) {
@@ -129,6 +153,9 @@ foreach ($line in Get-Content -LiteralPath $logFile) {
}
if ($frames.Count -lt 60) { Write-Host "[FAIL] Only $($frames.Count) frames logged." -ForegroundColor Red; exit 1 }

$tileData = Get-TileData
$bridgeFirst = $tileData.patterns.Count - 3 # BRIDGE_H..BRIDGE_X are the last tiles
$onBridge = 0
$first = $frames[0]
$moves = [int[]]::new($count)
$previous = $null
@@ -140,6 +167,11 @@ foreach ($f in $frames) {
}
$tile = $tiles[$cy * $width + $cx]
if ($tile -in $blocking) { $failures.Add("person $i on blocking tile $tile at cell ($cx,$cy)") }
# The pixel under the dot: %01 takes the high colour nibble, %10 the low one.
$pixel = ($tileData.patterns[$tile][$sy] -shr (6 - 2 * $sx)) -band 3
$color = switch ($pixel) { 1 { $tileData.colors[$tile] -shr 4 } 2 { $tileData.colors[$tile] -band 15 } default { -1 } }
if ($color -in $waterColors) { $failures.Add("person $i on a colour $color pixel of tile $tile at cell ($cx,$cy) pixel ($sx,$sy)") }
if ($tile -ge $bridgeFirst) { $onBridge++ }
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)
@@ -200,11 +232,11 @@ if ($sectors.Count -ne 4) { $failures.Add("people start in only $($sectors.Count

$seconds = [Math]::Round($frames.Count / 60.0, 1)
Write-Host ("Buffer flips: {0} frames, {1} missed; people update done by raster line {2} at the latest. Final hidden buffer: {3}, {4} bytes carry dots." -f $clocks.Count, $late, $lastLine, ('A', 'B')[$hiddenIndex], $dots)
Write-Host ("Logged {0} movement frames (~{1} s NTSC). Steps per person: {2}" -f $frames.Count, $seconds, ($moves -join ' '))
Write-Host ("Logged {0} movement frames (~{1} s NTSC). Steps per person: {2}. Person-frames on bridges: {3}." -f $frames.Count, $seconds, ($moves -join ' '), $onBridge)
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, never stand on water or stone; both buffers hold only the clean map plus the right dots; one flip per frame.' -ForegroundColor Green
Write-Host '[PASS] 16 people spread over 4 screens move one pixel at a time, never stand on water or stone (tiles or blue/grey bridge pixels); both buffers hold only the clean map plus the right dots; one flip per frame.' -ForegroundColor Green
exit 0

Loading…
Откажи
Сачувај

Powered by TurnKey Linux.