Something went wrong. Try again.
A cycle-accurate Apple II and Apple IIgs emulator written in Zig, usable as both a program and a library.
Something went wrong. Try again.
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671// SPDX-FileCopyrightText: 2026 Jeffrey C. Ollie <jeff@ocjtech.us>//// SPDX-License-Identifier: MIT
//! The WOZ reference images, read and — if there is a ROM to do it with —//! booted.//!//! The processors have the SingleStepTests corpus (SingleStepTests, n.d.): two//! and a half million recorded cases and a runner that says how many pass. A//! disk drive has nothing so exact, but it has the next best thing. The WOZ//! reference images were compiled by John K. Morris of the Applesauce project//! and published for emulator authors (Morris, 2021), with a readme that orders//! them by what they test: "all of the images here have been tested in multiple//! emulators and are all verified as good images. You can trust them. If they//! don't work for some reason, then it is something about your implementation."//!//! ## Two kinds of checking, because only one of them can run anywhere//!//! Booting a disk needs Apple's own ROMs — the machine's and the Disk II//! card's — and those cannot be fetched: they are Apple's code and this project//! ships none of it. So booting is what happens when `--rom` and `--disk-rom`//! are given, and it is not the default.//!//! What runs everywhere is the part that needs no ROM at all, and it is not a//! lesser test: every image is opened, its CRC checked, its chunks walked, and//! every track it holds is put under a real drive head and read the way the//! machine reads it. That exercises the WOZ reader, the bit-level drive, the//! shifter, self-sync, the quarter-track map and the noise over unrecorded//! surface — everything this project owns. What it cannot do is say whether the//! game starts, and that is what the ROMs are for.
const std = @import("std");const zig65 = @import("zig65");const sequencer = @import("sequencer.zig");
const Machine = zig65.CPU(zig65.clock.FakeClock, zig65.memory.AppleIIe(.{}));
/// How long to give a disk before deciding it is not going to boot.////// Generous: a IIe runs about a million instructions a second, so this is well/// over a minute of machine time, and a disk that has put nothing on the screen/// by then is not about to.const instructions_default = 80_000_000;const between_looks = 20_000;
/// What the set's readme groups the disks into, in its order.const Tier = enum { begin, protection, cross_track, wide_track, half_tracks, soft_switches, fake_bits, latch_lifespan, offset_streams, bit_timing, flux,
fn name(self: Tier) []const u8 { return switch (self) { .begin => "where to begin", .protection => "copy protection", .cross_track => "cross-track synchronisation", .wide_track => "a track two tracks wide", .half_tracks => "half tracks", .soft_switches => "soft-switch trickery", .fake_bits => "fake bits", .latch_lifespan => "the lifespan of the data latch", .offset_streams => "offset data streams", .bit_timing => "non-standard bit timing", .flux => "tracks recorded as flux rather than bits", }; }};
/// The two folders the same titles appear in, which is what makes the set a/// test of the format as well as of the drive: the disk is the same and only/// the file around it changed.const both_versions = [_][]const u8{ "WOZ 1.0", "WOZ 2.0" };
const Disk = struct { file: []const u8, tier: Tier, /// Which of the set's folders hold this disk. Most titles are shipped in /// both versions of the format; a few are in one only, and the flux disk /// is only in 2.1 because that is the version that has flux tracks. folders: []const []const u8 = &both_versions, /// Whether it got anywhere last time this was run with a ROM. Written down /// so that a change in either direction is noticed. boots: bool, /// Whether the disk has address fields on it at all. Nearly every one /// does, and a disk that suddenly has none is this project having stopped /// reading it — but a side written by a game's own loader rather than by /// DOS need not have a single field anywhere, and saying so here is what /// keeps the check meaningful for all the disks that should. fields: bool = true, /// What the readme says it is there to test, where that is something a /// person reading a failure would want to know. note: []const u8 = "",};
/// The set, in the readme's own order. Only the 5.25-inch images: a 3.5-inch/// WOZ is an 800K drive's business and this is a Disk II.const disks = [_]Disk{ .{ .file = "DOS 3.3 System Master.woz", .tier = .begin, .boots = true }, .{ .file = "The Apple at Play.woz", .tier = .begin, .boots = true }, .{ .file = "DOS 3.2 System Master.woz", .tier = .begin, .boots = true, .note = "thirteen sectors: wants --disk-rom-13" },
.{ .file = "Bouncing Kamungas - Disk 1, Side A.woz", .tier = .protection, .boots = true }, .{ .file = "Commando - Disk 1, Side A.woz", .tier = .protection, .boots = true }, .{ .file = "Planetfall - Disk 1, Side A.woz", .tier = .protection, .boots = true }, .{ .file = "Rescue Raiders - Disk 1, Side B.woz", .tier = .protection, .boots = true }, .{ .file = "Sammy Lightfoot - Disk 1, Side A.woz", .tier = .protection, .boots = true }, .{ .file = "Stargate - Disk 1, Side A.woz", .tier = .protection, .boots = true },
.{ .file = "Blazing Paddles (Baudville).woz", .tier = .cross_track, .boots = true }, .{ .file = "Take 1 (Baudville).woz", .tier = .cross_track, .boots = true },
.{ .file = "Hard Hat Mack - Disk 1, Side A.woz", .tier = .wide_track, .boots = true },
.{ .file = "The Bilestoad - Disk 1, Side A.woz", .tier = .half_tracks, .boots = true },
.{ .file = "Dino Eggs - Disk 1, Side A.woz", .tier = .soft_switches, .boots = true }, .{ .file = "Crisis Mountain - Disk 1, Side A.woz", .tier = .soft_switches, .boots = true }, .{ .file = "Miner 2049er II - Disk 1, Side A.woz", .tier = .soft_switches, .boots = true },
.{ .file = "The Print Shop Companion - Disk 1, Side A.woz", .tier = .fake_bits, .boots = true },
.{ .file = "First Math Adventures - Understanding Word Problems.woz", .tier = .latch_lifespan, .boots = true, .note = "reading the latch should not clear it" },
.{ .file = "Wings of Fury - Disk 1, Side A.woz", .tier = .offset_streams, .boots = true }, .{ .file = "Stickybear Town Builder - Disk 1, Side A.woz", .tier = .offset_streams, .boots = true }, .{ .file = "Wings of Fury - Disk 1, Side B.woz", .tier = .offset_streams, .boots = false, .fields = false, .note = "the game's own data side: no address fields anywhere on it, and track 0 holds sixteen distinct byte values in a repeating pattern" },
.{ .file = "Border Zone - Disk 1, Side A.woz", .tier = .bit_timing, .boots = true, .folders = &.{"WOZ 2.0"} }, .{ .file = "Border Zone - Disk 1, Side B.woz", .tier = .bit_timing, .boots = false, .folders = &.{"WOZ 2.0"}, .note = "the second side of a two-disk game, which is not a side that boots" },
.{ .file = "ProDOS User's Disk - Disk 1, Side A.woz", .tier = .flux, .boots = true, .folders = &.{"WOZ 2.1 (with FLUX chunks)"}, .note = "every other track is recorded as flux rather than as bits" },};
/// What reading an image found: what it holds, and what a drive makes of it.const Read = struct { tracks: usize, longest: u32, /// How many quarter-track positions hold something, which is how a disk /// with data between its tracks shows up. positions: usize, /// Positions holding a track that is not on a whole track boundary. between: usize, /// How many address fields a drive finds going once round each track, /// counting both the ordinary mark and the altered ones protections use. marks: usize, odd_marks: usize, /// Bytes compared against the card's own sequencer PROM, and how many of /// them were the same. Zero when no PROM was given to compare with. checked: usize = 0, agreed: usize = 0, /// How many tracks the two were compared over. compared: usize = 0, /// Tracks the comparison had to leave alone because the surface does not /// give the same answer twice. unrepeatable: usize = 0, /// Address fields marked the way a thirteen-sector disk marks them, which /// is how a file that does not say what it is can still be asked. thirteen: usize,};
/// Puts every track of a disk under a real head and reads it./// Whether a track has a stretch the drive will invent bits over.////// The amplifier holds four bits, and while any of them is set it hands back/// what it heard; once all four are clear it is over unrecorded surface and/// makes something up, which is what a real one does and what the WOZ/// reference asks for. So a track with four zeroes in a row anywhere on it does/// not read the same way twice, and there is no comparing it with anything./// The wrap counts: a track is a loop, and the head goes round it.fn inventsBits(track: *const zig65.disk2.Track) bool { if (track.count == 0) return true; var zeroes: u32 = 0; // Round once and then a little further, so that a run lying across the // join is seen as the one run it is. for (0..track.count + 4) |step| { const at: u32 = @intCast(step % track.count); if (track.bit(at) == 0) { zeroes += 1; if (zeroes >= 4) return true; } else zeroes = 0; } return false;}
/// Every byte the drive finishes, in order.////// Not what a program would see — a program sees whatever it happens to ask/// for — but what the register holds each time a byte lands in it, which is/// the sequence the card's sequencer defines. The drive is polled a cycle at a/// time, which is four times as often as a bit goes past, so nothing is/// missed; a byte has landed whenever the hold on the register starts.fn bytesFromDrive(floppy: *zig65.disk2.Floppy, position: u8, into: []u8) usize { var controller: zig65.disk2.Controller = .{}; controller.fitted = 1; controller.insert(0, floppy); controller.motor = true; controller.drive(0).quarter_track = position;
var got: usize = 0; var held: u16 = 0; var cycles: u64 = 0; // Four cycles to a bit and a byte every eight or ten, so this is several // laps of a track: an upper bound rather than a target, so that a track // giving nothing back cannot become a program that never finishes. const patience = 8 * @as(u64, zig65.disk2.empty_track_bits) * 4; while (got < into.len and cycles < patience) { cycles += 1; _ = controller.readNibble(cycles); const drive = controller.drive(0); if (held == 0 and drive.holding != 0) { into[got] = drive.data; got += 1; } held = drive.holding; } return got;}
fn readWith(gpa: std.mem.Allocator, image: []u8, prom: ?*const [sequencer.size]u8) !Read { const file = try zig65.woz.open(image); const floppy = try gpa.create(zig65.disk2.Floppy); defer gpa.destroy(floppy); floppy.* = .{}; try floppy.loadWoz(file);
var out: Read = .{ .tracks = 0, .longest = 0, .positions = 0, .between = 0, .marks = 0, .odd_marks = 0, .thirteen = 0 };
// Room for one track's worth of bytes twice over, for the two readings of // it that get compared. const compare: []u8 = if (prom != null) try gpa.alloc(u8, 2 * 7000) else &.{}; defer if (prom != null) gpa.free(compare); var seen: [zig65.disk2.quarter_tracks]bool = @splat(false);
for (0..zig65.disk2.quarter_tracks) |position| { const which = floppy.map[position]; if (which == zig65.disk2.nothing_there) continue; out.positions += 1; if (position % 4 != 0) out.between += 1; if (seen[which]) continue; seen[which] = true; out.tracks += 1; out.longest = @max(out.longest, floppy.tracks[which].count);
// What the card's own sequencer would have handed the processor off // this track, against what this project's drive hands it. if (prom) |rom| skip: { const track = &floppy.tracks[which]; if (inventsBits(track)) { out.unrepeatable += 1; break :skip; } const half = compare.len / 2; const mine = compare[0..half]; const theirs = compare[half..]; const got = bytesFromDrive(floppy, @intCast(position), mine); const said = sequencer.readTrack( rom, &track.bits, track.count, floppy.bit_timing, theirs, ); // The first few bytes are the head coming down in the middle of // somebody else's byte and are a smear either way, so the two are // lined up from where they have both found the surface. // // And lined up is work rather than an assumption. The drive reads // through the amplifier's window, which is a bit behind the // surface, so its first byte can finish a byte earlier or later // than the sequencer's — and a stream compared one byte out of // step disagrees with itself everywhere, which would read as this // drive being wrong rather than as it having started elsewhere. So // the offset that agrees best is the one used, out of a handful // either way; a drive that really was wrong does not become right // at any of them. const start = 8; const slack = 4; var best: usize = 0; var best_of: usize = 0; var shift: isize = -slack; while (shift <= slack) : (shift += 1) { var same: usize = 0; var of: usize = 0; var at: usize = start; while (at < got) : (at += 1) { const other = @as(isize, @intCast(at)) + shift; if (other < 0 or other >= said) continue; of += 1; if (mine[at] == theirs[@intCast(other)]) same += 1; } if (same > best) { best = same; best_of = of; } } out.checked += best_of; out.agreed += best; out.compared += 1; }
// Read it the way the machine does: put the head there, turn the motor // on, and poll the data register the way the boot ROM's loop does. var controller: zig65.disk2.Controller = .{}; controller.fitted = 1; controller.insert(0, floppy); controller.motor = true; controller.drive(0).quarter_track = @intCast(position);
var recent: [3]u8 = @splat(0); var cycles: u64 = 0; var got: usize = 0; // One revolution and a little over, in bytes: enough to meet every // field on the track wherever the head happened to come down. while (got < 7000) { cycles += 7; const value = controller.readNibble(cycles); if (value & 0x80 == 0) continue; got += 1; recent = .{ recent[1], recent[2], value }; if (recent[0] == 0xd5 and recent[1] == 0xaa) { if (recent[2] == 0x96) out.marks += 1; // The marks a protected disk uses instead. $b5 is what a // thirteen-sector disk writes; the rest are somebody being // awkward on purpose. if (recent[2] == 0xb5 or recent[2] == 0xad) out.odd_marks += 1; if (recent[2] == 0xb5) out.thirteen += 1; } else if (recent[0] == 0xd4 and recent[1] == 0xaa and recent[2] == 0x96) { out.odd_marks += 1; } cycles += 20; } } return out;}
const Boot = struct { booted: bool, drawn: usize, text: usize };
fn boot(gpa: std.mem.Allocator, rom: []const u8, card: []const u8, image: []u8, steps: usize) !Boot { const machine = try gpa.create(Machine); defer gpa.destroy(machine); try machine.init(null, null); defer machine.deinit(); try machine.memory.loadROMAtEnd(rom); try machine.memory.loadCardROM(card);
const floppy = try gpa.create(zig65.disk2.Floppy); defer gpa.destroy(floppy); floppy.* = .{}; try floppy.loadWoz(try zig65.woz.open(image)); machine.memory.drives().insert(0, floppy); machine.reset();
// How much of the last stretch it spends in the boot ROM's page: a machine // that never loaded a sector never leaves it. var in_rom: usize = 0; var looked: usize = 0; var done: usize = 0; while (done < steps) : (done += between_looks) { for (0..between_looks) |_| machine.executeInstruction() catch {}; if (done * 4 > steps * 3) { looked += 1; const at = machine.program_counter.value; if (at >= 0xc600 and at <= 0xc6ff) in_rom += 1; } }
var drawn: usize = 0; for (0x2000..0x6000) |at| { if (machine.memory.peek(@intCast(at)) != 0) drawn += 1; } var buffer: [zig65.screen.rows * 80]u8 = undefined; var writer: std.Io.Writer = .fixed(&buffer); machine.memory.writeText(&writer) catch {}; var text: usize = 0; for (writer.buffered()) |ch| { if (ch != ' ') text += 1; }
const stuck = looked > 0 and in_rom * 2 > looked; return .{ .booted = !stuck and (drawn > 64 or text > 16), .drawn = drawn, .text = text };}
const usage = \\usage: wozcheck --images DIR [--rom PATH --disk-rom PATH] \\ [--disk-rom-13 PATH] [--sequencer-rom PATH] \\ [--instructions N] [--only SUBSTRING] \\ \\Reads every WOZ reference image and puts its tracks under a real drive \\head. That needs nothing but the images and is what runs by default. \\ \\Given --rom (an Apple IIe system ROM) and --disk-rom (a Disk II boot \\PROM) it also boots each disk and says which get anywhere. Those are \\Apple's code and are not shipped with this project, which is why booting \\is not the default. --disk-rom-13 is the earlier thirteen-sector PROM, \\which the disks that want it say they want in their own INFO chunk. \\ \\--sequencer-rom is the card's other PROM, the 256-byte state machine at \\P6. Given it, every track is read twice — once by this project's drive \\and once by the card's own sequencer running out of its own ROM — and \\the two byte streams are compared. It is the one check here that is not \\somebody's reading of a manual. \\;
pub fn main(init: std.process.Init) !void { const io = init.io; const gpa = std.heap.smp_allocator;
var images: ?[]const u8 = null; var rom_path: ?[]const u8 = null; var card_path: ?[]const u8 = null; var card13_path: ?[]const u8 = null; var p6_path: ?[]const u8 = null; var steps: usize = instructions_default; var only: ?[]const u8 = null;
var args: std.process.Args.Iterator = .init(init.minimal.args); _ = args.skip(); while (args.next()) |arg| { if (std.mem.eql(u8, arg, "--images")) { images = args.next(); } else if (std.mem.eql(u8, arg, "--rom")) { rom_path = args.next(); } else if (std.mem.eql(u8, arg, "--disk-rom")) { card_path = args.next(); } else if (std.mem.eql(u8, arg, "--disk-rom-13")) { card13_path = args.next(); } else if (std.mem.eql(u8, arg, "--sequencer-rom")) { p6_path = args.next(); } else if (std.mem.eql(u8, arg, "--instructions")) { steps = std.fmt.parseInt(usize, args.next() orelse "0", 10) catch steps; } else if (std.mem.eql(u8, arg, "--only")) { only = args.next(); } else { std.debug.print("{s}", .{usage}); std.process.exit(if (std.mem.eql(u8, arg, "--help") or std.mem.eql(u8, arg, "-h")) 0 else 2); } }
const where = images orelse { std.debug.print("{s}", .{usage}); std.process.exit(2); };
// The ROMs, if booting was asked for. Both or neither: a machine without // its disk card cannot start from a disk. var rom: ?[]u8 = null; var card: ?[]u8 = null; var card13: ?[]u8 = null; if (rom_path != null and card_path != null) { rom = std.Io.Dir.cwd().readFileAlloc(io, rom_path.?, gpa, .limited(0x10001)) catch |err| { std.debug.print("wozcheck: cannot read '{s}': {s}\n", .{ rom_path.?, @errorName(err) }); std.process.exit(1); }; card = std.Io.Dir.cwd().readFileAlloc(io, card_path.?, gpa, .limited(0x1000)) catch |err| { std.debug.print("wozcheck: cannot read '{s}': {s}\n", .{ card_path.?, @errorName(err) }); std.process.exit(1); }; } // And the earlier PROM, for the disks that want it. Which one a disk wants // is not a guess: the WOZ INFO chunk carries a boot sector format, and the // format's own reference says the field is there to "assist emulators in // determining which P5 ROM variant to load". if (card13_path) |path| { card13 = std.Io.Dir.cwd().readFileAlloc(io, path, gpa, .limited(0x1000)) catch |err| { std.debug.print("wozcheck: cannot read '{s}': {s}\n", .{ path, @errorName(err) }); std.process.exit(1); }; } // The sequencer PROM, if there is one to check against. var p6: ?[]u8 = null; if (p6_path) |path| { p6 = std.Io.Dir.cwd().readFileAlloc(io, path, gpa, .limited(sequencer.size + 1)) catch |err| { std.debug.print("wozcheck: cannot read '{s}': {s}\n", .{ path, @errorName(err) }); std.process.exit(1); }; if (p6.?.len != sequencer.size) { std.debug.print( "wozcheck: '{s}' is {d} bytes and the sequencer PROM is {d}\n", .{ path, p6.?.len, sequencer.size }, ); std.process.exit(1); } } defer if (p6) |r| gpa.free(r);
defer if (rom) |r| gpa.free(r); defer if (card) |c| gpa.free(c); defer if (card13) |c| gpa.free(c);
std.debug.print( "the WOZ reference images, read{s}\n", .{if (rom == null) " (no ROM given, so not booted)" else " and booted"}, );
var last: ?Tier = null; var read_ok: usize = 0; var booted: usize = 0; var tried: usize = 0; var missing: usize = 0; var failures: usize = 0; var changes: usize = 0; var checked: usize = 0; var agreed: usize = 0; var compared: usize = 0; var unrepeatable: usize = 0;
for (disks) |disk| for (disk.folders) |folder| { if (only) |want| { if (std.mem.indexOf(u8, disk.file, want) == null) continue; } if (last == null or last.? != disk.tier) { std.debug.print("\n{s}\n", .{disk.tier.name()}); last = disk.tier; }
// The same title in two versions of the format is two tests, so the // name it is reported under says which file was read. var named: [512]u8 = undefined; const shown = try std.fmt.bufPrint(&named, "{s} [{s}]", .{ disk.file, folder });
var path: [512]u8 = undefined; const full = try std.fmt.bufPrint(&path, "{s}/{s}/{s}", .{ where, folder, disk.file }); const image = std.Io.Dir.cwd().readFileAlloc(io, full, gpa, .limited(zig65.woz.max_file_size)) catch { std.debug.print(" {s:<54} not here\n", .{shown}); missing += 1; continue; }; defer gpa.free(image); tried += 1;
const found = readWith(gpa, image, if (p6) |r| r[0..sequencer.size] else null) catch |err| { std.debug.print(" {s:<54} cannot be read: {s}\n", .{ shown, @errorName(err) }); failures += 1; continue; }; // A disk nothing can be found on is usually a disk this is not // reading: nearly every image in this set is a sectored disk, so a // head that goes all the way round every track without meeting a // single field of any kind has not understood what it was given. The // exception is a side written by a game's own loader, which owes DOS // nothing and need have no fields at all — and the table says which // those are, so that the check stays sharp for the rest. if (found.marks + found.odd_marks == 0 and disk.fields) { std.debug.print(" {s:<54} no fields found on any of its {d} tracks\n", .{ shown, found.tracks }); failures += 1; continue; } // And the other way round: a disk written down as having no fields // that suddenly has some is news too. if (found.marks + found.odd_marks > 0 and !disk.fields) { std.debug.print(" {s:<54} has {d} fields, and the table says it has none\n", .{ shown, found.marks + found.odd_marks }); failures += 1; continue; } read_ok += 1;
std.debug.print(" {s:<54} {d:>2} tracks, {d:>3} positions ({d} between), {d} marks", .{ shown, found.tracks, found.positions, found.between, found.marks, }); if (found.odd_marks > 0) std.debug.print(" and {d} unusual", .{found.odd_marks}); if (found.checked > 0 or found.unrepeatable > 0) { checked += found.checked; agreed += found.agreed; compared += found.compared; unrepeatable += found.unrepeatable; // A byte or two a track is the head coming down in the middle of // somebody else's, which both readings recover from within a few // bytes and neither is wrong about. More than that is worth // saying out loud. const missed = found.checked - found.agreed; if (found.compared > 0 and missed > 4 * found.compared) { std.debug.print("\n {s:<54} {d} of {d} bytes are not what the card's sequencer gives", .{ "", missed, found.checked, }); } }
if (rom) |r| { // Thirteen sectors a track is a different encoding and a different // boot PROM. A version 2 file says which it is, in a field the // format's own reference says is there to "assist emulators in // determining which P5 ROM variant to load". // // A version 1 file has no such field — it arrived with version 2 — // so for those the disk is asked instead of the file: a track with // no sixteen-sector address fields on it at all and plenty of the // thirteen-sector kind is a thirteen-sector disk, whatever the // header does or does not say. const claims = (try zig65.woz.open(image)).info.boot_format; const thirteen = claims == 2 or (claims == 0 and found.marks == 0 and found.thirteen > 0); const which = if (thirteen) card13 orelse { std.debug.print("\n {s:<54} not booted: thirteen sectors, and no --disk-rom-13 given", .{""}); std.debug.print("\n", .{}); continue; } else card.?; const outcome = try boot(gpa, r, which, image, steps); if (outcome.booted) booted += 1; if (outcome.booted != disk.boots) changes += 1; const said: []const u8 = if (outcome.booted == disk.boots) (if (outcome.booted) "boots" else "does not boot") else if (outcome.booted) "BOOTS, and did not before" else "STOPPED BOOTING"; std.debug.print("\n {s:<54} {s}", .{ "", said }); if (!outcome.booted and disk.note.len > 0) std.debug.print(" ({s})", .{disk.note}); } std.debug.print("\n", .{}); };
if (checked > 0) { std.debug.print( "\nall but {d} of {d} bytes over {d} tracks are what the card's own sequencer" ++ " PROM gives\n", .{ checked - agreed, checked, compared }, ); if (unrepeatable > 0) { std.debug.print( "{d} more tracks were left alone: they have unrecorded stretches the" ++ " drive invents bits over, so they do not read the same way twice\n", .{unrepeatable}, ); } }
std.debug.print("\n{d} of {d} read", .{ read_ok, tried }); if (rom != null) std.debug.print(", {d} boot", .{booted}); if (missing > 0) std.debug.print(", {d} not found", .{missing}); std.debug.print("\n", .{});
if (failures > 0) { std.debug.print("{d} could not be read, which is this project's fault\n", .{failures}); std.process.exit(1); } // The drive and the card's own state machine should hand the processor the // same bytes off the same surface, give or take the byte the head comes // down in the middle of. They currently differ on about two and a half a // track; a hundredth of what is read is a long way past that, and is this // drive having stopped agreeing with the hardware. if (checked > 0 and agreed * 100 < checked * 99) { std.debug.print( \\the drive and the card's sequencer no longer read the same disk the same \\way. That is not a difference of opinion: the sequencer here is the \\card's own PROM, so whatever changed in the drive changed away from \\the hardware. \\ , .{}); std.process.exit(1); } if (changes > 0) { std.debug.print( \\{d} boot differently than the table in src/main.zig says. If they \\stopped, that is a regression; if they started, that is good news \\and the table wants updating. Either way somebody should be told \\rather than the news being swallowed. \\ , .{changes}); std.process.exit(1); }}