2024-02-10 15:16:58 -05:00
|
|
|
( uxnemu shaviankb.rom | listener )
|
|
|
|
|
|
|
|
|00 @System &vector $2 &expansion $2 &wst $1 &rst $1 &metadata $2 &r $2 &g $2 &b $2 &debug $1 &state $1
|
|
|
|
|10 @Console &vector $2 &read $1 &pad $4 &type $1 &write $1 &error $1
|
|
|
|
|20 @Screen &vector $2 &width $2 &height $2 &auto $1 &pad $1 &x $2 &y $2 &addr $2 &pixel $1 &sprite $1
|
2024-02-11 14:36:26 -05:00
|
|
|
|80 @Controller &vector $2 &button $1 &key $1
|
2024-02-10 23:00:10 -05:00
|
|
|
|90 @Mouse &vector $2 &x $2 &y $2 &state $1 &chord $1 &pad $4 &scrolly &scrolly-hb $1 &scrolly-lb $1
|
2024-02-10 15:16:58 -05:00
|
|
|
|
2024-02-10 23:56:26 -05:00
|
|
|
|0000
|
|
|
|
|
2024-02-11 13:40:48 -05:00
|
|
|
@hover $2
|
|
|
|
@lock $1
|
2024-02-11 13:53:15 -05:00
|
|
|
@layer $1
|
2024-02-10 23:56:26 -05:00
|
|
|
|
2024-02-10 15:16:58 -05:00
|
|
|
|0100
|
|
|
|
|
|
|
|
@on-reset ( -> )
|
2024-02-11 13:13:46 -05:00
|
|
|
#d306 .System/r DEO2
|
|
|
|
#d90c .System/g DEO2
|
|
|
|
#d608 .System/b DEO2
|
2024-02-10 23:37:27 -05:00
|
|
|
#0130 .Screen/width DEO2
|
|
|
|
#00d0 .Screen/height DEO2
|
2024-02-10 23:00:10 -05:00
|
|
|
;on-mouse .Mouse/vector DEO2
|
2024-02-11 14:36:26 -05:00
|
|
|
;on-control .Controller/vector DEO2
|
2024-02-10 15:16:58 -05:00
|
|
|
<draw-keyboard>
|
2024-02-10 15:57:38 -05:00
|
|
|
( #010e DEO ) BRK
|
|
|
|
|
2024-02-10 23:00:10 -05:00
|
|
|
@on-mouse ( -> )
|
|
|
|
[ LIT2 00 -Mouse/state ] DEI NEQ #42 ADD ;pointer-icn <update-pointer>
|
2024-02-11 12:32:57 -05:00
|
|
|
( | within )
|
|
|
|
.Mouse/x DEI2 #0008 SUB2 #0120 LTH2 ?{ BRK }
|
|
|
|
.Mouse/y DEI2 #0008 SUB2 #00c0 LTH2 ?{ BRK }
|
2024-02-11 13:08:34 -05:00
|
|
|
[ LIT2 &last 00 -Mouse/state ] DEI #00 NEQ DUP ,&last STR
|
|
|
|
DUP2 #0100 EQU2 ?on-mouse-release
|
|
|
|
NIP ?on-mouse-down
|
2024-02-10 23:56:26 -05:00
|
|
|
( | hover )
|
|
|
|
get-mouse-key <set-hover>
|
|
|
|
BRK
|
|
|
|
|
2024-02-11 13:08:34 -05:00
|
|
|
@on-mouse-release ( states* -> )
|
|
|
|
.hover LDZ2 ;btn-hover-chr <draw-key-id>
|
|
|
|
[ LIT2 00 -lock ] STZ
|
|
|
|
POP2 BRK
|
|
|
|
|
2024-02-10 23:56:26 -05:00
|
|
|
@on-mouse-down ( -> )
|
2024-02-11 13:08:34 -05:00
|
|
|
.lock LDZ ?{
|
|
|
|
get-mouse-key <set-press>
|
|
|
|
[ LIT2 01 -lock ] STZ }
|
2024-02-10 23:00:10 -05:00
|
|
|
BRK
|
|
|
|
|
2024-02-11 14:36:26 -05:00
|
|
|
@on-control ( -> )
|
2024-02-11 15:04:45 -05:00
|
|
|
( | release )
|
|
|
|
.Controller/button DEI2 ORA ?{
|
2024-02-11 15:19:45 -05:00
|
|
|
#00 <set-layer>
|
2024-02-11 15:04:45 -05:00
|
|
|
[ LIT2 00 -lock ] STZ
|
|
|
|
BRK }
|
|
|
|
( | toggle layer )
|
2024-02-11 15:40:35 -05:00
|
|
|
.Controller/button DEI
|
|
|
|
( | buttons )
|
|
|
|
DUP [ LIT 40 ] NEQ ?{ #0018 <set-press> }
|
|
|
|
DUP [ LIT 80 ] NEQ ?{ #0019 <set-press> }
|
|
|
|
DUP [ LIT 04 ] NEQ ?{ #01 <set-layer> }
|
|
|
|
POP
|
|
|
|
( | key )
|
|
|
|
.Controller/key DEI tolowercase
|
2024-02-11 14:59:12 -05:00
|
|
|
( | top row )
|
|
|
|
DUP [ LIT "q ] NEQ ?{ #0000 <set-press> }
|
|
|
|
DUP [ LIT "w ] NEQ ?{ #0001 <set-press> }
|
|
|
|
DUP [ LIT "e ] NEQ ?{ #0002 <set-press> }
|
|
|
|
DUP [ LIT "r ] NEQ ?{ #0003 <set-press> }
|
|
|
|
DUP [ LIT "t ] NEQ ?{ #0004 <set-press> }
|
|
|
|
DUP [ LIT "y ] NEQ ?{ #0005 <set-press> }
|
|
|
|
DUP [ LIT "u ] NEQ ?{ #0006 <set-press> }
|
|
|
|
DUP [ LIT "i ] NEQ ?{ #0007 <set-press> }
|
|
|
|
DUP [ LIT "o ] NEQ ?{ #0008 <set-press> }
|
|
|
|
( | middle row )
|
|
|
|
DUP [ LIT "a ] NEQ ?{ #0009 <set-press> }
|
|
|
|
DUP [ LIT "s ] NEQ ?{ #000a <set-press> }
|
|
|
|
DUP [ LIT "d ] NEQ ?{ #000b <set-press> }
|
|
|
|
DUP [ LIT "f ] NEQ ?{ #000c <set-press> }
|
|
|
|
DUP [ LIT "g ] NEQ ?{ #000d <set-press> }
|
|
|
|
DUP [ LIT "h ] NEQ ?{ #000e <set-press> }
|
|
|
|
DUP [ LIT "j ] NEQ ?{ #000f <set-press> }
|
|
|
|
DUP [ LIT "k ] NEQ ?{ #0010 <set-press> }
|
|
|
|
DUP [ LIT "l ] NEQ ?{ #0011 <set-press> }
|
|
|
|
( | bottom row )
|
|
|
|
DUP [ LIT "z ] NEQ ?{ #0012 <set-press> }
|
|
|
|
DUP [ LIT "x ] NEQ ?{ #0013 <set-press> }
|
|
|
|
DUP [ LIT "c ] NEQ ?{ #0014 <set-press> }
|
|
|
|
DUP [ LIT "v ] NEQ ?{ #0015 <set-press> }
|
|
|
|
DUP [ LIT "b ] NEQ ?{ #0016 <set-press> }
|
|
|
|
DUP [ LIT "n ] NEQ ?{ #0017 <set-press> }
|
2024-02-11 15:08:29 -05:00
|
|
|
( | special )
|
|
|
|
DUP [ LIT 08 ] NEQ ?{ #001a <set-press> }
|
|
|
|
DUP [ LIT 0d ] NEQ ?{ #001f <set-press> }
|
|
|
|
DUP [ LIT 20 ] NEQ ?{ #001d <set-press> }
|
|
|
|
DUP [ LIT ", ] NEQ ?{ #001c <set-press> }
|
|
|
|
DUP [ LIT ". ] NEQ ?{ #001e <set-press> }
|
2024-02-11 14:59:12 -05:00
|
|
|
POP BRK
|
2024-02-11 15:10:38 -05:00
|
|
|
|
2024-02-10 23:56:26 -05:00
|
|
|
(
|
|
|
|
@|core )
|
|
|
|
|
|
|
|
@get-mouse-key ( -- id* )
|
|
|
|
( x ) .Mouse/x DEI2 #0008 SUB2 #05 SFT2
|
|
|
|
( y ) .Mouse/y DEI2 #0008 SUB2 #0030 DIV2 #0009 MUL2 ADD2
|
|
|
|
( last2 ) DUP #22 LTH ?{ #0004 SUB2 JMP2r }
|
|
|
|
( space ) DUP #1d SUB #04 GTH ?{ POP2 #001d }
|
|
|
|
JMP2r
|
|
|
|
|
2024-02-11 12:42:18 -05:00
|
|
|
@<set-press> ( id* -- )
|
2024-02-11 13:53:15 -05:00
|
|
|
DUP #1b NEQ ?{ POP2 !<toggle-layer> }
|
2024-02-11 12:42:18 -05:00
|
|
|
.hover LDZ2 ;btn-chr <draw-key-id>
|
2024-02-11 13:40:48 -05:00
|
|
|
DUP2 ;btn-press-chr <draw-key-id>
|
2024-02-11 15:04:45 -05:00
|
|
|
DUP2 .hover STZ2
|
2024-02-11 13:40:48 -05:00
|
|
|
( | event )
|
2024-02-11 14:21:55 -05:00
|
|
|
( key ) #0006 MUL2 ;layout ADD2
|
|
|
|
( layer ) get-layer #10 SFT2 ADD2 LDA2
|
2024-02-11 13:40:48 -05:00
|
|
|
( length ) #0010 ADD2 LDA2k SWP2 INC2 INC2
|
|
|
|
&l ( -- )
|
2024-02-11 14:21:55 -05:00
|
|
|
LDAk #18 DEO
|
2024-02-11 13:40:48 -05:00
|
|
|
INC2 GTH2k ?&l
|
|
|
|
POP2 POP2 JMP2r
|
2024-02-11 12:42:18 -05:00
|
|
|
|
2024-02-11 14:21:55 -05:00
|
|
|
@get-layer ( -- layer* )
|
|
|
|
.Mouse/state DEI
|
|
|
|
( ) DUP #02 AND ?&top
|
|
|
|
( ) #04 AND ?&bottom
|
2024-02-11 14:36:26 -05:00
|
|
|
.layer LDZ
|
2024-02-11 16:43:03 -05:00
|
|
|
( ) DUP #01 EQU ?&top
|
2024-02-11 14:36:26 -05:00
|
|
|
( ) #02 EQU ?&bottom
|
2024-02-11 16:43:03 -05:00
|
|
|
#0001 JMP2r
|
|
|
|
&top POP #0000 JMP2r
|
2024-02-11 14:21:55 -05:00
|
|
|
&bottom #0002 JMP2r
|
|
|
|
|
2024-02-11 13:53:15 -05:00
|
|
|
@<toggle-layer> ( -- )
|
2024-02-11 15:19:45 -05:00
|
|
|
.layer LDZ INC #03 DIVk MUL SUB
|
|
|
|
( >> )
|
|
|
|
|
|
|
|
@<set-layer> ( layer -- )
|
|
|
|
.layer STZ
|
2024-02-11 13:53:15 -05:00
|
|
|
!<draw-keyboard>
|
|
|
|
|
2024-02-11 12:15:18 -05:00
|
|
|
@<set-hover> ( id* -- )
|
2024-02-11 12:28:18 -05:00
|
|
|
DUP2 .hover LDZ2 EQU2 ?{
|
2024-02-11 12:42:18 -05:00
|
|
|
.hover LDZ2 ;btn-chr <draw-key-id>
|
2024-02-11 12:28:18 -05:00
|
|
|
DUP2 ;btn-hover-chr <draw-key-id>
|
|
|
|
.hover STZ2
|
2024-02-11 12:42:18 -05:00
|
|
|
JMP2r }
|
2024-02-11 12:15:18 -05:00
|
|
|
POP2 JMP2r
|
|
|
|
|
2024-02-10 22:09:42 -05:00
|
|
|
@<set-position> ( id* -- )
|
2024-02-10 23:37:27 -05:00
|
|
|
DUP2 #0009 DIV2 #0030 MUL2 #0008 ADD2 .Screen/y DEO2
|
2024-02-10 22:09:42 -05:00
|
|
|
DUP #1e NEQ ?{ POP2 #0007 }
|
|
|
|
DUP #1f NEQ ?{ POP2 #0008 }
|
2024-02-11 14:40:12 -05:00
|
|
|
#0009 DIV2k MUL2 SUB2 #50 SFT2 #0008 ADD2 .Screen/x DEO2
|
2024-02-10 15:57:38 -05:00
|
|
|
JMP2r
|
2024-02-10 15:16:58 -05:00
|
|
|
|
2024-02-11 12:15:18 -05:00
|
|
|
(
|
|
|
|
@|drawing )
|
|
|
|
|
2024-02-10 15:16:58 -05:00
|
|
|
@<draw-keyboard> ( -- )
|
2024-02-10 22:09:42 -05:00
|
|
|
#0020 #0000
|
|
|
|
&l ( -- )
|
2024-02-11 12:28:18 -05:00
|
|
|
DUP2 ;btn-chr <draw-key-id>
|
2024-02-11 00:10:26 -05:00
|
|
|
INC2 GTH2k ?&l
|
2024-02-10 23:56:26 -05:00
|
|
|
POP2 POP2 JMP2r
|
|
|
|
|
2024-02-11 12:28:18 -05:00
|
|
|
@<draw-key-id> ( id* frame* -- )
|
|
|
|
OVR2 <set-position>
|
|
|
|
OVR2 #001d EQU2 ?<draw-key-space>
|
|
|
|
STH2
|
2024-02-10 23:56:26 -05:00
|
|
|
#0006 MUL2 ;layout ADD2
|
2024-02-10 23:37:27 -05:00
|
|
|
( ) STH2k #0004 ADD2 LDA2
|
|
|
|
( ) STH2kr #0002 ADD2 LDA2
|
2024-02-11 12:28:18 -05:00
|
|
|
( ) STH2r LDA2 STH2r <draw-key>
|
2024-02-10 23:56:26 -05:00
|
|
|
JMP2r
|
2024-02-10 15:57:38 -05:00
|
|
|
|
2024-02-11 13:08:34 -05:00
|
|
|
@<draw-glyph> ( addr* color -- )
|
|
|
|
STH
|
2024-02-10 22:09:42 -05:00
|
|
|
.Screen/addr DEO2
|
2024-02-10 15:57:38 -05:00
|
|
|
[ LIT2 15 -Screen/auto ] DEO
|
2024-02-11 13:08:34 -05:00
|
|
|
STHr .Screen/sprite DEO
|
2024-02-10 15:57:38 -05:00
|
|
|
JMP2r
|
|
|
|
|
2024-02-11 12:15:18 -05:00
|
|
|
@<draw-key> ( a* b* c* frame* -- )
|
2024-02-11 12:32:57 -05:00
|
|
|
DUP2 ;btn-hover-chr EQU2 STH
|
2024-02-11 13:08:34 -05:00
|
|
|
DUP2 ;btn-press-chr EQU2 #10 SFT STH
|
2024-02-10 15:16:58 -05:00
|
|
|
<draw-button>
|
2024-02-11 00:10:26 -05:00
|
|
|
.Screen/x DEI2k #0002 SUB2 ROT DEO2
|
2024-02-11 13:08:34 -05:00
|
|
|
.Screen/y DEI2k #0024 STHr SUB STHr SUB SUB2 ROT DEO2
|
2024-02-10 15:57:38 -05:00
|
|
|
( | a )
|
2024-02-11 14:36:26 -05:00
|
|
|
#0a00 [ LIT2 01 -layer ] LDZ EQU [ JMP SWP POP ] <draw-glyph>
|
2024-02-10 22:09:42 -05:00
|
|
|
.Screen/x DEI2k #0002 SUB2 ROT DEO2
|
|
|
|
.Screen/y DEI2k #000c ADD2 ROT DEO2
|
2024-02-10 15:57:38 -05:00
|
|
|
( | b )
|
2024-02-11 14:36:26 -05:00
|
|
|
#0a00 [ LIT2 00 -layer ] LDZ EQU [ JMP SWP POP ] <draw-glyph>
|
2024-02-10 22:09:42 -05:00
|
|
|
.Screen/x DEI2k #0002 SUB2 ROT DEO2
|
|
|
|
.Screen/y DEI2k #000c ADD2 ROT DEO2
|
2024-02-10 15:57:38 -05:00
|
|
|
( | c )
|
2024-02-11 13:53:15 -05:00
|
|
|
#0a05 [ LIT2 02 -layer ] LDZ EQU [ JMP SWP POP ] <draw-glyph>
|
2024-02-10 22:09:42 -05:00
|
|
|
.Screen/x DEI2k #0006 ADD2 ROT DEO2
|
|
|
|
.Screen/y DEI2k #001c SUB2 ROT DEO2
|
2024-02-10 15:16:58 -05:00
|
|
|
JMP2r
|
|
|
|
|
2024-02-11 12:28:18 -05:00
|
|
|
@<draw-key-space> ( id* frame* -- )
|
2024-02-11 12:42:18 -05:00
|
|
|
DUP2 ;btn-press-chr NEQ2 #10 SFT INC ,&color STR
|
2024-02-11 12:28:18 -05:00
|
|
|
STH2
|
|
|
|
POP2 .Screen/x DEI2 .Screen/y DEI2 #1204 STH2r <draw-frame>
|
2024-02-11 12:11:38 -05:00
|
|
|
;fill-icn .Screen/addr DEO2
|
|
|
|
[ LIT2 31 -Screen/auto ] DEO
|
2024-02-11 12:42:18 -05:00
|
|
|
[ LIT2 &color 03 ee ] !<draw-times>
|
2024-02-10 23:37:27 -05:00
|
|
|
|
2024-02-11 12:15:18 -05:00
|
|
|
@<draw-button> ( frame* -- )
|
2024-02-11 12:42:18 -05:00
|
|
|
DUP2 ;btn-press-chr NEQ2 #10 SFT INC ,&color STR
|
2024-02-11 12:15:18 -05:00
|
|
|
STH2
|
|
|
|
.Screen/x DEI2 .Screen/y DEI2 #0204 STH2r <draw-frame>
|
2024-02-11 00:10:26 -05:00
|
|
|
;fill-icn .Screen/addr DEO2
|
|
|
|
[ LIT2 12 -Screen/auto ] DEO
|
2024-02-11 12:42:18 -05:00
|
|
|
[ LIT2 &color 03 -Screen/sprite ] DEOk DEOk DEOk DEO
|
2024-02-10 15:16:58 -05:00
|
|
|
JMP2r
|
|
|
|
|
2024-02-11 12:28:18 -05:00
|
|
|
@<draw-frame> ( x* y* w h sprite* -- )
|
|
|
|
.Screen/addr DEO2
|
|
|
|
,&h STR
|
|
|
|
,&w STR
|
|
|
|
DUP2 .Screen/y DEO2
|
|
|
|
,&y STR2
|
|
|
|
DUP2 .Screen/x DEO2
|
|
|
|
,&x STR2
|
2024-02-11 14:40:12 -05:00
|
|
|
[ LIT2 01 -Screen/auto ] DEO
|
|
|
|
[ LIT2 81 -Screen/sprite ] DEO
|
|
|
|
<draw-frame>/next
|
|
|
|
[ LIT &w $1 ] <draw-frame>/repeat
|
|
|
|
[ LIT2 02 -Screen/auto ] DEO
|
|
|
|
<draw-frame>/next
|
|
|
|
[ LIT2 81 -Screen/sprite ] DEO
|
|
|
|
<draw-frame>/next
|
|
|
|
[ LIT &h $1 ] <draw-frame>/repeat
|
2024-02-11 12:28:18 -05:00
|
|
|
( left ) [ LIT2 &y $2 ] #0008 ADD2 .Screen/y DEO2
|
|
|
|
[ LIT2 &x $2 ] .Screen/x DEO2
|
2024-02-11 14:40:12 -05:00
|
|
|
<draw-frame>/next
|
|
|
|
,&h LDR <draw-frame>/repeat
|
|
|
|
[ LIT2 01 -Screen/auto ] DEO
|
|
|
|
<draw-frame>/next
|
|
|
|
[ LIT2 81 -Screen/sprite ] DEO
|
|
|
|
<draw-frame>/next
|
|
|
|
,&w LDR <draw-frame>/repeat
|
|
|
|
<draw-frame>/next
|
|
|
|
[ LIT2 81 -Screen/sprite ] DEO
|
|
|
|
,&x LDR2 #0008 ADD2 .Screen/x DEO2
|
2024-02-11 12:28:18 -05:00
|
|
|
,&y LDR2 #0008 ADD2 .Screen/y DEO2
|
|
|
|
JMP2r
|
|
|
|
&next .Screen/addr DEI2k #0010 ADD2 ROT DEO2
|
|
|
|
JMP2r
|
2024-02-11 14:45:51 -05:00
|
|
|
&repeat #8100 ROT SUB
|
|
|
|
( >> )
|
|
|
|
|
|
|
|
@<draw-times> ( color times -- )
|
|
|
|
OVR .Screen/sprite DEO
|
|
|
|
INC DUP ?<draw-times>
|
2024-02-11 12:28:18 -05:00
|
|
|
POP2 JMP2r
|
|
|
|
|
2024-02-10 23:00:10 -05:00
|
|
|
@<update-pointer> ( color addr* -- )
|
|
|
|
[ LIT2 00 -Screen/auto ] DEO
|
|
|
|
;fill-icn .Screen/addr DEO2
|
|
|
|
#40 <draw-pointer>
|
|
|
|
.Mouse/x DEI2 ,<draw-pointer>/x STR2
|
|
|
|
.Mouse/y DEI2 ,<draw-pointer>/y STR2
|
|
|
|
.Screen/addr DEO2
|
|
|
|
|
|
|
|
@<draw-pointer> ( color -- )
|
|
|
|
[ LIT2 &x $2 ] .Screen/x DEO2
|
|
|
|
[ LIT2 &y $2 ] .Screen/y DEO2
|
|
|
|
.Screen/sprite DEO
|
|
|
|
JMP2r
|
|
|
|
|
2024-02-10 15:57:38 -05:00
|
|
|
(
|
|
|
|
@|stdlib )
|
|
|
|
|
2024-02-11 15:40:35 -05:00
|
|
|
@tolowercase ( char -- char )
|
|
|
|
DUP [ LIT "A ] GTH ?{ JMP2r }
|
|
|
|
DUP [ LIT "Z ] LTH ?{ JMP2r }
|
|
|
|
#20 ADD JMP2r
|
2024-02-11 14:59:12 -05:00
|
|
|
|
2024-02-10 15:16:58 -05:00
|
|
|
@<phex> ( short* -- )
|
|
|
|
SWP <phex>/b
|
|
|
|
&b ( -- )
|
|
|
|
DUP #04 SFT <phex>/c
|
|
|
|
&c ( -- )
|
|
|
|
#0f AND DUP #09 GTH #27 MUL ADD [ LIT "0 ] ADD #18 DEO
|
|
|
|
JMP2r
|
2024-02-11 15:40:35 -05:00
|
|
|
|
2024-02-10 16:32:01 -05:00
|
|
|
~assets.tal
|
2024-02-10 15:16:58 -05:00
|
|
|
|