... | ... |
@@ -24,5 +24,5 @@ rm -f ./bin/emulator |
24 | 24 |
cc -std=c89 -DDEBUG -Wall -Wno-unknown-pragmas -Wpedantic -Wshadow -Wextra -Werror=implicit-int -Werror=incompatible-pointer-types -Werror=int-conversion -Wvla -g -Og -fsanitize=address -fsanitize=undefined uxn.c emulator.c -L/usr/local/lib -lSDL2 -o bin/emulator |
25 | 25 |
|
26 | 26 |
# run |
27 |
-./bin/assembler examples/pixels.usm bin/boot.rom |
|
27 |
+./bin/assembler examples/draw.usm bin/boot.rom |
|
28 | 28 |
./bin/emulator bin/boot.rom |
29 | 29 |
new file mode 100644 |
... | ... |
@@ -0,0 +1,79 @@ |
1 |
+( draw routines ) |
|
2 |
+ |
|
3 |
+:dev/r fff8 ( std read port ) |
|
4 |
+:dev/w fff9 ( std write port ) |
|
5 |
+ |
|
6 |
+;x_ 2 ;y_ 2 |
|
7 |
+ |
|
8 |
+;x 2 ;y 2 ;w 2 ;h 2 |
|
9 |
+;color 1 |
|
10 |
+ |
|
11 |
+|0100 @RESET |
|
12 |
+ |
|
13 |
+ ( set dev/write to screen ) |
|
14 |
+ ,01 ,dev/w STR |
|
15 |
+ |
|
16 |
+ ( set color 1 ) |
|
17 |
+ ,03 ,color STR |
|
18 |
+ |
|
19 |
+ ,01 ,color STR |
|
20 |
+ ( fill rect x y w h ) |
|
21 |
+ ,0020 ,0020 ,0060 ,0040 ,fillrect JSR |
|
22 |
+ |
|
23 |
+ ,02 ,color STR |
|
24 |
+ ( fill rect x y w h ) |
|
25 |
+ ,0030 ,0030 ,0040 ,0060 ,fillrect JSR |
|
26 |
+ |
|
27 |
+ ,03 ,color STR |
|
28 |
+ ( fill rect x y w h ) |
|
29 |
+ ,0040 ,0040 ,0060 ,0040 ,fillrect JSR |
|
30 |
+ |
|
31 |
+ ,redraw JSR |
|
32 |
+ |
|
33 |
+BRK |
|
34 |
+ |
|
35 |
+@redraw |
|
36 |
+ ,0000 IOW^ |
|
37 |
+ ,0000 IOW^ |
|
38 |
+ ,00 IOW |
|
39 |
+ ,01 IOW |
|
40 |
+ RTS |
|
41 |
+ |
|
42 |
+@putpixel |
|
43 |
+ IOW^ ( y short ) |
|
44 |
+ IOW^ ( x short ) |
|
45 |
+ ,color LDR IOW ( color byte ) |
|
46 |
+ ,00 IOW ( redraw byte ) |
|
47 |
+ RTS |
|
48 |
+ |
|
49 |
+@fillrect |
|
50 |
+ ( store shape ) |
|
51 |
+ ,h STR^ ,w STR^ ,y STR^ ,x STR^ |
|
52 |
+ ( set head ) |
|
53 |
+ ,x LDR^ ,x_ STR^ ,y LDR^ ,y_ STR^ |
|
54 |
+ ( paint row ) |
|
55 |
+ ,fillrectrow JSR |
|
56 |
+ RTS |
|
57 |
+ |
|
58 |
+@fillrectcol |
|
59 |
+ ,x_ LDR^ ,y_ LDR^ ,putpixel JSR |
|
60 |
+ ( incr x ) |
|
61 |
+ ,x_ LDR^ ,0001 ADD^ ,x_ STR^ |
|
62 |
+ ( check if greater than w ) |
|
63 |
+ ,x_ LDR^ ,w LDR^ ,x LDR^ ADD^ GTH^ RTS? |
|
64 |
+ ,fillrectcol JMP |
|
65 |
+ RTS |
|
66 |
+ |
|
67 |
+@fillrectrow |
|
68 |
+ ,x LDR^ ,x_ STR^ |
|
69 |
+ ,fillrectcol JSR |
|
70 |
+ ( incr x ) |
|
71 |
+ ,y_ LDR^ ,0001 ADD^ ,y_ STR^ |
|
72 |
+ ( check if greater than w ) |
|
73 |
+ ,y_ LDR^ ,h LDR^ ,y LDR^ ADD^ GTH^ RTS? |
|
74 |
+ ,fillrectrow JMP |
|
75 |
+ RTS |
|
76 |
+ |
|
77 |
+|c000 @FRAME BRK |
|
78 |
+|d000 @ERROR BRK |
|
79 |
+|FFFA .RESET .FRAME .ERROR |