# The TED (MOS 7360 / 8360) One 48-pin chip does nearly everything that is not the CPU: video, two-voice sound, three timers, DRAM control and refresh, ROM chip selects, the keyboard latch, and the system clock, including the **single-clock / double-clock switch** that makes the CPU run at 894 kHz during display fetches and 1.79 MHz elsewhere (NTSC). That switch is this board's cycle-exactness corner. Citations: **TEDDS** (TED 7360R0 preliminary data sheet, Commodore spec. drawing, sheet numbers as printed), **TSHM** (TED System Hardware Manual, sections as printed), **TEDX** (TED extra pages: register bit chart), **MAME** (0.285 closed box, OBSERVED). The scans' OCR is poor; every number below was read in the page text and is to be re-read against the page image before it becomes a constant (the board's M1 task). ## Clocks | Fact | Source | Tag | | --- | --- | --- | | Input clock: 14.31818 MHz +/-70 ppm (NTSC), 17.734475 MHz (PAL), single phase, pin 14 | TSHM 4 (CLK IN); SM parts list Y1 14.31818 MHz | DOC | | Single clock 894 kHz, double clock 1.788 MHz (NTSC) | TEDDS sheet 11 | DOC | | MAME: TED @ 3.57 MHz (NTSC), 3.54 MHz (PAL); 7501 @ 894.88 kHz (NTSC), 886.72 kHz (PAL) | `mame -listdevices plus4`, `plus4p` | OBSERVED | | Arithmetic: 14,318,180 / 16 = 894,886; / 8 = 1,789,773; 17,734,475 / 20 = 886,724; / 10 = 1,773,448 | | arithmetic | | The horizontal position register counts **456 dots, 0 to 455** | TEDDS sheet 11 | DOC | | NTSC: 262 lines (0-261); PAL: 312 (0-311) | TEDDS register 11, register 28 | DOC | With 456 dots a line and one single-clock CPU cycle per 8 dots (14.31818 MHz / 2 = 7.16 MHz dots, / 8 = 894.9 kHz), a line is 57 single cycles or 114 double cycles (NTSC): HYPOTHESIS pending the circuit (the dot clock divisor is not stated in what was read; the PAL divisor is U5). ## The single/double clock switch TEDDS sheet 11 (the clearest statement): during horizontal counts **400-344** (the count wraps at 455), while on raster lines **0-204**, TED outputs single clock: counts 400-432 "processor handshaking", 432-344 character fetches, 304-344 DRAM refresh. Outside this window TED outputs double clock. During the vertical retrace lines (235-261 NTSC, 285-311 PAL by the scan; the OCR is damaged) double clock runs at all times except counts 304-344, which stay single for refresh. With the **blanking bit** (register 6) cleared the screen shows the border colour and double clock runs at all times except refresh. TSHM 4 (PHI OUT, pin 12) gives the same boundaries in a second form ("raster lines 0-204 and horizontal positions 400-344; horizontal positions 304-344"). Register 19's **force single clock** bit inhibits the doubling; register 7's (TEDX: $FF07 bit 5) **freeze** bit stops the horizontal and vertical counters and the timers and forces single clock with refresh (TEDDS register 7 text). **DMA** (TSHM 4.5.2, TEDDS register 20): twice per character row TED takes the bus for both halves of the cycle for 40 consecutive cycles: the attribute fetch on the raster line before the row, the character-pointer fetch on the row's first line. The sequence: (1) the clock comes out at double speed for one cycle and AEC starts toggling; (2) BA goes low; (3) three cycles are given to the 7501 to finish ("BA will go low during phase 1, 3 single clock cycles before TED performs any memory access", TSHM 4 BA pin); (4) 40 cycles of single clock with two TED fetches a cycle; (5) BA high with AEC; (6) 5 single cycles of refresh; (7) 16 double cycles (= 8 single). The DMA timing table gives 46 us DMA, 3 us halt, 5 us refresh, 9 us double speed (OCR partly damaged). What this means for the board (proposal): the scheduler steps TED **per dot or per half-cycle**, and TED, not the CPU, decides when the next CPU cycle begins and how long it is. The CPU core stays a plain per-cycle 6502 (cpu-7501.md); the board calls `cpu.step` cycle by cycle at the moments TED's PHI output rises, and holds RDY (BA) per the sequence above. An instruction's wall time therefore depends on the raster position, which is the whole point of the test programs that time code on this machine. **MAME as a detector here is weak.** Its traced boot advances `totalcycles` by exactly 894,885 a second (2,684,654 cycles over 150 frames of its 50 Hz screen), i.e. at the single-clock rate (mame-oracle.md trap 2). Whatever MAME does about double clock, its cycle counter does not show it, so a cycle-indexed lockstep against MAME cannot judge this corner; only the instruction stream and register-write order can be compared. ## Horizontal and vertical decodes (TEDDS sheets 11-12) Horizontal (dot counts): sync 358-390; equalisation pulse 1 152-170, pulse 2 380-398; blanking 344-416; burst 384-408; character window 432-296; external fetch window 400-288; refresh single clock 288-328 (conflict C4 with the prose's 304-344); character-window single clock 432-296; 40-column screen 451-315; 38-column 3-307; video shift register 446-364; increment blink 336; increment refresh 296-336; character position reload 424; character position increment 432-288; latch character position to reload 290; increment vertical line 376; end of screen 384. Vertical (line counts): end of screen 311 (PAL), 261 (NTSC); vertical sync 254-257 (PAL), 229-? (NTSC); equalisation 251-260 (PAL), 226-235 (NTSC); vertical blanking 251-269 (PAL), 226-244 (NTSC); attribute fetch start/stop around 0-203; frame window stop 204; 25-row window 4-204, 24-row window 8-200. Several of these are OCR-damaged (U6): re-read from the page images at M1. ## Registers ($FF00-$FF3F; TEDDS sheets 12-18, TEDX chart) | Reg | Address | Contents | | --- | --- | --- | | 0-5 | $FF00-$FF05 | timers 1-3, low then high byte | | 6 | $FF06 | TEST, ECM, BMM, BLANK, RSEL (25/24 rows), Y scroll 0-2 | | 7 | $FF07 | RVS OFF, PAL/NTSC (1 forces NTSC), FREEZE, MCM, CSEL (40/38 columns), X scroll 0-2 | | 8 | $FF08 | keyboard latch: a write scans the keyboard lines and latches; a read returns the latch | | 9 | $FF09 | interrupt flags: bit 1 raster, 2 light pen (no pen on TED machines), 3 timer 1, 4 timer 2, 6 timer 3, 7 any; writing 1 clears a flag | | 10 | $FF0A | interrupt mask; bit 0 is raster compare bit 8 | | 11 | $FF0B | raster compare bits 0-7 | | 12, 13 | $FF0C-$FF0D | hardware cursor position (10 bits, 0-999); blinks; text mode only | | 14, 15, 16 | $FF0E-$FF10 | voice 1 frequency low; voice 2 frequency low; voice 2 frequency high (2 bits) | | 17 | $FF11 | sound control: volume 0-8 (9-15 = 8), bit 4 voice 1, bit 5 voice 2 square, bit 6 voice 2 noise, bit 7 D/A mode | | 18 | $FF12 | bitmap base (bits 3-5), ROM/RAM for TED's character and bitmap fetches (bit 2), voice 1 frequency high (bits 0-1) | | 19 | $FF13 | character base, force single clock, status (read-only: CPU sees ROM) | | 20 | $FF14 | video matrix base (bits 3-7); attributes sit 1 KB below | | 21-25 | $FF15-$FF19 | background colours 0-3, border; each 4 colour bits + 3 luminance bits | | 26, 27 | $FF1A-$FF1B | character position reload (10 bits) | | 28, 29 | $FF1C-$FF1D | vertical line counter (9 bits) | | 30 | $FF1E | horizontal position, upper 8 bits (read); writes move it (TEDDS) | | 31 | $FF1F | blink counter (4 bits), vertical sub-address (3 bits) | | 62, 63 | $FF3E, $FF3F | not registers: a write to $FF3E maps ROM into $8000-$FFFF (except $FD00-$FF3F), a write to $FF3F maps RAM | The MAME boot trace's first writes (OBSERVED, detector): `$FF3E` at cycle 8; then the KERNAL's TED initialisation at cycles 416-830 (`$FF06=$1B`, `$FF07=$48`, `$FF0A=$02`, `$FF0B=$CC`, `$FF12=$04`, `$FF13=$D0`, `$FF14=$08`, colours `$71 $5B $75 $77 $6E`). ## Video 25 rows of 40 characters; each character cell's colour comes from the **attribute** byte (4 colour bits, 3 luminance bits, flash bit 7) 1 KB below the video matrix (TEDDS sheets 2-3). 16 colours x 8 luminances = 128 codes; black is the same at every luminance, so the familiar "121 colours" is arithmetic (TSHM 1 says "128 colors"). Modes: standard text, multicolour text, extended background colour, bitmap (320 x 200), multicolour bitmap (TEDDS sheets 3-6). Reverse video by the matrix byte's bit 7 unless RVS OFF; flash by the attribute's bit 7 at the blink counter's ~2 Hz (TEDDS register 31); a hardware cursor. Luminance voltages and colour phase angles (NTSC and PAL) are tabulated in TSHM 4.4.3-4.4.4: a palette can be computed from them (DOC), better than any emulator's table. Open bus: VICE-testprogs `Plus4/openmem` (readme with a photograph comparing a real Plus/4 and xplus4) says a bitmap fetched from ROM space while ROM is not there shows "the last value left in the data bus": a hardware observation the board must reproduce (tier 3). ## Sound Two square-wave voices with 10-bit frequency registers; voice 2 may be white noise instead (selecting both, voice 2 wins); 9 volume levels (TEDDS "Sound"). One output pin (pin 33), integrated by an RC network on the board (TSHM 4). The frequency formula, the noise generator's polynomial and the D/A-mode behaviour are not stated in what was read (U7): the good-enough rule for sound applies; test programs and detectors fill the gap. ## Timers Three 16-bit down counters at the single-clock rate whatever the CPU clock (TEDDS: 894 kHz NTSC, "884 kHz" PAL: conflict C5 with 17,734,475 / 20 = 886,724). Writing a low byte stops the timer until the high byte is written. Timer 1 reloads from the value last written; timers 2 and 3 run free, wrapping from 0 to $FFFF, and a write loads the count directly. Each interrupts on reaching 0. TEDDS warns against more than 125 us between the two writes (reason unstated). ## DRAM and refresh TED generates /RAS, /CAS and MUX; five RAS-only refreshes every raster line right after the character fetches, one row of a 256-row scheme each (TEDDS "Dynamic RAM refresh"; TSHM 2). The refresh counter is visible only through timing (refresh cycles are single clock) and through DRAM decay, which the board does not model. ## The chip rule TED is used by the Plus/4, C16, C116, C232, V364 and C264, all rows of this board; no other family machine uses it. It stays in the board (`ted.py`), pin-shaped. ## Oracles | Oracle | Tier | Decides | Cannot decide | | --- | --- | --- | --- | | TEDDS, TSHM, TEDX | 2 | registers, decodes, windows, DMA sequence | anything the scans' OCR damaged until re-read; PAL divisors; sound formulas | | VICE-testprogs `Plus4/openmem`, `TED/write-scanline-coarse` | 3 (openmem has a real-machine photograph) | open bus, mid-line writes | timing tables | | FPGATED (Istvan Hegedus; GPL-3.0, "cycle exact" by its author) | 4 | detector only, from emu-tools-gpl if built | anything as a judge | | plus4emu (GPL-2.0), YAPE (GPL-2.0), VICE xplus4 (GPL-2.0+) | 5 | detectors from emu-tools-gpl | | | MAME 0.285 | 5 | boot order of register writes | timing (trap 2) | **No die-level or hardware-capture source for TED was found.** The highest judge is the data sheet and the hardware manual, then test programs whose readmes record real-machine results. Open decision 4 asks whether to look for a TED die project (none met tonight).