HCALL wire reference

Every cart-Forth host word compiles to a single HCALL <id> bytecode op. The wire ids are stable; the same ids appear in cart binaries and in the bytecode disassembler. Surface names match the host word in the Forth reference.

Display (0x00 – 0x07)

IdNameStack effectSummary
0x00cls( c -- )Clear the screen to color index `c`.
0x01pixel( x y c -- )Set pixel at (x,y) to color index `c`.
0x02sprite( tile x y flags -- )Draw sprite `tile` at (x,y). `flags` bits: 1=hflip, 2=vflip, 4=wrap. Color 0 in the tile is transparent.
0x03rect( x y w h c -- )Draw filled w×h rectangle at (x,y) in color `c`.
0x04line( x0 y0 x1 y1 c -- )Draw a line from (x0,y0) to (x1,y1) in color `c`.
0x05print( x y c addr len -- )Render text from RAM at (x,y) in color `c` using the 4×6 font; `\n` advances to a new line.
0x06camera( x y -- )Set the camera offset (subtracted from draw coords).
0x07clip( x y w h -- )Set the clipping rectangle for subsequent draws.

Audio (0x20 – 0x24, 4 wired)

IdNameStack effectSummary
0x20note!( pitch instrument voice -- )Trigger MIDI `pitch` on `voice` using `instrument`'s ADSR.
0x21mute!( voice -- )Silence `voice` immediately (no release ramp).
0x22play-pattern( pattern -- )Start the host tracker engine on `pattern`. Loops until `stop-music`.
0x23play-once( pattern -- )Like `play-pattern` but auto-stops on row wrap (one pass). Use for SFX + game-over jingles.
0x24stop-music( -- )Stop the host tracker engine.

Input (0x40 – 0x41, 2 wired)

IdNameStack effectSummary
0x40btn( id -- flag )Push -1 if button `id` is held this frame, else 0.
0x41btnp( id -- flag )Push -1 if button `id` was pressed this frame (rising edge), else 0.