# Controllers: analog joysticks, buttons, light pen, 3D Imager Source tags as in [start-here.md](start-here.md). Extra: **[lp]** `lpfaq10.txt` and `DVE.TXT`, **[ze]** Zack Ethridge's `3DGOGGLE.TXT` (1995), **[td]** Tony Duell's `LIGHTPEN.TXT` (1995), all in Vide's `documents/` at the pinned revision (tier 3: people with consoles, measurements without method). ## The two ports Two DB9 ports, J202 and J203 [sch]. Each carries four button lines, two pots, +5 V, -5 V and ground. | | Port 1 | Port 2 | | --- | --- | --- | | physical position | **right** | **left** | | redraw label | J203 "RIGHT CONTROLLER" | J202 "LEFT CONTROLLER" | | buttons | SW0-SW3 = PSG IOA0-IOA3 | SW4-SW7 = PSG IOA4-IOA7 | | pots (mux Y half) | POT0 (X), POT1 (Y) | POT2 (X), POT3 (Y) | | extra wiring | **SW3 -> 6809 /FIRQ** (3.3k pull-up R204) | **SW7 -> VIA CA1** (3.3k pull-up R205) | Wiring from the redraw at 300 dpi (2026-11-12); "port 1 = right, port 2 = left" from [lp] ("plug the Lightpen into controller port 2 (left port) and a standard controller into controller port 1 (right port)"); bit order from the Executive's `Read_Btns` and MAME's `BUTTONS` port (bits 0-3 player 1, 4-7 player 2); pot order from MAME's `m_io_contr` array (`CONTR1X, CONTR1Y, CONTR2X, CONTR2Y` indexed by PB2:PB1). MAME's light-pen setting "left port" pulses CA1, "right port" pulses FIRQ: consistent. Which DB9 pin carries which signal: [td] puts SW7 on pin 4 of the left port; [ze]'s goggle pin numbers (3 in, 2 out) use a numbering we did not reconcile with the redraw (U14). **Correction of the task brief (C2):** FIRQ is not on the cartridge port. The cartridge port has /HALT (1), /NMI (34) and /IRQ (36); /FIRQ (6809 pin 4) is wired only to button line SW3 [sch]. So pressing button 4 on controller 1 asserts FIRQ for as long as it is held (a level), and any device on port 1's pin for SW3 can interrupt the CPU. The Executive leaves the FIRQ vector pointing at RAM `$CBF5` and never clears I or F (its only `ANDCC` is `#$FE`, clearing carry [bt]), so after reset neither IRQ nor FIRQ is taken until a cartridge program clears the mask. ## Buttons Active low, 680 ohm series resistor and 1 nF to ground per line [sch], read through PSG register 14 with the PSG's port A as an input. `Read_Btns` at `$F1BA` [bt] sets DDRA `$00`, selects register 14, reads with port B `$09`, restores. The four lines SW3 and SW7 are also live interrupt/edge inputs whatever the program reads. ## Joysticks: successive approximation The CD4052's second half routes one pot (POT0-3, chosen by PB2:PB1, enabled by PB0 = 0) to the + input of comparator IC304B (C307 1 nF on that input); the DAC voltage is on the - input; the output, through R314 2.2k and clamped by D301, is COMPARE on **PB5**: high when the pot is above the DAC [sch]; MAME `via_pb_r` computes the same (`pot > (signed char)PORTA` sets bit 5). Each pot is 330k with 1 nF to ground at the stick [sch]. `Joy_Analog` / `Joy_Digital` at `$F1F5` / `$F1F8` [bt], per enabled pot: select the pot with the mux on, write `$00` to the DAC, mux off, a settling loop (`LDB #$60` / `INCB` / `BPL`: 32 passes of 5 cycles = 160 cycles), mux on, then either one comparison against `$40`/`$C0` (digital mode: result -$40, 0 or +$40) or a binary search from bit 7 down to the resolution in `Vec_Joy_Resltn`, testing PB5 after each DAC write. So the board must give PB5 the comparator's state **as of the cycle of the read**, with the DAC and pot voltages as they are then; the comparator's own response time and the 1 nF settling are not modelled by any emulator read here (MAME computes it at the read) and are U13. Host input: each pot is a signed 8-bit value (the DAC code the comparator would flip at). ## Light pen The official VT3600 pen plugs into port 2 [lp] and "sends a negative edge pulse to 'button 4' when it senses a certain intensity of light" [lp]: SW7, so VIA **CA1**. The three released titles enable the CA1 interrupt: a scan of the images for `LDA/LDB #imm` then a store to `IER` found `$82` (CA1 enabled) in Art Master, Melody Master and AnimAction ([ran], `scripts` not kept: a 20-line byte-pattern search). Vide's `DVE.TXT` [lp]: "The lightpen will generate an interrupt on the PIA line CA1". Engine Analyzer (a later program) uses port 1 [lp], so SW3 and FIRQ. Model: the host supplies a pen position and a sensitivity; the board, from the beam segments of [analog.md](analog.md), raises SW7 (or SW3) low for a pulse when a lit segment passes within the sensitivity radius, at the cycle the beam passes. MAME does this geometrically per vector, with `d2 < 2e10` in its screen units; Vide has a light-pen delay setting of 0 (read from its source in Phase 0: HYPOTHESIS). The pulse width and the pen's response delay are U15 (no source). ## 3D Imager A motor-driven colour wheel in goggles, on port 2 [ze], [mame]: - **Index:** a photo sensor at a hole in the wheel produces a negative pulse, "1.05 msec" wide every "37.5 msec" in Narrow Escape (26.7 Hz) [ze], on SW7 (IO7) and so also CA1 [mame: "Index hole sensor is connected to IO7 which triggers also CA1 of VIA"]. - **Motor:** the program drives IO6 as an output with a negative pulse of "between 12 and 16 msec" per revolution [ze]; MAME: "IO6 controls the imager motor" and models the wheel's speed with "Guessed parameters" (inertia, damping, torque) [mame]. - The program times each eye's colour sectors from the index pulse; MAME's per-game wheel angles are tables keyed on the cartridge title (`NARROW`, `CRAZY COASTER`, `3D MINE STORM`). The board's job is the electrical part: an IO6 output callback, an SW7/CA1 index input. The wheel's mechanics and the colours are a host-side device with named parameters, like the analog model. Titles in the library: 3D Crazy Coaster, 3D Mine Storm, 3D Narrow Escape (No-Intro); Sledge 3D is a 3,671-byte sample whose imager use was not checked. ## What judges this Nothing above tier 3: the schematic for wiring, the Executive for the protocol, [ze]'s one measured pulse train, MAME (tier 5) for behaviour. The joystick and button paths are fully digital at the VIA and PSG and are compared exactly (L1/L2 in [analog.md](analog.md) ยง6); the pen and imager are compared by the programs' reactions, not by timing.