25개 이상의 토픽을 선택하실 수 없습니다. Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

79 lines
3.4KB

  1. # E04-S05: compile HELLO.N8 in x128, extract the generated PRG, and run it in
  2. # a second x128 session; the screen must show the source's string.
  3. [CmdletBinding()]
  4. param([int]$Port = 6548, [int]$TimeoutSeconds = 180)
  5. $ErrorActionPreference = "Stop"
  6. $project = Split-Path $PSScriptRoot -Parent
  7. Import-Module (Join-Path $PSScriptRoot "lib\Nova128Test.psm1") -Force
  8. & (Join-Path $PSScriptRoot "build-hello-test.ps1")
  9. $out = Join-Path $project "build\hello-test"
  10. $disk = Join-Path $out "hello-test.d81"
  11. $text = "HELLO FROM NOVA128"
  12. $failures = @()
  13. # ------------------------------------------------------- compile session
  14. $session = Start-Nova128X128 -Autostart $disk -Drive8Image $disk -Port $Port `
  15. -Screenshot (Join-Path $out "hello-compile-vicii.png")
  16. try {
  17. $mb = Wait-Nova128Mailbox $session -TimeoutSeconds $TimeoutSeconds
  18. } finally {
  19. Stop-Nova128X128 $session
  20. }
  21. Write-Host ("mailbox: " + (($mb | ForEach-Object { $_.ToString('X2') }) -join ' '))
  22. if ($mb[2] -ne 0x02) { $failures += ("producer $($mb[2]) expected 2 (compiler)") }
  23. if ($mb[3] -ne 0xA5) {
  24. $failures += ("compiler status {0:X2} failed at stage {1}" -f $mb[3], $mb[4])
  25. }
  26. if ($mb[8] -ne 0) { $failures += "diagnostics present: $($mb[8]) (see HELLO.ERR)" }
  27. if ($mb[9] -ne 1) { $failures += "captured $($mb[9]) string prints, expected 1" }
  28. if ($mb[10] -ne 0) { $failures += "unsupported print flag set" }
  29. if ($mb[11] -ne 18) { $failures += "captured $($mb[11]) string bytes, expected 18" }
  30. if ($mb[12] -ne 0) { $failures += "output error $($mb[12])" }
  31. # ------------------------------------------------- extract the generated PRG
  32. $c1541 = Get-ViceTool "c1541"
  33. $prg = Join-Path $out "hello.prg"
  34. if (Test-Path -LiteralPath $prg) { Remove-Item -LiteralPath $prg -Force }
  35. & $c1541 -attach $disk -read "hello.prg" $prg 2>&1 | Out-Null
  36. if (-not (Test-Path -LiteralPath $prg)) {
  37. $failures += "HELLO.PRG was not written to the compile disk"
  38. } else {
  39. $bytes = [IO.File]::ReadAllBytes($prg)
  40. if ($bytes.Length -lt 14 -or $bytes[0] -ne 0x01 -or $bytes[1] -ne 0x1C) {
  41. $failures += "HELLO.PRG does not load at `$1C01"
  42. }
  43. }
  44. # ----------------------------------------------------------- run the PRG
  45. $hitRow = -1
  46. if (-not $failures) {
  47. $session = Start-Nova128X128 -Autostart $prg -Port ($Port + 1) `
  48. -Screenshot (Join-Path $out "hello-run-vicii.png")
  49. try {
  50. $deadline = [DateTime]::UtcNow.AddSeconds(60)
  51. while ([DateTime]::UtcNow -lt $deadline) {
  52. Start-Sleep -Seconds 1
  53. try { $screenRam = Read-Nova128Memory $session 0x0400 1000 } catch { continue }
  54. for ($r = 0; $r -lt 25; $r++) {
  55. $chars = for ($c = 0; $c -lt 40; $c++) {
  56. $code = $screenRam[$r * 40 + $c]
  57. if ($code -le 0x1F) { [char]($code + 0x40) } elseif ($code -le 0x3F) { [char]$code } else { '?' }
  58. }
  59. if ((-join $chars) -match [regex]::Escape($text)) { $hitRow = $r; break }
  60. }
  61. if ($hitRow -ge 0) { break }
  62. }
  63. } finally {
  64. Stop-Nova128X128 $session
  65. }
  66. if ($hitRow -lt 0) { $failures += "the generated PRG never displayed '$text'" }
  67. }
  68. if ($failures) { throw ("hello verification failed:`n " + ($failures -join "`n ")) }
  69. Write-Host ("compile: diagnostics 0, one 18-byte print, out_err 0; HELLO.PRG {0} bytes" -f (Get-Item $prg).Length)
  70. Write-Host ("run: '$text' displayed on screen row $hitRow")
  71. Write-Host "verified hello.n8 compiles to a PRG and the PRG runs in x128"

Powered by TurnKey Linux.