| ... | ... |
@@ -20,5 +20,5 @@ cc -std=c89 -DDEBUG -Wall -Wno-unknown-pragmas -Wpedantic -Wshadow -Wextra -Werr |
| 20 | 20 |
# cc uxn.c emulator.c -std=c89 -Os -DNDEBUG -g0 -s -Wall -Wno-unknown-pragmas -L/usr/local/lib -lSDL2 -o bin/emulator |
| 21 | 21 |
|
| 22 | 22 |
# run |
| 23 |
-./bin/assembler examples/shapes.usm bin/boot.rom |
|
| 23 |
+./bin/assembler examples/paint.usm bin/boot.rom |
|
| 24 | 24 |
./bin/emulator bin/boot.rom |
| ... | ... |
@@ -3,77 +3,73 @@ |
| 3 | 3 |
:dev/r fff8 ( std read port ) |
| 4 | 4 |
:dev/w fff9 ( std write port ) |
| 5 | 5 |
|
| 6 |
-;x_ 2 ;y_ 2 ;x 2 ;y 2 ;w 2 ;h 2 ;color 1 |
|
| 6 |
+;color 1 ;x1 2 ;x2 2 ;y1 2 ;y2 2 |
|
| 7 | 7 |
|
| 8 | 8 |
|0100 @RESET |
| 9 | 9 |
|
| 10 | 10 |
#01 =dev/w ( set dev/write to screen ) |
| 11 | 11 |
|
| 12 |
- #01 ,color STR |
|
| 13 |
- ( fill rect x y w h ) |
|
| 14 |
- #0020 #0020 #0060 #0040 ,fillrect JSR |
|
| 15 |
- |
|
| 16 |
- #02 ,color STR |
|
| 17 |
- ( fill rect x y w h ) |
|
| 18 |
- #0030 #0030 #0040 #0060 ,fillrect JSR |
|
| 19 |
- |
|
| 20 |
- #03 ,color STR |
|
| 21 |
- ( fill rect x y w h ) |
|
| 22 |
- #0040 #0040 #0060 #0040 ,fillrect JSR |
|
| 23 |
- |
|
| 24 |
- #01 ,color STR |
|
| 25 |
- ( fill rect x y w h ) |
|
| 26 |
- #00a0 #0010 #0020 #0020 ,fillrect JSR |
|
| 27 |
- |
|
| 28 |
- #02 ,color STR |
|
| 29 |
- ( fill rect x y w h ) |
|
| 30 |
- #00b0 #0040 #0020 #0020 ,linerect JSR |
|
| 31 |
- |
|
| 32 |
- #03 ,color STR |
|
| 33 |
- ( fill rect x y w h ) |
|
| 34 |
- #0058 #0028 #0050 #0050 ,linerect JSR |
|
| 35 |
- |
|
| 36 |
- #01 ,color STR |
|
| 37 |
- ( fill rect x y w h ) |
|
| 38 |
- #0028 #0038 #0050 #0030 ,linerect JSR |
|
| 39 |
- |
|
| 12 |
+ #01 =color |
|
| 13 |
+ #0020 #0020 #0060 #0060 ,fill-rect JSR |
|
| 14 |
+ #02 =color |
|
| 15 |
+ #0030 #0030 #0070 #0070 ,fill-rect JSR |
|
| 16 |
+ #03 =color |
|
| 17 |
+ #0040 #0040 #0080 #0080 ,fill-rect JSR |
|
| 18 |
+ |
|
| 19 |
+ #01 =color |
|
| 20 |
+ #0090 #0020 #00d0 #0060 ,line-rect JSR |
|
| 21 |
+ #02 =color |
|
| 22 |
+ #00a0 #0030 #00e0 #0070 ,line-rect JSR |
|
| 23 |
+ #03 =color |
|
| 24 |
+ #00b0 #0040 #00f0 #0080 ,line-rect JSR |
|
| 25 |
+ |
|
| 40 | 26 |
BRK |
| 41 | 27 |
|
| 42 |
-@fillrect |
|
| 43 |
- =h =w =y =x |
|
| 44 |
- ~x =x_ ~y =y_ |
|
| 45 |
- @fillrectrow |
|
| 46 |
- ~x =x_ |
|
| 47 |
- @fillrectcol |
|
| 48 |
- ( draw ) ~x_ ~y_ ,putpixel JSR |
|
| 49 |
- ~x_ #0001 ADD2 =x_ |
|
| 50 |
- ~x_ ~w ~x ADD2 LTH2 ,fillrectcol ROT JMP? POP2 |
|
| 51 |
- ~y_ #0001 ADD2 =y_ |
|
| 52 |
- ~y_ ~h ~y ADD2 LTH2 ,fillrectrow ROT JMP? POP2 |
|
| 53 |
- RTS |
|
| 54 |
- |
|
| 55 |
-@linerect |
|
| 56 |
- =h =w =y =x |
|
| 57 |
- ~x =x_ ~y =y_ |
|
| 58 |
- @linerectcol |
|
| 59 |
- ( draw ) ~x ~y_ ,putpixel JSR |
|
| 60 |
- ( draw ) ~x ~w ADD2 ~y_ ,putpixel JSR |
|
| 61 |
- ~y_ #0001 ADD2 =y_ |
|
| 62 |
- ~y_ ~h ~y ADD2 LTH2 ,linerectcol ROT JMP? POP2 |
|
| 63 |
- @linerectrow |
|
| 64 |
- ( draw ) ~x_ ~y ,putpixel JSR |
|
| 65 |
- ( draw ) ~x_ ~y ~h ADD2 ,putpixel JSR |
|
| 66 |
- ~x_ #0001 ADD2 =x_ |
|
| 67 |
- ~x_ ~w ~x ADD2 #0001 ADD2 LTH2 ,linerectrow ROT JMP? POP2 |
|
| 68 |
- RTS |
|
| 69 |
- |
|
| 70 |
-@putpixel |
|
| 71 |
- IOW2 ( y short ) |
|
| 72 |
- IOW2 ( x short ) |
|
| 73 |
- ,color LDR IOW ( color byte ) |
|
| 74 |
- RTS |
|
| 28 |
+@line-ver ( x1 y1 y2 ) |
|
| 29 |
+ =y2 =y1 =x1 |
|
| 30 |
+ @line-ver-loop |
|
| 31 |
+ ( draw ) ~x1 ~y1 IOW2 IOW2 ~color IOW |
|
| 32 |
+ ( incr ) ~y1 #0001 ADD2 DUP2 =y1 |
|
| 33 |
+ ~y2 NEQ2 ,line-ver-loop ROT JMP? POP2 |
|
| 34 |
+RTS |
|
| 35 |
+ |
|
| 36 |
+@line-hor ( x1 y1 x2 ) |
|
| 37 |
+ =x2 =y1 =x1 |
|
| 38 |
+ @line-hor-loop |
|
| 39 |
+ ( draw ) ~x1 ~y1 IOW2 IOW2 ~color IOW |
|
| 40 |
+ ( incr ) ~x1 #0001 ADD2 DUP2 =x1 |
|
| 41 |
+ ~x2 NEQ2 ,line-hor-loop ROT JMP? POP2 |
|
| 42 |
+RTS |
|
| 43 |
+ |
|
| 44 |
+@line-rect ( x1 y1 x2 y2 ) |
|
| 45 |
+ =y2 =x2 ( stash x1 y1 ) DUP2 WSR2 =y1 DUP2 WSR2 =x1 |
|
| 46 |
+ @line-rect-hor |
|
| 47 |
+ ( draw ) ~x1 ~y1 IOW2 IOW2 ~color IOW |
|
| 48 |
+ ( draw ) ~x1 ~y2 IOW2 IOW2 ~color IOW |
|
| 49 |
+ ( incr ) ~x1 #0001 ADD2 DUP2 =x1 |
|
| 50 |
+ ~x2 #0001 ADD2 LTH2 ,line-rect-hor ROT JMP? POP2 |
|
| 51 |
+ ( restore x1 y1 ) RSW2 =x1 RSW2 =y1 |
|
| 52 |
+ @line-rect-ver |
|
| 53 |
+ ( incr ) ~y1 #0001 ADD2 DUP2 =y1 |
|
| 54 |
+ ( draw ) ~x1 ~y1 IOW2 IOW2 ~color IOW |
|
| 55 |
+ ( draw ) ~x2 ~y1 IOW2 IOW2 ~color IOW |
|
| 56 |
+ ~y2 #0001 SUB2 LTH2 ,line-rect-ver ROT JMP? POP2 |
|
| 57 |
+RTS |
|
| 58 |
+ |
|
| 59 |
+@fill-rect ( x1 y1 x2 y2 ) |
|
| 60 |
+ =y2 =x2 ( stash x1 y1 ) =y1 DUP2 WSR2 =x1 |
|
| 61 |
+ @fill-rect-ver |
|
| 62 |
+ RSW2 DUP2 =x1 WSR2 |
|
| 63 |
+ @fill-rect-hor |
|
| 64 |
+ ( draw ) ~x1 ~y1 IOW2 IOW2 ~color IOW |
|
| 65 |
+ ( incr ) ~x1 #0001 ADD2 DUP2 =x1 |
|
| 66 |
+ ~x2 LTH2 ,fill-rect-hor ROT JMP? POP2 |
|
| 67 |
+ ~y1 #0001 ADD2 DUP2 =y1 |
|
| 68 |
+ ~y2 LTH2 ,fill-rect-ver ROT JMP? POP2 |
|
| 69 |
+ RSW2 POP2 |
|
| 70 |
+RTS |
|
| 75 | 71 |
|
| 76 | 72 |
|c000 @FRAME BRK |
| 77 | 73 |
|d000 @ERROR BRK |
| 78 |
-|FFF0 [ f2ac 35bb 2b53 ] ( palette ) |
|
| 74 |
+|FFF0 [ f2ac 35bb 2b5f ] ( palette ) |
|
| 79 | 75 |
|FFFA .RESET .FRAME .ERROR ( vectors ) |
| 80 | 76 |
\ No newline at end of file |