( 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 |80 @Controller &vector $2 &button $1 &key $1 |90 @Mouse &vector $2 &x $2 &y $2 &state $1 &chord $1 &pad $4 &scrolly &scrolly-hb $1 &scrolly-lb $1 |0000 @hover $2 @lock $1 @layer $1 |0100 @on-reset ( -> ) ;meta #06 DEO2 #d306 .System/r DEO2 #d90c .System/g DEO2 #d608 .System/b DEO2 #0130 .Screen/width DEO2 #00d0 .Screen/height DEO2 ;on-mouse .Mouse/vector DEO2 ;on-control .Controller/vector DEO2 ( #010e DEO ) BRK @meta $1 ( name ) "Shaviankb 0a ( desc ) "Shavian 20 "Keyboard 0a ( auth ) "By 20 "Devine 20 "Lu 20 "Linvega 0a ( date ) "11 20 "Feb 20 "2024 $1 ( exts ) 00 @on-mouse ( -> ) [ LIT2 00 -Mouse/state ] DEI NEQ #42 ADD ;pointer-icn ( | within ) .Mouse/x DEI2 #0008 SUB2 #0120 LTH2 ?{ BRK } .Mouse/y DEI2 #0008 SUB2 #00c0 LTH2 ?{ BRK } [ LIT2 &last 00 -Mouse/state ] DEI #00 NEQ DUP ,&last STR DUP2 #0100 EQU2 ?on-mouse-release NIP ?on-mouse-down ( | hover ) get-mouse-key BRK @on-mouse-release ( states* -> ) .hover LDZ2 ;btn-hover-chr [ LIT2 00 -lock ] STZ POP2 BRK @on-mouse-down ( -> ) .lock LDZ ?{ get-mouse-key [ LIT2 01 -lock ] STZ } BRK @on-control ( -> ) ( | release ) .Controller/button DEI2 ORA ?{ #00 [ LIT2 00 -lock ] STZ BRK } ( | toggle layer ) .Controller/button DEI ( | buttons ) DUP [ LIT 40 ] NEQ ?{ #0018 } DUP [ LIT 80 ] NEQ ?{ #0019 } DUP [ LIT 04 ] NEQ ?{ #01 } POP ( | key ) .Controller/key DEI tolowercase ( | top row ) DUP [ LIT "q ] NEQ ?{ #0000 } DUP [ LIT "w ] NEQ ?{ #0001 } DUP [ LIT "e ] NEQ ?{ #0002 } DUP [ LIT "r ] NEQ ?{ #0003 } DUP [ LIT "t ] NEQ ?{ #0004 } DUP [ LIT "y ] NEQ ?{ #0005 } DUP [ LIT "u ] NEQ ?{ #0006 } DUP [ LIT "i ] NEQ ?{ #0007 } DUP [ LIT "o ] NEQ ?{ #0008 } ( | middle row ) DUP [ LIT "a ] NEQ ?{ #0009 } DUP [ LIT "s ] NEQ ?{ #000a } DUP [ LIT "d ] NEQ ?{ #000b } DUP [ LIT "f ] NEQ ?{ #000c } DUP [ LIT "g ] NEQ ?{ #000d } DUP [ LIT "h ] NEQ ?{ #000e } DUP [ LIT "j ] NEQ ?{ #000f } DUP [ LIT "k ] NEQ ?{ #0010 } DUP [ LIT "l ] NEQ ?{ #0011 } ( | bottom row ) DUP [ LIT "z ] NEQ ?{ #0012 } DUP [ LIT "x ] NEQ ?{ #0013 } DUP [ LIT "c ] NEQ ?{ #0014 } DUP [ LIT "v ] NEQ ?{ #0015 } DUP [ LIT "b ] NEQ ?{ #0016 } DUP [ LIT "n ] NEQ ?{ #0017 } ( | special ) DUP [ LIT 08 ] NEQ ?{ #001a } DUP [ LIT 0d ] NEQ ?{ #001f } DUP [ LIT 20 ] NEQ ?{ #001d } DUP [ LIT ", ] NEQ ?{ #001c } DUP [ LIT ". ] NEQ ?{ #001e } POP BRK ( @|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 @ ( id* -- ) DUP #1b NEQ ?{ POP2 ! } .hover LDZ2 ;btn-chr DUP2 ;btn-press-chr DUP2 .hover STZ2 STH2k ( | event ) ( key ) #0006 MUL2 ;layout ADD2 ( layer ) STH2r get-layer #10 SFT2 ADD2 LDA2 ( length ) #0010 ADD2 LDA2k SWP2 INC2 INC2 &l ( -- ) LDAk #18 DEO INC2 GTH2k ?&l POP2 POP2 JMP2r @get-layer ( id* -- layer* ) #0017 GTH2 ?&bottom .Mouse/state DEI ( ) DUP #02 AND ?&top ( ) #04 AND ?&bottom .layer LDZ ( ) DUP #01 EQU ?&top ( ) #02 EQU ?&bottom #0001 JMP2r &top POP #0000 JMP2r &bottom #0002 JMP2r @ ( -- ) .layer LDZ INC #03 DIVk MUL SUB ( >> ) @ ( layer -- ) .layer STZ ! @ ( id* -- ) DUP2 .hover LDZ2 EQU2 ?{ .hover LDZ2 ;btn-chr DUP2 ;btn-hover-chr .hover STZ2 ! } POP2 JMP2r @ ( id* -- ) DUP2 #0009 DIV2 #0030 MUL2 #0008 ADD2 .Screen/y DEO2 DUP #1e NEQ ?{ POP2 #0007 } DUP #1f NEQ ?{ POP2 #0008 } #0009 DIV2k MUL2 SUB2 #50 SFT2 #0008 ADD2 .Screen/x DEO2 JMP2r ( @|drawing ) @ ( -- ) #0020 #0000 &l ( -- ) DUP2 ;btn-chr INC2 GTH2k ?&l POP2 POP2 JMP2r @ ( id* frame* -- ) OVR2 OVR2 #001d EQU2 ? STH2 #0006 MUL2 ;layout ADD2 ( ) STH2k #0004 ADD2 LDA2 ( ) STH2kr #0002 ADD2 LDA2 ( ) STH2r LDA2 STH2r ! @ ( a* b* c* frame* -- ) DUP2 ;btn-hover-chr EQU2 STH DUP2 ;btn-press-chr EQU2 #10 SFT STH .Screen/x DEI2k #0002 SUB2 ROT DEO2 .Screen/y DEI2k #0024 STHr SUB STHr SUB SUB2 ROT DEO2 ( | a ) #0a00 [ LIT2 01 -layer ] LDZ EQU [ JMP SWP POP ] .Screen/x DEI2k #0002 SUB2 ROT DEO2 .Screen/y DEI2k #000c ADD2 ROT DEO2 ( | b ) #0a00 [ LIT2 00 -layer ] LDZ EQU [ JMP SWP POP ] .Screen/x DEI2k #0002 SUB2 ROT DEO2 .Screen/y DEI2k #000c ADD2 ROT DEO2 ( | c ) #0a05 [ LIT2 02 -layer ] LDZ EQU [ JMP SWP POP ] .Screen/x DEI2k #0006 ADD2 ROT DEO2 .Screen/y DEI2k #001c SUB2 ROT DEO2 JMP2r @ ( addr* color -- ) STH .Screen/addr DEO2 [ LIT2 15 -Screen/auto ] DEO STHr .Screen/sprite DEO JMP2r @ ( id* frame* -- ) DUP2 ;btn-press-chr NEQ2 #10 SFT INC ,&color STR STH2 POP2 .Screen/x DEI2 .Screen/y DEI2 #1204 STH2r ;fill-icn .Screen/addr DEO2 [ LIT2 31 -Screen/auto ] DEO [ LIT2 &color 03 ee ] ( | glyph ) .Screen/x DEI2k #0008 SUB2 ROT DEO2 .Screen/y DEI2k #0016 ADD2 ROT DEO2 ;keys/space #05 ( | draw hint ) JMP2r @ ( -- ) ( | clear ) #0050 .Screen/x DEO2 #00b2 .Screen/y DEO2 [ LIT2 f2 -Screen/auto ] DEO ;fill-icn .Screen/addr DEO2 [ LIT2 0f -Screen/sprite ] DEOk DEO ( | draw ) #0050 .Screen/x DEO2 #00b2 .Screen/y DEO2 .hover LDZ2 STH2k ( key ) #0006 MUL2 ;layout ADD2 ( layer ) STH2r get-layer #10 SFT2 ADD2 LDA2 ( length ) #0010 ADD2 LDA2 ! @ ( addr* -- ) [ LIT2 15 -Screen/auto ] DEO &w ( -- ) LDAk #20 SUB #00 SWP #40 SFT2 ;font-mono ADD2 .Screen/addr DEO2 [ LIT2 0c -Screen/sprite ] DEO INC2 LDAk ?&w POP2 JMP2r @ ( frame* -- ) DUP2 ;btn-press-chr NEQ2 #10 SFT INC ,&color STR STH2 .Screen/x DEI2 .Screen/y DEI2 #0204 STH2r ;fill-icn .Screen/addr DEO2 [ LIT2 12 -Screen/auto ] DEO [ LIT2 &color 03 -Screen/sprite ] DEOk DEOk DEOk DEO JMP2r @ ( x* y* w h sprite* -- ) .Screen/addr DEO2 ,&h STR ,&w STR DUP2 .Screen/y DEO2 ,&y STR2 DUP2 .Screen/x DEO2 ,&x STR2 [ LIT2 01 -Screen/auto ] DEO [ LIT2 81 -Screen/sprite ] DEO /next [ LIT &w $1 ] /repeat [ LIT2 02 -Screen/auto ] DEO /next [ LIT2 81 -Screen/sprite ] DEO /next [ LIT &h $1 ] /repeat ( left ) [ LIT2 &y $2 ] #0008 ADD2 .Screen/y DEO2 [ LIT2 &x $2 ] .Screen/x DEO2 /next ,&h LDR /repeat [ LIT2 01 -Screen/auto ] DEO /next [ LIT2 81 -Screen/sprite ] DEO /next ,&w LDR /repeat /next [ LIT2 81 -Screen/sprite ] DEO ,&x LDR2 #0008 ADD2 .Screen/x DEO2 ,&y LDR2 #0008 ADD2 .Screen/y DEO2 JMP2r &next .Screen/addr DEI2k #0010 ADD2 ROT DEO2 JMP2r &repeat #8100 ROT SUB ( >> ) @ ( color times -- ) OVR .Screen/sprite DEO INC DUP ? POP2 JMP2r @ ( color addr* -- ) [ LIT2 00 -Screen/auto ] DEO ;fill-icn .Screen/addr DEO2 #40 .Mouse/x DEI2 ,/x STR2 .Mouse/y DEI2 ,/y STR2 .Screen/addr DEO2 @ ( color -- ) [ LIT2 &x $2 ] .Screen/x DEO2 [ LIT2 &y $2 ] .Screen/y DEO2 .Screen/sprite DEO JMP2r ( @|stdlib ) @tolowercase ( char -- char ) DUP [ LIT "A ] GTH ?{ JMP2r } DUP [ LIT "Z ] LTH ?{ JMP2r } #20 ADD JMP2r @ ( short* -- ) SWP /b &b ( -- ) DUP #04 SFT /c &c ( -- ) #0f AND DUP #09 GTH #27 MUL ADD [ LIT "0 ] ADD #18 DEO JMP2r ~assets.tal