# The MDEC Sources: psx-spx `macroblockdecodermdec.md` at `6d7d1bc` (tier 3); ps1-tests `mdec/*` (MIT: `4bit`, `8bit`, `frame`, `movie` with expected `vram.png`, and `step-by-step-log` with its `psx.log` of the status register after every word); PeterLemon `MDEC/` EXEs. ## What it is (DOC psx-spx; DIE psxdev) A macroblock decoder on the CPU chip (psxdev cpu.md: one revision change, 90025 to 90048, fixed "some bug in MDEC"). Two ports: 1F801820h command/data in and data out, 1F801824h status and control. Fed by DMA0 (MDECin) and drained by DMA1 (MDECout). Commands: 1 decode macroblocks (4/8/15/24-bit output), 2 set quantisation tables, 3 set the IDCT scale table. psx-spx gives the run-length decode, the dequantisation, a "fast" and a "real" IDCT core, YUV-to-RGB and the zigzag tables in pseudo-code. ## Chip rule On the PlayStation's CPU die, so it appears wherever that chip does (the arcade boards), but it is not a CPU: **it stays in psx-python** (`psx_python.mdec`), as a peripheral on the bus with DMA channels. ## What the specification must model - The exact arithmetic of the hardware IDCT (rounding and clamping), because FMV pictures are compared pixel by pixel against ps1-tests' `vram.png` (MIT, presumed console captures). psx-spx offers two IDCT versions; **U1: which one the silicon computes**, judged by those pictures. - The status register's FIFO and busy bits word by word (ps1-tests step-by-step-log). - Throughput: how long a macroblock takes (games pace FMV on DMA1 completion). No document gives it (**U2**); fit to ps1-tests `frame`/`movie` timing and mark FITTED. - The rev 90025 MDEC bug (U3: what it was; early SCPH-1000 only, a later switch). ## Modelling level (proposal) **Transaction level**: a macroblock decoded as a unit with its busy time, words appearing at the output FIFO at the rate the fit gives.