You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

321 line
20KB

  1. <#
  2. .SYNOPSIS
  3. Check pixel-smooth scrolling of the C64 build headless in VICE.
  4. .DESCRIPTION
  5. Each scenario is a list of phases. A phase holds keys (faked as in tools/check-keys.ps1:
  6. tracepoints on the key_row_* instructions set the row bits, so host key presses cannot
  7. interfere) until a condition on the program state is met at people_moved (a frame
  8. number or a view position); the phase number lives in free RAM at $CFF0 and VICE
  9. conditional checkpoints move it on. Every frame the script logs the phase, view
  10. position, buffer state and scroll registers at people_moved; in the last phase it
  11. saves both buffers (bitmap and screen RAM), and the last save is checked.
  12. Scenarios:
  13. edges right+down to the bottom-right corner, hold there, then SHIFT (up+left)
  14. to the top-left corner, hold there, then release
  15. middle down, then right, then release in the middle of the world
  16. reverse right, reverse to left in the frame after a cell step, right again;
  17. then down, reverse to up right after a cell step; release
  18. Checks, per scenario:
  19. - the view moves at most one pixel per axis per frame, only in the direction of the
  20. keys read the frame before, and stays inside
  21. vx 0-336, vy 0-244; the fine-scroll registers match the view
  22. - every scenario reaches its last phase; edges: the view reaches vx 336 and vy 244,
  23. then 0 and 0, and does not move while the keys push against an edge
  24. - in every frame the shown buffer is complete (buf_ready) and built for the view's
  25. cell (buf_cx, buf_cy); a half-rebuilt buffer on screen tears the top of the map
  26. - the main loop never misses a frame and the people update ends before raster 55
  27. - nothing is stored into the shown buffer's map screen RAM or bitmap while the map
  28. is displayed (raster 55-210): such a store tears the picture
  29. - frames where a held key did not move the view although no edge was reached are
  30. counted as stalls and reported (they happen while the hidden buffer is not ready)
  31. - at the end, the buffer about to be shown (bitmap and screen RAM) equals a fresh
  32. render of the world from the view's top-left cell (39 columns, 21 rows) with this
  33. frame's dots ORed in; when a flip is pending, the shown buffer has last frame's dots
  34. Exit codes: 0 = pass, 1 = fail, 2 = a tool is missing.
  35. .EXAMPLE
  36. pwsh -File tools/check-scroll.ps1
  37. #>
  38. [CmdletBinding()]
  39. param([switch]$NoBuild, [int]$TimeoutSeconds = 300, [int]$MaxStallFrames = 40)
  40. . (Join-Path $PSScriptRoot 'lib.ps1')
  41. function Get-Label([hashtable]$Target, [string]$Symbol) {
  42. foreach ($line in Get-Content -LiteralPath (Get-RepoPath $Target.build.labels)) {
  43. $parts = $line -split '\s+'
  44. if ($parts.Count -ge 3 -and $parts[2].TrimStart('.') -eq $Symbol) { return [Convert]::ToInt32($parts[1], 16) }
  45. }
  46. throw "Symbol '$Symbol' not found in $($Target.build.labels)."
  47. }
  48. # Tile data from src/tiles.inc: patterns in file order, colours as declared there.
  49. function Get-TileData {
  50. $src = Get-Content -LiteralPath (Get-RepoPath 'src/tiles.inc') -Raw
  51. $block = $src.Substring($src.IndexOf('tile_patterns:'))
  52. $block = $block.Substring(0, $block.IndexOf('.assert * - tile_patterns'))
  53. $patterns = @(foreach ($m in [regex]::Matches($block, '(?m)^\s*\.byte\s+([^;\r\n]+)')) {
  54. , @($m.Groups[1].Value -split ',' | ForEach-Object { [Convert]::ToByte($_.Trim().TrimStart('$'), 16) })
  55. })
  56. $colors = [System.Collections.Generic.List[byte]]::new()
  57. $cblock = $src.Substring($src.IndexOf('tile_colors:'))
  58. $cblock = $cblock.Substring(0, $cblock.IndexOf('.assert * - tile_colors'))
  59. $repeat = 1
  60. foreach ($line in $cblock -split "`n") {
  61. if ($line -match '\.repeat\s+(\d+)') { $repeat = [int]$Matches[1]; continue }
  62. if ($line -match '\.endrepeat') { $repeat = 1; continue }
  63. if ($line -match '\.byte\s+([^;\r\n]+)') {
  64. $vals = $Matches[1] -split ',' | ForEach-Object { [Convert]::ToByte($_.Trim().TrimStart('$'), 16) }
  65. for ($r = 0; $r -lt $repeat; $r++) { foreach ($v in $vals) { $colors.Add($v) } }
  66. }
  67. }
  68. @{ patterns = $patterns; colors = $colors.ToArray() }
  69. }
  70. try {
  71. $project = Get-ProjectConfig
  72. $target = Get-ProjectTargets $project 'c64'
  73. if (-not $NoBuild) { Invoke-TargetBuild $project $target @{} }
  74. $emu = Get-ToolPath $project $target.emulator.binary
  75. } catch [MissingToolException] {
  76. Write-Host $_.Exception.Message -ForegroundColor Yellow
  77. exit 2
  78. }
  79. $tiles = Get-TileData
  80. $L = @{}
  81. foreach ($s in 'smoke_ready', 'people_moved', 'world_tiles', 'people_cx', 'visible', 'view_cx', 'map_d011', 'map_d016',
  82. 'move_frame', 'people_flip_pending', 'buf_cx', 'buf_cy', 'buf_ready', 'view_fx', 'view_cy', 'view_fy',
  83. 'key_row_cursor', 'key_row_lshift', 'key_row_rshift', 'key_row_space') { $L[$s] = Get-Label $target $s }
  84. # Key bits (active low): cursor column RIGHT = bit 2, DOWN = bit 7; left SHIFT = bit 7.
  85. $RIGHT_DOWN = '7b'; $DOWN = '7f'; $RIGHTK = 'fb'; $NONE = 'ff'; $SHIFT = '7f'
  86. $PHASE = 0xCFF0 # free RAM (the program ends below $2700)
  87. # Phase end conditions: frame = move_frame value (wraps every 256 frames); view = cell and fine.
  88. function Frame([int]$n) { , (, @($L.move_frame, $n)) }
  89. function View([int]$cx, [int]$fx, [int]$cy, [int]$fy) {
  90. $c = @()
  91. if ($cx -ge 0) { $c += , @($L.view_cx, $cx); $c += , @($L.view_fx, $fx) }
  92. if ($cy -ge 0) { $c += , @($L.view_cy, $cy); $c += , @($L.view_fy, $fy) }
  93. $c
  94. }
  95. $scenarios = @(
  96. @{ name = 'edges'; cycles = 30000000; phases = @(
  97. @{ cursor = $NONE; lshift = $NONE; until = (Frame 30) }
  98. @{ cursor = $RIGHT_DOWN; lshift = $NONE; until = (View 42 0 30 4) } # vx 336, vy 244
  99. @{ cursor = $RIGHT_DOWN; lshift = $NONE; until = (Frame 0); edge = $true }
  100. @{ cursor = $RIGHT_DOWN; lshift = $SHIFT; until = (View 0 0 0 0) }
  101. @{ cursor = $RIGHT_DOWN; lshift = $SHIFT; until = (Frame 128); edge = $true }
  102. @{ cursor = $NONE; lshift = $NONE }) }
  103. @{ name = 'middle'; cycles = 12000000; phases = @(
  104. @{ cursor = $NONE; lshift = $NONE; until = (Frame 30) }
  105. @{ cursor = $DOWN; lshift = $NONE; until = (View -1 0 12 3) } # vy 99
  106. @{ cursor = $RIGHTK; lshift = $NONE; until = (View 16 5 -1 0) } # vx 133
  107. @{ cursor = $NONE; lshift = $NONE }) }
  108. @{ name = 'reverse'; cycles = 12000000; phases = @(
  109. @{ cursor = $NONE; lshift = $NONE; until = (Frame 30) }
  110. @{ cursor = $RIGHTK; lshift = $NONE; until = (View 9 0 -1 0) } # just stepped into cell 9
  111. @{ cursor = $RIGHTK; lshift = $SHIFT; until = (View 3 2 -1 0) }
  112. @{ cursor = $RIGHTK; lshift = $NONE; until = (View 5 0 -1 0) }
  113. @{ cursor = $DOWN; lshift = $NONE; until = (View -1 0 6 0) } # just stepped into row 6
  114. @{ cursor = $DOWN; lshift = $SHIFT; until = (View -1 0 2 1) }
  115. @{ cursor = $NONE; lshift = $NONE }) }
  116. )
  117. $root = Get-RepoPath 'build/check-scroll'
  118. if (Test-Path -LiteralPath $root) { Remove-Item -LiteralPath $root -Recurse -Force }
  119. $failedScenarios = 0
  120. foreach ($sc in $scenarios) {
  121. $dir = Join-Path $root $sc.name
  122. New-Item -ItemType Directory -Force -Path $dir | Out-Null
  123. $mon = [System.Collections.Generic.List[string]]::new()
  124. $mon.Add('logname "monitor.log"'); $mon.Add('log on')
  125. $n = 0
  126. $add = { param($addr, $cmd, $cond)
  127. $script:n++
  128. $line = 'trace exec ${0:x4}' -f $addr
  129. if ($cond) { $line += ' if ' + (($cond | ForEach-Object { '(@cpu:${0:x4} == ${1:x2})' -f $_[0], $_[1] }) -join ' && ') }
  130. $mon.Add($line); $mon.Add(('command {0} "{1}"' -f $script:n, $cmd))
  131. }
  132. $lastPhase = $sc.phases.Count - 1
  133. & $add $L.smoke_ready ('bsave \"world.bin\" 0 {0:x4} {1:x4}' -f $L.world_tiles, ($L.world_tiles + 3999)) $null
  134. & $add $L.smoke_ready ('> {0:x4} 00' -f $PHASE) $null
  135. foreach ($row in 'key_row_cursor', 'key_row_lshift', 'key_row_rshift', 'key_row_space') { & $add $L[$row] 'r a = ff' $null }
  136. for ($ph = 0; $ph -le $lastPhase; $ph++) { # later checkpoints at one address run after earlier ones
  137. $k = $sc.phases[$ph]
  138. if ($k.cursor -ne $NONE) { & $add $L.key_row_cursor "r a = $($k.cursor)" @(, @($PHASE, $ph)) }
  139. if ($k.lshift -ne $NONE) { & $add $L.key_row_lshift "r a = $($k.lshift)" @(, @($PHASE, $ph)) }
  140. }
  141. for ($ph = $lastPhase - 1; $ph -ge 0; $ph--) { # descending, so one hit moves on at most one phase
  142. & $add $L.people_moved ('> {0:x4} {1:x2}' -f $PHASE, ($ph + 1)) (@(, @($PHASE, $ph)) + $sc.phases[$ph].until)
  143. }
  144. $viewCheckpoint = $n + 1
  145. & $add $L.people_moved ('m {0:x4} {1:x4}' -f $L.view_cx, ($L.view_cx + 3)) $null
  146. & $add $L.people_moved ('m {0:x4} {1:x4}' -f $L.map_d011, ($L.map_d016)) $null
  147. & $add $L.people_moved ('m {0:x4} {0:x4}' -f $L.visible) $null
  148. & $add $L.people_moved ('m {0:x4} {0:x4}' -f $L.people_flip_pending) $null
  149. & $add $L.people_moved ('m {0:x4} {1:x4}' -f $L.buf_cx, ($L.buf_cx + 1)) $null
  150. & $add $L.people_moved ('m {0:x4} {1:x4}' -f $L.buf_cy, ($L.buf_cy + 1)) $null
  151. & $add $L.people_moved ('m {0:x4} {1:x4}' -f $L.buf_ready, ($L.buf_ready + 1)) $null
  152. & $add $L.people_moved ('m {0:x4} {0:x4}' -f $PHASE) $null
  153. & $add $L.people_moved ('m {0:x4} {1:x4}' -f $L.people_cx, ($L.people_cx + 79)) $null
  154. foreach ($save in @('bitmap-a.bin 6000 7a3f', 'bitmap-b.bin a000 ba3f', 'screen-a.bin 4000 4347', 'screen-b.bin 8000 8347')) {
  155. $f = $save -split ' '
  156. & $add $L.people_moved ('bsave \"{0}\" 0 {1} {2}' -f $f[0], $f[1], $f[2]) @(, @($PHASE, $lastPhase))
  157. }
  158. # Stores into the shown buffer's map (screen RAM rows 0-20, bitmap) while the map is displayed
  159. # (raster 55-210) would tear the picture. Armed at smoke_ready, so start-up is not counted.
  160. $firstStore = $n + 1
  161. foreach ($range in @(@(0, 0x4000, 0x4347), @(0, 0x6000, 0x7a3f), @(1, 0x8000, 0x8347), @(1, 0xa000, 0xba3f))) {
  162. $n++
  163. $mon.Add(('trace store ${0:x4} ${1:x4} if (@cpu:${2:x4} == ${3:x2}) && (RL > $36) && (RL < $d3)' -f $range[1], $range[2], $L.visible, $range[0]))
  164. $mon.Add("disable $n")
  165. }
  166. $lastStore = $n
  167. for ($c = $firstStore; $c -le $lastStore; $c++) { & $add $L.smoke_ready "enable $c" $null }
  168. Set-Content -LiteralPath (Join-Path $dir 'monitor.txt') -Value $mon
  169. Set-Content -LiteralPath (Join-Path $dir 'vicerc') -Value ''
  170. $vargs = @('-config', 'vicerc', '-default', '-sounddev', 'dummy', '-warp', '-minimized') + (Get-VideoArgs $target)
  171. $vargs += @('-limitcycles', [string]$sc.cycles, '-exitscreenshot', 'screen.png', '-moncommands', 'monitor.txt', '-autostartprgmode', '1', '-autostart', (Get-AutostartFile $target))
  172. $quoted = $vargs | ForEach-Object { if ($_ -match '[\s"]') { '"' + $_ + '"' } else { $_ } }
  173. $p = Start-Process -FilePath $emu -ArgumentList $quoted -WorkingDirectory $dir -PassThru `
  174. -RedirectStandardOutput (Join-Path $dir 'vice.log') -RedirectStandardError (Join-Path $dir 'vice.err')
  175. if (-not $p.WaitForExit($TimeoutSeconds * 1000)) { $p.Kill($true) }
  176. # Parse frames: view (4 bytes), d011/d016, visible, people table; clock and raster line.
  177. $frames = [System.Collections.Generic.List[hashtable]]::new()
  178. $cur = $null; $want = $false
  179. foreach ($line in Get-Content -LiteralPath (Join-Path $dir 'monitor.log') -Encoding Latin1) {
  180. if ($line -match "^#$viewCheckpoint \(Trace\s+exec [0-9a-fA-F]+\)\s+(\d+)/") {
  181. $cur = @{ line = [int]$Matches[1]; people = [System.Collections.Generic.List[byte]]::new() }; $frames.Add($cur); $want = $true; continue
  182. }
  183. if ($want -and $line -match '^\.C:.*\s(\d+)\s*$') { $cur.clock = [long]$Matches[1]; $want = $false; continue }
  184. if ($null -eq $cur -or $line -notmatch '^>C:([0-9a-fA-F]{4}) ((?:[0-9a-fA-F]{2} )+)') { continue }
  185. $addr = [Convert]::ToInt32($Matches[1], 16)
  186. $bytes = @($Matches[2].Trim() -split ' ' | ForEach-Object { [Convert]::ToByte($_, 16) })
  187. if ($addr -eq $L.view_cx) { $cur.cx = $bytes[0]; $cur.fx = $bytes[1]; $cur.cy = $bytes[2]; $cur.fy = $bytes[3] }
  188. elseif ($addr -eq $L.map_d011) { $cur.d011 = $bytes[0]; $cur.d016 = $bytes[1] }
  189. elseif ($addr -eq $L.visible) { $cur.visible = $bytes[0] }
  190. elseif ($addr -eq $PHASE) { $cur.phase = $bytes[0] }
  191. elseif ($addr -eq $L.people_flip_pending) { $cur.pending = $bytes[0] }
  192. elseif ($addr -eq $L.buf_cx) { $cur.bufcx = $bytes[0..1] }
  193. elseif ($addr -eq $L.buf_cy) { $cur.bufcy = $bytes[0..1] }
  194. elseif ($addr -eq $L.buf_ready) { $cur.ready = $bytes[0..1] }
  195. elseif ($addr -ge $L.people_cx -and $addr -lt $L.people_cx + 80) { foreach ($b in $bytes) { if ($cur.people.Count -lt 80) { $cur.people.Add($b) } } }
  196. }
  197. $failures = [System.Collections.Generic.List[string]]::new()
  198. # A rejected checkpoint shifts the numbers of the ones after it, so commands would land on the wrong ones.
  199. $monErrors = @(Select-String -LiteralPath (Join-Path $dir 'monitor.log') -Pattern '^ERROR|not a valid checkpoint' | Select-Object -First 3)
  200. foreach ($e in $monErrors) { $failures.Add("monitor script error: $($e.Line.Trim())") }
  201. if ($frames.Count -lt 100) { $failures.Add("only $($frames.Count) frames logged") }
  202. $tears = @(Select-String -LiteralPath (Join-Path $dir 'monitor.log') -Pattern '^#(\d+) \(Trace\s+store ([0-9a-fA-F]{4})\)\s+(\d+)/' |
  203. Where-Object { [int]$_.Matches[0].Groups[1].Value -ge $firstStore -and [int]$_.Matches[0].Groups[1].Value -lt $firstStore + 4 })
  204. if ($tears.Count -gt 0) {
  205. $t = $tears[0].Matches[0].Groups
  206. $failures.Add("$($tears.Count) store(s) into the shown buffer while the map was displayed (first: `$$($t[2].Value) at raster line $($t[3].Value))")
  207. }
  208. $stalls = 0; $steps = 0; $late = 0; $lastLine = 0
  209. $maxVx = 0; $maxVy = 0; $minAfterMaxVx = 999; $minAfterMaxVy = 999
  210. $phaseFrames = @(0) * $sc.phases.Count
  211. for ($i = 0; $i -lt $frames.Count; $i++) {
  212. $f = $frames[$i]
  213. $vx = 8 * $f.cx + $f.fx; $vy = 8 * $f.cy + $f.fy
  214. $f.vx = $vx; $f.vy = $vy
  215. if ($f.phase -lt $sc.phases.Count) { $phaseFrames[$f.phase]++ } else { $failures.Add("frame ${i}: phase $($f.phase) out of range") }
  216. if ($vx -gt 336 -or $vy -gt 244 -or $f.fx -gt 7 -or $f.fy -gt 7) { $failures.Add("frame ${i}: view out of range ($vx,$vy)") }
  217. if ($f.d016 -ne (0x10 -bor (7 - $f.fx)) -or $f.d011 -ne (0x30 -bor (7 - $f.fy))) { $failures.Add(("frame {0}: registers d011={1:x2} d016={2:x2} do not match view fine scroll ({3},{4})" -f $i, $f.d011, $f.d016, $f.fx, $f.fy)) }
  218. $v = $f.visible
  219. if (-not $f.ready[$v] -or $f.bufcx[$v] -ne $f.cx -or $f.bufcy[$v] -ne $f.cy) {
  220. $failures.Add("frame ${i}: shown buffer $v is not a complete render at the view cell (ready $($f.ready[$v]), origin $($f.bufcx[$v]),$($f.bufcy[$v]), view cell $($f.cx),$($f.cy))")
  221. }
  222. if ($f.line -ge 55 -and $f.line -lt 251) { $failures.Add("frame ${i}: people update ended at raster line $($f.line)") }
  223. elseif ($f.line -lt 55) { $lastLine = [Math]::Max($lastLine, $f.line) }
  224. if ($i -gt 0) {
  225. $p = $frames[$i - 1]
  226. $dx = $vx - $p.vx; $dy = $vy - $p.vy
  227. if ($dx -ne 0 -or $dy -ne 0) { $steps++ }
  228. if ($f.clock - $p.clock -gt 1.5 * 17095) { $late++ }
  229. # The keys read after people_moved in frame i-1 (that frame's phase) give frame i's step.
  230. $k = $sc.phases[[Math]::Min($p.phase, $lastPhase)]
  231. $bits = [Convert]::ToByte($k.cursor, 16)
  232. $sign = if ($k.lshift -eq $SHIFT) { -1 } else { 1 }
  233. $wantX = if (($bits -band 0x04) -eq 0) { $sign } else { 0 }
  234. $wantY = if (($bits -band 0x80) -eq 0) { $sign } else { 0 }
  235. if (($dx -ne 0 -and $dx -ne $wantX) -or ($dy -ne 0 -and $dy -ne $wantY)) {
  236. $failures.Add("frame ${i}: view moved by ($dx,$dy) with keys asking for ($wantX,$wantY)")
  237. }
  238. if ($k.edge -and $f.phase -eq $p.phase -and ($dx -ne 0 -or $dy -ne 0)) { $failures.Add("frame ${i}: view moved by ($dx,$dy) while held against an edge") }
  239. $canX = ($wantX -gt 0 -and $p.vx -lt 336) -or ($wantX -lt 0 -and $p.vx -gt 0)
  240. $canY = ($wantY -gt 0 -and $p.vy -lt 244) -or ($wantY -lt 0 -and $p.vy -gt 0)
  241. if (($canX -or $canY) -and $dx -eq 0 -and $dy -eq 0) { $stalls++ }
  242. }
  243. if ($vx -gt $maxVx) { $maxVx = $vx; $minAfterMaxVx = $vx }
  244. if ($vy -gt $maxVy) { $maxVy = $vy; $minAfterMaxVy = $vy }
  245. if ($vx -lt $minAfterMaxVx) { $minAfterMaxVx = $vx }
  246. if ($vy -lt $minAfterMaxVy) { $minAfterMaxVy = $vy }
  247. }
  248. if ($late -gt 0) { $failures.Add("the main loop missed $late frame(s)") }
  249. if ($phaseFrames[$lastPhase] -lt 10) { $failures.Add("reached the last phase for only $($phaseFrames[$lastPhase]) frame(s) (frames per phase: $($phaseFrames -join ', '))") }
  250. if ($sc.name -eq 'edges') {
  251. if ($maxVx -ne 336 -or $maxVy -ne 244) { $failures.Add("did not reach the bottom-right edge (max vx $maxVx, vy $maxVy)") }
  252. if ($minAfterMaxVx -ne 0 -or $minAfterMaxVy -ne 0) { $failures.Add("did not return to the top-left edge (min vx $minAfterMaxVx, vy $minAfterMaxVy)") }
  253. }
  254. if ($stalls -gt $MaxStallFrames) { $failures.Add("$stalls stall frames (allowed $MaxStallFrames)") }
  255. # Final frames: at people_moved, the buffer that will be shown (the hidden one when a flip is
  256. # pending, otherwise the shown one) must equal a fresh render at the view origin plus this
  257. # frame's dots; with a flip pending, the shown buffer must hold the previous frame's dots.
  258. $world = [IO.File]::ReadAllBytes((Join-Path $dir 'world.bin'))
  259. $last = $frames[$frames.Count - 1]
  260. $checkBuffer = {
  261. param([int]$buf, $people, [string]$what)
  262. $suffix = @('a', 'b')[$buf]
  263. $bitmap = [IO.File]::ReadAllBytes((Join-Path $dir "bitmap-$suffix.bin"))
  264. $screen = [IO.File]::ReadAllBytes((Join-Path $dir "screen-$suffix.bin"))
  265. $dots = @{}
  266. for ($i = 0; $i -lt 16; $i++) {
  267. $col = $people[$i] - $last.cx; $row = $people[32 + $i] - $last.cy
  268. if ($col -ge 0 -and $col -lt 39 -and $row -ge 0 -and $row -lt 21) {
  269. $o = $row * 320 + $col * 8 + $people[48 + $i]
  270. $dots[$o] = [int]$dots[$o] -bor (0xC0 -shr (2 * $people[16 + $i]))
  271. }
  272. }
  273. $badBitmap = 0; $badScreen = 0
  274. $rows = [Math]::Min(21, 50 - $last.cy)
  275. for ($r = 0; $r -lt $rows; $r++) {
  276. for ($c = 0; $c -lt 39; $c++) {
  277. $t = $world[($last.cy + $r) * 80 + $last.cx + $c]
  278. if ($screen[$r * 40 + $c] -ne $tiles.colors[$t]) { $badScreen++ }
  279. for ($k = 0; $k -lt 8; $k++) {
  280. $o = $r * 320 + $c * 8 + $k
  281. if ($bitmap[$o] -ne ($tiles.patterns[$t][$k] -bor [int]$dots[$o])) { $badBitmap++ }
  282. }
  283. }
  284. }
  285. if ($badBitmap -gt 0 -or $badScreen -gt 0) { $failures.Add("buffer $suffix ($what) differs from the world plus dots: $badBitmap bitmap bytes, $badScreen colour bytes") }
  286. }
  287. if ($last.pending) {
  288. & $checkBuffer (1 - $last.visible) $last.people 'shown next frame'
  289. $prev = $frames[$frames.Count - 2]
  290. if ($prev.cx -eq $last.cx -and $prev.cy -eq $last.cy) { & $checkBuffer $last.visible $prev.people 'shown, previous dots' }
  291. } else {
  292. & $checkBuffer $last.visible $last.people 'shown'
  293. }
  294. $summary = "{0}: {1} frames (per phase {9}), {2} moving, {3} stall frames, update done by line {4}, final view ({5},{6}) cell ({7},{8})" -f `
  295. $sc.name, $frames.Count, $steps, $stalls, $lastLine, $last.vx, $last.vy, $last.cx, $last.cy, ($phaseFrames -join '/')
  296. if ($failures.Count -gt 0) {
  297. $failedScenarios++
  298. Write-Host " FAIL $summary" -ForegroundColor Red
  299. $failures | Select-Object -First 8 | ForEach-Object { Write-Host " $_" }
  300. } else {
  301. Write-Host " ok $summary"
  302. }
  303. }
  304. if ($failedScenarios -gt 0) { Write-Host "[FAIL] $failedScenarios of $($scenarios.Count) scroll scenarios" -ForegroundColor Red; exit 1 }
  305. Write-Host "[PASS] all $($scenarios.Count) scroll scenarios: smooth one-pixel steps, edges respected, shown buffer matches the world" -ForegroundColor Green
  306. exit 0

Powered by TurnKey Linux.