|
- <#
- .SYNOPSIS
- Put the current source on a transfer disk image for the Commodore (on-Commodore workflow).
-
- .DESCRIPTION
- The Git repository stays on this Windows host. This script prepares the disk image you
- attach in VICE (File > Attach disk image > drive 8) or copy to a real disk/SD card:
- - BASIC projects: tokenizes src/main.bas with petcat and writes the PRG to the image.
- - Other projects: copies the files listed in project.json (resolved.onCommodore.files).
- Then, on the Commodore: LOAD"<name>",8 and RUN (or load it into your native tool).
-
- .EXAMPLE
- pwsh -File tools/to-commodore.ps1
- #>
- [CmdletBinding()]
- param()
- . (Join-Path $PSScriptRoot 'lib.ps1')
-
- try {
- $project = Get-ProjectConfig
- $oc = $project.resolved.onCommodore
- if (-not $oc) { throw 'This project does not use the on-Commodore workflow.' }
- $c1541 = Get-ToolPath $project 'c1541'
- $image = Get-RepoPath $oc.image
- $stage = Split-Path $image -Parent
- New-Item -ItemType Directory -Force -Path $stage | Out-Null
- $files = @()
- if ($oc.kind -eq 'basic') {
- $petcat = Get-ToolPath $project 'petcat'
- $prg = Join-Path $stage "$($oc.programName).prg"
- Invoke-Tool $petcat @("-w$($oc.dialect)", '-f', '-o', $prg, '--', (Get-RepoPath $oc.source))
- $files += @{ path = $prg; dest = $oc.programName }
- }
- foreach ($f in @($oc.files)) {
- if (-not $f) { continue }
- $src = Get-RepoPath $f.source
- if ($f.convert -eq 'ascii-to-petscii') {
- $conv = Join-Path $stage ($f.name + '.petscii')
- [IO.File]::WriteAllBytes($conv, (ConvertTo-Petscii ([IO.File]::ReadAllBytes($src)) $f.lineEndings))
- $src = $conv
- }
- $files += @{ path = $src; dest = $(if ($f.type -eq 'seq') { "$($f.name),s" } else { $f.name }) }
- }
- if (Test-Path -LiteralPath $image) { Remove-Item -LiteralPath $image }
- $toolArgs = @('-format', $oc.diskName, $oc.diskFormat, $image)
- foreach ($f in $files) { $toolArgs += @('-write', $f.path, $f.dest) }
- $toolArgs += '-list'
- Invoke-Tool $c1541 $toolArgs
- Write-Host ""
- Write-Host "Transfer disk ready: $($oc.image)"
- Write-Host "On the Commodore (or VICE with the image on drive 8): $($oc.loadCommand)"
- } catch [MissingToolException] {
- Write-Host $_.Exception.Message -ForegroundColor Yellow
- exit 2
- } catch {
- Write-Host "FAILED: $($_.Exception.Message)" -ForegroundColor Red
- exit 1
- }
|