API - winnichenko/BLOB-87 GitHub Wiki
API
You can download a quick API reference sheet suitable for viewing or printing here: PDF or PNG. The Wiki also includes a Cheatsheet for fast reference.
Callbacks
Callbacks are functions that your game defines and that TIC-80 calls automatically. Every game at a minimum must define a TIC
function.
- TIC - Called 60 times per second (60 FPS); the main update/draw callback. Required.
- SCN(n) - Called prior to each scanline render (allowing for palette swaps, etc).
- OVR - Called last and draws to a separate layer (using a separate palette).
Sequencing
-- FRAME BEGINS (60 FPS)
TIC()
SCN(0) SCN(1) ... SCN(134) SCN(135)
OVR()
-- FRAME END
Functions
Drawing
- circ - Draw a filled circle
- circb - Draw a circle border
- elli - Draw a filled ellipse (0.90)
- ellib - Draw an ellipse border (0.90)
- clip - Set the screen clipping region
- cls - Clear the screen
- font - Print a string using foreground sprite data as the font
- line - Draw a straight line
- map - Draw a map region
- pix - Get or set the color of a single pixel
- print - Print a string using the system font
- rect - Draw a filled rectangle
- rectb - Draw a rectangle border
- spr - Draw a sprite or composite sprite
- tri - Draw a filled triangle
- trib - Draw a triangle border (0.90)
- textri - Draw a triangle filled with texture
Input
- btn - Get gamepad button state in current frame
- btnp - Get gamepad button state according to previous frame
- key - Get keyboard button state in current frame
- keyp - Get keyboard button state relative to previous frame
- mouse - Get XY and press state of mouse/touch
Sound
Memory
- memcpy - Copy bytes from one location in RAM to another
- memset - Set sequential bytes in RAM to a given value
- pmem - Access or update the persistent memory
- peek - Read a byte from an address in RAM
- peek4 - Read a nibble (4bit) value from an address RAM
- poke - Write a byte value to an address in RAM
- poke4 - Write a nibble (4bit) value to an address in RAM
- sync - Copy banks of RAM (sprites, map, etc) to and from the cartridge
Utilities
- fget - Retrieve a sprite flag (0.80)
- fset - Update a sprite flag (0.80)
- mget - Retrieve a map tile at given coordinates
- mset - Update a map tile at given coordinates