commit 04582724d5d17ab823609aab40c461b2ea01f1ce
parent 38aa48b8bc4739cd900f4f63505191997bdb3ecd
Author: neauoire <aliceffekt@gmail.com>
Date: Fri, 25 Jun 2021 08:36:33 -0700
Improved the keys example top reflect mods
Diffstat:
1 file changed, 75 insertions(+), 11 deletions(-)
diff --git a/projects/examples/devices/controller.keys.tal b/projects/examples/devices/controller.keys.tal
@@ -1,15 +1,31 @@
( dev/controller/keys )
+%+ { ADD } %- { SUB } %* { MUL } %/ { DIV }
+%< { LTH } %> { GTH } %= { EQU } %! { NEQ }
+%++ { ADD2 } %-- { SUB2 } %** { MUL2 } %// { DIV2 }
+%<< { LTH2 } %>> { GTH2 } %== { EQU2 } %!! { NEQ2 }
+
%RTN { JMP2r }
-%8+ { #0008 ADD2 }
-%8* { #30 SFT2 }
+%TOS { #00 SWP }
+
+%DEBUG { .Console/byte DEO #0a .Console/char DEO }
+%DEBUG2 { .Console/short DEO2 #0a .Console/char DEO }
( 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 ]
|80 @Controller [ &vector $2 &button $1 &key $1 ]
+( variables )
+
+|0000
+
+@position
+ &x $2
+ &y $2
+
( init )
|0100 ( -> )
@@ -26,33 +42,70 @@
BRK
@on-button ( -> )
-
+
( skip ) .Controller/key DEI #01 JCN [ BRK ]
+ ( 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 )
.Controller/key DEI #0d NEQ ,&no-return JCN
( draw ) #20 .Screen/color DEO
- ( reset ) #0000 .Screen/x DEO2
- ( incr ) .Screen/y DEI2 8+ .Screen/y DEO2
+ ( reset ) #0000 .position/x STZ2
+ ( incr ) .position/y LDZ2 #0008 ++ .position/y STZ2
;draw-cursor JSR2
BRK
&no-return
- ;font #00 .Controller/key DEI 8* ADD2 .Screen/addr DEO2
- ( draw ) #21 .Screen/color DEO
- ( incr ) .Screen/x DEI2 8+ .Screen/x DEO2
-
- ;draw-cursor JSR2
+ ;font #00 .Controller/key DEI #0008 ** ++ .Screen/addr DEO2
+ .Controller/button DEI ;mod-color JSR2 .Screen/color DEO
+ ( incr ) .position/x LDZ2 #0008 ++ .position/x STZ2
+ ,draw-cursor JSR
BRK
+@mod-color ( mod -- color )
+
+ ( ctrl ) DUP #01 = #01 * STH
+ ( alt ) DUP #02 = #03 * STH
+ ( shift ) #04 = #0e * STH2r + +
+ #21 +
+
+RTN
+
@draw-cursor ( -- )
+ .position/x LDZ2 .Screen/x DEO2
+ .position/y LDZ2 .Screen/y DEO2
;cursor .Screen/addr DEO2
#22 .Screen/color DEO
RTN
-@cursor [ ffff ffff ffff ffff ]
+@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
+
+@cursor
+ ffff ffff ffff ffff
@font ( spectrum-zx font )
0000 0000 0000 0000 0000 2400 7e3c 0000 0000 2400 3c42 0000 0000 6c7c 7c38 1000
@@ -87,3 +140,13 @@ RTN
0010 103c 1010 0c00 0000 4444 4444 3800 0000 4444 2828 1000 0000 4454 5454 2800
0000 4428 1028 4400 0000 4444 443c 0438 0000 7c08 1020 7c00 000c 0810 1008 0c00
0008 0808 0808 0800 0030 1008 0810 3000 0000 0032 4c00 0000 3c42 99a1 a199 423c
+
+@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
+ 007e 4078 4040 7e00 007e 4078 4040 4000
+\ No newline at end of file