... | ... |
@@ -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/paint.usm bin/boot.rom |
|
23 |
+./bin/assembler examples/drag.usm bin/boot.rom |
|
24 | 24 |
./bin/emulator bin/boot.rom |
... | ... |
@@ -3,116 +3,110 @@ |
3 | 3 |
:dev/r fff8 ( std read port ) |
4 | 4 |
:dev/w fff9 ( std write port ) |
5 | 5 |
|
6 |
-;drawx 2 ;drawy 2 ;x 2 ;y 2 ;w 2 ;h 2 ;color 1 |
|
7 |
-;touchx 2 ;touchy 2 ;down 1 |
|
6 |
+;dragx 2 ;dragy 2 |
|
7 |
+;mousex 2 ;mousey 2 |
|
8 |
+;lastx 2 ;lasty 2 |
|
9 |
+;originx 2 ;originy 2 |
|
10 |
+;down 1 ;state 1 |
|
8 | 11 |
|
9 | 12 |
|0100 @RESET |
10 | 13 |
|
11 | 14 |
#05 =dev/r ( set dev/read mouse ) |
12 |
- #01 =dev/w ( set dev/write to screen ) |
|
13 |
- |
|
14 |
- #02 =color ( starting color ) |
|
15 |
- #0050 =w #0080 =h ( starting size ) |
|
16 |
- ,update JSR |
|
15 |
+ #02 =dev/w ( set dev/write to sprite ) |
|
16 |
+ ,draw-picture JSR |
|
17 | 17 |
|
18 | 18 |
BRK |
19 | 19 |
|
20 | 20 |
|c000 @FRAME |
21 |
- |
|
21 |
+ |
|
22 |
+ ( clear last cursor ) |
|
23 |
+ #10 ,clear_icn ~lastx ~lasty ,draw-sprite JSR |
|
24 |
+ ( record mouse values ) |
|
25 |
+ #00 IOR2 =mousex #02 IOR2 =mousey |
|
26 |
+ #04 IOR #11 ADD =state |
|
27 |
+ ( draw mouse ) |
|
28 |
+ ~state ,cursor_icn ~mousex ~mousey ,draw-sprite JSR |
|
29 |
+ ( update last pos ) |
|
30 |
+ ~mousex =lastx ~mousey =lasty |
|
31 |
+ |
|
22 | 32 |
( get touch ) |
23 | 33 |
#05 IOR #01 EQU ,on-touch ROT JMP? POP2 |
24 | 34 |
#05 IOR #10 EQU ,on-release ROT JMP? POP2 |
25 | 35 |
#01 ~down EQU ,on-drag ROT JMP? POP2 |
36 |
+ |
|
26 | 37 |
BRK |
27 | 38 |
|
28 | 39 |
@on-touch |
29 | 40 |
#01 =down |
30 |
- #03 =color |
|
31 |
- #00 IOR2 =touchx #02 IOR2 =touchy |
|
41 |
+ #00 IOR2 =originx #02 IOR2 =originy |
|
32 | 42 |
,update JSR |
33 | 43 |
BRK |
34 | 44 |
|
35 | 45 |
@on-release |
36 | 46 |
#00 =down |
37 |
- #01 =color |
|
38 | 47 |
,update JSR |
39 | 48 |
BRK |
40 | 49 |
|
41 | 50 |
@on-drag |
42 |
- #00 IOR2 ~touchx SUBS2 ~x ADDS2 =x |
|
43 |
- #02 IOR2 ~touchy SUBS2 ~y ADDS2 =y |
|
44 |
- #00 IOR2 =touchx #02 IOR2 =touchy |
|
51 |
+ #00 IOR2 ~originx SUBS2 ~dragx ADDS2 =dragx |
|
52 |
+ #02 IOR2 ~originy SUBS2 ~dragy ADDS2 =dragy |
|
53 |
+ #00 IOR2 =originx #02 IOR2 =originy |
|
45 | 54 |
,update JSR |
46 | 55 |
BRK |
47 | 56 |
|
48 | 57 |
@update |
49 |
- ( draw ) ~x ~y ~w ~h ,linerect JSR |
|
50 |
- ( draw ) #0000 ,rounds_chr ~x #0010 ADD2 ~y #0010 ADD2 ,drawsprite JSR |
|
51 |
- ( draw ) #0100 ,eyeeye_chr ~x #0040 ADD2 ~y #0020 ADD2 ,drawsprite JSR |
|
52 |
- ,redraw JSR |
|
53 |
- BRK |
|
58 |
+ ,draw-picture JSR |
|
54 | 59 |
|
55 | 60 |
BRK |
56 | 61 |
|
57 |
-@putpixel |
|
58 |
- IOW2 ( y short ) |
|
59 |
- IOW2 ( x short ) |
|
60 |
- ,color LDR IOW ( color byte ) |
|
61 |
- #00 IOW ( redraw byte ) |
|
62 |
- RTS |
|
63 |
- |
|
64 |
-@fillrect |
|
65 |
- =h =w =y =x ( store values in variables ) |
|
66 |
- ~x =drawx ~y =drawy ( store draw pos in variables ) |
|
67 |
- @fillrectrow |
|
68 |
- ~x =drawx |
|
69 |
- @fillrectcol |
|
70 |
- ( draw ) ~drawx ~drawy IOW2 IOW2 ~color IOW #00 IOW |
|
71 |
- ~drawx #0001 ADD2 =drawx |
|
72 |
- ~drawx ~w ~x ADD2 LTH2 ,fillrectcol ROT JMP? POP2 |
|
73 |
- ~drawy #0001 ADD2 =drawy |
|
74 |
- ~drawy ~h ~y ADD2 LTH2 ,fillrectrow ROT JMP? POP2 |
|
75 |
- RTS |
|
76 |
- |
|
77 |
-@linerect |
|
78 |
- =h =w =y =x |
|
79 |
- ~x =drawx ~y =drawy |
|
80 |
- @linerectcol |
|
81 |
- ( draw ) ~x ~drawy ,putpixel JSR |
|
82 |
- ( draw ) ~x ~w ADD2 ~drawy ,putpixel JSR |
|
83 |
- ~drawy #0001 ADD2 =drawy |
|
84 |
- ~drawy ~h ~y ADD2 LTH2 ,linerectcol ROT JMP? POP2 |
|
85 |
- @linerectrow |
|
86 |
- ( draw ) ~drawx ~y ,putpixel JSR |
|
87 |
- ( draw ) ~drawx ~y ~h ADD2 ,putpixel JSR |
|
88 |
- ~drawx #0001 ADD2 =drawx |
|
89 |
- ~drawx ~w ~x ADD2 #0001 ADD2 LTH2 ,linerectrow ROT JMP? POP2 |
|
62 |
+@draw-picture |
|
63 |
+ #01 ,graphic #0040 ~dragx ADD2 #0040 ~dragy ADD2 ,draw-sprite JSR |
|
64 |
+ #01 ,graphic #0008 ADD2 #0048 ~dragx ADD2 #0040 ~dragy ADD2 ,draw-sprite JSR |
|
65 |
+ #01 ,graphic #0010 ADD2 #0050 ~dragx ADD2 #0040 ~dragy ADD2 ,draw-sprite JSR |
|
66 |
+ #01 ,graphic #0018 ADD2 #0058 ~dragx ADD2 #0040 ~dragy ADD2 ,draw-sprite JSR |
|
67 |
+ #01 ,graphic #0020 ADD2 #0040 ~dragx ADD2 #0048 ~dragy ADD2 ,draw-sprite JSR |
|
68 |
+ #01 ,graphic #0028 ADD2 #0048 ~dragx ADD2 #0048 ~dragy ADD2 ,draw-sprite JSR |
|
69 |
+ #01 ,graphic #0030 ADD2 #0050 ~dragx ADD2 #0048 ~dragy ADD2 ,draw-sprite JSR |
|
70 |
+ #01 ,graphic #0038 ADD2 #0058 ~dragx ADD2 #0048 ~dragy ADD2 ,draw-sprite JSR |
|
71 |
+ #01 ,graphic #0040 ADD2 #0040 ~dragx ADD2 #0050 ~dragy ADD2 ,draw-sprite JSR |
|
72 |
+ #01 ,graphic #0048 ADD2 #0048 ~dragx ADD2 #0050 ~dragy ADD2 ,draw-sprite JSR |
|
73 |
+ #01 ,graphic #0050 ADD2 #0050 ~dragx ADD2 #0050 ~dragy ADD2 ,draw-sprite JSR |
|
74 |
+ #01 ,graphic #0058 ADD2 #0058 ~dragx ADD2 #0050 ~dragy ADD2 ,draw-sprite JSR |
|
75 |
+ #01 ,graphic #0060 ADD2 #0040 ~dragx ADD2 #0058 ~dragy ADD2 ,draw-sprite JSR |
|
76 |
+ #01 ,graphic #0068 ADD2 #0048 ~dragx ADD2 #0058 ~dragy ADD2 ,draw-sprite JSR |
|
77 |
+ #01 ,graphic #0070 ADD2 #0050 ~dragx ADD2 #0058 ~dragy ADD2 ,draw-sprite JSR |
|
78 |
+ #01 ,graphic #0078 ADD2 #0058 ~dragx ADD2 #0058 ~dragy ADD2 ,draw-sprite JSR |
|
90 | 79 |
RTS |
91 | 80 |
|
92 |
-@getmouse |
|
93 |
- #00 IOR2 ( get mouse x ) |
|
94 |
- #02 IOR2 ( get mouse y ) |
|
95 |
- RTS |
|
96 |
- |
|
97 |
-@drawsprite |
|
98 |
- #02 =dev/w ( set dev/write to sprite ) |
|
99 |
- IOW2 ( y short ) |
|
100 |
- IOW2 ( x short ) |
|
81 |
+@draw-sprite |
|
82 |
+ IOW2 ( y byte ) |
|
83 |
+ IOW2 ( x byte ) |
|
101 | 84 |
IOW2 ( sprite address ) |
102 |
- IOW2 ( redraw byte ) |
|
103 |
- RTS |
|
104 |
- |
|
105 |
-@redraw |
|
106 |
- #01 =dev/w ( set dev/write to sprite ) |
|
107 |
- #0000 IOW2 |
|
108 |
- #0000 IOW2 |
|
109 |
- #00 IOW |
|
110 |
- #01 IOW |
|
85 |
+ IOW ( layer-color ) |
|
111 | 86 |
RTS |
112 | 87 |
|
113 |
-@rounds_chr [ 3844 92aa 9244 3800 0038 7c7c 7c38 0000 ] |
|
114 |
-@eyeeye_chr [ aa55 aa55 aa55 aa55 aa55 aa55 aa55 aa55 ] |
|
88 |
+@clear_icn [ 0000 0000 0000 0000 ] |
|
89 |
+@cursor_icn [ 80c0 e0f0 f8e0 1000 ] |
|
90 |
+ |
|
91 |
+@graphic [ |
|
92 |
+ ff80 8080 8080 8088 |
|
93 |
+ ffff fffc f8f9 f1f4 |
|
94 |
+ ffff 0010 c721 2120 |
|
95 |
+ ffff 3f0f 0717 c343 |
|
96 |
+ 8888 8080 8080 8080 |
|
97 |
+ f0f1 f2f5 f2f1 f0f4 |
|
98 |
+ 1208 804c 9212 4c00 |
|
99 |
+ 7303 0343 1b1b fbfb |
|
100 |
+ 8080 8f83 8383 8393 |
|
101 |
+ f0f3 f1f0 e4c0 80ff |
|
102 |
+ 00c7 c7c6 4606 00ff |
|
103 |
+ c3d3 c307 870f 3fff |
|
104 |
+ 8f83 8383 8383 83ff |
|
105 |
+ fff7 fdff c0e2 f1ff |
|
106 |
+ 7fef bfff 07af 5fff |
|
107 |
+ ffff ffff ffff ffff |
|
108 |
+] |
|
115 | 109 |
|
116 | 110 |
|d000 @ERROR BRK |
117 |
-|FFF0 [ f2ac 35bb 2b53 ] ( palette ) |
|
118 |
-|FFFA .RESET .FRAME .ERROR |
|
111 |
+|FFF0 [ f0ac f0bb f053 ] ( palette ) |
|
112 |
+|FFFA .RESET .FRAME .ERROR ( vectors ) |