Nie możesz wybrać więcej, niż 25 tematów Tematy muszą się zaczynać od litery lub cyfry, mogą zawierać myślniki ('-') i mogą mieć do 35 znaków.

75 wiersze
2.6KB

  1. # E01-S04: build the independent C128 display/clock probe.
  2. [CmdletBinding()]
  3. param()
  4. $ErrorActionPreference = "Stop"
  5. $project = Split-Path $PSScriptRoot -Parent
  6. $build = Join-Path $project "build"
  7. $source = Join-Path $project "src\platform\display-clock.s"
  8. $config = Join-Path $project "cfg\display-clock-c128.cfg"
  9. $object = Join-Path $build "display-clock.o"
  10. $program = Join-Path $build "display-clock.prg"
  11. $map = Join-Path $build "display-clock.map"
  12. $labels = Join-Path $build "display-clock.lbl"
  13. $debug = Join-Path $build "display-clock.dbg"
  14. $ca65 = (Get-Command ca65 -ErrorAction Stop).Source
  15. $ld65 = (Get-Command ld65 -ErrorAction Stop).Source
  16. New-Item -ItemType Directory -Force -Path $build | Out-Null
  17. foreach ($path in @($object, $program, $map, $labels, $debug)) {
  18. if (Test-Path -LiteralPath $path) {
  19. Remove-Item -LiteralPath $path -Force
  20. }
  21. }
  22. # VDC register access would make semantic storage/display behavior ambiguous.
  23. $sourceText = Get-Content -Raw -LiteralPath $source
  24. $codeOnly = ($sourceText -split "`n" | ForEach-Object {
  25. ($_ -split ';', 2)[0]
  26. }) -join "`n"
  27. if ($codeOnly -match '(?i)\$D60[01]') {
  28. throw "display/clock probe must not access VDC address/data registers"
  29. }
  30. & $ca65 --cpu 6502 --debug-info -o $object $source
  31. if ($LASTEXITCODE -ne 0) { throw "ca65 failed with exit code $LASTEXITCODE" }
  32. & $ld65 -C $config -o $program -m $map -Ln $labels --dbgfile $debug $object
  33. if ($LASTEXITCODE -ne 0) { throw "ld65 failed with exit code $LASTEXITCODE" }
  34. $bytes = [IO.File]::ReadAllBytes($program)
  35. if ($bytes.Length -lt 16) { throw "display-clock.prg is unexpectedly short" }
  36. if ($bytes[0] -ne 0x01 -or $bytes[1] -ne 0x1C) {
  37. throw "display-clock.prg load address is not `$1C01"
  38. }
  39. $labelText = Get-Content -Raw -LiteralPath $labels
  40. $expectedLabels = @{
  41. display_clock_entry = '001C0D'
  42. mode_40_checkpoint = '001C2E'
  43. mode_80_checkpoint = '001C3D'
  44. fast_checkpoint = '001C49'
  45. fallback_done = '001C8C'
  46. display_result = '001D0F'
  47. mode_observed = '001D10'
  48. fast_observed = '001D11'
  49. final_clock = '001D12'
  50. semantic_a = '001D13'
  51. semantic_b = '001D14'
  52. }
  53. foreach ($item in $expectedLabels.GetEnumerator()) {
  54. $pattern = "(?im)^al\s+" + $item.Value + "\s+\." +
  55. [regex]::Escape($item.Key) + "\s*$"
  56. if ($labelText -notmatch $pattern) {
  57. throw ("linker label {0} did not resolve to `${1}" -f
  58. $item.Key, $item.Value.Substring(2))
  59. }
  60. }
  61. Write-Host ("built {0} ({1} bytes)" -f $program, $bytes.Length)
  62. Write-Host ("map {0}" -f $map)
  63. Write-Host ("labels {0}" -f $labels)

Powered by TurnKey Linux.