Você não pode selecionar mais de 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.

82 linhas
2.2KB

  1. # build-ml.ps1 - assemble vrow.s with cc65 and turn the result into vml.c, the
  2. # Power C unit that holds the machine code as a byte array and calls it.
  3. #
  4. # powershell -NoProfile -File build-ml.ps1
  5. #
  6. # Run it whenever vrow.s changes, then build.ps1 as usual. vml.c is generated:
  7. # edit vrow.s, not vml.c.
  8. $ErrorActionPreference = "Stop"
  9. $here = $PSScriptRoot
  10. $bin = "D:\Development\Commodore\cc65-snapshot-win32\bin"
  11. $ca65 = Join-Path $bin "ca65.exe"
  12. $ld65 = Join-Path $bin "ld65.exe"
  13. $addr = 0xC020 # where the routine lives; the parameter block is at $C000
  14. $cfg = Join-Path $env:TEMP "vrow.cfg"
  15. @"
  16. MEMORY { M: start = `$C020, size = `$0100, file = "%O"; }
  17. SEGMENTS { CODE: load = M, type = ro; }
  18. "@ | Set-Content $cfg -Encoding ascii
  19. $obj = Join-Path $env:TEMP "vrow.o"
  20. $out = Join-Path $here "vrow.bin"
  21. & $ca65 (Join-Path $here "vrow.s") -o $obj
  22. if ($LASTEXITCODE) { throw "ca65 failed" }
  23. & $ld65 -C $cfg -o $out $obj
  24. if ($LASTEXITCODE) { throw "ld65 failed" }
  25. $b = [IO.File]::ReadAllBytes($out)
  26. $rows = @()
  27. for ($i = 0; $i -lt $b.Length; $i += 12) {
  28. $n = [Math]::Min(12, $b.Length - $i)
  29. $rows += " " + (($b[$i..($i + $n - 1)] | ForEach-Object { "$_" }) -join ", ")
  30. }
  31. $arr = $rows -join ",`n"
  32. @"
  33. /* vml.c - GENERATED by build-ml.ps1 from vrow.s. Do not edit by hand.
  34. *
  35. * The machine code row painter, kept as a byte array and called in place
  36. * through sys(). It is position independent; its parameters go through zero
  37. * page scratch `$22-`$28, which Power C leaves to ML routines.
  38. */
  39. char mlcode[$($b.Length)] = {
  40. $arr
  41. };
  42. /* nothing to install: the code runs where the array sits */
  43. mlinit()
  44. {
  45. return 0;
  46. }
  47. /* paint the screen row at address dst: len bytes from src, cursor at column cur
  48. (255 = none), rev = 128 for an all reverse row */
  49. mlrow(src, len, dst, cur, rev)
  50. unsigned src, dst;
  51. int len, cur, rev;
  52. {
  53. char *p;
  54. char a, x, y;
  55. p = (char *) 0x22;
  56. p[0] = src & 255;
  57. p[1] = src >> 8;
  58. p[2] = len;
  59. p[3] = dst & 255;
  60. p[4] = dst >> 8;
  61. p[5] = cur;
  62. p[6] = rev;
  63. a = 0;
  64. x = 0;
  65. y = 0;
  66. sys((unsigned) mlcode, &a, &x, &y); /* c64 form: no bank argument */
  67. return 0;
  68. }
  69. "@ | Set-Content (Join-Path $here "vml.c") -Encoding utf8
  70. Write-Host ("vrow.bin {0} bytes -> vml.c" -f $b.Length)

Powered by TurnKey Linux.