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
3.2KB

  1. # E01-S03: build the C128 KERNAL wrapper probe and its test disk.
  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\kernal-probe.s"
  8. $config = Join-Path $project "cfg\kernal-probe-c128.cfg"
  9. $object = Join-Path $build "kernal-probe.o"
  10. $program = Join-Path $build "kernal-probe.prg"
  11. $map = Join-Path $build "kernal-probe.map"
  12. $labels = Join-Path $build "kernal-probe.lbl"
  13. $debug = Join-Path $build "kernal-probe.dbg"
  14. $listing = Join-Path $build "kernal-probe.lst"
  15. $ca65 = (Get-Command ca65 -ErrorAction Stop).Source
  16. $ld65 = (Get-Command ld65 -ErrorAction Stop).Source
  17. New-Item -ItemType Directory -Force -Path $build | Out-Null
  18. foreach ($path in @($object, $program, $map, $labels, $debug, $listing)) {
  19. if (Test-Path -LiteralPath $path) { Remove-Item -LiteralPath $path -Force }
  20. }
  21. & $ca65 --cpu 6502 --debug-info -l $listing -o $object $source
  22. if ($LASTEXITCODE -ne 0) { throw "ca65 failed with exit code $LASTEXITCODE" }
  23. & $ld65 -C $config -o $program -m $map -Ln $labels --dbgfile $debug $object
  24. if ($LASTEXITCODE -ne 0) { throw "ld65 failed with exit code $LASTEXITCODE" }
  25. $bytes = [IO.File]::ReadAllBytes($program)
  26. if ($bytes.Length -lt 16) { throw "kernal-probe.prg is unexpectedly short" }
  27. if ($bytes[0] -ne 0x01 -or $bytes[1] -ne 0x1C) {
  28. throw "kernal-probe.prg load address is not `$1C01"
  29. }
  30. $expectedHeader = [byte[]](0x0B,0x1C,0x0A,0x00,0x9E,0x37,0x31,0x38,0x31,0x00,0x00,0x00)
  31. for ($i = 0; $i -lt $expectedHeader.Length; $i++) {
  32. if ($bytes[$i + 2] -ne $expectedHeader[$i]) {
  33. throw ("BASIC header differs at file offset {0}" -f ($i + 2))
  34. }
  35. }
  36. # The last loaded byte must remain below $2000, the end of the selected 8K
  37. # bottom-common window. File bytes after the two-byte load address begin $1C01.
  38. $lastAddress = 0x1C01 + ($bytes.Length - 2) - 1
  39. if ($lastAddress -ge 0x2000) {
  40. throw ("probe ends at `${0:X4}, outside bottom common RAM" -f $lastAddress)
  41. }
  42. $labelText = Get-Content -Raw -LiteralPath $labels
  43. foreach ($name in @(
  44. 'kprobe_entry','kprobe_done','kprobe_result','kprobe_complete',
  45. 'kprobe_state_result','kprobe_fail_a','kprobe_fail_p','kprobe_fail_st',
  46. 'kprobe_status_buf','kprobe_code_end','kcall')) {
  47. if ($labelText -notmatch ("(?im)^al\s+[0-9a-f]+\s+\." + [regex]::Escape($name) + "\s*$")) {
  48. throw "missing exported linker label $name"
  49. }
  50. }
  51. # The drive-8 success path needs a real disk: a fresh D64 holding only the
  52. # probe, so autostart loads it through true drive emulation.
  53. $c1541 = "C:\Program Files\GTK3VICE-3.10-win64\bin\c1541.exe"
  54. if (-not (Test-Path -LiteralPath $c1541)) { throw "c1541.exe not found at $c1541" }
  55. $disk = Join-Path $build "kernal-probe.d64"
  56. if (Test-Path -LiteralPath $disk) { Remove-Item -LiteralPath $disk -Force }
  57. & $c1541 -format "kprobe,kp" d64 $disk -write $program "kernal-probe" | Out-Null
  58. if ($LASTEXITCODE -ne 0 -or -not (Test-Path -LiteralPath $disk)) {
  59. throw "c1541 could not create $disk"
  60. }
  61. Write-Host ("built {0} ({1} bytes, ends `${2:X4})" -f $program, $bytes.Length, $lastAddress)
  62. Write-Host ("disk {0}" -f $disk)
  63. Write-Host ("map {0}" -f $map)
  64. Write-Host ("labels {0}" -f $labels)

Powered by TurnKey Linux.