From ada1e1aaa51bdcc92801dc5d5c0db783e4ea79d6 Mon Sep 17 00:00:00 2001 From: "Jeffrey C. Ollie" Date: Wed, 9 Sep 2026 21:49:52 -0500 Subject: [PATCH] apple2gs: bring the header up to date; the video is modelled now The module header still described the early skeleton: the Mega II's memory "not [wired]" and "no video" until it was, shadowing and the speed and state registers only "counted," fast RAM stopping at 256K. All of that has since been built -- the memory is wired and the display is drawn from it (Super Hi-Res in superhires.zig, the legacy modes in the shared video.zig), shadowing and the speed and state registers do their work, and fast RAM runs to eight megabytes. Rewrite "what is here" and "what is not" to match, leaving in the latter only what is genuinely still missing: PAL timing and the floating bus, with the soft-switch tally as the standing to-do for everything else. And the inline comment at the VGC registers no longer says "the video is not modelled" -- it stores and reads them back, hands the monochrome and screen-colour registers to the Mega II so text draws in the right colours, and points at where the drawing actually lives. Comment-only; no behavior changes. Co-Authored-By: Claude Opus 4.8 Claude-Session: https://claude.ai/code/session_01969H4dxMhArn3Co6Dr6k6w --- src/memory16/apple2gs.zig | 79 +++++++++++++++++++++------------------ 1 file changed, 43 insertions(+), 36 deletions(-) diff --git a/src/memory16/apple2gs.zig b/src/memory16/apple2gs.zig index 1ba20ee..549b746 100644 --- a/src/memory16/apple2gs.zig +++ b/src/memory16/apple2gs.zig @@ -2,8 +2,9 @@ // // SPDX-License-Identifier: MIT -//! An Apple IIgs, as far as it goes — which is not far yet, and the point of -//! this first version is to find out how far. +//! An Apple IIgs. It has come a fair way from its first version — it has its +//! memory, its video and the registers behind them — but it is not a complete +//! machine, and its gaps are still found the same way. //! //! There is no corpus for a machine. What there is instead is the ROM: it runs //! a self-test when the power comes on, and if the machine is honest about @@ -13,8 +14,8 @@ //! //! What is here: //! -//! - Fast RAM in banks `$00` and `$01`, and slow RAM in `$e0` and `$e1`, -//! which is the 256K a IIgs came with. +//! - Fast RAM from bank `$00` up, and slow RAM in `$e0` and `$e1`; the first +//! two fast banks with the two slow ones are the 256K a IIgs came with. //! - The ROM, in whichever top banks the image turns out to hold, found by //! `iigsrom.identify` because the file does not say. //! - The language card window, `$d000` to `$ffff` in banks `$00` and `$01`, @@ -23,37 +24,40 @@ //! come from the ROM through this window. //! //! And the registers the firmware asked for that the Hardware Reference (Apple -//! Computer, Inc., 1989) answers plainly, which is most of them. They are -//! kept and read back rather than acted on, except vertical blanking, which is -//! timed. A register that remembers what was written to it is a great deal -//! better than one that reads zero: firmware writes a configuration and then -//! checks it took. +//! Computer, Inc., 1989) answers plainly, which is most of them. Many are kept +//! and read back rather than acted on — a register that remembers what was +//! written to it is a great deal better than one that reads zero, since +//! firmware writes a configuration and then checks it took — but a growing +//! number do their work: the video controller, shadowing, the speed and state +//! registers, and vertical blanking and the VGC's timers, which are drawn from +//! the clock. //! -//! And a Mega II, for the soft switches. Banks `$e0` and `$e1` of a IIgs are -//! an Apple IIe's 128K, `memory/apple2e.zig` is an Apple IIe, and the `host` -//! option on that model exists so that one can be a part of a larger machine -//! rather than the whole of one. What is wired up so far is the switch page, -//! `$c000` to `$c0ff`, which is where all of the ones the firmware was still -//! asking for live: the keyboard, the eighty-column and character-set -//! switches, the slot ROM switches, the speaker. +//! And a Mega II, and its memory. Banks `$e0` and `$e1` of a IIgs are an Apple +//! IIe's 128K, `memory/apple2e.zig` is an Apple IIe, and the `host` option on +//! that model exists so that one can be part of a larger machine rather than +//! the whole of one. Both its switch page — `$c000` to `$c0ff`, the keyboard, +//! the eighty-column and character-set switches, the slot ROM switches, the +//! speaker — and its 128K are wired, and the second is what makes the video +//! real: the display is drawn out of that memory, Super Hi-Res from the VGC +//! (`superhires.zig`) and the legacy IIe modes through the shared `video.zig`. +//! Which half a bank address reaches is bit 0 of the New-Video register: set, +//! the low bit of the address picks main or auxiliary directly; clear, the +//! IIe's own switches decide. See `vgc` below. //! -//! What is not, and is the next thing rather than an oversight: +//! Shadowing (`$c035`), the speed register (`$c036`) and the state register +//! (`$c068`) are modelled too, where an earlier version of this only counted +//! them, and fast RAM runs on past the first 256K — a IIgs board holds banks +//! `$00` to `$7f`, eight megabytes, and an expansion card carries it further. //! -//! - The Mega II's *memory*. Its switches are wired up; its 128K is not, so -//! banks `$e0` and `$e1` are still this model's own array and the Mega -//! II's sits unused beside it. They have to become one before there is any -//! video, and the reason they are not one yet is that the IIe model keeps -//! its halves split by region — the language card sees to that — so there -//! is no flat 64K to hand a bank address to. +//! What is not: //! -//! The rule for which half, at least, is settled, and it is bit 0 of the -//! New-Video register: set, the low bit of the bank address picks main or -//! auxiliary directly; clear, the IIe's own switches decide. See -//! `vgc` below. -//! - Shadowing, the speed register, the state register, and every other -//! `$c0xx` this does not know. They are counted rather than guessed at. -//! - Banks `$02` upwards of fast RAM, which a machine with more than 256K -//! has. +//! - PAL timing. The frame stays the 262-line NTSC one whatever the PAL bit +//! says; the bit only reads back (`vgc.zig`). +//! - The IIgs floating bus. A `$c0xx` this does not model reads zero rather +//! than whatever the bus was last carrying. +//! - Whatever the ROM is still asking for that the tally of unknown soft +//! switches has not been read off yet — which is the whole reason the +//! tally is kept. const std = @import("std"); @@ -1632,11 +1636,14 @@ pub fn AppleIIgs(comptime options: Options) fn (type) type { // drawing and clear while it is not. The same way // round as a IIe and the opposite of a IIc. 0x19 => if (value == null) return if (self.blanking()) 0x00 else 0x80, - // The video controller's four registers. None of - // them draws anything — the video is not modelled — - // but all four read back what a program setting up a - // display put in them, which is what the firmware and - // the Control Panel between them need. + // The video controller's registers. Writing one here + // stores it and reads it back, which is what the + // firmware's self-test and the Control Panel need; the + // monochrome and screen-colour registers below are also + // handed to the Mega II, so its text draws in the right + // colours. The drawing itself is elsewhere: Super + // Hi-Res and the legacy modes are rendered from video + // memory in `superhires.zig` and `video.zig`. 0x21 => if (value) |v| { self.vgc.setMonochromeRegister(v); self.giveTextColours(); -- knotmirror 0.0.1