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.

62 linhas
3.1KB

  1. # pc-compile.ps1 - compile C sources with the ORIGINAL Power C in VICE, on a throwaway
  2. # copy of reference/POWERc.d81 (the original image is never written).
  3. # pc-compile.ps1 -Src a.c,b.c -Out outdir [-Link name] [-Run keys]
  4. # Produces outdir\a.o ... ; with -Link, links all objects (+libs) into outdir\<name>.prg
  5. param([string[]]$Src, [string]$Out, [string]$Link = "", [int]$Delay = 700, [int]$Pad = 20)
  6. $ErrorActionPreference = "Continue"
  7. $vice = "C:\Program Files\GTK3VICE-3.10-win64\bin"
  8. $x64 = Join-Path $vice "x64sc.exe"; $c1541 = Join-Path $vice "c1541.exe"
  9. $Src = @($Src | % { $_ -split "," } | % { (Resolve-Path $_).Path })
  10. New-Item -ItemType Directory -Force -Path $Out | Out-Null
  11. $Out = (Resolve-Path $Out).Path
  12. $here = $PSScriptRoot
  13. $base = Join-Path $here "..\..\POWERc.d81"
  14. $wd = Join-Path $here "..\work"
  15. New-Item -ItemType Directory -Force -Path $wd, $Out | Out-Null
  16. Set-Location $wd
  17. $img = "t.d81"
  18. Copy-Item $base $img -Force
  19. function ConvertTo-Petscii([string]$in, [string]$out) {
  20. $bytes = [IO.File]::ReadAllBytes($in); $o = New-Object System.Collections.Generic.List[byte]
  21. foreach ($b in $bytes) {
  22. if ($b -eq 13) { continue }
  23. if ($b -eq 10) { $o.Add([byte]13); continue }
  24. if ($b -ge 0x61 -and $b -le 0x7A) { $o.Add([byte]($b - 0x20)); continue }
  25. if ($b -ge 0x41 -and $b -le 0x5A) { $o.Add([byte]($b + 0x80)); continue }
  26. if ($b -ge 0x7B -and $b -le 0x7F) { $o.Add([byte]($b + 0x60)); continue }
  27. $o.Add([byte]$b)
  28. }
  29. [IO.File]::WriteAllBytes($out, $o.ToArray())
  30. }
  31. function Quote-Arg([string]$a) {
  32. if ($a -ne "" -and $a -notmatch '[\s"]') { return $a }
  33. $e = $a -replace '(\\*)"', '$1$1\"'; $e = $e -replace '(\\+)$', '$1$1'; return '"' + $e + '"'
  34. }
  35. $kb = ""; $names = @()
  36. foreach ($s in $Src) {
  37. $n = [IO.Path]::GetFileNameWithoutExtension($s); $names += $n
  38. $pet = Join-Path $wd "$n.pet"
  39. ConvertTo-Petscii $s $pet
  40. $null = & $c1541 $img -delete "$n.c" "$n.o" 2>$null
  41. $null = & $c1541 $img -write $pet "$n.c,s" 2>$null
  42. $kb += "cc $n.c\n" + ("\n" * 3) + ("\n" * $Pad)
  43. }
  44. if ($Link -ne "") {
  45. $kb += "link -s\n"
  46. foreach ($n in $names) { $kb += "$n.o\n" }
  47. $kb += "^\n\n$Link\n" + ("\n" * 8)
  48. }
  49. $shot = "last.png"; if (Test-Path $shot) { Remove-Item $shot -Force }
  50. $cycles = [long](($kb.Length * $Delay / 1000.0 + 20) * 13000000); if ($cycles -gt 2000000000) { $cycles = 2000000000 }
  51. $argv = @("-8", $img, "-autostart", "${img}:shell", "-autostart-warp", "-warp", "-sounddev", "dummy",
  52. "-keybuf-delay", "$Delay", "-keybuf", $kb, "-limitcycles", "$cycles", "-exitscreenshot", $shot)
  53. $psi = New-Object System.Diagnostics.ProcessStartInfo
  54. $psi.WorkingDirectory = (Get-Location).Path; $psi.FileName = $x64; $psi.Arguments = ($argv | % { Quote-Arg $_ }) -join ' '; $psi.UseShellExecute = $false
  55. $p = [Diagnostics.Process]::Start($psi); $p.WaitForExit(); Start-Sleep -Milliseconds 900
  56. foreach ($n in $names) {
  57. & $c1541 $img -read "$n.o,s" (Join-Path $Out "$n.o") 2>$null | Out-Null
  58. if (Test-Path (Join-Path $Out "$n.o")) { Write-Host "ok $n.o" } else { Write-Host "FAIL $n.o (see work\last.png)" }
  59. }
  60. if ($Link -ne "") { & $c1541 $img -read $Link (Join-Path $Out "$Link.prg") 2>$null | Out-Null }

Powered by TurnKey Linux.