pete286/jiles.jor

81 lines
1.9 KiB
Plaintext
Raw Normal View History

var lcolor 0x0f lcolor !
var rcolor 0x10 rcolor !
var spriteindex
2019-07-27 01:37:47 +00:00
var refresh-needed
: refresh 1 refresh-needed ! ;
2019-08-07 02:47:15 +00:00
array preview 128 allot
: color! >r dup r@ @ = if drop else r@ ! refresh then rdrop ;
2019-07-27 01:37:47 +00:00
: +sprite! spriteindex spritecount +!cycle refresh ;
2019-07-27 01:37:47 +00:00
: draw-palette 0 0x11 for i 79 i 3 << drawfatbox next ;
2019-08-07 02:47:15 +00:00
: draw-preview
0 18 for
i preview tile>buf
spriteindex @ preview spr>buf
i 3 % 2 * 65 + i 3 / 16 * preview paintbuf
next ;
: mousepos>sprpos 3 >> swap 3 >> swap ;
: mousexys mousepos mousepos>sprpos spriteindex @ ;
: mousepixel! ( color -- )
>r mousexys getpixel r@ != if
r@ mousexys putpixel refresh
then rdrop ;
var jiles-old-tick
var jiles-old-draw
44 const ^Z
45 const ^X
31 const ^S
: jiles-tick
2019-07-27 01:37:47 +00:00
mousepos 128 < swap 128 < and if
MOUSEL mousedown if lcolor @ mousepixel! then
MOUSER mousedown if rcolor @ mousepixel! then
then
2019-07-27 01:37:47 +00:00
mousepos 136 < swap 312 >= and if
mousepos swap drop 3 >> dup
MOUSEL mousedown if lcolor color! else drop then
MOUSER mousedown if rcolor color! else drop then
then
2019-07-27 01:37:47 +00:00
^LEFT key-pressed if -1 +sprite! then
^RIGHT key-pressed if 1 +sprite! then
^Z key-pressed if mousexys getpixel lcolor color! then
^X key-pressed if mousexys getpixel rcolor color! then
^S key-pressed if s" SAVING" type cr savegfx then
^TAB key-pressed if
jiles-old-draw @ ' draw redefine
jiles-old-tick @ ' tick redefine
mousehide unfuck invalidate-map
then
tick-debounce
2019-07-27 01:37:47 +00:00
;
: jiles-draw
2019-07-27 01:37:47 +00:00
refresh-needed @ if
mousehide
2019-08-07 02:47:15 +00:00
draw-preview
2019-07-27 01:37:47 +00:00
spriteindex @ drawfatsprite
lcolor @ 77 0 drawfatbox
rcolor @ 78 0 drawfatbox
2019-07-27 01:37:47 +00:00
draw-palette
mouseshow
0 refresh-needed !
then ;
: jiles
^TAB key-pressed if
' draw definition jiles-old-draw !
' tick definition jiles-old-tick !
' jiles-draw ' draw redefine
' jiles-tick ' tick redefine
fuck mouseshow refresh
then ;