|
- <#
- .SYNOPSIS
- Build a target and start it in VICE for interactive testing.
-
- .DESCRIPTION
- Starts the emulator listed for the target in project.json with the target's display and
- video options, attaches the disk image when there is one, and autostarts the program.
- VICE uses your normal VICE settings here (unlike tools/smoke.ps1).
-
- .EXAMPLE
- pwsh -File tools/run.ps1
- pwsh -File tools/run.ps1 -Target c128-80
- pwsh -File tools/run.ps1 -Target c64 -TimingBar
- .PARAMETER TimingBar
- Build with the assembler symbol TIMING_BAR into a separate program (<name>-timing.prg) whose border colour
- shows the CPU's work in each frame (see src/main.s). The normal build is not touched.
- #>
- [CmdletBinding()]
- param(
- [string]$Target,
- [switch]$NoBuild,
- [ValidateSet('pal', 'ntsc')][string]$Video,
- [switch]$TimingBar
- )
- . (Join-Path $PSScriptRoot 'lib.ps1')
-
- try {
- $project = Get-ProjectConfig
- $t = if ($Target) { Get-ProjectTargets $project $Target } else { @($project.resolved.targets)[0] }
- if ($TimingBar) {
- if ($t.build.kind -ne 'cc65') { throw "-TimingBar needs a cc65 target." }
- $t.build.asmDefines = @(@($t.build.asmDefines) + 'TIMING_BAR' | Where-Object { $_ })
- foreach ($k in 'labels', 'map') { $t.build[$k] = $t.build[$k] -replace '(\.\w+)$', '-timing$1' }
- $t.artifact = $t.artifact -replace '(\.\w+)$', '-timing$1'
- $t.disk = $null
- }
- if (-not $NoBuild) { Invoke-TargetBuild $project $t @{} }
- if ($t.build.kind -eq 'none' -and -not $t.disk) { throw "Target $($t.id) is built on the Commodore; follow docs/toolchain.md to load it." }
- $emu = Get-ToolPath $project $t.emulator.binary
- if ($Video) { $t.video = $Video }
- $vargs = @(Get-VideoArgs $t) + @($t.emulator.args)
- if ($t.emulator.autostart -ne 'disk' -and $t.disk) { $vargs += @('-8', (Get-RepoPath $t.disk.image)) }
- $vargs += @('-autostart', (Get-AutostartFile $t))
- $quoted = $vargs | ForEach-Object { if ($_ -match '\s') { '"' + $_ + '"' } else { $_ } }
- Write-Host "[$($t.id)] starting $($t.emulator.binary) $($quoted -join ' ')"
- Start-Process -FilePath $emu -ArgumentList $quoted | Out-Null
- Write-Host "Expected: $($t.expectedBehavior)"
- } catch [MissingToolException] {
- Write-Host $_.Exception.Message -ForegroundColor Yellow
- exit 2
- } catch {
- Write-Host "RUN FAILED: $($_.Exception.Message)" -ForegroundColor Red
- exit 1
- }
|