Improved some of the examples
This commit is contained in:
parent
57d29b1b10
commit
b4e766fd52
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
|
# 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 projects/examples/dev.mouse.usm bin/boot.rom
|
./bin/assembler projects/examples/win.editor.usm bin/boot.rom
|
||||||
./bin/emulator bin/boot.rom
|
./bin/emulator bin/boot.rom
|
||||||
|
|
|
@ -73,17 +73,17 @@ RTS
|
||||||
@line-rect ( x1 y1 x2 y2 color )
|
@line-rect ( x1 y1 x2 y2 color )
|
||||||
|
|
||||||
( load ) =color =rect.y2 =rect.x2 DUP2 =Screen.y =rect.y1 DUP2 =Screen.x =rect.x1
|
( load ) =color =rect.y2 =rect.x2 DUP2 =Screen.y =rect.y1 DUP2 =Screen.x =rect.x1
|
||||||
@line-rect-hor
|
$hor
|
||||||
( incr ) ~Screen.x #0001 ADD2 =Screen.x
|
( incr ) ~Screen.x #0001 ADD2 =Screen.x
|
||||||
( draw ) ~rect.y1 =Screen.y ~color =Screen.color
|
( draw ) ~rect.y1 =Screen.y ~color =Screen.color
|
||||||
( draw ) ~rect.y2 =Screen.y ~color =Screen.color
|
( draw ) ~rect.y2 =Screen.y ~color =Screen.color
|
||||||
,line-rect-hor ~Screen.x ~rect.x2 LTH2 JMP2? POP2
|
,$hor ~Screen.x ~rect.x2 LTH2 JMP2? POP2
|
||||||
~rect.y1 =Screen.y
|
~rect.y1 =Screen.y
|
||||||
@line-rect-ver
|
$ver
|
||||||
( draw ) ~rect.x1 =Screen.x ~color =Screen.color
|
( draw ) ~rect.x1 =Screen.x ~color =Screen.color
|
||||||
( draw ) ~rect.x2 =Screen.x ~color =Screen.color
|
( draw ) ~rect.x2 =Screen.x ~color =Screen.color
|
||||||
( incr ) ~Screen.y #0001 ADD2 =Screen.y
|
( incr ) ~Screen.y #0001 ADD2 =Screen.y
|
||||||
,line-rect-ver ~Screen.y ~rect.y2 #0001 ADD2 LTH2 JMP2? POP2
|
,$ver ~Screen.y ~rect.y2 #0001 ADD2 LTH2 JMP2? POP2
|
||||||
|
|
||||||
RTS
|
RTS
|
||||||
|
|
||||||
|
|
|
@ -30,11 +30,11 @@ BRK
|
||||||
|
|
||||||
( load ) =label.addr =label.color =Sprite.y =Sprite.x
|
( load ) =label.addr =label.color =Sprite.y =Sprite.x
|
||||||
~label.addr
|
~label.addr
|
||||||
@draw-label-left-loop
|
$loop
|
||||||
( draw ) DUP2 LDR #00 SWP #0008 MUL2 ,font ADD2 =Sprite.addr ~label.color =Sprite.color
|
( draw ) DUP2 LDR #00 SWP #0008 MUL2 ,font ADD2 =Sprite.addr ~label.color =Sprite.color
|
||||||
( incr ) #0001 ADD2
|
( incr ) #0001 ADD2
|
||||||
( incr ) ~Sprite.x #0008 ADD2 =Sprite.x
|
( incr ) ~Sprite.x #0008 ADD2 =Sprite.x
|
||||||
DUP2 LDR #00 NEQ ,draw-label-left-loop ROT JMP2? POP2
|
DUP2 LDR #00 NEQ ,$loop ROT JMP2? POP2
|
||||||
POP2
|
POP2
|
||||||
|
|
||||||
RTS
|
RTS
|
||||||
|
@ -44,11 +44,11 @@ RTS
|
||||||
( load ) =label.addr =label.color =Sprite.y
|
( load ) =label.addr =label.color =Sprite.y
|
||||||
( align ) ~label.addr ,get-text-length JSR2 #0008 MUL2 #0002 DIV2 SUB2 =Sprite.x
|
( align ) ~label.addr ,get-text-length JSR2 #0008 MUL2 #0002 DIV2 SUB2 =Sprite.x
|
||||||
~label.addr
|
~label.addr
|
||||||
@draw-label-middle-loop
|
$loop
|
||||||
( draw ) DUP2 LDR #00 SWP #0008 MUL2 ,font ADD2 =Sprite.addr ~label.color =Sprite.color
|
( draw ) DUP2 LDR #00 SWP #0008 MUL2 ,font ADD2 =Sprite.addr ~label.color =Sprite.color
|
||||||
( incr ) #0001 ADD2
|
( incr ) #0001 ADD2
|
||||||
( incr ) ~Sprite.x #0008 ADD2 =Sprite.x
|
( incr ) ~Sprite.x #0008 ADD2 =Sprite.x
|
||||||
DUP2 LDR #00 NEQ ,draw-label-middle-loop ROT JMP2? POP2
|
DUP2 LDR #00 NEQ ,$loop ROT JMP2? POP2
|
||||||
POP2
|
POP2
|
||||||
|
|
||||||
RTS
|
RTS
|
||||||
|
@ -58,11 +58,11 @@ RTS
|
||||||
( load ) =label.addr =label.color =Sprite.y
|
( load ) =label.addr =label.color =Sprite.y
|
||||||
( align ) ~label.addr ,get-text-length JSR2 #0008 MUL2 SUB2 #0008 SUB2 =Sprite.x
|
( align ) ~label.addr ,get-text-length JSR2 #0008 MUL2 SUB2 #0008 SUB2 =Sprite.x
|
||||||
~label.addr
|
~label.addr
|
||||||
@draw-label-right-loop
|
$loop
|
||||||
( draw ) DUP2 LDR #00 SWP #0008 MUL2 ,font ADD2 =Sprite.addr ~label.color =Sprite.color
|
( draw ) DUP2 LDR #00 SWP #0008 MUL2 ,font ADD2 =Sprite.addr ~label.color =Sprite.color
|
||||||
( incr ) #0001 ADD2
|
( incr ) #0001 ADD2
|
||||||
( incr ) ~Sprite.x #0008 ADD2 =Sprite.x
|
( incr ) ~Sprite.x #0008 ADD2 =Sprite.x
|
||||||
DUP2 LDR #00 NEQ ,draw-label-right-loop ROT JMP2? POP2
|
DUP2 LDR #00 NEQ ,$loop ROT JMP2? POP2
|
||||||
POP2
|
POP2
|
||||||
|
|
||||||
RTS
|
RTS
|
||||||
|
@ -70,10 +70,10 @@ RTS
|
||||||
@get-text-length ( label )
|
@get-text-length ( label )
|
||||||
|
|
||||||
#0000 ( counter )
|
#0000 ( counter )
|
||||||
@get-text-length-loop
|
$loop
|
||||||
( incr ) #0001 ADD2 OVR2 OVR2 ADD2
|
( incr ) #0001 ADD2 OVR2 OVR2 ADD2
|
||||||
LDR #00 NEQ ,get-text-length-loop ROT JMP2? POP2
|
LDR #00 NEQ ,$loop ROT JMP2? POP2
|
||||||
SWP2 POP2 #0001 SUB2
|
SWP2 POP2
|
||||||
|
|
||||||
RTS
|
RTS
|
||||||
|
|
||||||
|
|
|
@ -11,7 +11,7 @@
|
||||||
|
|
||||||
|0100 @RESET
|
|0100 @RESET
|
||||||
|
|
||||||
#0030 =window.x1 #0030 =window.y1 #00a8 =window.x2 #0090 =window.y2
|
#0030 =window.x1 #0030 =window.y1 #0090 =window.x2 #0090 =window.y2
|
||||||
|
|
||||||
~window.x1 #0010 ADD2 =editor.x1
|
~window.x1 #0010 ADD2 =editor.x1
|
||||||
~window.y1 #0010 ADD2 =editor.y1
|
~window.y1 #0010 ADD2 =editor.y1
|
||||||
|
@ -79,106 +79,83 @@ RTS
|
||||||
~editor.addr =Sprite.addr
|
~editor.addr =Sprite.addr
|
||||||
|
|
||||||
#00 =pixel.y
|
#00 =pixel.y
|
||||||
@redraw-ver
|
$ver
|
||||||
#00 =pixel.x
|
#00 =pixel.x
|
||||||
~editor.x1 =Sprite.x
|
~editor.x1 =Sprite.x
|
||||||
@redraw-hor
|
$hor
|
||||||
|
|
||||||
( get bit )
|
( get bit )
|
||||||
,cell0_icn #00
|
,cell0_icn #00
|
||||||
~editor.addr #00 ~pixel.y ADD2 LDR #07 ~pixel.x SUB ROR #01 AND ( get bit )
|
~editor.addr #00 ~pixel.y ADD2 LDR #07 ~pixel.x SUB ROR #01 AND ( get bit )
|
||||||
#0008 MUL2 ADD2 =Sprite.addr ( add *8 )
|
#0008 MUL2 ADD2 =Sprite.addr ( add *8 )
|
||||||
|
|
||||||
( draw ) #08 =Sprite.color
|
( draw ) #08 =Sprite.color
|
||||||
( incr ) ~Sprite.x #0008 ADD2 =Sprite.x
|
( incr ) ~Sprite.x #0008 ADD2 =Sprite.x
|
||||||
( incr ) ~pixel.x #01 ADD =pixel.x
|
( incr ) ~pixel.x #01 ADD =pixel.x
|
||||||
,redraw-hor ~Sprite.x ~editor.x1 #0040 ADD2 LTH2 JMP2? POP2
|
,$hor ~Sprite.x ~editor.x1 #0040 ADD2 LTH2 JMP2? POP2
|
||||||
( incr ) ~Sprite.y #0008 ADD2 =Sprite.y
|
( incr ) ~Sprite.y #0008 ADD2 =Sprite.y
|
||||||
( incr ) ~pixel.y #01 ADD =pixel.y
|
( incr ) ~pixel.y #01 ADD =pixel.y
|
||||||
,redraw-ver ~Sprite.y ~editor.y1 #0040 ADD2 LTH2 JMP2? POP2
|
,$ver ~Sprite.y ~editor.y1 #0040 ADD2 LTH2 JMP2? POP2
|
||||||
|
|
||||||
~editor.addr =Sprite.addr
|
~editor.addr =Sprite.addr
|
||||||
~window.y1 =Sprite.y
|
~window.y1 =Sprite.y
|
||||||
~window.x2 #0008 SUB2 =Sprite.x
|
~window.x2 #0008 SUB2 =Sprite.x
|
||||||
( draw ) #01 =Sprite.color
|
( draw ) #01 =Sprite.color
|
||||||
|
|
||||||
( TODO: Make a loop.. )
|
|
||||||
~window.x1 #0058 ADD2 ~window.y1 #0010 ADD2 #08 ~editor.addr ,draw-byte JSR2
|
|
||||||
~window.x1 #0058 ADD2 ~window.y1 #0018 ADD2 #08 ~editor.addr #0001 ADD2 ,draw-byte JSR2
|
|
||||||
~window.x1 #0058 ADD2 ~window.y1 #0020 ADD2 #08 ~editor.addr #0002 ADD2 ,draw-byte JSR2
|
|
||||||
~window.x1 #0058 ADD2 ~window.y1 #0028 ADD2 #08 ~editor.addr #0003 ADD2 ,draw-byte JSR2
|
|
||||||
~window.x1 #0058 ADD2 ~window.y1 #0030 ADD2 #08 ~editor.addr #0004 ADD2 ,draw-byte JSR2
|
|
||||||
~window.x1 #0058 ADD2 ~window.y1 #0038 ADD2 #08 ~editor.addr #0005 ADD2 ,draw-byte JSR2
|
|
||||||
~window.x1 #0058 ADD2 ~window.y1 #0040 ADD2 #08 ~editor.addr #0006 ADD2 ,draw-byte JSR2
|
|
||||||
~window.x1 #0058 ADD2 ~window.y1 #0048 ADD2 #08 ~editor.addr #0007 ADD2 ,draw-byte JSR2
|
|
||||||
|
|
||||||
RTS
|
RTS
|
||||||
|
|
||||||
@draw-label-left ( x y color addr )
|
@draw-label-left ( x y color addr )
|
||||||
|
|
||||||
( load ) =label.addr =label.color =Sprite.y =Sprite.x
|
( load ) =label.addr =label.color =Sprite.y =Sprite.x
|
||||||
~label.addr
|
~label.addr
|
||||||
@draw-label-left-loop
|
$loop NOP
|
||||||
( draw ) DUP2 LDR #00 SWP #0008 MUL2 ,font ADD2 =Sprite.addr ~label.color =Sprite.color
|
( draw ) DUP2 LDR #00 SWP #0008 MUL2 ,font ADD2 =Sprite.addr ~label.color =Sprite.color
|
||||||
( incr ) #0001 ADD2
|
( incr ) #0001 ADD2
|
||||||
( incr ) ~Sprite.x #0008 ADD2 =Sprite.x
|
( incr ) ~Sprite.x #0007 ADD2 =Sprite.x
|
||||||
DUP2 #0001 ADD2 LDR #00 NEQ ,draw-label-left-loop ROT JMP2? POP2
|
DUP2 LDR #00 NEQ ^$loop MUL JMPS
|
||||||
POP2
|
POP2
|
||||||
|
|
||||||
RTS
|
RTS
|
||||||
|
|
||||||
@draw-byte ( x y color addr )
|
|
||||||
|
|
||||||
( load ) =addr =color =Sprite.y =Sprite.x
|
|
||||||
,font_hex #00 ~addr LDR #f0 AND #04 ROR #08 MUL ADD2 =Sprite.addr ~color =Sprite.color
|
|
||||||
~Sprite.x #0008 ADD2 =Sprite.x
|
|
||||||
,font_hex #00 ~addr LDR #0f AND #08 MUL ADD2 =Sprite.addr ~color =Sprite.color
|
|
||||||
|
|
||||||
RTS
|
|
||||||
|
|
||||||
@fill-rect ( x1 y1 x2 y2 color )
|
@fill-rect ( x1 y1 x2 y2 color )
|
||||||
|
|
||||||
( load ) =color =rect.y2 =rect.x2 DUP2 =Screen.y =rect.y1 DUP2 =Screen.x =rect.x1
|
( load ) =color =rect.y2 =rect.x2 DUP2 =Screen.y =rect.y1 DUP2 =Screen.x =rect.x1
|
||||||
@fill-rect-ver
|
$ver NOP
|
||||||
~rect.x1 =Screen.x
|
~rect.x1 =Screen.x
|
||||||
@fill-rect-hor
|
$hor NOP
|
||||||
( draw ) ~color =Screen.color
|
( draw ) ~color =Screen.color
|
||||||
( incr ) ~Screen.x #0001 ADD2 =Screen.x
|
( incr ) ~Screen.x #0001 ADD2 =Screen.x
|
||||||
,fill-rect-hor ~Screen.x ~rect.x2 LTH2 JMP2? POP2
|
~Screen.x ~rect.x2 LTH2 ^$hor MUL JMPS
|
||||||
( incr ) ~Screen.y #0001 ADD2 =Screen.y
|
( incr ) ~Screen.y #0001 ADD2 =Screen.y
|
||||||
,fill-rect-ver ~Screen.y ~rect.y2 LTH2 JMP2? POP2
|
~Screen.y ~rect.y2 LTH2 ^$ver MUL JMPS
|
||||||
|
|
||||||
RTS
|
RTS
|
||||||
|
|
||||||
@line-rect ( x1 y1 x2 y2 color )
|
@line-rect ( x1 y1 x2 y2 color )
|
||||||
|
|
||||||
( load ) =color =rect.y2 =rect.x2 DUP2 =Screen.y =rect.y1 DUP2 =Screen.x =rect.x1
|
( load ) =color =rect.y2 =rect.x2 DUP2 =Screen.y =rect.y1 DUP2 =Screen.x =rect.x1
|
||||||
@line-rect-hor
|
$hor NOP
|
||||||
( incr ) ~Screen.x #0001 ADD2 =Screen.x
|
( incr ) ~Screen.x #0001 ADD2 =Screen.x
|
||||||
( draw ) ~rect.y1 =Screen.y ~color =Screen.color
|
( draw ) ~rect.y1 =Screen.y ~color =Screen.color
|
||||||
( draw ) ~rect.y2 =Screen.y ~color =Screen.color
|
( draw ) ~rect.y2 =Screen.y ~color =Screen.color
|
||||||
,line-rect-hor ~Screen.x ~rect.x2 LTH2 JMP2? POP2
|
~Screen.x ~rect.x2 LTH2 ^$hor MUL JMPS
|
||||||
~rect.y1 =Screen.y
|
~rect.y1 =Screen.y
|
||||||
@line-rect-ver
|
$ver NOP
|
||||||
( draw ) ~rect.x1 =Screen.x ~color =Screen.color
|
( draw ) ~rect.x1 =Screen.x ~color =Screen.color
|
||||||
( draw ) ~rect.x2 =Screen.x ~color =Screen.color
|
( draw ) ~rect.x2 =Screen.x ~color =Screen.color
|
||||||
( incr ) ~Screen.y #0001 ADD2 =Screen.y
|
( incr ) ~Screen.y #0001 ADD2 =Screen.y
|
||||||
,line-rect-ver ~Screen.y ~rect.y2 #0001 ADD2 LTH2 JMP2? POP2
|
~Screen.y ~rect.y2 #0001 ADD2 LTH2 ^$ver MUL JMPS
|
||||||
|
|
||||||
RTS
|
RTS
|
||||||
|
|
||||||
@tile-rect ( x1 y1 x2 y2 color addr )
|
@tile-rect ( x1 y1 x2 y2 color addr )
|
||||||
|
|
||||||
=Sprite.addr =color =rect.y2 =rect.x2 DUP2 =Sprite.y =rect.y1 DUP2 =Sprite.x =rect.x1
|
=Sprite.addr =color =rect.y2 =rect.x2 DUP2 =Sprite.y =rect.y1 DUP2 =Sprite.x =rect.x1
|
||||||
|
$ver NOP
|
||||||
@tile-rect-ver
|
|
||||||
~rect.x1 =Sprite.x
|
~rect.x1 =Sprite.x
|
||||||
@tile-rect-hor
|
$hor NOP
|
||||||
( draw ) ~color =Sprite.color
|
( draw ) ~color =Sprite.color
|
||||||
( incr ) ~Sprite.x #0008 ADD2 =Sprite.x
|
( incr ) ~Sprite.x #0008 ADD2 =Sprite.x
|
||||||
,tile-rect-hor ~Sprite.x ~rect.x2 LTH2 JMP2? POP2
|
~Sprite.x ~rect.x2 LTH2 ^$hor MUL JMPS
|
||||||
( incr ) ~Sprite.y #0008 ADD2 =Sprite.y
|
( incr ) ~Sprite.y #0008 ADD2 =Sprite.y
|
||||||
,tile-rect-ver ~Sprite.y ~rect.y2 LTH2 JMP2? POP2
|
~Sprite.y ~rect.y2 LTH2 ^$ver MUL JMPS
|
||||||
|
|
||||||
RTS
|
RTS
|
||||||
|
|
||||||
|
@ -207,19 +184,7 @@ RTS
|
||||||
@cell0_icn [ 7c82 8282 8282 7c00 ]
|
@cell0_icn [ 7c82 8282 8282 7c00 ]
|
||||||
@cell1_icn [ 7cfe fefe fefe 7c00 ]
|
@cell1_icn [ 7cfe fefe fefe 7c00 ]
|
||||||
|
|
||||||
@window_name [ pixel-editor 00 ]
|
@window_name [ Editor 00 ]
|
||||||
|
|
||||||
@font_hex ( 0-F )
|
|
||||||
[
|
|
||||||
7c82 8282 8282 7c00 3010 1010 1010 1000
|
|
||||||
7c82 027c 8080 fe00 7c82 027c 0282 7c00
|
|
||||||
4282 82fe 0202 0200 fc82 807c 0282 7c00
|
|
||||||
7c82 80fc 8282 7c00 7c82 021e 0202 0200
|
|
||||||
7c82 827c 8282 7c00 7c82 827e 0202 0400
|
|
||||||
7c82 027e 8282 7e00 fc82 82fc 8282 fc00
|
|
||||||
7c82 8080 8082 7c00 fc82 8282 8282 fc00
|
|
||||||
7c82 80f0 8082 7c00 7c82 80f0 8080 8000
|
|
||||||
]
|
|
||||||
|
|
||||||
@font ( spectrum-zx font )
|
@font ( spectrum-zx font )
|
||||||
[
|
[
|
||||||
|
|
Loading…
Reference in New Issue