0
0
Fork 0
mirror of https://git.sr.ht/~rabbits/uxn synced 2024-11-30 17:53:01 +00:00
uxn/projects/examples/devices/controller.keys.tal

148 lines
3.4 KiB
Tal
Raw Normal View History

2021-04-21 16:09:18 +00:00
( dev/controller/keys )
2021-02-27 03:46:56 +00:00
%+ { ADD } %- { SUB } %* { MUL } %/ { DIV }
%< { LTH } %> { GTH } %= { EQU } %! { NEQ }
%++ { ADD2 } %-- { SUB2 } %** { MUL2 } %// { DIV2 }
%<< { LTH2 } %>> { GTH2 } %== { EQU2 } %!! { NEQ2 }
2021-04-05 20:00:55 +00:00
%RTN { JMP2r }
%TOS { #00 SWP }
2021-07-02 00:33:55 +00:00
%DEBUG { ;print-hex JSR2 #0a .Console/write DEO }
%DEBUG2 { SWP ;print-hex JSR2 ;print-hex JSR2 #0a .Console/write DEO }
2021-04-21 16:09:18 +00:00
( devices )
2021-02-27 03:46:56 +00:00
2021-04-21 16:09:18 +00:00
|00 @System [ &vector $2 &pad $6 &r $2 &g $2 &b $2 ]
2021-07-02 00:33:55 +00:00
|10 @Console [ &vector $2 &read $1 &pad $5 &write $1 ]
2021-04-21 16:09:18 +00:00
|20 @Screen [ &vector $2 &width $2 &height $2 &pad $2 &x $2 &y $2 &addr $2 &color $1 ]
2021-04-26 17:52:46 +00:00
|80 @Controller [ &vector $2 &button $1 &key $1 ]
2021-07-02 00:33:55 +00:00
|a0 @File [ &vector $2 &success $2 &offset $2 &pad $2 &name $2 &length $2 &load $2 &save $2 ]
2021-03-28 18:20:36 +00:00
( variables )
|0000
@position
&x $2
&y $2
2021-04-21 16:48:04 +00:00
( init )
2021-04-05 20:00:55 +00:00
2021-04-21 16:48:04 +00:00
|0100 ( -> )
2021-04-21 16:09:18 +00:00
( theme )
#0f73 .System/r DEO2
#0fe3 .System/g DEO2
#0fc3 .System/b DEO2
2021-04-29 04:00:39 +00:00
2021-04-23 02:57:47 +00:00
( vectors )
;on-button .Controller/vector DEO2
2021-07-02 00:33:55 +00:00
( load font )
#1000 .File/length DEO2
;fontpath .File/name DEO2
;font-data .File/load DEO2
2021-04-21 16:09:18 +00:00
;draw-cursor JSR2
2021-03-28 18:20:36 +00:00
BRK
2021-03-02 01:05:04 +00:00
2021-04-21 16:48:04 +00:00
@on-button ( -> )
( skip ) .Controller/key DEI #01 JCN [ BRK ]
2021-04-29 04:00:39 +00:00
( print button-key code )
#0000 .Screen/x DEO2
.Screen/height DEI2 #0008 -- .Screen/y DEO2
.Controller/button DEI2 #21 ;draw-short JSR2
.position/x LDZ2 .Screen/x DEO2
.position/y LDZ2 .Screen/y DEO2
( linebreak )
2021-05-11 18:12:07 +00:00
.Controller/key DEI #0d NEQ ,&no-return JCN
( draw ) #20 .Screen/color DEO
( reset ) #0000 .position/x STZ2
2021-07-02 00:33:55 +00:00
( incr ) .position/y LDZ2 #0010 ++ .position/y STZ2
2021-04-21 16:09:18 +00:00
;draw-cursor JSR2
2021-04-11 02:39:32 +00:00
BRK
2021-04-21 16:09:18 +00:00
&no-return
2021-04-29 04:00:39 +00:00
2021-07-02 00:33:55 +00:00
.Controller/key DEI TOS #0020 ** DEBUG2
;font-data .Controller/key DEI TOS #0010 ** ++ .Screen/addr DEO2
.Controller/button DEI ;mod-color JSR2 .Screen/color DEO
.Screen/y DEI2 #0008 ++ .Screen/y DEO2
.Screen/addr DEI2 #0008 ++ .Screen/addr DEO2
.Controller/button DEI ;mod-color JSR2 .Screen/color DEO
( incr ) .position/x LDZ2 #0008 ++ .position/x STZ2
,draw-cursor JSR
2021-04-11 02:39:32 +00:00
2021-04-05 20:00:55 +00:00
BRK
2021-03-02 04:57:08 +00:00
@mod-color ( mod -- color )
( ctrl ) DUP #01 = #01 * STH
( alt ) DUP #02 = #03 * STH
2021-07-02 00:33:55 +00:00
( shift ) #04 = #05 * STH2r + +
#21 +
RTN
2021-04-21 16:48:04 +00:00
@draw-cursor ( -- )
2021-04-05 20:00:55 +00:00
.position/x LDZ2 .Screen/x DEO2
.position/y LDZ2 .Screen/y DEO2
;cursor .Screen/addr DEO2
#22 .Screen/color DEO
2021-03-26 18:19:19 +00:00
2021-07-02 00:33:55 +00:00
.position/y LDZ2 #0008 ++ .Screen/y DEO2
#22 .Screen/color DEO
2021-04-05 20:00:55 +00:00
RTN
2021-03-02 04:57:08 +00:00
@draw-short ( short* color -- )
STH SWP
DUP #04 SFT TOS #0008 ** ;font-hex ++ .Screen/addr DEO2
( draw ) STHkr .Screen/color DEO
#0f AND TOS #0008 ** ;font-hex ++ .Screen/addr DEO2
.Screen/x DEI2 #0008 ++ .Screen/x DEO2
( draw ) STHkr .Screen/color DEO
DUP #04 SFT TOS #0008 ** ;font-hex ++ .Screen/addr DEO2
.Screen/x DEI2 #0008 ++ .Screen/x DEO2
( draw ) STHkr .Screen/color DEO
#0f AND TOS #0008 ** ;font-hex ++ .Screen/addr DEO2
.Screen/x DEI2 #0008 ++ .Screen/x DEO2
( draw ) STHr .Screen/color DEO
RTN
2021-07-02 00:33:55 +00:00
@print-hex ( value -- )
STHk #04 SFT ,&parse JSR .Console/write DEO
STHr #0f AND ,&parse JSR .Console/write DEO
RTN
&parse ( value -- char )
DUP #09 GTH ,&above JCN #30 ADD RTN &above #09 SUB #60 ADD RTN
RTN
@cursor
ffff ffff ffff ffff
2021-03-28 17:20:24 +00:00
@font-hex
003c 464a 5262 3c00 0018 0808 0808 1c00
003c 4202 3c40 7e00 003c 421c 0242 3c00
000c 1424 447e 0400 007e 407c 0242 3c00
003c 407c 4242 3c00 007e 0204 0810 1000
003c 423c 4242 3c00 003c 4242 3e02 3c00
003c 4242 7e42 4200 007c 427c 4242 7c00
003c 4240 4042 3c00 007c 4242 4242 7c00
2021-07-02 00:33:55 +00:00
007e 4078 4040 7e00 007e 4078 4040 4000
@fontpath "projects/fonts/437dos8x16.bit
@font-data