pete286/jiles.jor

63 lines
1.4 KiB
Plaintext
Executable file

: blah ' seremit task-emit ! ;
blah
s" game.log" open seekend fdeactivate const LOGFILE
: emit-log ' fputc LOGFILE withfp ;
: atexit LOGFILE factivate close ;
: start-repl activate blah ' emit-log task-echo !
s" .:: J O R T H ( jean forth) ::." type cr
begin receive loadstring s" ok" type cr again ;
task const REPL
REPL start-repl
intern input.jor
input.jor loadfile
var color
var spriteindex
var refresh-needed
: refresh 1 refresh-needed ! ;
: color! dup color @ = if drop else color ! refresh then ;
: +sprite! spriteindex spritecount +!cycle refresh ;
: draw-palette 0 0x11 for i 79 i 3 << drawfatbox next ;
: mousepos>sprpos 3 >> swap 3 >> swap ;
: mousexys mousepos mousepos>sprpos spriteindex @ ;
: tick
mousepos 128 < swap 128 < and if
MOUSEL mousedown if
mousexys getpixel color @ != if
color @ mousexys putpixel
refresh
then
then
MOUSER clicked if
mousexys getpixel color!
then
then
mousepos 136 < swap 312 >= and if
mousepos swap drop 3 >>
MOUSEL mousedown if color! else drop then
then
^LEFT key-pressed if -1 +sprite! then
^RIGHT key-pressed if 1 +sprite! then
tick-debounce
;
: draw
refresh-needed @ if
mousehide
spriteindex @ drawfatsprite
color @ 78 0 drawfatbox
draw-palette
mouseshow
0 refresh-needed !
then ;
mouseshow
refresh