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.
0x08blit( sheet sx sy w h dx dy flags -- )GameTank only: copy a w×h rect from sprite sheet `sheet` at (sx,sy) to the framebuffer at (dx,dy). `flags` bits: 1=hflip, 2=vflip, 4=transparent, 8=fill.

Audio (0x20 – 0x27, 8 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-music( pattern -- )Start the music slot on `pattern`, looping. Cart-Forth alias: `play-pattern`.
0x23play-once( pattern -- )One-shot SFX on auto-allocated slot. Equivalent to passing pattern + -1 to `play-sfx` (e.g. `2 -1 play-sfx`).
0x25play-sfx( pattern slot -- )One-shot SFX; `slot` 0..=3 or -1 for auto.
0x26loop-sfx( pattern slot -- )Looping SFX; same slot semantics as `play-sfx`.
0x24stop-music( -- )Stop the music slot only.
0x27stop-sfx( slot -- )Stop SFX slot 0..=3 or all SFX (-1).
0x28set-bpm( frames-per-row -- )Set the music slot's tempo (frames per row, 2..=64). Takes effect at the next row boundary. No-op when music is stopped; never affects SFX slots.

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.