commit e1a5cc61959c1438a54bb87d0922f4ffc2000805
parent e4b6717981fd9774795244c7819b0417f99185e7
Author: neauoire <aliceffekt@gmail.com>
Date: Sat, 20 Feb 2021 17:14:36 -0800
Fixed shapes example
Diffstat:
5 files changed, 83 insertions(+), 100 deletions(-)
diff --git a/build.sh b/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/paint.usm bin/boot.rom
+./bin/assembler examples/shapes.usm bin/boot.rom
./bin/emulator bin/boot.rom
diff --git a/examples/devmouse.usm b/examples/devmouse.usm
@@ -27,11 +27,10 @@ BRK
#00 IOR2 =mousex #02 IOR2 =mousey
( record mouse state )
#04 IOR #11 ADD =state
-
+ ( detect click )
#04 IOR #01 NEQ ,no-click ROT JMP? POP2
#50 =timer
@no-click
-
( draw mouse )
~state ,cursor_icn ~mousex ~mousey ,draw-sprite JSR
( animate )
diff --git a/examples/devscreen.usm b/examples/devscreen.usm
@@ -42,4 +42,4 @@ BRK
|c000 @FRAME BRK
|d000 @ERROR BRK
|FFF0 [ f0ac f0bb f053 ] ( palette )
-|FFFA .RESET .FRAME .ERROR
+|FFFA .RESET .FRAME .ERROR ( vectors )
diff --git a/examples/draw.usm b/examples/draw.usm
@@ -1,96 +0,0 @@
-( draw routines )
-
-:dev/r fff8 ( std read port )
-:dev/w fff9 ( std write port )
-
-;x_ 2 ;y_ 2 ;x 2 ;y 2 ;w 2 ;h 2 ;color 1
-;x0 2 ;y0 2 ;x1 2 ;y1 2 ;dx 2 ;dy 2 ;err1 2 ;err2 2 ( line )
-
-|0100 @RESET
-
- ( set dev/write to screen )
- #01 =dev/w ( set dev/write to sprite )
-
- #01 ,color STR
- ( fill rect x y w h )
- #0020 #0020 #0060 #0040 ,fillrect JSR
-
- #02 ,color STR
- ( fill rect x y w h )
- #0030 #0030 #0040 #0060 ,fillrect JSR
-
- #03 ,color STR
- ( fill rect x y w h )
- #0040 #0040 #0060 #0040 ,fillrect JSR
-
- #01 ,color STR
- ( fill rect x y w h )
- #00a0 #0010 #0020 #0020 ,fillrect JSR
-
- #02 ,color STR
- ( fill rect x y w h )
- #00b0 #0040 #0020 #0020 ,linerect JSR
-
- #03 ,color STR
- ( fill rect x y w h )
- #0058 #0028 #0050 #0050 ,linerect JSR
-
- #01 ,color STR
- ( fill rect x y w h )
- #0028 #0038 #0050 #0030 ,linerect JSR
-
- ,redraw JSR
-
-BRK
-
-@fillrect
- ,h STR2 ,w STR2 ,y STR2 ,x STR2
- ,x LDR2 ,x_ STR2 ,y LDR2 ,y_ STR2
- @fillrectrow
- ,x LDR2 ,x_ STR2
- @fillrectcol
- ( draw ) ,x_ LDR2 ,y_ LDR2 ,putpixel JSR
- ,x_ LDR2 #0001 ADD2 ,x_ STR2
- ,x_ LDR2 ,w LDR2 ,x LDR2 ADD2 LTH2 ,fillrectcol ROT JMP? POP2
- ,y_ LDR2 #0001 ADD2 ,y_ STR2
- ,y_ LDR2 ,h LDR2 ,y LDR2 ADD2 LTH2 ,fillrectrow ROT JMP? POP2
- RTS
-
-@linerect
- ,h STR2 ,w STR2 ,y STR2 ,x STR2
- ,x LDR2 ,x_ STR2 ,y LDR2 ,y_ STR2
- @linerectcol
- ( draw ) ,x LDR2 ,y_ LDR2 ,putpixel JSR
- ( draw ) ,x LDR2 ,w LDR2 ADD2 ,y_ LDR2 ,putpixel JSR
- ,y_ LDR2 #0001 ADD2 ,y_ STR2
- ,y_ LDR2 ,h LDR2 ,y LDR2 ADD2 LTH2 ,linerectcol ROT JMP? POP2
- @linerectrow
- ( draw ) ,x_ LDR2 ,y LDR2 ,putpixel JSR
- ( draw ) ,x_ LDR2 ,y LDR2 ,h LDR2 ADD2 ,putpixel JSR
- ,x_ LDR2 #0001 ADD2 ,x_ STR2
- ,x_ LDR2 ,w LDR2 ,x LDR2 ADD2 #0001 ADD2 LTH2 ,linerectrow ROT JMP? POP2
- RTS
-
-@diff16
- OVR2 OVR2 GTH2 ,diff16sub ROT JMP? POP2
- SWP2 @diff16sub SUB2
-RTS
-
-@redraw
- #0000 IOW2
- #0000 IOW2
- #00 IOW
- #01 IOW
- RTS
-
-@putpixel
- IOW2 ( y short )
- IOW2 ( x short )
- ,color LDR IOW ( color byte )
- #00 IOW ( redraw byte )
- RTS
-
-|c000 @FRAME BRK
-|d000 @ERROR BRK
-|FFF0 [ f2ac 35bb 2b53 ] ( palette )
-|FFFA .RESET .FRAME .ERROR
diff --git a/examples/shapes.usm b/examples/shapes.usm
@@ -0,0 +1,79 @@
+( draw routines )
+
+:dev/r fff8 ( std read port )
+:dev/w fff9 ( std write port )
+
+;x_ 2 ;y_ 2 ;x 2 ;y 2 ;w 2 ;h 2 ;color 1
+
+|0100 @RESET
+
+ #01 =dev/w ( set dev/write to screen )
+
+ #01 ,color STR
+ ( fill rect x y w h )
+ #0020 #0020 #0060 #0040 ,fillrect JSR
+
+ #02 ,color STR
+ ( fill rect x y w h )
+ #0030 #0030 #0040 #0060 ,fillrect JSR
+
+ #03 ,color STR
+ ( fill rect x y w h )
+ #0040 #0040 #0060 #0040 ,fillrect JSR
+
+ #01 ,color STR
+ ( fill rect x y w h )
+ #00a0 #0010 #0020 #0020 ,fillrect JSR
+
+ #02 ,color STR
+ ( fill rect x y w h )
+ #00b0 #0040 #0020 #0020 ,linerect JSR
+
+ #03 ,color STR
+ ( fill rect x y w h )
+ #0058 #0028 #0050 #0050 ,linerect JSR
+
+ #01 ,color STR
+ ( fill rect x y w h )
+ #0028 #0038 #0050 #0030 ,linerect JSR
+
+BRK
+
+@fillrect
+ =h =w =y =x
+ ~x =x_ ~y =y_
+ @fillrectrow
+ ~x =x_
+ @fillrectcol
+ ( draw ) ~x_ ~y_ ,putpixel JSR
+ ~x_ #0001 ADD2 =x_
+ ~x_ ~w ~x ADD2 LTH2 ,fillrectcol ROT JMP? POP2
+ ~y_ #0001 ADD2 =y_
+ ~y_ ~h ~y ADD2 LTH2 ,fillrectrow ROT JMP? POP2
+ RTS
+
+@linerect
+ =h =w =y =x
+ ~x =x_ ~y =y_
+ @linerectcol
+ ( draw ) ~x ~y_ ,putpixel JSR
+ ( draw ) ~x ~w ADD2 ~y_ ,putpixel JSR
+ ~y_ #0001 ADD2 =y_
+ ~y_ ~h ~y ADD2 LTH2 ,linerectcol ROT JMP? POP2
+ @linerectrow
+ ( draw ) ~x_ ~y ,putpixel JSR
+ ( draw ) ~x_ ~y ~h ADD2 ,putpixel JSR
+ ~x_ #0001 ADD2 =x_
+ ~x_ ~w ~x ADD2 #0001 ADD2 LTH2 ,linerectrow ROT JMP? POP2
+ RTS
+
+@putpixel
+ IOW2 ( y short )
+ IOW2 ( x short )
+ ,color LDR IOW ( color byte )
+ RTS
+
+|c000 @FRAME BRK
+|d000 @ERROR BRK
+|FFF0 [ f2ac 35bb 2b53 ] ( palette )
+|FFFA .RESET .FRAME .ERROR ( vectors )
+\ No newline at end of file