# The GTE (COP2): where it lives and what it must model Sources: psx-spx `geometrytransformationenginegte.md` at `6d7d1bc` (tier 3, facts only); ps1-tests `gte/test-all` (MIT, tier 3: 1150 cases "generated by gte-fuzz", whose README says it "can be used to verify against real console"; `psx.log` reports 1150 passed, 0 failed, taken to be a console run - to confirm with the author's notes, U13); amidog `psxtest_gte` 1.4 (no licence: run only; v1.1 added timing tests, v1.2 fixed its RTPS/RTPT flag expectations after smf's report). ## Decision: the GTE belongs in this repository, as its own module The chip rule: CPUs always get their own core; a non-CPU chip used by one machine stays in the board; a chip gets its own repository when another emulator in the family could use it. Who uses a GTE? | User | CPU chip | Notes | | --- | --- | --- | | PlayStation, PSone, Net Yaroze, DTL dev kits | CXD8530 / CXD8606 | psxdev cpu.md: the GTE is on the CPU die | | Sony ZN-1 / ZN-2 (Capcom, Taito, Tecmo...), Namco System 11, Konami GV / System 573 / Twinkle | the same chips: MAME lists CXD8530AQ/BQ/CQ at 67.7376 MHz for `sfex` (zn.cpp), `tekken` (namcos11.cpp), `konamigv`, `gq863` (twinkle.cpp), `dstage` (ksys573.cpp) | OBSERVED `mame -listxml`, 2026-11-25; drivers not read | | Namco System 12 | **CXD8661R at 100 MHz** (`tekken3`, `mrdrillr`, namcos12.cpp) | OBSERVED `-listxml`: a faster derivative (50 MHz core?), HYPOTHESIS that it keeps the same GTE | | PS2 IOP (PS1 mode) | an IOP derived from the same CPU | whether the GTE is present and used in PS1 mode is **unknown** (HYPOTHESIS; U14). Era 4, far off | So the GTE is not single-machine, but **it never appears without this CPU**: every known GTE sits on the same die as the CW33300 and is reached only through its COP2 interface (MFC2/CFC2/MTC2/CTC2/LWC2/SWC2/COP2 imm25), with the CPU's interlocks deciding its timing. A separate repository would have exactly one consumer (this core) and would put the interlock (COP2 busy -> CPU stall) across a pin. Recommendation, in Open decisions: **module `r3000a_python.gte` here**, attached through a declared coprocessor interface, so that a board without a GTE (a plain R3000 board, if the family ever builds one) runs the core with COP2 unusable. Extract it only if a consumer appears that needs a GTE without this CPU (none is known). ## What it must model - 32 data and 32 control registers (psx-spx register summaries), with their odd reads: IRGB/ORGB conversion, SXYP pushing the SXY FIFO, LZCS/LZCR counting leading bits, H "BuggyU16" (reads sign-extended, psx-spx), FLAG bits 30-12 with bit 31 the OR of the error bits. Each needs a TEST ROM judge (ps1-tests test-all covers "all registers"). - 22 commands (psx-spx "GTE Command Summary"), selected by bits 0-5 only (bits 20-24 are a "fake" number ignored by hardware), with sf, lm and MVMVA's mx/v/cv fields; MVMVA with cv=2 (FC) is "bugged" (psx-spx, documented formula). - **Saturation and flags** per stage: 44-bit MAC overflow checks, IR clamping per lm, SZ3 and SXY limits, the RTPS/RTPT IR3 flag rule (psx-spx: FLAG.22 checked as if lm=0, IR3 stored per lm). - **The division** is not exact: an unsigned Newton-Raphson step with a 257-entry table (psx-spx "GTE Division Inaccuracy", which also gives the generator formula `max(0, (0x40000 // (i + 0x100) + 1) // 2 - 0x101)`); results saturate to 1FFFFh. The spec generates the table from the formula and checks it against the printed table (a fact, not code). ## Timing Each command has a fixed cycle count (psx-spx headings: RTPS 15, RTPT 23, NCLIP 8, AVSZ3 5, AVSZ4 6, MVMVA 8, SQR 5, OP 6, NCS 14, NCT 30, NCCS 17, NCCT 39, NCDS 19, NCDT 44, CC 11, CDP 13, DCPL 8, DPCS 8, DPCT 17, INTPL 8, GPF 5, GPL 5; DOC, judged by amidog's timing tests). The CPU runs on while the GTE computes and **stalls** on the next COP2 command or GTE register read until the command finishes (psx-spx "GTE Load Delay Slots"). MFC2/CFC2 have a one-instruction load delay (Tekken 2 breaks without it); MTC2/CTC2 writes take 2-3 cycles to land (IRGB 3) (psx-spx "Store Delay", U15). LWC2/SWC2 "have a delay of 2 instructions ... Any? That's wrong!" (psx-spx's own doubt, U16). The spec models the GTE as a unit with a `busy_until` cycle stamp the core consults: that is exactly the interlock the hardware has, and nothing finer is evidenced. ## Interrupts on a COP2 command See cpu.md: the command executes, EPC points at it (**U2**). This is the one GTE fact that changes game pictures directly (Crash, Spyro, Jinx).