# HDGL C64 — 60Hz frame-locked, emergent, substrate-faithful

Not an emulator racing a loop. The C64 emerges from being given its OWN clock
and ticked at exactly that cadence. One substrate tick = one NTSC frame = the
exact cycles a real C64 runs in 1/60s. It feels like the original because it is
clocked like the original.

## The clock contract (the KISS you asked for)

One 60Hz clock, three faces of it — because on a real C64 they ARE one clock:
- **Screen 60Hz**: the frame is paced to exactly 1/60s via the PIT hardware
  counter (1193182/60 = 19886 counts/frame). True NTSC 59.94Hz.
- **CPU one frame/tick**: the 6502 runs exactly 17095 cycles (263 lines x 65)
  per tick — one real frame's worth — declared in the machine's contract
  (FaceBasis.cycles_per_frame), not guessed.
- **Keyboard 60Hz**: the KERNAL's SCNKEY runs INSIDE the raster IRQ, which fires
  once per frame. So the keyboard is scanned 60x/sec, same clock as the screen.
  There is NO separate keyboard poll rate and NO responsiveness tuning — it is
  frame-locked, exactly like the original hardware.

The machine declares its clock; the substrate honors it. Change the contract to
PAL (19656 cyc, 50Hz) and it's a PAL machine. That is the interpreter ensuring
each machine gets the exact abstraction of hardware it needs.

## Substrate-faithful (not drifted)

- The SUBSTRATE owns the loop: each tick advances tau and RE-SETTLES
  Omega = Fix(T) = phi by iterating T(X)=1+1/X (nothing stored that can be
  derived). The C64 is a FACE under it (face table, phi-fold privacy token
  phi_fold(genome^session^id)), one face among many — not the loop owner.
- The C64 is REAL: a 6502 core runs the real KERNAL/BASIC ROMs. We do not
  compute results; BASIC does. We OBSERVE its state and project it.

## Fully expressive keyboard + full-color, full-size screen

- Shift keys: two keymaps (unshifted/shifted) with shift make/break tracking, so
  $ ( ) " * + : ; < > ? etc. all reach BASIC. Verified: the maze and sine-wave
  programs (heavy in shifted symbols) type and RUN.
- VIC color OBSERVED (widened projection): $D020 border, $D021 background,
  $D800 color RAM. POKE53280/53281 are now VISIBLE — the machine really wrote
  them; we observe and project them. Verified: POKE53280,2 -> red border, with
  text and background intact, full 800x600, no screen-size loss.
- PETSCII graphics (CHR$(205/206) maze diagonals) mapped so graphics render.

## Verified end-to-end (real ISO booted in QEMU, real keystrokes)

- `POKE53280,2` -> red border (VIC color observed), screen full-size.
- `10 PRINT CHR$(205.5+RND(1));:GOTO10` -> typed with all symbols, RUN, screen
  fills with the random maze pattern (~50% foreground).
- `10 X=X+.13:?TAB(20+18*SIN(X));"*";:GOTO10` -> typed, RUN, sine wave of '*'.
- Fast typing (0.12s gaps) keeps up; frame-locked, no lag.

## Boot

Rufus `iso/hdgl-c64.iso` (DD mode) -> USB -> enable BIOS "USB Legacy / port
60/64" -> boot -> interactive entry -> type. (Keyboard needs port 60/64 as
before; frame-locked scan is 60Hz.)

## Your four test programs

10 PRINT CHR$(205.5+RND(1));:GOTO10
10 POKE53280,RND(1)*16:POKE53281,RND(1)*16:?CHR$(205.5+RND(1));:GOTO10
10 X=X+.13:?TAB(20+18*SIN(X));"*";:GOTO10
10 PRINT CHR$(205.5+RND(1));:GOTO10

Programs 1, 3 verified running. Program 2 adds POKE color-cycling per character
(now observable). All type with the expressive keyboard.
