... | ... |
@@ -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 projects/examples/gui.shapes.usm bin/boot.rom |
|
23 |
+./bin/assembler projects/software/noodle.usm bin/boot.rom |
|
24 | 24 |
./bin/emulator bin/boot.rom |
... | ... |
@@ -8,14 +8,8 @@ |
8 | 8 |
;label { x 2 y 2 color 1 addr 2 } |
9 | 9 |
;pict { x 2 y 2 width 2 height 2 color 1 addr 2 } |
10 | 10 |
;rect { x1 2 y1 2 x2 2 y2 2 } |
11 |
+;line { x 2 y 2 sx 2 sy 2 dx 2 dy 2 e1 2 e2 2 } |
|
11 | 12 |
;color { byte 1 } |
12 |
-( clean up ) |
|
13 |
-;a { x 2 y 2 } |
|
14 |
-;b { x 2 y 2 } |
|
15 |
-;s { x 2 y 2 } |
|
16 |
-;d { x 2 y 2 } |
|
17 |
-;err { short 2 } |
|
18 |
-;err2 { short 2 } |
|
19 | 13 |
|
20 | 14 |
|0100 @RESET |
21 | 15 |
|
... | ... |
@@ -43,6 +37,32 @@ |
43 | 37 |
|
44 | 38 |
BRK |
45 | 39 |
|
40 |
+@draw-line ( x1 y1 x2 y2 color ) |
|
41 |
+ |
|
42 |
+ ( load ) =color =Sprite.y =Sprite.x =line.y =line.x |
|
43 |
+ ~Sprite.x ~line.x SUB2 ABS2 =line.dx |
|
44 |
+ ~Sprite.y ~line.y SUB2 ABS2 #0000 SWP2 SUB2 =line.dy |
|
45 |
+ #ffff #00 ~line.x ~Sprite.x LTS2 #0002 MUL2 ADD2 =line.sx |
|
46 |
+ #ffff #00 ~line.y ~Sprite.y LTS2 #0002 MUL2 ADD2 =line.sy |
|
47 |
+ ~line.dx ~line.dy ADD2 =line.e1 |
|
48 |
+ $loop |
|
49 |
+ ~line.x =Screen.x ~line.y =Screen.y ~color =Screen.color |
|
50 |
+ ,$end ~line.x ~Sprite.x EQU2 ~line.y ~Sprite.y EQU2 #0101 EQU2 JMP2? |
|
51 |
+ ~line.e1 #0002 MUL2 =line.e2 |
|
52 |
+ ,$skipy ~line.e2 ~line.dy LTS2 JMP2? |
|
53 |
+ ~line.e1 ~line.dy ADD2 =line.e1 |
|
54 |
+ ~line.x ~line.sx ADD2 =line.x |
|
55 |
+ $skipy |
|
56 |
+ ,$skipx ~line.e2 ~line.dx GTS2 JMP2? |
|
57 |
+ ~line.e1 ~line.dx ADD2 =line.e1 |
|
58 |
+ ~line.y ~line.sy ADD2 =line.y |
|
59 |
+ $skipx |
|
60 |
+ ,$loop JMP2 |
|
61 |
+ |
|
62 |
+ $end |
|
63 |
+ |
|
64 |
+RTN |
|
65 |
+ |
|
46 | 66 |
@line-rect ( x1 y1 x2 y2 color ) |
47 | 67 |
|
48 | 68 |
( load ) =color =rect.y2 =rect.x2 DUP2 =Screen.y =rect.y1 DUP2 =Screen.x =rect.x1 |
... | ... |
@@ -101,38 +121,6 @@ RTN |
101 | 121 |
|
102 | 122 |
RTN |
103 | 123 |
|
104 |
-@draw-line ( x1 y1 x2 y2 ) |
|
105 |
- |
|
106 |
- =color |
|
107 |
- =b.y =b.x =a.y =a.x |
|
108 |
- ~b.x ~a.x SUB2 ABS2 =d.x |
|
109 |
- ~b.y ~a.y SUB2 ABS2 #0000 SWP2 SUB2 =d.y |
|
110 |
- #ffff #00 ~a.x ~b.x LTS2 #0002 MUL2 ADD2 =s.x |
|
111 |
- #ffff #00 ~a.y ~b.y LTS2 #0002 MUL2 ADD2 =s.y |
|
112 |
- ~d.x ~d.y ADD2 =err |
|
113 |
- |
|
114 |
- $loop |
|
115 |
- |
|
116 |
- ~a.x =Screen.x ~a.y =Screen.y ~color =Screen.color |
|
117 |
- ,$end ~a.x ~b.x EQU2 ~a.y ~b.y EQU2 #0101 EQU2 JMP2? |
|
118 |
- ~err #0002 MUL2 =err2 |
|
119 |
- |
|
120 |
- ,$skipy ~err2 ~d.y LTS2 JMP2? |
|
121 |
- ~err ~d.y ADD2 =err |
|
122 |
- ~a.x ~s.x ADD2 =a.x |
|
123 |
- $skipy |
|
124 |
- |
|
125 |
- ,$skipx ~err2 ~d.x GTS2 JMP2? |
|
126 |
- ~err ~d.x ADD2 =err |
|
127 |
- ~a.y ~s.y ADD2 =a.y |
|
128 |
- $skipx |
|
129 |
- |
|
130 |
- ,$loop JMP2 |
|
131 |
- |
|
132 |
- $end |
|
133 |
- |
|
134 |
-RTN |
|
135 |
- |
|
136 | 124 |
@pict_small [ |
137 | 125 |
|
138 | 126 |
ff80 8080 8080 8088 ffff fffc f8f9 f1f4 |
... | ... |
@@ -23,6 +23,7 @@ |
23 | 23 |
|
24 | 24 |
%RTN { JMP2r } |
25 | 25 |
%RTN? { JMP2r? } |
26 |
+%ABS2 { DUP2 #000f SFT2 #ffff SWP2 SWP POP MUL2? } |
|
26 | 27 |
%++ { #0001 ADD2 } %-- { #0001 SUB2 } |
27 | 28 |
%2/ { #0001 SFT2 } |
28 | 29 |
%8/ { #0003 SFT2 } %8* { #0030 SFT2 } |
... | ... |
@@ -35,6 +36,7 @@ |
35 | 36 |
;cursor { x 2 y 2 x0 2 y0 2 size 1 patt 1 drag 1 mirror 1 } |
36 | 37 |
;zoom { active 1 x 2 y 2 } |
37 | 38 |
;rect { x1 2 y1 2 x2 2 y2 2 } |
39 |
+;line { x 2 y 2 sx 2 sy 2 dx 2 dy 2 e1 2 e2 2 } |
|
38 | 40 |
;origin { x1 2 y1 2 x2 2 y2 2 } |
39 | 41 |
;color { byte 1 } |
40 | 42 |
;pt0 { x 2 y 2 } |
... | ... |
@@ -125,6 +127,9 @@ BRK |
125 | 127 |
,$no-touch-canvas ~Mouse.x CLN2r ~canvas.x1 GTH2 STH2r ~canvas.x2 LTH2 #0101 NEQ2 JMP2? |
126 | 128 |
,$no-touch-canvas ~Mouse.y CLN2r ~canvas.y1 GTH2 STH2r ~canvas.y2 LTH2 #0101 NEQ2 JMP2? |
127 | 129 |
|
130 |
+ ~cursor.x0 ~canvas.x1 SUB2 ~cursor.y0 ~canvas.y1 SUB2 ~Mouse.x ~canvas.x1 SUB2 ~Mouse.y ~canvas.y1 SUB2 #01 ,paint-line JSR2 |
|
131 |
+ |
|
132 |
+ |
|
128 | 133 |
~Mouse.x ~canvas.x1 SUB2 ~Mouse.y ~canvas.y1 SUB2 ,paint JSR2 |
129 | 134 |
|
130 | 135 |
,$no-mirror-mode ~cursor.mirror #00 EQU JMP2? |
... | ... |
@@ -556,6 +561,32 @@ RTN |
556 | 561 |
|
557 | 562 |
( Generics ) |
558 | 563 |
|
564 |
+@paint-line ( x1 y1 x2 y2 color ) |
|
565 |
+ |
|
566 |
+ ( load ) =color =Sprite.y =Sprite.x =line.y =line.x |
|
567 |
+ ~Sprite.x ~line.x SUB2 ABS2 =line.dx |
|
568 |
+ ~Sprite.y ~line.y SUB2 ABS2 #0000 SWP2 SUB2 =line.dy |
|
569 |
+ #ffff #00 ~line.x ~Sprite.x LTS2 #0002 MUL2 ADD2 =line.sx |
|
570 |
+ #ffff #00 ~line.y ~Sprite.y LTS2 #0002 MUL2 ADD2 =line.sy |
|
571 |
+ ~line.dx ~line.dy ADD2 =line.e1 |
|
572 |
+ $loop |
|
573 |
+ ( paint ) ~line.x ~line.y ,add-pixel JSR2 |
|
574 |
+ ,$end ~line.x ~Sprite.x EQU2 ~line.y ~Sprite.y EQU2 #0101 EQU2 JMP2? |
|
575 |
+ ~line.e1 #0002 MUL2 =line.e2 |
|
576 |
+ ,$skipy ~line.e2 ~line.dy LTS2 JMP2? |
|
577 |
+ ~line.e1 ~line.dy ADD2 =line.e1 |
|
578 |
+ ~line.x ~line.sx ADD2 =line.x |
|
579 |
+ $skipy |
|
580 |
+ ,$skipx ~line.e2 ~line.dx GTS2 JMP2? |
|
581 |
+ ~line.e1 ~line.dx ADD2 =line.e1 |
|
582 |
+ ~line.y ~line.sy ADD2 =line.y |
|
583 |
+ $skipx |
|
584 |
+ ,$loop JMP2 |
|
585 |
+ |
|
586 |
+ $end |
|
587 |
+ |
|
588 |
+RTN |
|
589 |
+ |
|
559 | 590 |
@line-rect ( x1 y1 x2 y2 color ) |
560 | 591 |
|
561 | 592 |
( load ) =color =rect.y2 =rect.x2 DUP2 =Screen.y =rect.y1 DUP2 =Screen.x =rect.x1 |