-
Notifications
You must be signed in to change notification settings - Fork 0
Home
Welcome to the lolbot-iichan's TIC-80 fork wiki!
This fork introduces Brainfuck language scripting for TIC-80 fantasy console.
There are some things specific to current implementation of Brainfuck in TIC-80.
Memory is looped, there are 65536 16-bit memory cells accessible with <
and >
operations
#
can be used used to comment out any text until the line break, even including brainfuck commands (e.g. >#>
is an equivalent of >
). However, you can write comments without #
mark as long as they don't have any punctuation ^_~
There are 9 commands:
-
<
and>
,[
and]
,+
and-
works as usual -
.
appends current cell value to a memory buffer, not to interpreter's console as usual -
,
calls API function with that buffer (first value - id# of API function, other values - params) and stores result in current cell(s) -
?
prints a trace with current cell id# (0~65535) and value
Another important Brainfuck extention is macros support:
- Macros are used for code substitution, not function calls!
- Define macro NAME with
/NAME/<code>/
. Macro name can contain any characters except/
and\
. - Use macro NAME with
\NAME\
. You can use macros inside other macros, but loops are prohibited - Built-in macros for API functions are pushing API fuction id# and resetting current cell (e.g.
\cls\
is an equivalent of[-]++++.[-]
) - API macros don't call API functions,
,
is used to call an API function (e.g. use\cls\,
&\btn\++.,
for callingcls()
&btn(2)
)
Execution rules:
- code outside of macro definitions is executed once, before game starts, all cells are zeroed before it's run
- code MUST contain TIC macro, which is executed 60 times per second, cell #0 is zeroed before it's run
- code MAY contain scanline macro, which is executed 136*60 times per second, cell #0 is set to scan line's number before it's run
- code MAY contain OVR macro, which is executed 60 times per second, cell #0 is zeroed before it's run
TIC-80's font
, print
and trace
API functions reqiered strings as first argument.
- Brainfuck version of those APIs require string length as first argument followed by given amount of arguments considered string bytes (e.g.
\trace\+++.++++++++++++++++++++++++++++++.++.+.,
is tracing "!#$" string). - If string length is 0, then next argument is used for "%d" sprintf (e.g.
\trace\.++++++++++++.,
is tracing "12" string)
Some TIC-80's API functions are not returning any values. In this case memory cells are left as is.
-
mouse
API function currently writes result (x,y,lmb,mmb,rmb) to 5 (five!) memory cells -
time
API function currently writes result (sec,msec) to 2 memory cells
pmem
API function uses int16 memory cells, not int32 as in usual TIC80's API
There are some API demos similar to <API> DEMO / <LANG>
samples from TIC-80's Demos section
Run them, hit ESC & select "Exit to TIC-80" to read the source code. Download cartridges from here.
- http://lolbot-iichan.github.io/TIC-80/bin/html/bf_btnp.html - similar to BTNP DEMO / LUA
- http://lolbot-iichan.github.io/TIC-80/bin/html/bf_circ.html - similar to CIRC DEMO / LUA
- http://lolbot-iichan.github.io/TIC-80/bin/html/bf_coordinates.html - similar to COORDINATE SYSTEM DEMO / LUA
- http://lolbot-iichan.github.io/TIC-80/bin/html/bf_demo.html - similar to default cartridge
- http://lolbot-iichan.github.io/TIC-80/bin/html/bf_exit.html - similar to EXIT API COMMAND DEMO (LUA)
- http://lolbot-iichan.github.io/TIC-80/bin/html/bf_font.html - similar to FONT / LUA
- http://lolbot-iichan.github.io/TIC-80/bin/html/bf_fps.html - similar to FPS
- http://lolbot-iichan.github.io/TIC-80/bin/html/bf_minmax.html - similar to MIN/MAX DEMO / LUA
- http://lolbot-iichan.github.io/TIC-80/bin/html/bf_mouse2.html - similar to MOUSE DEMO 2 / LUA
- http://lolbot-iichan.github.io/TIC-80/bin/html/bf_mset.html - similar to MSET DEMO / LUA
- http://lolbot-iichan.github.io/TIC-80/bin/html/bf_pmem.html - similar to PMEM DEMO / LUA
- http://lolbot-iichan.github.io/TIC-80/bin/html/bf_scanline.html - similar to SCANLINE DEMO / LUA
- http://lolbot-iichan.github.io/TIC-80/bin/html/bf_sfx.html - similar to SFX DEMO / LUA
- http://lolbot-iichan.github.io/TIC-80/bin/html/bf_time.html - similar to TIME DEMO / LUA