|
- # E04-S05: run the print/fault runtime test in x128, then check the screen
- # text and the mailbox failure fields.
- [CmdletBinding()]
- param([int]$Port = 6546, [int]$TimeoutSeconds = 180)
-
- $ErrorActionPreference = "Stop"
- $project = Split-Path $PSScriptRoot -Parent
- Import-Module (Join-Path $PSScriptRoot "lib\Nova128Test.psm1") -Force
- & (Join-Path $PSScriptRoot "build-print-test.ps1")
-
- $out = Join-Path $project "build\print-test"
- $disk = Join-Path $out "print-test.d81"
- $expected = @(
- "NOVA128 PRINT TEST",
- "TEXT OK",
- "BYTE 0 7 255",
- "WORD 0 12345 65535",
- "INT -1 -32768 32767",
- "BOOL FALSE TRUE",
- "CHAR A",
- "RUNTIME FAULT R001",
- "RUNTIME FAULT R002",
- "RUNTIME FAULT R003",
- "RUNTIME FAULT R004",
- "RUNTIME FAULT R005")
- $failures = @()
-
- $session = Start-Nova128X128 -Autostart $disk -Drive8Image $disk -Port $Port `
- -Screenshot (Join-Path $out "print-test-vicii.png")
- try {
- $null = Wait-Nova128Mailbox $session -TimeoutSeconds $TimeoutSeconds
- Start-Sleep -Seconds 2 # all five fault lines are printed
- $mb = Read-Nova128Memory $session 0x1BF0 16
- $screenRam = Read-Nova128Memory $session 0x0400 1000
- } finally {
- Stop-Nova128X128 $session -SettleSeconds 0
- }
-
- # ------------------------------------------------------------- mailbox
- if ($mb[2] -ne 0x03) { $failures += ("producer $($mb[2]) expected 3 (generated program)") }
- if ($mb[3] -ne 0xFA) { $failures += ("status ${0:X2} expected FA (failure)" -f $mb[3]) }
- if ($mb[4] -ne 5 -or $mb[5] -ne 0) { $failures += ("code {0} expected 5 (heap)" -f ($mb[4] + 256 * $mb[5])) }
- $addr = $mb[6] + 256 * $mb[7]
- if ($addr -ne 0x1234) { $failures += ("address ${0:X4} expected 1234" -f $addr) }
- if ($mb[8] -ne 1) { $failures += "CR/RCR changed across the print and fault calls" }
-
- # -------------------------------------------------------------- screen
- $rows = for ($r = 0; $r -lt 25; $r++) {
- $chars = for ($c = 0; $c -lt 40; $c++) {
- $code = $screenRam[$r * 40 + $c]
- if ($code -le 0x1F) { [char]($code + 0x40) } elseif ($code -le 0x3F) { [char]$code } else { '?' }
- }
- (-join $chars).TrimEnd()
- }
- for ($r = 0; $r -lt $expected.Count; $r++) {
- if ($rows[$r] -cne $expected[$r]) {
- $failures += "screen row ${r}: '$($rows[$r])' expected '$($expected[$r])'"
- }
- }
- $wide = @($rows[0..($expected.Count - 1)] | Where-Object { $_.Length -gt 39 })
- if ($wide) { $failures += "screen rows longer than 39: $($wide -join ' | ')" }
-
- if ($failures) { throw ("print runtime verification failed:`n " + ($failures -join "`n ")) }
- Write-Host "screen:"
- $rows[0..($expected.Count - 1)] | ForEach-Object { Write-Host " |$_" }
- Write-Host ("mailbox: producer 3, status FA, code 5, address {0:X4}, mapping preserved" -f $addr)
- Write-Host "verified print formatting, fault reporting, and mapping stability"
|