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

+255
View File
@@ -0,0 +1,255 @@
// SPDX-License-Identifier: GPL-3.0-or-later
import SwiftUI
import Combine
struct DiskControlsView: View {
@ObservedObject var machine: MachineModel
@Environment(\.openWindow) private var openWindow
@State private var controllerExpanded = false
private let refresh = Timer.publish(every: 0.1, on: .main, in: .common).autoconnect()
var body: some View {
VStack(spacing: 0) {
HStack {
SecondaryHeader(title: "Floppy Disks", badge: "floppy")
SecondaryAction(title: "Open Disk Image…", systemImage: "folder") { DiskImageEditorCoordinator.shared.open(machine: machine) }
.accessibilityIdentifier("disk-editor-open-image")
}.padding(20)
Divider()
ScrollView {
VStack(alignment: .leading, spacing: 14) {
connection
if machine.diskEnabled {
ForEach(Array(machine.disks.enumerated()), id: \.offset) { index, disk in
DiskDriveRow(machine: machine, index: index, disk: disk)
}
}
if !machine.diskRestoreErrors.isEmpty {
ForEach(machine.diskRestoreErrors.keys.sorted(), id: \.self) { key in
Text(machine.diskRestoreErrors[key] ?? "").foregroundStyle(.red).textSelection(.enabled)
}
SecondaryAction(title: "Retry Remembered Disks", systemImage: "arrow.clockwise", action: machine.retryRememberedDisks)
Text("Reconnect the files and retry, or choose replacements. Eject forgets an unavailable drive assignment.")
.font(.caption).foregroundStyle(.secondary)
}
DisclosureGroup(isExpanded: $controllerExpanded) {
controllerDetails.padding(.top, 12)
} label: {
Label("Controller Details", systemImage: "slider.horizontal.3").font(.callout).fontWeight(.medium)
}.accessibilityIdentifier("floppy-controller-details")
SecondaryHelp(title: "About floppy disks") {
Text("The FD-502 opens DSK, JVC, OS-9, DMK and VDK images. Save As preserves the mounted format.")
Text("Writable disks save automatically. Temporary changes stay in memory until Save As. Drive assignments are remembered.")
Text("A new blank disk must be formatted by the CoCo. For a 35-track disk in FD0, type DSKINI0 in BASIC. Then choose Save As to create its Mac file and enable automatic saving.")
Text("Changing media or save mode pauses emulation. Automatic saves keep emulation running.")
}
if let error = machine.diskSettingsError {
Label(error, systemImage: "exclamationmark.circle").foregroundStyle(.red).textSelection(.enabled)
if machine.diskSettingsNeedsSave { SecondaryAction(title: "Retry Saving", systemImage: "arrow.clockwise", action: machine.saveDiskAssignments) }
}
if let error = machine.fileError ?? machine.error { Text(error).foregroundStyle(.red).textSelection(.enabled) }
}.padding(20)
}
Divider()
MediaExecutionFooter(machine: machine, note: "Media changes pause the CoCo; press Run to continue.").padding(20)
}.frame(minWidth: 700, minHeight: 420)
.disabled(machine.busy || machine.diskSaving || machine.diskEditorLocked || machine.state == .closed)
.onReceive(refresh) { _ in machine.poll() }
}
@ViewBuilder private var connection: some View {
if !machine.diskEnabled {
SecondaryCard {
VStack(alignment: .leading, spacing: 10) {
Label("Choose a disk ROM to enable the FD-502 controller", systemImage: "info.circle")
SecondaryAction(title: "Choose Disk ROM…", systemImage: "folder", action: machine.openDiskROM).disabled(machine.diskBusy)
}
}
} else if !machine.diskConnected {
Label("Controller disconnected · Mounted disks are retained", systemImage: "exclamationmark.circle")
.font(.callout).foregroundStyle(.orange)
SecondaryAction(title: "Configure Cartridges…", systemImage: "slider.horizontal.3") { openWindow(id: "cartridges") }
} else {
HStack {
Label("FD-502 connected", systemImage: "cable.connector")
Spacer()
Text(machine.diskSaving ? "Saving automatically…" : "Writable disks save automatically")
}.font(.caption).foregroundStyle(.secondary).frame(minHeight: 18)
}
}
private var controllerDetails: some View {
VStack(alignment: .leading, spacing: 12) {
HStack {
VStack(alignment: .leading, spacing: 3) {
Text("Disk ROM").fontWeight(.medium)
Text(machine.diskEnabled ? machine.diskROMName : "Not selected").lineLimit(1).truncationMode(.middle).foregroundStyle(.secondary)
}
Spacer()
SecondaryAction(title: machine.diskEnabled ? "Change Disk ROM…" : "Choose Disk ROM…", systemImage: "folder", action: machine.openDiskROM)
.disabled(machine.diskBusy)
}
if machine.diskEnabled {
HStack {
Text(machine.diskBusy ? "Disk operation in progress" : "Controller ready")
Text(machine.diskMotor ? "Motor on" : "Motor off")
Spacer()
if machine.diskSelectedDrive >= 0 {
Text("FD\(machine.diskSelectedDrive) · Track \(machine.diskTrack) · Sector \(machine.diskSector)")
.monospacedDigit()
}
}.font(.caption).foregroundStyle(.secondary)
SecondaryAction(title: "Disable Controller…", systemImage: "minus.circle", action: machine.disableDisks)
.disabled(machine.dirtyDisks || machine.diskBusy)
.accessibilityLabel("Disable floppy controller")
Text("Disabling ejects all four disks and cold-restarts the CoCo. Save or discard pending changes first.")
.font(.caption).foregroundStyle(.secondary).fixedSize(horizontal: false, vertical: true)
} else if !machine.diskRestoreErrors.isEmpty {
SecondaryAction(title: "Forget Remembered Setup…", systemImage: "minus.circle", action: machine.forgetUnavailableDisks)
}
}.font(.callout)
}
}
private struct DiskDriveRow: View {
@ObservedObject var machine: MachineModel
let index: Int
let disk: VCCDiskSnapshot
@State private var options = false
private struct CopySource: Identifiable {
let id = UUID()
let name: String
let epoch: UInt64
}
@State private var copySource: CopySource?
private var assigned: Bool { disk.mounted || machine.diskAssignments.drives[index] != nil }
private var manualSave: Bool {
disk.dirty && (machine.diskTemporary[index] || machine.diskAssignments.drives[index] == nil || disk.writeProtected || disk.sourceReadOnly)
}
private var mode: String {
if disk.writeProtected { return "Write protected" }
if machine.diskTemporary[index] { return "Temporary changes" }
return machine.diskAssignments.drives[index] == nil ? "No backing file · Use Save As" : "Saves automatically"
}
var body: some View {
SecondaryCard {
VStack(alignment: .leading, spacing: 12) {
HStack(spacing: 14) {
MediaDriveIdentity(name: "FD\(index)", mounted: disk.mounted)
VStack(alignment: .leading, spacing: 4) {
Text(disk.mounted ? disk.name : machine.diskAssignments.drives[index]?.url.lastPathComponent ?? "No disk inserted")
.fontWeight(.semibold).lineLimit(1).truncationMode(.middle)
Text(disk.mounted ? "\(disk.tracks) tracks · \(disk.sides) \(disk.sides == 1 ? "side" : "sides") · \(mode)" : assigned ? "Unavailable — reconnect or replace the file" : "Insert an image or create a blank disk")
.font(.caption).foregroundStyle(assigned && !disk.mounted ? Color.orange : Color.secondary)
.fixedSize(horizontal: false, vertical: true)
}.frame(maxWidth: .infinity, alignment: .leading)
SecondaryAction(title: assigned ? "Replace…" : "Insert…", systemImage: "folder") { machine.openDisk(index) }
.disabled(disk.dirty).accessibilityLabel("Insert disk in drive \(index)")
if assigned {
if disk.mounted {
SecondaryAction(title: "Edit…", systemImage: "pencil") { DiskImageEditorCoordinator.shared.edit(index, machine: machine) }
.accessibilityIdentifier("floppy-edit-\(index)").accessibilityLabel("Edit…")
.help("Edit files inside the disk. The CoCo stays paused and locked until the editor closes.")
}
SecondaryAction(title: "Eject", systemImage: "eject") { machine.ejectDisk(index) }
.disabled(disk.dirty).accessibilityLabel("Eject disk from drive \(index)")
} else {
newDiskMenu
}
}
if disk.mounted {
HStack {
DisclosureGroup(isExpanded: $options) { EmptyView() } label: { Text("Disk options").font(.callout) }
.accessibilityIdentifier("floppy-options-\(index)")
Spacer()
actions
}
if options {
HStack(spacing: 24) {
Toggle("Write protected", isOn: Binding(get: { disk.writeProtected }, set: { machine.protectDisk(index, $0) }))
.disabled(disk.sourceReadOnly || disk.formatWriteProtected).accessibilityLabel("Write protect drive \(index)")
.help(disk.formatWriteProtected ? "Write protection is stored in the disk image header." : disk.sourceReadOnly ? "The source file is read-only. Reopen a writable copy to enable writes." : "Prevent the CoCo from changing this disk.")
Toggle("Temporary changes", isOn: Binding(get: { machine.diskTemporary[index] }, set: { machine.setDiskTemporary(index, $0) }))
.accessibilityLabel("Temporary changes in drive \(index)")
Spacer(minLength: 0)
}.font(.callout)
Text("Temporary changes stay in memory. Turning this off saves pending changes to the assigned writable file. Save As chooses a file and retains this mode.")
.font(.caption).foregroundStyle(.secondary).fixedSize(horizontal: false, vertical: true)
}
if manualSave {
HStack {
Label("Unsaved changes · Save As to keep them", systemImage: "exclamationmark.circle").foregroundStyle(.orange)
Spacer()
SecondaryAction(title: "Save As…", systemImage: "square.and.arrow.up") { machine.exportDisk(index) }
.accessibilityLabel("Save disk from drive \(index) as")
}.font(.callout).frame(minHeight: 24)
}
}
if let error = machine.diskSaveErrors[index] {
Text(error).font(.callout).foregroundStyle(.red).textSelection(.enabled)
SecondaryAction(title: "Retry Save", systemImage: "arrow.clockwise") { machine.retryDiskSave(index) }
.disabled(machine.diskTemporary[index] || disk.writeProtected).accessibilityLabel("Retry saving drive \(index)")
}
}
}.modifier(MediaDropTarget(machine: machine, destination: .floppy(index)))
.sheet(item: $copySource) { source in
VCCDriveWireTransferView(machine: machine, drive: index, sourceName: source.name, sourceEpoch: source.epoch)
}
.disabled(machine.diskBusy)
}
private var newDiskMenu: some View {
Menu {
Button("Standard DSK") { machine.createDisk(index) }
Button("DMK Track Image") { machine.createDisk(index, format: .trackDMK) }
Button("VDK Disk Image") { machine.createDisk(index, format: .sectorVDK) }
} label: {
Label("New Disk", systemImage: "doc.badge.plus")
}
.fixedSize().disabled(disk.dirty).accessibilityLabel("New disk in drive \(index)")
.accessibilityIdentifier("floppy-new-\(index)")
}
private var actions: some View {
Menu {
Button { machine.exportDisk(index) } label: { Label("Save As…", systemImage: "square.and.arrow.up") }
.disabled(!disk.mounted).accessibilityLabel("Save disk from drive \(index) as")
Button {
copySource = CopySource(name: disk.name, epoch: machine.inputEpoch)
} label: { Label("Send a Copy to DriveWire…", systemImage: "paperplane") }
.disabled(!disk.mounted || machine.busy || machine.diskSaving || machine.diskEditorLocked)
.accessibilityIdentifier("floppy-send-copy-\(index)")
.help("Send an independent copy of the current disk, including changes in memory, to a running DriveWire session.")
newDiskMenu
if manualSave || machine.diskSaveErrors[index] != nil {
Divider()
Button { machine.discardDisk(index) } label: { Label("Discard Changes and Eject…", systemImage: "eject") }
.accessibilityLabel("Discard changes in drive \(index)")
}
} label: { Label("Actions", systemImage: "ellipsis.circle") }
.fixedSize().accessibilityIdentifier("floppy-actions-\(index)")
}
}
// Shared presentation only; drive and execution commands remain in MachineModel.
struct MediaDriveIdentity: View {
let name: String
let mounted: Bool
var body: some View {
Text(name).font(.system(.body, design: .monospaced).weight(.semibold))
.frame(width: 42, height: 42)
.background(mounted ? Color.accentColor.opacity(0.12) : Color.secondary.opacity(0.10), in: RoundedRectangle(cornerRadius: 7))
}
}
struct MediaExecutionFooter: View {
@ObservedObject var machine: MachineModel
let note: String
var body: some View {
HStack(spacing: 12) {
SecondaryAction(title: machine.state == .running ? "Pause" : "Run", systemImage: machine.state == .running ? "pause.fill" : "play.fill") {
if machine.state == .running { machine.pause() } else { machine.resume() }
}.disabled(machine.diskEditorLocked || machine.state == .empty || machine.state == .closed)
Text(note).font(.caption).foregroundStyle(.secondary).fixedSize(horizontal: false, vertical: true)
Spacer(minLength: 0)
Text(machine.executionDescription).font(.caption).foregroundStyle(.secondary)
}
}
}