# Agnus: beam counters, the DMA slot table, the Copper, the Blitter, chip-RAM arbitration Agnus (OCS 8361 NTSC / 8367 PAL, Fat Agnus 8370/8371; ECS 8372A, 8375; AGA Alice) owns the chip-RAM bus. Every chip-RAM cycle on the machine passes through its arbiter, which is why **the DMA slot table is where the board's cycle exactness lives**. Facts below are from HRM3 (tier 2) unless tagged otherwise; page numbers are PDF pages. ## Clocks | Clock | NTSC | PAL | Source | | --- | --- | --- | --- | | crystal | 28.63636 MHz | 28.37516 MHz | HRM3 pdf367 | | 68000 (7M), the blitter's clock | 7.15909 MHz | 7.09379 MHz | HRM3 pdf17, pdf208 | | colour clock (CCK): one chip-RAM memory cycle, "approximately 280 ns" | 3.579545 MHz | 3.546895 MHz | HRM3 pdf174 (Paula's "clock constant" = 7M / 2), pdf209 | | E clock (CIA timers, VPA cycles) | 715,909 Hz | 709,379 Hz | 7M / 10, HRM3 pdf367-368 | The board's time unit should be the **7M clock** (one 68000 clock = half a CCK). A CCK slot is two 7M clocks; a 68000 bus cycle is four (two slots); a hires pixel is half a 7M clock (a 28M/2 = 14M tick) and a lores pixel one 7M clock, so the specification needs a finer unit only inside Denise (denise.md). MAME's own figure agrees: 141,873 68000 clocks in a PAL frame (mame-oracle.md; OBSERVED). ## The beam counters - A line is **227.5 CCKs** in NTSC (HRM3 pdf209: "227.5 color clocks ... 226 cycles are available to be allocated"). NTSC alternates long and short lines; PAL lines are 227 CCKs (HYPOTHESIS from the PAL figures elsewhere; HRM3 gives the 227.5 figure in an NTSC context only: U1). - Fields: NTSC 262 then 263 lines, PAL 312 then 313 (interlace: long and short frames; HRM3 pdf39). VPOSR bit 15 is LOF, bit 0 is V8; VHPOSR holds V7-V0 and H8-H1, a horizontal resolution of one CCK (HRM3 pdf231, table 7-5). - VPOSR bits 14-8 carry the Agnus ID: 00 PAL OCS, 10 NTSC OCS, 20 PAL ECS, 30 NTSC ECS (HRM3 pdf314; "Do not depend on value!", pdf253). The board's machine rows set it. - ECS adds BEAMCON0 (programmable sync, PAL/NTSC switch in software) and VARBEAM registers (HRM3 appendix C): ECS row only. ## The DMA slot table Per line (HRM3 pdf209, figure 6-9 at pdf210): | Channel | Slots per line | Slot parity (figure 6-9) | | --- | --- | --- | | memory refresh | 4 | the first even slots of the line | | disk | 3 | even | | audio | 4 (one word per channel) | even | | sprites | 16 (two words per sprite, 8 sprites) | even | | bitplanes | up to 80 (lores: up to 6 planes in an 8-slot cycle using odd slots first and even slots for planes 5-6 / the 4th hires plane; hires: all 8 slots of the cycle for 4 planes) | per figures 6-11, 6-12 | | Copper | the odd slots no bitplane uses | odd (HRM3 pdf35) | | Blitter, 68000 | whatever is left; the blitter before the CPU | any free | Priorities (HRM3 pdf209): disk, audio, display (bitplanes) and sprites first (bitplanes over sprites: a wide or scrolled display takes the highest sprites' slots, pdf212), then the Copper, then the blitter, then the 68000. The lores fetch order inside an 8-slot cycle is planes `- 4 6 2 - 3 5 1` and hires `4 2 3 1 4 2 3 1` (figures 6-11, 6-12, read from the scan). DDFSTRT can begin no earlier than `$18` and the fetch stops by `$D8` (figure 6-9's notes: a "hardware stop"), data fetch starts only at multiples of 8 clocks, and "five clocks must occur before the data fetched for a particular position can appear on screen" (pdf210). **Figure 6-9 says of itself** that "this timing chart has been 'adjusted'" to match hardware requirements for data-fetch and display start, and that its cycle 0 "appears to exclude one of the memory refresh cycles. This is not the case." So the figure is a drawing, not a slot-by-slot table: **the exact slot numbers per channel are U2**, to be settled against vAmigaTS's Agnus/DDF and DIW tests (tier 3) before M2 freezes them. Specification shape (proposal): one function `slot_owner(line, cck)` driven by the registers latched for that line (DMACON, DDFSTRT/STOP, BPLCON0's plane count and resolution, sprite and audio and disk state), returning which channel owns the slot, and the arbiter giving free slots to Copper (odd only), Blitter, then CPU. Every slot is one row of the board's per-cycle trace. ## The 68000 and chip RAM - "The 68000 uses only the even-numbered memory access cycles" so that with four or fewer lores planes it "runs at full speed" (HRM3 pdf211, figure 6-10). But the same manual says audio, disk, refresh and sprites "use only the even-numbered memory cycles" and the Copper the odd ones (pdf35). Both cannot be literally true: **C1**. The modelling consequence is that the CPU's 4-clock bus cycle is granted a free slot wherever one falls, and stalls in 2-clock steps until one does; which parity it can use is decided by evidence (vAmigaTS, Amiga Test Kit timing loops), not by either page. - A CPU access to chip RAM or the custom registers waits for a free slot; ROM, CIA and (on machines that have it) fast RAM accesses do not use the chip bus. The A500's "slow" (trapdoor, C00000) RAM sits on the chip bus and contends like chip RAM (TRM, Gary: to confirm, U3). - More than four lores planes, or hires with more than two, steal the CPU's slots during the display: six lores planes take 160 slots a line, four hires planes all of them (pdf211-212). - **Blitter nasty** (DMACON bit 10, BLTPRI/DMAF_BLITHOG): set, the blitter takes every free cycle; clear, "if the 68000 is unsatisfied for three consecutive memory cycles, the blitter will release the bus for one cycle" (pdf213). Exactly which cycles count as "unsatisfied" is U4. - The 68000's TAS read-modify-write "will not fit into a DMA memory access slot" and must not be used (pdf211); what happens if it is used (lost write?) is U5. ## The Copper - Two instruction words per instruction; MOVE and SKIP take two memory cycles and, using only odd cycles, four memory-cycle times; WAIT takes three memory cycles, six cycle times, "one extra memory cycle to wake up" (HRM3 pdf35). Figure 6-9's note says "Copper Data Move instructions require 4 slots. Copper Wait instructions require 6 slots": the same figures counted in slots. - The Copper steals cycles from the blitter or the 68000 only (pdf34-35). - WAIT compares the beam position against masked VP/HP values; the horizontal resolution is 4 lores pixels; the vertical compare is 7 bits plus the blitter-finished disable bit (chapter 2: to be extracted with page cites at M3). - COPJMP1/2 strobes restart the Copper from COP1LC/COP2LC; COP1LC is reloaded at the start of every vertical blank (chapter 2). - The Copper danger bit (COPCON CDANG) limits which registers it may write (chapter 2; OCS and ECS differ: the ECS row lets it reach the blitter registers without CDANG, appendix C: U6 to confirm). - What the Copper does when a WAIT position lies in the horizontal blank or past the end of the line, and its exact wake-up slot, are U7: vAmigaTS Agnus/Copper decides. ## The Blitter - Channels A, B, C (sources) and D (destination); minterm logic, A shift and B shift, first and last word masks, fill (inclusive/exclusive), line mode with octants, zero detection; ascending and descending modes (HRM3 chapter 6, pdf185-215). - Writing BLTSIZE starts it (OCS: 10-bit height, 6-bit width; ECS adds BLTSIZV/BLTSIZH for larger blits). - Speed (pdf208): a blitter cycle is 4 to 8 clocks: A is free, B adds 2, C and D together add 2; line mode takes 8 clocks a pixel. This is a **summary**: the real sequence of slots per channel combination (which slot reads A, B, C, which writes D, the idle slots, the pipeline's first and last cycles) is not in HRM3: **U8**, the biggest single gap in the chip set. vAmigaTS Agnus/Blitter's screenshots judge it. - "Starting with the Fat Agnus the blitter busy bit has been 'fixed'" (pdf202): a revision row (OCS 8361/8367 versus Fat Agnus). - The blitter's interrupt (INTREQ BLIT, level 3) at the end. ## Chip RAM sizes and the address decode - Original and Fat Agnus: 512 KB of chip RAM; ECS 8372A: up to 1 MB; 8375 (A500+, A600): up to 2 MB (HRM3 pdf20; A500PSM). Above the Agnus's reach, accesses wrap (how, per revision: U9). - The custom registers sit at DFF000-DFF1FF (HRM3 appendix A/B, pdf329); undecoded register reads and the write-only registers' read values are U10.