Publish VCC Plus OSS source distribution for 3.6.2 build 60

This commit is contained in:
Brian Holman committed 2026-11-13 00:14:03 -07:00
commit c652a5276d
1192 files changed
+272368

No files matched your search

+432
View File
@@ -0,0 +1,432 @@
// SPDX-License-Identifier: GPL-3.0-or-later
import SwiftUI
import AppKit
import Combine
extension MachineModel {
var executionDescription: String {
state == .running ? (settings.fastForward ? "Fast-forward · Sound silenced" : "Running") : state == .paused ? "Paused" : state == .closed ? "Stopped" : "Ready"
}
var tapeTransportDescription: String {
if tapeMode == 2 { return tapeMotor ? "Recording — export to save" : "Recording ready — waiting for the computer" }
if tapeMode == 1 { return tapeMotor ? "Playing" : "Ready — waiting for the computer" }
return tapeMounted ? "Tape stopped" : "No tape inserted"
}
var needsMediaAttention: Bool {
mediaNeedsManualSave || !cartridgeRestoreErrors.isEmpty || !diskRestoreErrors.isEmpty || !diskSaveErrors.isEmpty ||
!hardRestoreErrors.isEmpty || !hardSaveErrors.isEmpty || diskSettingsError != nil
}
func requestColdReset() {
let alert = NSAlert(); alert.messageText = "Cold restart the CoCo?"
alert.informativeText = "This clears RAM and your working program. Mounted media and their changes are retained."
alert.addButton(withTitle: "Cancel"); alert.addButton(withTitle: "Cold Restart")
if alert.runModal() == .alertSecondButtonReturn { reset() }
}
func requestOrchestraWithoutROM(_ slot: Int) {
guard !busy, !diskSaving, (0..<5).contains(slot) else { return }
let alert = NSAlert(); alert.messageText = "Remove the Orchestra-90 ROM and restart?"
alert.informativeText = "This clears the working program in RAM. Orchestra-90 stays connected for stereo playback by supporting software. The ROM file and mounted disks are kept."
alert.addButton(withTitle: "Cancel"); alert.addButton(withTitle: "Remove ROM and Restart")
if alert.runModal() == .alertSecondButtonReturn { assignCartridge(.orchestra90, slot: slot, useBundledROM: false) }
}
func requestCartridge(_ kind: CartridgeAssignments.Kind, slot: Int) {
let old = cartridgeAssignments.slots[slot]
guard old.kind != kind else { return }
let alert = NSAlert(); alert.messageText = "Change \(slot == 0 ? "the cartridge" : "slot \(slot)") and restart?"
alert.informativeText = "This clears the working program in RAM. \(old.kind == .empty ? "" : "The current slot assignment will be replaced. ")A controller already in another Multi-Pak slot moves here. Mounted disks and their changes are retained."
if old.kind == .ramDisk {
alert.informativeText += " RAM disk data is volatile and is lost when its last assignment is removed."
}
alert.addButton(withTitle: "Cancel"); alert.addButton(withTitle: "Change and Restart")
if alert.runModal() == .alertSecondButtonReturn { assignCartridge(kind, slot: slot) }
}
}
struct MachineView: View {
@Environment(\.openWindow) private var openWindow
@ObservedObject var machine: MachineModel
@ObservedObject var presentation: PresentationSettings
let showManualHome: () -> Void
@State private var help = false
@FocusState private var controlsFocused: Bool
private let refresh = Timer.publish(every: 1.0 / 30, on: .main, in: .common).autoconnect()
private var system: Bool { presentation.mode == .system && !machine.hardware.custom }
var body: some View {
VStack(spacing: 12) {
HStack {
Button { openWindow(id: "machine-settings") } label: {
HardwareBadge(name: "coco-" + HardwareState.ramKeys[machine.settings.ram], label: "Color Computer 3, \(MachineSettings.memoryLabels[machine.settings.ram])")
.frame(maxWidth: 440, maxHeight: 42)
}.buttonStyle(.plain).help("Open Machine Settings for processor and memory")
Spacer(minLength: 24)
Button { openWindow(id: "machine-settings") } label: {
HardwareBadge(name: machine.use6309 ? "hitachi" : "motorola", label: machine.use6309 ? "Hitachi 6309" : "Motorola 6809").frame(width: 44, height: 44)
}.buttonStyle(.plain).help("Open Machine Settings for processor and memory")
}
Divider()
toolbar
if presentation.mode == .system && machine.hardware.custom {
HStack {
Label("Custom configuration", systemImage: "info.circle").fontWeight(.medium)
Text("This hardware layout uses conventional controls; your setup is unchanged.").foregroundStyle(.secondary)
Spacer()
Button("Cartridges…") { openWindow(id: "cartridges") }
}.font(.callout)
}
MachineStage(machine: machine, presentation: presentation, system: system) {
showManualHome()
openWindow(id: "manual-library")
}
.frame(maxWidth: .infinity, maxHeight: .infinity)
.background(system ? Color(red: 0.945, green: 0.933, blue: 0.904) : Color(red: 0.10, green: 0.14, blue: 0.12))
.clipShape(RoundedRectangle(cornerRadius: 8))
.modifier(MediaDropTarget(machine: machine))
status
if let error = machine.displayError ?? machine.fileError ?? machine.error ?? machine.profileError {
Text(error).foregroundStyle(.red).textSelection(.enabled).frame(maxWidth: .infinity, alignment: .leading)
.lineLimit(3).help(error)
}
if machine.needsMediaAttention {
HStack {
Label(machine.tapeDirty || machine.tapeMode == 2 ? "Tape recording needs export" : "Media needs attention", systemImage: "exclamationmark.circle")
.foregroundStyle(.orange)
Button("Cassette…") { openWindow(id: "cassette") }
Button("Floppies…") { openWindow(id: "disks") }
Button("Hard Disks…") { openWindow(id: "hard-disks") }
Button("Cartridges…") { openWindow(id: "cartridges") }
Spacer()
}.font(.callout)
}
}.padding(20).frame(minWidth: 940, minHeight: 590)
.task(id: machine.guideRequest) {
guard let request = machine.guideRequest,
presentation.shouldIntroduce(request.profile) else { return }
// Bring the existing emulator forward after a successful profile load.
// Allow its window and popover anchor to attach before presenting help.
openWindow(id: "machine")
do { try await Task.sleep(for: .milliseconds(300)) } catch { return }
guard !machine.busy, machine.guideRequest == request,
machine.usageProfile == request.profile else { return }
help = true
}
.onChange(of: presentation.controlsFocusRequest) { _, _ in controlsFocused = true }
.background(MacShellPermissionPresenter(machine: machine).frame(width: 0, height: 0).accessibilityHidden(true))
.onReceive(refresh) { _ in machine.poll() }
.onReceive(NSWorkspace.shared.notificationCenter.publisher(for: NSWorkspace.willSleepNotification)) { _ in machine.pause() }
// Changing presentation never invokes pause, reset, reload or a media command.
}
private var toolbar: some View {
HStack(spacing: 10) {
Button { openWindow(id: "profiles") } label: {
Label(machine.profileName.map { $0 + (machine.profileModified ? " • Modified" : "") } ?? "Profiles", systemImage: "circle.grid.2x2")
.lineLimit(1).frame(maxWidth: 170, alignment: .leading)
}.focusable().focused($controlsFocused).accessibilityIdentifier("profiles-button")
.onKeyPress(.space) { openWindow(id: "profiles"); return .handled }
.help("Review and load saved setups. A profile saves settings, not the running program.")
Button {
if machine.state == .running { machine.pause() } else { machine.resume() }
} label: { Label(machine.state == .running ? "Pause" : "Run", systemImage: machine.state == .running ? "pause.fill" : "play.fill") }
.buttonStyle(.borderedProminent).disabled(machine.busy || machine.diskEditorLocked || machine.state == .empty || machine.state == .closed)
.accessibilityIdentifier("execution")
MachineRestartMenu(machine: machine).equatable()
MediaActionsMenu()
MachineSettingsMenu(machine: machine).equatable()
Spacer(minLength: 0)
Picker("Presentation", selection: $presentation.mode) {
Label("Display", systemImage: "display").tag(PresentationSettings.Mode.display)
Label("System", systemImage: "shippingbox").tag(PresentationSettings.Mode.system)
}.pickerStyle(.segmented).labelsHidden().frame(width: 194).accessibilityIdentifier("presentation")
.help("Change the presentation without changing the running machine")
}.controlSize(.large)
}
private var status: some View {
HStack(spacing: 12) {
if machine.pasteRemaining > 0 {
Button("Cancel Paste (\(machine.pasteRemaining) left)") { machine.cancelPaste() }
.monospacedDigit().frame(width: 210, alignment: .leading)
.help("Stop typing. Text already entered in the CoCo is retained.")
}
Label(machine.executionDescription, systemImage: machine.state == .running ? "play.circle.fill" : "pause.circle")
.foregroundStyle(.secondary).fixedSize()
Divider().frame(height: 18)
ScrollView(.horizontal) {
HStack(spacing: 16) {
ForEach(Array(machine.disks.enumerated()), id: \.offset) { i, disk in
if disk.mounted { Button("FD\(i) \(disk.name)") { openWindow(id: "disks") }.help(disk.name) }
}
ForEach(Array(machine.hardDisks.enumerated()), id: \.offset) { i, disk in
if disk.mounted { Button("HD\(i) \(disk.name)") { openWindow(id: "hard-disks") }.help(disk.name) }
}
if machine.tapeMounted {
Button("Tape \(machine.tapeName)\(machine.tapeDirty || machine.tapeMode == 2 ? " — Unsaved" : "")") { openWindow(id: "cassette") }
.help(machine.tapeTransportDescription)
}
}.buttonStyle(.link).lineLimit(1)
}.scrollIndicators(.hidden)
if system {
Button { presentation.expanded.toggle() } label: {
Label(presentation.expanded ? "Return to system" : "Expand monitor", systemImage: presentation.expanded ? "arrow.down.right.and.arrow.up.left" : "arrow.up.left.and.arrow.down.right")
}.accessibilityIdentifier("expand-monitor").fixedSize()
}
Button { help.toggle() } label: { Image(systemName: "info.circle") }.help("Show the guide for this CoCo setup").accessibilityLabel("Using the CoCo")
.popover(isPresented: $help) {
CoCoUsageHelp(profile: machine.usageProfile,
floppyMounted: machine.disks.contains { $0.mounted },
hardMounted: machine.hardDiskConnected && machine.hardDisks.first?.mounted == true,
tapeMounted: machine.tapeMounted).equatable()
.onAppear {
if let profile = machine.usageProfile { presentation.didShowGuide(profile) }
}
.onChange(of: machine.usageProfile) { _, profile in
if let profile { presentation.didShowGuide(profile) }
}
}
}.font(.callout)
}
}
struct MediaActionsMenu: View {
@Environment(\.openWindow) private var openWindow
var body: some View {
Menu {
Button { openWindow(id: "software-library") } label: { Label("Software Library…", systemImage: "books.vertical") }
Divider()
Button("Floppy Disks…") { openWindow(id: "disks") }
Button("Virtual Hard Disks…") { openWindow(id: "hard-disks") }
Button("Cassette…") { openWindow(id: "cassette") }
Button("Printer Output…") { openWindow(id: "printer") }
Button("Cartridges…") { openWindow(id: "cartridges") }
} label: { Label("Media", systemImage: "externaldrive") }.fixedSize()
}
}
// Polling redraws the enclosing MachineView. These explicit equality boundaries
// keep tracking native menus intact; their own deduplicated observation still
// updates genuine command state (including changes made from the menu bar).
struct MachineSettingsMenu: View, Equatable {
let machine: MachineModel
@ObservedObject private var menu: MachineMenuState
@Environment(\.openWindow) private var openWindow
init(machine: MachineModel) { self.machine = machine; self.menu = machine.menuState }
static func == (lhs: Self, rhs: Self) -> Bool { lhs.machine === rhs.machine }
var body: some View {
Menu {
Button("Machine Settings…") { openWindow(id: "machine-settings") }
Button("Display Settings…") { openWindow(id: "display-settings") }
Button("Cartridges and Multi-Pak…") { openWindow(id: "cartridges") }
Button("Keyboard and Joysticks…") { openWindow(id: "input") }
Divider()
Picker("Video Signal", selection: Binding(get: { menu.values.videoOutput }, set: machine.setVideoOutput)) {
ForEach(DisplayOutput.allCases, id: \.rawValue) { Text($0.label).tag($0) }
}
Toggle("Sound", isOn: Binding(get: { menu.values.audioEnabled }, set: machine.setAudio))
Button("Sound and Cassette…") { openWindow(id: "cassette") }
Divider()
Button("Open System ROM…", action: machine.openROM)
if machine.hasBundledROMs {
Button("Restore App Defaults…") { machine.confirmRestoreAppDefaults() }
Divider()
Button("Restore Bundled System ROM…") { machine.restoreBundledROM(system: true) }
Button("Restore Bundled Disk ROM…") { machine.restoreBundledROM(system: false) }
}
Button("Load Binary…", action: machine.openBinary).disabled(!menu.values.canQuickLoad)
Button("Run Diagnostic", action: machine.loadDiagnostic)
} label: { Label("Settings", systemImage: "slider.horizontal.3") }
.fixedSize().disabled(menu.values.busy)
}
}
struct MachineRestartMenu: View, Equatable {
let machine: MachineModel
@ObservedObject private var menu: MachineMenuState
init(machine: MachineModel) { self.machine = machine; self.menu = machine.menuState }
static func == (lhs: Self, rhs: Self) -> Bool { lhs.machine === rhs.machine }
var body: some View {
Menu {
Button("Soft Reset — Retain RAM", action: machine.softReset)
Button("Cold Restart — Clear RAM…", action: machine.requestColdReset)
} label: { Label("Restart", systemImage: "arrow.counterclockwise") }
.disabled(menu.values.busy || menu.values.state == .empty || menu.values.state == .closed).fixedSize()
}
}
// Value-only content keeps the open help stable during frame/activity refreshes.
private struct CoCoUsageHelp: View, Equatable {
let profile: SystemProfile?
let floppyMounted: Bool
let hardMounted: Bool
let tapeMounted: Bool
var body: some View {
ScrollView {
VStack(alignment: .leading, spacing: 12) {
Label("Using your CoCo", systemImage: "book.closed").font(.headline)
if let profile { Text(profile.name).font(.subheadline.bold()) }
Text("Click the live display to type. Escape is Break; Home is Clear.")
if profile == .cocoSDC {
SDCUsageGuide()
} else if profile == .nitros9 {
Nitros9UsageGuide()
} else if profile == .hardDriveBasic {
if hardMounted {
instruction("Hard disk", "DIR 0", "Lists virtual volume 0 on HD0. RGBDOS selects hard-disk volumes at startup.")
} else {
Text("No image is mounted in HD0. Open Media → Virtual Hard Disks to insert one, or use the floppies below.")
}
instruction("Floppy drives", "DRIVE OFF\nDIR 0", "Lists FD0. Use DIR 1, DIR 2 or DIR 3 for the other floppies. OFF changes the drive mapping; it does not eject your images.")
instruction("Return to the hard disk", "DRIVE ON\nDIR 0", "Returns drive numbers to the hard disk's virtual volumes.")
} else if profile == .diskBasic {
instruction("Floppy drives", "DIR 0", "Lists FD0. Use DIR 1, DIR 2 or DIR 3 for the other floppies.")
} else {
Text("This is a custom setup. Disk and boot commands depend on its ROM and software; follow their instructions.")
}
if profile != nil && profile != .nitros9 && (floppyMounted || (profile == .hardDriveBasic && hardMounted)) {
instruction("Hello World example", "LOAD \"HELLO:0\"\nRUN", "On fresh starter media, HELLO asks where you live. Press 1 for Earth or 2 for Mars.")
}
if tapeMounted {
instruction("Cassette in BASIC", "CLOAD \"HELLO\"\nRUN", "For the starter tape, open Media → Cassette and press Play first.")
}
Text("Save disk programs or record and export a tape to keep your work. Profiles save settings and file locations, not the running program.")
.font(.caption).foregroundStyle(.secondary)
}.frame(maxWidth: .infinity, alignment: .leading).padding(20)
}.frame(width: 420).frame(maxHeight: 580)
.background(Color(nsColor: .windowBackgroundColor))
}
private func instruction(_ title: String, _ commands: String, _ explanation: String) -> some View {
VStack(alignment: .leading, spacing: 4) {
Text(title).font(.subheadline.bold())
Text(commands).font(.system(.callout, design: .monospaced)).textSelection(.enabled)
Text(explanation).font(.callout).foregroundStyle(.secondary)
}
}
}
// Shared by the system-profile details and live help; the archive remains a
// private input, and links provide the full catalogue without copying it.
struct Nitros9UsageGuide: View {
var body: some View {
VStack(alignment: .leading, spacing: 12) {
Text("Getting around OS-9").font(.headline)
Text("Loading this profile automatically types DOS 255 at the RGBDOS prompt. Wait for the OS-9 shell prompt before typing. These are OS-9 commands, not BASIC commands.").font(.callout)
section("System disk · HD0", "dir /dd\ndir /dd/games\ndir /dd/apps", "The boot disk is /dd, also accessible as /h0. Use chd to change your working directory; chx changes where commands are found.")
section("Shared data disk · HD1", "dir /h1\nchd /h1\necho Hello from OS-9 >hello\nlist hello", "This is the OS-9 area of your Hard Drive BASIC disk. Its BASIC volumes are separate; the existing HELLO program is preserved. Return with chd /dd.")
section("Explore files", "dir /dd/sources\ndir /dd/grfx\ndir /dd/sound\nlist /dd/docs.txt", "dir lists files; list reads text. The archive includes software, source, pictures and sound. Programs may have their own startup instructions.")
section("Command help", "help\nhelp dir", "Use the installed help and the archive notes for more detail.")
section("Return to BASIC", "DOS 255", "Choose Restart → Cold Restart — Clear RAM…, then select 6 (EXIT TO BASIC) and press Return at the archive menu. At BASIC, type DOS 255 to boot OS-9 again. In BASIC, DIR 1 lists archive volume 1; DRIVE OFF switches drive numbers 0–3 to the floppies, and DRIVE ON restores hard-disk mapping.")
DriveWireNetworkingHelp()
Text("The archive also describes DriveWire disks, MIDI and Glenside IDE hardware. VCC Plus uses its native virtual hard disks for this profile.")
.font(.caption).foregroundStyle(.secondary)
Link("Archive contents and original notes", destination: URL(string: "https://colorcomputerarchive.com/repo/Virtual%20Hard%20Drives/NitrOS-9%20L2%20V3.3.0/Virtual%20Hard%20Drive.txt")!)
}
}
private func section(_ title: String, _ command: String, _ detail: String) -> some View {
VStack(alignment: .leading, spacing: 4) {
Text(title).font(.subheadline.bold())
Text(command).font(.system(.callout, design: .monospaced)).textSelection(.enabled)
Text(detail).font(.callout).foregroundStyle(.secondary)
}
}
}
struct DriveWireNetworkingHelp: View {
var body: some View {
SecondaryHelp(title: "Connect from NitrOS-9") {
Text("A fresh NitrOS-9 system disk loads its networking drivers at boot. At the OS-9 shell, enter the host name and port of your TCP service or BBS.")
Text("telnet HOST PORT")
.font(.system(.callout, design: .monospaced)).textSelection(.enabled)
.accessibilityIdentifier("drivewire-guest-commands")
Text("Use 127.0.0.1 for a service running on this Mac. If you turned networking off, you can enable it again in Machine Settings.")
Text("For your Mac’s own command line, enter telnet macshell 2323 and respond to the permission request in VCC Plus. Type exit to return to OS-9.")
Text("Use clear to clear the CoCo screen. Hold Option while pressing an arrow key to move. In vi, press i to insert and Escape to finish inserting.")
Text("Using an older system disk? In Configuration Profiles, select NitrOS-9 and choose Create Fresh Starter Media… for a separate disk with the drivers installed. To keep using the older disk, load its bundled drivers using the instructions below.")
SecondaryHelp(title: "Load drivers on an older disk") {
Text("Use an unused filename for the combined drivers. Create the file once, then load it after each boot.")
Text("""
chd /dd/boot_with_beckerdw
merge dwio scdwv n n1 >/dd/dwnet
attr /dd/dwnet e
chd /dd
load /dd/dwnet
""").font(.system(.caption, design: .monospaced)).textSelection(.enabled)
}
}
}
}
// Shared by system-profile details and firmware-aware live help.
struct SDCUsageGuide: View {
var body: some View {
VStack(alignment: .leading, spacing: 12) {
Text("Your SD card is a local Mac folder. On first use, the CoCo SDC system profile supplies a writable copy of HELLO.DSK and a startup.cfg that mounts it in drive 0. Your changes are kept when you reload the profile.")
Text("List and run the supplied example").font(.subheadline.bold())
Text("DIR 0\nLOAD \"HELLO:0\"\nRUN").font(.system(.callout, design: .monospaced)).textSelection(.enabled)
Text("DIR lists files on the mounted disk. On a fresh card, HELLO asks you to press 1 for Earth or 2 for Mars.")
Text("Mount the starter disk again").font(.subheadline.bold())
Text("DRIVE 0,\"/HELLO.DSK\"").font(.system(.callout, design: .monospaced)).textSelection(.enabled)
Text("Use this if another image is mounted. The leading / starts at your SD card folder's root. To mount another image, use its path instead.")
Text("Find your files on the Mac").font(.subheadline.bold())
Text("Click the SDC cartridge or open Cartridge → Cartridges, then Show SD Card Folder in Finder. You can add extracted disk images there. The app keeps the bundled original; saves go directly to your local copy. Finish disk operations before changing files in Finder.")
Text("startup.cfg controls startup mounts. Changes to that file are preserved. Fresh Media Copy creates a separate clean card. This guide applies to the supplied SDC-DOS ROM; your chosen card may contain different files.").font(.caption).foregroundStyle(.secondary)
}
}
}
// A guest cannot bring the app or a window to the front. The prompt waits for
// an active emulator/settings window and yields to existing sheets and panels.
struct MacShellPermissionPresenter: NSViewRepresentable {
@ObservedObject var machine: MachineModel
func makeCoordinator() -> Presenter { Presenter() }
func makeNSView(context: Context) -> NSView {
let anchor = NSView()
anchor.setAccessibilityElement(false)
return anchor
}
func updateNSView(_ anchor: NSView, context: Context) {
let presenter = context.coordinator
DispatchQueue.main.async { [weak anchor] in presenter.update(in: anchor?.window, machine: machine) }
}
static func dismantleNSView(_ anchor: NSView, coordinator: Presenter) { coordinator.dismiss() }
@MainActor final class Presenter {
private var alert: NSAlert?
private var presented: MachineModel.MacShellRequest?
func dismiss() {
presented = nil
guard let alert else { return }
self.alert = nil
alert.window.sheetParent?.endSheet(alert.window, returnCode: .abort)
}
func update(in owner: NSWindow?, machine: MachineModel) {
let request = machine.macShellRequest
if alert != nil {
if presented != request { dismiss() }
return
}
guard let request, let owner, NSApp.isActive, owner.isKeyWindow, owner.isVisible,
!owner.isMiniaturized, owner.attachedSheet == nil, NSApp.modalWindow == nil,
!(NSApp.keyWindow is NSPanel) else { return }
let alert = NSAlert()
alert.alertStyle = .warning
alert.messageText = "Allow this CoCo program to use your Mac shell?"
alert.informativeText = "The guest requested macshell. It can run commands as your Mac user, starting in your home folder, and read or change files your account and VCC Plus can access."
alert.addButton(withTitle: "Deny").keyEquivalent = "\r"
alert.addButton(withTitle: "Allow")
if request.disk != nil {
alert.showsSuppressionButton = true
alert.suppressionButton?.title = "Remember for any program running with this NitrOS-9 setup"
alert.suppressionButton?.state = .off
}
self.alert = alert
presented = request
alert.beginSheetModal(for: owner) { [weak self, weak machine, weak alert] result in
guard let self, let machine, let alert, self.alert === alert else { return }
self.alert = nil; self.presented = nil
machine.decideMacShell(request, allow: result == .alertSecondButtonReturn,
remember: alert.suppressionButton?.state == .on)
}
}
}
}