uxn/projects/examples/devices/controller.keys.tal

148 lines
3.4 KiB
Tal
Raw Normal View History

2021-04-21 12:09:18 -04:00
( dev/controller/keys )
2021-02-26 22:46:56 -05:00
%+ { ADD } %- { SUB } %* { MUL } %/ { DIV }
%< { LTH } %> { GTH } %= { EQU } %! { NEQ }
%++ { ADD2 } %-- { SUB2 } %** { MUL2 } %// { DIV2 }
%<< { LTH2 } %>> { GTH2 } %== { EQU2 } %!! { NEQ2 }
2021-04-05 16:00:55 -04:00
%RTN { JMP2r }
%TOS { #00 SWP }
2021-07-01 20:33:55 -04:00
%DEBUG { ;print-hex JSR2 #0a .Console/write DEO }
%DEBUG2 { SWP ;print-hex JSR2 ;print-hex JSR2 #0a .Console/write DEO }
2021-04-21 12:09:18 -04:00
( devices )
2021-02-26 22:46:56 -05:00
2021-04-21 12:09:18 -04:00
|00 @System [ &vector $2 &pad $6 &r $2 &g $2 &b $2 ]
2021-07-01 20:33:55 -04:00
|10 @Console [ &vector $2 &read $1 &pad $5 &write $1 ]
2021-04-21 12:09:18 -04:00
|20 @Screen [ &vector $2 &width $2 &height $2 &pad $2 &x $2 &y $2 &addr $2 &color $1 ]
2021-04-26 13:52:46 -04:00
|80 @Controller [ &vector $2 &button $1 &key $1 ]
2021-07-01 20:33:55 -04:00
|a0 @File [ &vector $2 &success $2 &offset $2 &pad $2 &name $2 &length $2 &load $2 &save $2 ]
2021-03-28 14:20:36 -04:00
( variables )
|0000
@position
&x $2
&y $2
2021-04-21 12:48:04 -04:00
( init )
2021-04-05 16:00:55 -04:00
2021-04-21 12:48:04 -04:00
|0100 ( -> )
2021-04-21 12:09:18 -04:00
( theme )
#0f73 .System/r DEO2
#0fe3 .System/g DEO2
#0fc3 .System/b DEO2
2021-04-29 00:00:39 -04:00
2021-04-22 22:57:47 -04:00
( vectors )
;on-button .Controller/vector DEO2
2021-07-01 20:33:55 -04:00
( load font )
#1000 .File/length DEO2
;fontpath .File/name DEO2
;font-data .File/load DEO2
2021-04-21 12:09:18 -04:00
;draw-cursor JSR2
2021-03-28 14:20:36 -04:00
BRK
2021-03-01 20:05:04 -05:00
2021-04-21 12:48:04 -04:00
@on-button ( -> )
( skip ) .Controller/key DEI #01 JCN [ BRK ]
2021-04-29 00:00:39 -04: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 14:12:07 -04:00
.Controller/key DEI #0d NEQ ,&no-return JCN
( draw ) #20 .Screen/color DEO
( reset ) #0000 .position/x STZ2
2021-07-01 20:33:55 -04:00
( incr ) .position/y LDZ2 #0010 ++ .position/y STZ2
2021-04-21 12:09:18 -04:00
;draw-cursor JSR2
2021-04-10 22:39:32 -04:00
BRK
2021-04-21 12:09:18 -04:00
&no-return
2021-04-29 00:00:39 -04:00
2021-07-01 20:33:55 -04: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-10 22:39:32 -04:00
2021-04-05 16:00:55 -04:00
BRK
2021-03-01 23:57:08 -05:00
@mod-color ( mod -- color )
( ctrl ) DUP #01 = #01 * STH
( alt ) DUP #02 = #03 * STH
2021-07-01 20:33:55 -04:00
( shift ) #04 = #05 * STH2r + +
#21 +
RTN
2021-04-21 12:48:04 -04:00
@draw-cursor ( -- )
2021-04-05 16:00:55 -04:00
.position/x LDZ2 .Screen/x DEO2
.position/y LDZ2 .Screen/y DEO2
;cursor .Screen/addr DEO2
#22 .Screen/color DEO
2021-03-26 14:19:19 -04:00
2021-07-01 20:33:55 -04:00
.position/y LDZ2 #0008 ++ .Screen/y DEO2
#22 .Screen/color DEO
2021-04-05 16:00:55 -04:00
RTN
2021-03-01 23:57:08 -05: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-01 20:33:55 -04: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 13:20:24 -04: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-01 20:33:55 -04:00
007e 4078 4040 7e00 007e 4078 4040 4000
@fontpath "projects/fonts/437dos8x16.bit
@font-data