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.
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849// SPDX-FileCopyrightText: 2026 Jeffrey C. Ollie <jeff@ocjtech.us>//// SPDX-License-Identifier: MIT
/// Describes one instruction: its mnemonic, and every opcode that selects/// it together with that opcode's addressing mode and cycle count. Opcodes/// collects these at comptime to build the dispatch table.pub fn data(comptime CPU: type) type { return struct { pub const mnemonic = "WAI"; pub const opcodes = [_]CPU.Opcodes.Init{ .{ .opcode = 0xcb, .addressing_mode = .Implied, .cycles = 3, }, };
/// The implementation for a single addressing mode. Resolved at /// comptime so the dispatch table holds a plain function pointer with /// no mode left to branch on at runtime. pub fn func(comptime addressing_mode: CPU.AddressingModes) *const fn (*CPU) error{}!void { if (addressing_mode != .Implied) @compileError("illegal addressing mode"); const f = struct { /// Waits until something interrupts. /// /// The processor stops fetching and lets the clock run. What /// wakes it is the interrupt line: if interrupts are enabled /// it goes to the handler, and if they are not it carries on /// with the instruction after this one, which is how a program /// waits for something without a polling loop and without /// giving up control of what happens next. /// /// The corpus has nothing to say about this one: an /// instruction that waits cannot be recorded a case at a time, /// and the file for it in the corpus is empty. pub fn WAI(cpu: *CPU) error{}!void { // Two discarded fetches, and then it is not fetching any // more. cpu.program_counter.phantomRead(); cpu.program_counter.phantomRead(); cpu.waiting = true; } }; return f.WAI; } };}