0
0
Fork 0
mirror of https://git.sr.ht/~rabbits/uxn synced 2024-11-27 16:23:02 +00:00

Ported the keys example

This commit is contained in:
neauoire 2021-04-21 09:09:18 -07:00
parent ef94053723
commit 53eacc6039
4 changed files with 42 additions and 35 deletions

View file

@ -32,7 +32,7 @@ else
fi fi
echo "Assembling.." echo "Assembling.."
./bin/assembler projects/examples/dev.file.usm bin/boot.rom ./bin/assembler projects/examples/dev.controller.keys.usm bin/boot.rom
echo "Running.." echo "Running.."
if [ "${2}" = '--cli' ]; if [ "${2}" = '--cli' ];

View file

@ -1,4 +1,4 @@
( Dev/Console ) ( dev/console )
%RTN { JMP2r } %RTN { JMP2r }

View file

@ -1,15 +1,14 @@
( Dev/Controller ) ( dev/controller/buttons )
%++ { #0001 ADD2 } %-- { #0001 SUB2 }
%2/ { #0002 DIV2 }
%=>SC/ADDR { .Screen/addr IOW2 } %=>SC/ADDR { .Screen/addr IOW2 }
%->SC/COLR { .Screen/color IOW } %->SC/COLR { .Screen/color IOW }
%++ { #0001 ADD2 }
%-- { #0001 SUB2 }
%2/ { #0002 DIV2 }
( devices ) ( devices )
|00 @System [ &vector $2 &pad $6 &r $2 &g $2 &b $2 ] |00 @System [ &vector $2 &pad $6 &r $2 &g $2 &b $2 ]
|10 @Console [ &pad $8 &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 ] |20 @Screen [ &vector $2 &width $2 &height $2 &pad $2 &x $2 &y $2 &addr $2 &color $1 ]
|40 @Controller [ &vector $2 &button $1 &key $1 ] |40 @Controller [ &vector $2 &button $1 &key $1 ]
@ -32,6 +31,7 @@
( set origin ) ( set origin )
.Screen/width IOR2 2/ .Screen/x IOW2 .Screen/width IOR2 2/ .Screen/x IOW2
.Screen/height IOR2 2/ .Screen/y IOW2 .Screen/height IOR2 2/ .Screen/y IOW2
;default_icn =>SC/ADDR ;default_icn =>SC/ADDR
#31 ->SC/COLR #31 ->SC/COLR
#2a .slime POK #2a .slime POK

View file

@ -1,56 +1,64 @@
( Dev/Keys ) ( dev/controller/keys )
%RTN { JMP2r } %RTN { JMP2r }
%8+ { #0008 ADD2 } %8+ { #0008 ADD2 }
%8* { #0030 SFT2 } %8* { #0030 SFT2 }
|0100 ;System { vector 2 pad 6 r 2 g 2 b 2 } ( devices )
|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 }
|0140 ;Controller { vector 2 button 1 key 1 }
( program ) |00 @System [ &vector $2 &pad $6 &r $2 &g $2 &b $2 ]
|20 @Screen [ &vector $2 &width $2 &height $2 &pad $2 &x $2 &y $2 &addr $2 &color $1 ]
|40 @Controller [ &vector $2 &button $1 &key $1 ]
|0200 ( variables )
( theme ) #0f73 =System.r #0fe3 =System.g #0fc3 =System.b |0000
( vectors ) ,on-button =Controller.vector
,draw-cursor JSR2 @slime $1
|0100
( theme )
#0f73 .System/r IOW2
#0fe3 .System/g IOW2
#0fc3 .System/b IOW2
( vectors ) ;on-button .Controller/vector IOW2
;draw-cursor JSR2
BRK BRK
@on-button @on-button
~Controller.key #00 NEQ ^$skip JNZ BRK $skip .Controller/key IOR #00 NEQ ,&skip JNZ BRK &skip
~Controller.key #0d NEQ ^$no-return JNZ .Controller/key IOR #0d NEQ ,&no-return JNZ
#20 =Screen.color ( draw ) #20 .Screen/color IOW
#0000 =Screen.x ( reset ) #0000 .Screen/x IOW2
( incr ) ~Screen.y 8+ =Screen.y ( incr ) .Screen/y IOR2 8+ .Screen/y IOW2
,draw-cursor JSR2 ;draw-cursor JSR2
BRK BRK
$no-return &no-return
~Controller.key =Console.char ;font #00 .Controller/key IOR 8* ADD2 .Screen/addr IOW2
( draw ) #21 .Screen/color IOW
( incr ) .Screen/x IOR2 8+ .Screen/x IOW2
,cursor_icn =Screen.addr ;draw-cursor JSR2
,font #00 ~Controller.key 8* ADD2 =Screen.addr
( draw ) #21 =Screen.color
~Screen.x 8+ =Screen.x
,draw-cursor JSR2
BRK BRK
@draw-cursor @draw-cursor
,cursor_icn =Screen.addr #22 =Screen.color ;cursor .Screen/addr IOW2 #22 .Screen/color IOW
RTN RTN
@cursor_icn [ ffff ffff ffff ffff ] @cursor
ffff ffff ffff ffff
@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
007e 4242 4242 7e00 0000 1824 2418 0000 0018 2442 4224 1800 001e 063a 4a48 3000 007e 4242 4242 7e00 0000 1824 2418 0000 0018 2442 4224 1800 001e 063a 4a48 3000
@ -83,4 +91,3 @@ RTN
0010 103c 1010 0c00 0000 4444 4444 3800 0000 4444 2828 1000 0000 4454 5454 2800 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 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 0008 0808 0808 0800 0030 1008 0810 3000 0000 0032 4c00 0000 3c42 99a1 a199 423c
]