ROAD-PICA RC1 - ROAD 1.0 RC2 for the PicoCalc
=============================================================

The pseudo-3D racer ROAD, ported from the Pico Computer 3 (HDMI) to the
ClockworkPi PicoCalc. Same game, same tracks, same pictures and music.
The game uses the top 320 x 240 of the 320 x 320 LCD, with a black bar below.

IMPORTANT FIRST
  - Tested with PicoMite firmware V8.00.00b2 - the normal PicoMite for the
    RP2350, NOT WebMite (WebMite has no buffered LCD driver).
  - ROAD-PICA needs the BUFFERED LCD driver:
      OPTION LCDPANEL ST7365PBUFF, PORTRAIT, GP14, GP15, GP13
    Without it the colours cannot be set (error "Invalid for this display").
  - ROAD-PICA writes into FLASH SLOTS 2 AND 3 (the road and the background
    pictures of the current track). Anything saved there is overwritten.
    If a slot holds other data, ROAD-PICA asks first (Y = overwrite,
    N = quit, nothing written). Flash slot 1 is never touched.

NEEDS
  PicoCalc with a Pico 2 or Pico 2 W (RP2350). The RP2040 Pico is too small.

ONCE AT THE PROMPT (one line at a time, the PicoCalc restarts after some of them)
  The LCD SPI pins are already set on the PicoCalc; only the driver is changed.
  After OPTION LCDPANEL DISABLE the screen stays dark: type the next line blind
  or enter it over the serial console (e.g. TeraTerm).
  OPTION LCDPANEL DISABLE
  OPTION LCDPANEL ST7365PBUFF, PORTRAIT, GP14, GP15, GP13
  OPTION LCDPANEL CONSOLE
  OPTION CPUSPEED 300000                 (300 MHz: the display SPI runs at 50 MHz)
  OPTION COMPILE ON                      (important: about 3x faster)
  OPTION MODBUFF ENABLE 192              (room for the track music)
  If the colours look inverted, add  , , INVERT  to the LCDPANEL line.

COPY AND START
  Copy the folder ROAD-PICA to the SD card, then:
    CHDIR "B:/ROAD-PICA"
    RUN "ROAD-PICA"
  Loading a track takes longer the first time: the road, the roadside sprites
  and the mini map are worked out once and kept on the card (roadN.seg,
  roadN.spr, roadN.map). They are made again when roadN.trk changes (size or
  date), so your own tracks work as before. After that a track loads in 4-5 s.

KEYS
  arrows (or 2 throttle, 1 brake, 9 left, 0 right), P pause, ESC menu, M music, I info, T map
  Key M in the race switches between the music MOD and the effects MOD (only the
  effect samples, no music). OPTIONS - RACE MUSIC OFF: the race starts with the
  effects MOD.
  The info line (I) shows fps, the time per part (PR = picture output) and H = free memory in KB.
  The keys are also shown on the last page of the credits in the title.

WHAT IS DIFFERENT TO THE PC3 VERSION
  - no PSRAM: road and sprite data are packed into integers (same values); the road
    is built in the framebuffer while loading and then read from flash slot 2
  - sprite sheet in layer buffer L, background pictures from one flash slot
  - colours: MAP of the buffered LCD driver (256 entries) recolours the 16
    framebuffer colours, so every track keeps its own palette
  - the road box lists are shorter; when one is full it is drawn at once
  - sound only from the track MOD (music + effect samples): no engine mode (key E)
  - every CONST is written as its value (each one would cost a variable record);
    the CONST lines stay as comments, so the names are still there to read
  - at most 3200 roadside sprites per track, kept in the unused rows 240-319 of the
    layer buffer L; a track with more keeps an even share
  - the view follows the frame time (target 13 fps): road 65 to 100 segments
    (PC3: 120), scenery 50 to 75 (SCENERY, max, min in a track file)
  - 15 cars fewer than on the PC3 (CARS in the track file minus 15)
  - race times: factors 1.18 veteran / 1.33 rookie (PC3: 1.15 / 1.30);
    rookie +1 s at the start and 1 s less per bonus, veteran +2 s at the start
    and 1 s less per bonus from lap 2 on
  - the MOD player needs about 26 KB in one piece: 27 KB are reserved at the start
    and handed over just before PLAY MODFILE
  - a short wait (100 ms) before every PLAY MODFILE: without it the PicoCalc could
    freeze when a new MOD was loaded right after a picture had gone to the LCD
  - loading bar in the last 3 rows of the game picture
  - BACKGROUND PICTURES: the PC3 keeps every LAYER picture of a track in its own
    flash slot (4-8). The PicoCalc has only one slot for them, so all LAYER
    pictures of track N are packed into ONE picture, roadNbg.bmp:
      - 4-bit BMP (16 colours, the 16 standard framebuffer colours), 6 x less
        to read than 24 bit
      - shelves as wide as the widest layer; the layers in the order of the LAYER
        lines, each one into the first shelf with room (width left and not
        higher than the shelf), else a new shelf below
    ROAD-PICA works out the same places while loading. The single LAYER pictures
    (roadNsky.bmp etc.) stay in the folder: their size is read from them.
    A track with LAYER lines but without roadNbg.bmp gets a simple background.
  - no OPTION SYMBOLS OFF: it would save memory, but then the program is not compiled

IF SOMETHING GOES WRONG
  Please note the error message and the line number. If the colours stay
  strange after an error:  MAP RESET : MAP SET

ROAD 1.0 (c) Matthias (homa) with Claude, 2026 - based on Jake Gordon's
javascript-racer (MIT) and Lou's Pseudo 3d Page. MMBasic by Geoff Graham and
Peter Mather. The manuals of ROAD 1.0 RC1 describe the game and the code.
