Ported projects to new assembler syntax

All these programs tested working, except for left, which compiles but
doesn't run properly.
This commit is contained in:
Andrew Alderwick 2021-04-23 15:34:03 +01:00
parent e065b8015a
commit 3c758b734b
12 changed files with 2595 additions and 2546 deletions

View File

@ -2,142 +2,146 @@
%RTN { JMP2r } %RTN { JMP2r }
%ABS2 { DUP2 #000f SFT2 EQU #04 JNZ #ffff MUL2 } %ABS2 { DUP2 #000f SFT2 EQU #04 JNZ #ffff MUL2 }
%SCALEX { #0002 DIV2 ~Screen.width #0002 DIV2 ADD2 #0040 SUB2 } %SCALEX { #0002 DIV2 .Screen/width DEI2 #0002 DIV2 ADD2 #0040 SUB2 }
%SCALEY { #0002 DIV2 ~Screen.height #0002 DIV2 ADD2 #0040 SUB2 } %SCALEY { #0002 DIV2 .Screen/height DEI2 #0002 DIV2 ADD2 #0040 SUB2 }
%12HOURS { DUP #0c GTH #0c MUL SUB } %12HOURS { DUP #0c GTH #0c MUL SUB }
%MOD { DUP2 DIV 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 ) ( devices )
|0100 ;System { vector 2 pad 6 r 2 g 2 b 2 } |00 @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 } |20 @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 } |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 ) ( program )
|0200 |0100
( theme ) #0ff8 =System.r #0f08 =System.g #0f08 =System.b ( theme ) #0ff8 .System/r DEO2 #0f08 .System/g DEO2 #0f08 .System/b DEO2
( vectors ) ,on-frame =Screen.vector ( vectors ) ;on-frame .Screen/vector DEO2
BRK BRK
@on-frame @on-frame
#00 =DateTime.refresh #00 .DateTime/refresh DEO
( only draw once per second ) ( only draw once per second )
~DateTime.second ~current.second NEQ #01 JNZ BRK .DateTime/second DEI .current/second PEK NEQ #01 JNZ BRK
~DateTime.second =current.second .DateTime/second DEI .current/second POK
( clear ) ( clear )
#0080 SCALEX #0080 SCALEY ~needles.sx ~needles.sy #00 ,draw-line JSR2 #0080 SCALEX #0080 SCALEY .needles/sx PEK2 .needles/sy PEK2 #00 ;draw-line JSR2
#0080 SCALEX #0080 SCALEY ~needles.mx ~needles.my #00 ,draw-line JSR2 #0080 SCALEX #0080 SCALEY .needles/mx PEK2 .needles/my PEK2 #00 ;draw-line JSR2
#0080 SCALEX #0080 SCALEY ~needles.hx ~needles.hy #00 ,draw-line JSR2 #0080 SCALEX #0080 SCALEY .needles/hx PEK2 .needles/hy PEK2 #00 ;draw-line JSR2
( place ) ( place )
#00 ~DateTime.second #0002 MUL2 ,table ADD2 LDR2 #00 .DateTime/second DEI #0002 MUL2 ;table ADD2 GET2
#00 SWP SCALEY =needles.sy #00 SWP SCALEY .needles/sy POK2
#00 SWP SCALEX =needles.sx #00 SWP SCALEX .needles/sx POK2
#00 ~DateTime.minute #0002 MUL2 ,table ADD2 LDR2 #00 .DateTime/minute DEI #0002 MUL2 ;table ADD2 GET2
#00 SWP #0004 DIV2 #0003 MUL2 #0020 ADD2 SCALEY =needles.my #00 SWP #0004 DIV2 #0003 MUL2 #0020 ADD2 SCALEY .needles/my POK2
#00 SWP #0004 DIV2 #0003 MUL2 #0020 ADD2 SCALEX =needles.mx #00 SWP #0004 DIV2 #0003 MUL2 #0020 ADD2 SCALEX .needles/mx POK2
#00 ~DateTime.hour 12HOURS #05 MUL #0002 MUL2 ,table ADD2 LDR2 #00 .DateTime/hour DEI 12HOURS #05 MUL #0002 MUL2 ;table ADD2 GET2
#00 SWP #0002 DIV2 #0040 ADD2 SCALEY =needles.hy #00 SWP #0002 DIV2 #0040 ADD2 SCALEY .needles/hy POK2
#00 SWP #0002 DIV2 #0040 ADD2 SCALEX =needles.hx #00 SWP #0002 DIV2 #0040 ADD2 SCALEX .needles/hx POK2
( needles ) ( needles )
#0080 SCALEX #0080 SCALEY ~needles.sx ~needles.sy #02 ,draw-line JSR2 #0080 SCALEX #0080 SCALEY .needles/sx PEK2 .needles/sy PEK2 #02 ;draw-line JSR2
#0080 SCALEX #0080 SCALEY ~needles.mx ~needles.my #01 ,draw-line JSR2 #0080 SCALEX #0080 SCALEY .needles/mx PEK2 .needles/my PEK2 #01 ;draw-line JSR2
#0080 SCALEX #0080 SCALEY ~needles.hx ~needles.hy #03 ,draw-line JSR2 #0080 SCALEX #0080 SCALEY .needles/hx PEK2 .needles/hy PEK2 #03 ;draw-line JSR2
( circle ) ( circle )
#00 #3c #00 #3c
$loop &loop
( load ) OVR #00 SWP #0002 MUL2 ,table ADD2 LDR2 ( load ) OVR #00 SWP #0002 MUL2 ;table ADD2 GET2
#00 SWP SCALEY =Screen.y #00 SWP SCALEY .Screen/y DEO2
#00 SWP SCALEX =Screen.x #00 SWP SCALEX .Screen/x DEO2
OVR #0f MOD #00 EQU #01 ADD =Screen.color OVR #0f MOD #00 EQU #01 ADD .Screen/color DEO
( incr ) SWP #01 ADD SWP ( incr ) SWP #01 ADD SWP
DUP2 LTH ^$loop JNZ DUP2 LTH ,&loop JNZ
POP2 POP2
( display ) ( display )
~Screen.height #0002 DIV2 #0048 ADD2 =Screen.y .Screen/height DEI2 #0002 DIV2 #0048 ADD2 .Screen/y DEO2
~Screen.width #0002 DIV2 .Screen/width DEI2 #0002 DIV2
DUP2 #0020 SUB2 =Screen.x DUP2 #0020 SUB2 .Screen/x DEO2
,font_hex #00 ~DateTime.hour #0a DIV #08 MUL ADD2 =Screen.addr ;font_hex #00 .DateTime/hour DEI #0a DIV #08 MUL ADD2 .Screen/addr DEO2
#22 =Screen.color #22 .Screen/color DEO
DUP2 #0018 SUB2 =Screen.x DUP2 #0018 SUB2 .Screen/x DEO2
,font_hex #00 ~DateTime.hour #0a MOD #08 MUL ADD2 =Screen.addr ;font_hex #00 .DateTime/hour DEI #0a MOD #08 MUL ADD2 .Screen/addr DEO2
#22 =Screen.color #22 .Screen/color DEO
DUP2 #0008 SUB2 =Screen.x DUP2 #0008 SUB2 .Screen/x DEO2
,font_hex #00 ~DateTime.minute #0a DIV #08 MUL ADD2 =Screen.addr ;font_hex #00 .DateTime/minute DEI #0a DIV #08 MUL ADD2 .Screen/addr DEO2
#22 =Screen.color #22 .Screen/color DEO
DUP2 =Screen.x DUP2 .Screen/x DEO2
,font_hex #00 ~DateTime.minute #0a MOD #08 MUL ADD2 =Screen.addr ;font_hex #00 .DateTime/minute DEI #0a MOD #08 MUL ADD2 .Screen/addr DEO2
#22 =Screen.color #22 .Screen/color DEO
DUP2 #0010 ADD2 =Screen.x DUP2 #0010 ADD2 .Screen/x DEO2
,font_hex #00 ~DateTime.second #0a DIV #08 MUL ADD2 =Screen.addr ;font_hex #00 .DateTime/second DEI #0a DIV #08 MUL ADD2 .Screen/addr DEO2
#22 =Screen.color #22 .Screen/color DEO
DUP2 #0018 ADD2 =Screen.x DUP2 #0018 ADD2 .Screen/x DEO2
,font_hex #00 ~DateTime.second #0a MOD #08 MUL ADD2 =Screen.addr ;font_hex #00 .DateTime/second DEI #0a MOD #08 MUL ADD2 .Screen/addr DEO2
#22 =Screen.color #22 .Screen/color DEO
POP2 POP2
BRK BRK
@draw-line ( x1 y1 x2 y2 color -- ) @draw-line ( x1 y1 x2 y2 color -- )
( load ) =color =line.y0 =line.x0 =line.y =line.x ( load ) .color POK .line/y0 POK2 .line/x0 POK2 .line/y POK2 .line/x POK2
~line.x0 ~line.x SUB2 ABS2 =line.dx .line/x0 PEK2 .line/x PEK2 SUB2 ABS2 .line/dx POK2
~line.y0 ~line.y SUB2 ABS2 #0000 SWP2 SUB2 =line.dy .line/y0 PEK2 .line/y PEK2 SUB2 ABS2 #0000 SWP2 SUB2 .line/dy POK2
#ffff #00 ~line.x ~line.x0 LTS2 #0002 MUL2 ADD2 =line.sx #ffff #00 .line/x PEK2 .line/x0 PEK2 LTS2 #0002 MUL2 ADD2 .line/sx POK2
#ffff #00 ~line.y ~line.y0 LTS2 #0002 MUL2 ADD2 =line.sy #ffff #00 .line/y PEK2 .line/y0 PEK2 LTS2 #0002 MUL2 ADD2 .line/sy POK2
~line.dx ~line.dy ADD2 =line.e1 .line/dx PEK2 .line/dy PEK2 ADD2 .line/e1 POK2
$loop &loop
~line.x =Screen.x ~line.y =Screen.y ~color =Screen.color .line/x PEK2 .Screen/x DEO2 .line/y PEK2 .Screen/y DEO2 .color PEK .Screen/color DEO
~line.x ~line.x0 EQU2 ~line.y ~line.y0 EQU2 #0101 EQU2 ^$end JNZ .line/x PEK2 .line/x0 PEK2 EQU2 .line/y PEK2 .line/y0 PEK2 EQU2 #0101 EQU2 ,&end JNZ
~line.e1 #0002 MUL2 =line.e2 .line/e1 PEK2 #0002 MUL2 .line/e2 POK2
~line.e2 ~line.dy LTS2 ^$skipy JNZ .line/e2 PEK2 .line/dy PEK2 LTS2 ,&skipy JNZ
~line.e1 ~line.dy ADD2 =line.e1 .line/e1 PEK2 .line/dy PEK2 ADD2 .line/e1 POK2
~line.x ~line.sx ADD2 =line.x .line/x PEK2 .line/sx PEK2 ADD2 .line/x POK2
$skipy &skipy
~line.e2 ~line.dx GTS2 ^$skipx JNZ .line/e2 PEK2 .line/dx PEK2 GTS2 ,&skipx JNZ
~line.e1 ~line.dx ADD2 =line.e1 .line/e1 PEK2 .line/dx PEK2 ADD2 .line/e1 POK2
~line.y ~line.sy ADD2 =line.y .line/y PEK2 .line/sy PEK2 ADD2 .line/y POK2
$skipx &skipx
,$loop JMP2 ;&loop JMP2
$end &end
RTN RTN
@table ( 60 positions on a circle in bytes ) @table ( 60 positions on a circle in bytes )
[ [
8000 8d00 9a02 a706 b40b c011 cb18 d520 8000 8d00 9a02 a706 b40b c011 cb18 d520
df2a e734 ee40 f44b f958 fd65 ff72 ff80 df2a e734 ee40 f44b f958 fd65 ff72 ff80
ff8d fd9a f9a7 f4b4 eec0 e7cb dfd5 d5df ff8d fd9a f9a7 f4b4 eec0 e7cb dfd5 d5df
cbe7 c0ee b4f4 a7f9 9afd 8dff 80ff 72ff cbe7 c0ee b4f4 a7f9 9afd 8dff 80ff 72ff
65fd 58f9 4bf4 40ee 34e7 2adf 20d5 18cb 65fd 58f9 4bf4 40ee 34e7 2adf 20d5 18cb
11c0 0bb4 06a7 029a 008d 0080 0072 0265 11c0 0bb4 06a7 029a 008d 0080 0072 0265
0658 0b4b 113f 1834 202a 2a20 3418 3f11 0658 0b4b 113f 1834 202a 2a20 3418 3f11
4b0b 5806 6502 7200 4b0b 5806 6502 7200
] ]
@font_hex ( 0-F ) @font_hex ( 0-F )
[ [
007c 8282 8282 827c 0030 1010 1010 1010 007c 8282 8282 827c 0030 1010 1010 1010
007c 8202 7c80 80fe 007c 8202 1c02 827c 007c 8202 7c80 80fe 007c 8202 1c02 827c
000c 1424 4484 fe04 00fe 8080 7c02 827c 000c 1424 4484 fe04 00fe 8080 7c02 827c
007c 8280 fc82 827c 007c 8202 1e02 0202 007c 8280 fc82 827c 007c 8202 1e02 0202
007c 8282 7c82 827c 007c 8282 7e02 827c 007c 8282 7c82 827c 007c 8282 7e02 827c
007c 8202 7e82 827e 00fc 8282 fc82 82fc 007c 8202 7e82 827e 00fc 8282 fc82 82fc
007c 8280 8080 827c 00fc 8282 8282 82fc 007c 8280 8080 827c 00fc 8282 8282 82fc
007c 8280 f080 827c 007c 8280 f080 8080 007c 8280 f080 827c 007c 8280 f080 8080
] ]

View File

@ -1,249 +1,249 @@
( a blank file ) ( mini music tracker )
%RTN { JMP2r } %RTN { JMP2r }
%8+ { #0008 ADD2 } %8- { #0008 SUB2 } %8+ { #0008 ADD2 } %8- { #0008 SUB2 }
%8* { #0008 MUL2 } %8/ { #0008 DIV2 } %8* { #0008 MUL2 } %8/ { #0008 DIV2 }
%++ { #0001 ADD2 } %++ { #0001 ADD2 }
%MOD { DUP2 DIV MUL SUB } %MOD { DUP2 DIV MUL SUB }
%TRACK { ,track.ch1 #00 ~track.active #0020 MUL2 ADD2 } %TRACK { ;track/ch1 #00 .track/active PEK #0020 MUL2 ADD2 }
%SOUND { STH #00 =Audio.value STHr #00 =Audio.delay } %SOUND { STH #00 .Audio/value DEO2 STHr #00 .Audio/delay DEO2 }
%SOUND_FINISH { #00 =Audio.finish } %SOUND_FINISH { #00 .Audio/finish DEO }
( variables ) ( variables )
;pointer { x 2 y 2 } @pointer [ &x $2 &y $2 ]
;color { byte 1 } @color [ &byte $1 ]
;rect { x1 2 y1 2 x2 2 y2 2 } @rect [ &x1 $2 &y1 $2 &x2 $2 &y2 $2 ]
;trkframe { 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 } @chnframe [ &x1 $2 &y1 $2 &x2 $2 &y2 $2 ]
;ctlframe { 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 } @label [ &x $2 &y $2 &color $1 &addr $2 ]
;knob { x 2 y 2 value 1 } @knob [ &x $2 &y $2 &value $1 ]
;head { pos 1 } @head [ &pos $1 ]
;track { active 1 ch1 20 ch2 20 ch3 20 ch4 20 } @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 } @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 } @volume [ &ch1 $1 &ch2 $1 &ch3 $1 &ch4 $1 ]
( devices ) ( devices )
|0100 ;System { vector 2 pad 6 r 2 g 2 b 2 } |00 @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 } |10 @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 } |20 @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 } |30 @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 } |40 @Controller [ &vector $2 &button $1 &key $1 ]
|0160 ;Mouse { vector 2 x 2 y 2 state 1 chord 1 } |60 @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 } |70 @File [ &vector $2 &success $2 &offset $2 &pad $2 &name $2 &length $2 &load $2 &save $2 ]
( vectors ) ( vectors )
|0200 |0100
( theme ) #e0fa =System.r #30fa =System.g #30fa =System.b ( theme ) #e0fa .System/r DEO2 #30fa .System/g DEO2 #30fa .System/b DEO2
( vectors ) ,on-screen =Screen.vector ( vectors ) ;on-screen .Screen/vector DEO2
( vectors ) ,on-mouse =Mouse.vector ( vectors ) ;on-mouse .Mouse/vector DEO2
( vectors ) ,on-button =Controller.vector ( vectors ) ;on-button .Controller/vector DEO2
~Screen.width #0002 DIV2 DUP2 #0080 SUB2 =trkframe.x1 .Screen/width DEI2 #0002 DIV2 DUP2 #0080 SUB2 .trkframe/x1 POK2
#0080 ADD2 =trkframe.x2 #0080 ADD2 .trkframe/x2 POK2
~Screen.height #0002 DIV2 DUP2 #0038 SUB2 #0010 SUB2 =trkframe.y1 .Screen/height DEI2 #0002 DIV2 DUP2 #0038 SUB2 #0010 SUB2 .trkframe/y1 POK2
#0038 ADD2 #0010 SUB2 =trkframe.y2 #0038 ADD2 #0010 SUB2 .trkframe/y2 POK2
~trkframe.x1 =chnframe.x1 ~trkframe.y2 =chnframe.y1 .trkframe/x1 PEK2 .chnframe/x1 POK2 .trkframe/y2 PEK2 .chnframe/y1 POK2
~chnframe.x1 #0030 ADD2 =chnframe.x2 ~chnframe.y1 #0030 ADD2 =chnframe.y2 .chnframe/x1 PEK2 #0030 ADD2 .chnframe/x2 POK2 .chnframe/y1 PEK2 #0030 ADD2 .chnframe/y2 POK2
~chnframe.x2 =ctlframe.x1 ~chnframe.y1 =ctlframe.y1 .chnframe/x2 PEK2 .ctlframe/x1 POK2 .chnframe/y1 PEK2 .ctlframe/y1 POK2
~trkframe.x2 =ctlframe.x2 ~chnframe.y2 =ctlframe.y2 .trkframe/x2 PEK2 .ctlframe/x2 POK2 .chnframe/y2 PEK2 .ctlframe/y2 POK2
( default settings ) ( default settings )
,adsr-envelope =Audio.envelope ;adsr-envelope .Audio/envelope DEO2
#00 =adsr.ch1a #40 =adsr.ch1d #80 =adsr.ch1s #c0 =adsr.ch1r #88 =volume.ch1 #00 .adsr/ch1a POK #40 .adsr/ch1d POK #80 .adsr/ch1s POK #c0 .adsr/ch1r POK #88 .volume/ch1 POK
#10 =adsr.ch2a #50 =adsr.ch2d #90 =adsr.ch2s #d0 =adsr.ch2r #88 =volume.ch2 #10 .adsr/ch2a POK #50 .adsr/ch2d POK #90 .adsr/ch2s POK #d0 .adsr/ch2r POK #88 .volume/ch2 POK
#20 =adsr.ch3a #60 =adsr.ch3d #a0 =adsr.ch3s #e0 =adsr.ch3r #88 =volume.ch3 #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-timeline JSR2
,draw-controls JSR2 ;draw-controls JSR2
,draw-channels JSR2 ;draw-channels JSR2
BRK BRK
@on-screen ( -> ) @on-screen ( -> )
,move-head JSR2 ;move-head JSR2
~head.pos #08 MOD #00 NEQ ^$skip JNZ .head/pos PEK #08 MOD #00 NEQ ,&skip JNZ
,bang JSR2 ;bang JSR2
$skip &skip
BRK BRK
@on-mouse ( -> ) @on-mouse ( -> )
~Mouse.state #00 EQU ,$click-end JNZ2 .Mouse/state DEI #00 EQU ;&click-end JNZ2
~Mouse.x ~trkframe.x1 GTH2 ~Mouse.x ~trkframe.x2 LTH2 #0101 EQU2 .Mouse/x DEI2 .trkframe/x1 PEK2 GTH2 .Mouse/x DEI2 .trkframe/x2 PEK2 LTH2 #0101 EQU2
~Mouse.y ~trkframe.y1 GTH2 ~Mouse.y ~trkframe.y2 LTH2 #0101 EQU2 .Mouse/y DEI2 .trkframe/y1 PEK2 GTH2 .Mouse/y DEI2 .trkframe/y2 PEK2 LTH2 #0101 EQU2
#0101 EQU2 ,touch-trk JNZ2 #0101 EQU2 ;touch-trk JNZ2
~Mouse.x ~chnframe.x1 GTH2 ~Mouse.x ~chnframe.x2 LTH2 #0101 EQU2 .Mouse/x DEI2 .chnframe/x1 PEK2 GTH2 .Mouse/x DEI2 .chnframe/x2 PEK2 LTH2 #0101 EQU2
~Mouse.y ~chnframe.y1 8+ GTH2 ~Mouse.y ~chnframe.y2 8- 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 #0101 EQU2 ;touch-chn JNZ2
~Mouse.x ~ctlframe.x1 GTH2 ~Mouse.x ~ctlframe.x2 LTH2 #0101 EQU2 .Mouse/x DEI2 .ctlframe/x1 PEK2 GTH2 .Mouse/x DEI2 .ctlframe/x2 PEK2 LTH2 #0101 EQU2
~Mouse.y ~ctlframe.y1 8+ GTH2 ~Mouse.y ~ctlframe.y2 8- 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 #0101 EQU2 ;touch-ctl JNZ2
$click-end &click-end
,draw-cursor JSR2 ;draw-cursor JSR2
BRK BRK
@on-button ( -> ) @on-button ( -> )
~Controller.key .Controller/key DEI
DUP #61 NEQ ^$no-c JNZ DUP #61 NEQ ,&no-c JNZ
,notes PEK2 ,play JSR2 $no-c ;notes GET ;play JSR2 &no-c
DUP #73 NEQ ^$no-d JNZ DUP #73 NEQ ,&no-d JNZ
,notes #0001 ADD2 PEK2 ,play JSR2 $no-d ;notes #0001 ADD2 GET ;play JSR2 &no-d
DUP #64 NEQ ^$no-e JNZ DUP #64 NEQ ,&no-e JNZ
,notes #0002 ADD2 PEK2 ,play JSR2 $no-e ;notes #0002 ADD2 GET ;play JSR2 &no-e
DUP #66 NEQ ^$no-f JNZ DUP #66 NEQ ,&no-f JNZ
,notes #0003 ADD2 PEK2 ,play JSR2 $no-f ;notes #0003 ADD2 GET ;play JSR2 &no-f
DUP #67 NEQ ^$no-g JNZ DUP #67 NEQ ,&no-g JNZ
,notes #0004 ADD2 PEK2 ,play JSR2 $no-g ;notes #0004 ADD2 GET ;play JSR2 &no-g
DUP #68 NEQ ^$no-a JNZ DUP #68 NEQ ,&no-a JNZ
,notes #0005 ADD2 PEK2 ,play JSR2 $no-a ;notes #0005 ADD2 GET ;play JSR2 &no-a
DUP #6a NEQ ^$no-b JNZ DUP #6a NEQ ,&no-b JNZ
,notes #0006 ADD2 PEK2 ,play JSR2 $no-b ;notes #0006 ADD2 GET ;play JSR2 &no-b
DUP #6b NEQ ^$no-c2 JNZ DUP #6b NEQ ,&no-c2 JNZ
,notes #0007 ADD2 PEK2 ,play JSR2 $no-c2 ;notes #0007 ADD2 GET ;play JSR2 &no-c2
POP POP
BRK BRK
@play ( pitch -- ) @play ( pitch -- )
#80 ORA =Audio.pitch #80 ORA .Audio/pitch DEO
,triangle-wave =Audio.wave ;triangle-wave .Audio/wave DEO2
~track.active =Audio.play .track/active PEK .Audio/play DEO
RTN RTN
@touch-trk ( -- ) @touch-trk ( -- )
,clear-notes JSR2 ;clear-notes JSR2
( get note ) ( get note )
#0e ~Mouse.y ~trkframe.y1 SUB2 SWP POP #08 DIV SUB #0e .Mouse/y DEI2 .trkframe/y1 PEK2 SUB2 SWP POP #08 DIV SUB
~Mouse.state #10 NEQ ^$no-erase JNZ POP #00 $no-erase .Mouse/state DEI #10 NEQ ,&no-erase JNZ POP #00 &no-erase
( edit note ) ( edit note )
TRACK #00 ~Mouse.x ~trkframe.x1 SUB2 SWP POP #08 DIV ADD2 POK2 TRACK #00 .Mouse/x DEI2 .trkframe/x1 PEK2 SUB2 SWP POP #08 DIV ADD2 PUT
( release ) #00 =Mouse.state ( release ) #00 .Mouse/state DEO
,draw-notes JSR2 ;draw-notes JSR2
BRK BRK
@touch-chn ( -- ) @touch-chn ( -- )
,clear-notes JSR2 ;clear-notes JSR2
( save ) ~Mouse.y ~chnframe.y1 SUB2 SWP POP #08 DIV #01 SUB =track.active ( save ) .Mouse/y DEI2 .chnframe/y1 PEK2 SUB2 SWP POP #08 DIV #01 SUB .track/active POK
( release ) #00 =Mouse.state ( release ) #00 .Mouse/state DEO
,draw-channels JSR2 ;draw-channels JSR2
,draw-notes JSR2 ;draw-notes JSR2
,draw-controls JSR2 ;draw-controls JSR2
BRK BRK
@touch-ctl ( -- ) @touch-ctl ( -- )
~Mouse.x ~ctlframe.x1 SUB2 8- 8/ SWP POP #02 DIV .Mouse/x DEI2 .ctlframe/x1 PEK2 SUB2 8- 8/ SWP POP #02 DIV
DUP #00 NEQ ^$no-a JNZ DUP #00 NEQ ,&no-a JNZ
,adsr #00 ~track.active #04 MUL ADD2 PEK2 ;adsr #00 .track/active PEK #04 MUL ADD2 GET
#10 ~Mouse.state #10 EQU #e0 MUL ADD ADD #10 .Mouse/state DEI #10 EQU #e0 MUL ADD ADD
,adsr #00 ~track.active #04 MUL ADD2 POK2 $no-a ;adsr #00 .track/active PEK #04 MUL ADD2 PUT &no-a
DUP #01 NEQ ^$no-d JNZ DUP #01 NEQ ,&no-d JNZ
,adsr #00 ~track.active #04 MUL ADD2 #0001 ADD2 PEK2 ;adsr #00 .track/active PEK #04 MUL ADD2 #0001 ADD2 GET
#10 ~Mouse.state #10 EQU #e0 MUL ADD ADD #10 .Mouse/state DEI #10 EQU #e0 MUL ADD ADD
,adsr #00 ~track.active #04 MUL ADD2 #0001 ADD2 POK2 $no-d ;adsr #00 .track/active PEK #04 MUL ADD2 #0001 ADD2 PUT &no-d
DUP #02 NEQ ^$no-s JNZ DUP #02 NEQ ,&no-s JNZ
,adsr #00 ~track.active #04 MUL ADD2 #0002 ADD2 PEK2 ;adsr #00 .track/active PEK #04 MUL ADD2 #0002 ADD2 GET
#10 ~Mouse.state #10 EQU #e0 MUL ADD ADD #10 .Mouse/state DEI #10 EQU #e0 MUL ADD ADD
,adsr #00 ~track.active #04 MUL ADD2 #0002 ADD2 POK2 $no-s ;adsr #00 .track/active PEK #04 MUL ADD2 #0002 ADD2 PUT &no-s
DUP #03 NEQ ^$no-r JNZ DUP #03 NEQ ,&no-r JNZ
,adsr #00 ~track.active #04 MUL ADD2 #0003 ADD2 PEK2 ;adsr #00 .track/active PEK #04 MUL ADD2 #0003 ADD2 GET
#10 ~Mouse.state #10 EQU #e0 MUL ADD ADD #10 .Mouse/state DEI #10 EQU #e0 MUL ADD ADD
,adsr #00 ~track.active #04 MUL ADD2 #0003 ADD2 POK2 $no-r ;adsr #00 .track/active PEK #04 MUL ADD2 #0003 ADD2 PUT &no-r
DUP #05 NEQ ^$no-left JNZ DUP #05 NEQ ,&no-left JNZ
,volume #00 ~track.active ADD2 PEK2 ;volume #00 .track/active PEK ADD2 GET
#10 ~Mouse.state #10 EQU #e0 MUL ADD ADD #10 .Mouse/state DEI #10 EQU #e0 MUL ADD ADD
,volume #00 ~track.active ADD2 POK2 $no-left ;volume #00 .track/active PEK ADD2 PUT &no-left
DUP #06 NEQ ^$no-right JNZ DUP #06 NEQ ,&no-right JNZ
,volume #00 ~track.active ADD2 PEK2 ;volume #00 .track/active PEK ADD2 GET
DUP #f0 AND STH #01 ~Mouse.state #10 EQU #0e MUL ADD ADD #0f AND STHr ADD DUP #f0 AND STH #01 .Mouse/state DEI #10 EQU #0e MUL ADD ADD #0f AND STHr ADD
,volume #00 ~track.active ADD2 POK2 $no-right ;volume #00 .track/active PEK ADD2 PUT &no-right
POP POP
( release ) #00 =Mouse.state ( release ) #00 .Mouse/state DEO
,draw-controls JSR2 ;draw-controls JSR2
BRK BRK
@bang ( -- ) @bang ( -- )
,track.ch1 #00 ~head.pos #08 DIV ADD2 PEK2 ;track/ch1 #00 .head/pos PEK #08 DIV ADD2 GET
#01 SUB #01 SUB
DUP #ff NEQ ^$skip1 JNZ DUP #ff NEQ ,&skip1 JNZ
POP ^$listen2 JMP POP ,&listen2 JMP
$skip1 &skip1
#00 SWP ,notes ADD2 PEK2 #80 ORA =Audio.pitch #00 SWP ;notes ADD2 GET #80 ORA .Audio/pitch DEO
~volume.ch1 =Audio.volume .volume/ch1 PEK .Audio/volume DEO
,square-wave =Audio.wave ;square-wave .Audio/wave DEO2
#00 =Audio.play #00 .Audio/play DEO
$listen2 &listen2
,track.ch2 #00 ~head.pos #08 DIV ADD2 PEK2 ;track/ch2 #00 .head/pos PEK #08 DIV ADD2 GET
#01 SUB #01 SUB
DUP #ff NEQ ^$skip2 JNZ DUP #ff NEQ ,&skip2 JNZ
POP ^$listen3 JMP POP ,&listen3 JMP
$skip2 &skip2
#00 SWP ,notes ADD2 PEK2 #80 ORA =Audio.pitch #00 SWP ;notes ADD2 GET #80 ORA .Audio/pitch DEO
~volume.ch2 =Audio.volume .volume/ch2 PEK .Audio/volume DEO
,square-wave =Audio.wave ;square-wave .Audio/wave DEO2
#01 =Audio.play #01 .Audio/play DEO
$listen3 &listen3
,track.ch3 #00 ~head.pos #08 DIV ADD2 PEK2 ;track/ch3 #00 .head/pos PEK #08 DIV ADD2 GET
#01 SUB #01 SUB
DUP #ff NEQ ^$skip3 JNZ DUP #ff NEQ ,&skip3 JNZ
POP ^$end JMP POP ,&end JMP
$skip3 &skip3
#00 SWP ,notes ADD2 PEK2 #80 ORA =Audio.pitch #00 SWP ;notes ADD2 GET #80 ORA .Audio/pitch DEO
~volume.ch3 =Audio.volume .volume/ch3 PEK .Audio/volume DEO
,triangle-wave =Audio.wave ;triangle-wave .Audio/wave DEO2
#02 =Audio.play #02 .Audio/play DEO
$end &end
RTN RTN
@move-head ( -- ) @move-head ( -- )
( clear ) ( clear )
~trkframe.y1 8- =Screen.y .trkframe/y1 PEK2 8- .Screen/y DEO2
~trkframe.x1 #00 ~head.pos ADD2 =Screen.x .trkframe/x1 PEK2 #00 .head/pos PEK ADD2 .Screen/x DEO2
,head_icn =Screen.addr ;head_icn .Screen/addr DEO2
#20 =Screen.color #20 .Screen/color DEO
( incr ) ~head.pos #01 ADD =head.pos ( incr ) .head/pos PEK #01 ADD .head/pos POK
~trkframe.x1 #00 ~head.pos ADD2 =Screen.x .trkframe/x1 PEK2 #00 .head/pos PEK ADD2 .Screen/x DEO2
,head_icn =Screen.addr ;head_icn .Screen/addr DEO2
#21 ( if note ) TRACK #00 ~head.pos #08 DIV ADD2 PEK2 #00 NEQ ADD =Screen.color #21 ( if note ) TRACK #00 .head/pos PEK #08 DIV ADD2 GET #00 NEQ ADD .Screen/color DEO
RTN RTN
@clear-notes ( -- ) @clear-notes ( -- )
#00 #20 #00 #20
$loop &loop
( load ) OVR #00 SWP TRACK ADD2 PEK2 ( load ) OVR #00 SWP TRACK ADD2 GET
DUP STH #00 SWP #0e SWP SUB 8* ~trkframe.y1 ADD2 =Screen.y DUP STH #00 SWP #0e SWP SUB 8* .trkframe/y1 PEK2 ADD2 .Screen/y DEO2
OVR #00 SWP 8* ~trkframe.x1 ADD2 =Screen.x OVR #00 SWP 8* .trkframe/x1 PEK2 ADD2 .Screen/x DEO2
STHr #00 EQU ^$skip JNZ STHr #00 EQU ,&skip JNZ
#20 =Screen.color #20 .Screen/color DEO
$skip &skip
( incr ) SWP #01 ADD SWP ( incr ) SWP #01 ADD SWP
DUP2 LTH ^$loop JNZ DUP2 LTH ,&loop JNZ
POP2 POP2
RTN RTN
@ -251,63 +251,63 @@ RTN
@draw-notes ( -- ) @draw-notes ( -- )
#00 #20 #00 #20
$notes-loop &notes-loop
( load ) OVR #00 SWP TRACK ADD2 PEK2 ( load ) OVR #00 SWP TRACK ADD2 GET
DUP STH #00 SWP #0e SWP SUB 8* ~trkframe.y1 ADD2 =Screen.y DUP STH #00 SWP #0e SWP SUB 8* .trkframe/y1 PEK2 ADD2 .Screen/y DEO2
OVR #00 SWP 8* ~trkframe.x1 ADD2 =Screen.x OVR #00 SWP 8* .trkframe/x1 PEK2 ADD2 .Screen/x DEO2
,note_icn =Screen.addr ;note_icn .Screen/addr DEO2
STHr #00 EQU ^$skip JNZ STHr #00 EQU ,&skip JNZ
#25 =Screen.color #25 .Screen/color DEO
$skip &skip
( incr ) SWP #01 ADD SWP ( incr ) SWP #01 ADD SWP
DUP2 LTH ^$notes-loop JNZ DUP2 LTH ,&notes-loop JNZ
POP2 POP2
,draw-bars JSR2 ;draw-bars JSR2
RTN RTN
@draw-bars ( -- ) @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 ) ( grid )
~trkframe.y1 #0010 SUB2 =Screen.y .trkframe/y1 PEK2 #0010 SUB2 .Screen/y DEO2
,font_hex =Screen.addr ;font_hex .Screen/addr DEO2
#0000 #0100 #0000 #0100
$loop &loop
OVR2 SWP POP #02 DIV #0f AND #00 NEQ ^$skip JNZ OVR2 SWP POP #02 DIV #0f AND #00 NEQ ,&skip JNZ
OVR2 ~trkframe.x1 ADD2 =Screen.x OVR2 .trkframe/x1 PEK2 ADD2 .Screen/x DEO2
~trkframe.y1 #0010 SUB2 =Screen.y .trkframe/y1 PEK2 #0010 SUB2 .Screen/y DEO2
#22 =Screen.color #22 .Screen/color DEO
~Screen.addr 8+ =Screen.addr .Screen/addr DEI2 8+ .Screen/addr DEO2
OVR2 ~trkframe.x1 ADD2 ~trkframe.y1 ++ ~trkframe.y2 #01 ,line-vertical-dotted JSR2 OVR2 .trkframe/x1 PEK2 ADD2 .trkframe/y1 PEK2 ++ .trkframe/y2 PEK2 #01 ;line-vertical-dotted JSR2
$skip &skip
OVR2 ~trkframe.x1 ADD2 ~trkframe.y1 ~trkframe.y2 #01 ,line-vertical-dotted JSR2 OVR2 .trkframe/x1 PEK2 ADD2 .trkframe/y1 PEK2 .trkframe/y2 PEK2 #01 ;line-vertical-dotted JSR2
SWP2 8+ SWP2 SWP2 8+ SWP2
OVR2 OVR2 LTH2 ^$loop JNZ OVR2 OVR2 LTH2 ,&loop JNZ
POP2 POP2
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 RTN
@draw-octave ( x y -- ) @draw-octave ( x y -- )
=Screen.y .Screen/y DEO2
=Screen.x .Screen/x DEO2
,octave_icn =Screen.addr ;octave_icn .Screen/addr DEO2
~Screen.y ~Screen.y #0038 ADD2 .Screen/y DEI2 .Screen/y DEI2 #0038 ADD2
$loop &loop
OVR2 =Screen.y OVR2 .Screen/y DEO2
#21 =Screen.color #21 .Screen/color DEO
~Screen.addr 8+ =Screen.addr .Screen/addr DEI2 8+ .Screen/addr DEO2
~Screen.x 8+ =Screen.x .Screen/x DEI2 8+ .Screen/x DEO2
#21 =Screen.color #21 .Screen/color DEO
~Screen.addr 8+ =Screen.addr .Screen/addr DEI2 8+ .Screen/addr DEO2
~Screen.x 8- =Screen.x .Screen/x DEI2 8- .Screen/x DEO2
SWP2 8+ SWP2 SWP2 8+ SWP2
OVR2 OVR2 LTH2 ^$loop JNZ OVR2 OVR2 LTH2 ,&loop JNZ
POP2 POP2
POP2 POP2
@ -315,103 +315,103 @@ RTN
@draw-octaves ( -- ) @draw-octaves ( -- )
~trkframe.x1 #0018 SUB2 DUP2 ~trkframe.y1 ,draw-octave JSR2 .trkframe/x1 PEK2 #0018 SUB2 DUP2 .trkframe/y1 PEK2 ;draw-octave JSR2
~trkframe.y1 #0038 ADD2 ,draw-octave JSR2 .trkframe/y1 PEK2 #0038 ADD2 ;draw-octave JSR2
~trkframe.x1 #0028 SUB2 =Screen.x .trkframe/x1 PEK2 #0028 SUB2 .Screen/x DEO2
~trkframe.y1 #0030 ADD2 =Screen.y .trkframe/y1 PEK2 #0030 ADD2 .Screen/y DEO2
,font_hex #0028 ADD2 =Screen.addr ;font_hex #0028 ADD2 .Screen/addr DEO2
#23 =Screen.color #23 .Screen/color DEO
~trkframe.x1 #0030 SUB2 =Screen.x .trkframe/x1 PEK2 #0030 SUB2 .Screen/x DEO2
,font_hex #0060 ADD2 =Screen.addr ;font_hex #0060 ADD2 .Screen/addr DEO2
#23 =Screen.color #23 .Screen/color DEO
~trkframe.x1 #0028 SUB2 =Screen.x .trkframe/x1 PEK2 #0028 SUB2 .Screen/x DEO2
~trkframe.y1 #0068 ADD2 =Screen.y .trkframe/y1 PEK2 #0068 ADD2 .Screen/y DEO2
,font_hex #0020 ADD2 =Screen.addr ;font_hex #0020 ADD2 .Screen/addr DEO2
#23 =Screen.color #23 .Screen/color DEO
~trkframe.x1 #0030 SUB2 =Screen.x .trkframe/x1 PEK2 #0030 SUB2 .Screen/x DEO2
,font_hex #0060 ADD2 =Screen.addr ;font_hex #0060 ADD2 .Screen/addr DEO2
#23 =Screen.color #23 .Screen/color DEO
RTN RTN
@draw-timeline ( -- ) @draw-timeline ( -- )
,draw-bars JSR2 ;draw-bars JSR2
,draw-octaves JSR2 ;draw-octaves JSR2
RTN RTN
@draw-knob ( x* y* value -- ) @draw-knob ( x* y* value -- )
( load ) =knob.value =knob.y =knob.x ( load ) .knob/value POK .knob/y POK2 .knob/x POK2
~knob.x =Screen.x .knob/x PEK2 .Screen/x DEO2
~knob.y =Screen.y ,knob_icns =Screen.addr #21 =Screen.color .knob/y PEK2 .Screen/y DEO2 ;knob_icns .Screen/addr DEO2 #21 .Screen/color DEO
~knob.x 8+ =Screen.x ,knob_icns 8+ =Screen.addr #21 =Screen.color .knob/x PEK2 8+ .Screen/x DEO2 ;knob_icns 8+ .Screen/addr DEO2 #21 .Screen/color DEO
~knob.y 8+ =Screen.y ,knob_icns #0018 ADD2 =Screen.addr #21 =Screen.color .knob/y PEK2 8+ .Screen/y DEO2 ;knob_icns #0018 ADD2 .Screen/addr DEO2 #21 .Screen/color DEO
~knob.x =Screen.x ,knob_icns #0010 ADD2 =Screen.addr #21 =Screen.color .knob/x PEK2 .Screen/x DEO2 ;knob_icns #0010 ADD2 .Screen/addr DEO2 #21 .Screen/color DEO
~knob.x #00 #00 ~knob.value ,knob_offsetx ADD2 PEK2 ADD2 =Screen.x .knob/x PEK2 #00 #00 .knob/value PEK ;knob_offsetx ADD2 GET ADD2 .Screen/x DEO2
~knob.y #00 #00 ~knob.value ,knob_offsety ADD2 PEK2 ADD2 =Screen.y .knob/y PEK2 #00 #00 .knob/value PEK ;knob_offsety ADD2 GET ADD2 .Screen/y DEO2
,knob_icns #0020 ADD2 =Screen.addr ;knob_icns #0020 ADD2 .Screen/addr DEO2
#25 =Screen.color #25 .Screen/color DEO
~knob.x #0004 ADD2 =Screen.x .knob/x PEK2 #0004 ADD2 .Screen/x DEO2
~knob.y #0010 ADD2 =Screen.y .knob/y PEK2 #0010 ADD2 .Screen/y DEO2
,font_hex #00 ~knob.value #08 MUL ADD2 =Screen.addr ;font_hex #00 .knob/value PEK #08 MUL ADD2 .Screen/addr DEO2
#21 =Screen.color #21 .Screen/color DEO
RTN RTN
@draw-controls ( -- ) @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 ) ( env )
~ctlframe.x1 8+ ~ctlframe.y1 8+ #22 ,env_txt ,draw-label JSR2 .ctlframe/x1 PEK2 8+ .ctlframe/y1 PEK2 8+ #22 ;env_txt ;draw-label JSR2
~ctlframe.x1 8+ ~ctlframe.y1 #0010 ADD2 .ctlframe/x1 PEK2 8+ .ctlframe/y1 PEK2 #0010 ADD2
,adsr #00 ~track.active #04 MUL ADD2 PEK2 #04 SFT ;adsr #00 .track/active PEK #04 MUL ADD2 GET #04 SFT
,draw-knob JSR2 ;draw-knob JSR2
~ctlframe.x1 #0018 ADD2 ~ctlframe.y1 #0010 ADD2 .ctlframe/x1 PEK2 #0018 ADD2 .ctlframe/y1 PEK2 #0010 ADD2
,adsr #00 ~track.active #04 MUL ADD2 #0001 ADD2 PEK2 #04 SFT ;adsr #00 .track/active PEK #04 MUL ADD2 #0001 ADD2 GET #04 SFT
,draw-knob JSR2 ;draw-knob JSR2
~ctlframe.x1 #0028 ADD2 ~ctlframe.y1 #0010 ADD2 .ctlframe/x1 PEK2 #0028 ADD2 .ctlframe/y1 PEK2 #0010 ADD2
,adsr #00 ~track.active #04 MUL ADD2 #0002 ADD2 PEK2 #04 SFT ;adsr #00 .track/active PEK #04 MUL ADD2 #0002 ADD2 GET #04 SFT
,draw-knob JSR2 ;draw-knob JSR2
~ctlframe.x1 #0038 ADD2 ~ctlframe.y1 #0010 ADD2 .ctlframe/x1 PEK2 #0038 ADD2 .ctlframe/y1 PEK2 #0010 ADD2
,adsr #00 ~track.active #04 MUL ADD2 #0003 ADD2 PEK2 #04 SFT ;adsr #00 .track/active PEK #04 MUL ADD2 #0003 ADD2 GET #04 SFT
,draw-knob JSR2 ;draw-knob JSR2
( vol ) ( vol )
~ctlframe.x1 #0058 ADD2 ~ctlframe.y1 8+ #22 ,vol_txt ,draw-label JSR2 .ctlframe/x1 PEK2 #0058 ADD2 .ctlframe/y1 PEK2 8+ #22 ;vol_txt ;draw-label JSR2
~ctlframe.x1 #0058 ADD2 ~ctlframe.y1 #0010 ADD2 .ctlframe/x1 PEK2 #0058 ADD2 .ctlframe/y1 PEK2 #0010 ADD2
,volume #00 ~track.active ADD2 PEK2 #04 SFT ;volume #00 .track/active PEK ADD2 GET #04 SFT
,draw-knob JSR2 ;draw-knob JSR2
~ctlframe.x1 #0068 ADD2 ~ctlframe.y1 #0010 ADD2 .ctlframe/x1 PEK2 #0068 ADD2 .ctlframe/y1 PEK2 #0010 ADD2
,volume #00 ~track.active ADD2 PEK2 #0f AND ;volume #00 .track/active PEK ADD2 GET #0f AND
,draw-knob JSR2 ;draw-knob JSR2
RTN RTN
@draw-channels @draw-channels
~chnframe.x1 ~chnframe.y1 ~chnframe.x2 ~chnframe.y2 #01 ,line-rect JSR2 .chnframe/x1 PEK2 .chnframe/y1 PEK2 .chnframe/x2 PEK2 .chnframe/y2 PEK2 #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 PEK2 8+ .chnframe/y1 PEK2 8+ #21 .track/active PEK #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 PEK2 8+ .chnframe/y1 PEK2 #0010 ADD2 #21 .track/active PEK #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 PEK2 8+ .chnframe/y1 PEK2 #0018 ADD2 #21 .track/active PEK #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 8+ .chnframe/y1 PEK2 #0020 ADD2 #21 .track/active PEK #03 EQU #07 MUL ADD ;ch4_txt ;draw-label JSR2
RTN RTN
@draw-cursor ( -- ) @draw-cursor ( -- )
( clear last cursor ) ( clear last cursor )
,clear_icn =Screen.addr ;clear_icn .Screen/addr DEO2
~pointer.x =Screen.x .pointer/x PEK2 .Screen/x DEO2
~pointer.y =Screen.y .pointer/y PEK2 .Screen/y DEO2
#30 =Screen.color #30 .Screen/color DEO
( record pointer positions ) ( 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 ) ( draw new cursor )
,cursor_icn =Screen.addr ;cursor_icn .Screen/addr DEO2
~pointer.x =Screen.x .pointer/x PEK2 .Screen/x DEO2
~pointer.y =Screen.y .pointer/y PEK2 .Screen/y DEO2
#32 ~Mouse.state #00 NEQ ADD =Screen.color #32 .Mouse/state DEI #00 NEQ ADD .Screen/color DEO
RTN RTN
@ -419,61 +419,61 @@ RTN
@draw-label ( x y color addr -- ) @draw-label ( x y color addr -- )
( load ) =label.addr =label.color =Screen.y =Screen.x ( load ) .label/addr POK2 .label/color POK .Screen/y DEO2 .Screen/x DEO2
~label.addr .label/addr PEK2
$loop &loop
( draw ) DUP2 PEK2 #00 SWP 8* ,font ADD2 =Screen.addr ~label.color =Screen.color ( draw ) DUP2 GET #00 SWP 8* ;font ADD2 .Screen/addr DEO2 .label/color PEK .Screen/color DEO
( incr ) ++ ( incr ) ++
( incr ) ~Screen.x 8+ =Screen.x ( incr ) .Screen/x DEI2 8+ .Screen/x DEO2
DUP2 PEK2 #00 NEQ ^$loop JNZ DUP2 GET #00 NEQ ,&loop JNZ
POP2 POP2
RTN RTN
@line-vertical-dotted ( x y0 y1 color -- ) @line-vertical-dotted ( x y0 y1 color -- )
=color STH2 SWP2 =Screen.x STH2r OVR2 =Screen.y .color POK STH2 SWP2 .Screen/x DEO2 STH2r OVR2 .Screen/y DEO2
$draw-ver &draw-ver
( draw ) ~color =Screen.color ( draw ) .color PEK .Screen/color DEO
( incr ) SWP2 #0002 ADD2 DUP2 =Screen.y SWP2 ( incr ) SWP2 #0002 ADD2 DUP2 .Screen/y DEO2 SWP2
OVR2 OVR2 LTH2 ^$draw-ver JNZ OVR2 OVR2 LTH2 ,&draw-ver JNZ
POP2 POP2 POP2 POP2
RTN RTN
@line-horizontal-dotted ( x0 x1 y color -- ) @line-horizontal-dotted ( x0 x1 y color -- )
=color =Screen.y OVR2 =Screen.x .color POK .Screen/y DEO2 OVR2 .Screen/x DEO2
$draw-hor &draw-hor
( draw ) ~color =Screen.color ( draw ) .color PEK .Screen/color DEO
( incr ) SWP2 #0002 ADD2 DUP2 =Screen.x SWP2 ( incr ) SWP2 #0002 ADD2 DUP2 .Screen/x DEO2 SWP2
OVR2 OVR2 LTH2 ^$draw-hor JNZ OVR2 OVR2 LTH2 ,&draw-hor JNZ
POP2 POP2 POP2 POP2
RTN RTN
@line-rect ( x1 y1 x2 y2 color ) @line-rect ( x1 y1 x2 y2 color )
( load ) =color =rect.y2 =rect.x2 DUP2 =Screen.y =rect.y1 DUP2 =Screen.x =rect.x1 ( load ) .color POK .rect/y2 POK2 .rect/x2 POK2 DUP2 .Screen/y DEO2 .rect/y1 POK2 DUP2 .Screen/x DEO2 .rect/x1 POK2
$hor &hor
( incr ) ~Screen.x ++ =Screen.x ( incr ) .Screen/x DEI2 ++ .Screen/x DEO2
( draw ) ~rect.y1 =Screen.y ~color =Screen.color ( draw ) .rect/y1 PEK2 .Screen/y DEO2 .color PEK .Screen/color DEO
( draw ) ~rect.y2 =Screen.y ~color =Screen.color ( draw ) .rect/y2 PEK2 .Screen/y DEO2 .color PEK .Screen/color DEO
~Screen.x ~rect.x2 LTH2 ^$hor JNZ .Screen/x DEI2 .rect/x2 PEK2 LTH2 ,&hor JNZ
~rect.y1 =Screen.y .rect/y1 PEK2 .Screen/y DEO2
$ver &ver
( draw ) ~rect.x1 =Screen.x ~color =Screen.color ( draw ) .rect/x1 PEK2 .Screen/x DEO2 .color PEK .Screen/color DEO
( draw ) ~rect.x2 =Screen.x ~color =Screen.color ( draw ) .rect/x2 PEK2 .Screen/x DEO2 .color PEK .Screen/color DEO
( incr ) ~Screen.y ++ =Screen.y ( incr ) .Screen/y DEI2 ++ .Screen/y DEO2
~Screen.y ~rect.y2 ++ LTH2 ^$ver JNZ .Screen/y DEI2 .rect/y2 PEK2 ++ LTH2 ,&ver JNZ
RTN RTN
@adsr-envelope ( -- ) @adsr-envelope ( -- )
#ff ,adsr #00 ~Audio.play #04 MUL ADD2 PEK2 SOUND #ff ;adsr #00 .Audio/play DEI #04 MUL ADD2 GET SOUND
#80 ,adsr #00 ~Audio.play #04 MUL ADD2 #0001 ADD2 PEK2 SOUND #80 ;adsr #00 .Audio/play DEI #04 MUL ADD2 #0001 ADD2 GET SOUND
#80 ,adsr #00 ~Audio.play #04 MUL ADD2 #0002 ADD2 PEK2 SOUND #80 ;adsr #00 .Audio/play DEI #04 MUL ADD2 #0002 ADD2 GET SOUND
#00 ,adsr #00 ~Audio.play #04 MUL ADD2 #0003 ADD2 PEK2 SOUND #00 ;adsr #00 .Audio/play DEI #04 MUL ADD2 #0003 ADD2 GET SOUND
SOUND_FINISH SOUND_FINISH
BRK BRK
@ -490,19 +490,19 @@ RTN
#8040 SOUND #8040 SOUND
BRK BRK
@ch1_txt [ CHN0 00 ] @ch1_txt [ "CHN0 00 ]
@ch2_txt [ CHN1 00 ] @ch2_txt [ "CHN1 00 ]
@ch3_txt [ CHN2 00 ] @ch3_txt [ "CHN2 00 ]
@ch4_txt [ ---- 00 ] @ch4_txt [ "---- 00 ]
@env_txt [ Envelope 00 ] @env_txt [ "Envelope 00 ]
@vol_txt [ Volume 00 ] @vol_txt [ "Volume 00 ]
@clear_icn [ 0000 0000 0000 0000 ] @clear_icn [ 0000 0000 0000 0000 ]
@cursor_icn [ 80c0 e0f0 f8e0 1000 ] @cursor_icn [ 80c0 e0f0 f8e0 1000 ]
@note_icn [ 0000 1c3e 3e3e 1c00 ] @note_icn [ 0000 1c3e 3e3e 1c00 ]
@head_icn [ 0018 1818 7e3c 1800 ] @head_icn [ 0018 1818 7e3c 1800 ]
@notes [ @notes [
3c 3e 40 41 43 45 47 3c 3e 40 41 43 45 47
48 4a 4c 4d 4f 51 53 48 4a 4c 4d 4f 51 53
] ]
@ -516,20 +516,20 @@ RTN
] ]
@octave_icn [ @octave_icn [
ff00 0000 fefe fffe ff00 0000 fefe fffe
ff01 0101 0102 fc00 ff01 0101 0102 fc00
fffe fc00 fefe fffe fffe fc00 fefe fffe
ff01 0101 0102 fc00 ff01 0101 0102 fc00
fffe fc00 fefe fffe fffe fc00 fefe fffe
ff01 0101 0102 fc00 ff01 0101 0102 fc00
fffe fc00 0000 ff00 fffe fc00 0000 ff00
ff01 0101 0102 fc00 ff01 0101 0102 fc00
ff00 0000 fefe fffe ff00 0000 fefe fffe
ff01 0101 0102 fc00 ff01 0101 0102 fc00
fffe fc00 fefe fffe fffe fc00 fefe fffe
ff01 0101 0102 fc00 ff01 0101 0102 fc00
fffe fc00 0000 ff00 fffe fc00 0000 ff00
ff01 0101 0102 fc00 ff01 0101 0102 fc00
] ]
@knob_offsetx [ @knob_offsetx [
@ -542,19 +542,19 @@ RTN
00 00 01 02 03 05 06 07 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 8282 8282 827c 0030 1010 1010 1010
007c 8202 7c80 80fe 007c 8202 1c02 827c 007c 8202 7c80 80fe 007c 8202 1c02 827c
000c 1424 4484 fe04 00fe 8080 7c02 827c 000c 1424 4484 fe04 00fe 8080 7c02 827c
007c 8280 fc82 827c 007c 8202 1e02 0202 007c 8280 fc82 827c 007c 8202 1e02 0202
007c 8282 7c82 827c 007c 8282 7e02 827c 007c 8282 7c82 827c 007c 8282 7e02 827c
007c 8202 7e82 827e 00fc 8282 fc82 82fc 007c 8202 7e82 827e 00fc 8282 fc82 82fc
007c 8280 8080 827c 00fc 8282 8282 82fc 007c 8280 8080 827c 00fc 8282 8282 82fc
007c 8280 f080 827c 007c 8280 f080 8080 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 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 0010 387c 7c38 1000 0038 387c 6c10 3800 0010 387c 7c10 3800 0000 0018 1800 0000

View File

@ -7,331 +7,337 @@
%STEP8 { #0033 SFT2 } %STEP8 { #0033 SFT2 }
%S2B { SWP POP } %S2B { SWP POP }
;center { x 2 y 2 } ( devices )
;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 } |00 @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 } |20 @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 } |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 ) ( program )
|0200 |0100
( theme ) #127f =System.r #34e7 =System.g #56c4 =System.b ( theme ) #127f .System/r DEO2 #34e7 .System/g DEO2 #56c4 .System/b DEO2
( vectors ) ,on-mouse =Mouse.vector ( vectors ) ;on-mouse .Mouse/vector DEO2
#00b0 =window.w #00b0 .window/w POK2
#0050 =window.h #0050 .window/h POK2
( center window ) ( center window )
~Screen.width #0002 DIV2 ~window.w #0002 DIV2 SUB2 =window.x1 .Screen/width DEI2 #0002 DIV2 .window/w PEK2 #0002 DIV2 SUB2 .window/x1 POK2
~Screen.height #0002 DIV2 ~window.h #0002 DIV2 SUB2 =window.y1 .Screen/height DEI2 #0002 DIV2 .window/h PEK2 #0002 DIV2 SUB2 .window/y1 POK2
#01 =theme.r1 #02 =theme.g1 #03 =theme.b1 #01 .theme/r1 POK #02 .theme/g1 POK #03 .theme/b1 POK
#04 =theme.r2 #06 =theme.g2 #07 =theme.b2 #04 .theme/r2 POK #06 .theme/g2 POK #07 .theme/b2 POK
#0a =theme.r3 #09 =theme.g3 #08 =theme.b3 #0a .theme/r3 POK #09 .theme/g3 POK #08 .theme/b3 POK
#0c =theme.r4 #0b =theme.g4 #0d =theme.b4 #0c .theme/r4 POK #0b .theme/g4 POK #0d .theme/b4 POK
( find screen center ) ( find screen center )
~Screen.width #0002 DIV2 =center.x .Screen/width DEI2 #0002 DIV2 .center/x POK2
~Screen.height #0002 DIV2 =center.y .Screen/height DEI2 #0002 DIV2 .center/y POK2
,update-theme JSR2 ;update-theme JSR2
,draw-background JSR2 ;draw-background JSR2
,draw-window JSR2 ;draw-window JSR2
BRK BRK
@on-mouse @on-mouse
,draw-cursor JSR2 ;draw-cursor JSR2
~Mouse.state #00 NEQ ,$no-skip JNZ2 BRK $no-skip .Mouse/state DEI #00 NEQ ;&no-skip JNZ2 BRK &no-skip
~Mouse.y ~window.y1 SUB2 STEP8 .Mouse/y DEI2 .window/y1 PEK2 SUB2 STEP8
DUP2 #0010 NEQ2 ^$no-touch-red JNZ DUP2 #0010 NEQ2 ,&no-touch-red JNZ
~Mouse.x ~window.x1 #0060 ADD2 LTH2 ^$no-touch-red JNZ .Mouse/x DEI2 .window/x1 PEK2 #0060 ADD2 LTH2 ,&no-touch-red JNZ
~Mouse.x ~window.x1 #009c ADD2 GTH2 ^$no-touch-red JNZ .Mouse/x DEI2 .window/x1 PEK2 #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 ( 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 &no-touch-red
DUP2 #0020 NEQ2 ^$no-touch-green JNZ DUP2 #0020 NEQ2 ,&no-touch-green JNZ
~Mouse.x ~window.x1 #0060 ADD2 LTH2 ^$no-touch-green JNZ .Mouse/x DEI2 .window/x1 PEK2 #0060 ADD2 LTH2 ,&no-touch-green JNZ
~Mouse.x ~window.x1 #009c ADD2 GTH2 ^$no-touch-green JNZ .Mouse/x DEI2 .window/x1 PEK2 #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 ( 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 &no-touch-green
DUP2 #0030 NEQ2 ^$no-touch-blue JNZ DUP2 #0030 NEQ2 ,&no-touch-blue JNZ
~Mouse.x ~window.x1 #0060 ADD2 LTH2 ^$no-touch-blue JNZ .Mouse/x DEI2 .window/x1 PEK2 #0060 ADD2 LTH2 ,&no-touch-blue JNZ
~Mouse.x ~window.x1 #009c ADD2 GTH2 ^$no-touch-blue JNZ .Mouse/x DEI2 .window/x1 PEK2 #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 ( 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 &no-touch-blue
DUP2 #0040 NEQ2 ^$no-touch-radio JNZ DUP2 #0040 NEQ2 ,&no-touch-radio JNZ
~Mouse.x ~window.x1 #0050 ADD2 LTH2 ^$no-touch-radio JNZ .Mouse/x DEI2 .window/x1 PEK2 #0050 ADD2 LTH2 ,&no-touch-radio JNZ
~Mouse.x ~window.x1 #008c ADD2 GTH2 ^$no-touch-radio JNZ .Mouse/x DEI2 .window/x1 PEK2 #008c ADD2 GTH2 ,&no-touch-radio JNZ
~Mouse.x ~window.x1 SUB2 #0050 SUB2 STEP8 2/ #0008 DIV2 S2B =selection .Mouse/x DEI2 .window/x1 PEK2 SUB2 #0050 SUB2 STEP8 2/ #0008 DIV2 S2B .selection POK
$no-touch-radio &no-touch-radio
POP2 POP2
,update-theme JSR2 ;update-theme JSR2
,draw-window JSR2 ;draw-window JSR2
BRK BRK
@update-theme @update-theme
#0108 PEK2 #0f AND ~theme.r1 #40 SFT ADD #0108 POK2 #08 DEI #0f AND .theme/r1 PEK #40 SFT ADD #08 DEO
#010a PEK2 #0f AND ~theme.g1 #40 SFT ADD #010a POK2 #0a DEI #0f AND .theme/g1 PEK #40 SFT ADD #0a DEO
#010c PEK2 #0f AND ~theme.b1 #40 SFT ADD #010c POK2 #0c DEI #0f AND .theme/b1 PEK #40 SFT ADD #0c DEO
#0108 PEK2 #f0 AND ~theme.r2 ADD #0108 POK2 #08 DEI #f0 AND .theme/r2 PEK ADD #08 DEO
#010a PEK2 #f0 AND ~theme.g2 ADD #010a POK2 #0a DEI #f0 AND .theme/g2 PEK ADD #0a DEO
#010c PEK2 #f0 AND ~theme.b2 ADD #010c POK2 #0c DEI #f0 AND .theme/b2 PEK ADD #0c DEO
#0109 PEK2 #0f AND ~theme.r3 #40 SFT ADD #0109 POK2 #09 DEI #0f AND .theme/r3 PEK #40 SFT ADD #09 DEO
#010b PEK2 #0f AND ~theme.g3 #40 SFT ADD #010b POK2 #0b DEI #0f AND .theme/g3 PEK #40 SFT ADD #0b DEO
#010d PEK2 #0f AND ~theme.b3 #40 SFT ADD #010d POK2 #0d DEI #0f AND .theme/b3 PEK #40 SFT ADD #0d DEO
#0109 PEK2 #f0 AND ~theme.r4 ADD #0109 POK2 #09 DEI #f0 AND .theme/r4 PEK ADD #09 DEO
#010b PEK2 #f0 AND ~theme.g4 ADD #010b POK2 #0b DEI #f0 AND .theme/g4 PEK ADD #0b DEO
#010d PEK2 #f0 AND ~theme.b4 ADD #010d POK2 #0d DEI #f0 AND .theme/b4 PEK ADD #0d DEO
RTN RTN
@draw-background @draw-background
( draw hor line ) ( draw hor line )
#0000 =Screen.x ~center.y =Screen.y #0000 .Screen/x DEO2 .center/y PEK2 .Screen/y DEO2
#0000 ~Screen.width ( from/to ) #0000 .Screen/width DEI2 ( from/to )
$draw-hor &draw-hor
( draw ) #01 =Screen.color ( draw ) #01 .Screen/color DEO
( incr ) SWP2 #0002 ADD2 DUP2 =Screen.x SWP2 ( incr ) SWP2 #0002 ADD2 DUP2 .Screen/x DEO2 SWP2
OVR2 OVR2 LTH2 ^$draw-hor JNZ OVR2 OVR2 LTH2 ,&draw-hor JNZ
POP2 POP2 POP2 POP2
( draw ver line ) ( draw ver line )
~center.x =Screen.x #0000 =Screen.y .center/x PEK2 .Screen/x DEO2 #0000 .Screen/y DEO2
#0000 ~Screen.height ( from/to ) #0000 .Screen/height DEI2 ( from/to )
$draw-ver &draw-ver
( draw ) #02 =Screen.color ( draw ) #02 .Screen/color DEO
( incr ) SWP2 #0002 ADD2 DUP2 =Screen.y SWP2 ( incr ) SWP2 #0002 ADD2 DUP2 .Screen/y DEO2 SWP2
OVR2 OVR2 LTH2 ^$draw-ver JNZ OVR2 OVR2 LTH2 ,&draw-ver JNZ
POP2 POP2 POP2 POP2
( draw blending modes ) ( draw blending modes )
,preview_icn =Screen.addr ;preview_icn .Screen/addr DEO2
#0010 =Screen.y #0010 .Screen/y DEO2
#00 #08 #00 #08
$draw-pixel1 &draw-pixel1
( move ) OVR #00 SWP #0008 MUL2 #0010 ADD2 =Screen.x ( move ) OVR #00 SWP #0008 MUL2 #0010 ADD2 .Screen/x DEO2
( draw ) OVR =Screen.color ( draw ) OVR .Screen/color DEO
( incr ) SWP #01 ADD SWP ( incr ) SWP #01 ADD SWP
DUP2 LTH ^$draw-pixel1 JNZ DUP2 LTH ,&draw-pixel1 JNZ
POP POP POP POP
#0018 =Screen.y #0018 .Screen/y DEO2
#00 #08 #00 #08
$draw-pixel2 &draw-pixel2
( move ) OVR #00 SWP #0008 MUL2 #0010 ADD2 =Screen.x ( move ) OVR #00 SWP #0008 MUL2 #0010 ADD2 .Screen/x DEO2
( draw ) OVR #08 ADD =Screen.color ( draw ) OVR #08 ADD .Screen/color DEO
( incr ) SWP #01 ADD SWP ( incr ) SWP #01 ADD SWP
DUP2 LTH ^$draw-pixel2 JNZ DUP2 LTH ,&draw-pixel2 JNZ
POP POP POP POP
#0020 =Screen.y #0020 .Screen/y DEO2
#00 #08 #00 #08
$draw-icn1 &draw-icn1
( move ) OVR #00 SWP #0008 MUL2 #0010 ADD2 =Screen.x ( move ) OVR #00 SWP #0008 MUL2 #0010 ADD2 .Screen/x DEO2
( draw ) OVR #20 ADD =Screen.color ( draw ) OVR #20 ADD .Screen/color DEO
( incr ) SWP #01 ADD SWP ( incr ) SWP #01 ADD SWP
DUP2 LTH ^$draw-icn1 JNZ DUP2 LTH ,&draw-icn1 JNZ
POP POP POP POP
#0028 =Screen.y #0028 .Screen/y DEO2
#00 #08 #00 #08
$draw-icn2 &draw-icn2
( move ) OVR #00 SWP #0008 MUL2 #0010 ADD2 =Screen.x ( move ) OVR #00 SWP #0008 MUL2 #0010 ADD2 .Screen/x DEO2
( draw ) OVR #28 ADD =Screen.color ( draw ) OVR #28 ADD .Screen/color DEO
( incr ) SWP #01 ADD SWP ( incr ) SWP #01 ADD SWP
DUP2 LTH ^$draw-icn2 JNZ DUP2 LTH ,&draw-icn2 JNZ
POP POP POP POP
#0030 =Screen.y #0030 .Screen/y DEO2
#00 #08 #00 #08
$draw-chr1 &draw-chr1
( move ) OVR #00 SWP #0008 MUL2 #0010 ADD2 =Screen.x ( move ) OVR #00 SWP #0008 MUL2 #0010 ADD2 .Screen/x DEO2
( draw ) OVR #40 ADD =Screen.color ( draw ) OVR #40 ADD .Screen/color DEO
( incr ) SWP #01 ADD SWP ( incr ) SWP #01 ADD SWP
DUP2 LTH ^$draw-chr1 JNZ DUP2 LTH ,&draw-chr1 JNZ
POP POP POP POP
#0038 =Screen.y #0038 .Screen/y DEO2
#00 #08 #00 #08
$draw-chr2 &draw-chr2
( move ) OVR #00 SWP #0008 MUL2 #0010 ADD2 =Screen.x ( move ) OVR #00 SWP #0008 MUL2 #0010 ADD2 .Screen/x DEO2
( draw ) OVR #48 ADD =Screen.color ( draw ) OVR #48 ADD .Screen/color DEO
( incr ) SWP #01 ADD SWP ( incr ) SWP #01 ADD SWP
DUP2 LTH ^$draw-chr2 JNZ DUP2 LTH ,&draw-chr2 JNZ
POP POP POP POP
RTN RTN
@draw-window @draw-window
~window.x1 ~window.w ADD2 =window.x2 .window/x1 PEK2 .window/w PEK2 ADD2 .window/x2 POK2
~window.y1 ~window.h ADD2 =window.y2 .window/y1 PEK2 .window/h PEK2 ADD2 .window/y2 POK2
~window.x1 ~window.y1 ~window.x2 ~window.y2 #02 ,fill-rect JSR2 .window/x1 PEK2 .window/y1 PEK2 .window/x2 PEK2 .window/y2 PEK2 #02 ;fill-rect JSR2
~window.x1 ~window.y1 ~window.x2 ~window.y2 #01 ,line-rect JSR2 .window/x1 PEK2 .window/y1 PEK2 .window/x2 PEK2 .window/y2 PEK2 #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 PEK2 #0002 SUB2 .window/y1 PEK2 #0002 SUB2 .window/x2 PEK2 #0002 ADD2 .window/y2 PEK2 #0002 ADD2 #01 ;line-rect JSR2
~window.x1 #0008 ADD2 ~window.y1 #0010 ADD2 #25 ,red_txt ,draw-label JSR2 .window/x1 PEK2 #0008 ADD2 .window/y1 PEK2 #0010 ADD2 #25 ;red_txt ;draw-label JSR2
~window.x1 #0038 ADD2 ~window.y1 #0010 ADD2 #28 ,System.r ,draw-byte JSR2 .window/x1 PEK2 #0038 ADD2 .window/y1 PEK2 #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 PEK2 #0048 ADD2 .window/y1 PEK2 #0010 ADD2 #28 .System/r #01 ADD ;draw-byte JSR2
~window.x1 #0008 ADD2 ~window.y1 #0020 ADD2 #25 ,green_txt ,draw-label JSR2 .window/x1 PEK2 #0008 ADD2 .window/y1 PEK2 #0020 ADD2 #25 ;green_txt ;draw-label JSR2
~window.x1 #0038 ADD2 ~window.y1 #0020 ADD2 #28 ,System.g ,draw-byte JSR2 .window/x1 PEK2 #0038 ADD2 .window/y1 PEK2 #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 PEK2 #0048 ADD2 .window/y1 PEK2 #0020 ADD2 #28 .System/g #01 ADD ;draw-byte JSR2
~window.x1 #0008 ADD2 ~window.y1 #0030 ADD2 #25 ,blue_txt ,draw-label JSR2 .window/x1 PEK2 #0008 ADD2 .window/y1 PEK2 #0030 ADD2 #25 ;blue_txt ;draw-label JSR2
~window.x1 #0038 ADD2 ~window.y1 #0030 ADD2 #28 ,System.b ,draw-byte JSR2 .window/x1 PEK2 #0038 ADD2 .window/y1 PEK2 #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 PEK2 #0048 ADD2 .window/y1 PEK2 #0030 ADD2 #28 .System/b #01 ADD ;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 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 #0060 ADD2 ~window.y1 #0020 ADD2 ~window.x1 #0090 ADD2 #00 ,theme.g1 ~selection ADD PEK2 #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 #0060 ADD2 ~window.y1 #0030 ADD2 ~window.x1 #0090 ADD2 #00 ,theme.b1 ~selection ADD PEK2 #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 #0050 ADD2 =Screen.x .window/x1 PEK2 #0050 ADD2 .Screen/x DEO2
~window.y1 #0040 ADD2 =Screen.y .window/y1 PEK2 #0040 ADD2 .Screen/y DEO2
,radio_icns #00 ~selection #00 EQU #0008 MUL2 ADD2 =Screen.addr ;radio_icns #00 .selection PEK #00 EQU #0008 MUL2 ADD2 .Screen/addr DEO2
#25 =Screen.color #25 .Screen/color DEO
~window.x1 #0060 ADD2 =Screen.x .window/x1 PEK2 #0060 ADD2 .Screen/x DEO2
~window.y1 #0040 ADD2 =Screen.y .window/y1 PEK2 #0040 ADD2 .Screen/y DEO2
,radio_icns #00 ~selection #01 EQU #0008 MUL2 ADD2 =Screen.addr ;radio_icns #00 .selection PEK #01 EQU #0008 MUL2 ADD2 .Screen/addr DEO2
#25 =Screen.color #25 .Screen/color DEO
~window.x1 #0070 ADD2 =Screen.x .window/x1 PEK2 #0070 ADD2 .Screen/x DEO2
~window.y1 #0040 ADD2 =Screen.y .window/y1 PEK2 #0040 ADD2 .Screen/y DEO2
,radio_icns #00 ~selection #02 EQU #0008 MUL2 ADD2 =Screen.addr ;radio_icns #00 .selection PEK #02 EQU #0008 MUL2 ADD2 .Screen/addr DEO2
#25 =Screen.color #25 .Screen/color DEO
~window.x1 #0080 ADD2 =Screen.x .window/x1 PEK2 #0080 ADD2 .Screen/x DEO2
~window.y1 #0040 ADD2 =Screen.y .window/y1 PEK2 #0040 ADD2 .Screen/y DEO2
,radio_icns #00 ~selection #03 EQU #0008 MUL2 ADD2 =Screen.addr ;radio_icns #00 .selection PEK #03 EQU #0008 MUL2 ADD2 .Screen/addr DEO2
#25 =Screen.color #25 .Screen/color DEO
RTN RTN
@draw-cursor ( -- ) @draw-cursor ( -- )
( clear last cursor ) ( clear last cursor )
,clear_icn =Screen.addr ;clear_icn .Screen/addr DEO2
~pointer.x =Screen.x .pointer/x PEK2 .Screen/x DEO2
~pointer.y =Screen.y .pointer/y PEK2 .Screen/y DEO2
#30 =Screen.color #30 .Screen/color DEO
( record pointer positions ) ( 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 ) ( draw new cursor )
,pointer_icn =Screen.addr ;pointer_icn .Screen/addr DEO2
~pointer.x =Screen.x .pointer/x PEK2 .Screen/x DEO2
~pointer.y =Screen.y .pointer/y PEK2 .Screen/y DEO2
#33 ~Mouse.state #00 NEQ #02 MUL SUB =Screen.color #33 .Mouse/state DEI #00 NEQ #02 MUL SUB .Screen/color DEO
RTN RTN
@draw-slider ( x1 y x2 pos color -- ) @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/x1 PEK2 .Screen/x DEO2
~slider.y =Screen.y .slider/y PEK2 .Screen/y DEO2
,halftone_icn =Screen.addr ;halftone_icn .Screen/addr DEO2
,slidera_icn =Screen.addr ;slidera_icn .Screen/addr DEO2
( draw ) #25 =Screen.color ( draw ) #25 .Screen/color DEO
,sliderb_icn =Screen.addr ;sliderb_icn .Screen/addr DEO2
$loop &loop
( incr ) ~Screen.x 8+ =Screen.x ( incr ) .Screen/x DEI2 8+ .Screen/x DEO2
( draw ) #25 =Screen.color ( draw ) #25 .Screen/color DEO
~Screen.x ~slider.x2 #0008 ADD2 LTH2 ^$loop JNZ .Screen/x DEI2 .slider/x2 PEK2 #0008 ADD2 LTH2 ,&loop JNZ
( incr ) ~Screen.x #0004 ADD2 =Screen.x ( incr ) .Screen/x DEI2 #0004 ADD2 .Screen/x DEO2
,sliderc_icn =Screen.addr ;sliderc_icn .Screen/addr DEO2
( draw ) #25 =Screen.color ( draw ) #25 .Screen/color DEO
~slider.x1 ~slider.pos ADD2 =Screen.x .slider/x1 PEK2 .slider/pos PEK2 ADD2 .Screen/x DEO2
,sliderd_icn =Screen.addr ;sliderd_icn .Screen/addr DEO2
( draw ) #2a =Screen.color ( draw ) #2a .Screen/color DEO
RTN RTN
@fill-rect ( x1 y1 x2 y2 color ) @fill-rect ( x1 y1 x2 y2 color )
=color .color POK
( x1 x2 y1 y2 ) ROT2 SWP2 ( x1 x2 y1 y2 ) ROT2 SWP2
$ver &ver
( save ) OVR2 =Screen.y ( save ) OVR2 .Screen/y DEO2
STH2 STH2 OVR2 OVR2 STH2 STH2 OVR2 OVR2
$hor &hor
( save ) OVR2 =Screen.x ( save ) OVR2 .Screen/x DEO2
( draw ) ~color =Screen.color ( draw ) .color PEK .Screen/color DEO
( incr ) SWP2 #0001 ADD2 SWP2 ( incr ) SWP2 #0001 ADD2 SWP2
OVR2 OVR2 LTH2 ^$hor JNZ OVR2 OVR2 LTH2 ,&hor JNZ
POP2 POP2 STH2r STH2r POP2 POP2 STH2r STH2r
( incr ) SWP2 #0001 ADD2 SWP2 ( incr ) SWP2 #0001 ADD2 SWP2
OVR2 OVR2 LTH2 ^$ver JNZ OVR2 OVR2 LTH2 ,&ver JNZ
POP2 POP2 POP2 POP2 POP2 POP2 POP2 POP2
RTN RTN
@line-rect ( x1 y1 x2 y2 color -- ) @line-rect ( x1 y1 x2 y2 color -- )
( load ) =color =rect.y2 =rect.x2 DUP2 =Screen.y =rect.y1 DUP2 =Screen.x =rect.x1 ( load ) .color POK .rect/y2 POK2 .rect/x2 POK2 DUP2 .Screen/y DEO2 .rect/y1 POK2 DUP2 .Screen/x DEO2 .rect/x1 POK2
$hor &hor
( incr ) ~Screen.x ++ =Screen.x ( incr ) .Screen/x DEI2 ++ .Screen/x DEO2
( draw ) ~rect.y1 =Screen.y ~color =Screen.color ( draw ) .rect/y1 PEK2 .Screen/y DEO2 .color PEK .Screen/color DEO
( draw ) ~rect.y2 =Screen.y ~color =Screen.color ( draw ) .rect/y2 PEK2 .Screen/y DEO2 .color PEK .Screen/color DEO
~Screen.x ~rect.x2 LTH2 ^$hor JNZ .Screen/x DEI2 .rect/x2 PEK2 LTH2 ,&hor JNZ
~rect.y1 =Screen.y .rect/y1 PEK2 .Screen/y DEO2
$ver &ver
( draw ) ~rect.x1 =Screen.x ~color =Screen.color ( draw ) .rect/x1 PEK2 .Screen/x DEO2 .color PEK .Screen/color DEO
( draw ) ~rect.x2 =Screen.x ~color =Screen.color ( draw ) .rect/x2 PEK2 .Screen/x DEO2 .color PEK .Screen/color DEO
( incr ) ~Screen.y ++ =Screen.y ( incr ) .Screen/y DEI2 ++ .Screen/y DEO2
~Screen.y ~rect.y2 ++ LTH2 ^$ver JNZ .Screen/y DEI2 .rect/y2 PEK2 ++ LTH2 ,&ver JNZ
RTN RTN
@draw-label ( x y color addr -- ) @draw-label ( x y color addr -- )
( load ) =label.addr =color =Screen.y =Screen.x ~label.addr ( load ) .label/addr POK2 .color POK .Screen/y DEO2 .Screen/x DEO2 .label/addr PEK2
$loop &loop
( draw ) DUP2 PEK2 #00 SWP #0008 MUL2 ,font ADD2 =Screen.addr ~color =Screen.color ( draw ) DUP2 GET #00 SWP #0008 MUL2 ;font ADD2 .Screen/addr DEO2 .color PEK .Screen/color DEO
( incr ) ++ ( incr ) ++
( incr ) ~Screen.x 8+ =Screen.x ( incr ) .Screen/x DEI2 8+ .Screen/x DEO2
DUP2 PEK2 #00 NEQ ^$loop JNZ DUP2 GET #00 NEQ ,&loop JNZ
POP2 POP2
RTN RTN
@draw-byte ( x y color addr -- ) @draw-byte ( x y color addr -- )
=addr STH .addr POK STH
=Screen.y .Screen/y DEO2
=Screen.x .Screen/x DEO2
,font_hex #00 ~addr PEK2 #04 SFT #0008 MUL2 ADD2 =Screen.addr ;font_hex #00 .addr PEK DEI #04 SFT #0008 MUL2 ADD2 .Screen/addr DEO2
STHr DUP STH =Screen.color STHr DUP STH .Screen/color DEO
,font_hex #00 ~addr PEK2 #0f AND #0008 MUL2 ADD2 =Screen.addr ;font_hex #00 .addr PEK DEI #0f AND #0008 MUL2 ADD2 .Screen/addr DEO2
~Screen.x 8+ =Screen.x .Screen/x DEI2 8+ .Screen/x DEO2
STHr =Screen.color STHr .Screen/color DEO
RTN RTN
@ -342,28 +348,28 @@ RTN
@sliderb_icn [ ffff ffff ffff ffff ] @sliderb_icn [ ffff ffff ffff ffff ]
@sliderc_icn [ fcfe ffff ffff fefc ] @sliderc_icn [ fcfe ffff ffff fefc ]
@sliderd_icn [ 003c 7e7e 7e7e 3c00 ] @sliderd_icn [ 003c 7e7e 7e7e 3c00 ]
@preview_icn [ 183c 66db db66 3c18 0000 183c 3c18 0000 ] @preview_icn [ 183c 66db db66 3c18 0000 183c 3c18 0000 ]
@radio_icns @radio_icns
[ 3c42 8181 8181 423c ] [ 3c42 8181 8181 423c ]
[ 3c42 99bd bd99 423c ] [ 3c42 99bd bd99 423c ]
@red_txt [ Red 00 ] @red_txt [ "Red 00 ]
@green_txt [ Green 00 ] @green_txt [ "Green 00 ]
@blue_txt [ Blue 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 464a 5262 3c00 0018 0808 0808 1c00
003c 4202 3c40 7e00 003c 421c 0242 3c00 003c 4202 3c40 7e00 003c 421c 0242 3c00
000c 1424 447e 0400 007e 407c 0242 3c00 000c 1424 447e 0400 007e 407c 0242 3c00
003c 407c 4242 3c00 007e 0204 0810 1000 003c 407c 4242 3c00 007e 0204 0810 1000
003c 423c 4242 3c00 003c 4242 3e02 3c00 003c 423c 4242 3c00 003c 4242 3e02 3c00
003c 4242 7e42 4200 007c 427c 4242 7c00 003c 4242 7e42 4200 007c 427c 4242 7c00
003c 4240 4042 3c00 007c 4242 4242 7c00 003c 4240 4042 3c00 007c 4242 4242 7c00
007e 4078 4040 7e00 007e 4078 4040 4000 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 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 0010 387c 7c38 1000 0038 387c 6c10 3800 0010 387c 7c10 3800 0000 0018 1800 0000

View File

@ -2,94 +2,100 @@
%RTN { JMP2r } %RTN { JMP2r }
;color { byte 1 } ( devices )
;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 }
|0100 ;System { vector 2 pad 6 r 2 g 2 b 2 } |00 @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 } |20 @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 } |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 ) ( 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
( vectors ) ,on-mouse =Mouse.vector ( vectors ) ;on-mouse .Mouse/vector DEO2
#0020 #0030 #0060 #0060 =r1.y2 =r1.x2 =r1.y1 =r1.x1 #0020 #0030 #0060 #0060 .r1/y2 POK2 .r1/x2 POK2 .r1/y1 POK2 .r1/x1 POK2
#0058 #0050 #0090 #0080 =r2.y2 =r2.x2 =r2.y1 =r2.x1 #0058 #0050 #0090 #0080 .r2/y2 POK2 .r2/x2 POK2 .r2/y1 POK2 .r2/x1 POK2
#0048 #0048 #0080 #0098 =r3.y2 =r3.x2 =r3.y1 =r3.x1 #0048 #0048 #0080 #0098 .r3/y2 POK2 .r3/x2 POK2 .r3/y1 POK2 .r3/x1 POK2
( no BRK, run through to on-mouse )
@on-mouse
;pointer_icn .pointer/sprite POK2
#01 .color POK
( matrix comparison )
.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 POK
( 2-step comparison )
.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 POK
( 4-step comparison )
.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
BRK BRK
@on-mouse
,pointer_icn =pointer.sprite
#01 =color
( 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
#01 =color
( 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
#01 =color
( 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
,draw-cursor JSR2
BRK
@draw-cursor @draw-cursor
( clear last cursor ) ( clear last cursor )
,clear_icn =Screen.addr ;clear_icn .Screen/addr DEO2
~pointer.x =Screen.x .pointer/x PEK2 .Screen/x DEO2
~pointer.y =Screen.y .pointer/y PEK2 .Screen/y DEO2
#30 =Screen.color #30 .Screen/color DEO
( record pointer positions ) ( 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 ) ( draw new cursor )
~pointer.sprite =Screen.addr .pointer/sprite PEK2 .Screen/addr DEO2
~pointer.x =Screen.x .pointer/x PEK2 .Screen/x DEO2
~pointer.y =Screen.y .pointer/y PEK2 .Screen/y DEO2
#31 =Screen.color #31 .Screen/color DEO
RTN RTN
@line-rect ( x1 y1 x2 y2 color ) @line-rect ( x1 y1 x2 y2 color )
( load ) =color =rect.y2 =rect.x2 DUP2 =Screen.y =rect.y1 DUP2 =Screen.x =rect.x1 ( load ) .color POK .rect/y2 POK2 .rect/x2 POK2 DUP2 .Screen/y DEO2 .rect/y1 POK2 DUP2 .Screen/x DEO2 .rect/x1 POK2
$hor &hor
( incr ) ~Screen.x #0001 ADD2 =Screen.x ( incr ) .Screen/x DEI2 #0001 ADD2 .Screen/x DEO2
( draw ) ~rect.y1 =Screen.y ~color =Screen.color ( draw ) .rect/y1 PEK2 .Screen/y DEO2 .color PEK .Screen/color DEO
( draw ) ~rect.y2 =Screen.y ~color =Screen.color ( draw ) .rect/y2 PEK2 .Screen/y DEO2 .color PEK .Screen/color DEO
~Screen.x ~rect.x2 LTH2 ^$hor JNZ .Screen/x DEI2 .rect/x2 PEK2 LTH2 ,&hor JNZ
~rect.y1 =Screen.y .rect/y1 PEK2 .Screen/y DEO2
$ver &ver
( draw ) ~rect.x1 =Screen.x ~color =Screen.color ( draw ) .rect/x1 PEK2 .Screen/x DEO2 .color PEK .Screen/color DEO
( draw ) ~rect.x2 =Screen.x ~color =Screen.color ( draw ) .rect/x2 PEK2 .Screen/x DEO2 .color PEK .Screen/color DEO
( incr ) ~Screen.y #0001 ADD2 =Screen.y ( incr ) .Screen/y DEI2 #0001 ADD2 .Screen/y DEO2
~Screen.y ~rect.y2 #0001 ADD2 LTH2 ^$ver JNZ .Screen/y DEI2 .rect/y2 PEK2 #0001 ADD2 LTH2 ,&ver JNZ
RTN RTN

View File

@ -2,80 +2,86 @@
%RTN { JMP2r } %RTN { JMP2r }
;label { x 2 y 2 color 1 addr 2 } ( devices )
;center { x 2 y 2 }
|0100 ;System { vector 2 pad 6 r 2 g 2 b 2 } |00 @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 } |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 ) ( 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 BRK
@draw ( -- ) @draw ( -- )
( find screen center ) ( find screen center )
~Screen.width #0002 DIV2 =center.x .Screen/width DEI2 #0002 DIV2 .center/x POK2
~Screen.height #0002 DIV2 =center.y .Screen/height DEI2 #0002 DIV2 .center/y POK2
( draw ver line ) ( draw ver line )
~center.x =Screen.x #0000 =Screen.y .center/x PEK2 .Screen/x DEO2 #0000 .Screen/y DEO2
$draw-ver &draw-ver
( draw ) #02 =Screen.color ( draw ) #02 .Screen/color DEO
( incr ) ~Screen.y #0002 ADD2 =Screen.y ( incr ) .Screen/y DEI2 #0002 ADD2 .Screen/y DEO2
~Screen.y ~Screen.height LTH2 ^$draw-ver JNZ .Screen/y DEI2 .Screen/height DEI2 LTH2 ,&draw-ver JNZ
~center.x ~center.y #0010 SUB2 #2c ,text1 ,draw-label-left JSR2 .center/x PEK2 .center/y PEK2 #0010 SUB2 #2c ;text1 ;draw-label-left JSR2
~center.x ~center.y #2c ,text2 ,draw-label-middle JSR2 .center/x PEK2 .center/y PEK2 #2c ;text2 ;draw-label-middle JSR2
~center.x ~center.y #0010 ADD2 #2c ,text3 ,draw-label-right JSR2 .center/x PEK2 .center/y PEK2 #0010 ADD2 #2c ;text3 ;draw-label-right JSR2
~center.x ~center.y #0020 ADD2 #2c ,text4 ,draw-label-middle JSR2 .center/x PEK2 .center/y PEK2 #0020 ADD2 #2c ;text4 ;draw-label-middle JSR2
~center.x ~center.y #0030 ADD2 #2c ,text5 ,draw-label-middle JSR2 .center/x PEK2 .center/y PEK2 #0030 ADD2 #2c ;text5 ;draw-label-middle JSR2
RTN RTN
@draw-label-left ( x y color addr -- ) @draw-label-left ( x y color addr -- )
( load ) =label.addr =label.color =Screen.y =Screen.x ( load ) .label/addr POK2 .label/color POK .Screen/y DEO2 .Screen/x DEO2
~label.addr .label/addr PEK2
$loop &loop
( draw ) DUP2 PEK2 #00 SWP #0008 MUL2 ,font ADD2 =Screen.addr ~label.color =Screen.color ( draw ) DUP2 GET #00 SWP #0008 MUL2 ;font ADD2 .Screen/addr DEO2 .label/color PEK .Screen/color DEO
( incr ) #0001 ADD2 ( incr ) #0001 ADD2
( incr ) ~Screen.x #0008 ADD2 =Screen.x ( incr ) .Screen/x DEI2 #0008 ADD2 .Screen/x DEO2
DUP2 PEK2 #00 NEQ ^$loop JNZ DUP2 GET #00 NEQ ,&loop JNZ
POP2 POP2
RTN RTN
@draw-label-middle ( x y color addr -- ) @draw-label-middle ( x y color addr -- )
( load ) =label.addr =label.color =Screen.y ( load ) .label/addr POK2 .label/color POK .Screen/y DEO2
( align ) ~label.addr ,get-text-length JSR2 #0008 MUL2 #0002 DIV2 SUB2 =Screen.x ( align ) .label/addr PEK2 ;get-text-length JSR2 #0008 MUL2 #0002 DIV2 SUB2 .Screen/x DEO2
~label.addr .label/addr PEK2
$loop &loop
( draw ) DUP2 PEK2 #00 SWP #0008 MUL2 ,font ADD2 =Screen.addr ~label.color =Screen.color ( draw ) DUP2 GET #00 SWP #0008 MUL2 ;font ADD2 .Screen/addr DEO2 .label/color PEK .Screen/color DEO
( incr ) #0001 ADD2 ( incr ) #0001 ADD2
( incr ) ~Screen.x #0008 ADD2 =Screen.x ( incr ) .Screen/x DEI2 #0008 ADD2 .Screen/x DEO2
DUP2 PEK2 #00 NEQ ^$loop JNZ DUP2 GET #00 NEQ ,&loop JNZ
POP2 POP2
RTN RTN
@draw-label-right ( x y color addr -- ) @draw-label-right ( x y color addr -- )
( load ) =label.addr =label.color =Screen.y ( load ) .label/addr POK2 .label/color POK .Screen/y DEO2
( align ) ~label.addr ,get-text-length JSR2 #0008 MUL2 SUB2 #0008 SUB2 =Screen.x ( align ) .label/addr PEK2 ;get-text-length JSR2 #0008 MUL2 SUB2 #0008 SUB2 .Screen/x DEO2
~label.addr .label/addr PEK2
$loop &loop
( draw ) DUP2 PEK2 #00 SWP #0008 MUL2 ,font ADD2 =Screen.addr ~label.color =Screen.color ( draw ) DUP2 GET #00 SWP #0008 MUL2 ;font ADD2 .Screen/addr DEO2 .label/color PEK .Screen/color DEO
( incr ) #0001 ADD2 ( incr ) #0001 ADD2
( incr ) ~Screen.x #0008 ADD2 =Screen.x ( incr ) .Screen/x DEI2 #0008 ADD2 .Screen/x DEO2
DUP2 PEK2 #00 NEQ ^$loop JNZ DUP2 GET #00 NEQ ,&loop JNZ
POP2 POP2
RTN RTN
@ -83,14 +89,14 @@ RTN
@get-text-length ( label* -- length ) @get-text-length ( label* -- length )
#0000 ( counter ) #0000 ( counter )
$loop &loop
( incr ) #0001 ADD2 OVR2 OVR2 ADD2 ( incr ) #0001 ADD2 OVR2 OVR2 ADD2
PEK2 #00 NEQ ^$loop JNZ GET #00 NEQ ,&loop JNZ
SWP2 POP2 SWP2 POP2
RTN 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 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 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 0008 0808 0808 0800 0030 1008 0810 3000 0000 0032 4c00 0000 3c42 99a1 a199 423c
] ]
@text1 [ Left 20 Aligned 00 ] @text1 [ "Left 20 "Aligned 00 ]
@text2 [ Middle 20 Aligned 00 ] @text2 [ "Middle 20 "Aligned 00 ]
@text3 [ Right 20 Aligned 00 ] @text3 [ "Right 20 "Aligned 00 ]
@text4 [ even 00 ] @text4 [ "even 00 ]
@text5 [ odd 00 ] @text5 [ "odd 00 ]

View File

@ -1,103 +1,109 @@
( GUI Picture ) ( GUI Picture )
%RTN { JMP2r } %RTN { JMP2r }
%8+ { #0008 ADD2 } %8+ { #0008 ADD2 }
;color { byte 1 } ( devices )
;position { x 2 y 2 }
;size { width 2 height 2 }
|0100 ;System { vector 2 pad 6 r 2 g 2 b 2 } |00 @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 } |10 @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 } |20 @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 } |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 ) ( 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 ( load ) ;icn1_path .File/name DEO2 #1800 .File/length DEO2 ;image .File/load DEO2
( draw ) #0008 #0008 #0100 #00c0 #27 ,image ,draw-icn JSR2 ( draw ) #0008 #0008 #0100 #00c0 #27 ;image ;draw-icn JSR2
( load ) ,icn2_path =File.name #0800 =File.length ,image =File.load ( load ) ;icn2_path .File/name DEO2 #0800 .File/length DEO2 ;image .File/load DEO2
( draw ) #0010 #0078 #0080 #0080 #27 ,image ,draw-icn JSR2 ( draw ) #0010 #0078 #0080 #0080 #27 ;image ;draw-icn JSR2
( load ) ,chr1_path =File.name #4000 =File.length ,image =File.load ( load ) ;chr1_path .File/name DEO2 #4000 .File/length DEO2 ;image .File/load DEO2
( draw ) #00a8 #0010 #0100 #0100 #4f ,image ,draw-chr JSR2 ( draw ) #00a8 #0010 #0100 #0100 #4f ;image ;draw-chr JSR2
( load ) ,chr2_path =File.name #0900 =File.length ,image =File.load ( load ) ;chr2_path .File/name DEO2 #0900 .File/length DEO2 ;image .File/load DEO2
( draw ) #0088 #0088 #0060 #0060 #41 ,image ,draw-chr JSR2 ( draw ) #0088 #0088 #0060 #0060 #41 ;image ;draw-chr JSR2
BRK BRK
@draw-icn ( x y width height color addr -- ) @draw-icn ( x y width height color addr -- )
( load ) =Screen.addr =color =size.height =size.width =position.y =position.x ( load ) .Screen/addr DEO2 .color POK .size/height POK2 .size/width POK2 .position/y POK2 .position/x POK2
#0000 ~size.height #0000 .size/height PEK2
$ver &ver
( save ) OVR2 ~position.y ADD2 =Screen.y ( save ) OVR2 .position/y PEK2 ADD2 .Screen/y DEO2
#0000 ~size.width #0000 .size/width PEK2
$hor &hor
( save ) OVR2 ~position.x ADD2 =Screen.x ( save ) OVR2 .position/x PEK2 ADD2 .Screen/x DEO2
( draw ) ~color =Screen.color ( draw ) .color PEK .Screen/color DEO
( incr ) ~Screen.addr 8+ =Screen.addr ( incr ) .Screen/addr DEI2 8+ .Screen/addr DEO2
( incr ) SWP2 8+ SWP2 ( incr ) SWP2 8+ SWP2
OVR2 OVR2 LTH2 ^$hor JNZ OVR2 OVR2 LTH2 ,&hor JNZ
POP2 POP2 POP2 POP2
( incr ) SWP2 8+ SWP2 ( incr ) SWP2 8+ SWP2
OVR2 OVR2 LTH2 ^$ver JNZ OVR2 OVR2 LTH2 ,&ver JNZ
POP2 POP2 POP2 POP2
RTN RTN
@draw-chr ( x y width height color addr -- ) @draw-chr ( x y width height color addr -- )
( load ) =Screen.addr =color =size.height =size.width =position.y =position.x ( load ) .Screen/addr DEO2 .color POK .size/height POK2 .size/width POK2 .position/y POK2 .position/x POK2
#0000 ~size.height #0000 .size/height PEK2
$ver &ver
( save ) OVR2 ~position.y ADD2 =Screen.y ( save ) OVR2 .position/y PEK2 ADD2 .Screen/y DEO2
#0000 ~size.width #0000 .size/width PEK2
$hor &hor
( save ) OVR2 ~position.x ADD2 =Screen.x ( save ) OVR2 .position/x PEK2 ADD2 .Screen/x DEO2
( draw ) ~color =Screen.color ( draw ) .color PEK .Screen/color DEO
( incr ) ~Screen.addr #0010 ADD2 =Screen.addr ( incr ) .Screen/addr DEI2 #0010 ADD2 .Screen/addr DEO2
( incr ) SWP2 8+ SWP2 ( incr ) SWP2 8+ SWP2
OVR2 OVR2 LTH2 ^$hor JNZ OVR2 OVR2 LTH2 ,&hor JNZ
POP2 POP2 POP2 POP2
( incr ) SWP2 8+ SWP2 ( incr ) SWP2 8+ SWP2
OVR2 OVR2 LTH2 ^$ver JNZ OVR2 OVR2 LTH2 ,&ver JNZ
POP2 POP2 POP2 POP2
RTN RTN
@cover-pattern ( addr color -- ) @cover-pattern ( addr color -- )
( load ) =color =Screen.addr ( load ) .color POK .Screen/addr DEO2
#0000 ~Screen.height #0000 .Screen/height DEI2
$ver &ver
( save ) OVR2 =Screen.y ( save ) OVR2 .Screen/y DEO2
#0000 ~Screen.width #0000 .Screen/width DEI2
$hor &hor
( save ) OVR2 =Screen.x ( save ) OVR2 .Screen/x DEO2
( draw ) ~color =Screen.color ( draw ) .color PEK .Screen/color DEO
( incr ) SWP2 8+ SWP2 ( incr ) SWP2 8+ SWP2
OVR2 OVR2 LTH2 ^$hor JNZ OVR2 OVR2 LTH2 ,&hor JNZ
POP2 POP2 POP2 POP2
( incr ) SWP2 8+ SWP2 ( incr ) SWP2 8+ SWP2
OVR2 OVR2 LTH2 ^$ver JNZ OVR2 OVR2 LTH2 ,&ver JNZ
POP2 POP2 POP2 POP2
RTN RTN
@checker_icn [ f0f0 f0f0 0f0f 0f0f ] @checker_icn [ f0f0 f0f0 0f0f 0f0f ]
@icn1_path [ projects/pictures/ergo100x0c0.bit 00 ] @icn1_path [ "projects/pictures/ergo100x0c0.bit 00 ]
@icn2_path [ projects/pictures/dafu80x80.bit 00 ] @icn2_path [ "projects/pictures/dafu80x80.bit 00 ]
@chr1_path [ projects/pictures/zerotwo2020.chr 00 ] @chr1_path [ "projects/pictures/zerotwo2020.chr 00 ]
@chr2_path [ projects/pictures/felix0cx0c.chr 00 ] @chr2_path [ "projects/pictures/felix0cx0c.chr 00 ]
@image [ ] @image [ ]

View File

@ -7,147 +7,153 @@
%ABS2 { DUP2 #000f SFT2 EQU #04 JNZ #ffff MUL2 } %ABS2 { DUP2 #000f SFT2 EQU #04 JNZ #ffff MUL2 }
%SIZE-TO-RECT { %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 ) } ( x y w h -- x1 y1 x2 y2 )
( 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 )
|0000
( draw requirements ) ( draw requirements )
;color { byte 1 } @color [ &byte $1 ]
;rect { x1 2 y1 2 x2 2 y2 2 } @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 } @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 } @circle [ &xc $2 &yc $2 &x $2 &y $2 &r $2 &d $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 }
( program ) ( 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 #0010 #0030 #0020 #0020 SIZE-TO-RECT #01 ;line-slow JSR2
#0070 #0040 #0010 #01 ,draw-circle JSR2 #0070 #0040 #0010 #01 ;draw-circle JSR2
#0038 #0030 #0020 #0020 SIZE-TO-RECT #01 ,line-rect JSR2 #0038 #0030 #0020 #0020 SIZE-TO-RECT #01 ;line-rect JSR2
#0038 #0058 #0020 #0020 SIZE-TO-RECT #01 ,fill-rect JSR2 #0038 #0058 #0020 #0020 SIZE-TO-RECT #01 ;fill-rect JSR2
BRK BRK
@line-slow ( x1 y1 x2 y2 color -- ) @line-slow ( x1 y1 x2 y2 color -- )
( load ) =color -- =line.y0 -- =line.x0 =line.y =line.x ( load ) .color POK -- .line/y0 POK2 -- .line/x0 POK2 .line/y POK2 .line/x POK2
~line.x0 ~line.x SUB2 ABS2 =line.dx .line/x0 PEK2 .line/x PEK2 SUB2 ABS2 .line/dx POK2
~line.y0 ~line.y SUB2 ABS2 #0000 SWP2 SUB2 =line.dy .line/y0 PEK2 .line/y PEK2 SUB2 ABS2 #0000 SWP2 SUB2 .line/dy POK2
#ffff #00 ~line.x ~line.x0 LTS2 #0002 MUL2 ADD2 =line.sx #ffff #00 .line/x PEK2 .line/x0 PEK2 LTS2 #0002 MUL2 ADD2 .line/sx POK2
#ffff #00 ~line.y ~line.y0 LTS2 #0002 MUL2 ADD2 =line.sy #ffff #00 .line/y PEK2 .line/y0 PEK2 LTS2 #0002 MUL2 ADD2 .line/sy POK2
~line.dx ~line.dy ADD2 =line.e1 .line/dx PEK2 .line/dy PEK2 ADD2 .line/e1 POK2
$loop &loop
~line.x =Screen.x ~line.y =Screen.y ~color =Screen.color .line/x PEK2 .Screen/x DEO2 .line/y PEK2 .Screen/y DEO2 .color PEK .Screen/color DEO
~line.x ~line.x0 EQU2 ~line.y ~line.y0 EQU2 #0101 EQU2 ^$end JNZ .line/x PEK2 .line/x0 PEK2 EQU2 .line/y PEK2 .line/y0 PEK2 EQU2 #0101 EQU2 ,&end JNZ
~line.e1 #0002 MUL2 =line.e2 .line/e1 PEK2 #0002 MUL2 .line/e2 POK2
~line.e2 ~line.dy LTS2 ^$skipy JNZ .line/e2 PEK2 .line/dy PEK2 LTS2 ,&skipy JNZ
~line.e1 ~line.dy ADD2 =line.e1 .line/e1 PEK2 .line/dy PEK2 ADD2 .line/e1 POK2
~line.x ~line.sx ADD2 =line.x .line/x PEK2 .line/sx PEK2 ADD2 .line/x POK2
$skipy &skipy
~line.e2 ~line.dx GTS2 ^$skipx JNZ .line/e2 PEK2 .line/dx PEK2 GTS2 ,&skipx JNZ
~line.e1 ~line.dx ADD2 =line.e1 .line/e1 PEK2 .line/dx PEK2 ADD2 .line/e1 POK2
~line.y ~line.sy ADD2 =line.y .line/y PEK2 .line/sy PEK2 ADD2 .line/y POK2
$skipx &skipx
,$loop JMP2 ;&loop JMP2
$end &end
RTN RTN
@line-rect ( x1 y1 x2 y2 color -- ) @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 STH2r STH2r
$ver &ver
( save ) OVR2 =Screen.y ( save ) OVR2 .Screen/y DEO2
( draw ) ~rect.x1 =Screen.x ~color DUP =Screen.color ( draw ) .rect/x1 PEK2 .Screen/x DEO2 .color PEK DUP .Screen/color DEO
( draw ) ~rect.x2 =Screen.x =Screen.color ( draw ) .rect/x2 PEK2 .Screen/x DEO2 .Screen/color DEO
( incr ) SWP2 ++ SWP2 ( incr ) SWP2 ++ SWP2
OVR2 OVR2 LTS2 ^$ver JNZ OVR2 OVR2 LTS2 ,&ver JNZ
POP2 POP2 POP2 POP2
~rect.x1 ~rect.x2 .rect/x1 PEK2 .rect/x2 PEK2
$hor &hor
( save ) OVR2 =Screen.x ( save ) OVR2 .Screen/x DEO2
( draw ) ~rect.y1 =Screen.y ~color DUP =Screen.color ( draw ) .rect/y1 PEK2 .Screen/y DEO2 .color PEK DUP .Screen/color DEO
( draw ) ~rect.y2 =Screen.y =Screen.color ( draw ) .rect/y2 PEK2 .Screen/y DEO2 .Screen/color DEO
( incr ) SWP2 ++ SWP2 ( incr ) SWP2 ++ SWP2
OVR2 OVR2 ++ LTS2 ^$hor JNZ OVR2 OVR2 ++ LTS2 ,&hor JNZ
POP2 POP2 POP2 POP2
RTN RTN
@fill-rect ( x1 y1 x2 y2 color -- ) @fill-rect ( x1 y1 x2 y2 color -- )
=color .color POK
( x1 x2 y1 y2 ) ROT2 SWP2 ( x1 x2 y1 y2 ) ROT2 SWP2
$ver &ver
( save ) OVR2 =Screen.y ( save ) OVR2 .Screen/y DEO2
STH2 STH2 OVR2 OVR2 STH2 STH2 OVR2 OVR2
$hor &hor
( save ) OVR2 =Screen.x ( save ) OVR2 .Screen/x DEO2
( draw ) ~color =Screen.color ( draw ) .color PEK .Screen/color DEO
( incr ) SWP2 ++ SWP2 ( incr ) SWP2 ++ SWP2
OVR2 OVR2 LTS2 ^$hor JNZ OVR2 OVR2 LTS2 ,&hor JNZ
POP2 POP2 STH2r STH2r POP2 POP2 STH2r STH2r
( incr ) SWP2 ++ SWP2 ( incr ) SWP2 ++ SWP2
OVR2 OVR2 LTS2 ^$ver JNZ OVR2 OVR2 LTS2 ,&ver JNZ
POP2 POP2 POP2 POP2 POP2 POP2 POP2 POP2
RTN RTN
@draw-circle ( xc yc r color -- ) @draw-circle ( xc yc r color -- )
( load ) =color =circle.r =circle.yc =circle.xc ( load ) .color POK .circle/r POK2 .circle/yc POK2 .circle/xc POK2
#0000 =circle.x ~circle.r =circle.y #0000 .circle/x POK2 .circle/r PEK2 .circle/y POK2
~circle.r #0002 MUL2 =circle.d .circle/r PEK2 #0002 MUL2 .circle/d POK2
( draw ) ,$seg JSR2 ( draw ) ;&seg JSR2
$loop &loop
( incr ) ~circle.x ++ =circle.x ( incr ) .circle/x PEK2 ++ .circle/x POK2
~circle.d #0001 LTS2 ^$else JNZ .circle/d PEK2 #0001 LTS2 ,&else JNZ
( decr ) ~circle.y -- =circle.y ( decr ) .circle/y PEK2 -- .circle/y POK2
~circle.x ~circle.y SUB2 #0004 MUL2 ~circle.d ADD2 =circle.d .circle/x PEK2 .circle/y PEK2 SUB2 #0004 MUL2 .circle/d PEK2 ADD2 .circle/d POK2
,$end JMP2 ;&end JMP2
$else &else
~circle.x #0004 MUL2 ~circle.d ADD2 =circle.d .circle/x PEK2 #0004 MUL2 .circle/d PEK2 ADD2 .circle/d POK2
$end &end
( draw ) ,$seg JSR2 ( draw ) ;&seg JSR2
~circle.y ~circle.x -- GTS2 ^$loop JNZ .circle/y PEK2 .circle/x PEK2 -- GTS2 ,&loop JNZ
RTN RTN
$seg &seg
~circle.xc ~circle.x ADD2 =Screen.x ~circle.yc ~circle.y ADD2 =Screen.y ~color =Screen.color .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 ~circle.x SUB2 =Screen.x ~circle.yc ~circle.y ADD2 =Screen.y ~color =Screen.color .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 ~circle.x ADD2 =Screen.x ~circle.yc ~circle.y SUB2 =Screen.y ~color =Screen.color .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 ~circle.x SUB2 =Screen.x ~circle.yc ~circle.y SUB2 =Screen.y ~color =Screen.color .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 ~circle.y ADD2 =Screen.x ~circle.yc ~circle.x ADD2 =Screen.y ~color =Screen.color .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 ~circle.y SUB2 =Screen.x ~circle.yc ~circle.x ADD2 =Screen.y ~color =Screen.color .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 ~circle.y ADD2 =Screen.x ~circle.yc ~circle.x SUB2 =Screen.y ~color =Screen.color .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 ~circle.y SUB2 =Screen.x ~circle.yc ~circle.x SUB2 =Screen.y ~color =Screen.color .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 RTN
@cover-pattern ( addr color -- ) @cover-pattern ( addr color -- )
( load ) =color =Screen.addr ( load ) .color POK .Screen/addr DEO2
#0000 ~Screen.height #0000 .Screen/height DEI2
$ver &ver
( save ) OVR2 =Screen.y ( save ) OVR2 .Screen/y DEO2
#0000 ~Screen.width #0000 .Screen/width DEI2
$hor &hor
( save ) OVR2 =Screen.x ( save ) OVR2 .Screen/x DEO2
( draw ) ~color =Screen.color ( draw ) .color PEK .Screen/color DEO
( incr ) SWP2 8+ SWP2 ( incr ) SWP2 8+ SWP2
OVR2 OVR2 LTH2 ^$hor JNZ OVR2 OVR2 LTH2 ,&hor JNZ
POP2 POP2 POP2 POP2
( incr ) SWP2 8+ SWP2 ( incr ) SWP2 8+ SWP2
OVR2 OVR2 LTH2 ^$ver JNZ OVR2 OVR2 LTH2 ,&ver JNZ
POP2 POP2 POP2 POP2
RTN RTN

View File

@ -1,65 +1,69 @@
;scroll { x 2 y 2 wait 1 }
( devices ) ( devices )
|0100 ;System { vector 2 pad 6 r 2 g 2 b 2 } |00 @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 } |10 @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 } |20 @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 } |30 @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 } |40 @Controller [ &vector $2 &button $1 &key $1 ]
|0160 ;Mouse { vector 2 x 2 y 2 state 1 chord 1 } |60 @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 } |70 @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 } |a0 @DateTime [ &year $2 &month $1 &day $1 &hour $1 &minute $1 &second $1 &dotw $1 &doty $2 &isdst $1 &refresh $1 ]
|0200 ( variables )
#90ff =System.r #9000 =System.g #900f =System.b
#08e0 ~Screen.width #0001 SFT2 SUB2 =scroll.x |0000
#09b0 =scroll.y
,frame =Screen.vector @scroll [ &x $2 &y $2 &wait $1 ]
#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 ( -> ) @frame ( -> )
#ffff #ffff
$loop &loop
DUP2 ^row JSR DUP2 ,row JSR
#0001 ADD2 #0001 ADD2
DUP2 ~Screen.height LTH2 ^$loop JNZ DUP2 .Screen/height DEI2 LTH2 ,&loop JNZ
POP2 POP2
~scroll.wait ^$noscroll JNZ .scroll/wait PEK ,&noscroll JNZ
~scroll.y #0001 ADD2 =scroll.y .scroll/y PEK2 #0001 ADD2 .scroll/y POK2
BRK BRK
$noscroll &noscroll
~scroll.wait #01 SUB =scroll.wait .scroll/wait PEK #01 SUB .scroll/wait POK
BRK BRK
@row ( y* -- ) @row ( y* -- )
DUP2 =Screen.y DUP2 .Screen/y DEO2
~scroll.y ADD2 .scroll/y PEK2 ADD2
~Screen.width .Screen/width DEI2
$loop &loop
#0001 SUB2 #0001 SUB2
OVR2 OVR2 ~scroll.x ADD2 EOR2 DUP2 #0013 DIV2 #0013 MUL2 SUB2 OVR2 OVR2 .scroll/x PEK2 ADD2 EOR2 DUP2 #0013 DIV2 #0013 MUL2 SUB2
DUP #00 EQU ^$draw JNZ DUP #00 EQU ,&draw JNZ
DUP #05 EQU ^$draw JNZ DUP #05 EQU ,&draw JNZ
POP2 POP2
$rest &rest
DUP2 ORA ^$loop JNZ DUP2 ORA ,&loop JNZ
POP2 POP2 POP2 POP2
JMP2r JMP2r
#15 =Screen.color #15 .Screen/color DEO
JMP2r JMP2r
$draw &draw
OVR2 =Screen.x OVR2 .Screen/x DEO2
#05 ADD =Screen.color #05 ADD .Screen/color DEO
~Screen.y .Screen/y DEI2
DUP2 #0001 ADD2 =Screen.y DUP2 #0001 ADD2 .Screen/y DEO2
#00 =Screen.color #00 .Screen/color DEO
=Screen.y .Screen/y DEO2
POP POP
^$rest JMP ,&rest JMP

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -1,4 +1,4 @@
( Orca ( Orca
TODO TODO
- Synthax highlight - Synthax highlight
@ -21,145 +21,145 @@
%DATA-LOCKS { #3000 } %DATA-LOCKS { #3000 }
%DATA-TYPES { #4000 } %DATA-TYPES { #4000 }
%GET-CHAR { #24 MOD #00 SWP ,b36clc ADD2 PEK2 } ( b36 -- char ) %GET-CHAR { #24 MOD #00 SWP ;b36clc ADD2 GET } ( b36 -- char )
%GET-VALUE { #20 SUB #00 SWP ,values ADD2 PEK2 } ( char -- b36 ) %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-INDEX { #00 SWP #00 .grid/width PEK MUL2 ROT #00 SWP ADD2 } ( x y -- index )
%GET-CELL { GET-INDEX DATA-CELLS ADD2 PEK2 } ( x y -- char ) %GET-CELL { GET-INDEX DATA-CELLS ADD2 GET } ( x y -- char )
%SET-CELL { ROT ROT GET-INDEX DATA-CELLS ADD2 POK2 } ( x y char -- ) %SET-CELL { ROT ROT GET-INDEX DATA-CELLS ADD2 PUT } ( x y char -- )
%GET-TYPE { GET-INDEX DATA-TYPES ADD2 PEK2 } ( x y -- type ) %GET-TYPE { GET-INDEX DATA-TYPES ADD2 GET } ( x y -- type )
%SET-TYPE { ROT ROT GET-INDEX DATA-TYPES ADD2 POK2 } ( x y type -- ) %SET-TYPE { ROT ROT GET-INDEX DATA-TYPES ADD2 PUT } ( x y type -- )
%GET-LOCK { GET-INDEX DATA-TYPES ADD2 PEK2 } ( x y -- type ) %GET-LOCK { GET-INDEX DATA-TYPES ADD2 GET } ( x y -- type )
%SET-LOCK { ROT ROT GET-INDEX DATA-TYPES ADD2 POK2 } ( x y type -- ) %SET-LOCK { ROT ROT GET-INDEX DATA-TYPES ADD2 PUT } ( x y type -- )
%GET-PORT { } ( x y lock -- char ) %GET-PORT { } ( x y lock -- char )
%SET-PORT { } ( x y char -- ) %SET-PORT { } ( x y char -- )
%GET-CELL-VALUE { GET-CELL GET-VALUE } ( x y -- b36 ) %GET-CELL-VALUE { GET-CELL GET-VALUE } ( x y -- b36 )
( variables )
;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 }
( devices ) ( devices )
|0100 ;System { vector 2 pad 6 r 2 g 2 b 2 } |00 @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 } |10 @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 } |20 @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 } |40 @Controller [ &vector $2 &button $1 &key $1 ]
|0160 ;Mouse { vector 2 x 2 y 2 state 1 chord 1 } |60 @Mouse [ &vector $2 &x $2 &y $2 &state $1 &chord $1 ]
|0200 ( variables )
( theme ) #08f3 =System.r #08fc =System.g #08f9 =System.b @timer [ &byte $1 &frame $1 &speed $1 ]
( vectors ) ,on-button =Controller.vector @grid [ &width $1 &height $1 ]
( vectors ) ,on-mouse =Mouse.vector @selection [ &x1 $1 &y1 $1 &x2 $1 &y2 $1 ]
( vectors ) ,on-frame =Screen.vector @cursor [ &x $2 &y $2 ]
|0100
( 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 ) ( find size )
~Screen.width 8/ SWP POP =grid.width .Screen/width DEI2 8/ SWP POP .grid/width POK
~Screen.height 8/ SWP POP #02 SUB =grid.height .Screen/height DEI2 8/ SWP POP #02 SUB .grid/height POK
( fill grid with dots ) ( fill grid with dots )
,start JSR2 ;start JSR2
,redraw JSR2 ;redraw JSR2
BRK BRK
@on-frame @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 BRK
@on-button @on-button
~Controller.key #00 EQU ^$no-key JNZ .Controller/key DEI #00 EQU ,&no-key JNZ
~selection.x1 ~selection.y1 ~Controller.key SET-CELL .selection/x1 PEK .selection/y1 PEK .Controller/key DEI SET-CELL
,redraw JSR2 ;redraw JSR2
$no-key &no-key
( arrows ) ( arrows )
~Controller.button #f0 AND .Controller/button DEI #f0 AND
DUP #04 SFT #01 AND #01 NEQ ^$no-up JNZ DUP #04 SFT #01 AND #01 NEQ ,&no-up JNZ
~selection.y1 #00 EQU ^$no-up JNZ .selection/y1 PEK #00 EQU ,&no-up JNZ
~selection.y1 -- =selection.y1 .selection/y1 PEK -- .selection/y1 POK
~selection.y2 -- =selection.y2 $no-up .selection/y2 PEK -- .selection/y2 POK &no-up
DUP #05 SFT #01 AND #01 NEQ ^$no-down JNZ DUP #05 SFT #01 AND #01 NEQ ,&no-down JNZ
~selection.y1 ~grid.height -- EQU ^$no-down JNZ .selection/y1 PEK .grid/height PEK -- EQU ,&no-down JNZ
~selection.y1 ++ =selection.y1 .selection/y1 PEK ++ .selection/y1 POK
~selection.y2 ++ =selection.y2 $no-down .selection/y2 PEK ++ .selection/y2 POK &no-down
DUP #06 SFT #01 AND #01 NEQ ^$no-left JNZ DUP #06 SFT #01 AND #01 NEQ ,&no-left JNZ
~selection.x1 #00 EQU ^$no-left JNZ .selection/x1 PEK #00 EQU ,&no-left JNZ
~selection.x1 -- =selection.x1 .selection/x1 PEK -- .selection/x1 POK
~selection.x2 -- =selection.x2 $no-left .selection/x2 PEK -- .selection/x2 POK &no-left
DUP #07 SFT #01 AND #01 NEQ ^$no-right JNZ DUP #07 SFT #01 AND #01 NEQ ,&no-right JNZ
~selection.x1 ~grid.width -- EQU ^$no-right JNZ .selection/x1 PEK .grid/width PEK -- EQU ,&no-right JNZ
~selection.x1 ++ =selection.x1 .selection/x1 PEK ++ .selection/x1 POK
~selection.x2 ++ =selection.x2 $no-right .selection/x2 PEK ++ .selection/x2 POK &no-right
POP POP
~Controller.key #08 NEQ ^$no-backspace JNZ .Controller/key DEI #08 NEQ ,&no-backspace JNZ
~selection.x1 ~selection.y1 #2e SET-CELL ( put . char ) .selection/x1 PEK .selection/y1 PEK #2e SET-CELL ( put . char )
$no-backspace &no-backspace
,redraw JSR2 ;redraw JSR2
BRK BRK
@on-mouse @on-mouse
~Mouse.state #00 EQU ^$no-touch JNZ .Mouse/state DEI #00 EQU ,&no-touch JNZ
~Mouse.x 8/ SWP POP =selection.x1 .Mouse/x DEI2 8/ SWP POP .selection/x1 POK
~Mouse.y 8/ SWP POP =selection.y1 .Mouse/y DEI2 8/ SWP POP .selection/y1 POK
,redraw JSR2 ;redraw JSR2
$no-touch &no-touch
( clear last cursor ) ( clear last cursor )
~cursor.x =Screen.x .cursor/x PEK2 .Screen/x DEO2
~cursor.y =Screen.y .cursor/y PEK2 .Screen/y DEO2
,blank_icn =Screen.addr ;blank_icn .Screen/addr DEO2
#30 =Screen.color #30 .Screen/color DEO
( record cursor positions ) ( record cursor positions )
~Mouse.x =cursor.x .Mouse/x DEI2 .cursor/x POK2
~Mouse.y =cursor.y .Mouse/y DEI2 .cursor/y POK2
( draw new cursor ) ( draw new cursor )
~cursor.x =Screen.x .cursor/x PEK2 .Screen/x DEO2
~cursor.y =Screen.y .cursor/y PEK2 .Screen/y DEO2
,cursor_icn =Screen.addr ;cursor_icn .Screen/addr DEO2
#32 ~Mouse.state #01 EQU ADD =Screen.color #32 .Mouse/state DEI #01 EQU ADD .Screen/color DEO
BRK BRK
@start ( -- ) @start ( -- )
#00 ~grid.height #00 .grid/height PEK
$ver &ver
#00 ~grid.width #00 .grid/width PEK
$hor &hor
( get x,y ) SWP2 OVR STH SWP2 OVR STHr ( get x,y ) SWP2 OVR STH SWP2 OVR STHr
#2e SET-CELL #2e SET-CELL
( incr ) SWP ++ SWP ( incr ) SWP ++ SWP
DUP2 LTH ^$hor JNZ DUP2 LTH ,&hor JNZ
POP2 POP2
( incr ) SWP ++ SWP ( incr ) SWP ++ SWP
DUP2 LTH ^$ver JNZ DUP2 LTH ,&ver JNZ
POP2 POP2
#9a =timer.speed #9a .timer/speed POK
RTN RTN
@ -172,7 +172,7 @@ RTN
@is-selected ( x y -- flag ) @is-selected ( x y -- flag )
~selection.x1 ~selection.y1 EQU2 .selection/x1 PEK .selection/y1 PEK EQU2
RTN RTN
@ -190,17 +190,17 @@ RTN
@get-cell-sprite ( x y -- addr ) @get-cell-sprite ( x y -- addr )
DUP2 GET-CELL DUP2 GET-CELL
( if character is dot ) ( if character is dot )
DUP #2e NEQ ^$no-bar JNZ DUP #2e NEQ ,&no-bar JNZ
( check if x,y is grid ) ( check if x,y is grid )
POP POP
DUP2 #08 MOD #00 EQU SWP #08 MOD #00 EQU #0101 NEQ2 ^$no-marker8 JNZ POP2 ,marker8_icn RTN $no-marker8 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 DUP2 #02 MOD #00 EQU SWP #02 MOD #00 EQU #0101 NEQ2 ,&no-marker4 JNZ POP2 ;marker4_icn RTN &no-marker4
POP2 ,font RTN POP2 ;font RTN
$no-bar &no-bar
STH POP2 STHr STH POP2 STHr
#20 SUB #00 SWP #0008 MUL2 ,font ADD2 #20 SUB #00 SWP #0008 MUL2 ;font ADD2
RTN RTN
@ -211,9 +211,9 @@ RTN
POP POP
( get left ) DUP2 SWP -- SWP GET-CELL-VALUE STH ( get left ) DUP2 SWP -- SWP GET-CELL-VALUE STH
( get right ) 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 result ) ADDr STHr
GET-CHAR GET-CHAR
SET-CELL SET-CELL
RTN RTN
@ -223,9 +223,9 @@ RTN
POP POP
( get left ) DUP2 SWP -- SWP GET-CELL-VALUE STH ( get left ) DUP2 SWP -- SWP GET-CELL-VALUE STH
( get right ) DUP2 SWP ++ SWP GET-CELL-VALUE STH ( get right ) DUP2 SWP ++ SWP GET-CELL-VALUE STH
( incr y ) ++ ( incr y ) ++
( get result ) SUBr STHr ( get result ) SUBr STHr
GET-CHAR GET-CHAR
SET-CELL SET-CELL
( NOTE: Issue is not with modulo, but with converting ff to 36 ) ( NOTE: Issue is not with modulo, but with converting ff to 36 )
@ -236,7 +236,7 @@ RTN
POP POP
++ ++
#30 ~timer.frame #08 MOD ADD SET-CELL #30 .timer/frame PEK #08 MOD ADD SET-CELL
RTN RTN
@ -304,13 +304,13 @@ RTN
STH STH
( limit ) ( limit )
DUP #00 NEQ ^$not-edge JNZ DUP #00 NEQ ,&not-edge JNZ
#2a SET-CELL POP STHr RTN
$not-edge
( collide )
DUP2 -- GET-CELL #2e EQU ^$not-collide JNZ
#2a SET-CELL POP STHr RTN #2a SET-CELL POP STHr RTN
$not-collide &not-edge
( collide )
DUP2 -- GET-CELL #2e EQU ,&not-collide JNZ
#2a SET-CELL POP STHr RTN
&not-collide
( move ) ( move )
DUP2 STHr DUP2 STHr
SWP -- SWP SET-CELL SWP -- SWP SET-CELL
@ -344,7 +344,7 @@ RTN
@op-s ( x y char -- ) @op-s ( x y char -- )
STH STH
( clear ) DUP2 #2e SET-CELL ( clear ) DUP2 #2e SET-CELL
( move ) ++ DUP2 #01 SET-LOCK ( move ) ++ DUP2 #01 SET-LOCK
STHr SET-CELL STHr SET-CELL
@ -373,15 +373,15 @@ RTN
STH STH
( limit ) ( limit )
OVR #00 NEQ ^$not-edge JNZ 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
#2a SET-CELL POP STHr RTN #2a SET-CELL POP STHr RTN
$not-collide &not-edge
( collide )
DUP2 SWP -- SWP GET-CELL #2e EQU ,&not-collide JNZ
#2a SET-CELL POP STHr RTN
&not-collide
( move ) ( move )
DUP2 DUP2
SWP -- SWP STHr SET-CELL SWP -- SWP STHr SET-CELL
#2e SET-CELL #2e SET-CELL
@ -415,149 +415,149 @@ RTN
@run-char ( x y char -- ) @run-char ( x y char -- )
( skip dot ) ( skip dot )
DUP #2e NEQ ^$not-dot JNZ DUP #2e NEQ ,&not-dot JNZ
POP POP2 RTN POP POP2 RTN
$not-dot &not-dot
( skip locked ) ( skip locked )
ROT ROT DUP2 GET-LOCK #00 EQU ^$not-locked JNZ ROT ROT DUP2 GET-LOCK #00 EQU ,&not-locked JNZ
POP POP2 RTN POP POP2 RTN
$not-locked &not-locked
ROT ROT
( A ) DUP #41 EQU ,op-a JNZ2 ( B ) DUP #42 EQU ,op-b 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 ( 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 ( 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 ( 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 ( 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 ( 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 ( 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 ( 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 ( 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 ( 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 ( 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 ( 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 ( Y ) DUP #59 EQU ;op-y JNZ2 ( Z ) DUP #5a EQU ;op-z JNZ2
( * ) DUP #2a EQU ,op-bang JNZ2 ( * ) DUP #2a EQU ;op-bang JNZ2
POP POP2 POP POP2
RTN RTN
@init ( -- ) @init ( -- )
#00 ~grid.height #00 .grid/height PEK
$ver &ver
#00 ~grid.width #00 .grid/width PEK
$hor &hor
( get x,y ) SWP2 OVR STH SWP2 OVR STHr ( get x,y ) SWP2 OVR STH SWP2 OVR STHr
( unlock ) #00 SET-LOCK ( unlock ) #00 SET-LOCK
( incr ) SWP ++ SWP ( incr ) SWP ++ SWP
DUP2 LTH ^$hor JNZ DUP2 LTH ,&hor JNZ
POP2 POP2
( incr ) SWP ++ SWP ( incr ) SWP ++ SWP
DUP2 LTH ^$ver JNZ DUP2 LTH ,&ver JNZ
POP2 POP2
RTN RTN
@run ( -- ) @run ( -- )
,init JSR2 ;init JSR2
#00 ~grid.height #00 .grid/height PEK
$ver &ver
#00 ~grid.width #00 .grid/width PEK
$hor &hor
( get x,y ) SWP2 OVR STH SWP2 OVR STHr ( get x,y ) SWP2 OVR STH SWP2 OVR STHr
DUP2 GET-CELL ,run-char JSR2 DUP2 GET-CELL ;run-char JSR2
( incr ) SWP ++ SWP ( incr ) SWP ++ SWP
DUP2 LTH ^$hor JNZ DUP2 LTH ,&hor JNZ
POP2 POP2
( incr ) SWP ++ SWP ( incr ) SWP ++ SWP
DUP2 LTH ^$ver JNZ DUP2 LTH ,&ver JNZ
POP2 POP2
,redraw JSR2 ;redraw JSR2
RTN RTN
@draw-interface ( -- ) @draw-interface ( -- )
~Screen.height #0008 SUB2 =Screen.y .Screen/height DEI2 #0008 SUB2 .Screen/y DEO2
( Positionx ) ( Positionx )
#0000 =Screen.x #0000 .Screen/x DEO2
~selection.x1 .selection/x1 PEK
DUP #04 SFT GET-CHAR #20 SUB #00 SWP #0008 MUL2 ,font ADD2 =Screen.addr DUP #04 SFT GET-CHAR #20 SUB #00 SWP #0008 MUL2 ;font ADD2 .Screen/addr DEO2
#22 =Screen.color #22 .Screen/color DEO
#0008 =Screen.x #0008 .Screen/x DEO2
#0f AND GET-CHAR #20 SUB #00 SWP #0008 MUL2 ,font ADD2 =Screen.addr #0f AND GET-CHAR #20 SUB #00 SWP #0008 MUL2 ;font ADD2 .Screen/addr DEO2
#22 =Screen.color #22 .Screen/color DEO
( Positiony ) ( Positiony )
#0010 =Screen.x #0010 .Screen/x DEO2
~selection.y1 .selection/y1 PEK
DUP #04 SFT GET-CHAR #20 SUB #00 SWP #0008 MUL2 ,font ADD2 =Screen.addr DUP #04 SFT GET-CHAR #20 SUB #00 SWP #0008 MUL2 ;font ADD2 .Screen/addr DEO2
#22 =Screen.color #22 .Screen/color DEO
#0018 =Screen.x #0018 .Screen/x DEO2
#0f AND GET-CHAR #20 SUB #00 SWP #0008 MUL2 ,font ADD2 =Screen.addr #0f AND GET-CHAR #20 SUB #00 SWP #0008 MUL2 ;font ADD2 .Screen/addr DEO2
#22 =Screen.color #22 .Screen/color DEO
#0020 =Screen.x #0020 .Screen/x DEO2
,position_icn =Screen.addr ;position_icn .Screen/addr DEO2
#23 =Screen.color #23 .Screen/color DEO
( Frame ) ( Frame )
#0030 =Screen.x #0030 .Screen/x DEO2
~timer.frame .timer/frame PEK
DUP #04 SFT GET-CHAR #20 SUB #00 SWP #0008 MUL2 ,font ADD2 =Screen.addr DUP #04 SFT GET-CHAR #20 SUB #00 SWP #0008 MUL2 ;font ADD2 .Screen/addr DEO2
#22 =Screen.color #22 .Screen/color DEO
#0038 =Screen.x #0038 .Screen/x DEO2
#0f AND GET-CHAR #20 SUB #00 SWP #0008 MUL2 ,font ADD2 =Screen.addr #0f AND GET-CHAR #20 SUB #00 SWP #0008 MUL2 ;font ADD2 .Screen/addr DEO2
#22 =Screen.color #22 .Screen/color DEO
#0040 =Screen.x #0040 .Screen/x DEO2
,beat_icn =Screen.addr ;beat_icn .Screen/addr DEO2
#21 ~timer.frame #08 MOD #00 EQU #02 MUL ADD =Screen.color #21 .timer/frame PEK #08 MOD #00 EQU #02 MUL ADD .Screen/color DEO
( Speed ) ( Speed )
#0050 =Screen.x #0050 .Screen/x DEO2
~timer.speed .timer/speed PEK
DUP #04 SFT GET-CHAR #20 SUB #00 SWP #0008 MUL2 ,font ADD2 =Screen.addr DUP #04 SFT GET-CHAR #20 SUB #00 SWP #0008 MUL2 ;font ADD2 .Screen/addr DEO2
#22 =Screen.color #22 .Screen/color DEO
#0058 =Screen.x #0058 .Screen/x DEO2
#0f AND GET-CHAR #20 SUB #00 SWP #0008 MUL2 ,font ADD2 =Screen.addr #0f AND GET-CHAR #20 SUB #00 SWP #0008 MUL2 ;font ADD2 .Screen/addr DEO2
#22 =Screen.color #22 .Screen/color DEO
( TODO: Signal VU ) ( TODO: Signal VU )
( File ) ( File )
~Screen.width #0028 SUB2 =Screen.x .Screen/width DEI2 #0028 SUB2 .Screen/x DEO2
~Screen.x 8+ =Screen.x ,eye_icns =Screen.addr #21 =Screen.color .Screen/x DEI2 8+ .Screen/x DEO2 ;eye_icns .Screen/addr DEO2 #21 .Screen/color DEO
~Screen.x 8+ =Screen.x ,filestate_icn =Screen.addr #21 =Screen.color .Screen/x DEI2 8+ .Screen/x DEO2 ;filestate_icn .Screen/addr DEO2 #21 .Screen/color DEO
~Screen.x 8+ =Screen.x ,load_icn =Screen.addr #21 =Screen.color .Screen/x DEI2 8+ .Screen/x DEO2 ;load_icn .Screen/addr DEO2 #21 .Screen/color DEO
~Screen.x 8+ =Screen.x ,save_icn =Screen.addr #21 =Screen.color .Screen/x DEI2 8+ .Screen/x DEO2 ;save_icn .Screen/addr DEO2 #21 .Screen/color DEO
RTN RTN
@redraw ( -- ) @redraw ( -- )
#00 ~grid.height #00 .grid/height PEK
$ver &ver
( pos-y ) OVR #00 SWP #0008 MUL2 =Screen.y ( pos-y ) OVR #00 SWP #0008 MUL2 .Screen/y DEO2
#00 ~grid.width #00 .grid/width PEK
$hor &hor
( pos-x ) OVR #00 SWP #0008 MUL2 =Screen.x ( pos-x ) OVR #00 SWP #0008 MUL2 .Screen/x DEO2
( get x,y ) SWP2 OVR STH SWP2 OVR STHr ( get x,y ) SWP2 OVR STH SWP2 OVR STHr
( sprite ) DUP2 ,get-cell-sprite JSR2 =Screen.addr ( sprite ) DUP2 ;get-cell-sprite JSR2 .Screen/addr DEO2
( draw ) ,is-selected JSR2 #0d MUL #21 ADD =Screen.color ( draw ) ;is-selected JSR2 #0d MUL #21 ADD .Screen/color DEO
( incr ) SWP ++ SWP ( incr ) SWP ++ SWP
DUP2 LTH ^$hor JNZ DUP2 LTH ,&hor JNZ
POP2 POP2
( incr ) SWP ++ SWP ( incr ) SWP ++ SWP
DUP2 LTH ^$ver JNZ DUP2 LTH ,&ver JNZ
POP2 POP2
,draw-interface JSR2 ;draw-interface JSR2
RTN RTN
@ -565,18 +565,18 @@ RTN
@values [ @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 00 01 02 03 04 05 06 07
08 09 00 00 00 00 00 00 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 11 12 13 14 15 16 17 18
19 1a 1b 1c 1d 1e 1f 20 19 1a 1b 1c 1d 1e 1f 20
21 22 23 00 00 00 00 00 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 11 12 13 14 15 16 17 18
19 1a 1b 1c 1d 1e 1f 20 19 1a 1b 1c 1d 1e 1f 20
21 22 23 00 00 00 00 00 21 22 23 00 00 00 00 00
@ -608,7 +608,7 @@ RTN
[ 0000 0082 4438 0000 ] ( closed ) [ 0000 0082 4438 0000 ] ( closed )
@font ( specter8-frag font ) @font ( specter8-frag font )
[ [
0000 0000 0000 0000 0008 0808 0800 0800 0000 0000 0000 0000 0008 0808 0800 0800
0014 1400 0000 0000 0024 7e24 247e 2400 0014 1400 0000 0000 0024 7e24 247e 2400