Improved hover example

This commit is contained in:
neauoire 2021-03-01 08:55:16 -08:00
parent 77a00f7a7e
commit 0027296839
4 changed files with 24 additions and 19 deletions

View File

@ -20,5 +20,5 @@ cc -std=c89 -DDEBUG -Wall -Wno-unknown-pragmas -Wpedantic -Wshadow -Wextra -Werr
# cc uxn.c emulator.c -std=c89 -Os -DNDEBUG -g0 -s -Wall -Wno-unknown-pragmas -L/usr/local/lib -lSDL2 -o bin/emulator # cc uxn.c emulator.c -std=c89 -Os -DNDEBUG -g0 -s -Wall -Wno-unknown-pragmas -L/usr/local/lib -lSDL2 -o bin/emulator
# run # run
./bin/assembler examples/dev.mouse.usm bin/boot.rom ./bin/assembler examples/gui.hover.usm bin/boot.rom
./bin/emulator bin/boot.rom ./bin/emulator bin/boot.rom

View File

@ -329,7 +329,11 @@ doctrl(Uxn *u, SDL_Event *event, int z)
Uint8 Uint8
console_poke(Uint8 *m, Uint16 ptr, Uint8 b0, Uint8 b1) console_poke(Uint8 *m, Uint16 ptr, Uint8 b0, Uint8 b1)
{ {
printf("%c", b1); switch(b0) {
case 0x08: printf("%c", b1); break;
case 0x09: printf("%02x", b1); break;
case 0x0a: printf("%d", b1); break;
}
fflush(stdout); fflush(stdout);
(void)m; (void)m;
(void)ptr; (void)ptr;

View File

@ -1,6 +1,6 @@
( hello world ) ( hello world )
&Console { pad 8 stdio 1 } &Console { pad 8 char 1 byte 1 }
|0100 @RESET |0100 @RESET
@ -11,7 +11,7 @@ BRK
@print-label ( text ) @print-label ( text )
@cliloop @cliloop
DUP2 LDR =dev/console.stdio ( write pointer value to console ) DUP2 LDR =dev/console.char ( write pointer value to console )
#0001 ADD2 ( increment string pointer ) #0001 ADD2 ( increment string pointer )
DUP2 LDR #00 NEQ ,cliloop ROT JMP? POP2 ( while *ptr!=0 goto loop ) DUP2 LDR #00 NEQ ,cliloop ROT JMP? POP2 ( while *ptr!=0 goto loop )
POP2 POP2

View File

@ -22,31 +22,32 @@
BRK BRK
|0200 @FRAME |0200 @FRAME
,pointer_icn =cursor ,pointer_icn =cursor
#01 =color #01 =color
( matrix comparison )
~dev/mouse.x ~r1.x1 GTH2 ~dev/mouse.x ~r1.x2 LTH2 #0101 EQU2 ~dev/mouse.x ~r1.x1 GTH2 ~dev/mouse.x ~r1.x2 LTH2 #0101 EQU2
~dev/mouse.y ~r1.y1 GTH2 ~dev/mouse.y ~r1.y2 LTH2 #0101 EQU2 ~dev/mouse.y ~r1.y1 GTH2 ~dev/mouse.y ~r1.y2 LTH2 #0101 EQU2
#0101 NEQ2 ,skip1 ROT JMP? POP2 #02 =color ,hand_icn =cursor @skip1 #0101 NEQ2 ,draw1 ROT JMP? POP2 #02 =color ,hand_icn =cursor
~r1.x1 ~r1.y1 ~r1.x2 ~r1.y2 ~color ,line-rect JSR @draw1 ~r1.x1 ~r1.y1 ~r1.x2 ~r1.y2 ~color ,line-rect JSR
#01 =color #01 =color
( 2-step comparison )
~dev/mouse.x ~r2.x1 GTH2 ~dev/mouse.x ~r2.x2 LTH2 #0101 EQU2 ,draw2 ~dev/mouse.x ~r2.x1 GTH2 ~dev/mouse.x ~r2.x2 LTH2 #0101 NEQ2 JMP? POP2
~dev/mouse.y ~r2.y1 GTH2 ~dev/mouse.y ~r2.y2 LTH2 #0101 EQU2 ,draw2 ~dev/mouse.y ~r2.y1 GTH2 ~dev/mouse.y ~r2.y2 LTH2 #0101 NEQ2 JMP? POP2
#0101 NEQ2 ,skip2 ROT JMP? POP2 #02 =color ,hand_icn =cursor @skip2 #03 =color ,hand_icn =cursor
~r2.x1 ~r2.y1 ~r2.x2 ~r2.y2 ~color ,line-rect JSR @draw2 ~r2.x1 ~r2.y1 ~r2.x2 ~r2.y2 ~color ,line-rect JSR
#01 =color #01 =color
( 4-step comparison )
~dev/mouse.x ~r3.x1 GTH2 ~dev/mouse.x ~r3.x2 LTH2 #0101 EQU2 ,draw3 ~dev/mouse.x ~r3.x1 LTH2 JMP? POP2
~dev/mouse.y ~r3.y1 GTH2 ~dev/mouse.y ~r3.y2 LTH2 #0101 EQU2 ,draw3 ~dev/mouse.x ~r3.x2 GTH2 JMP? POP2
#0101 NEQ2 ,skip3 ROT JMP? POP2 #02 =color ,hand_icn =cursor @skip3 ,draw3 ~dev/mouse.y ~r3.y1 LTH2 JMP? POP2
~r3.x1 ~r3.y1 ~r3.x2 ~r3.y2 ~color ,line-rect JSR ,draw3 ~dev/mouse.y ~r3.y2 GTH2 JMP? POP2
#02 =color ,hand_icn =cursor
@draw3 ~r3.x1 ~r3.y1 ~r3.x2 ~r3.y2 ~color ,line-rect JSR
,draw-cursor JSR ,draw-cursor JSR