mirror of
https://git.sr.ht/~rabbits/uxn
synced 2024-11-27 08:13:01 +00:00
Improved hover example
This commit is contained in:
parent
77a00f7a7e
commit
0027296839
4 changed files with 24 additions and 19 deletions
2
build.sh
2
build.sh
|
@ -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
|
||||
|
||||
# run
|
||||
./bin/assembler examples/dev.mouse.usm bin/boot.rom
|
||||
./bin/assembler examples/gui.hover.usm bin/boot.rom
|
||||
./bin/emulator bin/boot.rom
|
||||
|
|
|
@ -329,7 +329,11 @@ doctrl(Uxn *u, SDL_Event *event, int z)
|
|||
Uint8
|
||||
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);
|
||||
(void)m;
|
||||
(void)ptr;
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
( hello world )
|
||||
|
||||
&Console { pad 8 stdio 1 }
|
||||
&Console { pad 8 char 1 byte 1 }
|
||||
|
||||
|0100 @RESET
|
||||
|
||||
|
@ -11,11 +11,11 @@ BRK
|
|||
@print-label ( text )
|
||||
|
||||
@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 )
|
||||
DUP2 LDR #00 NEQ ,cliloop ROT JMP? POP2 ( while *ptr!=0 goto loop )
|
||||
POP2
|
||||
|
||||
|
||||
RTS
|
||||
|
||||
@text1 [ Hello World ] <1 .00 ( add text to memory, return 1 byte, add null byte )
|
||||
|
|
|
@ -22,31 +22,32 @@
|
|||
|
||||
BRK
|
||||
|
||||
|
||||
|0200 @FRAME
|
||||
|
||||
,pointer_icn =cursor
|
||||
|
||||
#01 =color
|
||||
|
||||
( matrix comparison )
|
||||
~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
|
||||
#0101 NEQ2 ,skip1 ROT JMP? POP2 #02 =color ,hand_icn =cursor @skip1
|
||||
~r1.x1 ~r1.y1 ~r1.x2 ~r1.y2 ~color ,line-rect JSR
|
||||
#0101 NEQ2 ,draw1 ROT JMP? POP2 #02 =color ,hand_icn =cursor
|
||||
@draw1 ~r1.x1 ~r1.y1 ~r1.x2 ~r1.y2 ~color ,line-rect JSR
|
||||
|
||||
#01 =color
|
||||
|
||||
~dev/mouse.x ~r2.x1 GTH2 ~dev/mouse.x ~r2.x2 LTH2 #0101 EQU2
|
||||
~dev/mouse.y ~r2.y1 GTH2 ~dev/mouse.y ~r2.y2 LTH2 #0101 EQU2
|
||||
#0101 NEQ2 ,skip2 ROT JMP? POP2 #02 =color ,hand_icn =cursor @skip2
|
||||
~r2.x1 ~r2.y1 ~r2.x2 ~r2.y2 ~color ,line-rect JSR
|
||||
( 2-step comparison )
|
||||
,draw2 ~dev/mouse.x ~r2.x1 GTH2 ~dev/mouse.x ~r2.x2 LTH2 #0101 NEQ2 JMP? POP2
|
||||
,draw2 ~dev/mouse.y ~r2.y1 GTH2 ~dev/mouse.y ~r2.y2 LTH2 #0101 NEQ2 JMP? POP2
|
||||
#03 =color ,hand_icn =cursor
|
||||
@draw2 ~r2.x1 ~r2.y1 ~r2.x2 ~r2.y2 ~color ,line-rect JSR
|
||||
|
||||
#01 =color
|
||||
|
||||
~dev/mouse.x ~r3.x1 GTH2 ~dev/mouse.x ~r3.x2 LTH2 #0101 EQU2
|
||||
~dev/mouse.y ~r3.y1 GTH2 ~dev/mouse.y ~r3.y2 LTH2 #0101 EQU2
|
||||
#0101 NEQ2 ,skip3 ROT JMP? POP2 #02 =color ,hand_icn =cursor @skip3
|
||||
~r3.x1 ~r3.y1 ~r3.x2 ~r3.y2 ~color ,line-rect JSR
|
||||
( 4-step comparison )
|
||||
,draw3 ~dev/mouse.x ~r3.x1 LTH2 JMP? POP2
|
||||
,draw3 ~dev/mouse.x ~r3.x2 GTH2 JMP? POP2
|
||||
,draw3 ~dev/mouse.y ~r3.y1 LTH2 JMP? POP2
|
||||
,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
|
||||
|
||||
|
|
Loading…
Reference in a new issue