uxn

Varvara Ordinator, written in ANSI C(SDL2)
git clone https://git.eamoncaddigan.net/uxn.git
Log | Files | Refs | README | LICENSE

commit 3c758b734bc4bd86edad0afdf12879095844569f
parent e065b8015a76fe4f6280677459edafa5aa97f39d
Author: Andrew Alderwick <andrew@alderwick.co.uk>
Date:   Fri, 23 Apr 2021 15:34:03 +0100

Ported projects to new assembler syntax

All these programs tested working, except for left, which compiles but
doesn't run properly.

Diffstat:
Mprojects/demos/clock.usm | 182++++++++++++++++++++++++++++++++++++++++---------------------------------------
Mprojects/demos/musictracker.usm | 650++++++++++++++++++++++++++++++++++++++++----------------------------------------
Mprojects/demos/theme.usm | 476++++++++++++++++++++++++++++++++++++++++---------------------------------------
Mprojects/examples/gui.hover.usm | 122+++++++++++++++++++++++++++++++++++++++++--------------------------------------
Mprojects/examples/gui.label.usm | 106++++++++++++++++++++++++++++++++++++++++++-------------------------------------
Mprojects/examples/gui.picture.usm | 116++++++++++++++++++++++++++++++++++++++++++-------------------------------------
Mprojects/examples/gui.shapes.usm | 190+++++++++++++++++++++++++++++++++++++++++--------------------------------------
Mprojects/examples/gui.wallpaper.usm | 110+++++++++++++++++++++++++++++++++++++++++--------------------------------------
Mprojects/software/left.usm | 765++++++++++++++++++++++++++++++++++++++++---------------------------------------
Mprojects/software/nasu.usm | 909++++++++++++++++++++++++++++++++++++++++---------------------------------------
Mprojects/software/noodle.usm | 1136++++++++++++++++++++++++++++++++++++++++---------------------------------------
Mprojects/software/orca.usm | 414++++++++++++++++++++++++++++++++++++++++----------------------------------------
12 files changed, 2612 insertions(+), 2564 deletions(-)

diff --git a/projects/demos/clock.usm b/projects/demos/clock.usm @@ -2,142 +2,146 @@ %RTN { JMP2r } %ABS2 { DUP2 #000f SFT2 EQU #04 JNZ #ffff MUL2 } -%SCALEX { #0002 DIV2 ~Screen.width #0002 DIV2 ADD2 #0040 SUB2 } -%SCALEY { #0002 DIV2 ~Screen.height #0002 DIV2 ADD2 #0040 SUB2 } +%SCALEX { #0002 DIV2 .Screen/width DEI2 #0002 DIV2 ADD2 #0040 SUB2 } +%SCALEY { #0002 DIV2 .Screen/height DEI2 #0002 DIV2 ADD2 #0040 SUB2 } %12HOURS { DUP #0c GTH #0c MUL SUB } %MOD { DUP2 DIV MUL SUB } -;current { second 1 } -;needles { hx 2 hy 2 mx 2 my 2 sx 2 sy 2 } -;line { x0 2 y0 2 x 2 y 2 sx 2 sy 2 dx 2 dy 2 e1 2 e2 2 } -;color { byte 1 } - ( devices ) -|0100 ;System { vector 2 pad 6 r 2 g 2 b 2 } -|0120 ;Screen { vector 2 width 2 height 2 pad 2 x 2 y 2 addr 2 color 1 } -|01a0 ;DateTime { year 2 month 1 day 1 hour 1 minute 1 second 1 dotw 1 doty 2 isdst 1 refresh 1 } +|00 @System [ &vector $2 &pad $6 &r $2 &g $2 &b $2 ] +|20 @Screen [ &vector $2 &width $2 &height $2 &pad $2 &x $2 &y $2 &addr $2 &color $1 ] +|a0 @DateTime [ &year $2 &month $1 &day $1 &hour $1 &minute $1 &second $1 &dotw $1 &doty $2 &isdst $1 &refresh $1 ] + +( variables ) + +|0000 + +@current [ &second $1 ] +@needles [ &hx $2 &hy $2 &mx $2 &my $2 &sx $2 &sy $2 ] +@line [ &x0 $2 &y0 $2 &x $2 &y $2 &sx $2 &sy $2 &dx $2 &dy $2 &e1 $2 &e2 $2 ] +@color [ &byte $1 ] ( program ) -|0200 +|0100 - ( theme ) #0ff8 =System.r #0f08 =System.g #0f08 =System.b - ( vectors ) ,on-frame =Screen.vector + ( theme ) #0ff8 .System/r DEO2 #0f08 .System/g DEO2 #0f08 .System/b DEO2 + ( vectors ) ;on-frame .Screen/vector DEO2 BRK @on-frame - #00 =DateTime.refresh + #00 .DateTime/refresh DEO ( only draw once per second ) - ~DateTime.second ~current.second NEQ #01 JNZ BRK - ~DateTime.second =current.second + .DateTime/second DEI .current/second PEK NEQ #01 JNZ BRK + .DateTime/second DEI .current/second POK ( clear ) - #0080 SCALEX #0080 SCALEY ~needles.sx ~needles.sy #00 ,draw-line JSR2 - #0080 SCALEX #0080 SCALEY ~needles.mx ~needles.my #00 ,draw-line JSR2 - #0080 SCALEX #0080 SCALEY ~needles.hx ~needles.hy #00 ,draw-line JSR2 + #0080 SCALEX #0080 SCALEY .needles/sx PEK2 .needles/sy PEK2 #00 ;draw-line JSR2 + #0080 SCALEX #0080 SCALEY .needles/mx PEK2 .needles/my PEK2 #00 ;draw-line JSR2 + #0080 SCALEX #0080 SCALEY .needles/hx PEK2 .needles/hy PEK2 #00 ;draw-line JSR2 ( place ) - #00 ~DateTime.second #0002 MUL2 ,table ADD2 LDR2 - #00 SWP SCALEY =needles.sy - #00 SWP SCALEX =needles.sx - #00 ~DateTime.minute #0002 MUL2 ,table ADD2 LDR2 - #00 SWP #0004 DIV2 #0003 MUL2 #0020 ADD2 SCALEY =needles.my - #00 SWP #0004 DIV2 #0003 MUL2 #0020 ADD2 SCALEX =needles.mx - #00 ~DateTime.hour 12HOURS #05 MUL #0002 MUL2 ,table ADD2 LDR2 - #00 SWP #0002 DIV2 #0040 ADD2 SCALEY =needles.hy - #00 SWP #0002 DIV2 #0040 ADD2 SCALEX =needles.hx + #00 .DateTime/second DEI #0002 MUL2 ;table ADD2 GET2 + #00 SWP SCALEY .needles/sy POK2 + #00 SWP SCALEX .needles/sx POK2 + #00 .DateTime/minute DEI #0002 MUL2 ;table ADD2 GET2 + #00 SWP #0004 DIV2 #0003 MUL2 #0020 ADD2 SCALEY .needles/my POK2 + #00 SWP #0004 DIV2 #0003 MUL2 #0020 ADD2 SCALEX .needles/mx POK2 + #00 .DateTime/hour DEI 12HOURS #05 MUL #0002 MUL2 ;table ADD2 GET2 + #00 SWP #0002 DIV2 #0040 ADD2 SCALEY .needles/hy POK2 + #00 SWP #0002 DIV2 #0040 ADD2 SCALEX .needles/hx POK2 ( needles ) - #0080 SCALEX #0080 SCALEY ~needles.sx ~needles.sy #02 ,draw-line JSR2 - #0080 SCALEX #0080 SCALEY ~needles.mx ~needles.my #01 ,draw-line JSR2 - #0080 SCALEX #0080 SCALEY ~needles.hx ~needles.hy #03 ,draw-line JSR2 + #0080 SCALEX #0080 SCALEY .needles/sx PEK2 .needles/sy PEK2 #02 ;draw-line JSR2 + #0080 SCALEX #0080 SCALEY .needles/mx PEK2 .needles/my PEK2 #01 ;draw-line JSR2 + #0080 SCALEX #0080 SCALEY .needles/hx PEK2 .needles/hy PEK2 #03 ;draw-line JSR2 ( circle ) - #00 #3c - $loop - ( load ) OVR #00 SWP #0002 MUL2 ,table ADD2 LDR2 - #00 SWP SCALEY =Screen.y - #00 SWP SCALEX =Screen.x - OVR #0f MOD #00 EQU #01 ADD =Screen.color + #00 #3c + &loop + ( load ) OVR #00 SWP #0002 MUL2 ;table ADD2 GET2 + #00 SWP SCALEY .Screen/y DEO2 + #00 SWP SCALEX .Screen/x DEO2 + OVR #0f MOD #00 EQU #01 ADD .Screen/color DEO ( incr ) SWP #01 ADD SWP - DUP2 LTH ^$loop JNZ + DUP2 LTH ,&loop JNZ POP2 ( display ) - ~Screen.height #0002 DIV2 #0048 ADD2 =Screen.y - ~Screen.width #0002 DIV2 - DUP2 #0020 SUB2 =Screen.x - ,font_hex #00 ~DateTime.hour #0a DIV #08 MUL ADD2 =Screen.addr - #22 =Screen.color - DUP2 #0018 SUB2 =Screen.x - ,font_hex #00 ~DateTime.hour #0a MOD #08 MUL ADD2 =Screen.addr - #22 =Screen.color - DUP2 #0008 SUB2 =Screen.x - ,font_hex #00 ~DateTime.minute #0a DIV #08 MUL ADD2 =Screen.addr - #22 =Screen.color - DUP2 =Screen.x - ,font_hex #00 ~DateTime.minute #0a MOD #08 MUL ADD2 =Screen.addr - #22 =Screen.color - DUP2 #0010 ADD2 =Screen.x - ,font_hex #00 ~DateTime.second #0a DIV #08 MUL ADD2 =Screen.addr - #22 =Screen.color - DUP2 #0018 ADD2 =Screen.x - ,font_hex #00 ~DateTime.second #0a MOD #08 MUL ADD2 =Screen.addr - #22 =Screen.color + .Screen/height DEI2 #0002 DIV2 #0048 ADD2 .Screen/y DEO2 + .Screen/width DEI2 #0002 DIV2 + DUP2 #0020 SUB2 .Screen/x DEO2 + ;font_hex #00 .DateTime/hour DEI #0a DIV #08 MUL ADD2 .Screen/addr DEO2 + #22 .Screen/color DEO + DUP2 #0018 SUB2 .Screen/x DEO2 + ;font_hex #00 .DateTime/hour DEI #0a MOD #08 MUL ADD2 .Screen/addr DEO2 + #22 .Screen/color DEO + DUP2 #0008 SUB2 .Screen/x DEO2 + ;font_hex #00 .DateTime/minute DEI #0a DIV #08 MUL ADD2 .Screen/addr DEO2 + #22 .Screen/color DEO + DUP2 .Screen/x DEO2 + ;font_hex #00 .DateTime/minute DEI #0a MOD #08 MUL ADD2 .Screen/addr DEO2 + #22 .Screen/color DEO + DUP2 #0010 ADD2 .Screen/x DEO2 + ;font_hex #00 .DateTime/second DEI #0a DIV #08 MUL ADD2 .Screen/addr DEO2 + #22 .Screen/color DEO + DUP2 #0018 ADD2 .Screen/x DEO2 + ;font_hex #00 .DateTime/second DEI #0a MOD #08 MUL ADD2 .Screen/addr DEO2 + #22 .Screen/color DEO POP2 BRK @draw-line ( x1 y1 x2 y2 color -- ) - ( load ) =color =line.y0 =line.x0 =line.y =line.x - ~line.x0 ~line.x SUB2 ABS2 =line.dx - ~line.y0 ~line.y SUB2 ABS2 #0000 SWP2 SUB2 =line.dy - #ffff #00 ~line.x ~line.x0 LTS2 #0002 MUL2 ADD2 =line.sx - #ffff #00 ~line.y ~line.y0 LTS2 #0002 MUL2 ADD2 =line.sy - ~line.dx ~line.dy ADD2 =line.e1 - $loop - ~line.x =Screen.x ~line.y =Screen.y ~color =Screen.color - ~line.x ~line.x0 EQU2 ~line.y ~line.y0 EQU2 #0101 EQU2 ^$end JNZ - ~line.e1 #0002 MUL2 =line.e2 - ~line.e2 ~line.dy LTS2 ^$skipy JNZ - ~line.e1 ~line.dy ADD2 =line.e1 - ~line.x ~line.sx ADD2 =line.x - $skipy - ~line.e2 ~line.dx GTS2 ^$skipx JNZ - ~line.e1 ~line.dx ADD2 =line.e1 - ~line.y ~line.sy ADD2 =line.y - $skipx - ,$loop JMP2 - - $end + ( load ) .color POK .line/y0 POK2 .line/x0 POK2 .line/y POK2 .line/x POK2 + .line/x0 PEK2 .line/x PEK2 SUB2 ABS2 .line/dx POK2 + .line/y0 PEK2 .line/y PEK2 SUB2 ABS2 #0000 SWP2 SUB2 .line/dy POK2 + #ffff #00 .line/x PEK2 .line/x0 PEK2 LTS2 #0002 MUL2 ADD2 .line/sx POK2 + #ffff #00 .line/y PEK2 .line/y0 PEK2 LTS2 #0002 MUL2 ADD2 .line/sy POK2 + .line/dx PEK2 .line/dy PEK2 ADD2 .line/e1 POK2 + &loop + .line/x PEK2 .Screen/x DEO2 .line/y PEK2 .Screen/y DEO2 .color PEK .Screen/color DEO + .line/x PEK2 .line/x0 PEK2 EQU2 .line/y PEK2 .line/y0 PEK2 EQU2 #0101 EQU2 ,&end JNZ + .line/e1 PEK2 #0002 MUL2 .line/e2 POK2 + .line/e2 PEK2 .line/dy PEK2 LTS2 ,&skipy JNZ + .line/e1 PEK2 .line/dy PEK2 ADD2 .line/e1 POK2 + .line/x PEK2 .line/sx PEK2 ADD2 .line/x POK2 + &skipy + .line/e2 PEK2 .line/dx PEK2 GTS2 ,&skipx JNZ + .line/e1 PEK2 .line/dx PEK2 ADD2 .line/e1 POK2 + .line/y PEK2 .line/sy PEK2 ADD2 .line/y POK2 + &skipx + ;&loop JMP2 + + &end RTN @table ( 60 positions on a circle in bytes ) [ - 8000 8d00 9a02 a706 b40b c011 cb18 d520 - df2a e734 ee40 f44b f958 fd65 ff72 ff80 - ff8d fd9a f9a7 f4b4 eec0 e7cb dfd5 d5df - cbe7 c0ee b4f4 a7f9 9afd 8dff 80ff 72ff - 65fd 58f9 4bf4 40ee 34e7 2adf 20d5 18cb - 11c0 0bb4 06a7 029a 008d 0080 0072 0265 - 0658 0b4b 113f 1834 202a 2a20 3418 3f11 + 8000 8d00 9a02 a706 b40b c011 cb18 d520 + df2a e734 ee40 f44b f958 fd65 ff72 ff80 + ff8d fd9a f9a7 f4b4 eec0 e7cb dfd5 d5df + cbe7 c0ee b4f4 a7f9 9afd 8dff 80ff 72ff + 65fd 58f9 4bf4 40ee 34e7 2adf 20d5 18cb + 11c0 0bb4 06a7 029a 008d 0080 0072 0265 + 0658 0b4b 113f 1834 202a 2a20 3418 3f11 4b0b 5806 6502 7200 ] -@font_hex ( 0-F ) +@font_hex ( 0-F ) [ 007c 8282 8282 827c 0030 1010 1010 1010 007c 8202 7c80 80fe 007c 8202 1c02 827c 000c 1424 4484 fe04 00fe 8080 7c02 827c 007c 8280 fc82 827c 007c 8202 1e02 0202 007c 8282 7c82 827c 007c 8282 7e02 827c - 007c 8202 7e82 827e 00fc 8282 fc82 82fc - 007c 8280 8080 827c 00fc 8282 8282 82fc + 007c 8202 7e82 827e 00fc 8282 fc82 82fc + 007c 8280 8080 827c 00fc 8282 8282 82fc 007c 8280 f080 827c 007c 8280 f080 8080 ] diff --git a/projects/demos/musictracker.usm b/projects/demos/musictracker.usm @@ -1,249 +1,249 @@ -( a blank file ) +( mini music tracker ) %RTN { JMP2r } %8+ { #0008 ADD2 } %8- { #0008 SUB2 } %8* { #0008 MUL2 } %8/ { #0008 DIV2 } -%++ { #0001 ADD2 } +%++ { #0001 ADD2 } %MOD { DUP2 DIV MUL SUB } -%TRACK { ,track.ch1 #00 ~track.active #0020 MUL2 ADD2 } -%SOUND { STH #00 =Audio.value STHr #00 =Audio.delay } -%SOUND_FINISH { #00 =Audio.finish } +%TRACK { ;track/ch1 #00 .track/active PEK #0020 MUL2 ADD2 } +%SOUND { STH #00 .Audio/value DEO2 STHr #00 .Audio/delay DEO2 } +%SOUND_FINISH { #00 .Audio/finish DEO } ( variables ) -;pointer { x 2 y 2 } -;color { byte 1 } -;rect { x1 2 y1 2 x2 2 y2 2 } -;trkframe { x1 2 y1 2 x2 2 y2 2 } -;chnframe { x1 2 y1 2 x2 2 y2 2 } -;ctlframe { x1 2 y1 2 x2 2 y2 2 } -;label { x 2 y 2 color 1 addr 2 } -;knob { x 2 y 2 value 1 } -;head { pos 1 } -;track { active 1 ch1 20 ch2 20 ch3 20 ch4 20 } -;adsr { ch1a 1 ch1d 1 ch1s 1 ch1r 1 ch2a 1 ch2d 1 ch2s 1 ch2r 1 ch3a 1 ch3d 1 ch3s 1 ch3r 1 ch4a 1 ch4d 1 ch4s 1 ch4r 1 } -;volume { ch1 1 ch2 1 ch3 1 ch4 1 } +@pointer [ &x $2 &y $2 ] +@color [ &byte $1 ] +@rect [ &x1 $2 &y1 $2 &x2 $2 &y2 $2 ] +@trkframe [ &x1 $2 &y1 $2 &x2 $2 &y2 $2 ] +@chnframe [ &x1 $2 &y1 $2 &x2 $2 &y2 $2 ] +@ctlframe [ &x1 $2 &y1 $2 &x2 $2 &y2 $2 ] +@label [ &x $2 &y $2 &color $1 &addr $2 ] +@knob [ &x $2 &y $2 &value $1 ] +@head [ &pos $1 ] +@track [ &active $1 &ch1 $20 &ch2 $20 &ch3 $20 &ch4 $20 ] +@adsr [ &ch1a $1 &ch1d $1 &ch1s $1 &ch1r $1 &ch2a $1 &ch2d $1 &ch2s $1 &ch2r $1 &ch3a $1 &ch3d $1 &ch3s $1 &ch3r $1 &ch4a $1 &ch4d $1 &ch4s $1 &ch4r $1 ] +@volume [ &ch1 $1 &ch2 $1 &ch3 $1 &ch4 $1 ] ( devices ) -|0100 ;System { vector 2 pad 6 r 2 g 2 b 2 } -|0110 ;Console { vector 2 pad 6 char 1 byte 1 short 2 string 2 } -|0120 ;Screen { vector 2 width 2 height 2 pad 2 x 2 y 2 addr 2 color 1 } -|0130 ;Audio { wave 2 envelope 2 pad 4 volume 1 pitch 1 play 1 value 2 delay 2 finish 1 } -|0140 ;Controller { vector 2 button 1 key 1 } -|0160 ;Mouse { vector 2 x 2 y 2 state 1 chord 1 } -|0170 ;File { vector 2 success 2 offset 2 pad 2 name 2 length 2 load 2 save 2 } +|00 @System [ &vector $2 &pad $6 &r $2 &g $2 &b $2 ] +|10 @Console [ &vector $2 &pad $6 &char $1 &byte $1 &short $2 &string $2 ] +|20 @Screen [ &vector $2 &width $2 &height $2 &pad $2 &x $2 &y $2 &addr $2 &color $1 ] +|30 @Audio [ &wave $2 &envelope $2 &pad $4 &volume $1 &pitch $1 &play $1 &value $2 &delay $2 &finish $1 ] +|40 @Controller [ &vector $2 &button $1 &key $1 ] +|60 @Mouse [ &vector $2 &x $2 &y $2 &state $1 &chord $1 ] +|70 @File [ &vector $2 &success $2 &offset $2 &pad $2 &name $2 &length $2 &load $2 &save $2 ] ( vectors ) -|0200 +|0100 - ( theme ) #e0fa =System.r #30fa =System.g #30fa =System.b - ( vectors ) ,on-screen =Screen.vector - ( vectors ) ,on-mouse =Mouse.vector - ( vectors ) ,on-button =Controller.vector + ( theme ) #e0fa .System/r DEO2 #30fa .System/g DEO2 #30fa .System/b DEO2 + ( vectors ) ;on-screen .Screen/vector DEO2 + ( vectors ) ;on-mouse .Mouse/vector DEO2 + ( vectors ) ;on-button .Controller/vector DEO2 - ~Screen.width #0002 DIV2 DUP2 #0080 SUB2 =trkframe.x1 - #0080 ADD2 =trkframe.x2 - ~Screen.height #0002 DIV2 DUP2 #0038 SUB2 #0010 SUB2 =trkframe.y1 - #0038 ADD2 #0010 SUB2 =trkframe.y2 + .Screen/width DEI2 #0002 DIV2 DUP2 #0080 SUB2 .trkframe/x1 POK2 + #0080 ADD2 .trkframe/x2 POK2 + .Screen/height DEI2 #0002 DIV2 DUP2 #0038 SUB2 #0010 SUB2 .trkframe/y1 POK2 + #0038 ADD2 #0010 SUB2 .trkframe/y2 POK2 - ~trkframe.x1 =chnframe.x1 ~trkframe.y2 =chnframe.y1 - ~chnframe.x1 #0030 ADD2 =chnframe.x2 ~chnframe.y1 #0030 ADD2 =chnframe.y2 + .trkframe/x1 PEK2 .chnframe/x1 POK2 .trkframe/y2 PEK2 .chnframe/y1 POK2 + .chnframe/x1 PEK2 #0030 ADD2 .chnframe/x2 POK2 .chnframe/y1 PEK2 #0030 ADD2 .chnframe/y2 POK2 - ~chnframe.x2 =ctlframe.x1 ~chnframe.y1 =ctlframe.y1 - ~trkframe.x2 =ctlframe.x2 ~chnframe.y2 =ctlframe.y2 + .chnframe/x2 PEK2 .ctlframe/x1 POK2 .chnframe/y1 PEK2 .ctlframe/y1 POK2 + .trkframe/x2 PEK2 .ctlframe/x2 POK2 .chnframe/y2 PEK2 .ctlframe/y2 POK2 ( default settings ) - ,adsr-envelope =Audio.envelope - #00 =adsr.ch1a #40 =adsr.ch1d #80 =adsr.ch1s #c0 =adsr.ch1r #88 =volume.ch1 - #10 =adsr.ch2a #50 =adsr.ch2d #90 =adsr.ch2s #d0 =adsr.ch2r #88 =volume.ch2 - #20 =adsr.ch3a #60 =adsr.ch3d #a0 =adsr.ch3s #e0 =adsr.ch3r #88 =volume.ch3 + ;adsr-envelope .Audio/envelope DEO2 + #00 .adsr/ch1a POK #40 .adsr/ch1d POK #80 .adsr/ch1s POK #c0 .adsr/ch1r POK #88 .volume/ch1 POK + #10 .adsr/ch2a POK #50 .adsr/ch2d POK #90 .adsr/ch2s POK #d0 .adsr/ch2r POK #88 .volume/ch2 POK + #20 .adsr/ch3a POK #60 .adsr/ch3d POK #a0 .adsr/ch3s POK #e0 .adsr/ch3r POK #88 .volume/ch3 POK - ~volume.ch3 =Audio.volume + .volume/ch3 PEK .Audio/volume DEO - ,draw-timeline JSR2 - ,draw-controls JSR2 - ,draw-channels JSR2 + ;draw-timeline JSR2 + ;draw-controls JSR2 + ;draw-channels JSR2 BRK @on-screen ( -> ) - ,move-head JSR2 - ~head.pos #08 MOD #00 NEQ ^$skip JNZ - ,bang JSR2 - $skip + ;move-head JSR2 + .head/pos PEK #08 MOD #00 NEQ ,&skip JNZ + ;bang JSR2 + &skip BRK @on-mouse ( -> ) - ~Mouse.state #00 EQU ,$click-end JNZ2 - ~Mouse.x ~trkframe.x1 GTH2 ~Mouse.x ~trkframe.x2 LTH2 #0101 EQU2 - ~Mouse.y ~trkframe.y1 GTH2 ~Mouse.y ~trkframe.y2 LTH2 #0101 EQU2 - #0101 EQU2 ,touch-trk JNZ2 - ~Mouse.x ~chnframe.x1 GTH2 ~Mouse.x ~chnframe.x2 LTH2 #0101 EQU2 - ~Mouse.y ~chnframe.y1 8+ GTH2 ~Mouse.y ~chnframe.y2 8- LTH2 #0101 EQU2 - #0101 EQU2 ,touch-chn JNZ2 - ~Mouse.x ~ctlframe.x1 GTH2 ~Mouse.x ~ctlframe.x2 LTH2 #0101 EQU2 - ~Mouse.y ~ctlframe.y1 8+ GTH2 ~Mouse.y ~ctlframe.y2 8- LTH2 #0101 EQU2 - #0101 EQU2 ,touch-ctl JNZ2 - $click-end + .Mouse/state DEI #00 EQU ;&click-end JNZ2 + .Mouse/x DEI2 .trkframe/x1 PEK2 GTH2 .Mouse/x DEI2 .trkframe/x2 PEK2 LTH2 #0101 EQU2 + .Mouse/y DEI2 .trkframe/y1 PEK2 GTH2 .Mouse/y DEI2 .trkframe/y2 PEK2 LTH2 #0101 EQU2 + #0101 EQU2 ;touch-trk JNZ2 + .Mouse/x DEI2 .chnframe/x1 PEK2 GTH2 .Mouse/x DEI2 .chnframe/x2 PEK2 LTH2 #0101 EQU2 + .Mouse/y DEI2 .chnframe/y1 PEK2 8+ GTH2 .Mouse/y DEI2 .chnframe/y2 PEK2 8- LTH2 #0101 EQU2 + #0101 EQU2 ;touch-chn JNZ2 + .Mouse/x DEI2 .ctlframe/x1 PEK2 GTH2 .Mouse/x DEI2 .ctlframe/x2 PEK2 LTH2 #0101 EQU2 + .Mouse/y DEI2 .ctlframe/y1 PEK2 8+ GTH2 .Mouse/y DEI2 .ctlframe/y2 PEK2 8- LTH2 #0101 EQU2 + #0101 EQU2 ;touch-ctl JNZ2 + &click-end - ,draw-cursor JSR2 + ;draw-cursor JSR2 BRK @on-button ( -> ) - ~Controller.key - DUP #61 NEQ ^$no-c JNZ - ,notes PEK2 ,play JSR2 $no-c - DUP #73 NEQ ^$no-d JNZ - ,notes #0001 ADD2 PEK2 ,play JSR2 $no-d - DUP #64 NEQ ^$no-e JNZ - ,notes #0002 ADD2 PEK2 ,play JSR2 $no-e - DUP #66 NEQ ^$no-f JNZ - ,notes #0003 ADD2 PEK2 ,play JSR2 $no-f - DUP #67 NEQ ^$no-g JNZ - ,notes #0004 ADD2 PEK2 ,play JSR2 $no-g - DUP #68 NEQ ^$no-a JNZ - ,notes #0005 ADD2 PEK2 ,play JSR2 $no-a - DUP #6a NEQ ^$no-b JNZ - ,notes #0006 ADD2 PEK2 ,play JSR2 $no-b - DUP #6b NEQ ^$no-c2 JNZ - ,notes #0007 ADD2 PEK2 ,play JSR2 $no-c2 + .Controller/key DEI + DUP #61 NEQ ,&no-c JNZ + ;notes GET ;play JSR2 &no-c + DUP #73 NEQ ,&no-d JNZ + ;notes #0001 ADD2 GET ;play JSR2 &no-d + DUP #64 NEQ ,&no-e JNZ + ;notes #0002 ADD2 GET ;play JSR2 &no-e + DUP #66 NEQ ,&no-f JNZ + ;notes #0003 ADD2 GET ;play JSR2 &no-f + DUP #67 NEQ ,&no-g JNZ + ;notes #0004 ADD2 GET ;play JSR2 &no-g + DUP #68 NEQ ,&no-a JNZ + ;notes #0005 ADD2 GET ;play JSR2 &no-a + DUP #6a NEQ ,&no-b JNZ + ;notes #0006 ADD2 GET ;play JSR2 &no-b + DUP #6b NEQ ,&no-c2 JNZ + ;notes #0007 ADD2 GET ;play JSR2 &no-c2 POP BRK @play ( pitch -- ) - #80 ORA =Audio.pitch - ,triangle-wave =Audio.wave - ~track.active =Audio.play + #80 ORA .Audio/pitch DEO + ;triangle-wave .Audio/wave DEO2 + .track/active PEK .Audio/play DEO RTN @touch-trk ( -- ) - ,clear-notes JSR2 + ;clear-notes JSR2 ( get note ) - #0e ~Mouse.y ~trkframe.y1 SUB2 SWP POP #08 DIV SUB - ~Mouse.state #10 NEQ ^$no-erase JNZ POP #00 $no-erase + #0e .Mouse/y DEI2 .trkframe/y1 PEK2 SUB2 SWP POP #08 DIV SUB + .Mouse/state DEI #10 NEQ ,&no-erase JNZ POP #00 &no-erase ( edit note ) - TRACK #00 ~Mouse.x ~trkframe.x1 SUB2 SWP POP #08 DIV ADD2 POK2 - ( release ) #00 =Mouse.state - ,draw-notes JSR2 + TRACK #00 .Mouse/x DEI2 .trkframe/x1 PEK2 SUB2 SWP POP #08 DIV ADD2 PUT + ( release ) #00 .Mouse/state DEO + ;draw-notes JSR2 BRK @touch-chn ( -- ) - ,clear-notes JSR2 - ( save ) ~Mouse.y ~chnframe.y1 SUB2 SWP POP #08 DIV #01 SUB =track.active - ( release ) #00 =Mouse.state - ,draw-channels JSR2 - ,draw-notes JSR2 - ,draw-controls JSR2 + ;clear-notes JSR2 + ( save ) .Mouse/y DEI2 .chnframe/y1 PEK2 SUB2 SWP POP #08 DIV #01 SUB .track/active POK + ( release ) #00 .Mouse/state DEO + ;draw-channels JSR2 + ;draw-notes JSR2 + ;draw-controls JSR2 BRK @touch-ctl ( -- ) - ~Mouse.x ~ctlframe.x1 SUB2 8- 8/ SWP POP #02 DIV - DUP #00 NEQ ^$no-a JNZ - ,adsr #00 ~track.active #04 MUL ADD2 PEK2 - #10 ~Mouse.state #10 EQU #e0 MUL ADD ADD - ,adsr #00 ~track.active #04 MUL ADD2 POK2 $no-a - DUP #01 NEQ ^$no-d JNZ - ,adsr #00 ~track.active #04 MUL ADD2 #0001 ADD2 PEK2 - #10 ~Mouse.state #10 EQU #e0 MUL ADD ADD - ,adsr #00 ~track.active #04 MUL ADD2 #0001 ADD2 POK2 $no-d - DUP #02 NEQ ^$no-s JNZ - ,adsr #00 ~track.active #04 MUL ADD2 #0002 ADD2 PEK2 - #10 ~Mouse.state #10 EQU #e0 MUL ADD ADD - ,adsr #00 ~track.active #04 MUL ADD2 #0002 ADD2 POK2 $no-s - DUP #03 NEQ ^$no-r JNZ - ,adsr #00 ~track.active #04 MUL ADD2 #0003 ADD2 PEK2 - #10 ~Mouse.state #10 EQU #e0 MUL ADD ADD - ,adsr #00 ~track.active #04 MUL ADD2 #0003 ADD2 POK2 $no-r - DUP #05 NEQ ^$no-left JNZ - ,volume #00 ~track.active ADD2 PEK2 - #10 ~Mouse.state #10 EQU #e0 MUL ADD ADD - ,volume #00 ~track.active ADD2 POK2 $no-left - DUP #06 NEQ ^$no-right JNZ - ,volume #00 ~track.active ADD2 PEK2 - DUP #f0 AND STH #01 ~Mouse.state #10 EQU #0e MUL ADD ADD #0f AND STHr ADD - ,volume #00 ~track.active ADD2 POK2 $no-right + .Mouse/x DEI2 .ctlframe/x1 PEK2 SUB2 8- 8/ SWP POP #02 DIV + DUP #00 NEQ ,&no-a JNZ + ;adsr #00 .track/active PEK #04 MUL ADD2 GET + #10 .Mouse/state DEI #10 EQU #e0 MUL ADD ADD + ;adsr #00 .track/active PEK #04 MUL ADD2 PUT &no-a + DUP #01 NEQ ,&no-d JNZ + ;adsr #00 .track/active PEK #04 MUL ADD2 #0001 ADD2 GET + #10 .Mouse/state DEI #10 EQU #e0 MUL ADD ADD + ;adsr #00 .track/active PEK #04 MUL ADD2 #0001 ADD2 PUT &no-d + DUP #02 NEQ ,&no-s JNZ + ;adsr #00 .track/active PEK #04 MUL ADD2 #0002 ADD2 GET + #10 .Mouse/state DEI #10 EQU #e0 MUL ADD ADD + ;adsr #00 .track/active PEK #04 MUL ADD2 #0002 ADD2 PUT &no-s + DUP #03 NEQ ,&no-r JNZ + ;adsr #00 .track/active PEK #04 MUL ADD2 #0003 ADD2 GET + #10 .Mouse/state DEI #10 EQU #e0 MUL ADD ADD + ;adsr #00 .track/active PEK #04 MUL ADD2 #0003 ADD2 PUT &no-r + DUP #05 NEQ ,&no-left JNZ + ;volume #00 .track/active PEK ADD2 GET + #10 .Mouse/state DEI #10 EQU #e0 MUL ADD ADD + ;volume #00 .track/active PEK ADD2 PUT &no-left + DUP #06 NEQ ,&no-right JNZ + ;volume #00 .track/active PEK ADD2 GET + DUP #f0 AND STH #01 .Mouse/state DEI #10 EQU #0e MUL ADD ADD #0f AND STHr ADD + ;volume #00 .track/active PEK ADD2 PUT &no-right POP - ( release ) #00 =Mouse.state - ,draw-controls JSR2 + ( release ) #00 .Mouse/state DEO + ;draw-controls JSR2 BRK @bang ( -- ) - ,track.ch1 #00 ~head.pos #08 DIV ADD2 PEK2 + ;track/ch1 #00 .head/pos PEK #08 DIV ADD2 GET #01 SUB - DUP #ff NEQ ^$skip1 JNZ - POP ^$listen2 JMP - $skip1 - #00 SWP ,notes ADD2 PEK2 #80 ORA =Audio.pitch - ~volume.ch1 =Audio.volume - ,square-wave =Audio.wave - #00 =Audio.play - $listen2 - ,track.ch2 #00 ~head.pos #08 DIV ADD2 PEK2 + DUP #ff NEQ ,&skip1 JNZ + POP ,&listen2 JMP + &skip1 + #00 SWP ;notes ADD2 GET #80 ORA .Audio/pitch DEO + .volume/ch1 PEK .Audio/volume DEO + ;square-wave .Audio/wave DEO2 + #00 .Audio/play DEO + &listen2 + ;track/ch2 #00 .head/pos PEK #08 DIV ADD2 GET #01 SUB - DUP #ff NEQ ^$skip2 JNZ - POP ^$listen3 JMP - $skip2 - #00 SWP ,notes ADD2 PEK2 #80 ORA =Audio.pitch - ~volume.ch2 =Audio.volume - ,square-wave =Audio.wave - #01 =Audio.play - $listen3 - ,track.ch3 #00 ~head.pos #08 DIV ADD2 PEK2 + DUP #ff NEQ ,&skip2 JNZ + POP ,&listen3 JMP + &skip2 + #00 SWP ;notes ADD2 GET #80 ORA .Audio/pitch DEO + .volume/ch2 PEK .Audio/volume DEO + ;square-wave .Audio/wave DEO2 + #01 .Audio/play DEO + &listen3 + ;track/ch3 #00 .head/pos PEK #08 DIV ADD2 GET #01 SUB - DUP #ff NEQ ^$skip3 JNZ - POP ^$end JMP - $skip3 - #00 SWP ,notes ADD2 PEK2 #80 ORA =Audio.pitch - ~volume.ch3 =Audio.volume - ,triangle-wave =Audio.wave - #02 =Audio.play - $end + DUP #ff NEQ ,&skip3 JNZ + POP ,&end JMP + &skip3 + #00 SWP ;notes ADD2 GET #80 ORA .Audio/pitch DEO + .volume/ch3 PEK .Audio/volume DEO + ;triangle-wave .Audio/wave DEO2 + #02 .Audio/play DEO + &end RTN @move-head ( -- ) ( clear ) - ~trkframe.y1 8- =Screen.y - ~trkframe.x1 #00 ~head.pos ADD2 =Screen.x - ,head_icn =Screen.addr - #20 =Screen.color - ( incr ) ~head.pos #01 ADD =head.pos - ~trkframe.x1 #00 ~head.pos ADD2 =Screen.x - ,head_icn =Screen.addr - #21 ( if note ) TRACK #00 ~head.pos #08 DIV ADD2 PEK2 #00 NEQ ADD =Screen.color + .trkframe/y1 PEK2 8- .Screen/y DEO2 + .trkframe/x1 PEK2 #00 .head/pos PEK ADD2 .Screen/x DEO2 + ;head_icn .Screen/addr DEO2 + #20 .Screen/color DEO + ( incr ) .head/pos PEK #01 ADD .head/pos POK + .trkframe/x1 PEK2 #00 .head/pos PEK ADD2 .Screen/x DEO2 + ;head_icn .Screen/addr DEO2 + #21 ( if note ) TRACK #00 .head/pos PEK #08 DIV ADD2 GET #00 NEQ ADD .Screen/color DEO RTN @clear-notes ( -- ) #00 #20 - $loop - ( load ) OVR #00 SWP TRACK ADD2 PEK2 - DUP STH #00 SWP #0e SWP SUB 8* ~trkframe.y1 ADD2 =Screen.y - OVR #00 SWP 8* ~trkframe.x1 ADD2 =Screen.x - STHr #00 EQU ^$skip JNZ - #20 =Screen.color - $skip + &loop + ( load ) OVR #00 SWP TRACK ADD2 GET + DUP STH #00 SWP #0e SWP SUB 8* .trkframe/y1 PEK2 ADD2 .Screen/y DEO2 + OVR #00 SWP 8* .trkframe/x1 PEK2 ADD2 .Screen/x DEO2 + STHr #00 EQU ,&skip JNZ + #20 .Screen/color DEO + &skip ( incr ) SWP #01 ADD SWP - DUP2 LTH ^$loop JNZ + DUP2 LTH ,&loop JNZ POP2 RTN @@ -251,63 +251,63 @@ RTN @draw-notes ( -- ) #00 #20 - $notes-loop - ( load ) OVR #00 SWP TRACK ADD2 PEK2 - DUP STH #00 SWP #0e SWP SUB 8* ~trkframe.y1 ADD2 =Screen.y - OVR #00 SWP 8* ~trkframe.x1 ADD2 =Screen.x - ,note_icn =Screen.addr - STHr #00 EQU ^$skip JNZ - #25 =Screen.color - $skip + &notes-loop + ( load ) OVR #00 SWP TRACK ADD2 GET + DUP STH #00 SWP #0e SWP SUB 8* .trkframe/y1 PEK2 ADD2 .Screen/y DEO2 + OVR #00 SWP 8* .trkframe/x1 PEK2 ADD2 .Screen/x DEO2 + ;note_icn .Screen/addr DEO2 + STHr #00 EQU ,&skip JNZ + #25 .Screen/color DEO + &skip ( incr ) SWP #01 ADD SWP - DUP2 LTH ^$notes-loop JNZ + DUP2 LTH ,&notes-loop JNZ POP2 - ,draw-bars JSR2 + ;draw-bars JSR2 RTN @draw-bars ( -- ) - ~trkframe.x1 ~trkframe.y1 ~trkframe.x2 ~trkframe.y2 #01 ,line-rect JSR2 + .trkframe/x1 PEK2 .trkframe/y1 PEK2 .trkframe/x2 PEK2 .trkframe/y2 PEK2 #01 ;line-rect JSR2 ( grid ) - ~trkframe.y1 #0010 SUB2 =Screen.y - ,font_hex =Screen.addr - #0000 #0100 - $loop - OVR2 SWP POP #02 DIV #0f AND #00 NEQ ^$skip JNZ - OVR2 ~trkframe.x1 ADD2 =Screen.x - ~trkframe.y1 #0010 SUB2 =Screen.y - #22 =Screen.color - ~Screen.addr 8+ =Screen.addr - OVR2 ~trkframe.x1 ADD2 ~trkframe.y1 ++ ~trkframe.y2 #01 ,line-vertical-dotted JSR2 - $skip - OVR2 ~trkframe.x1 ADD2 ~trkframe.y1 ~trkframe.y2 #01 ,line-vertical-dotted JSR2 + .trkframe/y1 PEK2 #0010 SUB2 .Screen/y DEO2 + ;font_hex .Screen/addr DEO2 + #0000 #0100 + &loop + OVR2 SWP POP #02 DIV #0f AND #00 NEQ ,&skip JNZ + OVR2 .trkframe/x1 PEK2 ADD2 .Screen/x DEO2 + .trkframe/y1 PEK2 #0010 SUB2 .Screen/y DEO2 + #22 .Screen/color DEO + .Screen/addr DEI2 8+ .Screen/addr DEO2 + OVR2 .trkframe/x1 PEK2 ADD2 .trkframe/y1 PEK2 ++ .trkframe/y2 PEK2 #01 ;line-vertical-dotted JSR2 + &skip + OVR2 .trkframe/x1 PEK2 ADD2 .trkframe/y1 PEK2 .trkframe/y2 PEK2 #01 ;line-vertical-dotted JSR2 SWP2 8+ SWP2 - OVR2 OVR2 LTH2 ^$loop JNZ + OVR2 OVR2 LTH2 ,&loop JNZ POP2 POP2 - ~trkframe.x1 ~trkframe.x2 ~trkframe.y1 8- #0040 ADD2 #01 ,line-horizontal-dotted JSR2 + .trkframe/x1 PEK2 .trkframe/x2 PEK2 .trkframe/y1 PEK2 8- #0040 ADD2 #01 ;line-horizontal-dotted JSR2 RTN @draw-octave ( x y -- ) - =Screen.y - =Screen.x - ,octave_icn =Screen.addr - ~Screen.y ~Screen.y #0038 ADD2 - $loop - OVR2 =Screen.y - #21 =Screen.color - ~Screen.addr 8+ =Screen.addr - ~Screen.x 8+ =Screen.x - #21 =Screen.color - ~Screen.addr 8+ =Screen.addr - ~Screen.x 8- =Screen.x + .Screen/y DEO2 + .Screen/x DEO2 + ;octave_icn .Screen/addr DEO2 + .Screen/y DEI2 .Screen/y DEI2 #0038 ADD2 + &loop + OVR2 .Screen/y DEO2 + #21 .Screen/color DEO + .Screen/addr DEI2 8+ .Screen/addr DEO2 + .Screen/x DEI2 8+ .Screen/x DEO2 + #21 .Screen/color DEO + .Screen/addr DEI2 8+ .Screen/addr DEO2 + .Screen/x DEI2 8- .Screen/x DEO2 SWP2 8+ SWP2 - OVR2 OVR2 LTH2 ^$loop JNZ + OVR2 OVR2 LTH2 ,&loop JNZ POP2 POP2 @@ -315,103 +315,103 @@ RTN @draw-octaves ( -- ) - ~trkframe.x1 #0018 SUB2 DUP2 ~trkframe.y1 ,draw-octave JSR2 - ~trkframe.y1 #0038 ADD2 ,draw-octave JSR2 - ~trkframe.x1 #0028 SUB2 =Screen.x - ~trkframe.y1 #0030 ADD2 =Screen.y - ,font_hex #0028 ADD2 =Screen.addr - #23 =Screen.color - ~trkframe.x1 #0030 SUB2 =Screen.x - ,font_hex #0060 ADD2 =Screen.addr - #23 =Screen.color - ~trkframe.x1 #0028 SUB2 =Screen.x - ~trkframe.y1 #0068 ADD2 =Screen.y - ,font_hex #0020 ADD2 =Screen.addr - #23 =Screen.color - ~trkframe.x1 #0030 SUB2 =Screen.x - ,font_hex #0060 ADD2 =Screen.addr - #23 =Screen.color + .trkframe/x1 PEK2 #0018 SUB2 DUP2 .trkframe/y1 PEK2 ;draw-octave JSR2 + .trkframe/y1 PEK2 #0038 ADD2 ;draw-octave JSR2 + .trkframe/x1 PEK2 #0028 SUB2 .Screen/x DEO2 + .trkframe/y1 PEK2 #0030 ADD2 .Screen/y DEO2 + ;font_hex #0028 ADD2 .Screen/addr DEO2 + #23 .Screen/color DEO + .trkframe/x1 PEK2 #0030 SUB2 .Screen/x DEO2 + ;font_hex #0060 ADD2 .Screen/addr DEO2 + #23 .Screen/color DEO + .trkframe/x1 PEK2 #0028 SUB2 .Screen/x DEO2 + .trkframe/y1 PEK2 #0068 ADD2 .Screen/y DEO2 + ;font_hex #0020 ADD2 .Screen/addr DEO2 + #23 .Screen/color DEO + .trkframe/x1 PEK2 #0030 SUB2 .Screen/x DEO2 + ;font_hex #0060 ADD2 .Screen/addr DEO2 + #23 .Screen/color DEO RTN @draw-timeline ( -- ) - ,draw-bars JSR2 - ,draw-octaves JSR2 + ;draw-bars JSR2 + ;draw-octaves JSR2 RTN @draw-knob ( x* y* value -- ) - ( load ) =knob.value =knob.y =knob.x - ~knob.x =Screen.x - ~knob.y =Screen.y ,knob_icns =Screen.addr #21 =Screen.color - ~knob.x 8+ =Screen.x ,knob_icns 8+ =Screen.addr #21 =Screen.color - ~knob.y 8+ =Screen.y ,knob_icns #0018 ADD2 =Screen.addr #21 =Screen.color - ~knob.x =Screen.x ,knob_icns #0010 ADD2 =Screen.addr #21 =Screen.color - ~knob.x #00 #00 ~knob.value ,knob_offsetx ADD2 PEK2 ADD2 =Screen.x - ~knob.y #00 #00 ~knob.value ,knob_offsety ADD2 PEK2 ADD2 =Screen.y - ,knob_icns #0020 ADD2 =Screen.addr - #25 =Screen.color - ~knob.x #0004 ADD2 =Screen.x - ~knob.y #0010 ADD2 =Screen.y - ,font_hex #00 ~knob.value #08 MUL ADD2 =Screen.addr - #21 =Screen.color + ( load ) .knob/value POK .knob/y POK2 .knob/x POK2 + .knob/x PEK2 .Screen/x DEO2 + .knob/y PEK2 .Screen/y DEO2 ;knob_icns .Screen/addr DEO2 #21 .Screen/color DEO + .knob/x PEK2 8+ .Screen/x DEO2 ;knob_icns 8+ .Screen/addr DEO2 #21 .Screen/color DEO + .knob/y PEK2 8+ .Screen/y DEO2 ;knob_icns #0018 ADD2 .Screen/addr DEO2 #21 .Screen/color DEO + .knob/x PEK2 .Screen/x DEO2 ;knob_icns #0010 ADD2 .Screen/addr DEO2 #21 .Screen/color DEO + .knob/x PEK2 #00 #00 .knob/value PEK ;knob_offsetx ADD2 GET ADD2 .Screen/x DEO2 + .knob/y PEK2 #00 #00 .knob/value PEK ;knob_offsety ADD2 GET ADD2 .Screen/y DEO2 + ;knob_icns #0020 ADD2 .Screen/addr DEO2 + #25 .Screen/color DEO + .knob/x PEK2 #0004 ADD2 .Screen/x DEO2 + .knob/y PEK2 #0010 ADD2 .Screen/y DEO2 + ;font_hex #00 .knob/value PEK #08 MUL ADD2 .Screen/addr DEO2 + #21 .Screen/color DEO RTN @draw-controls ( -- ) - ~ctlframe.x1 ~ctlframe.y1 ~ctlframe.x2 ~ctlframe.y2 #01 ,line-rect JSR2 + .ctlframe/x1 PEK2 .ctlframe/y1 PEK2 .ctlframe/x2 PEK2 .ctlframe/y2 PEK2 #01 ;line-rect JSR2 ( env ) - ~ctlframe.x1 8+ ~ctlframe.y1 8+ #22 ,env_txt ,draw-label JSR2 - ~ctlframe.x1 8+ ~ctlframe.y1 #0010 ADD2 - ,adsr #00 ~track.active #04 MUL ADD2 PEK2 #04 SFT - ,draw-knob JSR2 - ~ctlframe.x1 #0018 ADD2 ~ctlframe.y1 #0010 ADD2 - ,adsr #00 ~track.active #04 MUL ADD2 #0001 ADD2 PEK2 #04 SFT - ,draw-knob JSR2 - ~ctlframe.x1 #0028 ADD2 ~ctlframe.y1 #0010 ADD2 - ,adsr #00 ~track.active #04 MUL ADD2 #0002 ADD2 PEK2 #04 SFT - ,draw-knob JSR2 - ~ctlframe.x1 #0038 ADD2 ~ctlframe.y1 #0010 ADD2 - ,adsr #00 ~track.active #04 MUL ADD2 #0003 ADD2 PEK2 #04 SFT - ,draw-knob JSR2 + .ctlframe/x1 PEK2 8+ .ctlframe/y1 PEK2 8+ #22 ;env_txt ;draw-label JSR2 + .ctlframe/x1 PEK2 8+ .ctlframe/y1 PEK2 #0010 ADD2 + ;adsr #00 .track/active PEK #04 MUL ADD2 GET #04 SFT + ;draw-knob JSR2 + .ctlframe/x1 PEK2 #0018 ADD2 .ctlframe/y1 PEK2 #0010 ADD2 + ;adsr #00 .track/active PEK #04 MUL ADD2 #0001 ADD2 GET #04 SFT + ;draw-knob JSR2 + .ctlframe/x1 PEK2 #0028 ADD2 .ctlframe/y1 PEK2 #0010 ADD2 + ;adsr #00 .track/active PEK #04 MUL ADD2 #0002 ADD2 GET #04 SFT + ;draw-knob JSR2 + .ctlframe/x1 PEK2 #0038 ADD2 .ctlframe/y1 PEK2 #0010 ADD2 + ;adsr #00 .track/active PEK #04 MUL ADD2 #0003 ADD2 GET #04 SFT + ;draw-knob JSR2 ( vol ) - ~ctlframe.x1 #0058 ADD2 ~ctlframe.y1 8+ #22 ,vol_txt ,draw-label JSR2 - ~ctlframe.x1 #0058 ADD2 ~ctlframe.y1 #0010 ADD2 - ,volume #00 ~track.active ADD2 PEK2 #04 SFT - ,draw-knob JSR2 - ~ctlframe.x1 #0068 ADD2 ~ctlframe.y1 #0010 ADD2 - ,volume #00 ~track.active ADD2 PEK2 #0f AND - ,draw-knob JSR2 + .ctlframe/x1 PEK2 #0058 ADD2 .ctlframe/y1 PEK2 8+ #22 ;vol_txt ;draw-label JSR2 + .ctlframe/x1 PEK2 #0058 ADD2 .ctlframe/y1 PEK2 #0010 ADD2 + ;volume #00 .track/active PEK ADD2 GET #04 SFT + ;draw-knob JSR2 + .ctlframe/x1 PEK2 #0068 ADD2 .ctlframe/y1 PEK2 #0010 ADD2 + ;volume #00 .track/active PEK ADD2 GET #0f AND + ;draw-knob JSR2 RTN @draw-channels - ~chnframe.x1 ~chnframe.y1 ~chnframe.x2 ~chnframe.y2 #01 ,line-rect JSR2 - ~chnframe.x1 8+ ~chnframe.y1 8+ #21 ~track.active #00 EQU #07 MUL ADD ,ch1_txt ,draw-label JSR2 - ~chnframe.x1 8+ ~chnframe.y1 #0010 ADD2 #21 ~track.active #01 EQU #07 MUL ADD ,ch2_txt ,draw-label JSR2 - ~chnframe.x1 8+ ~chnframe.y1 #0018 ADD2 #21 ~track.active #02 EQU #07 MUL ADD ,ch3_txt ,draw-label JSR2 - ~chnframe.x1 8+ ~chnframe.y1 #0020 ADD2 #21 ~track.active #03 EQU #07 MUL ADD ,ch4_txt ,draw-label JSR2 + .chnframe/x1 PEK2 .chnframe/y1 PEK2 .chnframe/x2 PEK2 .chnframe/y2 PEK2 #01 ;line-rect JSR2 + .chnframe/x1 PEK2 8+ .chnframe/y1 PEK2 8+ #21 .track/active PEK #00 EQU #07 MUL ADD ;ch1_txt ;draw-label JSR2 + .chnframe/x1 PEK2 8+ .chnframe/y1 PEK2 #0010 ADD2 #21 .track/active PEK #01 EQU #07 MUL ADD ;ch2_txt ;draw-label JSR2 + .chnframe/x1 PEK2 8+ .chnframe/y1 PEK2 #0018 ADD2 #21 .track/active PEK #02 EQU #07 MUL ADD ;ch3_txt ;draw-label JSR2 + .chnframe/x1 PEK2 8+ .chnframe/y1 PEK2 #0020 ADD2 #21 .track/active PEK #03 EQU #07 MUL ADD ;ch4_txt ;draw-label JSR2 RTN @draw-cursor ( -- ) ( clear last cursor ) - ,clear_icn =Screen.addr - ~pointer.x =Screen.x - ~pointer.y =Screen.y - #30 =Screen.color + ;clear_icn .Screen/addr DEO2 + .pointer/x PEK2 .Screen/x DEO2 + .pointer/y PEK2 .Screen/y DEO2 + #30 .Screen/color DEO ( record pointer positions ) - ~Mouse.x =pointer.x ~Mouse.y =pointer.y + .Mouse/x DEI2 .pointer/x POK2 .Mouse/y DEI2 .pointer/y POK2 ( draw new cursor ) - ,cursor_icn =Screen.addr - ~pointer.x =Screen.x - ~pointer.y =Screen.y - #32 ~Mouse.state #00 NEQ ADD =Screen.color + ;cursor_icn .Screen/addr DEO2 + .pointer/x PEK2 .Screen/x DEO2 + .pointer/y PEK2 .Screen/y DEO2 + #32 .Mouse/state DEI #00 NEQ ADD .Screen/color DEO RTN @@ -419,61 +419,61 @@ RTN @draw-label ( x y color addr -- ) - ( load ) =label.addr =label.color =Screen.y =Screen.x - ~label.addr - $loop - ( draw ) DUP2 PEK2 #00 SWP 8* ,font ADD2 =Screen.addr ~label.color =Screen.color + ( load ) .label/addr POK2 .label/color POK .Screen/y DEO2 .Screen/x DEO2 + .label/addr PEK2 + &loop + ( draw ) DUP2 GET #00 SWP 8* ;font ADD2 .Screen/addr DEO2 .label/color PEK .Screen/color DEO ( incr ) ++ - ( incr ) ~Screen.x 8+ =Screen.x - DUP2 PEK2 #00 NEQ ^$loop JNZ + ( incr ) .Screen/x DEI2 8+ .Screen/x DEO2 + DUP2 GET #00 NEQ ,&loop JNZ POP2 RTN @line-vertical-dotted ( x y0 y1 color -- ) - =color STH2 SWP2 =Screen.x STH2r OVR2 =Screen.y - $draw-ver - ( draw ) ~color =Screen.color - ( incr ) SWP2 #0002 ADD2 DUP2 =Screen.y SWP2 - OVR2 OVR2 LTH2 ^$draw-ver JNZ + .color POK STH2 SWP2 .Screen/x DEO2 STH2r OVR2 .Screen/y DEO2 + &draw-ver + ( draw ) .color PEK .Screen/color DEO + ( incr ) SWP2 #0002 ADD2 DUP2 .Screen/y DEO2 SWP2 + OVR2 OVR2 LTH2 ,&draw-ver JNZ POP2 POP2 RTN @line-horizontal-dotted ( x0 x1 y color -- ) - =color =Screen.y OVR2 =Screen.x - $draw-hor - ( draw ) ~color =Screen.color - ( incr ) SWP2 #0002 ADD2 DUP2 =Screen.x SWP2 - OVR2 OVR2 LTH2 ^$draw-hor JNZ + .color POK .Screen/y DEO2 OVR2 .Screen/x DEO2 + &draw-hor + ( draw ) .color PEK .Screen/color DEO + ( incr ) SWP2 #0002 ADD2 DUP2 .Screen/x DEO2 SWP2 + OVR2 OVR2 LTH2 ,&draw-hor JNZ POP2 POP2 RTN @line-rect ( x1 y1 x2 y2 color ) - ( load ) =color =rect.y2 =rect.x2 DUP2 =Screen.y =rect.y1 DUP2 =Screen.x =rect.x1 - $hor - ( incr ) ~Screen.x ++ =Screen.x - ( draw ) ~rect.y1 =Screen.y ~color =Screen.color - ( draw ) ~rect.y2 =Screen.y ~color =Screen.color - ~Screen.x ~rect.x2 LTH2 ^$hor JNZ - ~rect.y1 =Screen.y - $ver - ( draw ) ~rect.x1 =Screen.x ~color =Screen.color - ( draw ) ~rect.x2 =Screen.x ~color =Screen.color - ( incr ) ~Screen.y ++ =Screen.y - ~Screen.y ~rect.y2 ++ LTH2 ^$ver JNZ + ( load ) .color POK .rect/y2 POK2 .rect/x2 POK2 DUP2 .Screen/y DEO2 .rect/y1 POK2 DUP2 .Screen/x DEO2 .rect/x1 POK2 + &hor + ( incr ) .Screen/x DEI2 ++ .Screen/x DEO2 + ( draw ) .rect/y1 PEK2 .Screen/y DEO2 .color PEK .Screen/color DEO + ( draw ) .rect/y2 PEK2 .Screen/y DEO2 .color PEK .Screen/color DEO + .Screen/x DEI2 .rect/x2 PEK2 LTH2 ,&hor JNZ + .rect/y1 PEK2 .Screen/y DEO2 + &ver + ( draw ) .rect/x1 PEK2 .Screen/x DEO2 .color PEK .Screen/color DEO + ( draw ) .rect/x2 PEK2 .Screen/x DEO2 .color PEK .Screen/color DEO + ( incr ) .Screen/y DEI2 ++ .Screen/y DEO2 + .Screen/y DEI2 .rect/y2 PEK2 ++ LTH2 ,&ver JNZ RTN @adsr-envelope ( -- ) - #ff ,adsr #00 ~Audio.play #04 MUL ADD2 PEK2 SOUND - #80 ,adsr #00 ~Audio.play #04 MUL ADD2 #0001 ADD2 PEK2 SOUND - #80 ,adsr #00 ~Audio.play #04 MUL ADD2 #0002 ADD2 PEK2 SOUND - #00 ,adsr #00 ~Audio.play #04 MUL ADD2 #0003 ADD2 PEK2 SOUND + #ff ;adsr #00 .Audio/play DEI #04 MUL ADD2 GET SOUND + #80 ;adsr #00 .Audio/play DEI #04 MUL ADD2 #0001 ADD2 GET SOUND + #80 ;adsr #00 .Audio/play DEI #04 MUL ADD2 #0002 ADD2 GET SOUND + #00 ;adsr #00 .Audio/play DEI #04 MUL ADD2 #0003 ADD2 GET SOUND SOUND_FINISH BRK @@ -490,19 +490,19 @@ RTN #8040 SOUND BRK -@ch1_txt [ CHN0 00 ] -@ch2_txt [ CHN1 00 ] -@ch3_txt [ CHN2 00 ] -@ch4_txt [ ---- 00 ] -@env_txt [ Envelope 00 ] -@vol_txt [ Volume 00 ] +@ch1_txt [ "CHN0 00 ] +@ch2_txt [ "CHN1 00 ] +@ch3_txt [ "CHN2 00 ] +@ch4_txt [ "---- 00 ] +@env_txt [ "Envelope 00 ] +@vol_txt [ "Volume 00 ] @clear_icn [ 0000 0000 0000 0000 ] @cursor_icn [ 80c0 e0f0 f8e0 1000 ] @note_icn [ 0000 1c3e 3e3e 1c00 ] @head_icn [ 0018 1818 7e3c 1800 ] -@notes [ +@notes [ 3c 3e 40 41 43 45 47 48 4a 4c 4d 4f 51 53 ] @@ -516,20 +516,20 @@ RTN ] @octave_icn [ - ff00 0000 fefe fffe - ff01 0101 0102 fc00 - fffe fc00 fefe fffe - ff01 0101 0102 fc00 - fffe fc00 fefe fffe - ff01 0101 0102 fc00 - fffe fc00 0000 ff00 - ff01 0101 0102 fc00 - ff00 0000 fefe fffe - ff01 0101 0102 fc00 - fffe fc00 fefe fffe - ff01 0101 0102 fc00 - fffe fc00 0000 ff00 - ff01 0101 0102 fc00 + ff00 0000 fefe fffe + ff01 0101 0102 fc00 + fffe fc00 fefe fffe + ff01 0101 0102 fc00 + fffe fc00 fefe fffe + ff01 0101 0102 fc00 + fffe fc00 0000 ff00 + ff01 0101 0102 fc00 + ff00 0000 fefe fffe + ff01 0101 0102 fc00 + fffe fc00 fefe fffe + ff01 0101 0102 fc00 + fffe fc00 0000 ff00 + ff01 0101 0102 fc00 ] @knob_offsetx [ @@ -542,19 +542,19 @@ RTN 00 00 01 02 03 05 06 07 ] -@font_hex ( 0-F ) +@font_hex ( 0-F ) [ 007c 8282 8282 827c 0030 1010 1010 1010 007c 8202 7c80 80fe 007c 8202 1c02 827c 000c 1424 4484 fe04 00fe 8080 7c02 827c 007c 8280 fc82 827c 007c 8202 1e02 0202 007c 8282 7c82 827c 007c 8282 7e02 827c - 007c 8202 7e82 827e 00fc 8282 fc82 82fc - 007c 8280 8080 827c 00fc 8282 8282 82fc + 007c 8202 7e82 827e 00fc 8282 fc82 82fc + 007c 8280 8080 827c 00fc 8282 8282 82fc 007c 8280 f080 827c 007c 8280 f080 8080 ] -@font ( spectrum-zx font ) +@font ( spectrum-zx font ) [ 0000 0000 0000 0000 0000 2400 7e3c 0000 0000 2400 3c42 0000 0000 6c7c 7c38 1000 0010 387c 7c38 1000 0038 387c 6c10 3800 0010 387c 7c10 3800 0000 0018 1800 0000 diff --git a/projects/demos/theme.usm b/projects/demos/theme.usm @@ -7,331 +7,337 @@ %STEP8 { #0033 SFT2 } %S2B { SWP POP } -;center { x 2 y 2 } -;color { byte 1 } -;pointer { x 2 y 2 sprite 2 } -;rect { x1 2 y1 2 x2 2 y2 2 } -;window { x1 2 y1 2 x2 2 y2 2 w 2 h 2 } -;label { x 2 y 2 addr 2 } -;slider { x1 2 y 2 x2 2 pos 2 } -;selection { byte 1 } -;addr { short 2 } -;theme { - r1 1 r2 1 r3 1 r4 1 - g1 1 g2 1 g3 1 g4 1 - b1 1 b2 1 b3 1 b4 1 -} - -|0100 ;System { vector 2 pad 6 r 2 g 2 b 2 } -|0120 ;Screen { vector 2 width 2 height 2 pad 2 x 2 y 2 addr 2 color 1 } -|0160 ;Mouse { vector 2 x 2 y 2 state 1 chord 1 } +( devices ) + +|00 @System [ &vector $2 &pad $6 &r $2 &g $2 &b $2 ] +|20 @Screen [ &vector $2 &width $2 &height $2 &pad $2 &x $2 &y $2 &addr $2 &color $1 ] +|60 @Mouse [ &vector $2 &x $2 &y $2 &state $1 &chord $1 ] + +( variables ) + +|0000 + +@center [ &x $2 &y $2 ] +@color [ &byte $1 ] +@pointer [ &x $2 &y $2 &sprite $2 ] +@rect [ &x1 $2 &y1 $2 &x2 $2 &y2 $2 ] +@window [ &x1 $2 &y1 $2 &x2 $2 &y2 $2 &w $2 &h $2 ] +@label [ &x $2 &y $2 &addr $2 ] +@slider [ &x1 $2 &y $2 &x2 $2 &pos $2 ] +@selection [ &byte $1 ] +@addr [ &byte $1 ] +@theme [ + &r1 $1 &r2 $1 &r3 $1 &r4 $1 + &g1 $1 &g2 $1 &g3 $1 &g4 $1 + &b1 $1 &b2 $1 &b3 $1 &b4 $1 +] ( program ) -|0200 +|0100 - ( theme ) #127f =System.r #34e7 =System.g #56c4 =System.b - ( vectors ) ,on-mouse =Mouse.vector + ( theme ) #127f .System/r DEO2 #34e7 .System/g DEO2 #56c4 .System/b DEO2 + ( vectors ) ;on-mouse .Mouse/vector DEO2 - #00b0 =window.w - #0050 =window.h + #00b0 .window/w POK2 + #0050 .window/h POK2 ( center window ) - ~Screen.width #0002 DIV2 ~window.w #0002 DIV2 SUB2 =window.x1 - ~Screen.height #0002 DIV2 ~window.h #0002 DIV2 SUB2 =window.y1 + .Screen/width DEI2 #0002 DIV2 .window/w PEK2 #0002 DIV2 SUB2 .window/x1 POK2 + .Screen/height DEI2 #0002 DIV2 .window/h PEK2 #0002 DIV2 SUB2 .window/y1 POK2 - #01 =theme.r1 #02 =theme.g1 #03 =theme.b1 - #04 =theme.r2 #06 =theme.g2 #07 =theme.b2 - #0a =theme.r3 #09 =theme.g3 #08 =theme.b3 - #0c =theme.r4 #0b =theme.g4 #0d =theme.b4 + #01 .theme/r1 POK #02 .theme/g1 POK #03 .theme/b1 POK + #04 .theme/r2 POK #06 .theme/g2 POK #07 .theme/b2 POK + #0a .theme/r3 POK #09 .theme/g3 POK #08 .theme/b3 POK + #0c .theme/r4 POK #0b .theme/g4 POK #0d .theme/b4 POK ( find screen center ) - ~Screen.width #0002 DIV2 =center.x - ~Screen.height #0002 DIV2 =center.y + .Screen/width DEI2 #0002 DIV2 .center/x POK2 + .Screen/height DEI2 #0002 DIV2 .center/y POK2 - ,update-theme JSR2 - ,draw-background JSR2 - ,draw-window JSR2 + ;update-theme JSR2 + ;draw-background JSR2 + ;draw-window JSR2 BRK -@on-mouse +@on-mouse - ,draw-cursor JSR2 - - ~Mouse.state #00 NEQ ,$no-skip JNZ2 BRK $no-skip - - ~Mouse.y ~window.y1 SUB2 STEP8 - - DUP2 #0010 NEQ2 ^$no-touch-red JNZ - ~Mouse.x ~window.x1 #0060 ADD2 LTH2 ^$no-touch-red JNZ - ~Mouse.x ~window.x1 #009c ADD2 GTH2 ^$no-touch-red JNZ - ( get new value ) ~Mouse.x ~window.x1 SUB2 #0060 SUB2 #0004 DIV2 S2B ,theme.r1 #00 ~selection ADD2 POK2 - $no-touch-red - DUP2 #0020 NEQ2 ^$no-touch-green JNZ - ~Mouse.x ~window.x1 #0060 ADD2 LTH2 ^$no-touch-green JNZ - ~Mouse.x ~window.x1 #009c ADD2 GTH2 ^$no-touch-green JNZ - ( get new value ) ~Mouse.x ~window.x1 SUB2 #0060 SUB2 #0004 DIV2 S2B ,theme.g1 #00 ~selection ADD2 POK2 - $no-touch-green - DUP2 #0030 NEQ2 ^$no-touch-blue JNZ - ~Mouse.x ~window.x1 #0060 ADD2 LTH2 ^$no-touch-blue JNZ - ~Mouse.x ~window.x1 #009c ADD2 GTH2 ^$no-touch-blue JNZ - ( get new value ) ~Mouse.x ~window.x1 SUB2 #0060 SUB2 #0004 DIV2 S2B ,theme.b1 #00 ~selection ADD2 POK2 - $no-touch-blue - DUP2 #0040 NEQ2 ^$no-touch-radio JNZ - ~Mouse.x ~window.x1 #0050 ADD2 LTH2 ^$no-touch-radio JNZ - ~Mouse.x ~window.x1 #008c ADD2 GTH2 ^$no-touch-radio JNZ - ~Mouse.x ~window.x1 SUB2 #0050 SUB2 STEP8 2/ #0008 DIV2 S2B =selection - $no-touch-radio + ;draw-cursor JSR2 + + .Mouse/state DEI #00 NEQ ;&no-skip JNZ2 BRK &no-skip + + .Mouse/y DEI2 .window/y1 PEK2 SUB2 STEP8 + + DUP2 #0010 NEQ2 ,&no-touch-red JNZ + .Mouse/x DEI2 .window/x1 PEK2 #0060 ADD2 LTH2 ,&no-touch-red JNZ + .Mouse/x DEI2 .window/x1 PEK2 #009c ADD2 GTH2 ,&no-touch-red JNZ + ( get new value ) .Mouse/x DEI2 .window/x1 PEK2 SUB2 #0060 SUB2 #0004 DIV2 S2B ;theme/r1 #00 .selection PEK ADD2 PUT + &no-touch-red + DUP2 #0020 NEQ2 ,&no-touch-green JNZ + .Mouse/x DEI2 .window/x1 PEK2 #0060 ADD2 LTH2 ,&no-touch-green JNZ + .Mouse/x DEI2 .window/x1 PEK2 #009c ADD2 GTH2 ,&no-touch-green JNZ + ( get new value ) .Mouse/x DEI2 .window/x1 PEK2 SUB2 #0060 SUB2 #0004 DIV2 S2B ;theme/g1 #00 .selection PEK ADD2 PUT + &no-touch-green + DUP2 #0030 NEQ2 ,&no-touch-blue JNZ + .Mouse/x DEI2 .window/x1 PEK2 #0060 ADD2 LTH2 ,&no-touch-blue JNZ + .Mouse/x DEI2 .window/x1 PEK2 #009c ADD2 GTH2 ,&no-touch-blue JNZ + ( get new value ) .Mouse/x DEI2 .window/x1 PEK2 SUB2 #0060 SUB2 #0004 DIV2 S2B ;theme/b1 #00 .selection PEK ADD2 PUT + &no-touch-blue + DUP2 #0040 NEQ2 ,&no-touch-radio JNZ + .Mouse/x DEI2 .window/x1 PEK2 #0050 ADD2 LTH2 ,&no-touch-radio JNZ + .Mouse/x DEI2 .window/x1 PEK2 #008c ADD2 GTH2 ,&no-touch-radio JNZ + .Mouse/x DEI2 .window/x1 PEK2 SUB2 #0050 SUB2 STEP8 2/ #0008 DIV2 S2B .selection POK + &no-touch-radio POP2 - ,update-theme JSR2 - ,draw-window JSR2 + ;update-theme JSR2 + ;draw-window JSR2 -BRK +BRK @update-theme - #0108 PEK2 #0f AND ~theme.r1 #40 SFT ADD #0108 POK2 - #010a PEK2 #0f AND ~theme.g1 #40 SFT ADD #010a POK2 - #010c PEK2 #0f AND ~theme.b1 #40 SFT ADD #010c POK2 - #0108 PEK2 #f0 AND ~theme.r2 ADD #0108 POK2 - #010a PEK2 #f0 AND ~theme.g2 ADD #010a POK2 - #010c PEK2 #f0 AND ~theme.b2 ADD #010c POK2 - #0109 PEK2 #0f AND ~theme.r3 #40 SFT ADD #0109 POK2 - #010b PEK2 #0f AND ~theme.g3 #40 SFT ADD #010b POK2 - #010d PEK2 #0f AND ~theme.b3 #40 SFT ADD #010d POK2 - #0109 PEK2 #f0 AND ~theme.r4 ADD #0109 POK2 - #010b PEK2 #f0 AND ~theme.g4 ADD #010b POK2 - #010d PEK2 #f0 AND ~theme.b4 ADD #010d POK2 + #08 DEI #0f AND .theme/r1 PEK #40 SFT ADD #08 DEO + #0a DEI #0f AND .theme/g1 PEK #40 SFT ADD #0a DEO + #0c DEI #0f AND .theme/b1 PEK #40 SFT ADD #0c DEO + #08 DEI #f0 AND .theme/r2 PEK ADD #08 DEO + #0a DEI #f0 AND .theme/g2 PEK ADD #0a DEO + #0c DEI #f0 AND .theme/b2 PEK ADD #0c DEO + #09 DEI #0f AND .theme/r3 PEK #40 SFT ADD #09 DEO + #0b DEI #0f AND .theme/g3 PEK #40 SFT ADD #0b DEO + #0d DEI #0f AND .theme/b3 PEK #40 SFT ADD #0d DEO + #09 DEI #f0 AND .theme/r4 PEK ADD #09 DEO + #0b DEI #f0 AND .theme/g4 PEK ADD #0b DEO + #0d DEI #f0 AND .theme/b4 PEK ADD #0d DEO RTN @draw-background ( draw hor line ) - #0000 =Screen.x ~center.y =Screen.y - #0000 ~Screen.width ( from/to ) - $draw-hor - ( draw ) #01 =Screen.color - ( incr ) SWP2 #0002 ADD2 DUP2 =Screen.x SWP2 - OVR2 OVR2 LTH2 ^$draw-hor JNZ + #0000 .Screen/x DEO2 .center/y PEK2 .Screen/y DEO2 + #0000 .Screen/width DEI2 ( from/to ) + &draw-hor + ( draw ) #01 .Screen/color DEO + ( incr ) SWP2 #0002 ADD2 DUP2 .Screen/x DEO2 SWP2 + OVR2 OVR2 LTH2 ,&draw-hor JNZ POP2 POP2 ( draw ver line ) - ~center.x =Screen.x #0000 =Screen.y - #0000 ~Screen.height ( from/to ) - $draw-ver - ( draw ) #02 =Screen.color - ( incr ) SWP2 #0002 ADD2 DUP2 =Screen.y SWP2 - OVR2 OVR2 LTH2 ^$draw-ver JNZ + .center/x PEK2 .Screen/x DEO2 #0000 .Screen/y DEO2 + #0000 .Screen/height DEI2 ( from/to ) + &draw-ver + ( draw ) #02 .Screen/color DEO + ( incr ) SWP2 #0002 ADD2 DUP2 .Screen/y DEO2 SWP2 + OVR2 OVR2 LTH2 ,&draw-ver JNZ POP2 POP2 ( draw blending modes ) - ,preview_icn =Screen.addr - #0010 =Screen.y + ;preview_icn .Screen/addr DEO2 + #0010 .Screen/y DEO2 #00 #08 - $draw-pixel1 - ( move ) OVR #00 SWP #0008 MUL2 #0010 ADD2 =Screen.x - ( draw ) OVR =Screen.color - ( incr ) SWP #01 ADD SWP - DUP2 LTH ^$draw-pixel1 JNZ + &draw-pixel1 + ( move ) OVR #00 SWP #0008 MUL2 #0010 ADD2 .Screen/x DEO2 + ( draw ) OVR .Screen/color DEO + ( incr ) SWP #01 ADD SWP + DUP2 LTH ,&draw-pixel1 JNZ POP POP - #0018 =Screen.y + #0018 .Screen/y DEO2 #00 #08 - $draw-pixel2 - ( move ) OVR #00 SWP #0008 MUL2 #0010 ADD2 =Screen.x - ( draw ) OVR #08 ADD =Screen.color - ( incr ) SWP #01 ADD SWP - DUP2 LTH ^$draw-pixel2 JNZ + &draw-pixel2 + ( move ) OVR #00 SWP #0008 MUL2 #0010 ADD2 .Screen/x DEO2 + ( draw ) OVR #08 ADD .Screen/color DEO + ( incr ) SWP #01 ADD SWP + DUP2 LTH ,&draw-pixel2 JNZ POP POP - #0020 =Screen.y + #0020 .Screen/y DEO2 #00 #08 - $draw-icn1 - ( move ) OVR #00 SWP #0008 MUL2 #0010 ADD2 =Screen.x - ( draw ) OVR #20 ADD =Screen.color - ( incr ) SWP #01 ADD SWP - DUP2 LTH ^$draw-icn1 JNZ + &draw-icn1 + ( move ) OVR #00 SWP #0008 MUL2 #0010 ADD2 .Screen/x DEO2 + ( draw ) OVR #20 ADD .Screen/color DEO + ( incr ) SWP #01 ADD SWP + DUP2 LTH ,&draw-icn1 JNZ POP POP - #0028 =Screen.y + #0028 .Screen/y DEO2 #00 #08 - $draw-icn2 - ( move ) OVR #00 SWP #0008 MUL2 #0010 ADD2 =Screen.x - ( draw ) OVR #28 ADD =Screen.color - ( incr ) SWP #01 ADD SWP - DUP2 LTH ^$draw-icn2 JNZ + &draw-icn2 + ( move ) OVR #00 SWP #0008 MUL2 #0010 ADD2 .Screen/x DEO2 + ( draw ) OVR #28 ADD .Screen/color DEO + ( incr ) SWP #01 ADD SWP + DUP2 LTH ,&draw-icn2 JNZ POP POP - #0030 =Screen.y + #0030 .Screen/y DEO2 #00 #08 - $draw-chr1 - ( move ) OVR #00 SWP #0008 MUL2 #0010 ADD2 =Screen.x - ( draw ) OVR #40 ADD =Screen.color - ( incr ) SWP #01 ADD SWP - DUP2 LTH ^$draw-chr1 JNZ + &draw-chr1 + ( move ) OVR #00 SWP #0008 MUL2 #0010 ADD2 .Screen/x DEO2 + ( draw ) OVR #40 ADD .Screen/color DEO + ( incr ) SWP #01 ADD SWP + DUP2 LTH ,&draw-chr1 JNZ POP POP - #0038 =Screen.y + #0038 .Screen/y DEO2 #00 #08 - $draw-chr2 - ( move ) OVR #00 SWP #0008 MUL2 #0010 ADD2 =Screen.x - ( draw ) OVR #48 ADD =Screen.color - ( incr ) SWP #01 ADD SWP - DUP2 LTH ^$draw-chr2 JNZ + &draw-chr2 + ( move ) OVR #00 SWP #0008 MUL2 #0010 ADD2 .Screen/x DEO2 + ( draw ) OVR #48 ADD .Screen/color DEO + ( incr ) SWP #01 ADD SWP + DUP2 LTH ,&draw-chr2 JNZ POP POP RTN @draw-window - ~window.x1 ~window.w ADD2 =window.x2 - ~window.y1 ~window.h ADD2 =window.y2 - ~window.x1 ~window.y1 ~window.x2 ~window.y2 #02 ,fill-rect JSR2 - ~window.x1 ~window.y1 ~window.x2 ~window.y2 #01 ,line-rect JSR2 - ~window.x1 #0002 SUB2 ~window.y1 #0002 SUB2 ~window.x2 #0002 ADD2 ~window.y2 #0002 ADD2 #01 ,line-rect JSR2 - - ~window.x1 #0008 ADD2 ~window.y1 #0010 ADD2 #25 ,red_txt ,draw-label JSR2 - ~window.x1 #0038 ADD2 ~window.y1 #0010 ADD2 #28 ,System.r ,draw-byte JSR2 - ~window.x1 #0048 ADD2 ~window.y1 #0010 ADD2 #28 ,System.r #0001 ADD2 ,draw-byte JSR2 - - ~window.x1 #0008 ADD2 ~window.y1 #0020 ADD2 #25 ,green_txt ,draw-label JSR2 - ~window.x1 #0038 ADD2 ~window.y1 #0020 ADD2 #28 ,System.g ,draw-byte JSR2 - ~window.x1 #0048 ADD2 ~window.y1 #0020 ADD2 #28 ,System.g #0001 ADD2 ,draw-byte JSR2 - - ~window.x1 #0008 ADD2 ~window.y1 #0030 ADD2 #25 ,blue_txt ,draw-label JSR2 - ~window.x1 #0038 ADD2 ~window.y1 #0030 ADD2 #28 ,System.b ,draw-byte JSR2 - ~window.x1 #0048 ADD2 ~window.y1 #0030 ADD2 #28 ,System.b #0001 ADD2 ,draw-byte JSR2 - - ~window.x1 #0060 ADD2 ~window.y1 #0010 ADD2 ~window.x1 #0090 ADD2 #00 ,theme.r1 ~selection ADD PEK2 #0004 MUL2 #01 ,draw-slider JSR2 - ~window.x1 #0060 ADD2 ~window.y1 #0020 ADD2 ~window.x1 #0090 ADD2 #00 ,theme.g1 ~selection ADD PEK2 #0004 MUL2 #01 ,draw-slider JSR2 - ~window.x1 #0060 ADD2 ~window.y1 #0030 ADD2 ~window.x1 #0090 ADD2 #00 ,theme.b1 ~selection ADD PEK2 #0004 MUL2 #01 ,draw-slider JSR2 - - ~window.x1 #0050 ADD2 =Screen.x - ~window.y1 #0040 ADD2 =Screen.y - ,radio_icns #00 ~selection #00 EQU #0008 MUL2 ADD2 =Screen.addr - #25 =Screen.color - - ~window.x1 #0060 ADD2 =Screen.x - ~window.y1 #0040 ADD2 =Screen.y - ,radio_icns #00 ~selection #01 EQU #0008 MUL2 ADD2 =Screen.addr - #25 =Screen.color - - ~window.x1 #0070 ADD2 =Screen.x - ~window.y1 #0040 ADD2 =Screen.y - ,radio_icns #00 ~selection #02 EQU #0008 MUL2 ADD2 =Screen.addr - #25 =Screen.color - - ~window.x1 #0080 ADD2 =Screen.x - ~window.y1 #0040 ADD2 =Screen.y - ,radio_icns #00 ~selection #03 EQU #0008 MUL2 ADD2 =Screen.addr - #25 =Screen.color + .window/x1 PEK2 .window/w PEK2 ADD2 .window/x2 POK2 + .window/y1 PEK2 .window/h PEK2 ADD2 .window/y2 POK2 + .window/x1 PEK2 .window/y1 PEK2 .window/x2 PEK2 .window/y2 PEK2 #02 ;fill-rect JSR2 + .window/x1 PEK2 .window/y1 PEK2 .window/x2 PEK2 .window/y2 PEK2 #01 ;line-rect JSR2 + .window/x1 PEK2 #0002 SUB2 .window/y1 PEK2 #0002 SUB2 .window/x2 PEK2 #0002 ADD2 .window/y2 PEK2 #0002 ADD2 #01 ;line-rect JSR2 + + .window/x1 PEK2 #0008 ADD2 .window/y1 PEK2 #0010 ADD2 #25 ;red_txt ;draw-label JSR2 + .window/x1 PEK2 #0038 ADD2 .window/y1 PEK2 #0010 ADD2 #28 .System/r ;draw-byte JSR2 + .window/x1 PEK2 #0048 ADD2 .window/y1 PEK2 #0010 ADD2 #28 .System/r #01 ADD ;draw-byte JSR2 + + .window/x1 PEK2 #0008 ADD2 .window/y1 PEK2 #0020 ADD2 #25 ;green_txt ;draw-label JSR2 + .window/x1 PEK2 #0038 ADD2 .window/y1 PEK2 #0020 ADD2 #28 .System/g ;draw-byte JSR2 + .window/x1 PEK2 #0048 ADD2 .window/y1 PEK2 #0020 ADD2 #28 .System/g #01 ADD ;draw-byte JSR2 + + .window/x1 PEK2 #0008 ADD2 .window/y1 PEK2 #0030 ADD2 #25 ;blue_txt ;draw-label JSR2 + .window/x1 PEK2 #0038 ADD2 .window/y1 PEK2 #0030 ADD2 #28 .System/b ;draw-byte JSR2 + .window/x1 PEK2 #0048 ADD2 .window/y1 PEK2 #0030 ADD2 #28 .System/b #01 ADD ;draw-byte JSR2 + + .window/x1 PEK2 #0060 ADD2 .window/y1 PEK2 #0010 ADD2 .window/x1 PEK2 #0090 ADD2 #00 ;theme/r1 .selection PEK ADD GET #0004 MUL2 #01 ;draw-slider JSR2 + .window/x1 PEK2 #0060 ADD2 .window/y1 PEK2 #0020 ADD2 .window/x1 PEK2 #0090 ADD2 #00 ;theme/g1 .selection PEK ADD GET #0004 MUL2 #01 ;draw-slider JSR2 + .window/x1 PEK2 #0060 ADD2 .window/y1 PEK2 #0030 ADD2 .window/x1 PEK2 #0090 ADD2 #00 ;theme/b1 .selection PEK ADD GET #0004 MUL2 #01 ;draw-slider JSR2 + + .window/x1 PEK2 #0050 ADD2 .Screen/x DEO2 + .window/y1 PEK2 #0040 ADD2 .Screen/y DEO2 + ;radio_icns #00 .selection PEK #00 EQU #0008 MUL2 ADD2 .Screen/addr DEO2 + #25 .Screen/color DEO + + .window/x1 PEK2 #0060 ADD2 .Screen/x DEO2 + .window/y1 PEK2 #0040 ADD2 .Screen/y DEO2 + ;radio_icns #00 .selection PEK #01 EQU #0008 MUL2 ADD2 .Screen/addr DEO2 + #25 .Screen/color DEO + + .window/x1 PEK2 #0070 ADD2 .Screen/x DEO2 + .window/y1 PEK2 #0040 ADD2 .Screen/y DEO2 + ;radio_icns #00 .selection PEK #02 EQU #0008 MUL2 ADD2 .Screen/addr DEO2 + #25 .Screen/color DEO + + .window/x1 PEK2 #0080 ADD2 .Screen/x DEO2 + .window/y1 PEK2 #0040 ADD2 .Screen/y DEO2 + ;radio_icns #00 .selection PEK #03 EQU #0008 MUL2 ADD2 .Screen/addr DEO2 + #25 .Screen/color DEO RTN @draw-cursor ( -- ) ( clear last cursor ) - ,clear_icn =Screen.addr - ~pointer.x =Screen.x - ~pointer.y =Screen.y - #30 =Screen.color + ;clear_icn .Screen/addr DEO2 + .pointer/x PEK2 .Screen/x DEO2 + .pointer/y PEK2 .Screen/y DEO2 + #30 .Screen/color DEO ( record pointer positions ) - ~Mouse.x =pointer.x ~Mouse.y =pointer.y + .Mouse/x DEI2 .pointer/x POK2 .Mouse/y DEI2 .pointer/y POK2 ( draw new cursor ) - ,pointer_icn =Screen.addr - ~pointer.x =Screen.x - ~pointer.y =Screen.y - #33 ~Mouse.state #00 NEQ #02 MUL SUB =Screen.color + ;pointer_icn .Screen/addr DEO2 + .pointer/x PEK2 .Screen/x DEO2 + .pointer/y PEK2 .Screen/y DEO2 + #33 .Mouse/state DEI #00 NEQ #02 MUL SUB .Screen/color DEO RTN @draw-slider ( x1 y x2 pos color -- ) - ( load ) =color =slider.pos =slider.x2 =slider.y =slider.x1 + ( load ) .color POK .slider/pos POK2 .slider/x2 POK2 .slider/y POK2 .slider/x1 POK2 - ~slider.x1 =Screen.x - ~slider.y =Screen.y - ,halftone_icn =Screen.addr + .slider/x1 PEK2 .Screen/x DEO2 + .slider/y PEK2 .Screen/y DEO2 + ;halftone_icn .Screen/addr DEO2 - ,slidera_icn =Screen.addr - ( draw ) #25 =Screen.color - ,sliderb_icn =Screen.addr + ;slidera_icn .Screen/addr DEO2 + ( draw ) #25 .Screen/color DEO + ;sliderb_icn .Screen/addr DEO2 - $loop - ( incr ) ~Screen.x 8+ =Screen.x - ( draw ) #25 =Screen.color - ~Screen.x ~slider.x2 #0008 ADD2 LTH2 ^$loop JNZ + &loop + ( incr ) .Screen/x DEI2 8+ .Screen/x DEO2 + ( draw ) #25 .Screen/color DEO + .Screen/x DEI2 .slider/x2 PEK2 #0008 ADD2 LTH2 ,&loop JNZ - ( incr ) ~Screen.x #0004 ADD2 =Screen.x - ,sliderc_icn =Screen.addr - ( draw ) #25 =Screen.color + ( incr ) .Screen/x DEI2 #0004 ADD2 .Screen/x DEO2 + ;sliderc_icn .Screen/addr DEO2 + ( draw ) #25 .Screen/color DEO - ~slider.x1 ~slider.pos ADD2 =Screen.x - ,sliderd_icn =Screen.addr - ( draw ) #2a =Screen.color + .slider/x1 PEK2 .slider/pos PEK2 ADD2 .Screen/x DEO2 + ;sliderd_icn .Screen/addr DEO2 + ( draw ) #2a .Screen/color DEO RTN @fill-rect ( x1 y1 x2 y2 color ) - =color + .color POK ( x1 x2 y1 y2 ) ROT2 SWP2 - $ver - ( save ) OVR2 =Screen.y - STH2 STH2 OVR2 OVR2 - $hor - ( save ) OVR2 =Screen.x - ( draw ) ~color =Screen.color + &ver + ( save ) OVR2 .Screen/y DEO2 + STH2 STH2 OVR2 OVR2 + &hor + ( save ) OVR2 .Screen/x DEO2 + ( draw ) .color PEK .Screen/color DEO ( incr ) SWP2 #0001 ADD2 SWP2 - OVR2 OVR2 LTH2 ^$hor JNZ + OVR2 OVR2 LTH2 ,&hor JNZ POP2 POP2 STH2r STH2r ( incr ) SWP2 #0001 ADD2 SWP2 - OVR2 OVR2 LTH2 ^$ver JNZ + OVR2 OVR2 LTH2 ,&ver JNZ POP2 POP2 POP2 POP2 RTN @line-rect ( x1 y1 x2 y2 color -- ) - ( load ) =color =rect.y2 =rect.x2 DUP2 =Screen.y =rect.y1 DUP2 =Screen.x =rect.x1 - $hor - ( incr ) ~Screen.x ++ =Screen.x - ( draw ) ~rect.y1 =Screen.y ~color =Screen.color - ( draw ) ~rect.y2 =Screen.y ~color =Screen.color - ~Screen.x ~rect.x2 LTH2 ^$hor JNZ - ~rect.y1 =Screen.y - $ver - ( draw ) ~rect.x1 =Screen.x ~color =Screen.color - ( draw ) ~rect.x2 =Screen.x ~color =Screen.color - ( incr ) ~Screen.y ++ =Screen.y - ~Screen.y ~rect.y2 ++ LTH2 ^$ver JNZ + ( load ) .color POK .rect/y2 POK2 .rect/x2 POK2 DUP2 .Screen/y DEO2 .rect/y1 POK2 DUP2 .Screen/x DEO2 .rect/x1 POK2 + &hor + ( incr ) .Screen/x DEI2 ++ .Screen/x DEO2 + ( draw ) .rect/y1 PEK2 .Screen/y DEO2 .color PEK .Screen/color DEO + ( draw ) .rect/y2 PEK2 .Screen/y DEO2 .color PEK .Screen/color DEO + .Screen/x DEI2 .rect/x2 PEK2 LTH2 ,&hor JNZ + .rect/y1 PEK2 .Screen/y DEO2 + &ver + ( draw ) .rect/x1 PEK2 .Screen/x DEO2 .color PEK .Screen/color DEO + ( draw ) .rect/x2 PEK2 .Screen/x DEO2 .color PEK .Screen/color DEO + ( incr ) .Screen/y DEI2 ++ .Screen/y DEO2 + .Screen/y DEI2 .rect/y2 PEK2 ++ LTH2 ,&ver JNZ RTN @draw-label ( x y color addr -- ) - ( load ) =label.addr =color =Screen.y =Screen.x ~label.addr - $loop - ( draw ) DUP2 PEK2 #00 SWP #0008 MUL2 ,font ADD2 =Screen.addr ~color =Screen.color + ( load ) .label/addr POK2 .color POK .Screen/y DEO2 .Screen/x DEO2 .label/addr PEK2 + &loop + ( draw ) DUP2 GET #00 SWP #0008 MUL2 ;font ADD2 .Screen/addr DEO2 .color PEK .Screen/color DEO ( incr ) ++ - ( incr ) ~Screen.x 8+ =Screen.x - DUP2 PEK2 #00 NEQ ^$loop JNZ + ( incr ) .Screen/x DEI2 8+ .Screen/x DEO2 + DUP2 GET #00 NEQ ,&loop JNZ POP2 RTN @draw-byte ( x y color addr -- ) - =addr STH - =Screen.y - =Screen.x - ,font_hex #00 ~addr PEK2 #04 SFT #0008 MUL2 ADD2 =Screen.addr - STHr DUP STH =Screen.color - ,font_hex #00 ~addr PEK2 #0f AND #0008 MUL2 ADD2 =Screen.addr - ~Screen.x 8+ =Screen.x - STHr =Screen.color + .addr POK STH + .Screen/y DEO2 + .Screen/x DEO2 + ;font_hex #00 .addr PEK DEI #04 SFT #0008 MUL2 ADD2 .Screen/addr DEO2 + STHr DUP STH .Screen/color DEO + ;font_hex #00 .addr PEK DEI #0f AND #0008 MUL2 ADD2 .Screen/addr DEO2 + .Screen/x DEI2 8+ .Screen/x DEO2 + STHr .Screen/color DEO RTN @@ -342,28 +348,28 @@ RTN @sliderb_icn [ ffff ffff ffff ffff ] @sliderc_icn [ fcfe ffff ffff fefc ] @sliderd_icn [ 003c 7e7e 7e7e 3c00 ] -@preview_icn [ 183c 66db db66 3c18 0000 183c 3c18 0000 ] -@radio_icns +@preview_icn [ 183c 66db db66 3c18 0000 183c 3c18 0000 ] +@radio_icns [ 3c42 8181 8181 423c ] [ 3c42 99bd bd99 423c ] -@red_txt [ Red 00 ] -@green_txt [ Green 00 ] -@blue_txt [ Blue 00 ] +@red_txt [ "Red 00 ] +@green_txt [ "Green 00 ] +@blue_txt [ "Blue 00 ] -@font_hex ( 0-F TODO: should pull from @font instead.. ) +@font_hex ( 0-F TODO: should pull from @font instead.. ) [ 003c 464a 5262 3c00 0018 0808 0808 1c00 003c 4202 3c40 7e00 003c 421c 0242 3c00 000c 1424 447e 0400 007e 407c 0242 3c00 003c 407c 4242 3c00 007e 0204 0810 1000 003c 423c 4242 3c00 003c 4242 3e02 3c00 - 003c 4242 7e42 4200 007c 427c 4242 7c00 - 003c 4240 4042 3c00 007c 4242 4242 7c00 + 003c 4242 7e42 4200 007c 427c 4242 7c00 + 003c 4240 4042 3c00 007c 4242 4242 7c00 007e 4078 4040 7e00 007e 4078 4040 4000 ] -@font ( spectrum-zx font ) +@font ( spectrum-zx font ) [ 0000 0000 0000 0000 0000 2400 7e3c 0000 0000 2400 3c42 0000 0000 6c7c 7c38 1000 0010 387c 7c38 1000 0038 387c 6c10 3800 0010 387c 7c10 3800 0000 0018 1800 0000 diff --git a/projects/examples/gui.hover.usm b/projects/examples/gui.hover.usm @@ -2,94 +2,100 @@ %RTN { JMP2r } -;color { byte 1 } -;pointer { x 2 y 2 sprite 2 } -;rect { x1 2 y1 2 x2 2 y2 2 } -;r1 { x1 2 y1 2 x2 2 y2 2 } -;r2 { x1 2 y1 2 x2 2 y2 2 } -;r3 { x1 2 y1 2 x2 2 y2 2 } +( devices ) -|0100 ;System { vector 2 pad 6 r 2 g 2 b 2 } -|0120 ;Screen { vector 2 width 2 height 2 pad 2 x 2 y 2 addr 2 color 1 } -|0160 ;Mouse { vector 2 x 2 y 2 state 1 chord 1 } +|00 @System [ &vector $2 &pad $6 &r $2 &g $2 &b $2 ] +|20 @Screen [ &vector $2 &width $2 &height $2 &pad $2 &x $2 &y $2 &addr $2 &color $1 ] +|60 @Mouse [ &vector $2 &x $2 &y $2 &state $1 &chord $1 ] + +( variables ) + +|0000 + +@color [ &byte $1 ] +@pointer [ &x $2 &y $2 &sprite $2 ] +@rect [ &x1 $2 &y1 $2 &x2 $2 &y2 $2 ] +@r1 [ &x1 $2 &y1 $2 &x2 $2 &y2 $2 ] +@r2 [ &x1 $2 &y1 $2 &x2 $2 &y2 $2 ] +@r3 [ &x1 $2 &y1 $2 &x2 $2 &y2 $2 ] ( program ) -|0200 +|0100 - ( theme ) #0f0f =System.r #0fff =System.g #0ff0 =System.b - ( vectors ) ,on-mouse =Mouse.vector + ( theme ) #0f0f .System/r DEO2 #0fff .System/g DEO2 #0ff0 .System/b DEO2 + ( vectors ) ;on-mouse .Mouse/vector DEO2 - #0020 #0030 #0060 #0060 =r1.y2 =r1.x2 =r1.y1 =r1.x1 - #0058 #0050 #0090 #0080 =r2.y2 =r2.x2 =r2.y1 =r2.x1 - #0048 #0048 #0080 #0098 =r3.y2 =r3.x2 =r3.y1 =r3.x1 + #0020 #0030 #0060 #0060 .r1/y2 POK2 .r1/x2 POK2 .r1/y1 POK2 .r1/x1 POK2 + #0058 #0050 #0090 #0080 .r2/y2 POK2 .r2/x2 POK2 .r2/y1 POK2 .r2/x1 POK2 + #0048 #0048 #0080 #0098 .r3/y2 POK2 .r3/x2 POK2 .r3/y1 POK2 .r3/x1 POK2 -BRK +( no BRK, run through to on-mouse ) -@on-mouse +@on-mouse - ,pointer_icn =pointer.sprite + ;pointer_icn .pointer/sprite POK2 - #01 =color + #01 .color POK ( matrix comparison ) - ~Mouse.x ~r1.x1 GTH2 ~Mouse.x ~r1.x2 LTH2 #0101 EQU2 - ~Mouse.y ~r1.y1 GTH2 ~Mouse.y ~r1.y2 LTH2 #0101 EQU2 - #0101 NEQ2 ^$draw1 JNZ #02 =color ,hand_icn =pointer.sprite - $draw1 ~r1.x1 ~r1.y1 ~r1.x2 ~r1.y2 ~color ,line-rect JSR2 + .Mouse/x DEI2 .r1/x1 PEK2 GTH2 .Mouse/x DEI2 .r1/x2 PEK2 LTH2 #0101 EQU2 + .Mouse/y DEI2 .r1/y1 PEK2 GTH2 .Mouse/y DEI2 .r1/y2 PEK2 LTH2 #0101 EQU2 + #0101 NEQ2 ,&draw1 JNZ #02 .color POK ;hand_icn .pointer/sprite POK2 + &draw1 .r1/x1 PEK2 .r1/y1 PEK2 .r1/x2 PEK2 .r1/y2 PEK2 .color PEK ;line-rect JSR2 - #01 =color + #01 .color POK ( 2-step comparison ) - ~Mouse.x ~r2.x1 GTH2 ~Mouse.x ~r2.x2 LTH2 #0101 NEQ2 ^$draw2 JNZ - ~Mouse.y ~r2.y1 GTH2 ~Mouse.y ~r2.y2 LTH2 #0101 NEQ2 ^$draw2 JNZ - #03 =color ,hand_icn =pointer.sprite - $draw2 ~r2.x1 ~r2.y1 ~r2.x2 ~r2.y2 ~color ,line-rect JSR2 + .Mouse/x DEI2 .r2/x1 PEK2 GTH2 .Mouse/x DEI2 .r2/x2 PEK2 LTH2 #0101 NEQ2 ,&draw2 JNZ + .Mouse/y DEI2 .r2/y1 PEK2 GTH2 .Mouse/y DEI2 .r2/y2 PEK2 LTH2 #0101 NEQ2 ,&draw2 JNZ + #03 .color POK ;hand_icn .pointer/sprite POK2 + &draw2 .r2/x1 PEK2 .r2/y1 PEK2 .r2/x2 PEK2 .r2/y2 PEK2 .color PEK ;line-rect JSR2 - #01 =color + #01 .color POK ( 4-step comparison ) - ~Mouse.x ~r3.x1 LTH2 ^$draw3 JNZ - ~Mouse.x ~r3.x2 GTH2 ^$draw3 JNZ - ~Mouse.y ~r3.y1 LTH2 ^$draw3 JNZ - ~Mouse.y ~r3.y2 GTH2 ^$draw3 JNZ - #02 =color ,hand_icn =pointer.sprite - $draw3 ~r3.x1 ~r3.y1 ~r3.x2 ~r3.y2 ~color ,line-rect JSR2 + .Mouse/x DEI2 .r3/x1 PEK2 LTH2 ,&draw3 JNZ + .Mouse/x DEI2 .r3/x2 PEK2 GTH2 ,&draw3 JNZ + .Mouse/y DEI2 .r3/y1 PEK2 LTH2 ,&draw3 JNZ + .Mouse/y DEI2 .r3/y2 PEK2 GTH2 ,&draw3 JNZ + #02 .color POK ;hand_icn .pointer/sprite POK2 + &draw3 .r3/x1 PEK2 .r3/y1 PEK2 .r3/x2 PEK2 .r3/y2 PEK2 .color PEK ;line-rect JSR2 - ,draw-cursor JSR2 + ;draw-cursor JSR2 -BRK +BRK @draw-cursor ( clear last cursor ) - ,clear_icn =Screen.addr - ~pointer.x =Screen.x - ~pointer.y =Screen.y - #30 =Screen.color + ;clear_icn .Screen/addr DEO2 + .pointer/x PEK2 .Screen/x DEO2 + .pointer/y PEK2 .Screen/y DEO2 + #30 .Screen/color DEO ( record pointer positions ) - ~Mouse.x =pointer.x ~Mouse.y =pointer.y + .Mouse/x DEI2 .pointer/x POK2 .Mouse/y DEI2 .pointer/y POK2 ( draw new cursor ) - ~pointer.sprite =Screen.addr - ~pointer.x =Screen.x - ~pointer.y =Screen.y - #31 =Screen.color + .pointer/sprite PEK2 .Screen/addr DEO2 + .pointer/x PEK2 .Screen/x DEO2 + .pointer/y PEK2 .Screen/y DEO2 + #31 .Screen/color DEO RTN @line-rect ( x1 y1 x2 y2 color ) - ( load ) =color =rect.y2 =rect.x2 DUP2 =Screen.y =rect.y1 DUP2 =Screen.x =rect.x1 - $hor - ( incr ) ~Screen.x #0001 ADD2 =Screen.x - ( draw ) ~rect.y1 =Screen.y ~color =Screen.color - ( draw ) ~rect.y2 =Screen.y ~color =Screen.color - ~Screen.x ~rect.x2 LTH2 ^$hor JNZ - ~rect.y1 =Screen.y - $ver - ( draw ) ~rect.x1 =Screen.x ~color =Screen.color - ( draw ) ~rect.x2 =Screen.x ~color =Screen.color - ( incr ) ~Screen.y #0001 ADD2 =Screen.y - ~Screen.y ~rect.y2 #0001 ADD2 LTH2 ^$ver JNZ + ( load ) .color POK .rect/y2 POK2 .rect/x2 POK2 DUP2 .Screen/y DEO2 .rect/y1 POK2 DUP2 .Screen/x DEO2 .rect/x1 POK2 + &hor + ( incr ) .Screen/x DEI2 #0001 ADD2 .Screen/x DEO2 + ( draw ) .rect/y1 PEK2 .Screen/y DEO2 .color PEK .Screen/color DEO + ( draw ) .rect/y2 PEK2 .Screen/y DEO2 .color PEK .Screen/color DEO + .Screen/x DEI2 .rect/x2 PEK2 LTH2 ,&hor JNZ + .rect/y1 PEK2 .Screen/y DEO2 + &ver + ( draw ) .rect/x1 PEK2 .Screen/x DEO2 .color PEK .Screen/color DEO + ( draw ) .rect/x2 PEK2 .Screen/x DEO2 .color PEK .Screen/color DEO + ( incr ) .Screen/y DEI2 #0001 ADD2 .Screen/y DEO2 + .Screen/y DEI2 .rect/y2 PEK2 #0001 ADD2 LTH2 ,&ver JNZ RTN diff --git a/projects/examples/gui.label.usm b/projects/examples/gui.label.usm @@ -2,80 +2,86 @@ %RTN { JMP2r } -;label { x 2 y 2 color 1 addr 2 } -;center { x 2 y 2 } +( devices ) -|0100 ;System { vector 2 pad 6 r 2 g 2 b 2 } -|0120 ;Screen { vector 2 width 2 height 2 pad 2 x 2 y 2 addr 2 color 1 } +|00 @System [ &vector $2 &pad $6 &r $2 &g $2 &b $2 ] +|20 @Screen [ &vector $2 &width $2 &height $2 &pad $2 &x $2 &y $2 &addr $2 &color $1 ] + +( variables ) + +|0000 + +@label [ &x $2 &y $2 &color $1 &addr $2 ] +@center [ &x $2 &y $2 ] ( program ) -|0200 +|0100 - ( theme ) #0f0f =System.r #0fff =System.g #0ff0 =System.b + ( theme ) #0f0f .System/r DEO2 #0fff .System/g DEO2 #0ff0 .System/b DEO2 - ,draw JSR2 + ;draw JSR2 BRK @draw ( -- ) ( find screen center ) - ~Screen.width #0002 DIV2 =center.x - ~Screen.height #0002 DIV2 =center.y + .Screen/width DEI2 #0002 DIV2 .center/x POK2 + .Screen/height DEI2 #0002 DIV2 .center/y POK2 ( draw ver line ) - ~center.x =Screen.x #0000 =Screen.y - $draw-ver - ( draw ) #02 =Screen.color - ( incr ) ~Screen.y #0002 ADD2 =Screen.y - ~Screen.y ~Screen.height LTH2 ^$draw-ver JNZ - - ~center.x ~center.y #0010 SUB2 #2c ,text1 ,draw-label-left JSR2 - ~center.x ~center.y #2c ,text2 ,draw-label-middle JSR2 - ~center.x ~center.y #0010 ADD2 #2c ,text3 ,draw-label-right JSR2 - ~center.x ~center.y #0020 ADD2 #2c ,text4 ,draw-label-middle JSR2 - ~center.x ~center.y #0030 ADD2 #2c ,text5 ,draw-label-middle JSR2 + .center/x PEK2 .Screen/x DEO2 #0000 .Screen/y DEO2 + &draw-ver + ( draw ) #02 .Screen/color DEO + ( incr ) .Screen/y DEI2 #0002 ADD2 .Screen/y DEO2 + .Screen/y DEI2 .Screen/height DEI2 LTH2 ,&draw-ver JNZ + + .center/x PEK2 .center/y PEK2 #0010 SUB2 #2c ;text1 ;draw-label-left JSR2 + .center/x PEK2 .center/y PEK2 #2c ;text2 ;draw-label-middle JSR2 + .center/x PEK2 .center/y PEK2 #0010 ADD2 #2c ;text3 ;draw-label-right JSR2 + .center/x PEK2 .center/y PEK2 #0020 ADD2 #2c ;text4 ;draw-label-middle JSR2 + .center/x PEK2 .center/y PEK2 #0030 ADD2 #2c ;text5 ;draw-label-middle JSR2 RTN @draw-label-left ( x y color addr -- ) - ( load ) =label.addr =label.color =Screen.y =Screen.x - ~label.addr - $loop - ( draw ) DUP2 PEK2 #00 SWP #0008 MUL2 ,font ADD2 =Screen.addr ~label.color =Screen.color + ( load ) .label/addr POK2 .label/color POK .Screen/y DEO2 .Screen/x DEO2 + .label/addr PEK2 + &loop + ( draw ) DUP2 GET #00 SWP #0008 MUL2 ;font ADD2 .Screen/addr DEO2 .label/color PEK .Screen/color DEO ( incr ) #0001 ADD2 - ( incr ) ~Screen.x #0008 ADD2 =Screen.x - DUP2 PEK2 #00 NEQ ^$loop JNZ + ( incr ) .Screen/x DEI2 #0008 ADD2 .Screen/x DEO2 + DUP2 GET #00 NEQ ,&loop JNZ POP2 RTN @draw-label-middle ( x y color addr -- ) - ( load ) =label.addr =label.color =Screen.y - ( align ) ~label.addr ,get-text-length JSR2 #0008 MUL2 #0002 DIV2 SUB2 =Screen.x - ~label.addr - $loop - ( draw ) DUP2 PEK2 #00 SWP #0008 MUL2 ,font ADD2 =Screen.addr ~label.color =Screen.color + ( load ) .label/addr POK2 .label/color POK .Screen/y DEO2 + ( align ) .label/addr PEK2 ;get-text-length JSR2 #0008 MUL2 #0002 DIV2 SUB2 .Screen/x DEO2 + .label/addr PEK2 + &loop + ( draw ) DUP2 GET #00 SWP #0008 MUL2 ;font ADD2 .Screen/addr DEO2 .label/color PEK .Screen/color DEO ( incr ) #0001 ADD2 - ( incr ) ~Screen.x #0008 ADD2 =Screen.x - DUP2 PEK2 #00 NEQ ^$loop JNZ + ( incr ) .Screen/x DEI2 #0008 ADD2 .Screen/x DEO2 + DUP2 GET #00 NEQ ,&loop JNZ POP2 RTN @draw-label-right ( x y color addr -- ) - ( load ) =label.addr =label.color =Screen.y - ( align ) ~label.addr ,get-text-length JSR2 #0008 MUL2 SUB2 #0008 SUB2 =Screen.x - ~label.addr - $loop - ( draw ) DUP2 PEK2 #00 SWP #0008 MUL2 ,font ADD2 =Screen.addr ~label.color =Screen.color + ( load ) .label/addr POK2 .label/color POK .Screen/y DEO2 + ( align ) .label/addr PEK2 ;get-text-length JSR2 #0008 MUL2 SUB2 #0008 SUB2 .Screen/x DEO2 + .label/addr PEK2 + &loop + ( draw ) DUP2 GET #00 SWP #0008 MUL2 ;font ADD2 .Screen/addr DEO2 .label/color PEK .Screen/color DEO ( incr ) #0001 ADD2 - ( incr ) ~Screen.x #0008 ADD2 =Screen.x - DUP2 PEK2 #00 NEQ ^$loop JNZ + ( incr ) .Screen/x DEI2 #0008 ADD2 .Screen/x DEO2 + DUP2 GET #00 NEQ ,&loop JNZ POP2 RTN @@ -83,14 +89,14 @@ RTN @get-text-length ( label* -- length ) #0000 ( counter ) - $loop - ( incr ) #0001 ADD2 OVR2 OVR2 ADD2 - PEK2 #00 NEQ ^$loop JNZ + &loop + ( incr ) #0001 ADD2 OVR2 OVR2 ADD2 + GET #00 NEQ ,&loop JNZ SWP2 POP2 RTN -@font ( spectrum-zx font ) +@font ( spectrum-zx font ) [ 0000 0000 0000 0000 0000 2400 7e3c 0000 0000 2400 3c42 0000 0000 6c7c 7c38 1000 0010 387c 7c38 1000 0038 387c 6c10 3800 0010 387c 7c10 3800 0000 0018 1800 0000 @@ -126,8 +132,8 @@ RTN 0008 0808 0808 0800 0030 1008 0810 3000 0000 0032 4c00 0000 3c42 99a1 a199 423c ] -@text1 [ Left 20 Aligned 00 ] -@text2 [ Middle 20 Aligned 00 ] -@text3 [ Right 20 Aligned 00 ] -@text4 [ even 00 ] -@text5 [ odd 00 ] -\ No newline at end of file +@text1 [ "Left 20 "Aligned 00 ] +@text2 [ "Middle 20 "Aligned 00 ] +@text3 [ "Right 20 "Aligned 00 ] +@text4 [ "even 00 ] +@text5 [ "odd 00 ] +\ No newline at end of file diff --git a/projects/examples/gui.picture.usm b/projects/examples/gui.picture.usm @@ -1,103 +1,109 @@ ( GUI Picture ) %RTN { JMP2r } -%8+ { #0008 ADD2 } +%8+ { #0008 ADD2 } -;color { byte 1 } -;position { x 2 y 2 } -;size { width 2 height 2 } +( devices ) -|0100 ;System { vector 2 pad 6 r 2 g 2 b 2 } -|0110 ;Console { vector 2 pad 6 char 1 byte 1 short 2 string 2 } -|0120 ;Screen { vector 2 width 2 height 2 pad 2 x 2 y 2 addr 2 color 1 } -|0170 ;File { vector 2 success 2 offset 2 pad 2 name 2 length 2 load 2 save 2 } +|00 @System [ &vector $2 &pad $6 &r $2 &g $2 &b $2 ] +|10 @Console [ &vector $2 &pad $6 &char $1 &byte $1 &short $2 &string $2 ] +|20 @Screen [ &vector $2 &width $2 &height $2 &pad $2 &x $2 &y $2 &addr $2 &color $1 ] +|70 @File [ &vector $2 &success $2 &offset $2 &pad $2 &name $2 &length $2 &load $2 &save $2 ] + +( variables ) + +|0000 + +@color [ &byte $1 ] +@position [ &x $2 &y $2 ] +@size [ &width $2 &height $2 ] ( program ) -|0200 +|0100 - ( theme ) #037a =System.r #032a =System.g #052a =System.b + ( theme ) #037a .System/r DEO2 #032a .System/g DEO2 #052a .System/b DEO2 - ( background ) ,checker_icn #22 ,cover-pattern JSR2 + ( background ) ;checker_icn #22 ;cover-pattern JSR2 - ( load ) ,icn1_path =File.name #1800 =File.length ,image =File.load - ( draw ) #0008 #0008 #0100 #00c0 #27 ,image ,draw-icn JSR2 + ( load ) ;icn1_path .File/name DEO2 #1800 .File/length DEO2 ;image .File/load DEO2 + ( draw ) #0008 #0008 #0100 #00c0 #27 ;image ;draw-icn JSR2 - ( load ) ,icn2_path =File.name #0800 =File.length ,image =File.load - ( draw ) #0010 #0078 #0080 #0080 #27 ,image ,draw-icn JSR2 + ( load ) ;icn2_path .File/name DEO2 #0800 .File/length DEO2 ;image .File/load DEO2 + ( draw ) #0010 #0078 #0080 #0080 #27 ;image ;draw-icn JSR2 - ( load ) ,chr1_path =File.name #4000 =File.length ,image =File.load - ( draw ) #00a8 #0010 #0100 #0100 #4f ,image ,draw-chr JSR2 + ( load ) ;chr1_path .File/name DEO2 #4000 .File/length DEO2 ;image .File/load DEO2 + ( draw ) #00a8 #0010 #0100 #0100 #4f ;image ;draw-chr JSR2 - ( load ) ,chr2_path =File.name #0900 =File.length ,image =File.load - ( draw ) #0088 #0088 #0060 #0060 #41 ,image ,draw-chr JSR2 + ( load ) ;chr2_path .File/name DEO2 #0900 .File/length DEO2 ;image .File/load DEO2 + ( draw ) #0088 #0088 #0060 #0060 #41 ;image ;draw-chr JSR2 BRK @draw-icn ( x y width height color addr -- ) - ( load ) =Screen.addr =color =size.height =size.width =position.y =position.x - #0000 ~size.height - $ver - ( save ) OVR2 ~position.y ADD2 =Screen.y - #0000 ~size.width - $hor - ( save ) OVR2 ~position.x ADD2 =Screen.x - ( draw ) ~color =Screen.color - ( incr ) ~Screen.addr 8+ =Screen.addr + ( load ) .Screen/addr DEO2 .color POK .size/height POK2 .size/width POK2 .position/y POK2 .position/x POK2 + #0000 .size/height PEK2 + &ver + ( save ) OVR2 .position/y PEK2 ADD2 .Screen/y DEO2 + #0000 .size/width PEK2 + &hor + ( save ) OVR2 .position/x PEK2 ADD2 .Screen/x DEO2 + ( draw ) .color PEK .Screen/color DEO + ( incr ) .Screen/addr DEI2 8+ .Screen/addr DEO2 ( incr ) SWP2 8+ SWP2 - OVR2 OVR2 LTH2 ^$hor JNZ + OVR2 OVR2 LTH2 ,&hor JNZ POP2 POP2 ( incr ) SWP2 8+ SWP2 - OVR2 OVR2 LTH2 ^$ver JNZ + OVR2 OVR2 LTH2 ,&ver JNZ POP2 POP2 RTN @draw-chr ( x y width height color addr -- ) - ( load ) =Screen.addr =color =size.height =size.width =position.y =position.x - #0000 ~size.height - $ver - ( save ) OVR2 ~position.y ADD2 =Screen.y - #0000 ~size.width - $hor - ( save ) OVR2 ~position.x ADD2 =Screen.x - ( draw ) ~color =Screen.color - ( incr ) ~Screen.addr #0010 ADD2 =Screen.addr + ( load ) .Screen/addr DEO2 .color POK .size/height POK2 .size/width POK2 .position/y POK2 .position/x POK2 + #0000 .size/height PEK2 + &ver + ( save ) OVR2 .position/y PEK2 ADD2 .Screen/y DEO2 + #0000 .size/width PEK2 + &hor + ( save ) OVR2 .position/x PEK2 ADD2 .Screen/x DEO2 + ( draw ) .color PEK .Screen/color DEO + ( incr ) .Screen/addr DEI2 #0010 ADD2 .Screen/addr DEO2 ( incr ) SWP2 8+ SWP2 - OVR2 OVR2 LTH2 ^$hor JNZ + OVR2 OVR2 LTH2 ,&hor JNZ POP2 POP2 ( incr ) SWP2 8+ SWP2 - OVR2 OVR2 LTH2 ^$ver JNZ + OVR2 OVR2 LTH2 ,&ver JNZ POP2 POP2 RTN @cover-pattern ( addr color -- ) - ( load ) =color =Screen.addr - #0000 ~Screen.height - $ver - ( save ) OVR2 =Screen.y - #0000 ~Screen.width - $hor - ( save ) OVR2 =Screen.x - ( draw ) ~color =Screen.color + ( load ) .color POK .Screen/addr DEO2 + #0000 .Screen/height DEI2 + &ver + ( save ) OVR2 .Screen/y DEO2 + #0000 .Screen/width DEI2 + &hor + ( save ) OVR2 .Screen/x DEO2 + ( draw ) .color PEK .Screen/color DEO ( incr ) SWP2 8+ SWP2 - OVR2 OVR2 LTH2 ^$hor JNZ + OVR2 OVR2 LTH2 ,&hor JNZ POP2 POP2 ( incr ) SWP2 8+ SWP2 - OVR2 OVR2 LTH2 ^$ver JNZ + OVR2 OVR2 LTH2 ,&ver JNZ POP2 POP2 RTN @checker_icn [ f0f0 f0f0 0f0f 0f0f ] -@icn1_path [ projects/pictures/ergo100x0c0.bit 00 ] -@icn2_path [ projects/pictures/dafu80x80.bit 00 ] -@chr1_path [ projects/pictures/zerotwo2020.chr 00 ] -@chr2_path [ projects/pictures/felix0cx0c.chr 00 ] +@icn1_path [ "projects/pictures/ergo100x0c0.bit 00 ] +@icn2_path [ "projects/pictures/dafu80x80.bit 00 ] +@chr1_path [ "projects/pictures/zerotwo2020.chr 00 ] +@chr2_path [ "projects/pictures/felix0cx0c.chr 00 ] @image [ ] \ No newline at end of file diff --git a/projects/examples/gui.shapes.usm b/projects/examples/gui.shapes.usm @@ -7,147 +7,153 @@ %ABS2 { DUP2 #000f SFT2 EQU #04 JNZ #ffff MUL2 } %SIZE-TO-RECT { - STH2 STH2 OVR2 STH2r ADD2 OVR2 STH2r ADD2 + STH2 STH2 OVR2 STH2r ADD2 OVR2 STH2r ADD2 } ( x y w h -- x1 y1 x2 y2 ) -( draw requirements ) -;color { byte 1 } +( devices ) + +|00 @System [ &vector $2 &pad $6 &r $2 &g $2 &b $2 ] +|10 @Console [ &vector $2 &pad $6 &char $1 &byte $1 &short $2 &string $2 ] +|20 @Screen [ &vector $2 &width $2 &height $2 &pad $2 &x $2 &y $2 &addr $2 &color $1 ] + +( variables ) -;rect { x1 2 y1 2 x2 2 y2 2 } -;line { x0 2 y0 2 x 2 y 2 sx 2 sy 2 dx 2 dy 2 e1 2 e2 2 } -;circle { xc 2 yc 2 x 2 y 2 r 2 d 2 } +|0000 + +( draw requirements ) +@color [ &byte $1 ] -|0100 ;System { vector 2 pad 6 r 2 g 2 b 2 } -|0110 ;Console { vector 2 pad 6 char 1 byte 1 short 2 string 2 } -|0120 ;Screen { vector 2 width 2 height 2 pad 2 x 2 y 2 addr 2 color 1 } +@rect [ &x1 $2 &y1 $2 &x2 $2 &y2 $2 ] +@line [ &x0 $2 &y0 $2 &x $2 &y $2 &sx $2 &sy $2 &dx $2 &dy $2 &e1 $2 &e2 $2 ] +@circle [ &xc $2 &yc $2 &x $2 &y $2 &r $2 &d $2 ] ( program ) -|0200 +|0100 - ( theme ) #f03f =System.r #f03f =System.g #003f =System.b + ( theme ) #f03f .System/r DEO2 #f03f .System/g DEO2 #003f .System/b DEO2 - ( background ) ,checker_icn #23 ,cover-pattern JSR2 + ( background ) ;checker_icn #23 ;cover-pattern JSR2 - #0010 #0030 #0020 #0020 SIZE-TO-RECT #01 ,line-slow JSR2 - #0070 #0040 #0010 #01 ,draw-circle JSR2 - #0038 #0030 #0020 #0020 SIZE-TO-RECT #01 ,line-rect JSR2 - #0038 #0058 #0020 #0020 SIZE-TO-RECT #01 ,fill-rect JSR2 + #0010 #0030 #0020 #0020 SIZE-TO-RECT #01 ;line-slow JSR2 + #0070 #0040 #0010 #01 ;draw-circle JSR2 + #0038 #0030 #0020 #0020 SIZE-TO-RECT #01 ;line-rect JSR2 + #0038 #0058 #0020 #0020 SIZE-TO-RECT #01 ;fill-rect JSR2 BRK @line-slow ( x1 y1 x2 y2 color -- ) - ( load ) =color -- =line.y0 -- =line.x0 =line.y =line.x - ~line.x0 ~line.x SUB2 ABS2 =line.dx - ~line.y0 ~line.y SUB2 ABS2 #0000 SWP2 SUB2 =line.dy - #ffff #00 ~line.x ~line.x0 LTS2 #0002 MUL2 ADD2 =line.sx - #ffff #00 ~line.y ~line.y0 LTS2 #0002 MUL2 ADD2 =line.sy - ~line.dx ~line.dy ADD2 =line.e1 - $loop - ~line.x =Screen.x ~line.y =Screen.y ~color =Screen.color - ~line.x ~line.x0 EQU2 ~line.y ~line.y0 EQU2 #0101 EQU2 ^$end JNZ - ~line.e1 #0002 MUL2 =line.e2 - ~line.e2 ~line.dy LTS2 ^$skipy JNZ - ~line.e1 ~line.dy ADD2 =line.e1 - ~line.x ~line.sx ADD2 =line.x - $skipy - ~line.e2 ~line.dx GTS2 ^$skipx JNZ - ~line.e1 ~line.dx ADD2 =line.e1 - ~line.y ~line.sy ADD2 =line.y - $skipx - ,$loop JMP2 - - $end + ( load ) .color POK -- .line/y0 POK2 -- .line/x0 POK2 .line/y POK2 .line/x POK2 + .line/x0 PEK2 .line/x PEK2 SUB2 ABS2 .line/dx POK2 + .line/y0 PEK2 .line/y PEK2 SUB2 ABS2 #0000 SWP2 SUB2 .line/dy POK2 + #ffff #00 .line/x PEK2 .line/x0 PEK2 LTS2 #0002 MUL2 ADD2 .line/sx POK2 + #ffff #00 .line/y PEK2 .line/y0 PEK2 LTS2 #0002 MUL2 ADD2 .line/sy POK2 + .line/dx PEK2 .line/dy PEK2 ADD2 .line/e1 POK2 + &loop + .line/x PEK2 .Screen/x DEO2 .line/y PEK2 .Screen/y DEO2 .color PEK .Screen/color DEO + .line/x PEK2 .line/x0 PEK2 EQU2 .line/y PEK2 .line/y0 PEK2 EQU2 #0101 EQU2 ,&end JNZ + .line/e1 PEK2 #0002 MUL2 .line/e2 POK2 + .line/e2 PEK2 .line/dy PEK2 LTS2 ,&skipy JNZ + .line/e1 PEK2 .line/dy PEK2 ADD2 .line/e1 POK2 + .line/x PEK2 .line/sx PEK2 ADD2 .line/x POK2 + &skipy + .line/e2 PEK2 .line/dx PEK2 GTS2 ,&skipx JNZ + .line/e1 PEK2 .line/dx PEK2 ADD2 .line/e1 POK2 + .line/y PEK2 .line/sy PEK2 ADD2 .line/y POK2 + &skipx + ;&loop JMP2 + + &end RTN @line-rect ( x1 y1 x2 y2 color -- ) - ( load ) =color DUP2 STH2 -- =rect.y2 -- =rect.x2 DUP2 STH2 =rect.y1 =rect.x1 + ( load ) .color POK DUP2 STH2 -- .rect/y2 POK2 -- .rect/x2 POK2 DUP2 STH2 .rect/y1 POK2 .rect/x1 POK2 STH2r STH2r - $ver - ( save ) OVR2 =Screen.y - ( draw ) ~rect.x1 =Screen.x ~color DUP =Screen.color - ( draw ) ~rect.x2 =Screen.x =Screen.color + &ver + ( save ) OVR2 .Screen/y DEO2 + ( draw ) .rect/x1 PEK2 .Screen/x DEO2 .color PEK DUP .Screen/color DEO + ( draw ) .rect/x2 PEK2 .Screen/x DEO2 .Screen/color DEO ( incr ) SWP2 ++ SWP2 - OVR2 OVR2 LTS2 ^$ver JNZ + OVR2 OVR2 LTS2 ,&ver JNZ POP2 POP2 - ~rect.x1 ~rect.x2 - $hor - ( save ) OVR2 =Screen.x - ( draw ) ~rect.y1 =Screen.y ~color DUP =Screen.color - ( draw ) ~rect.y2 =Screen.y =Screen.color + .rect/x1 PEK2 .rect/x2 PEK2 + &hor + ( save ) OVR2 .Screen/x DEO2 + ( draw ) .rect/y1 PEK2 .Screen/y DEO2 .color PEK DUP .Screen/color DEO + ( draw ) .rect/y2 PEK2 .Screen/y DEO2 .Screen/color DEO ( incr ) SWP2 ++ SWP2 - OVR2 OVR2 ++ LTS2 ^$hor JNZ + OVR2 OVR2 ++ LTS2 ,&hor JNZ POP2 POP2 RTN @fill-rect ( x1 y1 x2 y2 color -- ) - =color + .color POK ( x1 x2 y1 y2 ) ROT2 SWP2 - $ver - ( save ) OVR2 =Screen.y - STH2 STH2 OVR2 OVR2 - $hor - ( save ) OVR2 =Screen.x - ( draw ) ~color =Screen.color + &ver + ( save ) OVR2 .Screen/y DEO2 + STH2 STH2 OVR2 OVR2 + &hor + ( save ) OVR2 .Screen/x DEO2 + ( draw ) .color PEK .Screen/color DEO ( incr ) SWP2 ++ SWP2 - OVR2 OVR2 LTS2 ^$hor JNZ + OVR2 OVR2 LTS2 ,&hor JNZ POP2 POP2 STH2r STH2r ( incr ) SWP2 ++ SWP2 - OVR2 OVR2 LTS2 ^$ver JNZ + OVR2 OVR2 LTS2 ,&ver JNZ POP2 POP2 POP2 POP2 RTN @draw-circle ( xc yc r color -- ) - ( load ) =color =circle.r =circle.yc =circle.xc - #0000 =circle.x ~circle.r =circle.y - ~circle.r #0002 MUL2 =circle.d - ( draw ) ,$seg JSR2 - $loop - ( incr ) ~circle.x ++ =circle.x - ~circle.d #0001 LTS2 ^$else JNZ - ( decr ) ~circle.y -- =circle.y - ~circle.x ~circle.y SUB2 #0004 MUL2 ~circle.d ADD2 =circle.d - ,$end JMP2 - $else - ~circle.x #0004 MUL2 ~circle.d ADD2 =circle.d - $end - ( draw ) ,$seg JSR2 - ~circle.y ~circle.x -- GTS2 ^$loop JNZ + ( load ) .color POK .circle/r POK2 .circle/yc POK2 .circle/xc POK2 + #0000 .circle/x POK2 .circle/r PEK2 .circle/y POK2 + .circle/r PEK2 #0002 MUL2 .circle/d POK2 + ( draw ) ;&seg JSR2 + &loop + ( incr ) .circle/x PEK2 ++ .circle/x POK2 + .circle/d PEK2 #0001 LTS2 ,&else JNZ + ( decr ) .circle/y PEK2 -- .circle/y POK2 + .circle/x PEK2 .circle/y PEK2 SUB2 #0004 MUL2 .circle/d PEK2 ADD2 .circle/d POK2 + ;&end JMP2 + &else + .circle/x PEK2 #0004 MUL2 .circle/d PEK2 ADD2 .circle/d POK2 + &end + ( draw ) ;&seg JSR2 + .circle/y PEK2 .circle/x PEK2 -- GTS2 ,&loop JNZ RTN - $seg - ~circle.xc ~circle.x ADD2 =Screen.x ~circle.yc ~circle.y ADD2 =Screen.y ~color =Screen.color - ~circle.xc ~circle.x SUB2 =Screen.x ~circle.yc ~circle.y ADD2 =Screen.y ~color =Screen.color - ~circle.xc ~circle.x ADD2 =Screen.x ~circle.yc ~circle.y SUB2 =Screen.y ~color =Screen.color - ~circle.xc ~circle.x SUB2 =Screen.x ~circle.yc ~circle.y SUB2 =Screen.y ~color =Screen.color - ~circle.xc ~circle.y ADD2 =Screen.x ~circle.yc ~circle.x ADD2 =Screen.y ~color =Screen.color - ~circle.xc ~circle.y SUB2 =Screen.x ~circle.yc ~circle.x ADD2 =Screen.y ~color =Screen.color - ~circle.xc ~circle.y ADD2 =Screen.x ~circle.yc ~circle.x SUB2 =Screen.y ~color =Screen.color - ~circle.xc ~circle.y SUB2 =Screen.x ~circle.yc ~circle.x SUB2 =Screen.y ~color =Screen.color + &seg + .circle/xc PEK2 .circle/x PEK2 ADD2 .Screen/x DEO2 .circle/yc PEK2 .circle/y PEK2 ADD2 .Screen/y DEO2 .color PEK .Screen/color DEO + .circle/xc PEK2 .circle/x PEK2 SUB2 .Screen/x DEO2 .circle/yc PEK2 .circle/y PEK2 ADD2 .Screen/y DEO2 .color PEK .Screen/color DEO + .circle/xc PEK2 .circle/x PEK2 ADD2 .Screen/x DEO2 .circle/yc PEK2 .circle/y PEK2 SUB2 .Screen/y DEO2 .color PEK .Screen/color DEO + .circle/xc PEK2 .circle/x PEK2 SUB2 .Screen/x DEO2 .circle/yc PEK2 .circle/y PEK2 SUB2 .Screen/y DEO2 .color PEK .Screen/color DEO + .circle/xc PEK2 .circle/y PEK2 ADD2 .Screen/x DEO2 .circle/yc PEK2 .circle/x PEK2 ADD2 .Screen/y DEO2 .color PEK .Screen/color DEO + .circle/xc PEK2 .circle/y PEK2 SUB2 .Screen/x DEO2 .circle/yc PEK2 .circle/x PEK2 ADD2 .Screen/y DEO2 .color PEK .Screen/color DEO + .circle/xc PEK2 .circle/y PEK2 ADD2 .Screen/x DEO2 .circle/yc PEK2 .circle/x PEK2 SUB2 .Screen/y DEO2 .color PEK .Screen/color DEO + .circle/xc PEK2 .circle/y PEK2 SUB2 .Screen/x DEO2 .circle/yc PEK2 .circle/x PEK2 SUB2 .Screen/y DEO2 .color PEK .Screen/color DEO RTN @cover-pattern ( addr color -- ) - ( load ) =color =Screen.addr - #0000 ~Screen.height - $ver - ( save ) OVR2 =Screen.y - #0000 ~Screen.width - $hor - ( save ) OVR2 =Screen.x - ( draw ) ~color =Screen.color + ( load ) .color POK .Screen/addr DEO2 + #0000 .Screen/height DEI2 + &ver + ( save ) OVR2 .Screen/y DEO2 + #0000 .Screen/width DEI2 + &hor + ( save ) OVR2 .Screen/x DEO2 + ( draw ) .color PEK .Screen/color DEO ( incr ) SWP2 8+ SWP2 - OVR2 OVR2 LTH2 ^$hor JNZ + OVR2 OVR2 LTH2 ,&hor JNZ POP2 POP2 ( incr ) SWP2 8+ SWP2 - OVR2 OVR2 LTH2 ^$ver JNZ + OVR2 OVR2 LTH2 ,&ver JNZ POP2 POP2 RTN diff --git a/projects/examples/gui.wallpaper.usm b/projects/examples/gui.wallpaper.usm @@ -1,65 +1,69 @@ -;scroll { x 2 y 2 wait 1 } - ( devices ) -|0100 ;System { vector 2 pad 6 r 2 g 2 b 2 } -|0110 ;Console { vector 2 pad 6 char 1 byte 1 short 2 string 2 } -|0120 ;Screen { vector 2 width 2 height 2 pad 2 x 2 y 2 addr 2 color 1 } -|0130 ;Audio { wave 2 envelope 2 pad 4 volume 1 pitch 1 play 1 value 2 delay 2 finish 1 } -|0140 ;Controller { vector 2 button 1 key 1 } -|0160 ;Mouse { vector 2 x 2 y 2 state 1 chord 1 } -|0170 ;File { vector 2 success 2 offset 2 pad 2 name 2 length 2 load 2 save 2 } -|01a0 ;DateTime { year 2 month 1 day 1 hour 1 minute 1 second 1 dotw 1 doty 2 isdst 1 refresh 1 } +|00 @System [ &vector $2 &pad $6 &r $2 &g $2 &b $2 ] +|10 @Console [ &vector $2 &pad $6 &char $1 &byte $1 &short $2 &string $2 ] +|20 @Screen [ &vector $2 &width $2 &height $2 &pad $2 &x $2 &y $2 &addr $2 &color $1 ] +|30 @Audio [ &wave $2 &envelope $2 &pad $4 &volume $1 &pitch $1 &play $1 &value $2 &delay $2 &finish $1 ] +|40 @Controller [ &vector $2 &button $1 &key $1 ] +|60 @Mouse [ &vector $2 &x $2 &y $2 &state $1 &chord $1 ] +|70 @File [ &vector $2 &success $2 &offset $2 &pad $2 &name $2 &length $2 &load $2 &save $2 ] +|a0 @DateTime [ &year $2 &month $1 &day $1 &hour $1 &minute $1 &second $1 &dotw $1 &doty $2 &isdst $1 &refresh $1 ] + +( variables ) + +|0000 + +@scroll [ &x $2 &y $2 &wait $1 ] -|0200 - #90ff =System.r #9000 =System.g #900f =System.b - #08e0 ~Screen.width #0001 SFT2 SUB2 =scroll.x - #09b0 =scroll.y - ,frame =Screen.vector - #30 =scroll.wait - BRK +|0100 ( -> ) + #90ff .System/r DEO2 #9000 .System/g DEO2 #900f .System/b DEO2 + #08e0 .Screen/width DEI2 #0001 SFT2 SUB2 .scroll/x POK2 + #09b0 .scroll/y POK2 + ;frame .Screen/vector DEO2 + #30 .scroll/wait POK + BRK @frame ( -> ) - #ffff - $loop - DUP2 ^row JSR - #0001 ADD2 - DUP2 ~Screen.height LTH2 ^$loop JNZ - POP2 - ~scroll.wait ^$noscroll JNZ - ~scroll.y #0001 ADD2 =scroll.y - BRK + #ffff + &loop + DUP2 ,row JSR + #0001 ADD2 + DUP2 .Screen/height DEI2 LTH2 ,&loop JNZ + POP2 + .scroll/wait PEK ,&noscroll JNZ + .scroll/y PEK2 #0001 ADD2 .scroll/y POK2 + BRK - $noscroll - ~scroll.wait #01 SUB =scroll.wait - BRK + &noscroll + .scroll/wait PEK #01 SUB .scroll/wait POK + BRK @row ( y* -- ) - DUP2 =Screen.y - ~scroll.y ADD2 + DUP2 .Screen/y DEO2 + .scroll/y PEK2 ADD2 - ~Screen.width - $loop - #0001 SUB2 - OVR2 OVR2 ~scroll.x ADD2 EOR2 DUP2 #0013 DIV2 #0013 MUL2 SUB2 - DUP #00 EQU ^$draw JNZ - DUP #05 EQU ^$draw JNZ - POP2 - $rest - DUP2 ORA ^$loop JNZ - POP2 POP2 - JMP2r + .Screen/width DEI2 + &loop + #0001 SUB2 + OVR2 OVR2 .scroll/x PEK2 ADD2 EOR2 DUP2 #0013 DIV2 #0013 MUL2 SUB2 + DUP #00 EQU ,&draw JNZ + DUP #05 EQU ,&draw JNZ + POP2 + &rest + DUP2 ORA ,&loop JNZ + POP2 POP2 + JMP2r - #15 =Screen.color - JMP2r + #15 .Screen/color DEO + JMP2r - $draw - OVR2 =Screen.x - #05 ADD =Screen.color - ~Screen.y - DUP2 #0001 ADD2 =Screen.y - #00 =Screen.color - =Screen.y - POP - ^$rest JMP + &draw + OVR2 .Screen/x DEO2 + #05 ADD .Screen/color DEO + .Screen/y DEI2 + DUP2 #0001 ADD2 .Screen/y DEO2 + #00 .Screen/color DEO + .Screen/y DEO2 + POP + ,&rest JMP diff --git a/projects/software/left.usm b/projects/software/left.usm @@ -1,4 +1,4 @@ -( +( app/left : text editor TODO @@ -14,7 +14,10 @@ - Don't scroll past oef - Hor scroll - Real scrolling distance -) + FIXME + - Imperfect port from previous assembler syntax +) + %RTN { JMP2r } %RTN? { #00 EQU #02 JNZ STH2r JMP2 } @@ -23,420 +26,422 @@ %8/ { #0003 SFT2 } %8* { #0030 SFT2 } %8- { #0008 SUB2 } %8+ { #0008 ADD2 } -( variables ) +( devices ) -;lock { byte 1 } -;k { byte 1 } -;l { byte 1 } -;i { short 2 } -;j { short 2 } -;addr { short 2 } -;selection { from 2 to 2 } -;position { x 2 y 2 } -;scroll { x 2 y 2 } -;pt { x 2 y 2 } -;mouse { x 2 y 2 } -;touch { x1 2 y1 2 x2 2 y2 2 state 1 } -;textarea { x1 2 y1 2 x2 2 y2 2 addr 2 cursor 1 } -;label { x 2 y 2 color 1 addr 2 } ( remove ) +|00 @System [ &vector $2 &pad $6 &r $2 &g $2 &b $2 ] +|10 @Console [ &vector $2 &pad $6 &char $1 &byte $1 &short $2 &string $2 ] +|20 @Screen [ &vector $2 &width $2 &height $2 &pad $2 &x $2 &y $2 &addr $2 &color $1 ] +|40 @Controller [ &vector $2 &button $1 &key $1 ] +|60 @Mouse [ &vector $2 &x $2 &y $2 &state $1 &chord $1 ] +|70 @File [ &vector $2 &success $2 &offset $2 &pad $2 &name $2 &length $2 &load $2 &save $2 ] -( devices ) +( variables ) -|0100 ;System { vector 2 pad 6 r 2 g 2 b 2 } -|0110 ;Console { vector 2 pad 6 char 1 byte 1 short 2 string 2 } -|0120 ;Screen { vector 2 width 2 height 2 pad 2 x 2 y 2 addr 2 color 1 } -|0140 ;Controller { vector 2 button 1 key 1 } -|0160 ;Mouse { vector 2 x 2 y 2 state 1 chord 1 } -|0170 ;File { vector 2 success 2 offset 2 pad 2 name 2 length 2 load 2 save 2 } +|0000 + +@lock [ &byte $1 ] +@k [ &byte $1 ] +@l [ &byte $1 ] +@i [ &short $2 ] +@j [ &short $2 ] +@addr [ &short $2 ] +@selection [ &from $2 &to $2 ] +@position [ &x $2 &y $2 ] +@scroll [ &x $2 &y $2 ] +@pt [ &x $2 &y $2 ] +@mouse [ &x $2 &y $2 ] +@touch [ &x1 $2 &y1 $2 &x2 $2 &y2 $2 &state $1 ] +@textarea [ &x1 $2 &y1 $2 &x2 $2 &y2 $2 &addr $2 &cursor $1 ] +@label [ &x $2 &y $2 &color $1 &addr $2 ] ( remove ) ( program ) -|0200 @RESET +|0100 @RESET - ( theme ) #e0fa =System.r #30fa =System.g #30fa =System.b - ( vectors ) ,on-mouse =Mouse.vector - ( vectors ) ,on-button =Controller.vector + ( theme ) #e0fa .System/r DEO2 #30fa .System/g DEO2 #30fa .System/b DEO2 + ( vectors ) ;on-mouse .Mouse/vector DEO2 + ( vectors ) ;on-button .Controller/vector DEO2 ( load file ) - ,filepath ,load-file JSR2 + ;filepath ;load-file JSR2 ( place textarea ) - #0018 =textarea.x1 ~Screen.height 8- =textarea.y2 + #0018 .textarea/x1 POK2 .Screen/height DEI2 8- .textarea/y2 POK2 - ,select JSR2 - ,redraw JSR2 + ;select JSR2 + ;redraw JSR2 BRK @on-button ( -> ) ( alt + arrow ) - ~Controller.button #0f AND #02 NEQ ^$no-alt JNZ - ~Controller.button #04 SFT - DUP #01 NEQ ^$no-aup JNZ - ( sel word ) ,find-wordstart JSR2 =selection.to $no-aup - DUP #02 NEQ ^$no-adown JNZ - ( sel word ) ,find-wordend JSR2 =selection.to $no-adown - DUP #04 NEQ ^$no-aleft JNZ - ( sel decr ) ~selection.to -- =selection.to $no-aleft - DUP #08 NEQ ^$no-aright JNZ - ( sel incr ) ~selection.to ++ =selection.to $no-aright + .Controller/button DEI #0f AND #02 NEQ ,&no-alt JNZ + .Controller/button DEI #04 SFT + DUP #01 NEQ ,&no-aup JNZ + ( sel word ) ;find-wordstart JSR2 .selection/to POK2 &no-aup + DUP #02 NEQ ,&no-adown JNZ + ( sel word ) ;find-wordend JSR2 .selection/to POK2 &no-adown + DUP #04 NEQ ,&no-aleft JNZ + ( sel decr ) .selection/to PEK2 -- .selection/to POK2 &no-aleft + DUP #08 NEQ ,&no-aright JNZ + ( sel incr ) .selection/to PEK2 ++ .selection/to POK2 &no-aright POP - ,clamp-selection JSR2 - ,redraw JSR2 + ;clamp-selection JSR2 + ;redraw JSR2 BRK - $no-alt + &no-alt ( ctrl + arrow ) - ~Controller.button #0f AND #01 NEQ ^$no-ctrl JNZ - ~Controller.button #04 SFT - DUP #01 NEQ ^$no-cup JNZ - ( jump scroll ) #0004 ,scroll-up JSR2 $no-cup - DUP #02 NEQ ^$no-cdown JNZ - ( jump scroll ) #0004 ,scroll-down JSR2 $no-cdown - DUP #04 NEQ ^$no-cleft JNZ - ( jump line ) ,goto-linestart JSR2 $no-cleft - DUP #08 NEQ ^$no-cright JNZ - ( jump line ) ,goto-lineend JSR2 $no-cright + .Controller/button DEI #0f AND #01 NEQ ,&no-ctrl JNZ + .Controller/button DEI #04 SFT + DUP #01 NEQ ,&no-cup JNZ + ( jump scroll ) #0004 ;scroll-up JSR2 &no-cup + DUP #02 NEQ ,&no-cdown JNZ + ( jump scroll ) #0004 ;scroll-down JSR2 &no-cdown + DUP #04 NEQ ,&no-cleft JNZ + ( jump line ) ;goto-linestart JSR2 &no-cleft + DUP #08 NEQ ,&no-cright JNZ + ( jump line ) ;goto-lineend JSR2 &no-cright POP - ,redraw JSR2 + ;redraw JSR2 BRK - $no-ctrl + &no-ctrl ( arrow ) - ~Controller.button #f0 AND #00 EQU ,$no-arrow JNZ2 - ~Controller.button #f0 AND - DUP #10 NEQ ^$no-arrowup JNZ - ( clamp ) ~position.y #0000 EQU2 ^$no-arrowup JNZ - ,find-lineoffset JSR2 =position.x ~position.y -- =position.y - ,find-selection JSR2 DUP2 =selection.from ++ =selection.to $no-arrowup - DUP #20 NEQ ^$no-arrowdown JNZ + .Controller/button DEI #f0 AND #00 EQU ;&no-arrow JNZ2 + .Controller/button DEI #f0 AND + DUP #10 NEQ ,&no-arrowup JNZ + ( clamp ) .position/y PEK2 #0000 EQU2 ,&no-arrowup JNZ + ;find-lineoffset JSR2 .position/x POK2 .position/y PEK2 -- .position/y POK2 + ;find-selection JSR2 DUP2 .selection/from POK2 ++ .selection/to POK2 &no-arrowup + DUP #20 NEQ ,&no-arrowdown JNZ ( clamp:TODO ) - ,find-lineoffset JSR2 =position.x ~position.y ++ =position.y - ,find-selection JSR2 DUP2 =selection.from ++ =selection.to $no-arrowdown - DUP #40 NEQ ^$no-arrowleft JNZ - ( clamp ) ~selection.from ,document.body EQU2 ^$no-arrowleft JNZ - ~selection.from -- DUP2 =selection.from ++ =selection.to $no-arrowleft - DUP #80 NEQ ^$no-arrowright JNZ + ;find-lineoffset JSR2 .position/x POK2 .position/y PEK2 ++ .position/y POK2 + ;find-selection JSR2 DUP2 .selection/from POK2 ++ .selection/to POK2 &no-arrowdown + DUP #40 NEQ ,&no-arrowleft JNZ + ( clamp ) .selection/from PEK2 ;document/body EQU2 ,&no-arrowleft JNZ + .selection/from PEK2 -- DUP2 .selection/from POK2 ++ .selection/to POK2 &no-arrowleft + DUP #80 NEQ ,&no-arrowright JNZ ( clamp:TODO ) - #aa =Console.byte - ~selection.from ++ DUP2 =selection.from ++ =selection.to $no-arrowright + #aa .Console/byte DEO + .selection/from PEK2 ++ DUP2 .selection/from POK2 ++ .selection/to POK2 &no-arrowright POP - ,clamp-selection JSR2 - ,follow-selection JSR2 - ,redraw JSR2 - $no-arrow + ;clamp-selection JSR2 + ;follow-selection JSR2 + ;redraw JSR2 + &no-arrow - ~Controller.key #08 NEQ ^$no-backspace JNZ + .Controller/key DEI #08 NEQ ,&no-backspace JNZ ( erase ) - ~selection.to ~selection.from SUB2 #0001 NEQ2 ^$erase-multiple JNZ - ~selection.to ~selection.from SUB2 ,shift-left JSR2 - ,$erase-end JMP2 - $erase-multiple - ~selection.from ++ =selection.from - ~selection.to ~selection.from SUB2 ++ ,shift-left JSR2 - $erase-end - ~selection.from -- =selection.from - ~selection.from ++ =selection.to - ,redraw JSR2 + .selection/to PEK2 .selection/from PEK2 SUB2 #0001 NEQ2 ,&erase-multiple JNZ + .selection/to PEK2 .selection/from PEK2 SUB2 ;shift-left JSR2 + ;&erase-end JMP2 + &erase-multiple + .selection/from PEK2 ++ .selection/from POK2 + .selection/to PEK2 .selection/from PEK2 SUB2 ++ ;shift-left JSR2 + &erase-end + .selection/from PEK2 -- .selection/from POK2 + .selection/from PEK2 ++ .selection/to POK2 + ;redraw JSR2 BRK - $no-backspace + &no-backspace ( insert ) - ~selection.to ~selection.from SUB2 ,shift-right JSR2 - ~Controller.key ~selection.from POK2 - ~selection.from ++ =selection.from - ~selection.from ++ =selection.to - ,redraw JSR2 + .selection/to PEK2 .selection/from PEK2 SUB2 ;shift-right JSR2 + .Controller/key DEI .selection/from PEK2 PUT + .selection/from PEK2 ++ .selection/from POK2 + .selection/from PEK2 ++ .selection/to POK2 + ;redraw JSR2 BRK @on-mouse ( -> ) - ~Mouse.state #00 EQU ^$touch-end JNZ - ~Mouse.x #0010 LTH2 ,touch-linebar JNZ2 - ~Mouse.x ~Screen.width 8- LTH2 ,touch-body JNZ2 - ,touch-scrollbar JMP2 - $touch-end + .Mouse/state DEI #00 EQU ,&touch-end JNZ + .Mouse/x DEI2 #0010 LTH2 ;touch-linebar JNZ2 + .Mouse/x DEI2 .Screen/width DEI2 8- LTH2 ;touch-body JNZ2 + ;touch-scrollbar JMP2 + &touch-end - ~Mouse.state =touch.state + .Mouse/state DEI .touch/state POK - ,draw-cursor JSR2 + ;draw-cursor JSR2 BRK @touch-linebar ( -- ) - #0000 =position.x - ~Mouse.y 8/ ~scroll.y ADD2 =position.y - ,find-selection JSR2 DUP2 =selection.from ++ =selection.to - ,goto-linestart JSR2 - ,redraw JSR2 - ,draw-cursor JSR2 + #0000 .position/x POK2 + .Mouse/y DEI2 8/ .scroll/y PEK2 ADD2 .position/y POK2 + ;find-selection JSR2 DUP2 .selection/from POK2 ++ .selection/to POK2 + ;goto-linestart JSR2 + ;redraw JSR2 + ;draw-cursor JSR2 BRK @touch-body ( -- ) - ~Mouse.y 8/ ~scroll.y ADD2 =position.y - ~Mouse.x ~textarea.x1 SUB2 #0007 ADD2 #0007 DIV2 =position.x + .Mouse/y DEI2 8/ .scroll/y PEK2 ADD2 .position/y POK2 + .Mouse/x DEI2 .textarea/x1 PEK2 SUB2 #0007 ADD2 #0007 DIV2 .position/x POK2 ( chords ) - ~Mouse.chord #00 EQU ^$no-chords JNZ - ~Mouse.chord - DUP #01 NEQ ^$no-chord-cut JNZ - ,cut JSR2 ( release ) #00 DUP =Mouse.state =Mouse.chord $no-chord-cut - DUP #10 NEQ ^$no-chord-paste JNZ - ,paste JSR2 ( release ) #00 DUP =Mouse.state =Mouse.chord $no-chord-paste + .Mouse/chord DEI #00 EQU ,&no-chords JNZ + .Mouse/chord DEI + DUP #01 NEQ ,&no-chord-cut JNZ + ;cut JSR2 ( release ) #00 DUP .Mouse/state DEO .Mouse/chord DEO &no-chord-cut + DUP #10 NEQ ,&no-chord-paste JNZ + ;paste JSR2 ( release ) #00 DUP .Mouse/state DEO .Mouse/chord DEO &no-chord-paste POP - ,redraw JSR2 + ;redraw JSR2 BRK - $no-chords + &no-chords ( drag ) - ~Mouse.state ~touch.state NEQ ~Controller.button #0f AND #02 NEQ #0101 EQU2 ^$no-drag JNZ + .Mouse/state DEI .touch/state PEK NEQ .Controller/button DEI #0f AND #02 NEQ #0101 EQU2 ,&no-drag JNZ ( on drag ) - ,find-selection JSR2 ++ =selection.to - ,clamp-selection JSR2 - ^$end JMP - $no-drag + ;find-selection JSR2 ++ .selection/to POK2 + ;clamp-selection JSR2 + ,&end JMP + &no-drag ( on click ) - ,find-selection JSR2 DUP2 =selection.from ++ =selection.to - $end - ~Mouse.state =touch.state - ,draw-cursor JSR2 - ,redraw JSR2 + ;find-selection JSR2 DUP2 .selection/from POK2 ++ .selection/to POK2 + &end + .Mouse/state DEI .touch/state POK + ;draw-cursor JSR2 + ;redraw JSR2 BRK @touch-scrollbar ( -- ) - ~Mouse.y #0008 GTH2 ^$no-up JNZ - ( decr ) ~scroll.y #00 ~scroll.y #0000 NEQ2 SUB2 =scroll.y - ^$end JMP - $no-up - ~Mouse.y ~Screen.height 8- LTH2 ^$no-down JNZ - ( incr ) ~scroll.y ++ =scroll.y - ^$end JMP - $no-down - ~Mouse.y 8- =scroll.y - $end - ~Mouse.state =touch.state - ,draw-cursor JSR2 - ,redraw JSR2 + .Mouse/y DEI2 #0008 GTH2 ,&no-up JNZ + ( decr ) .scroll/y PEK2 #00 .scroll/y PEK2 #0000 NEQ2 SUB2 .scroll/y POK2 + ,&end JMP + &no-up + .Mouse/y DEI2 .Screen/height DEI2 8- LTH2 ,&no-down JNZ + ( incr ) .scroll/y PEK2 ++ .scroll/y POK2 + ,&end JMP + &no-down + .Mouse/y DEI2 8- .scroll/y POK2 + &end + .Mouse/state DEI .touch/state POK + ;draw-cursor JSR2 + ;redraw JSR2 BRK @load-file ( path ) - =File.name #8000 =File.length ,document.body =File.load + .File/name DEO2 #8000 .File/length DEO2 ;document/body .File/load DEO2 ( get file length ) - ,document.body =document.eof - $loop - ( incr ) ~document.eof ++ =document.eof - ~document.eof PEK2 #00 NEQ ^$loop JNZ + ;document/body ;document/eof PUT2 + &loop + ( incr ) ;document/eof GET2 ++ ;document/eof PUT2 + ;document/eof GET2 GET #00 NEQ ,&loop JNZ RTN @scroll-up ( length -- ) - DUP2 ~scroll.y LTH2 ^$clamp JNZ - #0000 =scroll.y POP2 RTN - $clamp - ~scroll.y SWP2 SUB2 =scroll.y + DUP2 .scroll/y PEK2 LTH2 ,&clamp JNZ + #0000 .scroll/y POK2 POP2 RTN + &clamp + .scroll/y PEK2 SWP2 SUB2 .scroll/y POK2 RTN @scroll-down ( length -- ) ( TODO: Clamp ) - ~scroll.y SWP2 ADD2 =scroll.y + .scroll/y PEK2 SWP2 ADD2 .scroll/y POK2 RTN @shift-left ( length -- ) - =i - ~selection.from -- =j ( start -> end ) - $loop - ( move ) ~j ~i ADD2 PEK2 ~j POK2 - ( incr ) ~j ++ =j - ~j ~document.eof LTH2 ^$loop JNZ - ~document.eof ~i SUB2 =document.eof + .i POK2 + .selection/from PEK2 -- .j POK2 ( start -> end ) + &loop + ( move ) .j PEK2 .i PEK2 ADD2 GET .j PEK2 PUT + ( incr ) .j PEK2 ++ .j POK2 + .j PEK2 ;document/eof GET2 LTH2 ,&loop JNZ + ;document/eof GET2 .i PEK2 SUB2 ;document/eof PUT2 RTN @shift-right ( length -- ) - =i - ~document.eof =j ( end -> start ) - $loop - ( move ) ~j ~i SUB2 PEK2 ~j POK2 - ( decr ) ~j -- =j - ~j ~selection.from GTH2 ^$loop JNZ - ~document.eof ~i ADD2 =document.eof + .i POK2 + ;document/eof GET2 .j POK2 ( end -> start ) + &loop + ( move ) .j PEK2 .i PEK2 SUB2 GET .j PEK2 PUT + ( decr ) .j PEK2 -- .j POK2 + .j PEK2 .selection/from PEK2 GTH2 ,&loop JNZ + ;document/eof GET2 .i PEK2 ADD2 ;document/eof PUT2 RTN @follow-selection ( -- ) - ~position.y ~scroll.y GTH2 ^$no-up JNZ - ~position.y =scroll.y RTN - $no-up - ~position.y ~Screen.height #0010 SUB2 8/ ~scroll.y ADD2 LTH2 ^$no-down JNZ - ~position.y ~Screen.height #0010 SUB2 8/ SUB2 =scroll.y RTN - $no-down + .position/y PEK2 .scroll/y PEK2 GTH2 ,&no-up JNZ + .position/y PEK2 .scroll/y POK2 RTN + &no-up + .position/y PEK2 .Screen/height DEI2 #0010 SUB2 8/ .scroll/y PEK2 ADD2 LTH2 ,&no-down JNZ + .position/y PEK2 .Screen/height DEI2 #0010 SUB2 8/ SUB2 .scroll/y POK2 RTN + &no-down RTN @clamp-selection ( -- ) - ~selection.from ~selection.to LTH2 RTN? - ~selection.from ++ =selection.to + .selection/from PEK2 .selection/to PEK2 LTH2 RTN? + .selection/from PEK2 ++ .selection/to POK2 RTN @goto-linestart ( -- ) - $loop - ~selection.from -- PEK2 #0a EQU RTN? - ~selection.from -- PEK2 #0d EQU RTN? - ( decr ) ~selection.from DUP2 =selection.to -- =selection.from - ~selection.from PEK2 #00 NEQ ^$loop JNZ + &loop + .selection/from PEK2 -- GET #0a EQU RTN? + .selection/from PEK2 -- GET #0d EQU RTN? + ( decr ) .selection/from PEK2 DUP2 .selection/to POK2 -- .selection/from POK2 + .selection/from PEK2 GET #00 NEQ ,&loop JNZ ( clamp at document body ) - ~selection.from ,document.body GTH2 RTN? - ,document.body DUP2 =selection.from ++ =selection.to + .selection/from PEK2 ;document/body GTH2 RTN? + ;document/body DUP2 .selection/from POK2 ++ .selection/to POK2 RTN @goto-lineend ( -- ) - $loop - ~selection.from PEK2 #0a EQU RTN? - ~selection.from PEK2 #0d EQU RTN? - ( incr ) ~selection.from ++ DUP2 ++ =selection.to =selection.from - ~selection.from PEK2 #00 NEQ ^$loop JNZ + &loop + .selection/from PEK2 GET #0a EQU RTN? + .selection/from PEK2 GET #0d EQU RTN? + ( incr ) .selection/from PEK2 ++ DUP2 ++ .selection/to POK2 .selection/from POK2 + .selection/from PEK2 GET #00 NEQ ,&loop JNZ ( clamp at document body ) - ~selection.from ,document.eof LTH2 RTN? - ,document.eof -- DUP2 =selection.from ++ =selection.to + .selection/from PEK2 ;document/eof LTH2 RTN? + ;document/eof -- DUP2 .selection/from POK2 ++ .selection/to POK2 RTN @find-wordstart ( -- ) - ~selection.to =j - $loop - ( decr ) ~j -- =j - ~j PEK2 #20 EQU ^$end JNZ - ~j PEK2 #0a EQU ^$end JNZ - ~j PEK2 #0d EQU ^$end JNZ - ~j ,document.body GTH2 ^$loop JNZ - $end - ( return ) ~j -- + .selection/to PEK2 .j POK2 + &loop + ( decr ) .j PEK2 -- .j POK2 + .j PEK2 GET #20 EQU ,&end JNZ + .j PEK2 GET #0a EQU ,&end JNZ + .j PEK2 GET #0d EQU ,&end JNZ + .j PEK2 ;document/body GTH2 ,&loop JNZ + &end + ( return ) .j PEK2 -- RTN @find-wordend ( -- ) - ~selection.to =j - $loop - ( incr ) ~j ++ =j - ~j PEK2 #20 EQU ^$end JNZ - ~j PEK2 #0a EQU ^$end JNZ - ~j PEK2 #0d EQU ^$end JNZ - ~j ,document.body GTH2 ^$loop JNZ - $end - ( return ) ~j ++ + .selection/to PEK2 .j POK2 + &loop + ( incr ) .j PEK2 ++ .j POK2 + .j PEK2 GET #20 EQU ,&end JNZ + .j PEK2 GET #0a EQU ,&end JNZ + .j PEK2 GET #0d EQU ,&end JNZ + .j PEK2 ;document/body GTH2 ,&loop JNZ + &end + ( return ) .j PEK2 ++ RTN @find-lineoffset ( return character offset from linestart ) - #0000 =j - $loop - ( incr ) ~j ++ =j - ~selection.from ~j SUB2 PEK2 #0a EQU ^$end JNZ - ~selection.from ~j SUB2 PEK2 #0d EQU ^$end JNZ - ~selection.from ~j SUB2 ,document.body GTH2 ^$loop JNZ - $end - ( return ) ~j + #0000 .j POK2 + &loop + ( incr ) .j PEK2 ++ .j POK2 + .selection/from PEK2 .j PEK2 SUB2 GET #0a EQU ,&end JNZ + .selection/from PEK2 .j PEK2 SUB2 GET #0d EQU ,&end JNZ + .selection/from PEK2 .j PEK2 SUB2 ;document/body GTH2 ,&loop JNZ + &end + ( return ) .j PEK2 RTN @find-line ( position -> addr ) - ,document.body =j #0000 =pt.y - $loop - ~pt.y ~position.y -- GTH2 ^$end JNZ - ~j PEK2 #0a NEQ ~j PEK2 #0d NEQ #0101 EQU2 ^$no-space JNZ - ( incr ) ~pt.y ++ =pt.y - $no-space - ( incr ) ~j ++ =j - ~j PEK2 #00 NEQ ^$loop JNZ - $end - ( return ) ~j + ;document/body .j POK2 #0000 .pt/y POK2 + &loop + .pt/y PEK2 .position/y PEK2 -- GTH2 ,&end JNZ + .j PEK2 GET #0a NEQ .j PEK2 GET #0d NEQ #0101 EQU2 ,&no-space JNZ + ( incr ) .pt/y PEK2 ++ .pt/y POK2 + &no-space + ( incr ) .j PEK2 ++ .j POK2 + .j PEK2 GET #00 NEQ ,&loop JNZ + &end + ( return ) .j PEK2 RTN @find-selection ( position -> addr ) - ,find-line JSR2 ( find line ) - #0000 =pt.x - $loop - ~j ~pt.x ADD2 PEK2 #0a EQU ^$end JNZ - ~j ~pt.x ADD2 PEK2 #0d EQU ^$end JNZ - ( incr ) ~pt.x ++ =pt.x - ~pt.x ~position.x -- LTH2 ^$loop JNZ - $end - ( return ) ~pt.x ADD2 + ;find-line JSR2 ( find line ) + #0000 .pt/x POK2 + &loop + .j PEK2 .pt/x PEK2 ADD2 GET #0a EQU ,&end JNZ + .j PEK2 .pt/x PEK2 ADD2 GET #0d EQU ,&end JNZ + ( incr ) .pt/x PEK2 ++ .pt/x POK2 + .pt/x PEK2 .position/x PEK2 -- LTH2 ,&loop JNZ + &end + ( return ) .pt/x PEK2 ADD2 RTN @cut ( -- ) - ,copy JSR2 - ~selection.to ~selection.from SUB2 ,shift-left JSR2 - ~selection.from ++ =selection.to + ;copy JSR2 + .selection/to PEK2 .selection/from PEK2 SUB2 ;shift-left JSR2 + .selection/from PEK2 ++ .selection/to POK2 RTN @copy ( -- ) - #0000 =i ( start ) - ~selection.to ~selection.from SUB2 =j ( end ) - ~j =clip.len - $loop - ~selection.from ~i ADD2 PEK2 ,clip.body ~i ADD2 POK2 - ( incr ) ~i ++ =i - ~i ~j LTH2 ^$loop JNZ + #0000 .i POK2 ( start ) + .selection/to PEK2 .selection/from PEK2 SUB2 .j POK2 ( end ) + .j PEK2 ;clip/len PUT2 + &loop + .selection/from PEK2 .i PEK2 ADD2 GET ;clip/body .i PEK2 ADD2 PUT + ( incr ) .i PEK2 ++ .i POK2 + .i PEK2 .j PEK2 LTH2 ,&loop JNZ RTN @paste ( -- ) - ~clip.len ,shift-right JSR2 - #0000 =i ( start ) - ~clip.len =j ( end ) - $loop - ,clip.body ~i ADD2 PEK2 ~selection.from ~i ADD2 POK2 - ( incr ) ~i ++ =i - ~i ~j LTH2 ^$loop JNZ + ;clip/len GET2 ;shift-right JSR2 + #0000 .i POK2 ( start ) + ;clip/len GET2 .j POK2 ( end ) + &loop + ;clip/body .i PEK2 ADD2 GET .selection/from PEK2 .i PEK2 ADD2 PUT + ( incr ) .i PEK2 ++ .i POK2 + .i PEK2 .j PEK2 LTH2 ,&loop JNZ RTN @select ( position -> selection ) - ,document.body =selection.from #0000 =pt.x #0000 =pt.y - $loop - ~selection.from PEK2 #0a NEQ ~selection.from PEK2 #0d NEQ #0101 EQU2 ^$no-space JNZ - ( incr ) ~pt.y ++ =pt.y - #0000 =pt.x - $no-space - ~pt.y ~position.y -- GTH2 ~pt.x ~position.x -- GTH2 #0101 NEQ2 ^$no-reached JNZ - ~selection.from ++ =selection.to + ;document/body .selection/from POK2 #0000 .pt/x POK2 #0000 .pt/y POK2 + &loop + .selection/from PEK2 GET #0a NEQ .selection/from PEK2 GET #0d NEQ #0101 EQU2 ,&no-space JNZ + ( incr ) .pt/y PEK2 ++ .pt/y POK2 + #0000 .pt/x POK2 + &no-space + .pt/y PEK2 .position/y PEK2 -- GTH2 .pt/x PEK2 .position/x PEK2 -- GTH2 #0101 NEQ2 ,&no-reached JNZ + .selection/from PEK2 ++ .selection/to POK2 RTN - $no-reached - ( incr ) ~pt.x ++ =pt.x - ( incr ) ~selection.from ++ =selection.from - ~selection.from PEK2 #00 NEQ ^$loop JNZ + &no-reached + ( incr ) .pt/x PEK2 ++ .pt/x POK2 + ( incr ) .selection/from PEK2 ++ .selection/from POK2 + .selection/from PEK2 GET #00 NEQ ,&loop JNZ RTN @@ -444,196 +449,196 @@ RTN @redraw - ,draw-textarea JSR2 - ,draw-scrollbar JSR2 - ,draw-titlebar JSR2 + ;draw-textarea JSR2 + ;draw-scrollbar JSR2 + ;draw-titlebar JSR2 ( save/load icons ) - ~Screen.height 8- =Screen.y + .Screen/height DEI2 8- .Screen/y DEO2 - ~Screen.width #0030 SUB2 =Screen.x - ,eye_icn =Screen.addr - #22 =Screen.color + .Screen/width DEI2 #0030 SUB2 .Screen/x DEO2 + ;eye_icn .Screen/addr DEO2 + #22 .Screen/color DEO - ~Screen.width #0028 SUB2 =Screen.x - ,name_icn =Screen.addr - #22 =Screen.color + .Screen/width DEI2 #0028 SUB2 .Screen/x DEO2 + ;name_icn .Screen/addr DEO2 + #22 .Screen/color DEO - ~Screen.width #0020 SUB2 =Screen.x - ,load_icn =Screen.addr - #22 =Screen.color + .Screen/width DEI2 #0020 SUB2 .Screen/x DEO2 + ;load_icn .Screen/addr DEO2 + #22 .Screen/color DEO - ~Screen.width #0018 SUB2 =Screen.x - ,save_icn =Screen.addr - #22 =Screen.color + .Screen/width DEI2 #0018 SUB2 .Screen/x DEO2 + ;save_icn .Screen/addr DEO2 + #22 .Screen/color DEO RTN @draw-short ( short ) - =addr - ,font_hex #00 ,addr PEK2 #f0 AND #04 SFT #08 MUL ADD2 =Screen.addr - ( draw ) #2e =Screen.color - ~Screen.x 8+ =Screen.x - ,font_hex #00 ,addr PEK2 #0f AND #08 MUL ADD2 =Screen.addr - ( draw ) #2e =Screen.color - ~Screen.x 8+ =Screen.x - ,font_hex #00 ,addr ++ PEK2 #f0 AND #04 SFT #08 MUL ADD2 =Screen.addr - ( draw ) #2e =Screen.color - ~Screen.x 8+ =Screen.x - ,font_hex #00 ,addr ++ PEK2 #0f AND #08 MUL ADD2 =Screen.addr - ( draw ) #2e =Screen.color + .addr POK2 + ;font_hex #00 ;addr GET #f0 AND #04 SFT #08 MUL ADD2 .Screen/addr DEO2 + ( draw ) #2e .Screen/color DEO + .Screen/x DEI2 8+ .Screen/x DEO2 + ;font_hex #00 ;addr GET #0f AND #08 MUL ADD2 .Screen/addr DEO2 + ( draw ) #2e .Screen/color DEO + .Screen/x DEI2 8+ .Screen/x DEO2 + ;font_hex #00 ;addr ++ GET #f0 AND #04 SFT #08 MUL ADD2 .Screen/addr DEO2 + ( draw ) #2e .Screen/color DEO + .Screen/x DEI2 8+ .Screen/x DEO2 + ;font_hex #00 ;addr ++ GET #0f AND #08 MUL ADD2 .Screen/addr DEO2 + ( draw ) #2e .Screen/color DEO RTN @draw-cursor ( clear last cursor ) - ~mouse.x =Screen.x - ~mouse.y =Screen.y - ,blank_icn =Screen.addr - #30 =Screen.color + .mouse/x PEK2 .Screen/x DEO2 + .mouse/y PEK2 .Screen/y DEO2 + ;blank_icn .Screen/addr DEO2 + #30 .Screen/color DEO ( record mouse positions ) - ~Mouse.x =mouse.x - ~Mouse.y =mouse.y + .Mouse/x DEI2 .mouse/x POK2 + .Mouse/y DEI2 .mouse/y POK2 ( draw new cursor ) - ~mouse.x =Screen.x - ~mouse.y =Screen.y - ,cursor_icn =Screen.addr - #3f ~Mouse.state #01 EQU #0a MUL SUB =Screen.color + .mouse/x PEK2 .Screen/x DEO2 + .mouse/y PEK2 .Screen/y DEO2 + ;cursor_icn .Screen/addr DEO2 + #3f .Mouse/state DEI #01 EQU #0a MUL SUB .Screen/color DEO RTN @draw-textarea ( x y color addr ) - ,document.body =textarea.addr - + ;document/body .textarea/addr POK2 + ( scroll to position ) - #0000 =j ( j is linebreaks ) - $find-offset - ~scroll.y ~j EQU2 ^$find-offset-end JNZ - ~textarea.addr PEK2 #0a NEQ ~textarea.addr PEK2 #0d NEQ #0101 EQU2 ^$no-break JNZ - ( incr ) ~j ++ =j $no-break - ( incr ) ~textarea.addr ++ =textarea.addr - ~textarea.addr PEK2 #00 NEQ ^$find-offset JNZ - $find-offset-end + #0000 .j POK2 ( j is linebreaks ) + &find-offset + .scroll/y PEK2 .j PEK2 EQU2 ,&find-offset-end JNZ + .textarea/addr PEK2 GET #0a NEQ .textarea/addr PEK2 GET #0d NEQ #0101 EQU2 ,&no-break JNZ + ( incr ) .j PEK2 ++ .j POK2 &no-break + ( incr ) .textarea/addr PEK2 ++ .textarea/addr POK2 + .textarea/addr PEK2 GET #00 NEQ ,&find-offset JNZ + &find-offset-end - #0018 =Screen.x #0000 =Screen.y - ~textarea.addr =i + #0018 .Screen/x DEO2 #0000 .Screen/y DEO2 + .textarea/addr PEK2 .i POK2 - $loop + &loop - ~Screen.y ~Screen.height #0010 SUB2 GTH2 ,$end JNZ2 + .Screen/y DEI2 .Screen/height DEI2 #0010 SUB2 GTH2 ;&end JNZ2 - ~i PEK2 #0a NEQ ~i PEK2 #0d NEQ #0101 EQU2 ,$no-linebreak JNZ2 + .i PEK2 GET #0a NEQ .i PEK2 GET #0d NEQ #0101 EQU2 ;&no-linebreak JNZ2 ( draw linebreak ) - ,linebreak_icn =Screen.addr + ;linebreak_icn .Screen/addr DEO2 ( draw ) #02 - ~i ~selection.from -- GTH2 - ~i ~selection.to LTH2 #0101 EQU2 - #26 MUL ADD =Screen.color + .i PEK2 .selection/from PEK2 -- GTH2 + .i PEK2 .selection/to PEK2 LTH2 #0101 EQU2 + #26 MUL ADD .Screen/color DEO ( fill clear ) - $fill-clear - ( incr ) ~Screen.x 8+ =Screen.x - ,font =Screen.addr - #21 =Screen.color - ~Screen.x ~Screen.width 8- LTH2 ^$fill-clear JNZ + &fill-clear + ( incr ) .Screen/x DEI2 8+ .Screen/x DEO2 + ;font .Screen/addr DEO2 + #21 .Screen/color DEO + .Screen/x DEI2 .Screen/width DEI2 8- LTH2 ,&fill-clear JNZ ( draw line number ) - #0000 =Screen.x - ~scroll.y ~Screen.y 8/ ADD2 DUP2 SWP POP =k - ~position.y EQU2 #05 MUL =l - ,font_hex #00 ~k #f0 AND #04 SFT #08 MUL ADD2 =Screen.addr - #24 ~l ADD =Screen.color - #0008 =Screen.x - ,font_hex #00 ~k #0f AND #08 MUL ADD2 =Screen.addr - #24 ~l ADD =Screen.color + #0000 .Screen/x DEO2 + .scroll/y PEK2 .Screen/y DEI2 8/ ADD2 DUP2 SWP POP .k POK + .position/y PEK2 EQU2 #05 MUL .l POK + ;font_hex #00 .k PEK #f0 AND #04 SFT #08 MUL ADD2 .Screen/addr DEO2 + #24 .l PEK ADD .Screen/color DEO + #0008 .Screen/x DEO2 + ;font_hex #00 .k PEK #0f AND #08 MUL ADD2 .Screen/addr DEO2 + #24 .l PEK ADD .Screen/color DEO - #0010 =Screen.x - ( incr ) ~Screen.y 8+ =Screen.y - $no-linebreak + #0010 .Screen/x DEO2 + ( incr ) .Screen/y DEI2 8+ .Screen/y DEO2 + &no-linebreak ( get character ) - ,font #00 ~i PEK2 #20 SUB 8* ADD2 =Screen.addr + ;font #00 .i PEK2 GET #20 SUB 8* ADD2 .Screen/addr DEO2 ( is a special character ) - ~i PEK2 #20 GTH ^$no-tab JNZ ,font =Screen.addr $no-tab + .i PEK2 GET #20 GTH ,&no-tab JNZ ;font .Screen/addr DEO2 &no-tab - ( draw ) #21 - ~i ~selection.from -- GTH2 - ~i ~selection.to LTH2 #0101 EQU2 - #05 MUL ADD =Screen.color + ( draw ) #21 + .i PEK2 .selection/from PEK2 -- GTH2 + .i PEK2 .selection/to PEK2 LTH2 #0101 EQU2 + #05 MUL ADD .Screen/color DEO - ( incr ) ~i ++ =i - ( incr ) ~Screen.x #0007 ADD2 =Screen.x + ( incr ) .i PEK2 ++ .i POK2 + ( incr ) .Screen/x DEI2 #0007 ADD2 .Screen/x DEO2 - ~i PEK2 #00 NEQ ,$loop JNZ2 + .i PEK2 GET #00 NEQ ;&loop JNZ2 - $end + &end RTN @draw-scrollbar ( -- ) - ,scrollbar_icn ( keeping a copy on stack ) + ;scrollbar_icn ( keeping a copy on stack ) - ~Screen.width 8- =Screen.x - #0008 =Screen.y - DUP2 =Screen.addr + .Screen/width DEI2 8- .Screen/x DEO2 + #0008 .Screen/y DEO2 + DUP2 .Screen/addr DEO2 - #0008 ~Screen.height 8- - $loop - ( draw ) #21 =Screen.color - ( incr ) SWP2 8+ DUP2 =Screen.y SWP2 - OVR2 OVR2 LTH2 ^$loop JNZ + #0008 .Screen/height DEI2 8- + &loop + ( draw ) #21 .Screen/color DEO + ( incr ) SWP2 8+ DUP2 .Screen/y DEO2 SWP2 + OVR2 OVR2 LTH2 ,&loop JNZ POP2 POP2 - ~scroll.y 8+ =Screen.y - DUP2 #0008 ADD2 =Screen.addr - ( draw ) #21 =Screen.color + .scroll/y PEK2 8+ .Screen/y DEO2 + DUP2 #0008 ADD2 .Screen/addr DEO2 + ( draw ) #21 .Screen/color DEO - #0000 =Screen.y - DUP2 #0010 ADD2 =Screen.addr - ( draw ) #24 =Screen.color + #0000 .Screen/y DEO2 + DUP2 #0010 ADD2 .Screen/addr DEO2 + ( draw ) #24 .Screen/color DEO - ~Screen.height 8- =Screen.y - #0018 ADD2 =Screen.addr - ( draw ) #24 =Screen.color + .Screen/height DEI2 8- .Screen/y DEO2 + #0018 ADD2 .Screen/addr DEO2 + ( draw ) #24 .Screen/color DEO RTN @draw-titlebar - #0018 ~Screen.height 8- #29 ,filepath - ( load ) =label.addr =label.color =Screen.y =Screen.x - ~label.addr - $loop - ( draw ) DUP2 PEK2 #00 SWP #20 SUB 8* ,font ADD2 =Screen.addr ~label.color =Screen.color + #0018 .Screen/height DEI2 8- #29 ;filepath + ( load ) .label/addr POK2 .label/color POK .Screen/y DEO2 .Screen/x DEO2 + .label/addr PEK2 + &loop + ( draw ) DUP2 GET #00 SWP #20 SUB 8* ;font ADD2 .Screen/addr DEO2 .label/color PEK .Screen/color DEO ( incr ) ++ - ( incr ) ~Screen.x 8+ =Screen.x - DUP2 PEK2 #00 NEQ ^$loop JNZ + ( incr ) .Screen/x DEI2 8+ .Screen/x DEO2 + DUP2 GET #00 NEQ ,&loop JNZ POP2 ( selection ) - ~selection.from ,document.body SUB2 ,draw-short JSR2 + .selection/from PEK2 ;document/body SUB2 ;draw-short JSR2 RTN -@font_hex ( 0-F TODO: should pull from @font instead.. ) +@font_hex ( 0-F TODO: should pull from @font instead.. ) [ 003c 464a 5262 3c00 0018 0808 0808 1c00 003c 4202 3c40 7e00 003c 421c 0242 3c00 000c 1424 447e 0400 007e 407c 0242 3c00 003c 407c 4242 3c00 007e 0204 0810 1000 003c 423c 4242 3c00 003c 4242 3e02 3c00 - 003c 4242 7e42 4200 007c 427c 4242 7c00 - 003c 4240 4042 3c00 007c 4242 4242 7c00 + 003c 4242 7e42 4200 007c 427c 4242 7c00 + 003c 4240 4042 3c00 007c 4242 4242 7c00 007e 4078 4040 7e00 007e 4078 4040 4000 ] -@font ( specter8-frag font ) +@font ( specter8-frag font ) [ 0000 0000 0000 0000 0008 0808 0800 0800 0014 1400 0000 0000 0024 7e24 247e 2400 @@ -696,17 +701,18 @@ RTN [ 0010 387c fe10 1010 ] ( up ) [ 0010 1010 fe7c 3810 ] ( down ) -@name_icn [ 1054 28c6 2854 1000 ] -@load_icn [ feaa d6aa d4aa f400 ] -@save_icn [ fe82 8282 848a f400 ] +@name_icn [ 1054 28c6 2854 1000 ] +@load_icn [ feaa d6aa d4aa f400 ] +@save_icn [ fe82 8282 848a f400 ] @linebreak_icn [ 003e 7474 3414 1400 ] @blank_icn [ 0000 0000 0000 0000 ] @cursor_icn [ 80c0 e0f0 f8e0 1000 ] -@filepath1 [ projects/examples/gui.hover.usm 00 ] -@filepath [ projects/examples/dev.time.usm 00 ] +@filepath1 [ "projects/examples/gui.hover.usm 00 ] +@filepath [ "README.md 00 ] + +@clip [ &len $2 &body $100 ] +@document [ &eof $2 &body $0 ] -;clip { len 2 body 256 } -;document { eof 2 body 2 } -\ No newline at end of file diff --git a/projects/software/nasu.usm b/projects/software/nasu.usm @@ -1,4 +1,4 @@ -( +( app/nasu : spritesheet editor arrows - move selection @@ -12,7 +12,8 @@ Select paint color for 2-bit mode ) -%RTN { JMP2r } + +%RTN { JMP2r } %STEP8 { #0033 SFT2 } %++ { #0001 ADD2 } %-- { #0001 SUB2 } @@ -23,87 +24,89 @@ %MOD { DUP2 DIV MUL SUB } %SIZE-TO-RECT { - STH2 STH2 OVR2 STH2r ADD2 OVR2 STH2r ADD2 + STH2 STH2 OVR2 STH2r ADD2 OVR2 STH2r ADD2 } ( x y w h -- x1 y1 x2 y2 ) %SET-RECT { - DUP2 ROT2 SWP2 #0006 ADD2 STR2 - DUP2 ROT2 SWP2 #0004 ADD2 STR2 - DUP2 ROT2 SWP2 #0002 ADD2 STR2 - DUP2 ROT2 SWP2 STR2 + DUP2 ROT2 SWP2 #0006 ADD2 PUT2 + DUP2 ROT2 SWP2 #0004 ADD2 PUT2 + DUP2 ROT2 SWP2 #0002 ADD2 PUT2 + DUP2 ROT2 SWP2 PUT2 POP2 } ( x1 y1 x2 y2 addr -- ) %BANK { #2000 } +( devices ) + +|00 @System [ &vector $2 &pad $6 &r $2 &g $2 &b $2 ] +|10 @Console [ &vector $2 &pad $6 &char $1 &byte $1 &short $2 &string $2 ] +|20 @Screen [ &vector $2 &width $2 &height $2 &pad $2 &x $2 &y $2 &addr $2 &color $1 ] +|40 @Controller [ &vector $2 &button $1 &key $1 ] +|60 @Mouse [ &vector $2 &x $2 &y $2 &state $1 &chord $1 ] +|70 @File [ &vector $2 &success $2 &offset $2 &pad $2 &name $2 &length $2 &load $2 &save $2 ] + ( variables ) -;settings { blending 1 depth 1 brush 1 page 2 } - -;frame { x1 2 y1 2 x2 2 y2 2 width 2 height 2 } -;bankview { x 2 y 2 mode 1 selection 1 } -;tileview { x 2 y 2 addr 2 } -;colorview { x1 2 y1 2 x2 2 y2 2 } -;blendview { x1 2 y1 2 x2 2 y2 2 } -;dataview { x1 2 y1 2 x2 2 y2 2 } -;rect { x1 2 y1 2 x2 2 y2 2 } -;mouse { x 2 y 2 } -;color { byte 1 } -;i { byte 1 } -;pt { x 1 y 1 } -;addr { short 2 } -;pos { x 2 y 2 } +|0000 -( devices ) +@settings [ &blending $1 &depth $1 &brush $1 &page $2 ] -|0100 ;System { vector 2 pad 6 r 2 g 2 b 2 } -|0110 ;Console { vector 2 pad 6 char 1 byte 1 short 2 string 2 } -|0120 ;Screen { vector 2 width 2 height 2 pad 2 x 2 y 2 addr 2 color 1 } -|0140 ;Controller { vector 2 button 1 key 1 } -|0160 ;Mouse { vector 2 x 2 y 2 state 1 chord 1 } -|0170 ;File { vector 2 success 2 offset 2 pad 2 name 2 length 2 load 2 save 2 } +@frame [ &x1 $2 &y1 $2 &x2 $2 &y2 $2 &width $2 &height $2 ] +@bankview [ &x $2 &y $2 &mode $1 &selection $1 ] +@tileview [ &x $2 &y $2 &addr $2 ] +@colorview [ &x1 $2 &y1 $2 &x2 $2 &y2 $2 ] +@blendview [ &x1 $2 &y1 $2 &x2 $2 &y2 $2 ] +@dataview [ &x1 $2 &y1 $2 &x2 $2 &y2 $2 ] +@rect [ &x1 $2 &y1 $2 &x2 $2 &y2 $2 ] +@mouse [ &x $2 &y $2 ] +@color [ &byte $1 ] +@i [ &byte $1 ] +@pt [ &x $1 &y $1 ] +@addr [ &short $2 ] +@pos [ &x $2 &y $2 ] ( program ) -|0200 +|0100 - ( theme ) #0efc =System.r #03cc =System.g #03ac =System.b - ( vectors ) ,on-button =Controller.vector - ( vectors ) ,on-mouse =Mouse.vector - ( vectors ) ,on-transfer =File.vector + ( theme ) #0efc .System/r DEO2 #03cc .System/g DEO2 #03ac .System/b DEO2 + ( vectors ) ;on-button .Controller/vector DEO2 + ( vectors ) ;on-mouse .Mouse/vector DEO2 + ( vectors ) ;on-transfer .File/vector DEO2 ( set frame ) - #0130 =frame.width - #00a8 =frame.height - #01 =settings.brush + #0130 .frame/width POK2 + #00a8 .frame/height POK2 + #01 .settings/brush POK - ~Screen.width 2/ ~frame.width 2/ SUB2 - ~Screen.height 2/ ~frame.height 2/ SUB2 #0010 ADD2 - ~frame.width ~frame.height - SIZE-TO-RECT ,frame SET-RECT + .Screen/width DEI2 2/ .frame/width PEK2 2/ SUB2 + .Screen/height DEI2 2/ .frame/height PEK2 2/ SUB2 #0010 ADD2 + .frame/width PEK2 .frame/height PEK2 + SIZE-TO-RECT ;frame SET-RECT - ~frame.x1 #0010 ADD2 =bankview.x - ~frame.y1 =bankview.y - BANK =settings.page + .frame/x1 PEK2 #0010 ADD2 .bankview/x POK2 + .frame/y1 PEK2 .bankview/y POK2 + BANK .settings/page POK2 - ~frame.x2 #0098 SUB2 =tileview.x - ~frame.y1 =tileview.y - BANK #0448 ADD2 =tileview.addr + .frame/x2 PEK2 #0098 SUB2 .tileview/x POK2 + .frame/y1 PEK2 .tileview/y POK2 + BANK #0448 ADD2 .tileview/addr POK2 - ~frame.x1 #0010 ADD2 ~frame.y2 #0020 SUB2 #0020 #0020 SIZE-TO-RECT ,blendview SET-RECT - ~frame.x1 #0038 ADD2 ~frame.y2 #0020 SUB2 #0020 #0020 SIZE-TO-RECT ,colorview SET-RECT - ~frame.x2 #0010 SUB2 ~frame.y1 #0010 #0080 SIZE-TO-RECT ,dataview SET-RECT + .frame/x1 PEK2 #0010 ADD2 .frame/y2 PEK2 #0020 SUB2 #0020 #0020 SIZE-TO-RECT ;blendview SET-RECT + .frame/x1 PEK2 #0038 ADD2 .frame/y2 PEK2 #0020 SUB2 #0020 #0020 SIZE-TO-RECT ;colorview SET-RECT + .frame/x2 PEK2 #0010 SUB2 .frame/y1 PEK2 #0010 #0080 SIZE-TO-RECT ;dataview SET-RECT - #01 =settings.blending + #01 .settings/blending POK - ,filepath1 =File.name #0800 =File.length BANK =File.load - ,filepath2 =File.name #0800 =File.length BANK #0800 ADD2 =File.load - ,filepath3 =File.name #1000 =File.length BANK #1000 ADD2 =File.load - ,filepath4 =File.name #1000 =File.length BANK #2000 ADD2 =File.load - ,filepath5 =File.name #1000 =File.length BANK #2800 ADD2 =File.load - ,filepath6 =File.name #1000 =File.length BANK #3800 ADD2 =File.load + ;filepath1 .File/name DEO2 #0800 .File/length DEO2 BANK .File/load DEO2 + ;filepath2 .File/name DEO2 #0800 .File/length DEO2 BANK #0800 ADD2 .File/load DEO2 + ;filepath3 .File/name DEO2 #1000 .File/length DEO2 BANK #1000 ADD2 .File/load DEO2 + ;filepath4 .File/name DEO2 #1000 .File/length DEO2 BANK #2000 ADD2 .File/load DEO2 + ;filepath5 .File/name DEO2 #1000 .File/length DEO2 BANK #2800 ADD2 .File/load DEO2 + ;filepath6 .File/name DEO2 #1000 .File/length DEO2 BANK #3800 ADD2 .File/load DEO2 - #40 DUP =bankview.selection ,select-tile JSR2 + #40 DUP .bankview/selection POK ;select-tile JSR2 ( ~frame.x1 ~frame.y1 ~frame.x2 ~frame.y2 #01 ,line-rect JSR2 ) @@ -111,221 +114,221 @@ BRK @on-transfer ( -> ) - ,redraw JSR2 + ;redraw JSR2 BRK @on-button ( -> ) ( arrow button ) - ~Controller.button #00 EQU ,$no-button JNZ2 - ~Controller.button #11 NEQ ^$no-pageup JNZ ~settings.page - #0800 SUB2 =settings.page ,redraw JSR2 BRK $no-pageup - ~Controller.button #21 NEQ ^$no-pagedown JNZ ~settings.page - #0800 ADD2 =settings.page ,redraw JSR2 BRK $no-pagedown - ~Controller.button #f0 AND - DUP #04 SFT #01 AND #01 NEQ ^$no-up JNZ - ( move ) ~bankview.selection #10 SUB =bankview.selection $no-up - DUP #05 SFT #01 AND #01 NEQ ^$no-down JNZ - ( move ) ~bankview.selection #10 ADD =bankview.selection $no-down - DUP #06 SFT #01 AND #01 NEQ ^$no-left JNZ - ( move ) ~bankview.selection #01 SUB =bankview.selection $no-left - DUP #07 SFT #01 AND #01 NEQ ^$no-right JNZ - ( move ) ~bankview.selection #01 ADD =bankview.selection $no-right + .Controller/button DEI #00 EQU ;&no-button JNZ2 + .Controller/button DEI #11 NEQ ,&no-pageup JNZ .settings/page PEK2 + #0800 SUB2 .settings/page POK2 ;redraw JSR2 BRK &no-pageup + .Controller/button DEI #21 NEQ ,&no-pagedown JNZ .settings/page PEK2 + #0800 ADD2 .settings/page POK2 ;redraw JSR2 BRK &no-pagedown + .Controller/button DEI #f0 AND + DUP #04 SFT #01 AND #01 NEQ ,&no-up JNZ + ( move ) .bankview/selection PEK #10 SUB .bankview/selection POK &no-up + DUP #05 SFT #01 AND #01 NEQ ,&no-down JNZ + ( move ) .bankview/selection PEK #10 ADD .bankview/selection POK &no-down + DUP #06 SFT #01 AND #01 NEQ ,&no-left JNZ + ( move ) .bankview/selection PEK #01 SUB .bankview/selection POK &no-left + DUP #07 SFT #01 AND #01 NEQ ,&no-right JNZ + ( move ) .bankview/selection PEK #01 ADD .bankview/selection POK &no-right POP - ~bankview.selection ,select-tile JSR2 - $no-button - - ~Controller.key #00 EQU ^$no-key JNZ - ~Controller.key #31 LTH ^$no-number JNZ - ~Controller.key #33 GTH ^$no-number JNZ - ( select ) ~Controller.key #31 SUB =bankview.mode - ,redraw JSR2 - $no-number - ~Controller.key #20 NEQ ^$no-space JNZ - ,toggle-depth JSR2 - ,redraw JSR2 - $no-space - $no-key + .bankview/selection PEK ;select-tile JSR2 + &no-button + + .Controller/key DEI #00 EQU ,&no-key JNZ + .Controller/key DEI #31 LTH ,&no-number JNZ + .Controller/key DEI #33 GTH ,&no-number JNZ + ( select ) .Controller/key DEI #31 SUB .bankview/mode POK + ;redraw JSR2 + &no-number + .Controller/key DEI #20 NEQ ,&no-space JNZ + ;toggle-depth JSR2 + ;redraw JSR2 + &no-space + &no-key BRK @on-mouse ( -> ) - ,draw-cursor JSR2 + ;draw-cursor JSR2 - ~Mouse.state #00 NEQ ^$no-touch JNZ BRK $no-touch + .Mouse/state DEI #00 NEQ ,&no-touch JNZ BRK &no-touch ( toolbar ) - ~Mouse.y ~bankview.y #0010 SUB2 SUB2 8/ #0000 NEQ2 ,$no-toolbar-click JNZ2 + .Mouse/y DEI2 .bankview/y PEK2 #0010 SUB2 SUB2 8/ #0000 NEQ2 ;&no-toolbar-click JNZ2 ( brush ) - ~Mouse.x ~bankview.x SUB2 8/ #000d LTH2 ^$no-brush-click JNZ - ~Mouse.x ~bankview.x SUB2 8/ #000f GTH2 ^$no-brush-click JNZ - ( select ) ~mouse.x ~bankview.x SUB2 8/ #000d SUB2 SWP POP =bankview.mode - $no-brush-click - ~Mouse.x ~bankview.x SUB2 8/ #0005 NEQ2 ^$no-toggle-depth JNZ - ,toggle-depth JSR2 - $no-toggle-depth - ( release ) #00 =Mouse.state - ,redraw JSR2 BRK - $no-toolbar-click + .Mouse/x DEI2 .bankview/x PEK2 SUB2 8/ #000d LTH2 ,&no-brush-click JNZ + .Mouse/x DEI2 .bankview/x PEK2 SUB2 8/ #000f GTH2 ,&no-brush-click JNZ + ( select ) .mouse/x PEK2 .bankview/x PEK2 SUB2 8/ #000d SUB2 SWP POP .bankview/mode POK + &no-brush-click + .Mouse/x DEI2 .bankview/x PEK2 SUB2 8/ #0005 NEQ2 ,&no-toggle-depth JNZ + ;toggle-depth JSR2 + &no-toggle-depth + ( release ) #00 .Mouse/state DEO + ;redraw JSR2 BRK + &no-toolbar-click ( bankview ) - ~Mouse.x ~bankview.x GTH2 ~Mouse.x ~bankview.x #0080 ADD2 LTH2 #0101 EQU2 - ~Mouse.y ~bankview.y GTH2 ~Mouse.y ~bankview.y #0080 ADD2 LTH2 #0101 EQU2 - #0101 EQU2 ,on-touch-bankview JNZ2 + .Mouse/x DEI2 .bankview/x PEK2 GTH2 .Mouse/x DEI2 .bankview/x PEK2 #0080 ADD2 LTH2 #0101 EQU2 + .Mouse/y DEI2 .bankview/y PEK2 GTH2 .Mouse/y DEI2 .bankview/y PEK2 #0080 ADD2 LTH2 #0101 EQU2 + #0101 EQU2 ;on-touch-bankview JNZ2 ( tileview ) - ~Mouse.x ~tileview.x GTH2 ~Mouse.x ~tileview.x #0080 ADD2 LTH2 #0101 EQU2 - ~Mouse.y ~tileview.y GTH2 ~Mouse.y ~tileview.y #0080 ADD2 LTH2 #0101 EQU2 - #0101 EQU2 ,on-touch-tileview JNZ2 + .Mouse/x DEI2 .tileview/x PEK2 GTH2 .Mouse/x DEI2 .tileview/x PEK2 #0080 ADD2 LTH2 #0101 EQU2 + .Mouse/y DEI2 .tileview/y PEK2 GTH2 .Mouse/y DEI2 .tileview/y PEK2 #0080 ADD2 LTH2 #0101 EQU2 + #0101 EQU2 ;on-touch-tileview JNZ2 ( dataview ) - ~Mouse.x DUP2 ~dataview.x1 GTH2 ROT ROT ~dataview.x2 LTH2 #0101 EQU2 - ~Mouse.y DUP2 ~dataview.y1 GTH2 ROT ROT ~dataview.y2 LTH2 #0101 EQU2 - #0101 EQU2 ,on-touch-dataview JNZ2 + .Mouse/x DEI2 DUP2 .dataview/x1 PEK2 GTH2 ROT ROT .dataview/x2 PEK2 LTH2 #0101 EQU2 + .Mouse/y DEI2 DUP2 .dataview/y1 PEK2 GTH2 ROT ROT .dataview/y2 PEK2 LTH2 #0101 EQU2 + #0101 EQU2 ;on-touch-dataview JNZ2 ( blendbiew ) - ~Mouse.x DUP2 ~blendview.x1 GTH2 ROT ROT ~blendview.x2 LTH2 #0101 EQU2 - ~Mouse.y DUP2 ~blendview.y1 GTH2 ROT ROT ~blendview.y2 LTH2 #0101 EQU2 - #0101 EQU2 ,on-touch-blendview JNZ2 + .Mouse/x DEI2 DUP2 .blendview/x1 PEK2 GTH2 ROT ROT .blendview/x2 PEK2 LTH2 #0101 EQU2 + .Mouse/y DEI2 DUP2 .blendview/y1 PEK2 GTH2 ROT ROT .blendview/y2 PEK2 LTH2 #0101 EQU2 + #0101 EQU2 ;on-touch-blendview JNZ2 ( colorview ) - ~Mouse.x DUP2 ~colorview.x1 GTH2 ROT ROT ~colorview.x2 LTH2 #0101 EQU2 - ~Mouse.y DUP2 ~colorview.y1 GTH2 ROT ROT ~colorview.y2 LTH2 #0101 EQU2 - #0101 EQU2 ,on-touch-colorview JNZ2 + .Mouse/x DEI2 DUP2 .colorview/x1 PEK2 GTH2 ROT ROT .colorview/x2 PEK2 LTH2 #0101 EQU2 + .Mouse/y DEI2 DUP2 .colorview/y1 PEK2 GTH2 ROT ROT .colorview/y2 PEK2 LTH2 #0101 EQU2 + #0101 EQU2 ;on-touch-colorview JNZ2 BRK @on-touch-bankview ( -> ) - ~bankview.mode #01 NEQ ^$not-copy-mode JNZ - #00 =i - $copy-loop - ( load ) ~tileview.addr ~i ADD PEK2 + .bankview/mode PEK #01 NEQ ,&not-copy-mode JNZ + #00 .i POK + &copy-loop + ( load ) .tileview/addr PEK2 .i PEK ADD GET ( get touch addr ) - ~Mouse.x ~bankview.x SUB2 STEP8 - ~Mouse.y ~bankview.y SUB2 STEP8 #0010 MUL2 ADD2 - ( 2-bit mode ) #00 ~settings.depth #01 ADD MUL2 - ~settings.page ADD2 #00 ~i ADD2 POK2 - ( incr ) ~i #01 ADD =i - ~i #08 LTH ^$copy-loop JNZ - ,redraw JSR2 BRK - $not-copy-mode - - ~bankview.mode #02 NEQ ^$not-erase-mode JNZ - #00 =i - $erase-loop - #00 + .Mouse/x DEI2 .bankview/x PEK2 SUB2 STEP8 + .Mouse/y DEI2 .bankview/y PEK2 SUB2 STEP8 #0010 MUL2 ADD2 + ( 2-bit mode ) #00 .settings/depth PEK #01 ADD MUL2 + .settings/page PEK2 ADD2 #00 .i PEK ADD2 PUT + ( incr ) .i PEK #01 ADD .i POK + .i PEK #08 LTH ,&copy-loop JNZ + ;redraw JSR2 BRK + &not-copy-mode + + .bankview/mode PEK #02 NEQ ,&not-erase-mode JNZ + #00 .i POK + &erase-loop + #00 ( get touch addr ) - ~Mouse.x ~bankview.x SUB2 STEP8 - ~Mouse.y ~bankview.y SUB2 STEP8 #0010 MUL2 ADD2 - ( 2-bit mode ) #00 ~settings.depth #01 ADD MUL2 - ~settings.page ADD2 #00 ~i ADD2 POK2 - ( incr ) ~i #01 ADD =i - ~i #08 LTH ^$erase-loop JNZ - ,redraw JSR2 BRK - $not-erase-mode + .Mouse/x DEI2 .bankview/x PEK2 SUB2 STEP8 + .Mouse/y DEI2 .bankview/y PEK2 SUB2 STEP8 #0010 MUL2 ADD2 + ( 2-bit mode ) #00 .settings/depth PEK #01 ADD MUL2 + .settings/page PEK2 ADD2 #00 .i PEK ADD2 PUT + ( incr ) .i PEK #01 ADD .i POK + .i PEK #08 LTH ,&erase-loop JNZ + ;redraw JSR2 BRK + &not-erase-mode ( select ) - ~Mouse.x ~bankview.x SUB2 8/ SWP POP - ~Mouse.y ~bankview.y SUB2 8/ SWP POP #40 SFT ADD - DUP =bankview.selection - ,select-tile JSR2 + .Mouse/x DEI2 .bankview/x PEK2 SUB2 8/ SWP POP + .Mouse/y DEI2 .bankview/y PEK2 SUB2 8/ SWP POP #40 SFT ADD + DUP .bankview/selection POK + ;select-tile JSR2 BRK @on-touch-tileview ( -> ) - ~Mouse.x ~tileview.x SUB2 STEP8 #0040 DIV2 - ~Mouse.y ~tileview.y SUB2 STEP8 #0040 DIV2 2* ADD2 + .Mouse/x DEI2 .tileview/x PEK2 SUB2 STEP8 #0040 DIV2 + .Mouse/y DEI2 .tileview/y PEK2 SUB2 STEP8 #0040 DIV2 2* ADD2 8* - ~tileview.addr ADD2 =addr ( addr offset ) - ~Mouse.x ~tileview.x SUB2 ~Mouse.x ~tileview.x SUB2 #0040 DIV2 #0040 MUL2 SUB2 =pos.x - ~Mouse.y ~tileview.y SUB2 ~Mouse.y ~tileview.y SUB2 #0040 DIV2 #0040 MUL2 SUB2 =pos.y - ~Mouse.state #10 NEQ ^$no-erase-mode JNZ - ( load ) ~addr ~pos.y 8/ ADD2 PEK2 - ( mask ) #01 #07 ~pos.x 8/ SWP POP SUB SFL + .tileview/addr PEK2 ADD2 .addr POK2 ( addr offset ) + .Mouse/x DEI2 .tileview/x PEK2 SUB2 .Mouse/x DEI2 .tileview/x PEK2 SUB2 #0040 DIV2 #0040 MUL2 SUB2 .pos/x POK2 + .Mouse/y DEI2 .tileview/y PEK2 SUB2 .Mouse/y DEI2 .tileview/y PEK2 SUB2 #0040 DIV2 #0040 MUL2 SUB2 .pos/y POK2 + .Mouse/state DEI #10 NEQ ,&no-erase-mode JNZ + ( load ) .addr PEK2 .pos/y PEK2 8/ ADD2 GET + ( mask ) #01 #07 .pos/x PEK2 8/ SWP POP SUB SFL #ff EOR AND - ( save ) ~addr ~pos.y 8/ ADD2 POK2 - ,redraw JSR2 BRK - $no-erase-mode - ( load ) ~addr ~pos.y 8/ ADD2 PEK2 - ( mask ) #01 #07 ~pos.x 8/ SWP POP SUB SFL + ( save ) .addr PEK2 .pos/y PEK2 8/ ADD2 PUT + ;redraw JSR2 BRK + &no-erase-mode + ( load ) .addr PEK2 .pos/y PEK2 8/ ADD2 GET + ( mask ) #01 #07 .pos/x PEK2 8/ SWP POP SUB SFL ORA - ( save ) ~addr ~pos.y 8/ ADD2 POK2 - ,redraw JSR2 + ( save ) .addr PEK2 .pos/y PEK2 8/ ADD2 PUT + ;redraw JSR2 BRK @on-touch-dataview ( -> ) - ~Mouse.y ~dataview.y1 SUB2 STEP8 SWP POP #60 EQU ^$skip JNZ BRK $skip - ~Mouse.x ~dataview.x1 SUB2 #0008 DIV2 SWP POP - DUP #00 NEQ ^$no-move-up JNZ - ,op_shiftup JSR2 - ( release ) #00 =Mouse.state - ,redraw JSR2 POP BRK $no-move-up - DUP #01 NEQ ^$no-move-down JNZ - ,op_shiftdown JSR2 - ( release ) #00 =Mouse.state - ,redraw JSR2 POP BRK $no-move-down + .Mouse/y DEI2 .dataview/y1 PEK2 SUB2 STEP8 SWP POP #60 EQU ,&skip JNZ BRK &skip + .Mouse/x DEI2 .dataview/x1 PEK2 SUB2 #0008 DIV2 SWP POP + DUP #00 NEQ ,&no-move-up JNZ + ;op_shiftup JSR2 + ( release ) #00 .Mouse/state DEO + ;redraw JSR2 POP BRK &no-move-up + DUP #01 NEQ ,&no-move-down JNZ + ;op_shiftdown JSR2 + ( release ) #00 .Mouse/state DEO + ;redraw JSR2 POP BRK &no-move-down POP BRK @on-touch-blendview ( -> ) - ~Mouse.x ~blendview.x1 SUB2 8/ SWP POP - ~Mouse.y ~blendview.y1 SUB2 8/ SWP POP #04 MUL ADD - =settings.blending - ( release ) #00 =Mouse.state - ,redraw JSR2 + .Mouse/x DEI2 .blendview/x1 PEK2 SUB2 8/ SWP POP + .Mouse/y DEI2 .blendview/y1 PEK2 SUB2 8/ SWP POP #04 MUL ADD + .settings/blending POK + ( release ) #00 .Mouse/state DEO + ;redraw JSR2 -BRK +BRK @on-touch-colorview ( -> ) - ( channel ) ~Mouse.y ~colorview.y1 SUB2 8/ SWP POP STH - ( rgb ) ~Mouse.x ~colorview.x1 SUB2 8/ SWP POP - DUP #00 NEQ ^$no-brush JNZ - DUPr STHr =settings.brush $no-brush - DUP #01 NEQ ^$no-red JNZ - DUPr STHr ,System.r ,set-color JSR2 $no-red - DUP #02 NEQ ^$no-green JNZ - DUPr STHr ,System.g ,set-color JSR2 $no-green - DUP #03 NEQ ^$no-blue JNZ - DUPr STHr ,System.b ,set-color JSR2 $no-blue + ( channel ) .Mouse/y DEI2 .colorview/y1 PEK2 SUB2 8/ SWP POP STH + ( rgb ) .Mouse/x DEI2 .colorview/x1 PEK2 SUB2 8/ SWP POP + DUP #00 NEQ ,&no-brush JNZ + DUPr STHr .settings/brush POK &no-brush + DUP #01 NEQ ,&no-red JNZ + DUPr STHr ;System/r ;set-color JSR2 &no-red + DUP #02 NEQ ,&no-green JNZ + DUPr STHr ;System/g ;set-color JSR2 &no-green + DUP #03 NEQ ,&no-blue JNZ + DUPr STHr ;System/b ;set-color JSR2 &no-blue POP POPr - ( release ) #00 =Mouse.state - ,redraw JSR2 + ( release ) #00 .Mouse/state DEO + ;redraw JSR2 BRK @set-color ( color rgb -- ) STH2 - DUP #00 NEQ ^$no-red0 JNZ - DUP2r STH2r PEK2 DUP #04 SFT #01 ADD - ( add/sub ) ~Mouse.state #10 EQU #fe MUL ADD - ( resume ) #40 SFT SWP #0f AND ADD DUP2r STH2r POK2 - $no-red0 - DUP #01 NEQ ^$no-red1 JNZ - DUP2r STH2r PEK2 DUP #0f AND #01 ADD - ( add/sub ) ~Mouse.state #10 EQU #fe MUL ADD - ( resume ) #0f AND SWP #f0 AND ADD DUP2r STH2r POK2 - $no-red1 - DUP #02 NEQ ^$no-red2 JNZ - DUP2r STH2r #0001 ADD2 PEK2 DUP #04 SFT #01 ADD - ( add/sub ) ~Mouse.state #10 EQU #fe MUL ADD - ( resume ) #40 SFT SWP #0f AND ADD DUP2r STH2r #0001 ADD2 POK2 - $no-red2 - DUP #03 NEQ ^$no-red3 JNZ - DUP2r STH2r #0001 ADD2 PEK2 DUP #0f AND #01 ADD - ( add/sub ) ~Mouse.state #10 EQU #fe MUL ADD - ( resume ) #0f AND SWP #f0 AND ADD DUP2r STH2r #0001 ADD2 POK2 - $no-red3 + DUP #00 NEQ ,&no-red0 JNZ + DUP2r STH2r GET DUP #04 SFT #01 ADD + ( add/sub ) .Mouse/state DEI #10 EQU #fe MUL ADD + ( resume ) #40 SFT SWP #0f AND ADD DUP2r STH2r PUT + &no-red0 + DUP #01 NEQ ,&no-red1 JNZ + DUP2r STH2r GET DUP #0f AND #01 ADD + ( add/sub ) .Mouse/state DEI #10 EQU #fe MUL ADD + ( resume ) #0f AND SWP #f0 AND ADD DUP2r STH2r PUT + &no-red1 + DUP #02 NEQ ,&no-red2 JNZ + DUP2r STH2r #0001 ADD2 GET DUP #04 SFT #01 ADD + ( add/sub ) .Mouse/state DEI #10 EQU #fe MUL ADD + ( resume ) #40 SFT SWP #0f AND ADD DUP2r STH2r #0001 ADD2 PUT + &no-red2 + DUP #03 NEQ ,&no-red3 JNZ + DUP2r STH2r #0001 ADD2 GET DUP #0f AND #01 ADD + ( add/sub ) .Mouse/state DEI #10 EQU #fe MUL ADD + ( resume ) #0f AND SWP #f0 AND ADD DUP2r STH2r #0001 ADD2 PUT + &no-red3 POP POP2r @@ -334,230 +337,230 @@ RTN @select-tile ( pos -- ) ( x y ) DUP #0f AND SWP #04 SFT - ( y ) #10 MOD #10 MUL #00 SWP 8* - ( x ) ROT #10 MOD #00 SWP 8* ADD2 - ( 2-bit mode ) #00 ~settings.depth #01 ADD MUL2 - ( offset ) ~settings.page ADD2 =tileview.addr - ,redraw JSR2 + ( y ) #10 MOD #10 MUL #00 SWP 8* + ( x ) ROT #10 MOD #00 SWP 8* ADD2 + ( 2-bit mode ) #00 .settings/depth PEK #01 ADD MUL2 + ( offset ) .settings/page PEK2 ADD2 .tileview/addr POK2 + ;redraw JSR2 RTN @toggle-depth ( -- ) - ~bankview.selection - ~settings.depth #00 EQU =settings.depth - ,select-tile JSR2 + .bankview/selection PEK + .settings/depth PEK #00 EQU .settings/depth POK + ;select-tile JSR2 RTN @op_shiftup - ~tileview.addr PEK2 - ~tileview.addr #0001 ADD2 PEK2 ~tileview.addr POK2 - ~tileview.addr #0002 ADD2 PEK2 ~tileview.addr #0001 ADD2 POK2 - ~tileview.addr #0003 ADD2 PEK2 ~tileview.addr #0002 ADD2 POK2 - ~tileview.addr #0004 ADD2 PEK2 ~tileview.addr #0003 ADD2 POK2 - ~tileview.addr #0005 ADD2 PEK2 ~tileview.addr #0004 ADD2 POK2 - ~tileview.addr #0006 ADD2 PEK2 ~tileview.addr #0005 ADD2 POK2 - ~tileview.addr #0007 ADD2 PEK2 ~tileview.addr #0006 ADD2 POK2 - ~tileview.addr #0007 ADD2 POK2 + .tileview/addr PEK2 GET + .tileview/addr PEK2 #0001 ADD2 GET .tileview/addr PEK2 PUT + .tileview/addr PEK2 #0002 ADD2 GET .tileview/addr PEK2 #0001 ADD2 PUT + .tileview/addr PEK2 #0003 ADD2 GET .tileview/addr PEK2 #0002 ADD2 PUT + .tileview/addr PEK2 #0004 ADD2 GET .tileview/addr PEK2 #0003 ADD2 PUT + .tileview/addr PEK2 #0005 ADD2 GET .tileview/addr PEK2 #0004 ADD2 PUT + .tileview/addr PEK2 #0006 ADD2 GET .tileview/addr PEK2 #0005 ADD2 PUT + .tileview/addr PEK2 #0007 ADD2 GET .tileview/addr PEK2 #0006 ADD2 PUT + .tileview/addr PEK2 #0007 ADD2 PUT RTN @op_shiftdown - ~tileview.addr #0007 ADD2 PEK2 - ~tileview.addr #0006 ADD2 PEK2 ~tileview.addr #0007 ADD2 POK2 - ~tileview.addr #0005 ADD2 PEK2 ~tileview.addr #0006 ADD2 POK2 - ~tileview.addr #0004 ADD2 PEK2 ~tileview.addr #0005 ADD2 POK2 - ~tileview.addr #0003 ADD2 PEK2 ~tileview.addr #0004 ADD2 POK2 - ~tileview.addr #0002 ADD2 PEK2 ~tileview.addr #0003 ADD2 POK2 - ~tileview.addr #0001 ADD2 PEK2 ~tileview.addr #0002 ADD2 POK2 - ~tileview.addr PEK2 ~tileview.addr #0001 ADD2 POK2 - ~tileview.addr POK2 + .tileview/addr PEK2 #0007 ADD2 GET + .tileview/addr PEK2 #0006 ADD2 GET .tileview/addr PEK2 #0007 ADD2 PUT + .tileview/addr PEK2 #0005 ADD2 GET .tileview/addr PEK2 #0006 ADD2 PUT + .tileview/addr PEK2 #0004 ADD2 GET .tileview/addr PEK2 #0005 ADD2 PUT + .tileview/addr PEK2 #0003 ADD2 GET .tileview/addr PEK2 #0004 ADD2 PUT + .tileview/addr PEK2 #0002 ADD2 GET .tileview/addr PEK2 #0003 ADD2 PUT + .tileview/addr PEK2 #0001 ADD2 GET .tileview/addr PEK2 #0002 ADD2 PUT + .tileview/addr PEK2 GET .tileview/addr PEK2 #0001 ADD2 PUT + .tileview/addr PEK2 PUT RTN @redraw - ,draw-bankview JSR2 - ,draw-tileview JSR2 - ,draw-blendview JSR2 - ,draw-colorview JSR2 - ,draw-dataview JSR2 + ;draw-bankview JSR2 + ;draw-tileview JSR2 + ;draw-blendview JSR2 + ;draw-colorview JSR2 + ;draw-dataview JSR2 RTN @draw-bankview - ~bankview.x #0002 SUB2 ~bankview.y #0002 SUB2 ~bankview.x #0081 ADD2 ~bankview.y #0081 ADD2 #03 ,line-rect JSR2 + .bankview/x PEK2 #0002 SUB2 .bankview/y PEK2 #0002 SUB2 .bankview/x PEK2 #0081 ADD2 .bankview/y PEK2 #0081 ADD2 #03 ;line-rect JSR2 ( position ) - ~bankview.x =Screen.x - ~bankview.y #0010 SUB2 =Screen.y - ~settings.page ,draw-short JSR2 + .bankview/x PEK2 .Screen/x DEO2 + .bankview/y PEK2 #0010 SUB2 .Screen/y DEO2 + .settings/page PEK2 ;draw-short JSR2 ( toolbar ) - ~bankview.y #0010 SUB2 =Screen.y + .bankview/y PEK2 #0010 SUB2 .Screen/y DEO2 - ~bankview.x #0028 ADD2 =Screen.x - ,depth_icns #00 ~settings.depth 8* ADD2 =Screen.addr - #23 =Screen.color + .bankview/x PEK2 #0028 ADD2 .Screen/x DEO2 + ;depth_icns #00 .settings/depth PEK 8* ADD2 .Screen/addr DEO2 + #23 .Screen/color DEO - ~bankview.x #0068 ADD2 =Screen.x - ,tool_selector =Screen.addr - #21 ~bankview.mode #00 EQU ADD =Screen.color + .bankview/x PEK2 #0068 ADD2 .Screen/x DEO2 + ;tool_selector .Screen/addr DEO2 + #21 .bankview/mode PEK #00 EQU ADD .Screen/color DEO - ~Screen.x 8+ =Screen.x - ,tool_hand =Screen.addr - #21 ~bankview.mode #01 EQU ADD =Screen.color + .Screen/x DEI2 8+ .Screen/x DEO2 + ;tool_hand .Screen/addr DEO2 + #21 .bankview/mode PEK #01 EQU ADD .Screen/color DEO - ~Screen.x 8+ =Screen.x - ,tool_eraser =Screen.addr - #21 ~bankview.mode #02 EQU ADD =Screen.color + .Screen/x DEI2 8+ .Screen/x DEO2 + ;tool_eraser .Screen/addr DEO2 + #21 .bankview/mode PEK #02 EQU ADD .Screen/color DEO ( guides ) - ~bankview.x #0010 SUB2 =Screen.x - ~bankview.y =Screen.y - ,font_hex =Screen.addr + .bankview/x PEK2 #0010 SUB2 .Screen/x DEO2 + .bankview/y PEK2 .Screen/y DEO2 + ;font_hex .Screen/addr DEO2 #00 #10 - $guides - ( draw ) OVR ~bankview.selection #04 SFT EQU #22 ADD =Screen.color - ~Screen.addr 8+ =Screen.addr - ~Screen.y 8+ =Screen.y + &guides + ( draw ) OVR .bankview/selection PEK #04 SFT EQU #22 ADD .Screen/color DEO + .Screen/addr DEI2 8+ .Screen/addr DEO2 + .Screen/y DEI2 8+ .Screen/y DEO2 SWP #01 ADD SWP - DUP2 LTH ^$guides JNZ + DUP2 LTH ,&guides JNZ POP2 ( draw page ) - ( load ) ~settings.page =Screen.addr - ~bankview.y DUP2 #0080 ADD2 - $ver - ( save ) OVR2 =Screen.y - ~bankview.x DUP2 #0080 ADD2 - $hor - ( save ) OVR2 =Screen.x - ( get selected ) ~Screen.addr ~tileview.addr EQU2 - ( get blending ) ~settings.blending - ( get depth ) ~settings.depth #20 MUL - ( draw ) #20 ADD ADD ADD =Screen.color + ( load ) .settings/page PEK2 .Screen/addr DEO2 + .bankview/y PEK2 DUP2 #0080 ADD2 + &ver + ( save ) OVR2 .Screen/y DEO2 + .bankview/x PEK2 DUP2 #0080 ADD2 + &hor + ( save ) OVR2 .Screen/x DEO2 + ( get selected ) .Screen/addr DEI2 .tileview/addr PEK2 EQU2 + ( get blending ) .settings/blending PEK + ( get depth ) .settings/depth PEK #20 MUL + ( draw ) #20 ADD ADD ADD .Screen/color DEO ( incr ) SWP2 8+ SWP2 - ( incr ) ~Screen.addr 8+ #00 ~settings.depth #0008 MUL2 ADD2 =Screen.addr - OVR2 OVR2 LTH2 ^$hor JNZ + ( incr ) .Screen/addr DEI2 8+ #00 .settings/depth PEK #0008 MUL2 ADD2 .Screen/addr DEO2 + OVR2 OVR2 LTH2 ,&hor JNZ POP2 POP2 ( incr ) SWP2 8+ SWP2 - OVR2 OVR2 LTH2 ^$ver JNZ + OVR2 OVR2 LTH2 ,&ver JNZ POP2 POP2 RTN @draw-tileview - ~tileview.x #0002 SUB2 ~tileview.y #0002 SUB2 ~tileview.x #0080 ADD2 ~tileview.y #0081 ADD2 #03 ,line-rect JSR2 + .tileview/x PEK2 #0002 SUB2 .tileview/y PEK2 #0002 SUB2 .tileview/x PEK2 #0080 ADD2 .tileview/y PEK2 #0081 ADD2 #03 ;line-rect JSR2 - ~tileview.x #0028 ADD2 =Screen.x - ~tileview.y #0010 SUB2 =Screen.y - ~tileview.addr =Screen.addr + .tileview/x PEK2 #0028 ADD2 .Screen/x DEO2 + .tileview/y PEK2 #0010 SUB2 .Screen/y DEO2 + .tileview/addr PEK2 .Screen/addr DEO2 - ( get blending ) ~settings.blending - ( get depth ) ~settings.depth #20 MUL - ( draw ) #20 ADD ADD =Screen.color + ( get blending ) .settings/blending PEK + ( get depth ) .settings/depth PEK #20 MUL + ( draw ) #20 ADD ADD .Screen/color DEO ( position ) - ~tileview.x =Screen.x - ~tileview.y #0010 SUB2 =Screen.y - ~tileview.addr ,draw-short JSR2 + .tileview/x PEK2 .Screen/x DEO2 + .tileview/y PEK2 #0010 SUB2 .Screen/y DEO2 + .tileview/addr PEK2 ;draw-short JSR2 ( body ) - ~tileview.x =Screen.x - ~tileview.y =Screen.y - ~tileview.addr =tileview.addr - ,draw-tileview-icn JSR2 + .tileview/x PEK2 .Screen/x DEO2 + .tileview/y PEK2 .Screen/y DEO2 + .tileview/addr PEK2 .tileview/addr POK2 + ;draw-tileview-icn JSR2 - ~tileview.x #0040 ADD2 =Screen.x - ~tileview.y =Screen.y - ~tileview.addr 8+ =tileview.addr - ,draw-tileview-icn JSR2 + .tileview/x PEK2 #0040 ADD2 .Screen/x DEO2 + .tileview/y PEK2 .Screen/y DEO2 + .tileview/addr PEK2 8+ .tileview/addr POK2 + ;draw-tileview-icn JSR2 - ~tileview.x =Screen.x - ~tileview.y #0040 ADD2 =Screen.y - ~tileview.addr 8+ =tileview.addr - ,draw-tileview-icn JSR2 + .tileview/x PEK2 .Screen/x DEO2 + .tileview/y PEK2 #0040 ADD2 .Screen/y DEO2 + .tileview/addr PEK2 8+ .tileview/addr POK2 + ;draw-tileview-icn JSR2 - ~tileview.x #0040 ADD2 =Screen.x - ~tileview.y #0040 ADD2 =Screen.y - ~tileview.addr 8+ =tileview.addr - ,draw-tileview-icn JSR2 + .tileview/x PEK2 #0040 ADD2 .Screen/x DEO2 + .tileview/y PEK2 #0040 ADD2 .Screen/y DEO2 + .tileview/addr PEK2 8+ .tileview/addr POK2 + ;draw-tileview-icn JSR2 ( line hor ) - ~tileview.y #003f ADD2 =Screen.y - ~tileview.x =Screen.x - $line-hor - ( draw ) #03 =Screen.color - ( incr ) ~Screen.x #0002 ADD2 =Screen.x - ~Screen.x ~tileview.x #0082 ADD2 LTH2 ^$line-hor JNZ + .tileview/y PEK2 #003f ADD2 .Screen/y DEO2 + .tileview/x PEK2 .Screen/x DEO2 + &line-hor + ( draw ) #03 .Screen/color DEO + ( incr ) .Screen/x DEI2 #0002 ADD2 .Screen/x DEO2 + .Screen/x DEI2 .tileview/x PEK2 #0082 ADD2 LTH2 ,&line-hor JNZ ( line ver ) - ~tileview.y =Screen.y - ~tileview.x #003f ADD2 =Screen.x - $line-ver - ( draw ) #03 =Screen.color - ( incr ) ~Screen.y #0002 ADD2 =Screen.y - ~Screen.y ~tileview.y #0081 ADD2 LTH2 ^$line-ver JNZ + .tileview/y PEK2 .Screen/y DEO2 + .tileview/x PEK2 #003f ADD2 .Screen/x DEO2 + &line-ver + ( draw ) #03 .Screen/color DEO + ( incr ) .Screen/y DEI2 #0002 ADD2 .Screen/y DEO2 + .Screen/y DEI2 .tileview/y PEK2 #0081 ADD2 LTH2 ,&line-ver JNZ - ( rewind ) ~tileview.addr #0018 SUB2 =tileview.addr + ( rewind ) .tileview/addr PEK2 #0018 SUB2 .tileview/addr POK2 RTN @draw-tileview-icn - #00 =pt.x #00 =pt.y - $ver - #00 =pt.x - $hor + #00 .pt/x POK #00 .pt/y POK + &ver + #00 .pt/x POK + &hor ( get bit ) - ,blank_icn #00 - ~tileview.addr #00 ~pt.y ADD2 PEK2 #07 ~pt.x SUB SFT #01 AND ( get bit ) - 8* ADD2 =Screen.addr ( add *8 ) - ( draw ) #21 =Screen.color - ( incr ) ~Screen.x 8+ =Screen.x - ( incr ) ~pt.x #01 ADD =pt.x - ~pt.x #08 LTH ,$hor JNZ2 - ( incr ) ~Screen.y 8+ =Screen.y - ( incr ) ~pt.y #01 ADD =pt.y - ~Screen.x #0040 SUB2 =Screen.x - ~pt.y #08 LTH ,$ver JNZ2 + ;blank_icn #00 + .tileview/addr PEK2 #00 .pt/y PEK ADD2 GET #07 .pt/x PEK SUB SFT #01 AND ( get bit ) + 8* ADD2 .Screen/addr DEO2 ( add *8 ) + ( draw ) #21 .Screen/color DEO + ( incr ) .Screen/x DEI2 8+ .Screen/x DEO2 + ( incr ) .pt/x PEK #01 ADD .pt/x POK + .pt/x PEK #08 LTH ;&hor JNZ2 + ( incr ) .Screen/y DEI2 8+ .Screen/y DEO2 + ( incr ) .pt/y PEK #01 ADD .pt/y POK + .Screen/x DEI2 #0040 SUB2 .Screen/x DEO2 + .pt/y PEK #08 LTH ;&ver JNZ2 RTN @draw-blendview ( -- ) - ~blendview.x1 #0002 SUB2 ~blendview.y1 #0002 SUB2 ~blendview.x2 #0001 ADD2 ~blendview.y2 #0001 ADD2 #03 ,line-rect JSR2 + .blendview/x1 PEK2 #0002 SUB2 .blendview/y1 PEK2 #0002 SUB2 .blendview/x2 PEK2 #0001 ADD2 .blendview/y2 PEK2 #0001 ADD2 #03 ;line-rect JSR2 - ~tileview.addr =Screen.addr + .tileview/addr PEK2 .Screen/addr DEO2 #00 #10 - $loop - OVR #04 MOD #00 SWP #0008 MUL2 ~blendview.x1 ADD2 =Screen.x - OVR #04 DIV #00 SWP #0008 MUL2 ~blendview.y1 ADD2 =Screen.y - #20 =Screen.color - OVR #20 ADD ~settings.depth #20 MUL ADD =Screen.color + &loop + OVR #04 MOD #00 SWP #0008 MUL2 .blendview/x1 PEK2 ADD2 .Screen/x DEO2 + OVR #04 DIV #00 SWP #0008 MUL2 .blendview/y1 PEK2 ADD2 .Screen/y DEO2 + #20 .Screen/color DEO + OVR #20 ADD .settings/depth PEK #20 MUL ADD .Screen/color DEO SWP #01 ADD SWP - DUP2 LTH ^$loop JNZ + DUP2 LTH ,&loop JNZ POP2 - ~blendview.x1 #0002 SUB2 ~blendview.y2 #0001 ADD2 ~blendview.x1 #000e ADD2 ~blendview.y2 #0009 ADD2 #03 ,line-rect JSR2 - ~blendview.x1 #0001 SUB2 =Screen.x - ~blendview.y2 #0001 ADD2 =Screen.y + .blendview/x1 PEK2 #0002 SUB2 .blendview/y2 PEK2 #0001 ADD2 .blendview/x1 PEK2 #000e ADD2 .blendview/y2 PEK2 #0009 ADD2 #03 ;line-rect JSR2 + .blendview/x1 PEK2 #0001 SUB2 .Screen/x DEO2 + .blendview/y2 PEK2 #0001 ADD2 .Screen/y DEO2 - ( get blending ) ~settings.blending - ( get depth ) ~settings.depth #20 MUL - ( draw ) #20 ADD ADD #2c ,draw-byte JSR2 + ( get blending ) .settings/blending PEK + ( get depth ) .settings/depth PEK #20 MUL + ( draw ) #20 ADD ADD #2c ;draw-byte JSR2 RTN @@ -565,130 +568,130 @@ RTN ( bytes ) - ~tileview.y #0018 ADD2 =Screen.y - #00 =i - $bytes - ~tileview.x #0088 ADD2 =Screen.x - ~tileview.addr #00 ~i ADD2 PEK2 #22 ,draw-byte JSR2 - ( incr ) ~i #01 ADD =i - ( incr ) ~Screen.y 8+ =Screen.y - ~i #08 LTH ,$bytes JNZ2 + .tileview/y PEK2 #0018 ADD2 .Screen/y DEO2 + #00 .i POK + &bytes + .tileview/x PEK2 #0088 ADD2 .Screen/x DEO2 + .tileview/addr PEK2 #00 .i PEK ADD2 GET #22 ;draw-byte JSR2 + ( incr ) .i PEK #01 ADD .i POK + ( incr ) .Screen/y DEI2 8+ .Screen/y DEO2 + .i PEK #08 LTH ;&bytes JNZ2 ( operations ) - ~Screen.y 8+ =Screen.y - ,movedown_icn =Screen.addr - #21 =Screen.color - ~Screen.x 8- =Screen.x - ,moveup_icn =Screen.addr - #21 =Screen.color + .Screen/y DEI2 8+ .Screen/y DEO2 + ;movedown_icn .Screen/addr DEO2 + #21 .Screen/color DEO + .Screen/x DEI2 8- .Screen/x DEO2 + ;moveup_icn .Screen/addr DEO2 + #21 .Screen/color DEO ( draw tiles 2x2 ) - ~tileview.y =Screen.y - #00 =pt.x #00 =pt.y ~tileview.addr =Screen.addr - - $tiles-ver - #00 =pt.x - ~tileview.x #0088 ADD2 =Screen.x - $tiles-hor - ( draw ) #23 =Screen.color - ( incr ) ~Screen.x 8+ =Screen.x - ( incr ) ~Screen.addr 8+ =Screen.addr - ( incr ) ~pt.x #01 ADD =pt.x - ~pt.x #02 LTH ,$tiles-hor JNZ2 - ( incr ) ~pt.y #01 ADD =pt.y - ( incr ) ~Screen.y 8+ =Screen.y - ~pt.y #02 LTH ,$tiles-ver JNZ2 + .tileview/y PEK2 .Screen/y DEO2 + #00 .pt/x POK #00 .pt/y POK .tileview/addr PEK2 .Screen/addr DEO2 + + &tiles-ver + #00 .pt/x POK + .tileview/x PEK2 #0088 ADD2 .Screen/x DEO2 + &tiles-hor + ( draw ) #23 .Screen/color DEO + ( incr ) .Screen/x DEI2 8+ .Screen/x DEO2 + ( incr ) .Screen/addr DEI2 8+ .Screen/addr DEO2 + ( incr ) .pt/x PEK #01 ADD .pt/x POK + .pt/x PEK #02 LTH ;&tiles-hor JNZ2 + ( incr ) .pt/y PEK #01 ADD .pt/y POK + ( incr ) .Screen/y DEI2 8+ .Screen/y DEO2 + .pt/y PEK #02 LTH ;&tiles-ver JNZ2 RTN @draw-colorview ( -- ) - ~colorview.y1 #18 ADD =Screen.y - ~colorview.x1 #08 ADD =Screen.x - ~System.r ,draw-color-code JSR2 - ~colorview.y1 #18 ADD =Screen.y - ~colorview.x1 #10 ADD =Screen.x - ~System.g ,draw-color-code JSR2 - ~colorview.y1 #18 ADD =Screen.y - ~colorview.x1 #18 ADD =Screen.x - ~System.b ,draw-color-code JSR2 - - ~colorview.x1 =Screen.x - ,circle_icns =Screen.addr + .colorview/y1 PEK2 #18 ADD .Screen/y DEO2 + .colorview/x1 PEK2 #08 ADD .Screen/x DEO2 + .System/r DEI2 ;draw-color-code JSR2 + .colorview/y1 PEK2 #18 ADD .Screen/y DEO2 + .colorview/x1 PEK2 #10 ADD .Screen/x DEO2 + .System/g DEI2 ;draw-color-code JSR2 + .colorview/y1 PEK2 #18 ADD .Screen/y DEO2 + .colorview/x1 PEK2 #18 ADD .Screen/x DEO2 + .System/b DEI2 ;draw-color-code JSR2 + + .colorview/x1 PEK2 .Screen/x DEO2 + ;circle_icns .Screen/addr DEO2 #00 #04 - $loop - OVR ~settings.brush EQU #00 SWP #0008 MUL2 ,circle_icns ADD2 =Screen.addr - OVR ~colorview.y1 ROT #00 SWP #0008 MUL2 ADD2 =Screen.y - OVR #20 ADD =Screen.color + &loop + OVR .settings/brush PEK EQU #00 SWP #0008 MUL2 ;circle_icns ADD2 .Screen/addr DEO2 + OVR .colorview/y1 PEK2 ROT #00 SWP #0008 MUL2 ADD2 .Screen/y DEO2 + OVR #20 ADD .Screen/color DEO SWP #01 ADD SWP - DUP2 LTH ^$loop JNZ + DUP2 LTH ,&loop JNZ POP2 RTN @draw-color-code ( color* -- ) - DUP ,font_hex ROT #0f AND #08 MUL #00 SWP ADD2 =Screen.addr - ( draw ) #22 =Screen.color - ~colorview.y1 #10 ADD =Screen.y - ,font_hex ROT #04 SFT #08 MUL #00 SWP ADD2 =Screen.addr - ( draw ) #22 =Screen.color - ~colorview.y1 #08 ADD =Screen.y - DUP ,font_hex ROT #0f AND #08 MUL #00 SWP ADD2 =Screen.addr - ( draw ) #22 =Screen.color - ~colorview.y1 =Screen.y - ,font_hex ROT #04 SFT #08 MUL #00 SWP ADD2 =Screen.addr - ( draw ) #22 =Screen.color + DUP ;font_hex ROT #0f AND #08 MUL #00 SWP ADD2 .Screen/addr DEO2 + ( draw ) #22 .Screen/color DEO + .colorview/y1 PEK2 #10 ADD .Screen/y DEO2 + ;font_hex ROT #04 SFT #08 MUL #00 SWP ADD2 .Screen/addr DEO2 + ( draw ) #22 .Screen/color DEO + .colorview/y1 PEK2 #08 ADD .Screen/y DEO2 + DUP ;font_hex ROT #0f AND #08 MUL #00 SWP ADD2 .Screen/addr DEO2 + ( draw ) #22 .Screen/color DEO + .colorview/y1 PEK2 .Screen/y DEO2 + ;font_hex ROT #04 SFT #08 MUL #00 SWP ADD2 .Screen/addr DEO2 + ( draw ) #22 .Screen/color DEO RTN @draw-cursor ( clear last cursor ) - ~mouse.x =Screen.x - ~mouse.y =Screen.y - ,blank_icn =Screen.addr - #30 =Screen.color + .mouse/x PEK2 .Screen/x DEO2 + .mouse/y PEK2 .Screen/y DEO2 + ;blank_icn .Screen/addr DEO2 + #30 .Screen/color DEO ( record mouse positions ) - ~Mouse.x =mouse.x - ~Mouse.y =mouse.y + .Mouse/x DEI2 .mouse/x POK2 + .Mouse/y DEI2 .mouse/y POK2 ( draw new cursor ) - ~mouse.x =Screen.x - ~mouse.y =Screen.y - ,tool_selector #00 ~bankview.mode #08 MUL ADD2 =Screen.addr - #32 ~Mouse.state #00 NEQ ADD =Screen.color + .mouse/x PEK2 .Screen/x DEO2 + .mouse/y PEK2 .Screen/y DEO2 + ;tool_selector #00 .bankview/mode PEK #08 MUL ADD2 .Screen/addr DEO2 + #32 .Mouse/state DEI #00 NEQ ADD .Screen/color DEO RTN @draw-byte ( byte color -- ) - =color STH - ,font_hex #00 DUPr STHr #f0 AND #04 SFT #08 MUL ADD2 =Screen.addr - ( draw ) ~color =Screen.color - ~Screen.x 8+ =Screen.x - ,font_hex #00 STHr #0f AND #08 MUL ADD2 =Screen.addr - ( draw ) ~color =Screen.color + .color POK STH + ;font_hex #00 DUPr STHr #f0 AND #04 SFT #08 MUL ADD2 .Screen/addr DEO2 + ( draw ) .color PEK .Screen/color DEO + .Screen/x DEI2 8+ .Screen/x DEO2 + ;font_hex #00 STHr #0f AND #08 MUL ADD2 .Screen/addr DEO2 + ( draw ) .color PEK .Screen/color DEO RTN @draw-short ( short -- ) - =addr - ,font_hex #00 ,addr PEK2 #f0 AND #04 SFT #08 MUL ADD2 =Screen.addr - ( draw ) #22 =Screen.color - ~Screen.x 8+ =Screen.x - ,font_hex #00 ,addr PEK2 #0f AND #08 MUL ADD2 =Screen.addr - ( draw ) #22 =Screen.color - ~Screen.x 8+ =Screen.x - ,font_hex #00 ,addr ++ PEK2 #f0 AND #04 SFT #08 MUL ADD2 =Screen.addr - ( draw ) #22 =Screen.color - ~Screen.x 8+ =Screen.x - ,font_hex #00 ,addr ++ PEK2 #0f AND #08 MUL ADD2 =Screen.addr - ( draw ) #22 =Screen.color + .addr POK2 + ;font_hex #00 ;addr GET #f0 AND #04 SFT #08 MUL ADD2 .Screen/addr DEO2 + ( draw ) #22 .Screen/color DEO + .Screen/x DEI2 8+ .Screen/x DEO2 + ;font_hex #00 ;addr GET #0f AND #08 MUL ADD2 .Screen/addr DEO2 + ( draw ) #22 .Screen/color DEO + .Screen/x DEI2 8+ .Screen/x DEO2 + ;font_hex #00 ;addr ++ GET #f0 AND #04 SFT #08 MUL ADD2 .Screen/addr DEO2 + ( draw ) #22 .Screen/color DEO + .Screen/x DEI2 8+ .Screen/x DEO2 + ;font_hex #00 ;addr ++ GET #0f AND #08 MUL ADD2 .Screen/addr DEO2 + ( draw ) #22 .Screen/color DEO RTN @@ -696,27 +699,27 @@ RTN @line-rect ( x1 y1 x2 y2 color -- ) - ( load ) =color DUP2 STH2 =rect.y2 =rect.x2 DUP2 STH2 =rect.y1 =rect.x1 + ( load ) .color POK DUP2 STH2 .rect/y2 POK2 .rect/x2 POK2 DUP2 STH2 .rect/y1 POK2 .rect/x1 POK2 STH2r STH2r - $ver - ( save ) OVR2 =Screen.y - ( draw ) ~rect.x1 =Screen.x ~color DUP =Screen.color - ( draw ) ~rect.x2 =Screen.x =Screen.color + &ver + ( save ) OVR2 .Screen/y DEO2 + ( draw ) .rect/x1 PEK2 .Screen/x DEO2 .color PEK DUP .Screen/color DEO + ( draw ) .rect/x2 PEK2 .Screen/x DEO2 .Screen/color DEO ( incr ) SWP2 ++ SWP2 - OVR2 OVR2 LTS2 ^$ver JNZ + OVR2 OVR2 LTS2 ,&ver JNZ POP2 POP2 - ~rect.x1 ~rect.x2 - $hor - ( save ) OVR2 =Screen.x - ( draw ) ~rect.y1 =Screen.y ~color DUP =Screen.color - ( draw ) ~rect.y2 =Screen.y =Screen.color + .rect/x1 PEK2 .rect/x2 PEK2 + &hor + ( save ) OVR2 .Screen/x DEO2 + ( draw ) .rect/y1 PEK2 .Screen/y DEO2 .color PEK DUP .Screen/color DEO + ( draw ) .rect/y2 PEK2 .Screen/y DEO2 .Screen/color DEO ( incr ) SWP2 ++ SWP2 - OVR2 OVR2 ++ LTS2 ^$hor JNZ + OVR2 OVR2 ++ LTS2 ,&hor JNZ POP2 POP2 RTN -@circle_icns +@circle_icns [ 0038 7cfe fefe 7c38 ] ( full ) [ 0038 4482 8282 4438 ] ( line ) @eye_icns @@ -735,21 +738,21 @@ RTN 00fe 8282 fe82 82fe 00fe 9292 fe92 92fe ] -@filepath1 [ projects/fonts/specter8.bit 00 ] -@filepath2 [ projects/pictures/cibo.bit 00 ] -@filepath3 [ projects/pictures/zerotwo10x10.chr 00 ] -@filepath4 [ projects/fonts/katahira8.bit 00 ] -@filepath5 [ projects/pictures/ako10x10.chr 00 ] -@filepath6 [ projects/pictures/cyr4x4.chr 00 ] - -@font_hex ( 0-F ) +@filepath1 [ "projects/fonts/specter8.bit 00 ] +@filepath2 [ "projects/pictures/cibo.bit 00 ] +@filepath3 [ "projects/pictures/zerotwo10x10.chr 00 ] +@filepath4 [ "projects/fonts/katahira8.bit 00 ] +@filepath5 [ "projects/pictures/ako10x10.chr 00 ] +@filepath6 [ "projects/pictures/cyr4x4.chr 00 ] + +@font_hex ( 0-F ) [ 007c 8282 8282 827c 0030 1010 1010 1010 007c 8202 7c80 80fe 007c 8202 1c02 827c 000c 1424 4484 fe04 00fe 8080 7c02 827c 007c 8280 fc82 827c 007c 8202 1e02 0202 007c 8282 7c82 827c 007c 8282 7e02 827c - 007c 8202 7e82 827e 00fc 8282 fc82 82fc - 007c 8280 8080 827c 00fc 8282 8282 82fc + 007c 8202 7e82 827e 00fc 8282 fc82 82fc + 007c 8280 8080 827c 00fc 8282 8282 82fc 007c 8280 f080 827c 007c 8280 f080 8080 ] diff --git a/projects/software/noodle.usm b/projects/software/noodle.usm @@ -1,4 +1,4 @@ -( +( app/noodle : illustration program right-click - erase @@ -23,525 +23,527 @@ %2/ { #0001 SFT2 } %8/ { #0003 SFT2 } %8* { #0030 SFT2 } %8+ { #0008 ADD2 } -%FILESIZE { ~canvas.w ~canvas.h MUL2 #0008 MUL2 } +%FILESIZE { .canvas/w PEK2 .canvas/h PEK2 MUL2 #0008 MUL2 } -( variables ) +( devices ) -;cursor { x 2 y 2 x0 2 y0 2 dx 2 dy 2 } -;brush { tool 1 size 1 patt 1 drag 1 last 1 oper 2 } -;zoom { active 1 x 2 y 2 } -;toolpane { x1 2 y1 2 x2 2 y2 2 } -;pattpane { x1 2 y1 2 x2 2 y2 2 } -;sizepane { x1 2 y1 2 x2 2 y2 2 } -;viewpane { x1 2 y1 2 x2 2 y2 2 } -;canvas { x1 2 y1 2 x2 2 y2 2 w 2 h 2 } -;rect { x1 2 y1 2 x2 2 y2 2 } -;line { x1 2 y1 2 x2 2 y2 2 sx 2 sy 2 dx 2 dy 2 e1 2 e2 2 } -;origin { x1 2 y1 2 x2 2 y2 2 } -;color { byte 1 } -;pt0 { x 2 y 2 } -;pt1 { x 2 y 2 } -;pt2 { x 2 y 2 } ( paint-rect ) -;px { x 1 y 1 } -;document { state 1 edit 1 presentation 1 } -;path { length 1 name 20 } -;timer { byte 1 } -;theme { r0 2 g0 2 b0 2 r1 2 g1 2 b1 2 } +|00 @System [ &vector $2 &pad $6 &r $2 &g $2 &b $2 ] +|10 @Console [ &vector $2 &pad $6 &char $1 &byte $1 &short $2 &string $2 ] +|20 @Screen [ &vector $2 &width $2 &height $2 &pad $2 &x $2 &y $2 &addr $2 &color $1 ] +|40 @Controller [ &vector $2 &button $1 &key $1 ] +|60 @Mouse [ &vector $2 &x $2 &y $2 &state $1 &chord $1 ] +|70 @File [ &vector $2 &success $2 &offset $2 &pad $2 &name $2 &length $2 &load $2 &save $2 ] -( devices ) +( variables ) -|0100 ;System { vector 2 pad 6 r 2 g 2 b 2 } -|0110 ;Console { vector 2 pad 6 char 1 byte 1 short 2 string 2 } -|0120 ;Screen { vector 2 width 2 height 2 pad 2 x 2 y 2 addr 2 color 1 } -|0140 ;Controller { vector 2 button 1 key 1 } -|0160 ;Mouse { vector 2 x 2 y 2 state 1 chord 1 } -|0170 ;File { vector 2 success 2 offset 2 pad 2 name 2 length 2 load 2 save 2 } +|0000 + +@cursor [ &x $2 &y $2 &x0 $2 &y0 $2 &dx $2 &dy $2 ] +@brush [ &tool $1 &size $1 &patt $1 &drag $1 &last $1 &oper $2 ] +@zoom [ &active $1 &x $2 &y $2 ] +@toolpane [ &x1 $2 &y1 $2 &x2 $2 &y2 $2 ] +@pattpane [ &x1 $2 &y1 $2 &x2 $2 &y2 $2 ] +@sizepane [ &x1 $2 &y1 $2 &x2 $2 &y2 $2 ] +@viewpane [ &x1 $2 &y1 $2 &x2 $2 &y2 $2 ] +@canvas [ &x1 $2 &y1 $2 &x2 $2 &y2 $2 &w $2 &h $2 ] +@rect [ &x1 $2 &y1 $2 &x2 $2 &y2 $2 ] +@line [ &x1 $2 &y1 $2 &x2 $2 &y2 $2 &sx $2 &sy $2 &dx $2 &dy $2 &e1 $2 &e2 $2 ] +@origin [ &x1 $2 &y1 $2 &x2 $2 &y2 $2 ] +@color [ &byte $1 ] +@pt0 [ &x $2 &y $2 ] +@pt1 [ &x $2 &y $2 ] +@pt2 [ &x $2 &y $2 ] ( paint-rect ) +@px [ &x $1 &y $1 ] +@document [ &state $1 &edit $1 &presentation $1 ] +@path [ &length $1 &name $20 ] +@timer [ &byte $1 ] +@theme [ &r0 $2 &g0 $2 &b0 $2 &r1 $2 &g1 $2 &b1 $2 ] ( program ) -|0200 +|0100 - ( theme ) - #e0fa =theme.r0 #30fa =theme.g0 #30fa =theme.b0 ( normal mode ) - #00fe =theme.r1 #00f3 =theme.g1 #00f3 =theme.b1 ( presentation mode ) - ( vectors ) ,on-screen =Screen.vector - ( vectors ) ,on-button =Controller.vector - ( vectors ) ,on-mouse =Mouse.vector + ( theme ) + #e0fa .theme/r0 POK2 #30fa .theme/g0 POK2 #30fa .theme/b0 POK2 ( normal mode ) + #00fe .theme/r1 POK2 #00f3 .theme/g1 POK2 #00f3 .theme/b1 POK2 ( presentation mode ) + ( vectors ) ;on-screen .Screen/vector DEO2 + ( vectors ) ;on-button .Controller/vector DEO2 + ( vectors ) ;on-mouse .Mouse/vector DEO2 - ~theme.r0 =System.r ~theme.g0 =System.g ~theme.b0 =System.b + .theme/r0 PEK2 .System/r DEO2 .theme/g0 PEK2 .System/g DEO2 .theme/b0 PEK2 .System/b DEO2 ( default canvas ) - #002a =canvas.w #0018 =canvas.h + #002a .canvas/w POK2 #0018 .canvas/h POK2 ( default brush ) - #04 =brush.size #00 =brush.patt #00 =brush.tool + #04 .brush/size POK #00 .brush/patt POK #00 .brush/tool POK ( load file ) - ,untitled_txt ,path.name ,strcpy JSR2 + ;untitled_txt ;path/name ;strcpy JSR2 ( setup panes ) - #0010 =toolpane.x1 #0010 =toolpane.y1 ~toolpane.x1 #0028 ADD2 =toolpane.x2 ~toolpane.y1 #0008 ADD2 =toolpane.y2 - #0040 =sizepane.x1 #0010 =sizepane.y1 ~sizepane.x1 #0040 ADD2 =sizepane.x2 ~sizepane.y1 #0008 ADD2 =sizepane.y2 - ~Screen.width #0078 SUB2 =viewpane.x1 #0010 =viewpane.y1 ~viewpane.x1 #0020 ADD2 =viewpane.x2 ~viewpane.y1 #0008 ADD2 =viewpane.y2 - ~Screen.width #0050 SUB2 =pattpane.x1 #0010 =pattpane.y1 ~pattpane.x1 #0040 ADD2 =pattpane.x2 ~pattpane.y1 #0008 ADD2 =pattpane.y2 + #0010 .toolpane/x1 POK2 #0010 .toolpane/y1 POK2 .toolpane/x1 PEK2 #0028 ADD2 .toolpane/x2 POK2 .toolpane/y1 PEK2 #0008 ADD2 .toolpane/y2 POK2 + #0040 .sizepane/x1 POK2 #0010 .sizepane/y1 POK2 .sizepane/x1 PEK2 #0040 ADD2 .sizepane/x2 POK2 .sizepane/y1 PEK2 #0008 ADD2 .sizepane/y2 POK2 + .Screen/width DEI2 #0078 SUB2 .viewpane/x1 POK2 #0010 .viewpane/y1 POK2 .viewpane/x1 PEK2 #0020 ADD2 .viewpane/x2 POK2 .viewpane/y1 PEK2 #0008 ADD2 .viewpane/y2 POK2 + .Screen/width DEI2 #0050 SUB2 .pattpane/x1 POK2 #0010 .pattpane/y1 POK2 .pattpane/x1 PEK2 #0040 ADD2 .pattpane/x2 POK2 .pattpane/y1 PEK2 #0008 ADD2 .pattpane/y2 POK2 ( ready. ) - ,center JSR2 - ,clear JSR2 + ;center JSR2 + ;clear JSR2 ( load default file ) - ,path.name ,load-file JSR2 + ;path/name ;load-file JSR2 BRK @on-screen ( -> ) - ~document.edit #01 NEQ ^$no-edit JNZ - #0008 =Screen.x - ~Screen.height #0010 SUB2 =Screen.y - ,path.name #01 ~timer #04 DIV #03 AND #03 MUL ADD ,draw-label JSR2 - $clear - #20 =Screen.color - ~Screen.x 8+ DUP2 =Screen.x - ~Screen.width LTH2 ^$clear JNZ - ( blink ) ~timer #01 ADD =timer - $no-edit + .document/edit PEK #01 NEQ ,&no-edit JNZ + #0008 .Screen/x DEO2 + .Screen/height DEI2 #0010 SUB2 .Screen/y DEO2 + ;path/name #01 .timer PEK #04 DIV #03 AND #03 MUL ADD ;draw-label JSR2 + &clear + #20 .Screen/color DEO + .Screen/x DEI2 8+ DUP2 .Screen/x DEO2 + .Screen/width DEI2 LTH2 ,&clear JNZ + ( blink ) .timer PEK #01 ADD .timer POK + &no-edit BRK @on-mouse ( -> ) - ,draw-cursor JSR2 + ;draw-cursor JSR2 ( release drag ) - ~Mouse.state #00 EQU ~brush.drag #01 EQU #0101 NEQ2 ^$no-release JNZ - ~origin.x1 #0002 SUB2 ~origin.y1 #0002 SUB2 ~origin.x2 #0002 ADD2 ~origin.y2 #0002 ADD2 #00 ,fill-rect JSR2 - ~canvas.x1 -- ~canvas.y1 -- ~canvas.x2 ~canvas.y2 #10 ,line-rect JSR2 - ,draw-background JSR2 - ,fit-canvas JSR2 - ,draw-foreground JSR2 - #00 =brush.drag - $no-release + .Mouse/state DEI #00 EQU .brush/drag PEK #01 EQU #0101 NEQ2 ,&no-release JNZ + .origin/x1 PEK2 #0002 SUB2 .origin/y1 PEK2 #0002 SUB2 .origin/x2 PEK2 #0002 ADD2 .origin/y2 PEK2 #0002 ADD2 #00 ;fill-rect JSR2 + .canvas/x1 PEK2 -- .canvas/y1 PEK2 -- .canvas/x2 PEK2 .canvas/y2 PEK2 #10 ;line-rect JSR2 + ;draw-background JSR2 + ;fit-canvas JSR2 + ;draw-foreground JSR2 + #00 .brush/drag POK + &no-release ( operations on release line/rect ) - ~Mouse.state ~brush.last EQU ,$no-touch-change JNZ2 - ~Mouse.x CLN2r ~canvas.x1 GTS2 STH2r ~canvas.x2 LTS2 #0101 NEQ2 ,$no-touch-change JNZ2 - ~Mouse.y CLN2r ~canvas.y1 GTS2 STH2r ~canvas.y2 LTS2 #0101 NEQ2 ,$no-touch-change JNZ2 - ~Mouse.state #00 EQU ^$no-touch-ondown JNZ + .Mouse/state DEI .brush/last PEK EQU ;&no-touch-change JNZ2 + .Mouse/x DEI2 CLN2r .canvas/x1 PEK2 GTS2 STH2r .canvas/x2 PEK2 LTS2 #0101 NEQ2 ;&no-touch-change JNZ2 + .Mouse/y DEI2 CLN2r .canvas/y1 PEK2 GTS2 STH2r .canvas/y2 PEK2 LTS2 #0101 NEQ2 ;&no-touch-change JNZ2 + .Mouse/state DEI #00 EQU ,&no-touch-ondown JNZ ( on down ) - ~Mouse.x =cursor.dx - ~Mouse.y =cursor.dy - $no-touch-ondown - ~Mouse.state #00 NEQ ^$no-touch-onup JNZ + .Mouse/x DEI2 .cursor/dx POK2 + .Mouse/y DEI2 .cursor/dy POK2 + &no-touch-ondown + .Mouse/state DEI #00 NEQ ,&no-touch-onup JNZ ( on up ) - ~brush.tool #02 NEQ ^$no-touch-line JNZ - ~cursor.dx ~canvas.x1 SUB2 ~cursor.dy ~canvas.y1 SUB2 ~Mouse.x ~canvas.x1 SUB2 ~Mouse.y ~canvas.y1 SUB2 ,paint-line JSR2 - ,$touch-end JMP2 - $no-touch-line - ~brush.tool #03 NEQ ^$no-touch-rect JNZ - ~cursor.dx ~canvas.x1 SUB2 ~cursor.dy ~canvas.y1 SUB2 ~Mouse.x ~canvas.x1 SUB2 ~Mouse.y ~canvas.y1 SUB2 ,paint-rect JSR2 - ,$touch-end JMP2 - $no-touch-rect - $no-touch-onup - $no-touch-change - - ~Mouse.state #00 EQU ,$no-touch JNZ2 + .brush/tool PEK #02 NEQ ,&no-touch-line JNZ + .cursor/dx PEK2 .canvas/x1 PEK2 SUB2 .cursor/dy PEK2 .canvas/y1 PEK2 SUB2 .Mouse/x DEI2 .canvas/x1 PEK2 SUB2 .Mouse/y DEI2 .canvas/y1 PEK2 SUB2 ;paint-line JSR2 + ;&touch-end JMP2 + &no-touch-line + .brush/tool PEK #03 NEQ ,&no-touch-rect JNZ + .cursor/dx PEK2 .canvas/x1 PEK2 SUB2 .cursor/dy PEK2 .canvas/y1 PEK2 SUB2 .Mouse/x DEI2 .canvas/x1 PEK2 SUB2 .Mouse/y DEI2 .canvas/y1 PEK2 SUB2 ;paint-rect JSR2 + ;&touch-end JMP2 + &no-touch-rect + &no-touch-onup + &no-touch-change + + .Mouse/state DEI #00 EQU ;&no-touch JNZ2 ( drag ) - ~Controller.button #02 NEQ ,$no-drag JNZ2 - ~brush.drag #00 NEQ ^$no-drag-start JNZ - ~canvas.x1 =origin.x1 - ~canvas.y1 =origin.y1 - ~canvas.x2 =origin.x2 - ~canvas.y2 =origin.y2 - $no-drag-start - ~canvas.x1 -- ~canvas.y1 -- ~canvas.x2 ~canvas.y2 #10 ,line-rect JSR2 - ~canvas.x1 ~Mouse.x ~cursor.x0 SUB2 ADD2 =canvas.x1 - ~canvas.y1 ~Mouse.y ~cursor.y0 SUB2 ADD2 =canvas.y1 - ~canvas.w 8* ~canvas.x1 ADD2 =canvas.x2 - ~canvas.h 8* ~canvas.y1 ADD2 =canvas.y2 - ~canvas.x1 -- ~canvas.y1 -- ~canvas.x2 ~canvas.y2 #13 ,line-rect JSR2 - #01 =brush.drag - ,$touch-end JMP2 - $no-drag + .Controller/button DEI #02 NEQ ;&no-drag JNZ2 + .brush/drag PEK #00 NEQ ,&no-drag-start JNZ + .canvas/x1 PEK2 .origin/x1 POK2 + .canvas/y1 PEK2 .origin/y1 POK2 + .canvas/x2 PEK2 .origin/x2 POK2 + .canvas/y2 PEK2 .origin/y2 POK2 + &no-drag-start + .canvas/x1 PEK2 -- .canvas/y1 PEK2 -- .canvas/x2 PEK2 .canvas/y2 PEK2 #10 ;line-rect JSR2 + .canvas/x1 PEK2 .Mouse/x DEI2 .cursor/x0 PEK2 SUB2 ADD2 .canvas/x1 POK2 + .canvas/y1 PEK2 .Mouse/y DEI2 .cursor/y0 PEK2 SUB2 ADD2 .canvas/y1 POK2 + .canvas/w PEK2 8* .canvas/x1 PEK2 ADD2 .canvas/x2 POK2 + .canvas/h PEK2 8* .canvas/y1 PEK2 ADD2 .canvas/y2 POK2 + .canvas/x1 PEK2 -- .canvas/y1 PEK2 -- .canvas/x2 PEK2 .canvas/y2 PEK2 #13 ;line-rect JSR2 + #01 .brush/drag POK + ;&touch-end JMP2 + &no-drag ( in sizepane ) - ~Mouse.x CLN2r ~sizepane.x1 GTH2 STH2r ~sizepane.x2 LTH2 #0101 NEQ2 ^$no-touch-sizepane JNZ - ~Mouse.y CLN2r ~sizepane.y1 GTH2 STH2r ~sizepane.y2 LTH2 #0101 NEQ2 ^$no-touch-sizepane JNZ - ( release ) #00 =Mouse.state - #01 =brush.tool - ~Mouse.x ~sizepane.x1 SUB2 8/ SWP POP =brush.size - ( draw ) ,draw-sizepane JSR2 - ( draw ) ,draw-toolpane JSR2 - ,$touch-end JMP2 - $no-touch-sizepane + .Mouse/x DEI2 CLN2r .sizepane/x1 PEK2 GTH2 STH2r .sizepane/x2 PEK2 LTH2 #0101 NEQ2 ,&no-touch-sizepane JNZ + .Mouse/y DEI2 CLN2r .sizepane/y1 PEK2 GTH2 STH2r .sizepane/y2 PEK2 LTH2 #0101 NEQ2 ,&no-touch-sizepane JNZ + ( release ) #00 .Mouse/state DEO + #01 .brush/tool POK + .Mouse/x DEI2 .sizepane/x1 PEK2 SUB2 8/ SWP POP .brush/size POK + ( draw ) ;draw-sizepane JSR2 + ( draw ) ;draw-toolpane JSR2 + ;&touch-end JMP2 + &no-touch-sizepane ( in pattpane ) - ~Mouse.x CLN2r ~pattpane.x1 GTH2 STH2r ~pattpane.x2 LTH2 #0101 NEQ2 ^$no-touch-pattpane JNZ - ~Mouse.y CLN2r ~pattpane.y1 GTH2 STH2r ~pattpane.y2 LTH2 #0101 NEQ2 ^$no-touch-pattpane JNZ - ( release ) #00 =Mouse.state - ~Mouse.x ~pattpane.x1 SUB2 8/ SWP POP =brush.patt - ( draw ) ,draw-pattpane JSR2 - ,$touch-end JMP2 - $no-touch-pattpane + .Mouse/x DEI2 CLN2r .pattpane/x1 PEK2 GTH2 STH2r .pattpane/x2 PEK2 LTH2 #0101 NEQ2 ,&no-touch-pattpane JNZ + .Mouse/y DEI2 CLN2r .pattpane/y1 PEK2 GTH2 STH2r .pattpane/y2 PEK2 LTH2 #0101 NEQ2 ,&no-touch-pattpane JNZ + ( release ) #00 .Mouse/state DEO + .Mouse/x DEI2 .pattpane/x1 PEK2 SUB2 8/ SWP POP .brush/patt POK + ( draw ) ;draw-pattpane JSR2 + ;&touch-end JMP2 + &no-touch-pattpane ( in toolpane ) - ~Mouse.x CLN2r ~toolpane.x1 GTH2 STH2r ~toolpane.x2 LTH2 #0101 NEQ2 ^$no-touch-toolpane JNZ - ~Mouse.y CLN2r ~toolpane.y1 GTH2 STH2r ~toolpane.y2 LTH2 #0101 NEQ2 ^$no-touch-toolpane JNZ - ( release ) #00 =Mouse.state - ~Mouse.x ~toolpane.x1 SUB2 8/ SWP POP =brush.tool - ( draw ) ,draw-toolpane JSR2 - ,$touch-end JMP2 - $no-touch-toolpane + .Mouse/x DEI2 CLN2r .toolpane/x1 PEK2 GTH2 STH2r .toolpane/x2 PEK2 LTH2 #0101 NEQ2 ,&no-touch-toolpane JNZ + .Mouse/y DEI2 CLN2r .toolpane/y1 PEK2 GTH2 STH2r .toolpane/y2 PEK2 LTH2 #0101 NEQ2 ,&no-touch-toolpane JNZ + ( release ) #00 .Mouse/state DEO + .Mouse/x DEI2 .toolpane/x1 PEK2 SUB2 8/ SWP POP .brush/tool POK + ( draw ) ;draw-toolpane JSR2 + ;&touch-end JMP2 + &no-touch-toolpane ( in viewpane ) - ~Mouse.x CLN2r ~viewpane.x1 GTH2 STH2r ~viewpane.x2 LTH2 #0101 NEQ2 ,$no-touch-viewpane JNZ2 - ~Mouse.y CLN2r ~viewpane.y1 GTH2 STH2r ~viewpane.y2 LTH2 #0101 NEQ2 ,$no-touch-viewpane JNZ2 - ( release ) #00 =Mouse.state - ( clear ) ~canvas.x1 #0002 SUB2 ~canvas.y1 #0002 SUB2 ~canvas.x2 #0002 ADD2 ~canvas.y2 #0002 ADD2 #00 ,fill-rect JSR2 - ,draw-background JSR2 - ~Mouse.x ~viewpane.x1 SUB2 8/ SWP POP - DUP #00 NEQ ^$no-incwidth JNZ - ~canvas.w ++ =canvas.w - $no-incwidth - DUP #01 NEQ ^$no-decwidth JNZ - ~canvas.w -- =canvas.w - $no-decwidth - DUP #02 NEQ ^$no-incheight JNZ - ~canvas.h ++ =canvas.h - $no-incheight - DUP #03 NEQ ^$no-decheight JNZ - ~canvas.h -- =canvas.h - $no-decheight + .Mouse/x DEI2 CLN2r .viewpane/x1 PEK2 GTH2 STH2r .viewpane/x2 PEK2 LTH2 #0101 NEQ2 ;&no-touch-viewpane JNZ2 + .Mouse/y DEI2 CLN2r .viewpane/y1 PEK2 GTH2 STH2r .viewpane/y2 PEK2 LTH2 #0101 NEQ2 ;&no-touch-viewpane JNZ2 + ( release ) #00 .Mouse/state DEO + ( clear ) .canvas/x1 PEK2 #0002 SUB2 .canvas/y1 PEK2 #0002 SUB2 .canvas/x2 PEK2 #0002 ADD2 .canvas/y2 PEK2 #0002 ADD2 #00 ;fill-rect JSR2 + ;draw-background JSR2 + .Mouse/x DEI2 .viewpane/x1 PEK2 SUB2 8/ SWP POP + DUP #00 NEQ ,&no-incwidth JNZ + .canvas/w PEK2 ++ .canvas/w POK2 + &no-incwidth + DUP #01 NEQ ,&no-decwidth JNZ + .canvas/w PEK2 -- .canvas/w POK2 + &no-decwidth + DUP #02 NEQ ,&no-incheight JNZ + .canvas/h PEK2 ++ .canvas/h POK2 + &no-incheight + DUP #03 NEQ ,&no-decheight JNZ + .canvas/h PEK2 -- .canvas/h POK2 + &no-decheight POP - ,fit-canvas JSR2 - ,redraw JSR2 - ,$touch-end JMP2 - $no-touch-viewpane + ;fit-canvas JSR2 + ;redraw JSR2 + ;&touch-end JMP2 + &no-touch-viewpane ( in canvas ) - ~Mouse.x CLN2r ~canvas.x1 GTS2 STH2r ~canvas.x2 LTS2 #0101 NEQ2 ,$no-touch-canvas JNZ2 - ~Mouse.y CLN2r ~canvas.y1 GTS2 STH2r ~canvas.y2 LTS2 #0101 NEQ2 ,$no-touch-canvas JNZ2 + .Mouse/x DEI2 CLN2r .canvas/x1 PEK2 GTS2 STH2r .canvas/x2 PEK2 LTS2 #0101 NEQ2 ;&no-touch-canvas JNZ2 + .Mouse/y DEI2 CLN2r .canvas/y1 PEK2 GTS2 STH2r .canvas/y2 PEK2 LTS2 #0101 NEQ2 ;&no-touch-canvas JNZ2 ( set cursor operation ) - ,add-pixel ~Mouse.state #01 EQU ,$no-oper JNZ2 POP2 ,remove-pixel $no-oper =brush.oper + ;add-pixel .Mouse/state DEI #01 EQU ;&no-oper JNZ2 POP2 ;remove-pixel &no-oper .brush/oper POK2 - ~brush.tool #00 NEQ ^$no-touch-pen JNZ - ~cursor.x0 ~canvas.x1 SUB2 ~cursor.y0 ~canvas.y1 SUB2 ~Mouse.x ~canvas.x1 SUB2 ~Mouse.y ~canvas.y1 SUB2 ,paint-line JSR2 - ,$touch-end JMP2 - $no-touch-pen + .brush/tool PEK #00 NEQ ,&no-touch-pen JNZ + .cursor/x0 PEK2 .canvas/x1 PEK2 SUB2 .cursor/y0 PEK2 .canvas/y1 PEK2 SUB2 .Mouse/x DEI2 .canvas/x1 PEK2 SUB2 .Mouse/y DEI2 .canvas/y1 PEK2 SUB2 ;paint-line JSR2 + ;&touch-end JMP2 + &no-touch-pen - ~brush.tool #01 NEQ ^$no-touch-brush JNZ - ~Mouse.x ~canvas.x1 SUB2 ~Mouse.y ~canvas.y1 SUB2 ,paint-brush JSR2 - ,$touch-end JMP2 - $no-touch-brush + .brush/tool PEK #01 NEQ ,&no-touch-brush JNZ + .Mouse/x DEI2 .canvas/x1 PEK2 SUB2 .Mouse/y DEI2 .canvas/y1 PEK2 SUB2 ;paint-brush JSR2 + ;&touch-end JMP2 + &no-touch-brush - ~brush.tool #04 NEQ ^$no-touch-zoom JNZ - ~zoom.active #00 EQU =zoom.active - ( release ) #00 =Mouse.state - ~Mouse.x ~canvas.x1 SUB2 ~canvas.w 2/ SUB2 =zoom.x - ~Mouse.y ~canvas.y1 SUB2 ~canvas.h 2/ SUB2 =zoom.y - ,redraw JSR2 - ,$touch-end JMP2 - $no-touch-zoom + .brush/tool PEK #04 NEQ ,&no-touch-zoom JNZ + .zoom/active PEK #00 EQU .zoom/active POK + ( release ) #00 .Mouse/state DEO + .Mouse/x DEI2 .canvas/x1 PEK2 SUB2 .canvas/w PEK2 2/ SUB2 .zoom/x POK2 + .Mouse/y DEI2 .canvas/y1 PEK2 SUB2 .canvas/h PEK2 2/ SUB2 .zoom/y POK2 + ;redraw JSR2 + ;&touch-end JMP2 + &no-touch-zoom - $no-touch-canvas + &no-touch-canvas ( background interface ) - ~Mouse.y STEP8 ~Screen.height #0010 SUB2 NEQ2 ^$no-touch-background JNZ - ~Mouse.x ~Screen.width #0028 SUB2 SUB2 8/ SWP POP - DUP #00 NEQ ^$no-eye-button JNZ - ,present JSR2 - ( release ) #00 =Mouse.state - $no-eye-button - DUP #01 NEQ ^$no-rename-button JNZ - ,rename JSR2 - #01 =document.edit - ( release ) #00 =Mouse.state - $no-rename-button - DUP #02 NEQ ^$no-load-button JNZ - ,path.name ,load-file JSR2 - ,draw-canvas JSR2 - ( release ) #00 =Mouse.state - $no-load-button - DUP #03 NEQ ^$no-save-button JNZ - ,path.name ,save-file JSR2 - ( release ) #00 =Mouse.state - $no-save-button + .Mouse/y DEI2 STEP8 .Screen/height DEI2 #0010 SUB2 NEQ2 ,&no-touch-background JNZ + .Mouse/x DEI2 .Screen/width DEI2 #0028 SUB2 SUB2 8/ SWP POP + DUP #00 NEQ ,&no-eye-button JNZ + ;present JSR2 + ( release ) #00 .Mouse/state DEO + &no-eye-button + DUP #01 NEQ ,&no-rename-button JNZ + ;rename JSR2 + #01 .document/edit POK + ( release ) #00 .Mouse/state DEO + &no-rename-button + DUP #02 NEQ ,&no-load-button JNZ + ;path/name ;load-file JSR2 + ;draw-canvas JSR2 + ( release ) #00 .Mouse/state DEO + &no-load-button + DUP #03 NEQ ,&no-save-button JNZ + ;path/name ;save-file JSR2 + ( release ) #00 .Mouse/state DEO + &no-save-button POP - $no-touch-background + &no-touch-background ( jump label ) - $touch-end + &touch-end - $no-touch + &no-touch - ~Mouse.x =cursor.x0 - ~Mouse.y =cursor.y0 - ~Mouse.state =brush.last + .Mouse/x DEI2 .cursor/x0 POK2 + .Mouse/y DEI2 .cursor/y0 POK2 + .Mouse/state DEI .brush/last POK BRK @on-button ( -> ) ( if in renaming mode ) - ~document.edit #01 NEQ ,$no-edit JNZ2 - ~Controller.key #00 EQU ,$no-edit JNZ2 + .document/edit PEK #01 NEQ ;&no-edit JNZ2 + .Controller/key DEI #00 EQU ;&no-edit JNZ2 ( enter ) - ~Controller.key #0d NEQ ^$no-edit-enter JNZ - #00 =document.edit - ,redraw JSR2 + .Controller/key DEI #0d NEQ ,&no-edit-enter JNZ + #00 .document/edit POK + ;redraw JSR2 BRK - $no-edit-enter + &no-edit-enter ( backspace ) - ~Controller.key #08 NEQ ^$no-edit-backspace JNZ - ~path.length #00 EQU ^$edit-end JNZ - ~path.length #01 SUB =path.length - #00 ,path.name #00 ~path.length ADD2 POK2 + .Controller/key DEI #08 NEQ ,&no-edit-backspace JNZ + .path/length PEK #00 EQU ,&edit-end JNZ + .path/length PEK #01 SUB .path/length POK + #00 ;path/name #00 .path/length PEK ADD2 PUT BRK - $no-edit-backspace + &no-edit-backspace ( default ) - ~path.length #1f EQU ^$edit-end JNZ - ~Controller.key ,path.name #00 ~path.length ADD2 POK2 - ~path.length #01 ADD =path.length - $edit-end - #00 ,path.name #00 ~path.length ADD2 POK2 + .path/length PEK #1f EQU ,&edit-end JNZ + .Controller/key DEI ;path/name #00 .path/length PEK ADD2 PUT + .path/length PEK #01 ADD .path/length POK + &edit-end + #00 ;path/name #00 .path/length PEK ADD2 PUT BRK - $no-edit + &no-edit ( control zoom ) - ~zoom.active #00 EQU ^$skip-zoom JNZ - ~Controller.button #f0 AND - DUP #04 SFT #01 AND #01 NEQ ^$no-up JNZ - ( move ) ~zoom.y -- =zoom.y $no-up - DUP #05 SFT #01 AND #01 NEQ ^$no-down JNZ - ( move ) ~zoom.y ++ =zoom.y $no-down - DUP #06 SFT #01 AND #01 NEQ ^$no-left JNZ - ( move ) ~zoom.x -- =zoom.x $no-left - DUP #07 SFT #01 AND #01 NEQ ^$no-right JNZ - ( move ) ~zoom.x ++ =zoom.x $no-right - #00 EQU #04 JNZ ,draw-canvas JSR2 - $skip-zoom - - ~Controller.key - DUP #20 NEQ ^$no-space JNZ - ( toggle zoom ) ~zoom.active #00 EQU =zoom.active ,redraw JSR2 $no-space - DUP #08 NEQ ^$no-backspace JNZ - ( erase ) ,clear JSR2 $no-backspace - DUP #71 NEQ ^$no-qkey JNZ - ( tool0 ) #00 =brush.tool ,draw-toolpane JSR2 $no-qkey - DUP #77 NEQ ^$no-wkey JNZ - ( tool0 ) #01 =brush.tool ,draw-toolpane JSR2 $no-wkey - DUP #65 NEQ ^$no-ekey JNZ - ( tool0 ) #02 =brush.tool ,draw-toolpane JSR2 $no-ekey - DUP #72 NEQ ^$no-rkey JNZ - ( tool0 ) #03 =brush.tool ,draw-toolpane JSR2 $no-rkey - DUP #74 NEQ ^$no-tkey JNZ - ( tool0 ) #04 =brush.tool ,draw-toolpane JSR2 $no-tkey - DUP - DUP #30 GTH SWP #39 LTH #0101 NEQ2 ^$no-numkey JNZ - ( size ) ~Controller.key #31 SUB =brush.size ,draw-sizepane JSR2 $no-numkey + .zoom/active PEK #00 EQU ,&skip-zoom JNZ + .Controller/button DEI #f0 AND + DUP #04 SFT #01 AND #01 NEQ ,&no-up JNZ + ( move ) .zoom/y PEK2 -- .zoom/y POK2 &no-up + DUP #05 SFT #01 AND #01 NEQ ,&no-down JNZ + ( move ) .zoom/y PEK2 ++ .zoom/y POK2 &no-down + DUP #06 SFT #01 AND #01 NEQ ,&no-left JNZ + ( move ) .zoom/x PEK2 -- .zoom/x POK2 &no-left + DUP #07 SFT #01 AND #01 NEQ ,&no-right JNZ + ( move ) .zoom/x PEK2 ++ .zoom/x POK2 &no-right + #00 EQU #04 JNZ ;draw-canvas JSR2 + &skip-zoom + + .Controller/key DEI + DUP #20 NEQ ,&no-space JNZ + ( toggle zoom ) .zoom/active PEK #00 EQU .zoom/active POK ;redraw JSR2 &no-space + DUP #08 NEQ ,&no-backspace JNZ + ( erase ) ;clear JSR2 &no-backspace + DUP #71 NEQ ,&no-qkey JNZ + ( tool0 ) #00 .brush/tool POK ;draw-toolpane JSR2 &no-qkey + DUP #77 NEQ ,&no-wkey JNZ + ( tool0 ) #01 .brush/tool POK ;draw-toolpane JSR2 &no-wkey + DUP #65 NEQ ,&no-ekey JNZ + ( tool0 ) #02 .brush/tool POK ;draw-toolpane JSR2 &no-ekey + DUP #72 NEQ ,&no-rkey JNZ + ( tool0 ) #03 .brush/tool POK ;draw-toolpane JSR2 &no-rkey + DUP #74 NEQ ,&no-tkey JNZ + ( tool0 ) #04 .brush/tool POK ;draw-toolpane JSR2 &no-tkey + DUP + DUP #30 GTH SWP #39 LTH #0101 NEQ2 ,&no-numkey JNZ + ( size ) .Controller/key DEI #31 SUB .brush/size POK ;draw-sizepane JSR2 &no-numkey POP BRK @center ( -- ) - ( clear old ) - ~canvas.x1 #0002 SUB2 ~canvas.y1 #0002 SUB2 ~canvas.x2 #0002 ADD2 ~canvas.y2 #0002 ADD2 #00 ,fill-rect JSR2 + ( clear old ) + .canvas/x1 PEK2 #0002 SUB2 .canvas/y1 PEK2 #0002 SUB2 .canvas/x2 PEK2 #0002 ADD2 .canvas/y2 PEK2 #0002 ADD2 #00 ;fill-rect JSR2 - ,draw-background JSR2 + ;draw-background JSR2 - ~Screen.width #0002 DIV2 ~canvas.w 8* 2/ SUB2 =canvas.x1 - ~Screen.height #0002 DIV2 ~canvas.h 8* 2/ SUB2 =canvas.y1 + .Screen/width DEI2 #0002 DIV2 .canvas/w PEK2 8* 2/ SUB2 .canvas/x1 POK2 + .Screen/height DEI2 #0002 DIV2 .canvas/h PEK2 8* 2/ SUB2 .canvas/y1 POK2 - ,fit-canvas JSR2 - ,draw-foreground JSR2 + ;fit-canvas JSR2 + ;draw-foreground JSR2 RTN @rename - ,untitled_txt ,path.name ,strcpy JSR2 - #00 =path.length + ;untitled_txt ;path/name ;strcpy JSR2 + #00 .path/length POK RTN @clear ( -- ) - ,data FILESIZE ,data ADD2 - $loop - ( write ) OVR2 #00 ROT ROT POK2 + ;data FILESIZE ;data ADD2 + &loop + ( write ) OVR2 #00 ROT ROT PUT ( incr ) SWP2 #0001 ADD2 SWP2 - OVR2 OVR2 LTH2 ^$loop JNZ + OVR2 OVR2 LTH2 ,&loop JNZ POP2 POP2 - ,redraw JSR2 + ;redraw JSR2 RTN @present - ~document.presentation #00 EQU =document.presentation + .document/presentation PEK #00 EQU .document/presentation POK - ~document.presentation - DUP #00 NEQ ^$skip0 JNZ - ~theme.r0 =System.r ~theme.g0 =System.g ~theme.b0 =System.b - $skip0 - DUP #01 NEQ ^$skip1 JNZ - ~theme.r1 =System.r ~theme.g1 =System.g ~theme.b1 =System.b - $skip1 + .document/presentation PEK + DUP #00 NEQ ,&skip0 JNZ + .theme/r0 PEK2 .System/r DEO2 .theme/g0 PEK2 .System/g DEO2 .theme/b0 PEK2 .System/b DEO2 + &skip0 + DUP #01 NEQ ,&skip1 JNZ + .theme/r1 PEK2 .System/r DEO2 .theme/g1 PEK2 .System/g DEO2 .theme/b1 PEK2 .System/b DEO2 + &skip1 POP - ~toolpane.x1 #0002 SUB2 ~toolpane.y1 #0002 SUB2 ~toolpane.x2 ++ ~toolpane.y2 ++ #00 ,fill-rect JSR2 - ~pattpane.x1 #0002 SUB2 ~pattpane.y1 #0002 SUB2 ~pattpane.x2 ++ ~pattpane.y2 ++ #00 ,fill-rect JSR2 - ~sizepane.x1 #0002 SUB2 ~sizepane.y1 #0002 SUB2 ~sizepane.x2 ++ ~sizepane.y2 ++ #00 ,fill-rect JSR2 - ~viewpane.x1 #0002 SUB2 ~viewpane.y1 #0002 SUB2 ~viewpane.x2 ++ ~viewpane.y2 ++ #00 ,fill-rect JSR2 + .toolpane/x1 PEK2 #0002 SUB2 .toolpane/y1 PEK2 #0002 SUB2 .toolpane/x2 PEK2 ++ .toolpane/y2 PEK2 ++ #00 ;fill-rect JSR2 + .pattpane/x1 PEK2 #0002 SUB2 .pattpane/y1 PEK2 #0002 SUB2 .pattpane/x2 PEK2 ++ .pattpane/y2 PEK2 ++ #00 ;fill-rect JSR2 + .sizepane/x1 PEK2 #0002 SUB2 .sizepane/y1 PEK2 #0002 SUB2 .sizepane/x2 PEK2 ++ .sizepane/y2 PEK2 ++ #00 ;fill-rect JSR2 + .viewpane/x1 PEK2 #0002 SUB2 .viewpane/y1 PEK2 #0002 SUB2 .viewpane/x2 PEK2 ++ .viewpane/y2 PEK2 ++ #00 ;fill-rect JSR2 ( clear panes ) - ,redraw JSR2 + ;redraw JSR2 RTN @fit-canvas - ~canvas.w 8* ~canvas.x1 ADD2 =canvas.x2 - ~canvas.h 8* ~canvas.y1 ADD2 =canvas.y2 - ~canvas.x1 -- ~canvas.y1 -- ~canvas.x2 ~canvas.y2 #01 ,line-rect JSR2 - ,draw-canvas JSR2 + .canvas/w PEK2 8* .canvas/x1 PEK2 ADD2 .canvas/x2 POK2 + .canvas/h PEK2 8* .canvas/y1 PEK2 ADD2 .canvas/y2 POK2 + .canvas/x1 PEK2 -- .canvas/y1 PEK2 -- .canvas/x2 PEK2 .canvas/y2 PEK2 #01 ;line-rect JSR2 + ;draw-canvas JSR2 RTN @paint-line ( x1 y1 x2 y2 -- ) - ( load ) =line.y1 =line.x1 =line.y2 =line.x2 + ( load ) .line/y1 POK2 .line/x1 POK2 .line/y2 POK2 .line/x2 POK2 ( trim if zoomed ) - ~zoom.active #01 NEQ ^$no-zoom JNZ - ~line.x1 8/ ~zoom.x ADD2 =line.x1 - ~line.y1 8/ ~zoom.y ADD2 =line.y1 - ~line.x2 8/ ~zoom.x ADD2 =line.x2 - ~line.y2 8/ ~zoom.y ADD2 =line.y2 - $no-zoom - - ~line.x1 ~line.x2 SUB2 ABS2 =line.dx - ~line.y1 ~line.y2 SUB2 ABS2 #0000 SWP2 SUB2 =line.dy - #ffff #00 ~line.x2 ~line.x1 LTS2 #0002 MUL2 ADD2 =line.sx - #ffff #00 ~line.y2 ~line.y1 LTS2 #0002 MUL2 ADD2 =line.sy - ~line.dx ~line.dy ADD2 =line.e1 - $loop - ( paint ) ~line.x2 ~line.y2 ~brush.oper JSR2 - ~line.x2 ~line.x1 EQU2 ~line.y2 ~line.y1 EQU2 #0101 EQU2 ^$end JNZ - ~line.e1 #0002 MUL2 =line.e2 - ~line.e2 ~line.dy LTS2 ^$skipy JNZ - ~line.e1 ~line.dy ADD2 =line.e1 - ~line.x2 ~line.sx ADD2 =line.x2 - $skipy - ~line.e2 ~line.dx GTS2 ^$skipx JNZ - ~line.e1 ~line.dx ADD2 =line.e1 - ~line.y2 ~line.sy ADD2 =line.y2 - $skipx - ,$loop JMP2 - $end - - ,draw-canvas JSR2 - ,draw-foreground JSR2 + .zoom/active PEK #01 NEQ ,&no-zoom JNZ + .line/x1 PEK2 8/ .zoom/x PEK2 ADD2 .line/x1 POK2 + .line/y1 PEK2 8/ .zoom/y PEK2 ADD2 .line/y1 POK2 + .line/x2 PEK2 8/ .zoom/x PEK2 ADD2 .line/x2 POK2 + .line/y2 PEK2 8/ .zoom/y PEK2 ADD2 .line/y2 POK2 + &no-zoom + + .line/x1 PEK2 .line/x2 PEK2 SUB2 ABS2 .line/dx POK2 + .line/y1 PEK2 .line/y2 PEK2 SUB2 ABS2 #0000 SWP2 SUB2 .line/dy POK2 + #ffff #00 .line/x2 PEK2 .line/x1 PEK2 LTS2 #0002 MUL2 ADD2 .line/sx POK2 + #ffff #00 .line/y2 PEK2 .line/y1 PEK2 LTS2 #0002 MUL2 ADD2 .line/sy POK2 + .line/dx PEK2 .line/dy PEK2 ADD2 .line/e1 POK2 + &loop + ( paint ) .line/x2 PEK2 .line/y2 PEK2 .brush/oper PEK2 JSR2 + .line/x2 PEK2 .line/x1 PEK2 EQU2 .line/y2 PEK2 .line/y1 PEK2 EQU2 #0101 EQU2 ,&end JNZ + .line/e1 PEK2 #0002 MUL2 .line/e2 POK2 + .line/e2 PEK2 .line/dy PEK2 LTS2 ,&skipy JNZ + .line/e1 PEK2 .line/dy PEK2 ADD2 .line/e1 POK2 + .line/x2 PEK2 .line/sx PEK2 ADD2 .line/x2 POK2 + &skipy + .line/e2 PEK2 .line/dx PEK2 GTS2 ,&skipx JNZ + .line/e1 PEK2 .line/dx PEK2 ADD2 .line/e1 POK2 + .line/y2 PEK2 .line/sy PEK2 ADD2 .line/y2 POK2 + &skipx + ;&loop JMP2 + &end + + ;draw-canvas JSR2 + ;draw-foreground JSR2 RTN @paint-rect ( x1 y1 x2 y2 -- ) - ( load ) =rect.y2 =rect.x2 =rect.y1 =rect.x1 + ( load ) .rect/y2 POK2 .rect/x2 POK2 .rect/y1 POK2 .rect/x1 POK2 ( trim if zoomed ) - ~zoom.active #01 NEQ ^$no-zoom JNZ - ~rect.x1 8/ ~zoom.x ADD2 =rect.x1 - ~rect.y1 8/ ~zoom.y ADD2 =rect.y1 - ~rect.x2 8/ ~zoom.x ADD2 #0001 ADD2 =rect.x2 - ~rect.y2 8/ ~zoom.y ADD2 #0001 ADD2 =rect.y2 - $no-zoom - - ~rect.x1 =pt2.x - ~rect.y1 =pt2.y - - $ver - ~rect.x1 =pt2.x - $hor - ~pt2.x SWP POP =px.x ~pt2.y SWP POP =px.y - ,patternize JSR2 #00 EQU ^$no-pixel JNZ - ( draw ) ~pt2.x ~pt2.y ~brush.oper JSR2 $no-pixel - ( incr ) ~pt2.x ++ =pt2.x - ~pt2.x ~rect.x2 LTS2 ^$hor JNZ - ~pt2.y ++ =pt2.y - ~pt2.y ~rect.y2 LTS2 ^$ver JNZ - - ,draw-canvas JSR2 - ,draw-foreground JSR2 + .zoom/active PEK #01 NEQ ,&no-zoom JNZ + .rect/x1 PEK2 8/ .zoom/x PEK2 ADD2 .rect/x1 POK2 + .rect/y1 PEK2 8/ .zoom/y PEK2 ADD2 .rect/y1 POK2 + .rect/x2 PEK2 8/ .zoom/x PEK2 ADD2 #0001 ADD2 .rect/x2 POK2 + .rect/y2 PEK2 8/ .zoom/y PEK2 ADD2 #0001 ADD2 .rect/y2 POK2 + &no-zoom + + .rect/x1 PEK2 .pt2/x POK2 + .rect/y1 PEK2 .pt2/y POK2 + + &ver + .rect/x1 PEK2 .pt2/x POK2 + &hor + .pt2/x PEK2 SWP POP .px/x POK .pt2/y PEK2 SWP POP .px/y POK + ;patternize JSR2 #00 EQU ,&no-pixel JNZ + ( draw ) .pt2/x PEK2 .pt2/y PEK2 .brush/oper PEK2 JSR2 &no-pixel + ( incr ) .pt2/x PEK2 ++ .pt2/x POK2 + .pt2/x PEK2 .rect/x2 PEK2 LTS2 ,&hor JNZ + .pt2/y PEK2 ++ .pt2/y POK2 + .pt2/y PEK2 .rect/y2 PEK2 LTS2 ,&ver JNZ + + ;draw-canvas JSR2 + ;draw-foreground JSR2 RTN @paint-brush ( x y -- ) - #0003 SUB2 =pt0.y #0003 SUB2 =pt0.x ( cursor offset ) + #0003 SUB2 .pt0/y POK2 #0003 SUB2 .pt0/x POK2 ( cursor offset ) ( trim if zoomed ) - ~zoom.active #01 NEQ ^$no-zoom JNZ - ~pt0.x 8/ ~zoom.x ADD2 #0003 SUB2 =pt0.x - ~pt0.y 8/ ~zoom.y ADD2 #0003 SUB2 =pt0.y - $no-zoom - - #00 =px.x #00 =px.y - $ver - #00 =px.x - $hor - ( addr ) ,size_icns #00 ~brush.size 8* ADD2 - ( byte ) #00 ~px.y ADD2 PEK2 #07 ~px.x SUB SFT #01 AND - #00 EQU ^$no-pixel JNZ - ,patternize JSR2 #00 EQU ^$no-pixel JNZ - ~pt0.x #00 ~px.x ADD2 ~pt0.y #00 ~px.y ADD2 ~brush.oper JSR2 $no-pixel - ( incr ) ~px.x #01 ADD =px.x - ~px.x #08 LTH ^$hor JNZ - ( incr ) ~px.y #01 ADD =px.y - ~px.y #08 LTH ^$ver JNZ - - ,draw-canvas JSR2 - ,draw-foreground JSR2 + .zoom/active PEK #01 NEQ ,&no-zoom JNZ + .pt0/x PEK2 8/ .zoom/x PEK2 ADD2 #0003 SUB2 .pt0/x POK2 + .pt0/y PEK2 8/ .zoom/y PEK2 ADD2 #0003 SUB2 .pt0/y POK2 + &no-zoom + + #00 .px/x POK #00 .px/y POK + &ver + #00 .px/x POK + &hor + ( addr ) ;size_icns #00 .brush/size PEK 8* ADD2 + ( byte ) #00 .px/y PEK ADD2 GET #07 .px/x PEK SUB SFT #01 AND + #00 EQU ,&no-pixel JNZ + ;patternize JSR2 #00 EQU ,&no-pixel JNZ + .pt0/x PEK2 #00 .px/x PEK ADD2 .pt0/y PEK2 #00 .px/y PEK ADD2 .brush/oper PEK2 JSR2 &no-pixel + ( incr ) .px/x PEK #01 ADD .px/x POK + .px/x PEK #08 LTH ,&hor JNZ + ( incr ) .px/y PEK #01 ADD .px/y POK + .px/y PEK #08 LTH ,&ver JNZ + + ;draw-canvas JSR2 + ;draw-foreground JSR2 RTN @patternize ( -- ) - ~brush.patt #00 NEQ ^$noplain JNZ - #01 RTN $noplain + .brush/patt PEK #00 NEQ ,&noplain JNZ + #01 RTN &noplain - ~brush.patt #01 NEQ ^$notone1 JNZ - ~pt0.x #00 ~px.x ADD2 ~pt0.y #00 ~px.y ADD2 ADD2 #0001 AND2 #0000 EQU2 - ~pt0.x #00 ~px.x ADD2 ~pt0.y #00 ~px.y ADD2 SUB2 #0001 AND2 #0000 EQU2 + .brush/patt PEK #01 NEQ ,&notone1 JNZ + .pt0/x PEK2 #00 .px/x PEK ADD2 .pt0/y PEK2 #00 .px/y PEK ADD2 ADD2 #0001 AND2 #0000 EQU2 + .pt0/x PEK2 #00 .px/x PEK ADD2 .pt0/y PEK2 #00 .px/y PEK ADD2 SUB2 #0001 AND2 #0000 EQU2 #0101 EQU2 - RTN $notone1 + RTN &notone1 - ~brush.patt #02 NEQ ^$notone2 JNZ - ~pt0.x #00 ~px.x ADD2 ~pt0.y #00 ~px.y ADD2 ADD2 #0003 AND2 #0000 EQU2 - ~pt0.x #00 ~px.x ADD2 ~pt0.y #00 ~px.y ADD2 SUB2 #0003 AND2 #0000 EQU2 + .brush/patt PEK #02 NEQ ,&notone2 JNZ + .pt0/x PEK2 #00 .px/x PEK ADD2 .pt0/y PEK2 #00 .px/y PEK ADD2 ADD2 #0003 AND2 #0000 EQU2 + .pt0/x PEK2 #00 .px/x PEK ADD2 .pt0/y PEK2 #00 .px/y PEK ADD2 SUB2 #0003 AND2 #0000 EQU2 #0101 EQU2 - RTN $notone2 + RTN &notone2 - ~brush.patt #03 NEQ ^$notone3 JNZ - ~pt0.x #00 ~px.x ADD2 ~pt0.y #00 ~px.y ADD2 ADD2 #0005 AND2 #0000 EQU2 - ~pt0.x #00 ~px.x ADD2 ~pt0.y #00 ~px.y ADD2 SUB2 #0005 AND2 #0000 EQU2 + .brush/patt PEK #03 NEQ ,&notone3 JNZ + .pt0/x PEK2 #00 .px/x PEK ADD2 .pt0/y PEK2 #00 .px/y PEK ADD2 ADD2 #0005 AND2 #0000 EQU2 + .pt0/x PEK2 #00 .px/x PEK ADD2 .pt0/y PEK2 #00 .px/y PEK ADD2 SUB2 #0005 AND2 #0000 EQU2 #0101 EQU2 - RTN $notone3 + RTN &notone3 - ~brush.patt #04 NEQ ^$notone4 JNZ - ~pt0.x #00 ~px.x ADD2 ~pt0.y #00 ~px.y ADD2 ADD2 #0003 AND2 #0000 EQU2 RTN $notone4 + .brush/patt PEK #04 NEQ ,&notone4 JNZ + .pt0/x PEK2 #00 .px/x PEK ADD2 .pt0/y PEK2 #00 .px/y PEK ADD2 ADD2 #0003 AND2 #0000 EQU2 RTN &notone4 - ~brush.patt #05 NEQ ^$notone5 JNZ - ~pt0.x #00 ~px.x ADD2 ~pt0.y #00 ~px.y ADD2 SUB2 #0003 AND2 #0000 EQU2 RTN $notone5 + .brush/patt PEK #05 NEQ ,&notone5 JNZ + .pt0/x PEK2 #00 .px/x PEK ADD2 .pt0/y PEK2 #00 .px/y PEK ADD2 SUB2 #0003 AND2 #0000 EQU2 RTN &notone5 - ~brush.patt #06 NEQ ^$notone6 JNZ - ~pt0.x #00 ~px.x ADD2 #0001 AND2 SWP POP RTN $notone6 + .brush/patt PEK #06 NEQ ,&notone6 JNZ + .pt0/x PEK2 #00 .px/x PEK ADD2 #0001 AND2 SWP POP RTN &notone6 - ~brush.patt #07 NEQ ^$notone7 JNZ - ~pt0.y #00 ~px.y ADD2 #0001 AND2 SWP POP RTN $notone7 + .brush/patt PEK #07 NEQ ,&notone7 JNZ + .pt0/y PEK2 #00 .px/y PEK ADD2 #0001 AND2 SWP POP RTN &notone7 #00 @@ -549,31 +551,31 @@ RTN @get-pixel ( x y -- b ) - SWP POP #07 AND =px.y - SWP POP #07 AND =px.x - ( get tile ) ~pt1.x 8/ ~pt1.y 8/ ~canvas.w MUL2 ADD2 8* - ( add addr ) ,data ADD2 - #00 ~px.y ADD2 PEK2 #07 ~px.x SUB SFT #01 AND + SWP POP #07 AND .px/y POK + SWP POP #07 AND .px/x POK + ( get tile ) .pt1/x PEK2 8/ .pt1/y PEK2 8/ .canvas/w PEK2 MUL2 ADD2 8* + ( add addr ) ;data ADD2 + #00 .px/y PEK ADD2 GET #07 .px/x PEK SUB SFT #01 AND RTN @add-pixel ( x y -- ) - =pt1.y =pt1.x - ( get tile addr ) ,data ~pt1.x 8/ ~pt1.y 8/ ~canvas.w MUL2 ADD2 8* ~pt1.y MOD8 ADD2 ADD2 - ( load ) DUP2 PEK2 - ( mask ) #01 #07 ~pt1.x MOD8 SWP POP SUB SFL ORA - ( save ) ROT ROT POK2 + .pt1/y POK2 .pt1/x POK2 + ( get tile addr ) ;data .pt1/x PEK2 8/ .pt1/y PEK2 8/ .canvas/w PEK2 MUL2 ADD2 8* .pt1/y PEK2 MOD8 ADD2 ADD2 + ( load ) DUP2 GET + ( mask ) #01 #07 .pt1/x PEK2 MOD8 SWP POP SUB SFL ORA + ( save ) ROT ROT PUT RTN @remove-pixel ( x y -- ) - =pt1.y =pt1.x - ( get tile addr ) ,data ~pt1.x 8/ ~pt1.y 8/ ~canvas.w MUL2 ADD2 8* ~pt1.y MOD8 ADD2 ADD2 - ( load ) DUP2 PEK2 - ( mask ) #01 #07 ~pt1.x MOD8 SWP POP SUB SFL #ff EOR AND - ( save ) ROT ROT POK2 + .pt1/y POK2 .pt1/x POK2 + ( get tile addr ) ;data .pt1/x PEK2 8/ .pt1/y PEK2 8/ .canvas/w PEK2 MUL2 ADD2 8* .pt1/y PEK2 MOD8 ADD2 ADD2 + ( load ) DUP2 GET + ( mask ) #01 #07 .pt1/x PEK2 MOD8 SWP POP SUB SFL #ff EOR AND + ( save ) ROT ROT PUT RTN @@ -581,15 +583,15 @@ RTN @load-file ( path -- ) - =File.name FILESIZE =File.length ,data =File.load - ~File.name ,path.name ,strcpy JSR2 - ,draw-canvas JSR2 + .File/name DEO2 FILESIZE .File/length DEO2 ;data .File/load DEO2 + .File/name DEI2 ;path/name ;strcpy JSR2 + ;draw-canvas JSR2 RTN @save-file ( path -- ) - =File.name FILESIZE =File.length ,data =File.save + .File/name DEO2 FILESIZE .File/length DEO2 ;data .File/save DEO2 RTN @@ -597,207 +599,207 @@ RTN @redraw ( -- ) - ,draw-background JSR2 - ,draw-canvas JSR2 - ,draw-foreground JSR2 + ;draw-background JSR2 + ;draw-canvas JSR2 + ;draw-foreground JSR2 RTN @draw-canvas ( -- ) - ~zoom.active #01 EQU ,draw-canvas-zoom JNZ2 - - ~canvas.y1 =Screen.y - ,data =Screen.addr - $ver - ~canvas.x1 =Screen.x - $hor - ( draw ) #29 =Screen.color - ( incr ) ~Screen.x 8+ =Screen.x - ( incr ) ~Screen.addr 8+ =Screen.addr - ~Screen.x ~canvas.x2 NEQ2 ^$hor JNZ - ( incr ) ~Screen.y 8+ =Screen.y - ~Screen.y ~canvas.y2 NEQ2 ^$ver JNZ + .zoom/active PEK #01 EQU ;draw-canvas-zoom JNZ2 + + .canvas/y1 PEK2 .Screen/y DEO2 + ;data .Screen/addr DEO2 + &ver + .canvas/x1 PEK2 .Screen/x DEO2 + &hor + ( draw ) #29 .Screen/color DEO + ( incr ) .Screen/x DEI2 8+ .Screen/x DEO2 + ( incr ) .Screen/addr DEI2 8+ .Screen/addr DEO2 + .Screen/x DEI2 .canvas/x2 PEK2 NEQ2 ,&hor JNZ + ( incr ) .Screen/y DEI2 8+ .Screen/y DEO2 + .Screen/y DEI2 .canvas/y2 PEK2 NEQ2 ,&ver JNZ RTN @draw-canvas-zoom ( -- ) - ~zoom.y =pt1.y - ~canvas.y1 =Screen.y - ,data =Screen.addr - $ver - ~canvas.x1 =Screen.x - ~zoom.x =pt1.x - $hor - ( incr ) ,bigpixel_icn #0008 #00 ~pt1.x ~pt1.y ,get-pixel JSR2 MUL2 ADD2 =Screen.addr - ( draw ) #29 =Screen.color - ( incr ) ~Screen.x 8+ =Screen.x - ( incr ) ~pt1.x ++ =pt1.x - ~Screen.x ~canvas.x2 NEQ2 ^$hor JNZ - ( incr ) ~Screen.y 8+ =Screen.y - ( incr ) ~pt1.y ++ =pt1.y - ~Screen.y ~canvas.y2 NEQ2 ^$ver JNZ + .zoom/y PEK2 .pt1/y POK2 + .canvas/y1 PEK2 .Screen/y DEO2 + ;data .Screen/addr DEO2 + &ver + .canvas/x1 PEK2 .Screen/x DEO2 + .zoom/x PEK2 .pt1/x POK2 + &hor + ( incr ) ;bigpixel_icn #0008 #00 .pt1/x PEK2 .pt1/y PEK2 ;get-pixel JSR2 MUL2 ADD2 .Screen/addr DEO2 + ( draw ) #29 .Screen/color DEO + ( incr ) .Screen/x DEI2 8+ .Screen/x DEO2 + ( incr ) .pt1/x PEK2 ++ .pt1/x POK2 + .Screen/x DEI2 .canvas/x2 PEK2 NEQ2 ,&hor JNZ + ( incr ) .Screen/y DEI2 8+ .Screen/y DEO2 + ( incr ) .pt1/y PEK2 ++ .pt1/y POK2 + .Screen/y DEI2 .canvas/y2 PEK2 NEQ2 ,&ver JNZ RTN @draw-cursor ( -- ) - ,blank_icn =Screen.addr + ;blank_icn .Screen/addr DEO2 ( clear brush size ) - ~cursor.x #0003 SUB2 =Screen.x ~cursor.y #0003 SUB2 =Screen.y #30 =Screen.color + .cursor/x PEK2 #0003 SUB2 .Screen/x DEO2 .cursor/y PEK2 #0003 SUB2 .Screen/y DEO2 #30 .Screen/color DEO ( clear last cursor ) - ~cursor.x =Screen.x ~cursor.y =Screen.y #30 =Screen.color + .cursor/x PEK2 .Screen/x DEO2 .cursor/y PEK2 .Screen/y DEO2 #30 .Screen/color DEO ( record cursor positions ) - ~Mouse.x =cursor.x ~Mouse.y =cursor.y + .Mouse/x DEI2 .cursor/x POK2 .Mouse/y DEI2 .cursor/y POK2 ( draw size cursor ) - ~brush.tool #01 NEQ ,$outside-canvas JNZ2 + .brush/tool PEK #01 NEQ ;&outside-canvas JNZ2 ( do not draw size when holding alt ) - ~Controller.button #02 EQU ,$outside-canvas JNZ2 - ~Mouse.x CLN2r ~canvas.x1 GTH2 STH2r ~canvas.x2 LTH2 #0101 NEQ2 ,$outside-canvas JNZ2 - ~Mouse.y CLN2r ~canvas.y1 GTH2 STH2r ~canvas.y2 LTH2 #0101 NEQ2 ,$outside-canvas JNZ2 + .Controller/button DEI #02 EQU ;&outside-canvas JNZ2 + .Mouse/x DEI2 CLN2r .canvas/x1 PEK2 GTH2 STH2r .canvas/x2 PEK2 LTH2 #0101 NEQ2 ;&outside-canvas JNZ2 + .Mouse/y DEI2 CLN2r .canvas/y1 PEK2 GTH2 STH2r .canvas/y2 PEK2 LTH2 #0101 NEQ2 ;&outside-canvas JNZ2 ( do not draw size in toolpane ) - ~Mouse.x CLN2r ~toolpane.x1 GTH2 STH2r ~toolpane.x2 LTH2 #0101 EQU2 ~Mouse.y CLN2r ~toolpane.y1 GTH2 STH2r ~toolpane.y2 LTH2 #0101 EQU2 #0101 EQU2 ,$outside-canvas JNZ2 - ~Mouse.x CLN2r ~sizepane.x1 GTH2 STH2r ~sizepane.x2 LTH2 #0101 EQU2 ~Mouse.y CLN2r ~sizepane.y1 GTH2 STH2r ~sizepane.y2 LTH2 #0101 EQU2 #0101 EQU2 ,$outside-canvas JNZ2 - ~Mouse.x CLN2r ~pattpane.x1 GTH2 STH2r ~pattpane.x2 LTH2 #0101 EQU2 ~Mouse.y CLN2r ~pattpane.y1 GTH2 STH2r ~pattpane.y2 LTH2 #0101 EQU2 #0101 EQU2 ,$outside-canvas JNZ2 - ~cursor.x #0003 SUB2 =Screen.x ~cursor.y #0003 SUB2 =Screen.y - ,brush_icns #00 ~brush.size 8* ADD2 =Screen.addr - #31 ~Mouse.state #02 MUL ADD =Screen.color - ~Mouse.state #00 EQU ^$outside-canvas JNZ RTN - $outside-canvas + .Mouse/x DEI2 CLN2r .toolpane/x1 PEK2 GTH2 STH2r .toolpane/x2 PEK2 LTH2 #0101 EQU2 .Mouse/y DEI2 CLN2r .toolpane/y1 PEK2 GTH2 STH2r .toolpane/y2 PEK2 LTH2 #0101 EQU2 #0101 EQU2 ;&outside-canvas JNZ2 + .Mouse/x DEI2 CLN2r .sizepane/x1 PEK2 GTH2 STH2r .sizepane/x2 PEK2 LTH2 #0101 EQU2 .Mouse/y DEI2 CLN2r .sizepane/y1 PEK2 GTH2 STH2r .sizepane/y2 PEK2 LTH2 #0101 EQU2 #0101 EQU2 ;&outside-canvas JNZ2 + .Mouse/x DEI2 CLN2r .pattpane/x1 PEK2 GTH2 STH2r .pattpane/x2 PEK2 LTH2 #0101 EQU2 .Mouse/y DEI2 CLN2r .pattpane/y1 PEK2 GTH2 STH2r .pattpane/y2 PEK2 LTH2 #0101 EQU2 #0101 EQU2 ;&outside-canvas JNZ2 + .cursor/x PEK2 #0003 SUB2 .Screen/x DEO2 .cursor/y PEK2 #0003 SUB2 .Screen/y DEO2 + ;brush_icns #00 .brush/size PEK 8* ADD2 .Screen/addr DEO2 + #31 .Mouse/state DEI #02 MUL ADD .Screen/color DEO + .Mouse/state DEI #00 EQU ,&outside-canvas JNZ RTN + &outside-canvas ( draw new cursor ) - ~cursor.x =Screen.x ~cursor.y =Screen.y - ,pointers_icn #00 ~Controller.button #02 EQU 8* ADD2 =Screen.addr - #3f ~Mouse.state #01 EQU #0a MUL SUB =Screen.color + .cursor/x PEK2 .Screen/x DEO2 .cursor/y PEK2 .Screen/y DEO2 + ;pointers_icn #00 .Controller/button DEI #02 EQU 8* ADD2 .Screen/addr DEO2 + #3f .Mouse/state DEI #01 EQU #0a MUL SUB .Screen/color DEO RTN @draw-toolpane ( -- ) - ~document.presentation #00 EQU ^$skip JNZ RTN $skip + .document/presentation PEK #00 EQU ,&skip JNZ RTN &skip - ( frame ) - ~toolpane.x1 -- ~toolpane.y1 -- ~toolpane.x2 ~toolpane.y2 #00 ,line-rect JSR2 - ~toolpane.x1 #0002 SUB2 ~toolpane.y1 #0002 SUB2 ~toolpane.x2 ~toolpane.y2 #01 ,line-rect JSR2 + ( frame ) + .toolpane/x1 PEK2 -- .toolpane/y1 PEK2 -- .toolpane/x2 PEK2 .toolpane/y2 PEK2 #00 ;line-rect JSR2 + .toolpane/x1 PEK2 #0002 SUB2 .toolpane/y1 PEK2 #0002 SUB2 .toolpane/x2 PEK2 .toolpane/y2 PEK2 #01 ;line-rect JSR2 - ~toolpane.x1 =Screen.x ~toolpane.y1 =Screen.y ,tool_icns =Screen.addr + .toolpane/x1 PEK2 .Screen/x DEO2 .toolpane/y1 PEK2 .Screen/y DEO2 ;tool_icns .Screen/addr DEO2 - $loop - ( draw ) #21 ~Screen.x ~toolpane.x1 SUB2 8/ SWP POP ~brush.tool EQU #02 MUL ADD =Screen.color - ( incr ) ~Screen.x 8+ =Screen.x - ( incr ) ~Screen.addr 8+ =Screen.addr - ~Screen.x ~toolpane.x2 LTH2 ^$loop JNZ + &loop + ( draw ) #21 .Screen/x DEI2 .toolpane/x1 PEK2 SUB2 8/ SWP POP .brush/tool PEK EQU #02 MUL ADD .Screen/color DEO + ( incr ) .Screen/x DEI2 8+ .Screen/x DEO2 + ( incr ) .Screen/addr DEI2 8+ .Screen/addr DEO2 + .Screen/x DEI2 .toolpane/x2 PEK2 LTH2 ,&loop JNZ - ~zoom.active #01 NEQ ^$no-zoom JNZ - ~Screen.x #0008 SUB2 =Screen.x - ,tool_icns #0028 ADD2 =Screen.addr - #21 #04 ~brush.tool EQU #02 MUL ADD =Screen.color - $no-zoom + .zoom/active PEK #01 NEQ ,&no-zoom JNZ + .Screen/x DEI2 #0008 SUB2 .Screen/x DEO2 + ;tool_icns #0028 ADD2 .Screen/addr DEO2 + #21 #04 .brush/tool PEK EQU #02 MUL ADD .Screen/color DEO + &no-zoom RTN @draw-pattpane ( -- ) - ~document.presentation #00 EQU ^$skip JNZ RTN $skip + .document/presentation PEK #00 EQU ,&skip JNZ RTN &skip - ( frame ) - ~pattpane.x1 -- ~pattpane.y1 -- ~pattpane.x2 ~pattpane.y2 #00 ,line-rect JSR2 - ~pattpane.x1 #0002 SUB2 ~pattpane.y1 #0002 SUB2 ~pattpane.x2 ~pattpane.y2 #01 ,line-rect JSR2 + ( frame ) + .pattpane/x1 PEK2 -- .pattpane/y1 PEK2 -- .pattpane/x2 PEK2 .pattpane/y2 PEK2 #00 ;line-rect JSR2 + .pattpane/x1 PEK2 #0002 SUB2 .pattpane/y1 PEK2 #0002 SUB2 .pattpane/x2 PEK2 .pattpane/y2 PEK2 #01 ;line-rect JSR2 - ~pattpane.x1 =Screen.x ~pattpane.y1 =Screen.y ,patt_icns =Screen.addr + .pattpane/x1 PEK2 .Screen/x DEO2 .pattpane/y1 PEK2 .Screen/y DEO2 ;patt_icns .Screen/addr DEO2 - $loop - ( draw ) #21 ~Screen.x ~pattpane.x1 SUB2 8/ SWP POP ~brush.patt EQU #02 MUL ADD =Screen.color - ( incr ) ~Screen.x 8+ =Screen.x - ( incr ) ~Screen.addr 8+ =Screen.addr - ~Screen.x ~pattpane.x2 LTH2 ^$loop JNZ + &loop + ( draw ) #21 .Screen/x DEI2 .pattpane/x1 PEK2 SUB2 8/ SWP POP .brush/patt PEK EQU #02 MUL ADD .Screen/color DEO + ( incr ) .Screen/x DEI2 8+ .Screen/x DEO2 + ( incr ) .Screen/addr DEI2 8+ .Screen/addr DEO2 + .Screen/x DEI2 .pattpane/x2 PEK2 LTH2 ,&loop JNZ RTN @draw-sizepane ( -- ) - ~document.presentation #00 EQU ^$skip JNZ RTN $skip + .document/presentation PEK #00 EQU ,&skip JNZ RTN &skip ( frame ) - ~sizepane.x1 -- ~sizepane.y1 -- ~sizepane.x2 ~sizepane.y2 #00 ,line-rect JSR2 - ~sizepane.x1 #0002 SUB2 ~sizepane.y1 #0002 SUB2 ~sizepane.x2 ~sizepane.y2 #01 ,line-rect JSR2 + .sizepane/x1 PEK2 -- .sizepane/y1 PEK2 -- .sizepane/x2 PEK2 .sizepane/y2 PEK2 #00 ;line-rect JSR2 + .sizepane/x1 PEK2 #0002 SUB2 .sizepane/y1 PEK2 #0002 SUB2 .sizepane/x2 PEK2 .sizepane/y2 PEK2 #01 ;line-rect JSR2 - ~sizepane.x1 =Screen.x ~sizepane.y1 =Screen.y ,size_icns =Screen.addr + .sizepane/x1 PEK2 .Screen/x DEO2 .sizepane/y1 PEK2 .Screen/y DEO2 ;size_icns .Screen/addr DEO2 - $loop - ( draw ) #21 ~Screen.x ~sizepane.x1 SUB2 8/ SWP POP ~brush.size EQU #02 MUL ADD =Screen.color - ( incr ) ~Screen.x 8+ =Screen.x - ( incr ) ~Screen.addr 8+ =Screen.addr - ~Screen.x ~sizepane.x2 LTH2 ^$loop JNZ + &loop + ( draw ) #21 .Screen/x DEI2 .sizepane/x1 PEK2 SUB2 8/ SWP POP .brush/size PEK EQU #02 MUL ADD .Screen/color DEO + ( incr ) .Screen/x DEI2 8+ .Screen/x DEO2 + ( incr ) .Screen/addr DEI2 8+ .Screen/addr DEO2 + .Screen/x DEI2 .sizepane/x2 PEK2 LTH2 ,&loop JNZ RTN @draw-viewpane ( -- ) - ~document.presentation #00 EQU ^$skip JNZ RTN $skip + .document/presentation PEK #00 EQU ,&skip JNZ RTN &skip ( frame ) - ~viewpane.x1 -- ~viewpane.y1 -- ~viewpane.x2 ~viewpane.y2 #00 ,line-rect JSR2 - ~viewpane.x1 #0002 SUB2 ~viewpane.y1 #0002 SUB2 ~viewpane.x2 ~viewpane.y2 #01 ,line-rect JSR2 + .viewpane/x1 PEK2 -- .viewpane/y1 PEK2 -- .viewpane/x2 PEK2 .viewpane/y2 PEK2 #00 ;line-rect JSR2 + .viewpane/x1 PEK2 #0002 SUB2 .viewpane/y1 PEK2 #0002 SUB2 .viewpane/x2 PEK2 .viewpane/y2 PEK2 #01 ;line-rect JSR2 - ~viewpane.x1 =Screen.x ~viewpane.y1 =Screen.y ,view_icns =Screen.addr + .viewpane/x1 PEK2 .Screen/x DEO2 .viewpane/y1 PEK2 .Screen/y DEO2 ;view_icns .Screen/addr DEO2 - $loop - ( draw ) #21 =Screen.color - ( incr ) ~Screen.x 8+ =Screen.x - ( incr ) ~Screen.addr 8+ =Screen.addr - ~Screen.x ~viewpane.x2 LTH2 ^$loop JNZ + &loop + ( draw ) #21 .Screen/color DEO + ( incr ) .Screen/x DEI2 8+ .Screen/x DEO2 + ( incr ) .Screen/addr DEI2 8+ .Screen/addr DEO2 + .Screen/x DEI2 .viewpane/x2 PEK2 LTH2 ,&loop JNZ RTN @draw-foreground - ,draw-toolpane JSR2 - ,draw-pattpane JSR2 - ,draw-sizepane JSR2 - ,draw-viewpane JSR2 + ;draw-toolpane JSR2 + ;draw-pattpane JSR2 + ;draw-sizepane JSR2 + ;draw-viewpane JSR2 RTN @draw-background ( draw hor line ) - #0000 ~Screen.width ~Screen.height #0002 DIV2 ~document.presentation #00 EQU ,line-horizontal-dotted JSR2 + #0000 .Screen/width DEI2 .Screen/height DEI2 #0002 DIV2 .document/presentation PEK #00 EQU ;line-horizontal-dotted JSR2 ( draw ver line ) - ~Screen.width #0002 DIV2 #0000 ~Screen.height ~document.presentation #00 EQU ,line-vertical-dotted JSR2 + .Screen/width DEI2 #0002 DIV2 #0000 .Screen/height DEI2 .document/presentation PEK #00 EQU ;line-vertical-dotted JSR2 - ~document.presentation #01 EQU ,$skip-size JNZ2 + .document/presentation PEK #01 EQU ;&skip-size JNZ2 ( draw size ) - #0010 =Screen.y + #0010 .Screen/y DEO2 ( draw width ) - ~Screen.width #00a0 SUB2 =Screen.x ,font_hex ~canvas.w #f0 AND #04 SFT #08 MUL ADD2 =Screen.addr - ( draw ) #21 =Screen.color - ~Screen.x 8+ =Screen.x ,font_hex ~canvas.w #0f AND #08 MUL ADD2 =Screen.addr - ( draw ) #21 =Screen.color + .Screen/width DEI2 #00a0 SUB2 .Screen/x DEO2 ;font_hex .canvas/w PEK2 #f0 AND #04 SFT #08 MUL ADD2 .Screen/addr DEO2 + ( draw ) #21 .Screen/color DEO + .Screen/x DEI2 8+ .Screen/x DEO2 ;font_hex .canvas/w PEK2 #0f AND #08 MUL ADD2 .Screen/addr DEO2 + ( draw ) #21 .Screen/color DEO ( draw height ) - ~Screen.x 8+ =Screen.x ,font_hex ~canvas.h #f0 AND #04 SFT #08 MUL ADD2 =Screen.addr - ( draw ) #21 =Screen.color - ~Screen.x 8+ =Screen.x ,font_hex ~canvas.h #0f AND #08 MUL ADD2 =Screen.addr - ( draw ) #21 =Screen.color - $skip-size + .Screen/x DEI2 8+ .Screen/x DEO2 ;font_hex .canvas/h PEK2 #f0 AND #04 SFT #08 MUL ADD2 .Screen/addr DEO2 + ( draw ) #21 .Screen/color DEO + .Screen/x DEI2 8+ .Screen/x DEO2 ;font_hex .canvas/h PEK2 #0f AND #08 MUL ADD2 .Screen/addr DEO2 + ( draw ) #21 .Screen/color DEO + &skip-size ( draw save/load/guides icons ) - ~Screen.height #0010 SUB2 =Screen.y - ~Screen.width #0028 SUB2 =Screen.x - ,eye_icn #00 ~document.presentation #08 MUL ADD2 =Screen.addr - #23 =Screen.color - ~Screen.x 8+ =Screen.x - ,filestate_icn =Screen.addr - #23 =Screen.color - ~Screen.x 8+ =Screen.x - ,load_icn =Screen.addr - #23 =Screen.color - ~Screen.x 8+ =Screen.x - ,save_icn =Screen.addr - #23 =Screen.color + .Screen/height DEI2 #0010 SUB2 .Screen/y DEO2 + .Screen/width DEI2 #0028 SUB2 .Screen/x DEO2 + ;eye_icn #00 .document/presentation PEK #08 MUL ADD2 .Screen/addr DEO2 + #23 .Screen/color DEO + .Screen/x DEI2 8+ .Screen/x DEO2 + ;filestate_icn .Screen/addr DEO2 + #23 .Screen/color DEO + .Screen/x DEI2 8+ .Screen/x DEO2 + ;load_icn .Screen/addr DEO2 + #23 .Screen/color DEO + .Screen/x DEI2 8+ .Screen/x DEO2 + ;save_icn .Screen/addr DEO2 + #23 .Screen/color DEO - #0008 =Screen.x - ,path.name #01 ,draw-label JSR2 + #0008 .Screen/x DEO2 + ;path/name #01 ;draw-label JSR2 RTN @@ -805,92 +807,92 @@ RTN @line-rect ( x1 y1 x2 y2 color -- ) - ( load ) =color DUP2 STH2 =rect.y2 =rect.x2 DUP2 STH2 =rect.y1 =rect.x1 + ( load ) .color POK DUP2 STH2 .rect/y2 POK2 .rect/x2 POK2 DUP2 STH2 .rect/y1 POK2 .rect/x1 POK2 STH2r STH2r - $ver - ( save ) OVR2 =Screen.y - ( draw ) ~rect.x1 =Screen.x ~color DUP =Screen.color - ( draw ) ~rect.x2 =Screen.x =Screen.color + &ver + ( save ) OVR2 .Screen/y DEO2 + ( draw ) .rect/x1 PEK2 .Screen/x DEO2 .color PEK DUP .Screen/color DEO + ( draw ) .rect/x2 PEK2 .Screen/x DEO2 .Screen/color DEO ( incr ) SWP2 ++ SWP2 - OVR2 OVR2 LTS2 ^$ver JNZ + OVR2 OVR2 LTS2 ,&ver JNZ POP2 POP2 - ~rect.x1 ~rect.x2 - $hor - ( save ) OVR2 =Screen.x - ( draw ) ~rect.y1 =Screen.y ~color DUP =Screen.color - ( draw ) ~rect.y2 =Screen.y =Screen.color + .rect/x1 PEK2 .rect/x2 PEK2 + &hor + ( save ) OVR2 .Screen/x DEO2 + ( draw ) .rect/y1 PEK2 .Screen/y DEO2 .color PEK DUP .Screen/color DEO + ( draw ) .rect/y2 PEK2 .Screen/y DEO2 .Screen/color DEO ( incr ) SWP2 ++ SWP2 - OVR2 OVR2 ++ LTS2 ^$hor JNZ + OVR2 OVR2 ++ LTS2 ,&hor JNZ POP2 POP2 RTN @fill-rect ( x1 y1 x2 y2 color -- ) - =color + .color POK ( x1 x2 y1 y2 ) ROT2 SWP2 - $ver - ( save ) OVR2 =Screen.y - STH2 STH2 OVR2 OVR2 - $hor - ( save ) OVR2 =Screen.x - ( draw ) ~color =Screen.color + &ver + ( save ) OVR2 .Screen/y DEO2 + STH2 STH2 OVR2 OVR2 + &hor + ( save ) OVR2 .Screen/x DEO2 + ( draw ) .color PEK .Screen/color DEO ( incr ) SWP2 ++ SWP2 - OVR2 OVR2 LTS2 ^$hor JNZ + OVR2 OVR2 LTS2 ,&hor JNZ POP2 POP2 STH2r STH2r ( incr ) SWP2 ++ SWP2 - OVR2 OVR2 LTS2 ^$ver JNZ + OVR2 OVR2 LTS2 ,&ver JNZ POP2 POP2 POP2 POP2 RTN @draw-label ( addr color -- ) - =color - $loop - DUP2 PEK2 #00 SWP #0008 MUL2 ,font ADD2 =Screen.addr - ( draw ) ~color #20 ADD =Screen.color + .color POK + &loop + DUP2 GET #00 SWP #0008 MUL2 ;font ADD2 .Screen/addr DEO2 + ( draw ) .color PEK #20 ADD .Screen/color DEO ( incr ) #0001 ADD2 - ( incr ) ~Screen.x 8+ =Screen.x - ( loop ) DUP2 PEK2 #00 NEQ ^$loop JNZ + ( incr ) .Screen/x DEI2 8+ .Screen/x DEO2 + ( loop ) DUP2 GET #00 NEQ ,&loop JNZ POP2 RTN @line-horizontal-dotted ( x0 x1 y color -- ) - =color =Screen.y OVR2 =Screen.x - $draw-hor - ( draw ) ~color =Screen.color - ( incr ) SWP2 #0002 ADD2 DUP2 =Screen.x SWP2 - OVR2 OVR2 LTH2 ^$draw-hor JNZ + .color POK .Screen/y DEO2 OVR2 .Screen/x DEO2 + &draw-hor + ( draw ) .color PEK .Screen/color DEO + ( incr ) SWP2 #0002 ADD2 DUP2 .Screen/x DEO2 SWP2 + OVR2 OVR2 LTH2 ,&draw-hor JNZ POP2 POP2 RTN @line-vertical-dotted ( x y0 y1 color -- ) - =color STH2 SWP2 =Screen.x STH2r OVR2 =Screen.y - $draw-ver - ( draw ) ~color =Screen.color - ( incr ) SWP2 #0002 ADD2 DUP2 =Screen.y SWP2 - OVR2 OVR2 LTH2 ^$draw-ver JNZ + .color POK STH2 SWP2 .Screen/x DEO2 STH2r OVR2 .Screen/y DEO2 + &draw-ver + ( draw ) .color PEK .Screen/color DEO + ( incr ) SWP2 #0002 ADD2 DUP2 .Screen/y DEO2 SWP2 + OVR2 OVR2 LTH2 ,&draw-ver JNZ POP2 POP2 RTN @strcpy ( src* dst* -- ) - $loop - ( copy src->dst ) OVR2 OVR2 SWP2 PEK2 ROT ROT POK2 + &loop + ( copy src->dst ) OVR2 OVR2 SWP2 GET ROT ROT PUT ( incr dst ) ++ ( incr src ) SWP2 ++ SWP2 - OVR2 PEK2 #00 NEQ ^$loop JNZ - #00 ROT ROT POK2 POP2 + OVR2 GET #00 NEQ ,&loop JNZ + #00 ROT ROT PUT POP2 RTN -@size_icns +@size_icns [ 0000 0010 0000 0000 ] [ 0000 1038 1000 0000 ] [ 0000 3838 3800 0000 ] @@ -900,7 +902,7 @@ RTN [ 387c fefe fe7c 3800 ] [ 7cfe fefe fefe 7c00 ] -@patt_icns +@patt_icns [ fefe fefe fefe fe00 ] [ fed6 aad6 aad6 fe00 ] [ fe92 82d6 8292 fe00 ] @@ -910,7 +912,7 @@ RTN [ feaa aaaa aaaa fe00 ] [ fe82 fe82 fe82 fe00 ] -@tool_icns +@tool_icns [ c0e0 5028 140a 0400 ] [ e0d0 a844 2212 0c00 ] [ c0b8 4848 7804 0200 ] @@ -918,13 +920,13 @@ RTN [ 3048 8484 4834 0200 ] ( zoom ) [ 3245 8284 4834 0200 ] ( zoom out ) -@view_icns +@view_icns [ ee92 8a84 8a92 ee00 ] [ f68a 92a2 928a f600 ] [ fe82 8244 aa92 ee00 ] [ fe82 92aa 4482 fe00 ] -@brush_icns +@brush_icns [ 0000 0010 0000 0000 ] [ 0000 1028 1000 0000 ] [ 0000 3828 3800 0000 ] @@ -935,7 +937,7 @@ RTN [ 7c82 8282 8282 7c00 ] [ 7cfe fefe fefe 7c00 ] -@bigpixel_icn +@bigpixel_icn [ 5580 0080 0080 0080 ] [ 55ff 7fff 7fff 7fff ] @@ -952,21 +954,21 @@ RTN @save_icn [ fe82 8282 848a f400 ] @blank_icn [ 0000 0000 0000 0000 ] -@untitled_txt [ untitled.bit 00 ] +@untitled_txt [ "untitled.bit 00 ] -@font_hex ( 0-F TODO: should pull from @font instead.. ) +@font_hex ( 0-F TODO: should pull from @font instead.. ) [ 003c 464a 5262 3c00 0018 0808 0808 1c00 003c 4202 3c40 7e00 003c 421c 0242 3c00 000c 1424 447e 0400 007e 407c 0242 3c00 003c 407c 4242 3c00 007e 0204 0810 1000 003c 423c 4242 3c00 003c 4242 3e02 3c00 - 003c 4242 7e42 4200 007c 427c 4242 7c00 - 003c 4240 4042 3c00 007c 4242 4242 7c00 + 003c 4242 7e42 4200 007c 427c 4242 7c00 + 003c 4240 4042 3c00 007c 4242 4242 7c00 007e 4078 4040 7e00 007e 4078 4040 4000 ] -@font ( spectrum-zx font ) +@font ( spectrum-zx font ) [ 0000 0000 0000 0000 0000 2400 7e3c 0000 0000 2400 3c42 0000 0000 6c7c 7c38 1000 0010 387c 7c38 1000 0038 387c 6c10 3800 0010 387c 7c10 3800 0000 0018 1800 0000 diff --git a/projects/software/orca.usm b/projects/software/orca.usm @@ -1,4 +1,4 @@ -( Orca +( Orca TODO - Synthax highlight @@ -21,145 +21,145 @@ %DATA-LOCKS { #3000 } %DATA-TYPES { #4000 } -%GET-CHAR { #24 MOD #00 SWP ,b36clc ADD2 PEK2 } ( b36 -- char ) -%GET-VALUE { #20 SUB #00 SWP ,values ADD2 PEK2 } ( char -- b36 ) +%GET-CHAR { #24 MOD #00 SWP ;b36clc ADD2 GET } ( b36 -- char ) +%GET-VALUE { #20 SUB #00 SWP ;values ADD2 GET } ( char -- b36 ) -%GET-INDEX { #00 SWP #00 ~grid.width MUL2 ROT #00 SWP ADD2 } ( x y -- index ) -%GET-CELL { GET-INDEX DATA-CELLS ADD2 PEK2 } ( x y -- char ) -%SET-CELL { ROT ROT GET-INDEX DATA-CELLS ADD2 POK2 } ( x y char -- ) -%GET-TYPE { GET-INDEX DATA-TYPES ADD2 PEK2 } ( x y -- type ) -%SET-TYPE { ROT ROT GET-INDEX DATA-TYPES ADD2 POK2 } ( x y type -- ) -%GET-LOCK { GET-INDEX DATA-TYPES ADD2 PEK2 } ( x y -- type ) -%SET-LOCK { ROT ROT GET-INDEX DATA-TYPES ADD2 POK2 } ( x y type -- ) +%GET-INDEX { #00 SWP #00 .grid/width PEK MUL2 ROT #00 SWP ADD2 } ( x y -- index ) +%GET-CELL { GET-INDEX DATA-CELLS ADD2 GET } ( x y -- char ) +%SET-CELL { ROT ROT GET-INDEX DATA-CELLS ADD2 PUT } ( x y char -- ) +%GET-TYPE { GET-INDEX DATA-TYPES ADD2 GET } ( x y -- type ) +%SET-TYPE { ROT ROT GET-INDEX DATA-TYPES ADD2 PUT } ( x y type -- ) +%GET-LOCK { GET-INDEX DATA-TYPES ADD2 GET } ( x y -- type ) +%SET-LOCK { ROT ROT GET-INDEX DATA-TYPES ADD2 PUT } ( x y type -- ) %GET-PORT { } ( x y lock -- char ) %SET-PORT { } ( x y char -- ) %GET-CELL-VALUE { GET-CELL GET-VALUE } ( x y -- b36 ) -( variables ) +( devices ) -;timer { byte 1 frame 1 speed 1 } -;grid { width 1 height 1 } -;selection { x1 1 y1 1 x2 1 y2 1 } -;cursor { x 2 y 2 } +|00 @System [ &vector $2 &pad $6 &r $2 &g $2 &b $2 ] +|10 @Console [ &vector $2 &pad $6 &char $1 &byte $1 &short $2 &string $2 ] +|20 @Screen [ &vector $2 &width $2 &height $2 &pad $2 &x $2 &y $2 &addr $2 &color $1 ] +|40 @Controller [ &vector $2 &button $1 &key $1 ] +|60 @Mouse [ &vector $2 &x $2 &y $2 &state $1 &chord $1 ] -( devices ) +( variables ) -|0100 ;System { vector 2 pad 6 r 2 g 2 b 2 } -|0110 ;Console { vector 2 pad 6 char 1 byte 1 short 2 string 2 } -|0120 ;Screen { vector 2 width 2 height 2 pad 2 x 2 y 2 addr 2 color 1 } -|0140 ;Controller { vector 2 button 1 key 1 } -|0160 ;Mouse { vector 2 x 2 y 2 state 1 chord 1 } +@timer [ &byte $1 &frame $1 &speed $1 ] +@grid [ &width $1 &height $1 ] +@selection [ &x1 $1 &y1 $1 &x2 $1 &y2 $1 ] +@cursor [ &x $2 &y $2 ] -|0200 +|0100 - ( theme ) #08f3 =System.r #08fc =System.g #08f9 =System.b - ( vectors ) ,on-button =Controller.vector - ( vectors ) ,on-mouse =Mouse.vector - ( vectors ) ,on-frame =Screen.vector + ( theme ) #08f3 .System/r DEO2 #08fc .System/g DEO2 #08f9 .System/b DEO2 + ( vectors ) ;on-button .Controller/vector DEO2 + ( vectors ) ;on-mouse .Mouse/vector DEO2 + ( vectors ) ;on-frame .Screen/vector DEO2 ( find size ) - ~Screen.width 8/ SWP POP =grid.width - ~Screen.height 8/ SWP POP #02 SUB =grid.height + .Screen/width DEI2 8/ SWP POP .grid/width POK + .Screen/height DEI2 8/ SWP POP #02 SUB .grid/height POK ( fill grid with dots ) - ,start JSR2 - ,redraw JSR2 + ;start JSR2 + ;redraw JSR2 BRK @on-frame - ~timer ++ DUP =timer + .timer PEK ++ DUP .timer POK - ( skip ) #08 EQU ^$tick JNZ BRK $tick + ( skip ) #08 EQU ,&tick JNZ BRK &tick - ~timer.frame ++ =timer.frame + .timer/frame PEK ++ .timer/frame POK - ,run JSR2 + ;run JSR2 - #00 =timer + #00 .timer POK BRK @on-button - ~Controller.key #00 EQU ^$no-key JNZ - ~selection.x1 ~selection.y1 ~Controller.key SET-CELL - ,redraw JSR2 - $no-key + .Controller/key DEI #00 EQU ,&no-key JNZ + .selection/x1 PEK .selection/y1 PEK .Controller/key DEI SET-CELL + ;redraw JSR2 + &no-key ( arrows ) - ~Controller.button #f0 AND - DUP #04 SFT #01 AND #01 NEQ ^$no-up JNZ - ~selection.y1 #00 EQU ^$no-up JNZ - ~selection.y1 -- =selection.y1 - ~selection.y2 -- =selection.y2 $no-up - DUP #05 SFT #01 AND #01 NEQ ^$no-down JNZ - ~selection.y1 ~grid.height -- EQU ^$no-down JNZ - ~selection.y1 ++ =selection.y1 - ~selection.y2 ++ =selection.y2 $no-down - DUP #06 SFT #01 AND #01 NEQ ^$no-left JNZ - ~selection.x1 #00 EQU ^$no-left JNZ - ~selection.x1 -- =selection.x1 - ~selection.x2 -- =selection.x2 $no-left - DUP #07 SFT #01 AND #01 NEQ ^$no-right JNZ - ~selection.x1 ~grid.width -- EQU ^$no-right JNZ - ~selection.x1 ++ =selection.x1 - ~selection.x2 ++ =selection.x2 $no-right + .Controller/button DEI #f0 AND + DUP #04 SFT #01 AND #01 NEQ ,&no-up JNZ + .selection/y1 PEK #00 EQU ,&no-up JNZ + .selection/y1 PEK -- .selection/y1 POK + .selection/y2 PEK -- .selection/y2 POK &no-up + DUP #05 SFT #01 AND #01 NEQ ,&no-down JNZ + .selection/y1 PEK .grid/height PEK -- EQU ,&no-down JNZ + .selection/y1 PEK ++ .selection/y1 POK + .selection/y2 PEK ++ .selection/y2 POK &no-down + DUP #06 SFT #01 AND #01 NEQ ,&no-left JNZ + .selection/x1 PEK #00 EQU ,&no-left JNZ + .selection/x1 PEK -- .selection/x1 POK + .selection/x2 PEK -- .selection/x2 POK &no-left + DUP #07 SFT #01 AND #01 NEQ ,&no-right JNZ + .selection/x1 PEK .grid/width PEK -- EQU ,&no-right JNZ + .selection/x1 PEK ++ .selection/x1 POK + .selection/x2 PEK ++ .selection/x2 POK &no-right POP - ~Controller.key #08 NEQ ^$no-backspace JNZ - ~selection.x1 ~selection.y1 #2e SET-CELL ( put . char ) - $no-backspace + .Controller/key DEI #08 NEQ ,&no-backspace JNZ + .selection/x1 PEK .selection/y1 PEK #2e SET-CELL ( put . char ) + &no-backspace - ,redraw JSR2 + ;redraw JSR2 BRK @on-mouse - ~Mouse.state #00 EQU ^$no-touch JNZ - ~Mouse.x 8/ SWP POP =selection.x1 - ~Mouse.y 8/ SWP POP =selection.y1 - ,redraw JSR2 - $no-touch + .Mouse/state DEI #00 EQU ,&no-touch JNZ + .Mouse/x DEI2 8/ SWP POP .selection/x1 POK + .Mouse/y DEI2 8/ SWP POP .selection/y1 POK + ;redraw JSR2 + &no-touch ( clear last cursor ) - ~cursor.x =Screen.x - ~cursor.y =Screen.y - ,blank_icn =Screen.addr - #30 =Screen.color + .cursor/x PEK2 .Screen/x DEO2 + .cursor/y PEK2 .Screen/y DEO2 + ;blank_icn .Screen/addr DEO2 + #30 .Screen/color DEO ( record cursor positions ) - ~Mouse.x =cursor.x - ~Mouse.y =cursor.y + .Mouse/x DEI2 .cursor/x POK2 + .Mouse/y DEI2 .cursor/y POK2 ( draw new cursor ) - ~cursor.x =Screen.x - ~cursor.y =Screen.y - ,cursor_icn =Screen.addr - #32 ~Mouse.state #01 EQU ADD =Screen.color + .cursor/x PEK2 .Screen/x DEO2 + .cursor/y PEK2 .Screen/y DEO2 + ;cursor_icn .Screen/addr DEO2 + #32 .Mouse/state DEI #01 EQU ADD .Screen/color DEO BRK @start ( -- ) - #00 ~grid.height - $ver - #00 ~grid.width - $hor - ( get x,y ) SWP2 OVR STH SWP2 OVR STHr + #00 .grid/height PEK + &ver + #00 .grid/width PEK + &hor + ( get x,y ) SWP2 OVR STH SWP2 OVR STHr #2e SET-CELL - ( incr ) SWP ++ SWP - DUP2 LTH ^$hor JNZ + ( incr ) SWP ++ SWP + DUP2 LTH ,&hor JNZ POP2 ( incr ) SWP ++ SWP - DUP2 LTH ^$ver JNZ + DUP2 LTH ,&ver JNZ POP2 - #9a =timer.speed + #9a .timer/speed POK RTN @@ -172,7 +172,7 @@ RTN @is-selected ( x y -- flag ) - ~selection.x1 ~selection.y1 EQU2 + .selection/x1 PEK .selection/y1 PEK EQU2 RTN @@ -190,17 +190,17 @@ RTN @get-cell-sprite ( x y -- addr ) - DUP2 GET-CELL + DUP2 GET-CELL ( if character is dot ) - DUP #2e NEQ ^$no-bar JNZ + DUP #2e NEQ ,&no-bar JNZ ( check if x,y is grid ) POP - DUP2 #08 MOD #00 EQU SWP #08 MOD #00 EQU #0101 NEQ2 ^$no-marker8 JNZ POP2 ,marker8_icn RTN $no-marker8 - DUP2 #02 MOD #00 EQU SWP #02 MOD #00 EQU #0101 NEQ2 ^$no-marker4 JNZ POP2 ,marker4_icn RTN $no-marker4 - POP2 ,font RTN - $no-bar + DUP2 #08 MOD #00 EQU SWP #08 MOD #00 EQU #0101 NEQ2 ,&no-marker8 JNZ POP2 ;marker8_icn RTN &no-marker8 + DUP2 #02 MOD #00 EQU SWP #02 MOD #00 EQU #0101 NEQ2 ,&no-marker4 JNZ POP2 ;marker4_icn RTN &no-marker4 + POP2 ;font RTN + &no-bar STH POP2 STHr - #20 SUB #00 SWP #0008 MUL2 ,font ADD2 + #20 SUB #00 SWP #0008 MUL2 ;font ADD2 RTN @@ -211,9 +211,9 @@ RTN POP ( get left ) DUP2 SWP -- SWP GET-CELL-VALUE STH ( get right ) DUP2 SWP ++ SWP GET-CELL-VALUE STH - ( incr y ) ++ + ( incr y ) ++ ( get result ) ADDr STHr - GET-CHAR + GET-CHAR SET-CELL RTN @@ -223,9 +223,9 @@ RTN POP ( get left ) DUP2 SWP -- SWP GET-CELL-VALUE STH ( get right ) DUP2 SWP ++ SWP GET-CELL-VALUE STH - ( incr y ) ++ - ( get result ) SUBr STHr - GET-CHAR + ( incr y ) ++ + ( get result ) SUBr STHr + GET-CHAR SET-CELL ( NOTE: Issue is not with modulo, but with converting ff to 36 ) @@ -236,7 +236,7 @@ RTN POP ++ - #30 ~timer.frame #08 MOD ADD SET-CELL + #30 .timer/frame PEK #08 MOD ADD SET-CELL RTN @@ -304,13 +304,13 @@ RTN STH ( limit ) - DUP #00 NEQ ^$not-edge JNZ - #2a SET-CELL POP STHr RTN - $not-edge + DUP #00 NEQ ,&not-edge JNZ + #2a SET-CELL POP STHr RTN + &not-edge ( collide ) - DUP2 -- GET-CELL #2e EQU ^$not-collide JNZ + DUP2 -- GET-CELL #2e EQU ,&not-collide JNZ #2a SET-CELL POP STHr RTN - $not-collide + &not-collide ( move ) DUP2 STHr SWP -- SWP SET-CELL @@ -344,7 +344,7 @@ RTN @op-s ( x y char -- ) - STH + STH ( clear ) DUP2 #2e SET-CELL ( move ) ++ DUP2 #01 SET-LOCK STHr SET-CELL @@ -373,15 +373,15 @@ RTN STH ( limit ) - OVR #00 NEQ ^$not-edge JNZ - #2a SET-CELL POP STHr RTN - $not-edge + OVR #00 NEQ ,&not-edge JNZ + #2a SET-CELL POP STHr RTN + &not-edge ( collide ) - DUP2 SWP -- SWP GET-CELL #2e EQU ^$not-collide JNZ + DUP2 SWP -- SWP GET-CELL #2e EQU ,&not-collide JNZ #2a SET-CELL POP STHr RTN - $not-collide + &not-collide ( move ) - DUP2 + DUP2 SWP -- SWP STHr SET-CELL #2e SET-CELL @@ -415,149 +415,149 @@ RTN @run-char ( x y char -- ) ( skip dot ) - DUP #2e NEQ ^$not-dot JNZ + DUP #2e NEQ ,&not-dot JNZ POP POP2 RTN - $not-dot + &not-dot ( skip locked ) - ROT ROT DUP2 GET-LOCK #00 EQU ^$not-locked JNZ - POP POP2 RTN - $not-locked + ROT ROT DUP2 GET-LOCK #00 EQU ,&not-locked JNZ + POP POP2 RTN + &not-locked ROT - ( A ) DUP #41 EQU ,op-a JNZ2 ( B ) DUP #42 EQU ,op-b JNZ2 - ( C ) DUP #43 EQU ,op-c JNZ2 ( D ) DUP #44 EQU ,op-d JNZ2 - ( E ) DUP #45 EQU ,op-e JNZ2 ( F ) DUP #46 EQU ,op-f JNZ2 - ( G ) DUP #47 EQU ,op-g JNZ2 ( H ) DUP #48 EQU ,op-h JNZ2 - ( I ) DUP #49 EQU ,op-i JNZ2 ( J ) DUP #4a EQU ,op-j JNZ2 - ( K ) DUP #4b EQU ,op-k JNZ2 ( L ) DUP #4c EQU ,op-l JNZ2 - ( M ) DUP #4d EQU ,op-m JNZ2 ( N ) DUP #4e EQU ,op-n JNZ2 - ( O ) DUP #4f EQU ,op-o JNZ2 ( P ) DUP #50 EQU ,op-p JNZ2 - ( Q ) DUP #51 EQU ,op-q JNZ2 ( R ) DUP #52 EQU ,op-r JNZ2 - ( S ) DUP #53 EQU ,op-s JNZ2 ( T ) DUP #54 EQU ,op-t JNZ2 - ( U ) DUP #55 EQU ,op-u JNZ2 ( V ) DUP #56 EQU ,op-v JNZ2 - ( W ) DUP #57 EQU ,op-w JNZ2 ( X ) DUP #58 EQU ,op-x JNZ2 - ( Y ) DUP #59 EQU ,op-y JNZ2 ( Z ) DUP #5a EQU ,op-z JNZ2 - ( * ) DUP #2a EQU ,op-bang JNZ2 + ( A ) DUP #41 EQU ;op-a JNZ2 ( B ) DUP #42 EQU ;op-b JNZ2 + ( C ) DUP #43 EQU ;op-c JNZ2 ( D ) DUP #44 EQU ;op-d JNZ2 + ( E ) DUP #45 EQU ;op-e JNZ2 ( F ) DUP #46 EQU ;op-f JNZ2 + ( G ) DUP #47 EQU ;op-g JNZ2 ( H ) DUP #48 EQU ;op-h JNZ2 + ( I ) DUP #49 EQU ;op-i JNZ2 ( J ) DUP #4a EQU ;op-j JNZ2 + ( K ) DUP #4b EQU ;op-k JNZ2 ( L ) DUP #4c EQU ;op-l JNZ2 + ( M ) DUP #4d EQU ;op-m JNZ2 ( N ) DUP #4e EQU ;op-n JNZ2 + ( O ) DUP #4f EQU ;op-o JNZ2 ( P ) DUP #50 EQU ;op-p JNZ2 + ( Q ) DUP #51 EQU ;op-q JNZ2 ( R ) DUP #52 EQU ;op-r JNZ2 + ( S ) DUP #53 EQU ;op-s JNZ2 ( T ) DUP #54 EQU ;op-t JNZ2 + ( U ) DUP #55 EQU ;op-u JNZ2 ( V ) DUP #56 EQU ;op-v JNZ2 + ( W ) DUP #57 EQU ;op-w JNZ2 ( X ) DUP #58 EQU ;op-x JNZ2 + ( Y ) DUP #59 EQU ;op-y JNZ2 ( Z ) DUP #5a EQU ;op-z JNZ2 + ( * ) DUP #2a EQU ;op-bang JNZ2 POP POP2 RTN @init ( -- ) - #00 ~grid.height - $ver - #00 ~grid.width - $hor - ( get x,y ) SWP2 OVR STH SWP2 OVR STHr + #00 .grid/height PEK + &ver + #00 .grid/width PEK + &hor + ( get x,y ) SWP2 OVR STH SWP2 OVR STHr ( unlock ) #00 SET-LOCK ( incr ) SWP ++ SWP - DUP2 LTH ^$hor JNZ + DUP2 LTH ,&hor JNZ POP2 ( incr ) SWP ++ SWP - DUP2 LTH ^$ver JNZ + DUP2 LTH ,&ver JNZ POP2 RTN @run ( -- ) - ,init JSR2 + ;init JSR2 - #00 ~grid.height - $ver - #00 ~grid.width - $hor - ( get x,y ) SWP2 OVR STH SWP2 OVR STHr - DUP2 GET-CELL ,run-char JSR2 - ( incr ) SWP ++ SWP - DUP2 LTH ^$hor JNZ + #00 .grid/height PEK + &ver + #00 .grid/width PEK + &hor + ( get x,y ) SWP2 OVR STH SWP2 OVR STHr + DUP2 GET-CELL ;run-char JSR2 + ( incr ) SWP ++ SWP + DUP2 LTH ,&hor JNZ POP2 ( incr ) SWP ++ SWP - DUP2 LTH ^$ver JNZ + DUP2 LTH ,&ver JNZ POP2 - ,redraw JSR2 + ;redraw JSR2 RTN @draw-interface ( -- ) - ~Screen.height #0008 SUB2 =Screen.y + .Screen/height DEI2 #0008 SUB2 .Screen/y DEO2 ( Positionx ) - #0000 =Screen.x - ~selection.x1 - DUP #04 SFT GET-CHAR #20 SUB #00 SWP #0008 MUL2 ,font ADD2 =Screen.addr - #22 =Screen.color - #0008 =Screen.x - #0f AND GET-CHAR #20 SUB #00 SWP #0008 MUL2 ,font ADD2 =Screen.addr - #22 =Screen.color + #0000 .Screen/x DEO2 + .selection/x1 PEK + DUP #04 SFT GET-CHAR #20 SUB #00 SWP #0008 MUL2 ;font ADD2 .Screen/addr DEO2 + #22 .Screen/color DEO + #0008 .Screen/x DEO2 + #0f AND GET-CHAR #20 SUB #00 SWP #0008 MUL2 ;font ADD2 .Screen/addr DEO2 + #22 .Screen/color DEO ( Positiony ) - #0010 =Screen.x - ~selection.y1 - DUP #04 SFT GET-CHAR #20 SUB #00 SWP #0008 MUL2 ,font ADD2 =Screen.addr - #22 =Screen.color - #0018 =Screen.x - #0f AND GET-CHAR #20 SUB #00 SWP #0008 MUL2 ,font ADD2 =Screen.addr - #22 =Screen.color - - #0020 =Screen.x - ,position_icn =Screen.addr - #23 =Screen.color + #0010 .Screen/x DEO2 + .selection/y1 PEK + DUP #04 SFT GET-CHAR #20 SUB #00 SWP #0008 MUL2 ;font ADD2 .Screen/addr DEO2 + #22 .Screen/color DEO + #0018 .Screen/x DEO2 + #0f AND GET-CHAR #20 SUB #00 SWP #0008 MUL2 ;font ADD2 .Screen/addr DEO2 + #22 .Screen/color DEO + + #0020 .Screen/x DEO2 + ;position_icn .Screen/addr DEO2 + #23 .Screen/color DEO ( Frame ) - #0030 =Screen.x - ~timer.frame - DUP #04 SFT GET-CHAR #20 SUB #00 SWP #0008 MUL2 ,font ADD2 =Screen.addr - #22 =Screen.color - #0038 =Screen.x - #0f AND GET-CHAR #20 SUB #00 SWP #0008 MUL2 ,font ADD2 =Screen.addr - #22 =Screen.color - - #0040 =Screen.x - ,beat_icn =Screen.addr - #21 ~timer.frame #08 MOD #00 EQU #02 MUL ADD =Screen.color + #0030 .Screen/x DEO2 + .timer/frame PEK + DUP #04 SFT GET-CHAR #20 SUB #00 SWP #0008 MUL2 ;font ADD2 .Screen/addr DEO2 + #22 .Screen/color DEO + #0038 .Screen/x DEO2 + #0f AND GET-CHAR #20 SUB #00 SWP #0008 MUL2 ;font ADD2 .Screen/addr DEO2 + #22 .Screen/color DEO + + #0040 .Screen/x DEO2 + ;beat_icn .Screen/addr DEO2 + #21 .timer/frame PEK #08 MOD #00 EQU #02 MUL ADD .Screen/color DEO ( Speed ) - #0050 =Screen.x - ~timer.speed - DUP #04 SFT GET-CHAR #20 SUB #00 SWP #0008 MUL2 ,font ADD2 =Screen.addr - #22 =Screen.color - #0058 =Screen.x - #0f AND GET-CHAR #20 SUB #00 SWP #0008 MUL2 ,font ADD2 =Screen.addr - #22 =Screen.color + #0050 .Screen/x DEO2 + .timer/speed PEK + DUP #04 SFT GET-CHAR #20 SUB #00 SWP #0008 MUL2 ;font ADD2 .Screen/addr DEO2 + #22 .Screen/color DEO + #0058 .Screen/x DEO2 + #0f AND GET-CHAR #20 SUB #00 SWP #0008 MUL2 ;font ADD2 .Screen/addr DEO2 + #22 .Screen/color DEO ( TODO: Signal VU ) ( File ) - ~Screen.width #0028 SUB2 =Screen.x - ~Screen.x 8+ =Screen.x ,eye_icns =Screen.addr #21 =Screen.color - ~Screen.x 8+ =Screen.x ,filestate_icn =Screen.addr #21 =Screen.color - ~Screen.x 8+ =Screen.x ,load_icn =Screen.addr #21 =Screen.color - ~Screen.x 8+ =Screen.x ,save_icn =Screen.addr #21 =Screen.color + .Screen/width DEI2 #0028 SUB2 .Screen/x DEO2 + .Screen/x DEI2 8+ .Screen/x DEO2 ;eye_icns .Screen/addr DEO2 #21 .Screen/color DEO + .Screen/x DEI2 8+ .Screen/x DEO2 ;filestate_icn .Screen/addr DEO2 #21 .Screen/color DEO + .Screen/x DEI2 8+ .Screen/x DEO2 ;load_icn .Screen/addr DEO2 #21 .Screen/color DEO + .Screen/x DEI2 8+ .Screen/x DEO2 ;save_icn .Screen/addr DEO2 #21 .Screen/color DEO RTN @redraw ( -- ) - #00 ~grid.height - $ver - ( pos-y ) OVR #00 SWP #0008 MUL2 =Screen.y - #00 ~grid.width - $hor - ( pos-x ) OVR #00 SWP #0008 MUL2 =Screen.x - ( get x,y ) SWP2 OVR STH SWP2 OVR STHr - ( sprite ) DUP2 ,get-cell-sprite JSR2 =Screen.addr - ( draw ) ,is-selected JSR2 #0d MUL #21 ADD =Screen.color - ( incr ) SWP ++ SWP - DUP2 LTH ^$hor JNZ + #00 .grid/height PEK + &ver + ( pos-y ) OVR #00 SWP #0008 MUL2 .Screen/y DEO2 + #00 .grid/width PEK + &hor + ( pos-x ) OVR #00 SWP #0008 MUL2 .Screen/x DEO2 + ( get x,y ) SWP2 OVR STH SWP2 OVR STHr + ( sprite ) DUP2 ;get-cell-sprite JSR2 .Screen/addr DEO2 + ( draw ) ;is-selected JSR2 #0d MUL #21 ADD .Screen/color DEO + ( incr ) SWP ++ SWP + DUP2 LTH ,&hor JNZ POP2 ( incr ) SWP ++ SWP - DUP2 LTH ^$ver JNZ + DUP2 LTH ,&ver JNZ POP2 - ,draw-interface JSR2 + ;draw-interface JSR2 RTN @@ -565,18 +565,18 @@ RTN @values [ - 00 00 00 00 00 00 00 00 - 00 00 00 00 00 00 00 00 + 00 00 00 00 00 00 00 00 + 00 00 00 00 00 00 00 00 00 01 02 03 04 05 06 07 08 09 00 00 00 00 00 00 - 00 0a 0b 0c 0d 0e 0f 10 + 00 0a 0b 0c 0d 0e 0f 10 11 12 13 14 15 16 17 18 19 1a 1b 1c 1d 1e 1f 20 21 22 23 00 00 00 00 00 - 00 0a 0b 0c 0d 0e 0f 10 + 00 0a 0b 0c 0d 0e 0f 10 11 12 13 14 15 16 17 18 19 1a 1b 1c 1d 1e 1f 20 21 22 23 00 00 00 00 00 @@ -608,7 +608,7 @@ RTN [ 0000 0082 4438 0000 ] ( closed ) -@font ( specter8-frag font ) +@font ( specter8-frag font ) [ 0000 0000 0000 0000 0008 0808 0800 0800 0014 1400 0000 0000 0024 7e24 247e 2400