A cycle-accurate Apple II and Apple IIgs emulator written in Zig, usable as both a program and a library.

give the machine a mouse

An AppleMouse II card in slot 4, with its own firmware as the other cards have: the five bytes a program looks for, the table of eight routines it calls through, and the screen holes it reads the answers out of. The card does the work and leaves the position and the buttons where they are expected, which is what the processor on a real card's own board does. It is the first thing here besides vertical blanking and the serial card to pull the interrupt line, and the only one that does it of its own accord: told to, it interrupts when the mouse moves, when a button goes down, or once a frame. Owning up through the firmware is what takes it off the line again, and the line is still worked out from everything at once, so one card letting go does not quieten another. `--mouse` fits it and points the terminal's own mouse at it. Where the pointer is over the machine's screen is where the mouse is, scaled to whatever the program has clamped it to. A terminal says where a pointer is rather than how far it has moved, so that is what there is. The tests call the firmware the way a program does: through the table, with the slot in X and Y and interrupts disabled, and they check what comes back in the screen holes and in the carry. Two things came out of writing them: the status a program reads has to be the one that stood before the read, since that is what tells it a click or a movement is new, and a handler really does have to be called with interrupts disabled, because otherwise the processor answers the interrupt before reaching the call. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01FawbWzEu5hoLLZSMCehUGP


Author jcollie.dev
Co-author Claude Opus 5 Date Commit Parent 2de2177e