Sync source edition with VCC Plus 3.7.0 build 63

This commit is contained in:
Brian Holman committed 2026-11-14 01:43:46 -07:00
1 parent c652a5276d
commit b2ecec4d87
86 files changed
+10519 -472

No files matched your search

@@ -354,6 +354,60 @@ final class CartridgePersistenceTests: XCTestCase {
XCTAssertFalse(model.disks[0].dirty); XCTAssertTrue(model.diskConnected)
}
}
@MainActor func testMediaCommandsRecheckActiveTransferWithoutChangingDisksOnBothCPUs() async throws {
// The native controls remain available during guest I/O. Their safety
// must come from the worker's current state, not a stale UI snapshot.
for use6309 in [false, true] {
let controller = VCCMachineController()
func step(_ action: (@escaping @Sendable (VCCMachineSnapshot) -> Void) -> Void) async -> VCCMachineSnapshot {
await withCheckedContinuation { c in action { c.resume(returning: $0) } }
}
let original = Data(repeating: 0, count: 161280)
_ = await step { controller.loadDiskROM(Data(repeating: 0, count: 8192), name: "Original ROM", completion: $0) }
_ = await step { controller.mountDisk(original, drive: 0, name: "Original.dsk", readOnly: false, completion: $0) }
var system = Data(repeating: 0, count: 32768)
// Begin a write, then leave its sector data transfer incomplete.
let code: [UInt8] = [0x86,0x29,0xb7,0xff,0x40,0x86,1,0xb7,0xff,0x4a,0x86,0xa0,0xb7,0xff,0x48,0x20,0xfe]
system.replaceSubrange(0..<code.count, with: code); system[32766] = 0x80
_ = await step { controller.loadROM(system, use6309: use6309, completion: $0) }
_ = await step(controller.resume)
var snapshot = await step(controller.snapshot)
for _ in 0..<100 where !snapshot.diskBusy {
try await Task.sleep(nanoseconds: 1_000_000)
snapshot = await step(controller.snapshot)
}
XCTAssertTrue(snapshot.diskBusy, "CPU \(use6309 ? "6309" : "6809") must reach a real transfer")
_ = await step(controller.pause)
let operations: [(@escaping @Sendable (VCCMachineSnapshot) -> Void) -> Void] = [
controller.pauseForDiskChange,
{ controller.mountDisk(Data(repeating: 0xe5, count: 161280), drive: 0, name: "Replacement.dsk", readOnly: false, completion: $0) },
{ controller.createDisk(inDrive: 0, format: .standard, completion: $0) },
{ controller.ejectDisk(inDrive: 0, discard: false, completion: $0) },
{ controller.setDiskWriteProtected(true, drive: 0, completion: $0) },
{ controller.loadDiskROM(Data(repeating: 0x12, count: 8192), name: "Replacement ROM", completion: $0) },
controller.disableDisks,
]
for operation in operations {
snapshot = await step(operation)
XCTAssertNotNil(snapshot.errorMessage)
XCTAssertTrue(snapshot.diskBusy)
XCTAssertTrue(snapshot.disks[0].mounted)
XCTAssertEqual(snapshot.disks[0].name, "Original.dsk")
XCTAssertFalse(snapshot.disks[0].writeProtected)
XCTAssertEqual(snapshot.diskROMName, "Original ROM")
}
_ = await step(controller.reset)
let (bytes, _, exported): (Data?, UInt64, VCCMachineSnapshot) = await withCheckedContinuation { done in
controller.exportDisk(inDrive: 0) { done.resume(returning: ($0, $1, $2)) }
}
XCTAssertNil(exported.errorMessage)
XCTAssertEqual(bytes, original, "Rejected actions must retain the original bytes")
snapshot = await step { controller.ejectDisk(inDrive: 0, discard: false, completion: $0) }
XCTAssertNil(snapshot.errorMessage)
XCTAssertFalse(snapshot.disks[0].mounted, "Ejection works once the controller is idle")
_ = await step(controller.shutdown)
}
}
@MainActor func testBridgeRejectsInvalidAndBusyLayoutsWithoutReplacingSlots() async throws {
let controller = VCCMachineController()
func step(_ action: (@escaping @Sendable (VCCMachineSnapshot) -> Void) -> Void) async -> VCCMachineSnapshot {