# Interrupts on all three processors Sources: **[TRM]** p.16-17, 38-39, 58-61, 86-87, 98-99, 135 (tier 2); **[NET]** `tom/MISC.NET` l.26-104, `jerry/JMISC.NET` l.32-90, `tom/TOM.NET` l.307 (tier 2 as text, read); MAME's `cpu_space_map` (tier 5). The JRISC cores' interrupt *entry* (vector = 16 x number from the base of local RAM, the push on R31, R30 corrupted, `IMASK`, the atomic sequences) is `jrisc-python`'s; the **latches, enables, sources and the lines between chips** are the board's. ## The picture ``` video VI ------------+ GPU (G_CTRL bit 1) --+ OP stop object ------+--> Tom INT1 latches --> one line --> 68000 IPL (level 2), vector 64 Tom PIT -------------+ (5 sources) Jerry INT out -------+ (also GPU interrupt 1) external (EINT0) ----+ DSP (D_CTRL bit 1) --+ Jerry timer 1 -------+--> Jerry J_INT latches --> Jerry INT out --> Tom "dint" (source 4 above) Jerry timer 2 -------+ (6 sources) UART ----------------+ I2S -----------------+ GPU interrupts: 0 CPU (G_CTRL bit 2), 1 Jerry/DSP line, 2 Tom PIT, 3 OP GPU object, 4 Blitter DSP interrupts: 0 CPU (D_CTRL bit 2), 1 I2S, 2 timer 1, 3 timer 2, 4 external 0, 5 external 1 ``` ## The 68000 - **One interrupt line.** Tom ORs its five latches into one output (`MISC.NET`: `Intl := NR6(i[0..4])`). There is **no VPA and no vector logic: "all interrupts are acknowledged with vector $40"** [TRM p.135, Tom bug 7], so every interrupt enters through vector 64, the long at `$100`. The level is a board wiring fact: MAME answers the acknowledge of **level 2** with `0x40` and autovectors the rest (`jaguar.cpp` `cpu_space_map`, with a TODO quoting the manual). The handler reads `INT1` to find the source. For `m68000-python` this is `acknowledge(level)` returning `0x40` (a vectored acknowledge, 44 clocks, no E-clock wait). - **`INT1` (`F000E0`)**: write bits 0-4 = enables (video, GPU, object, timer, Jerry), bits 8-12 = clear the pending latch; read bits 0-4 = pending [TRM p.16]. - **Netlist details the manual does not give** (`MISC.NET` l.55-80): 1. a source's pulse sets its pending latch **only if its enable bit is set at that moment** (`Gip := AN2(gpuint, ie[1])` and likewise for the others): a disabled source leaves no pending bit to find later; 2. the video interrupt has a pre-latch (`Lvint`) set by the video logic and cleared only by writing bit 8; the pending latch is set on that pre-latch's **rising edge**. A handler that does not write `$0100`-style acknowledges never sees a second video interrupt; 3. the Jerry input is sampled for a rising edge as well (the manual says so: "the first interrupt will occur on the first rising edge after it has been enabled"). - **`INT2` (`F000E2`)**, any write: ends the "CPU under interrupt" bus-priority boost. A latch `ihandler` is set when the interrupt line asserts and cleared by this write (`MISC.NET` l.95-104); while set the 68000 arbitrates above the GPU and blitter at normal priority ([bus-arbitration.md](bus-arbitration.md)). "INT2 must always be written to at the end of a CPU interrupt service routine" [TRM p.17]; after the write "no further instructions will then be executed until either the next interrupt occurs, or the GPU or Blitter operation completes": i.e. with the boost gone a busy GPU or blitter starves the 68000. - The video interrupt fires on the half-line in `VI` (`F0004E`), "odd for non-interlaced". - **STOP**: games park the 68000 in `STOP #$2000` between interrupts (or turn it into a pure interrupt servant while the GPU runs the game); the core's STOP wake-up is *provisional* in its claims page, which is enough: nothing here depends on its clock count beyond the entry. ## Jerry's controller (`J_INT`, `F10020`) [TRM p.86-87; `JMISC.NET`] Bits 0-5 enable / read pending, bits 8-13 clear: 0 external (`EINT0`, rising edge), 1 DSP (`D_CTRL` bit 1), 2 timer 1, 3 timer 2, 4 UART, 5 I2S. Same gating rule as Tom (enable at the time of the pulse). The OR of the latches leaves Jerry and enters Tom as source 4 **and** as GPU interrupt 1. A game takes "Jerry" interrupts on the 68000 only if both `J_INT` and `INT1` bit 4 are enabled. ## The GPU [TRM p.38-39, 58-61] Five sources; `G_FLAGS` bits 4-8 enable, 9-13 clear (write 1), bit 3 `IMASK`; `G_CTRL` bits 6-10 read the latches, bit 1 `CPUINT` raises Tom source 1 on the 68000, bit 2 `GPUINT0` raises GPU interrupt 0. Source 2 is Tom's PIT, not the video counter: `TOM.NET` l.307 passes `tint` (the PIT's pulse, `MISC.NET` l.160) into the graphics block beside `dint` and `grpintreq`. "If two interrupts arrive within a few ticks of each other, the higher numbered will be serviced first" [TRM p.38]. The Object Processor's GPU object holds the OP until the GPU writes `OBF`, so interrupt 3's latency is **display time**: it shows on screen. ## The DSP [TRM p.98-99] Six sources (above); the same register layout at `F1A100`/`F1A114` with one more enable and latch (where the sixth enable and clear bits sit is a `jrisc` register-layout fact). External 0 and 1 are pins: the CD unit's Butch uses one ([sockets.md](sockets.md)). "Two DMA channels by way of DSP interrupts": the DMA request is an interrupt pin and the acknowledge a GPIO decode [TRM p.132]. ## Who owns what | Thing | Owner | | --- | --- | | `INT1`, `INT2`, `J_INT` latches, enables, edge detectors, the `ihandler` latch | board | | The lines: Jerry to Tom, Tom to 68000 IPL, OP to GPU, Blitter to GPU, timers, I2S, UART, external pins | board | | `G_FLAGS`/`D_FLAGS` enable, clear and `IMASK` bits; the latches read in `G_CTRL`/`D_CTRL`; priority among pending; entry sequence; atomic instruction pairs | `jrisc` core | | The interface between them | the board calls `core.raise_interrupt(n)` (a pulse); the core calls back `on_cpu_interrupt()` for the `CPUINT` write and exposes nothing else | The jrisc core's Phase 0 (`../jrisc-python/docs/phase0-status.md`, read 2026-11-12) puts the latches and the entry sequence in the core as well, so the two sides **agree** on this table; the alternative, the board owning the JRISC interrupt latches, would split one register (`G_CTRL`) across two repositories. Both pages agree the latch is set only while its enable bit is set (`INTER-UA.NET`: `irq AND int_ena`), matching Tom's and Jerry's own controllers here. The DSP's sixth source has its enable at `D_FLAGS` bit 16, its clear at bit 17 and its latch at `D_CTRL` bit 16 (jrisc's reading). Naming: jrisc calls the DSP's timer sources "timer 0" and "timer 1"; this board calls them timer 1 and timer 2, as the Jerry chapter does. ## Not established **U13** the clock at which each pulse is sampled relative to the instruction that caused it (matters for `CPUINT` followed at once by a read of `INT1`); **U14** what the JK latches do when set and clear arrive in the same clock (an `FJK2` with J and K both high toggles, if the cell model is a plain JK: to be confirmed from the cell library); **U15** whether a pending-but-masked DSP interrupt 0 can be lost. All three are decidable by simulating the netlist; none by the manual.