# The DMA blitter Midway's sprites and backgrounds are drawn by a custom DMA chip that copies images from the image ROMs into VRAM, not by the TMS34010's graphics instructions (cpu-needs.md). It is the board's largest unknown: **no document describes its registers or its timing.** Everything below the hardware section is a reading of MAME's bus traffic (OBSERVED) and marked HYPOTHESIS where it interprets it. ## The hardware (DOC: manuals' parts lists and schematics, read by eye) - **Y-unit:** "IC, Custom Asic" in Smash T.V.'s CPU parts list (16-3044-K-101, Sept 1990), beside PLDs named "Video RAM Control", "Video RAM Sequencer", "Image ROM Control", "Miscellaneous Control", "Autoerase Controller", "Color RAM Control", "Address Decode", "Local Control". No data sheet or pin list found. - **T-unit:** **DMA2**, UE13, part 5410-12862-00 (MK II and NBA Jam parts lists). The NBA Jam manual's CPU-board schematic (16-43123-101, the DMA2 sheet) shows a 160-pin package with: a 32-bit image-ROM data bus (ID0-ID31 from `IDAT00-31`) and image-ROM address RA1-RA22 (to `IADDR`); a 32-bit VRAM data bus (VD0-VD31) and multiplexed VRAM address VA0-VA8 with per-bank RAS/CAS strobes (`VRAS`, `VCAS`, `VWR`); a 16-bit host data bus HD0-HD15 and four register-address lines (`LADDR0-3`); `DMA_CS`, `WR`, `TR/OE`, `RESET`; `CLK` (`DMA_CLK`), `VCLK`; `HALTZ` / `BLTAZ` (named on the sheet's cross-reference `BLT_REQ`, `DMA_BAK`), `IRQZ` (`DMA_IRQ`), `DMAGO`, `PAL`, `RAENZ`, `VIDENZ`. On the neighbouring sheet the Actel 1020 (UF5, A-17480) takes `DMA_HRQ` and `HLDA` and drives `GSP_HAK`, `GSPHRQ` and `DMA_BSY`: the DMA asks for the local bus and the TMS34010 grants it through HOLD/HLDA. Four register-address lines match the 16 registers the T-unit games write (below). - **Wolf:** not documented here (no Wolf manual pinned); its games write the same 16 registers in the same way (OBSERVED). ## The registers, as the games use them (OBSERVED; meanings HYPOTHESIS) Taps on MAME's bus (`scripts/mame/tap.lua`, then `scripts/dma_stats.py`); register *n* is at base + 16*n (16-bit registers, bit-addressed). ### Y-unit (10 registers; the games write the mirror at `01A80000`) `term2`, frames 600-605: 117 transfers a frame, every one written in the order reg 8, 9, 6, 7, 4, 5, 2, 3, 1, 0; the write to **reg 0** comes last with bit 15 set (`E018` 696 times, `8018` 6), and reading reg 0 back shows bit 15 set while the transfer runs and clear when it ends (`8018` then `0018`). | Reg | Values seen | Reading (HYPOTHESIS) | | --- | --- | --- | | 0 | `E018`, `8018` | control: bit 15 start / busy; the low bits a mode (transparency, flip, pixel depth; not separated) | | 1 | `000F`, `0017`, `0007`, `0031` | an offset or mode word | | 2, 3 | e.g. `A278`, `0401` | the image-ROM bit address, low and high words | | 4, 5 | e.g. `017A`, `0000` | destination X, Y | | 6, 7 | `0008 x 0008` (384 times), `000C x 000D`, `0016 x 0012` | width, height | | 8, 9 | `3D3D`, `0303`, `0707` | a colour or palette byte, duplicated in both halves | ### T-unit and Wolf (16 registers) `mk`, frames 2700-2705 (a fight in the attract demo, snapshot `snap/mk-2700.png`): 153-155 transfers a frame, written reg 10, 11, 8, 9, 6, 7, 4, 5, 2, 3, 0, then **reg 1** last with bit 15 set (`E042` 641 times, `E052` 132, `E058`, `E048`, `E002`). `umk3` writes regs 4-11 at `01A00040-B0` and regs 0-3 through the mirror at `01A80000-30`, the same register set. | Reg | Values seen (`mk`, `umk3`) | Reading (HYPOTHESIS) | | --- | --- | --- | | 0 | `0000` mostly; `2500`, `7F00`, `8A00` | an offset (a skip or a constant colour) | | 1 | `E042`, `E052`, ... | control: bit 15 start / busy, the rest the mode | | 2, 3 | e.g. `4A0A`, `0460` | image-ROM bit address | | 4, 5 | e.g. `006C`, `0180` | destination X, Y (Y includes the page: `0180`) | | 6, 7 | `0028 x 0013`, `0090 x 0012`, ... (`umk3`: `0044 x 0072`, `00C4 x 0080`) | width, height | | 8, 9 | `1E1E`, `1919`, `0F0F` | palette (the duplicated byte, as on the Y-unit) | | 10, 11 | `0100`; reg 11 also `0300`, `0380`, `03C0`, `0360`, `03A0` | **scale**, 8.8 fixed point (1.0 = `0100`): only reg 11 varied, in `mk` | | 12, 13 | written in pairs once a frame: (`0100`, `01FD`) and (`0000`, `00FD`) | a vertical clip window: lines 0-253 of the page at `0100` or `0000`, so 254 lines, the visible height; the pair alternates, which reads as double buffering | Reading 13 against the screen height (254 lines visible, start-here.md) is the strongest check these readings have so far. ## How much it draws (OBSERVED counts; pixels HYPOTHESIS: reg 6 x reg 7) | Set | Transfers per frame | Status polls per frame | Sum of width x height per frame | Per second | Screens' worth | | --- | ---: | ---: | ---: | ---: | ---: | | `term2` 600-605 (Y; a quiet screen) | 117 | 120 | 10,412 | 0.57 M | 0.1 | | `mk` 2700-2705 (T; a fight) | 154.5 | 4,590 | 203,327 | 11.1 M | 2.0 of 400 x 254 | | `umk3` 1800-1805 (Wolf) | 40.2 | 43 | 216,540 | 11.8 M | 2.1 | Two full screens a frame (a background plus characters) is what a fighting game would draw, which supports the width-times-height reading. These are MAME's opinion of what the games ask for, not the hardware's speed. ## Timing: unknown How many clocks a pixel takes, how transparency and scaling change it, and whether the DMA releases the bus between rows are **unknown** (U1-U3 in the brief). What constrains a model: - The CPU waits for the DMA: `mk` polls the busy bit about 4,590 times a frame. The number of polls is a function of the DMA's duration, so the CPU's instruction stream depends on the DMA's timing. A wrong DMA speed changes every later instruction count but not the picture. - Midway's own diagnostic tests the DMA: `yunittst` has DIP switches "Harsh DMA Test" and "Quick DMA Test". It is the only judge with a maker's verdict (validation.md). - MAME's DMA timing is a model of unknown provenance; it is a detector. Recommendation (provisional, a chip-level default): model the DMA at **transaction level**: each transfer computes its pixels in the hardware's order and a duration from a per-pixel cost plus a per-row cost, holds the CPU off the bus for that time, and raises the done state at its end. The costs start FITTED to MAME's busy durations, then to `yunittst`'s DMA tests, and stay FITTED until a measurement exists.