... | ... |
@@ -18,7 +18,7 @@ typedef signed short Sint16; |
18 | 18 |
|
19 | 19 |
typedef struct { |
20 | 20 |
char name[64], items[16][64]; |
21 |
- Uint8 len; |
|
21 |
+ Uint8 len, refs; |
|
22 | 22 |
} Macro; |
23 | 23 |
|
24 | 24 |
typedef struct { |
... | ... |
@@ -45,10 +45,10 @@ Program p; |
45 | 45 |
/* clang-format off */ |
46 | 46 |
|
47 | 47 |
char ops[][4] = { |
48 |
- "BRK", "NOP", "LIT", "LDR", "STR", "JMP", "JSR", "RTS", |
|
48 |
+ "BRK", "NOP", "LIT", "LDR", "STR", "JMP", "JSR", "RTN", |
|
49 | 49 |
"EQU", "NEQ", "GTH", "LTH", "AND", "XOR", "ROL", "ROR", |
50 | 50 |
"POP", "DUP", "SWP", "OVR", "ROT", "---", "WSR", "RSW", |
51 |
- "ADD", "SUB", "MUL", "DIV", "---", "---", "---", "PRG" |
|
51 |
+ "ADD", "SUB", "MUL", "DIV", "---", "---", "---", "---" |
|
52 | 52 |
}; |
53 | 53 |
|
54 | 54 |
int scin(char *s, char c) { int i = 0; while(s[i]) if(s[i++] == c) return i - 1; return -1; } /* string char index */ |
... | ... |
@@ -434,10 +434,13 @@ void |
434 | 434 |
cleanup(char *filename) |
435 | 435 |
{ |
436 | 436 |
int i; |
437 |
- printf("Assembled %s, %d labels.\n\n", filename, p.llen); |
|
437 |
+ printf("Assembled %s, %d labels, %d macros.\n\n", filename, p.llen, p.mlen); |
|
438 | 438 |
for(i = 0; i < p.llen; ++i) |
439 | 439 |
if(!p.labels[i].refs) |
440 | 440 |
printf("--- Unused label: %s\n", p.labels[i].name); |
441 |
+ for(i = 0; i < p.mlen; ++i) |
|
442 |
+ if(!p.macros[i].refs) |
|
443 |
+ printf("--- Unused macro: %s\n", p.macros[i].name); |
|
441 | 444 |
} |
442 | 445 |
|
443 | 446 |
int |
... | ... |
@@ -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/software/nasu.usm bin/boot.rom |
|
23 |
+./bin/assembler projects/software/left.usm bin/boot.rom |
|
24 | 24 |
./bin/emulator bin/boot.rom |
... | ... |
@@ -31,14 +31,14 @@ BRK |
31 | 31 |
~textarea.x1 #0001 SUB2 ~textarea.y1 #0001 SUB2 ~textarea.x2 ~textarea.y2 #00 ,line-rect JSR2 |
32 | 32 |
~textarea.x1 #0002 SUB2 ~textarea.y1 #0002 SUB2 ~textarea.x2 #0001 ADD2 ~textarea.y2 #0001 ADD2 #01 ,line-rect JSR2 |
33 | 33 |
|
34 |
-RTS |
|
34 |
+RTN |
|
35 | 35 |
|
36 | 36 |
@redraw |
37 | 37 |
|
38 | 38 |
~textarea.x1 ~textarea.y1 ~textarea.x2 ~textarea.y2 #01 ,fill-rect JSR2 |
39 | 39 |
~textarea.x1 ~textarea.y1 #04 ~textarea.addr ,draw-textarea JSR2 |
40 | 40 |
|
41 |
-RTS |
|
41 |
+RTN |
|
42 | 42 |
|
43 | 43 |
@blink-cursor |
44 | 44 |
|
... | ... |
@@ -50,7 +50,7 @@ RTS |
50 | 50 |
@skip |
51 | 51 |
~timer #01 ADD =timer |
52 | 52 |
|
53 |
-RTS |
|
53 |
+RTN |
|
54 | 54 |
|
55 | 55 |
@tile-rect ( x1 y1 x2 y2 color addr ) |
56 | 56 |
|
... | ... |
@@ -65,7 +65,7 @@ RTS |
65 | 65 |
( incr ) ~Sprite.y #0008 ADD2 =Sprite.y |
66 | 66 |
,$ver ~Sprite.y ~rect.y2 LTH2 JMP2? POP2 |
67 | 67 |
|
68 |
-RTS |
|
68 |
+RTN |
|
69 | 69 |
|
70 | 70 |
@fill-rect ( x1 y1 x2 y2 color ) |
71 | 71 |
|
... | ... |
@@ -79,7 +79,7 @@ RTS |
79 | 79 |
( incr ) ~Screen.y #0001 ADD2 =Screen.y |
80 | 80 |
,$ver ~Screen.y ~rect.y2 LTH2 JMP2? POP2 |
81 | 81 |
|
82 |
-RTS |
|
82 |
+RTN |
|
83 | 83 |
|
84 | 84 |
@line-rect ( x1 y1 x2 y2 color ) |
85 | 85 |
|
... | ... |
@@ -96,7 +96,7 @@ RTS |
96 | 96 |
( incr ) ~Screen.y #0001 ADD2 =Screen.y |
97 | 97 |
,$ver ~Screen.y ~rect.y2 #0001 ADD2 LTH2 JMP2? POP2 |
98 | 98 |
|
99 |
-RTS |
|
99 |
+RTN |
|
100 | 100 |
|
101 | 101 |
@draw-textarea ( x y color addr ) |
102 | 102 |
|
... | ... |
@@ -115,7 +115,7 @@ RTS |
115 | 115 |
DUP2 LDR #00 NEQ ,$loop ROT JMP2? POP2 |
116 | 116 |
POP2 |
117 | 117 |
|
118 |
-RTS |
|
118 |
+RTN |
|
119 | 119 |
|
120 | 120 |
@do-textarea |
121 | 121 |
|
... | ... |
@@ -138,7 +138,7 @@ RTS |
138 | 138 |
#06 =Sprite.color |
139 | 139 |
@do-textarea-end |
140 | 140 |
|
141 |
-RTS |
|
141 |
+RTN |
|
142 | 142 |
|
143 | 143 |
@do-cursor |
144 | 144 |
|
... | ... |
@@ -151,7 +151,7 @@ RTS |
151 | 151 |
~mouse.x ~Mouse.x NEQU2 |
152 | 152 |
~mouse.y ~Mouse.y NEQU2 |
153 | 153 |
|
154 |
- #0000 EQU2 RTS? ( Return if unchanged ) |
|
154 |
+ #0000 EQU2 RTN? ( Return if unchanged ) |
|
155 | 155 |
|
156 | 156 |
( clear last cursor ) |
157 | 157 |
#10 ,clear_icn ~mouse.x ~mouse.y ,draw-sprite JSR2 |
... | ... |
@@ -160,7 +160,7 @@ RTS |
160 | 160 |
#12 ,cursor_icn ~mouse.x ~mouse.y ,draw-sprite JSR2 |
161 | 161 |
|
162 | 162 |
|
163 |
-RTS |
|
163 |
+RTN |
|
164 | 164 |
|
165 | 165 |
@draw-sprite |
166 | 166 |
|
... | ... |
@@ -169,7 +169,7 @@ RTS |
169 | 169 |
=Sprite.addr |
170 | 170 |
=Sprite.color |
171 | 171 |
|
172 |
-RTS |
|
172 |
+RTN |
|
173 | 173 |
|
174 | 174 |
@font ( spectrum-zx font ) |
175 | 175 |
[ |
... | ... |
@@ -72,7 +72,7 @@ BRK |
72 | 72 |
~pointer.y =Sprite.y |
73 | 73 |
#11 =Sprite.color |
74 | 74 |
|
75 |
-RTS |
|
75 |
+RTN |
|
76 | 76 |
|
77 | 77 |
@draw-polycat |
78 | 78 |
|
... | ... |
@@ -86,7 +86,7 @@ RTS |
86 | 86 |
,polycat #00a0 ADD2 ~cat.x ~cat.y #0010 ADD2 ,draw-sprite-chr JSR2 |
87 | 87 |
,polycat #00b0 ADD2 ~cat.x #0008 ADD2 ~cat.y #0010 ADD2 ,draw-sprite-chr JSR2 |
88 | 88 |
|
89 |
-RTS |
|
89 |
+RTN |
|
90 | 90 |
|
91 | 91 |
@animate-polycat |
92 | 92 |
|
... | ... |
@@ -105,22 +105,22 @@ RTS |
105 | 105 |
~pointer.y ~cat.y #0008 ADD2 GTH2 ,animate-polycat-left-down ROT JMP2? POP2 |
106 | 106 |
,polycat #0040 ADD2 ~cat.x ~cat.y #0008 ADD2 ,draw-sprite-chr JSR2 |
107 | 107 |
,polycat #0050 ADD2 ~cat.x #0008 ADD2 ~cat.y #0008 ADD2 ,draw-sprite-chr JSR2 |
108 |
- RTS |
|
108 |
+ RTN |
|
109 | 109 |
@animate-polycat-left-down |
110 | 110 |
,polycat #0020 ADD2 ~cat.x ~cat.y #0008 ADD2 ,draw-sprite-chr JSR2 |
111 | 111 |
,polycat #0030 ADD2 ~cat.x #0008 ADD2 ~cat.y #0008 ADD2 ,draw-sprite-chr JSR2 |
112 |
- RTS |
|
112 |
+ RTN |
|
113 | 113 |
@animate-polycat-right |
114 | 114 |
~pointer.y ~cat.y #0008 ADD2 GTH2 ,animate-polycat-right-down ROT JMP2? POP2 |
115 | 115 |
,polycat #0060 ADD2 ~cat.x ~cat.y #0008 ADD2 ,draw-sprite-chr JSR2 |
116 | 116 |
,polycat #0070 ADD2 ~cat.x #0008 ADD2 ~cat.y #0008 ADD2 ,draw-sprite-chr JSR2 |
117 |
- RTS |
|
117 |
+ RTN |
|
118 | 118 |
@animate-polycat-right-down |
119 | 119 |
,polycat #0080 ADD2 ~cat.x ~cat.y #0008 ADD2 ,draw-sprite-chr JSR2 |
120 | 120 |
,polycat #0090 ADD2 ~cat.x #0008 ADD2 ~cat.y #0008 ADD2 ,draw-sprite-chr JSR2 |
121 |
- RTS |
|
121 |
+ RTN |
|
122 | 122 |
|
123 |
-RTS |
|
123 |
+RTN |
|
124 | 124 |
|
125 | 125 |
@draw-label ( x y color addr ) |
126 | 126 |
|
... | ... |
@@ -133,7 +133,7 @@ RTS |
133 | 133 |
DUP2 #0001 ADD2 LDR #00 NEQ ,$loop ROT JMP2? POP2 |
134 | 134 |
POP2 |
135 | 135 |
|
136 |
-RTS |
|
136 |
+RTN |
|
137 | 137 |
|
138 | 138 |
@draw-sprite |
139 | 139 |
|
... | ... |
@@ -142,7 +142,7 @@ RTS |
142 | 142 |
=Sprite.addr |
143 | 143 |
=Sprite.color |
144 | 144 |
|
145 |
-RTS |
|
145 |
+RTN |
|
146 | 146 |
|
147 | 147 |
@draw-sprite-chr |
148 | 148 |
|
... | ... |
@@ -151,7 +151,7 @@ RTS |
151 | 151 |
=Sprite.addr |
152 | 152 |
#20 =Sprite.color |
153 | 153 |
|
154 |
-RTS |
|
154 |
+RTN |
|
155 | 155 |
|
156 | 156 |
@clear_icn [ 0000 0000 0000 0000 ] |
157 | 157 |
@cursor_icn [ 80c0 e0f0 f8e0 1000 ] |
... | ... |
@@ -68,7 +68,7 @@ BRK |
68 | 68 |
~pointer.y =Sprite.y |
69 | 69 |
#11 =Sprite.color |
70 | 70 |
|
71 |
-RTS |
|
71 |
+RTN |
|
72 | 72 |
|
73 | 73 |
@line-rect ( x1 y1 x2 y2 color ) |
74 | 74 |
|
... | ... |
@@ -85,7 +85,7 @@ RTS |
85 | 85 |
( incr ) ~Screen.y #0001 ADD2 =Screen.y |
86 | 86 |
,$ver ~Screen.y ~rect.y2 #0001 ADD2 LTH2 JMP2? POP2 |
87 | 87 |
|
88 |
-RTS |
|
88 |
+RTN |
|
89 | 89 |
|
90 | 90 |
@clear_icn [ 0000 0000 0000 0000 ] |
91 | 91 |
@pointer_icn [ 80c0 e0f0 f8e0 1000 ] |
... | ... |
@@ -37,7 +37,7 @@ BRK |
37 | 37 |
DUP2 LDR #00 NEQ ,$loop ROT JMP2? POP2 |
38 | 38 |
POP2 |
39 | 39 |
|
40 |
-RTS |
|
40 |
+RTN |
|
41 | 41 |
|
42 | 42 |
@draw-label-middle ( x y color addr ) |
43 | 43 |
|
... | ... |
@@ -51,7 +51,7 @@ RTS |
51 | 51 |
DUP2 LDR #00 NEQ ,$loop ROT JMP2? POP2 |
52 | 52 |
POP2 |
53 | 53 |
|
54 |
-RTS |
|
54 |
+RTN |
|
55 | 55 |
|
56 | 56 |
@draw-label-right ( x y color addr ) |
57 | 57 |
|
... | ... |
@@ -65,7 +65,7 @@ RTS |
65 | 65 |
DUP2 LDR #00 NEQ ,$loop ROT JMP2? POP2 |
66 | 66 |
POP2 |
67 | 67 |
|
68 |
-RTS |
|
68 |
+RTN |
|
69 | 69 |
|
70 | 70 |
@get-text-length ( label ) |
71 | 71 |
|
... | ... |
@@ -75,7 +75,7 @@ RTS |
75 | 75 |
LDR #00 NEQ ,$loop ROT JMP2? POP2 |
76 | 76 |
SWP2 POP2 |
77 | 77 |
|
78 |
-RTS |
|
78 |
+RTN |
|
79 | 79 |
|
80 | 80 |
@font ( spectrum-zx font ) |
81 | 81 |
[ |
... | ... |
@@ -41,7 +41,7 @@ BRK |
41 | 41 |
( incr ) ~Screen.y #0001 ADD2 =Screen.y |
42 | 42 |
,$ver ~Screen.y ~rect.y2 #0001 ADD2 LTH2 JMP2? POP2 |
43 | 43 |
|
44 |
-RTS |
|
44 |
+RTN |
|
45 | 45 |
|
46 | 46 |
@fill-rect ( x1 y1 x2 y2 color ) |
47 | 47 |
|
... | ... |
@@ -55,7 +55,7 @@ RTS |
55 | 55 |
( incr ) ~Screen.y #0001 ADD2 =Screen.y |
56 | 56 |
,$ver ~Screen.y ~rect.y2 LTH2 JMP2? POP2 |
57 | 57 |
|
58 |
-RTS |
|
58 |
+RTN |
|
59 | 59 |
|
60 | 60 |
@draw-picture ( x y width height color addr ) |
61 | 61 |
|
... | ... |
@@ -70,7 +70,7 @@ RTS |
70 | 70 |
( incr ) ~Sprite.y #0008 ADD2 =Sprite.y |
71 | 71 |
,$ver ~Sprite.y ~pict.height ~pict.y ADD2 LTH2 JMP2? POP2 |
72 | 72 |
|
73 |
-RTS |
|
73 |
+RTN |
|
74 | 74 |
|
75 | 75 |
@draw-label ( x y color addr ) |
76 | 76 |
|
... | ... |
@@ -82,7 +82,7 @@ RTS |
82 | 82 |
DUP2 LDR #00 NEQ ,$loop ROT JMP2? POP2 |
83 | 83 |
POP2 |
84 | 84 |
|
85 |
-RTS |
|
85 |
+RTN |
|
86 | 86 |
|
87 | 87 |
@pict_small [ |
88 | 88 |
|
... | ... |
@@ -65,7 +65,7 @@ BRK |
65 | 65 |
( background ) ~window.x1 ~window.y1 ~window.x2 ~window.y2 #02 ,fill-rect JSR2 |
66 | 66 |
( label ) ~window.x1 ~window.y1 #04 ,window_name ,draw-label-left JSR2 |
67 | 67 |
|
68 |
-RTS |
|
68 |
+RTN |
|
69 | 69 |
|
70 | 70 |
@draw-editor |
71 | 71 |
|
... | ... |
@@ -94,7 +94,7 @@ RTS |
94 | 94 |
~window.x2 #0008 SUB2 =Sprite.x |
95 | 95 |
( draw ) #01 =Sprite.color |
96 | 96 |
|
97 |
-RTS |
|
97 |
+RTN |
|
98 | 98 |
|
99 | 99 |
@draw-label-left ( x y color addr ) |
100 | 100 |
|
... | ... |
@@ -107,7 +107,7 @@ RTS |
107 | 107 |
DUP2 LDR #00 NEQ ^$loop MUL JMPS |
108 | 108 |
POP2 |
109 | 109 |
|
110 |
-RTS |
|
110 |
+RTN |
|
111 | 111 |
|
112 | 112 |
@fill-rect ( x1 y1 x2 y2 color ) |
113 | 113 |
|
... | ... |
@@ -121,7 +121,7 @@ RTS |
121 | 121 |
( incr ) ~Screen.y #0001 ADD2 =Screen.y |
122 | 122 |
~Screen.y ~rect.y2 LTH2 ^$ver MUL JMPS |
123 | 123 |
|
124 |
-RTS |
|
124 |
+RTN |
|
125 | 125 |
|
126 | 126 |
@line-rect ( x1 y1 x2 y2 color ) |
127 | 127 |
|
... | ... |
@@ -138,7 +138,7 @@ RTS |
138 | 138 |
( incr ) ~Screen.y #0001 ADD2 =Screen.y |
139 | 139 |
~Screen.y ~rect.y2 #0001 ADD2 LTH2 ^$ver MUL JMPS |
140 | 140 |
|
141 |
-RTS |
|
141 |
+RTN |
|
142 | 142 |
|
143 | 143 |
@tile-rect ( x1 y1 x2 y2 color addr ) |
144 | 144 |
|
... | ... |
@@ -152,7 +152,7 @@ RTS |
152 | 152 |
( incr ) ~Sprite.y #0008 ADD2 =Sprite.y |
153 | 153 |
~Sprite.y ~rect.y2 LTH2 ^$ver MUL JMPS |
154 | 154 |
|
155 |
-RTS |
|
155 |
+RTN |
|
156 | 156 |
|
157 | 157 |
@draw-cursor |
158 | 158 |
|
... | ... |
@@ -176,7 +176,7 @@ RTS |
176 | 176 |
~pointer.y =Sprite.y |
177 | 177 |
#11 =Sprite.color |
178 | 178 |
|
179 |
-RTS |
|
179 |
+RTN |
|
180 | 180 |
|
181 | 181 |
@pattern [ 0000 0000 0000 0000 ] |
182 | 182 |
@clear_icn [ 0000 0000 0000 0000 ] |
... | ... |
@@ -35,7 +35,7 @@ |
35 | 35 |
( load file ) |
36 | 36 |
,filepath ,load-file JSR2 |
37 | 37 |
( place textarea ) |
38 |
- #0018 =textarea.x1 ~SCRN.height #0008 SUB2 =textarea.y2 |
|
38 |
+ #0018 =textarea.x1 ~Screen.height #0008 SUB2 =textarea.y2 |
|
39 | 39 |
|
40 | 40 |
,select JSR2 |
41 | 41 |
,redraw JSR2 |
... | ... |
@@ -46,62 +46,62 @@ BRK |
46 | 46 |
|
47 | 47 |
( ctrl ) |
48 | 48 |
|
49 |
- ,ctrl-end ~CTRL #00 EQU ~lock #00 NEQ #0000 NEQ2 JMP2? POP2 |
|
49 |
+ ,ctrl-end ~Controller #00 EQU ~lock #00 NEQ #0000 NEQ2 JMP2? POP2 |
|
50 | 50 |
( lock ) #04 =lock |
51 |
- ,no-ctrl-up ~CTRL #10 NEQ JMP2? POP2 |
|
51 |
+ ,no-ctrl-up ~Controller #10 NEQ JMP2? POP2 |
|
52 | 52 |
( clamp ) ,no-ctrl-up ~position.y #0000 EQU2 JMP2? POP2 |
53 | 53 |
,find-lineoffset JSR2 =position.x |
54 | 54 |
~position.y #0001 SUB2 =position.y |
55 | 55 |
,find-selection JSR2 DUP2 =selection.from #0001 ADD2 =selection.to |
56 | 56 |
,clamp-selection JSR2 ,follow-selection JSR2 ,redraw JSR2 ,ctrl-end JMP2 |
57 | 57 |
@no-ctrl-up |
58 |
- ,no-ctrl-down ~CTRL #20 NEQ JMP2? POP2 |
|
58 |
+ ,no-ctrl-down ~Controller #20 NEQ JMP2? POP2 |
|
59 | 59 |
,find-lineoffset JSR2 =position.x ~position.y #0001 ADD2 =position.y |
60 | 60 |
,find-selection JSR2 DUP2 =selection.from #0001 ADD2 =selection.to |
61 | 61 |
,clamp-selection JSR2 ,follow-selection JSR2 ,redraw JSR2 ,ctrl-end JMP2 |
62 | 62 |
@no-ctrl-down |
63 |
- ,no-ctrl-left ~CTRL #40 NEQ JMP2? POP2 |
|
63 |
+ ,no-ctrl-left ~Controller #40 NEQ JMP2? POP2 |
|
64 | 64 |
( clamp ) ,no-ctrl-left ~selection.from ,document.body EQU2 JMP2? POP2 |
65 | 65 |
~selection.from #0001 SUB2 DUP2 =selection.from #0001 ADD2 =selection.to |
66 | 66 |
,clamp-selection JSR2 ,follow-selection JSR2 ,redraw JSR2 ,ctrl-end JMP2 |
67 | 67 |
@no-ctrl-left |
68 |
- ,no-ctrl-right ~CTRL #80 NEQ JMP2? POP2 |
|
68 |
+ ,no-ctrl-right ~Controller #80 NEQ JMP2? POP2 |
|
69 | 69 |
~selection.from #0001 ADD2 DUP2 =selection.from #0001 ADD2 =selection.to |
70 | 70 |
,clamp-selection JSR2 ,follow-selection JSR2 ,redraw JSR2 ,ctrl-end JMP2 |
71 | 71 |
@no-ctrl-right |
72 | 72 |
( alt ) |
73 |
- ,no-alt ~CTRL #0f AND #02 NEQ JMP2? POP2 |
|
74 |
- ,no-aup ~CTRL #04 ROR #01 NEQ JMP2? POP2 |
|
73 |
+ ,no-alt ~Controller #0f AND #02 NEQ JMP2? POP2 |
|
74 |
+ ,no-aup ~Controller #04 ROR #01 NEQ JMP2? POP2 |
|
75 | 75 |
,find-wordstart JSR2 =selection.to |
76 | 76 |
,clamp-selection JSR2 ,redraw JSR2 ,ctrl-end JMP2 |
77 | 77 |
@no-aup |
78 |
- ,no-adown ~CTRL #04 ROR #02 NEQ JMP2? POP2 |
|
78 |
+ ,no-adown ~Controller #04 ROR #02 NEQ JMP2? POP2 |
|
79 | 79 |
,find-wordend JSR2 =selection.to |
80 | 80 |
,clamp-selection JSR2 ,redraw JSR2 ,ctrl-end JMP2 |
81 | 81 |
@no-adown |
82 |
- ,no-aleft ~CTRL #04 ROR #04 NEQ JMP2? POP2 |
|
82 |
+ ,no-aleft ~Controller #04 ROR #04 NEQ JMP2? POP2 |
|
83 | 83 |
~selection.to #0001 SUB2 =selection.to |
84 | 84 |
,clamp-selection JSR2 ,redraw JSR2 ,ctrl-end JMP2 |
85 | 85 |
@no-aleft |
86 |
- ,no-aright ~CTRL #04 ROR #08 NEQ JMP2? POP2 |
|
86 |
+ ,no-aright ~Controller #04 ROR #08 NEQ JMP2? POP2 |
|
87 | 87 |
~selection.to #0001 ADD2 =selection.to |
88 | 88 |
,clamp-selection JSR2 ,redraw JSR2 ,ctrl-end JMP2 |
89 | 89 |
@no-aright |
90 | 90 |
@no-alt |
91 | 91 |
( ctrl ) |
92 |
- ,no-ctrl ~CTRL #0f AND #01 NEQ JMP2? POP2 |
|
93 |
- ,no-cup ~CTRL #04 ROR #01 NEQ JMP2? POP2 |
|
92 |
+ ,no-ctrl ~Controller #0f AND #01 NEQ JMP2? POP2 |
|
93 |
+ ,no-cup ~Controller #04 ROR #01 NEQ JMP2? POP2 |
|
94 | 94 |
#0004 ,scroll-up JSR2 |
95 | 95 |
,redraw JSR2 ,ctrl-end JMP2 |
96 | 96 |
@no-cup |
97 |
- ,no-cdown ~CTRL #04 ROR #02 NEQ JMP2? POP2 |
|
97 |
+ ,no-cdown ~Controller #04 ROR #02 NEQ JMP2? POP2 |
|
98 | 98 |
#0004 ,scroll-down JSR2 |
99 | 99 |
,redraw JSR2 ,ctrl-end JMP2 |
100 | 100 |
@no-cdown |
101 |
- ,no-cleft ~CTRL #04 ROR #04 NEQ JMP2? POP2 |
|
101 |
+ ,no-cleft ~Controller #04 ROR #04 NEQ JMP2? POP2 |
|
102 | 102 |
,goto-linestart JSR2 ,redraw JSR2 ,ctrl-end JMP2 |
103 | 103 |
@no-cleft |
104 |
- ,no-cright ~CTRL #04 ROR #08 NEQ JMP2? POP2 |
|
104 |
+ ,no-cright ~Controller #04 ROR #08 NEQ JMP2? POP2 |
|
105 | 105 |
,goto-lineend JSR2 ,redraw JSR2 ,ctrl-end JMP2 |
106 | 106 |
@no-cright |
107 | 107 |
@no-ctrl |
... | ... |
@@ -110,9 +110,9 @@ BRK |
110 | 110 |
|
111 | 111 |
( keys ) |
112 | 112 |
|
113 |
- ,no-keys ~KEYS #00 EQU JMP2? POP2 |
|
113 |
+ ,no-keys ~Keys #00 EQU JMP2? POP2 |
|
114 | 114 |
|
115 |
- ,$no-backspace ~KEYS #08 NEQ JMP2? POP2 |
|
115 |
+ ,$no-backspace ~Keys #08 NEQ JMP2? POP2 |
|
116 | 116 |
( erase ) |
117 | 117 |
,$erase-multiple ~selection.to ~selection.from SUB2 #0001 NEQ2 JMP2? POP2 |
118 | 118 |
~selection.to ~selection.from SUB2 ,shift-left JSR2 |
... | ... |
@@ -127,38 +127,38 @@ BRK |
127 | 127 |
|
128 | 128 |
( insert ) |
129 | 129 |
~selection.to ~selection.from SUB2 ,shift-right JSR2 |
130 |
- ~KEYS ~selection.from STR |
|
130 |
+ ~Keys ~selection.from STR |
|
131 | 131 |
~selection.from #0001 ADD2 =selection.from |
132 | 132 |
|
133 | 133 |
$keys-end |
134 | 134 |
~selection.from #0001 ADD2 =selection.to |
135 |
- ( release ) #00 =KEYS |
|
135 |
+ ( release ) #00 =Keys |
|
136 | 136 |
,redraw JSR2 |
137 | 137 |
|
138 | 138 |
@no-keys |
139 | 139 |
|
140 | 140 |
( mouse ) |
141 | 141 |
|
142 |
- ,no-change ~MOUS.state ~touch.state EQU JMP2? POP2 |
|
142 |
+ ,no-change ~Mouse.state ~touch.state EQU JMP2? POP2 |
|
143 | 143 |
|
144 |
- #0000 =SPRT.x ~SCRN.height #0008 SUB2 =SPRT.y |
|
145 |
- ,mouse00icn =SPRT.addr |
|
146 |
- ,nobutton1 ~MOUS.state #01 NEQ JMP2? POP2 ,mouse01icn =SPRT.addr @nobutton1 |
|
147 |
- ,nobutton2 ~MOUS.state #10 NEQ JMP2? POP2 ,mouse10icn =SPRT.addr @nobutton2 |
|
148 |
- ,nobutton3 ~MOUS.state #11 NEQ JMP2? POP2 ,mouse11icn =SPRT.addr @nobutton3 |
|
149 |
- #01 =SPRT.color |
|
144 |
+ #0000 =Sprite.x ~Screen.height #0008 SUB2 =Sprite.y |
|
145 |
+ ,mouse00icn =Sprite.addr |
|
146 |
+ ,nobutton1 ~Mouse.state #01 NEQ JMP2? POP2 ,mouse01icn =Sprite.addr @nobutton1 |
|
147 |
+ ,nobutton2 ~Mouse.state #10 NEQ JMP2? POP2 ,mouse10icn =Sprite.addr @nobutton2 |
|
148 |
+ ,nobutton3 ~Mouse.state #11 NEQ JMP2? POP2 ,mouse11icn =Sprite.addr @nobutton3 |
|
149 |
+ #01 =Sprite.color |
|
150 | 150 |
|
151 | 151 |
@no-change |
152 | 152 |
|
153 |
- ,touch-end ~MOUS.state #00 EQU JMP2? POP2 |
|
153 |
+ ,touch-end ~Mouse.state #00 EQU JMP2? POP2 |
|
154 | 154 |
|
155 |
- ,touch-linebar ~MOUS.x #0010 LTH2 JMP2? POP2 |
|
156 |
- ,touch-body ~MOUS.x ~SCRN.width #0008 SUB2 LTH2 JMP2? POP2 |
|
155 |
+ ,touch-linebar ~Mouse.x #0010 LTH2 JMP2? POP2 |
|
156 |
+ ,touch-body ~Mouse.x ~Screen.width #0008 SUB2 LTH2 JMP2? POP2 |
|
157 | 157 |
,touch-scrollbar JMP2 |
158 | 158 |
|
159 | 159 |
@touch-end |
160 | 160 |
|
161 |
- ~MOUS.state =touch.state |
|
161 |
+ ~Mouse.state =touch.state |
|
162 | 162 |
|
163 | 163 |
( unlock ) ,skip-unlock ~lock #00 EQU JMP2? POP2 ~lock #01 SUB =lock @skip-unlock |
164 | 164 |
|
... | ... |
@@ -168,49 +168,49 @@ BRK |
168 | 168 |
|
169 | 169 |
@touch-scrollbar |
170 | 170 |
|
171 |
- ,$no-up ~MOUS.y #0008 GTH2 JMP2? POP2 |
|
171 |
+ ,$no-up ~Mouse.y #0008 GTH2 JMP2? POP2 |
|
172 | 172 |
( decr ) ~scroll.y #00 ~scroll.y #0000 NEQ2 SUB2 =scroll.y |
173 | 173 |
^$end JMPS |
174 | 174 |
$no-up |
175 |
- ,$no-down ~MOUS.y ~SCRN.height #0008 SUB2 LTH2 JMP2? POP2 |
|
175 |
+ ,$no-down ~Mouse.y ~Screen.height #0008 SUB2 LTH2 JMP2? POP2 |
|
176 | 176 |
( incr ) ~scroll.y #0001 ADD2 =scroll.y |
177 | 177 |
^$end JMPS |
178 | 178 |
$no-down |
179 |
- ~MOUS.y #0008 SUB2 =scroll.y |
|
179 |
+ ~Mouse.y #0008 SUB2 =scroll.y |
|
180 | 180 |
$end |
181 | 181 |
,redraw JSR2 |
182 | 182 |
,touch-end JMP2 |
183 | 183 |
|
184 |
-RTS |
|
184 |
+RTN |
|
185 | 185 |
|
186 | 186 |
@touch-linebar |
187 | 187 |
|
188 |
- ~MOUS.y #0008 DIV2 ~scroll.y ADD2 =position.y #0000 =position.x |
|
188 |
+ ~Mouse.y #0008 DIV2 ~scroll.y ADD2 =position.y #0000 =position.x |
|
189 | 189 |
,find-selection JSR2 DUP2 =selection.from #0001 ADD2 =selection.to |
190 | 190 |
,redraw JSR2 |
191 | 191 |
,touch-end JMP2 |
192 | 192 |
|
193 |
-RTS |
|
193 |
+RTN |
|
194 | 194 |
|
195 | 195 |
@touch-body |
196 | 196 |
|
197 |
- ~MOUS.y #0008 DIV2 ~scroll.y ADD2 =position.y |
|
198 |
- ~MOUS.x ~textarea.x1 SUB2 #0007 ADD2 #0007 DIV2 =position.x |
|
197 |
+ ~Mouse.y #0008 DIV2 ~scroll.y ADD2 =position.y |
|
198 |
+ ~Mouse.x ~textarea.x1 SUB2 #0007 ADD2 #0007 DIV2 =position.x |
|
199 | 199 |
|
200 |
- ,$no-chord-cut ~MOUS.chord #01 NEQ JMP2? POP2 |
|
200 |
+ ,$no-chord-cut ~Mouse.chord #01 NEQ JMP2? POP2 |
|
201 | 201 |
,cut JSR2 |
202 |
- ( release ) #00 DUP =MOUS.state =MOUS.chord |
|
202 |
+ ( release ) #00 DUP =Mouse.state =Mouse.chord |
|
203 | 203 |
^$end JMPS |
204 | 204 |
$no-chord-cut |
205 |
- ,$no-chord-paste ~MOUS.chord #10 NEQ JMP2? POP2 |
|
205 |
+ ,$no-chord-paste ~Mouse.chord #10 NEQ JMP2? POP2 |
|
206 | 206 |
,paste JSR2 |
207 |
- ( release ) #00 DUP =MOUS.state =MOUS.chord |
|
207 |
+ ( release ) #00 DUP =Mouse.state =Mouse.chord |
|
208 | 208 |
^$end JMPS |
209 | 209 |
$no-chord-paste |
210 | 210 |
|
211 |
- ,$end ~MOUS.state #11 EQU JMP2? POP2 |
|
211 |
+ ,$end ~Mouse.state #11 EQU JMP2? POP2 |
|
212 | 212 |
|
213 |
- ,$no-drag ~MOUS.state ~touch.state NEQ ~CTRL #0f AND #02 NEQ #0101 EQU2 JMP2? POP2 |
|
213 |
+ ,$no-drag ~Mouse.state ~touch.state NEQ ~Controller #0f AND #02 NEQ #0101 EQU2 JMP2? POP2 |
|
214 | 214 |
( on drag ) |
215 | 215 |
,find-selection JSR2 #0001 ADD2 =selection.to |
216 | 216 |
,clamp-selection JSR2 |
... | ... |
@@ -222,34 +222,34 @@ RTS |
222 | 222 |
,redraw JSR2 |
223 | 223 |
,touch-end JMP2 |
224 | 224 |
|
225 |
-RTS |
|
225 |
+RTN |
|
226 | 226 |
|
227 | 227 |
@load-file ( path ) |
228 | 228 |
|
229 |
- =FILE.name #8000 =FILE.length ,document.body =FILE.load |
|
229 |
+ =File.name #8000 =File.length ,document.body =File.load |
|
230 | 230 |
( get file length ) |
231 | 231 |
,document.body =document.eof |
232 | 232 |
$loop NOP |
233 | 233 |
( incr ) ~document.eof #0001 ADD2 =document.eof |
234 | 234 |
~document.eof LDR #00 NEQ ^$loop MUL JMPS |
235 | 235 |
|
236 |
-RTS |
|
236 |
+RTN |
|
237 | 237 |
|
238 | 238 |
@scroll-up ( length ) |
239 | 239 |
|
240 | 240 |
DUP2 ~scroll.y LTH2 ,$clamp ROT JMP2? POP2 |
241 |
- #0000 =scroll.y POP2 RTS |
|
241 |
+ #0000 =scroll.y POP2 RTN |
|
242 | 242 |
$clamp |
243 | 243 |
~scroll.y SWP2 SUB2 =scroll.y |
244 | 244 |
|
245 |
-RTS |
|
245 |
+RTN |
|
246 | 246 |
|
247 | 247 |
@scroll-down ( length ) |
248 | 248 |
|
249 | 249 |
( TODO: Clamp ) |
250 | 250 |
~scroll.y SWP2 ADD2 =scroll.y |
251 | 251 |
|
252 |
-RTS |
|
252 |
+RTN |
|
253 | 253 |
|
254 | 254 |
@shift-left ( length ) |
255 | 255 |
|
... | ... |
@@ -261,7 +261,7 @@ RTS |
261 | 261 |
~j ~document.eof LTH2 ^$loop MUL JMPS |
262 | 262 |
~document.eof ~i SUB2 =document.eof |
263 | 263 |
|
264 |
-RTS |
|
264 |
+RTN |
|
265 | 265 |
|
266 | 266 |
@shift-right ( length ) |
267 | 267 |
|
... | ... |
@@ -273,51 +273,51 @@ RTS |
273 | 273 |
~j ~selection.from GTH2 ^$loop MUL JMPS |
274 | 274 |
~document.eof ~i ADD2 =document.eof |
275 | 275 |
|
276 |
-RTS |
|
276 |
+RTN |
|
277 | 277 |
|
278 | 278 |
@follow-selection |
279 | 279 |
|
280 | 280 |
,$no-up ~position.y ~scroll.y GTH2 JMP2? POP2 |
281 |
- ~position.y =scroll.y RTS |
|
281 |
+ ~position.y =scroll.y RTN |
|
282 | 282 |
$no-up |
283 |
- ,$no-down ~position.y ~SCRN.height #0010 SUB2 #0008 DIV2 ~scroll.y ADD2 LTH2 JMP2? POP2 |
|
284 |
- ~position.y ~SCRN.height #0010 SUB2 #0008 DIV2 SUB2 =scroll.y RTS |
|
283 |
+ ,$no-down ~position.y ~Screen.height #0010 SUB2 #0008 DIV2 ~scroll.y ADD2 LTH2 JMP2? POP2 |
|
284 |
+ ~position.y ~Screen.height #0010 SUB2 #0008 DIV2 SUB2 =scroll.y RTN |
|
285 | 285 |
$no-down |
286 | 286 |
|
287 |
-RTS |
|
287 |
+RTN |
|
288 | 288 |
|
289 | 289 |
@clamp-selection |
290 | 290 |
|
291 |
- ~selection.from ~selection.to LTH2 RTS? |
|
291 |
+ ~selection.from ~selection.to LTH2 RTN? |
|
292 | 292 |
~selection.from #0001 ADD2 =selection.to |
293 | 293 |
|
294 |
-RTS |
|
294 |
+RTN |
|
295 | 295 |
|
296 | 296 |
@goto-linestart |
297 | 297 |
|
298 | 298 |
$loop NOP |
299 |
- ~selection.from #0001 SUB2 LDR #0a EQU RTS? |
|
300 |
- ~selection.from #0001 SUB2 LDR #0d EQU RTS? |
|
299 |
+ ~selection.from #0001 SUB2 LDR #0a EQU RTN? |
|
300 |
+ ~selection.from #0001 SUB2 LDR #0d EQU RTN? |
|
301 | 301 |
( decr ) ~selection.from DUP2 =selection.to #0001 SUB2 =selection.from |
302 | 302 |
~selection.from LDR #00 NEQ ^$loop MUL JMPS |
303 | 303 |
( clamp at document body ) |
304 |
- ~selection.from ,document.body GTH2 RTS? |
|
304 |
+ ~selection.from ,document.body GTH2 RTN? |
|
305 | 305 |
,document.body DUP2 =selection.from #0001 ADD2 =selection.to |
306 | 306 |
|
307 |
-RTS |
|
307 |
+RTN |
|
308 | 308 |
|
309 | 309 |
@goto-lineend |
310 | 310 |
|
311 | 311 |
$loop NOP |
312 |
- ~selection.from LDR #0a EQU RTS? |
|
313 |
- ~selection.from LDR #0d EQU RTS? |
|
312 |
+ ~selection.from LDR #0a EQU RTN? |
|
313 |
+ ~selection.from LDR #0d EQU RTN? |
|
314 | 314 |
( incr ) ~selection.from #0001 ADD2 DUP2 #0001 ADD2 =selection.to =selection.from |
315 | 315 |
~selection.from LDR #00 NEQ ^$loop MUL JMPS |
316 | 316 |
( clamp at document body ) |
317 |
- ~selection.from ,document.eof LTH2 RTS? |
|
317 |
+ ~selection.from ,document.eof LTH2 RTN? |
|
318 | 318 |
,document.eof #0001 SUB2 DUP2 =selection.from #0001 ADD2 =selection.to |
319 | 319 |
|
320 |
-RTS |
|
320 |
+RTN |
|
321 | 321 |
|
322 | 322 |
@find-wordstart |
323 | 323 |
|
... | ... |
@@ -331,7 +331,7 @@ RTS |
331 | 331 |
$end |
332 | 332 |
( return ) ~j #0001 SUB2 |
333 | 333 |
|
334 |
-RTS |
|
334 |
+RTN |
|
335 | 335 |
|
336 | 336 |
@find-wordend |
337 | 337 |
|
... | ... |
@@ -345,7 +345,7 @@ RTS |
345 | 345 |
$end |
346 | 346 |
( return ) ~j #0001 ADD2 |
347 | 347 |
|
348 |
-RTS |
|
348 |
+RTN |
|
349 | 349 |
|
350 | 350 |
@find-lineoffset ( return character offset from linestart ) |
351 | 351 |
|
... | ... |
@@ -358,7 +358,7 @@ RTS |
358 | 358 |
$end |
359 | 359 |
( return ) ~j |
360 | 360 |
|
361 |
-RTS |
|
361 |
+RTN |
|
362 | 362 |
|
363 | 363 |
@find-line ( position -> addr ) |
364 | 364 |
|
... | ... |
@@ -373,7 +373,7 @@ RTS |
373 | 373 |
$end |
374 | 374 |
( return ) ~j |
375 | 375 |
|
376 |
-RTS |
|
376 |
+RTN |
|
377 | 377 |
|
378 | 378 |
@find-selection ( position -> addr ) |
379 | 379 |
|
... | ... |
@@ -387,7 +387,7 @@ RTS |
387 | 387 |
$end |
388 | 388 |
( return ) ~pt.x ADD2 |
389 | 389 |
|
390 |
-RTS |
|
390 |
+RTN |
|
391 | 391 |
|
392 | 392 |
@cut |
393 | 393 |
|
... | ... |
@@ -395,7 +395,7 @@ RTS |
395 | 395 |
~selection.to ~selection.from SUB2 ,shift-left JSR2 |
396 | 396 |
~selection.from #0001 ADD2 =selection.to |
397 | 397 |
|
398 |
-RTS |
|
398 |
+RTN |
|
399 | 399 |
|
400 | 400 |
@copy ( selection ) |
401 | 401 |
|
... | ... |
@@ -407,7 +407,7 @@ RTS |
407 | 407 |
( incr ) ~i #0001 ADD2 =i |
408 | 408 |
~i ~j LTH2 ^$loop MUL JMPS |
409 | 409 |
|
410 |
-RTS |
|
410 |
+RTN |
|
411 | 411 |
|
412 | 412 |
@paste |
413 | 413 |
|
... | ... |
@@ -419,7 +419,7 @@ RTS |
419 | 419 |
( incr ) ~i #0001 ADD2 =i |
420 | 420 |
~i ~j LTH2 ^$loop MUL JMPS |
421 | 421 |
|
422 |
-RTS |
|
422 |
+RTN |
|
423 | 423 |
|
424 | 424 |
@select ( position -> selection ) |
425 | 425 |
|
... | ... |
@@ -431,13 +431,13 @@ RTS |
431 | 431 |
$no-space |
432 | 432 |
,$no-reached ~pt.y ~position.y #0001 SUB2 GTH2 ~pt.x ~position.x #0001 SUB2 GTH2 #0101 NEQ2 JMP2? POP2 |
433 | 433 |
~selection.from #0001 ADD2 =selection.to |
434 |
- RTS |
|
434 |
+ RTN |
|
435 | 435 |
$no-reached |
436 | 436 |
( incr ) ~pt.x #0001 ADD2 =pt.x |
437 | 437 |
( incr ) ~selection.from #0001 ADD2 =selection.from |
438 | 438 |
,$loop ~selection.from LDR #00 NEQ JMP2? POP2 |
439 | 439 |
|
440 |
-RTS |
|
440 |
+RTN |
|
441 | 441 |
|
442 | 442 |
( drawing functions ) |
443 | 443 |
|
... | ... |
@@ -448,57 +448,57 @@ RTS |
448 | 448 |
,draw-titlebar JSR2 |
449 | 449 |
|
450 | 450 |
( save/load icons ) |
451 |
- ~SCRN.height #0008 SUB2 =SPRT.y |
|
452 |
- ~SCRN.width #0018 SUB2 =SPRT.x |
|
453 |
- ,load_icn =SPRT.addr |
|
454 |
- #02 =SPRT.color |
|
455 |
- ~SCRN.width #0010 SUB2 =SPRT.x |
|
456 |
- ,save_icn =SPRT.addr |
|
457 |
- #02 =SPRT.color |
|
451 |
+ ~Screen.height #0008 SUB2 =Sprite.y |
|
452 |
+ ~Screen.width #0018 SUB2 =Sprite.x |
|
453 |
+ ,load_icn =Sprite.addr |
|
454 |
+ #02 =Sprite.color |
|
455 |
+ ~Screen.width #0010 SUB2 =Sprite.x |
|
456 |
+ ,save_icn =Sprite.addr |
|
457 |
+ #02 =Sprite.color |
|
458 | 458 |
|
459 |
-RTS |
|
459 |
+RTN |
|
460 | 460 |
|
461 | 461 |
@draw-short ( short ) |
462 | 462 |
|
463 | 463 |
=addr |
464 |
- ,font_hex #00 ,addr LDR #f0 AND #04 ROR #08 MUL ADD2 =SPRT.addr |
|
465 |
- ( draw ) #0e =SPRT.color |
|
466 |
- ~SPRT.x #0008 ADD2 =SPRT.x |
|
467 |
- ,font_hex #00 ,addr LDR #0f AND #08 MUL ADD2 =SPRT.addr |
|
468 |
- ( draw ) #0e =SPRT.color |
|
469 |
- ~SPRT.x #0008 ADD2 =SPRT.x |
|
470 |
- ,font_hex #00 ,addr #0001 ADD2 LDR #f0 AND #04 ROR #08 MUL ADD2 =SPRT.addr |
|
471 |
- ( draw ) #0e =SPRT.color |
|
472 |
- ~SPRT.x #0008 ADD2 =SPRT.x |
|
473 |
- ,font_hex #00 ,addr #0001 ADD2 LDR #0f AND #08 MUL ADD2 =SPRT.addr |
|
474 |
- ( draw ) #0e =SPRT.color |
|
475 |
- |
|
476 |
-RTS |
|
464 |
+ ,font_hex #00 ,addr LDR #f0 AND #04 ROR #08 MUL ADD2 =Sprite.addr |
|
465 |
+ ( draw ) #0e =Sprite.color |
|
466 |
+ ~Sprite.x #0008 ADD2 =Sprite.x |
|
467 |
+ ,font_hex #00 ,addr LDR #0f AND #08 MUL ADD2 =Sprite.addr |
|
468 |
+ ( draw ) #0e =Sprite.color |
|
469 |
+ ~Sprite.x #0008 ADD2 =Sprite.x |
|
470 |
+ ,font_hex #00 ,addr #0001 ADD2 LDR #f0 AND #04 ROR #08 MUL ADD2 =Sprite.addr |
|
471 |
+ ( draw ) #0e =Sprite.color |
|
472 |
+ ~Sprite.x #0008 ADD2 =Sprite.x |
|
473 |
+ ,font_hex #00 ,addr #0001 ADD2 LDR #0f AND #08 MUL ADD2 =Sprite.addr |
|
474 |
+ ( draw ) #0e =Sprite.color |
|
475 |
+ |
|
476 |
+RTN |
|
477 | 477 |
|
478 | 478 |
@draw-cursor |
479 | 479 |
|
480 |
- ~mouse.x ~MOUS.x NEQU2 |
|
481 |
- ~mouse.y ~MOUS.y NEQU2 |
|
480 |
+ ~mouse.x ~Mouse.x NEQU2 |
|
481 |
+ ~mouse.y ~Mouse.y NEQU2 |
|
482 | 482 |
|
483 |
- #0000 EQU2 RTS? ( Return if unchanged ) |
|
483 |
+ #0000 EQU2 RTN? ( Return if unchanged ) |
|
484 | 484 |
|
485 | 485 |
( clear last cursor ) |
486 |
- ~mouse.x =SPRT.x |
|
487 |
- ~mouse.y =SPRT.y |
|
488 |
- ,blank_icn =SPRT.addr |
|
489 |
- #10 =SPRT.color |
|
486 |
+ ~mouse.x =Sprite.x |
|
487 |
+ ~mouse.y =Sprite.y |
|
488 |
+ ,blank_icn =Sprite.addr |
|
489 |
+ #10 =Sprite.color |
|
490 | 490 |
|
491 | 491 |
( record mouse positions ) |
492 |
- ~MOUS.x =mouse.x |
|
493 |
- ~MOUS.y =mouse.y |
|
492 |
+ ~Mouse.x =mouse.x |
|
493 |
+ ~Mouse.y =mouse.y |
|
494 | 494 |
|
495 | 495 |
( draw new cursor ) |
496 |
- ~mouse.x =SPRT.x |
|
497 |
- ~mouse.y =SPRT.y |
|
498 |
- ,cursor_icn =SPRT.addr |
|
499 |
- #13 =SPRT.color |
|
496 |
+ ~mouse.x =Sprite.x |
|
497 |
+ ~mouse.y =Sprite.y |
|
498 |
+ ,cursor_icn =Sprite.addr |
|
499 |
+ #13 =Sprite.color |
|
500 | 500 |
|
501 |
-RTS |
|
501 |
+RTN |
|
502 | 502 |
|
503 | 503 |
@draw-textarea ( x y color addr ) |
504 | 504 |
|
... | ... |
@@ -515,100 +515,100 @@ RTS |
515 | 515 |
~textarea.addr LDR #00 NEQ ^$find-offset MUL JMPS |
516 | 516 |
$find-offset-end |
517 | 517 |
|
518 |
- #0018 =SPRT.x #0000 =SPRT.y |
|
518 |
+ #0018 =Sprite.x #0000 =Sprite.y |
|
519 | 519 |
~textarea.addr =i |
520 | 520 |
|
521 | 521 |
$loop |
522 | 522 |
|
523 |
- ,$end ~SPRT.y ~SCRN.height #0010 SUB2 GTH2 JMP2? POP2 |
|
523 |
+ ,$end ~Sprite.y ~Screen.height #0010 SUB2 GTH2 JMP2? POP2 |
|
524 | 524 |
|
525 | 525 |
( get character ) |
526 |
- ,font #00 ~i LDR #20 SUB #0008 MUL2 ADD2 =SPRT.addr |
|
526 |
+ ,font #00 ~i LDR #20 SUB #0008 MUL2 ADD2 =Sprite.addr |
|
527 | 527 |
|
528 | 528 |
( draw ) #01 |
529 | 529 |
~i ~selection.from #0001 SUB2 GTH2 |
530 | 530 |
~i ~selection.to LTH2 #0101 EQU2 |
531 |
- #05 MUL ADD ~i ~selection.from EQU2 ADD =SPRT.color |
|
531 |
+ #05 MUL ADD ~i ~selection.from EQU2 ADD =Sprite.color |
|
532 | 532 |
|
533 | 533 |
,$no-linebreak ~i LDR #0a NEQ ~i LDR #0d NEQ #0101 EQU2 JMP2? POP2 |
534 | 534 |
( draw linebreak ) |
535 |
- ,linebreak_icn =SPRT.addr |
|
535 |
+ ,linebreak_icn =Sprite.addr |
|
536 | 536 |
( draw ) #02 |
537 | 537 |
~i ~selection.from #0001 SUB2 GTH2 |
538 | 538 |
~i ~selection.to LTH2 #0101 EQU2 |
539 |
- #06 MUL ADD =SPRT.color |
|
539 |
+ #06 MUL ADD =Sprite.color |
|
540 | 540 |
( fill clear ) |
541 | 541 |
$fill-clear |
542 |
- ( incr ) ~SPRT.x #0008 ADD2 =SPRT.x |
|
543 |
- ,font =SPRT.addr |
|
544 |
- #01 =SPRT.color |
|
545 |
- ,$fill-clear ~SPRT.x ~SCRN.width #0008 SUB2 LTH2 JMP2? POP2 |
|
542 |
+ ( incr ) ~Sprite.x #0008 ADD2 =Sprite.x |
|
543 |
+ ,font =Sprite.addr |
|
544 |
+ #01 =Sprite.color |
|
545 |
+ ,$fill-clear ~Sprite.x ~Screen.width #0008 SUB2 LTH2 JMP2? POP2 |
|
546 | 546 |
|
547 | 547 |
( draw line number ) |
548 | 548 |
|
549 |
- #0000 =SPRT.x |
|
550 |
- ~scroll.y ~SPRT.y #0008 DIV2 ADD2 DUP2 SWP POP =k |
|
549 |
+ #0000 =Sprite.x |
|
550 |
+ ~scroll.y ~Sprite.y #0008 DIV2 ADD2 DUP2 SWP POP =k |
|
551 | 551 |
~position.y EQU2 #0c MUL =l |
552 |
- ,font_hex #00 ~k #f0 AND #04 ROR #08 MUL ADD2 =SPRT.addr |
|
553 |
- #02 ~l ADD =SPRT.color |
|
554 |
- #0008 =SPRT.x |
|
555 |
- ,font_hex #00 ~k #0f AND #08 MUL ADD2 =SPRT.addr |
|
556 |
- #02 ~l ADD =SPRT.color |
|
557 |
- |
|
558 |
- #0010 =SPRT.x |
|
559 |
- ( incr ) ~SPRT.y #0008 ADD2 =SPRT.y |
|
552 |
+ ,font_hex #00 ~k #f0 AND #04 ROR #08 MUL ADD2 =Sprite.addr |
|
553 |
+ #02 ~l ADD =Sprite.color |
|
554 |
+ #0008 =Sprite.x |
|
555 |
+ ,font_hex #00 ~k #0f AND #08 MUL ADD2 =Sprite.addr |
|
556 |
+ #02 ~l ADD =Sprite.color |
|
557 |
+ |
|
558 |
+ #0010 =Sprite.x |
|
559 |
+ ( incr ) ~Sprite.y #0008 ADD2 =Sprite.y |
|
560 | 560 |
$no-linebreak |
561 | 561 |
|
562 | 562 |
( incr ) ~i #0001 ADD2 =i |
563 |
- ( incr ) ~SPRT.x #0007 ADD2 =SPRT.x |
|
563 |
+ ( incr ) ~Sprite.x #0007 ADD2 =Sprite.x |
|
564 | 564 |
|
565 | 565 |
,$loop ~i LDR #00 NEQ JMP2? POP2 |
566 | 566 |
|
567 | 567 |
$end |
568 | 568 |
|
569 |
-RTS |
|
569 |
+RTN |
|
570 | 570 |
|
571 | 571 |
@draw-scrollbar |
572 | 572 |
|
573 |
- ~SCRN.width #0008 SUB2 =SPRT.x |
|
574 |
- #0000 =SPRT.y |
|
575 |
- ,scrollbar_bg =SPRT.addr |
|
573 |
+ ~Screen.width #0008 SUB2 =Sprite.x |
|
574 |
+ #0000 =Sprite.y |
|
575 |
+ ,scrollbar_bg =Sprite.addr |
|
576 | 576 |
|
577 | 577 |
$loop NOP |
578 |
- ( draw ) #08 =SPRT.color |
|
579 |
- ( incr ) ~SPRT.y #0008 ADD2 =SPRT.y |
|
580 |
- ~SPRT.y ~SCRN.height LTH2 ^$loop MUL JMPS |
|
578 |
+ ( draw ) #08 =Sprite.color |
|
579 |
+ ( incr ) ~Sprite.y #0008 ADD2 =Sprite.y |
|
580 |
+ ~Sprite.y ~Screen.height LTH2 ^$loop MUL JMPS |
|
581 | 581 |
|
582 |
- #0000 =SPRT.y |
|
583 |
- ,arrowup_icn =SPRT.addr |
|
584 |
- ( draw ) #08 =SPRT.color |
|
582 |
+ #0000 =Sprite.y |
|
583 |
+ ,arrowup_icn =Sprite.addr |
|
584 |
+ ( draw ) #08 =Sprite.color |
|
585 | 585 |
|
586 | 586 |
( at ) |
587 |
- ~scroll.y #0008 ADD2 =SPRT.y |
|
588 |
- ,scrollbar_fg =SPRT.addr |
|
589 |
- ( draw ) #08 =SPRT.color |
|
587 |
+ ~scroll.y #0008 ADD2 =Sprite.y |
|
588 |
+ ,scrollbar_fg =Sprite.addr |
|
589 |
+ ( draw ) #08 =Sprite.color |
|
590 | 590 |
|
591 |
- ~SCRN.height #0008 SUB2 =SPRT.y |
|
592 |
- ,arrowdown_icn =SPRT.addr |
|
593 |
- ( draw ) #08 =SPRT.color |
|
591 |
+ ~Screen.height #0008 SUB2 =Sprite.y |
|
592 |
+ ,arrowdown_icn =Sprite.addr |
|
593 |
+ ( draw ) #08 =Sprite.color |
|
594 | 594 |
|
595 |
-RTS |
|
595 |
+RTN |
|
596 | 596 |
|
597 | 597 |
@draw-titlebar |
598 | 598 |
|
599 |
- #0018 ~SCRN.height #0008 SUB2 #09 ,filepath |
|
600 |
- ( load ) =label.addr =label.color =SPRT.y =SPRT.x |
|
599 |
+ #0018 ~Screen.height #0008 SUB2 #09 ,filepath |
|
600 |
+ ( load ) =label.addr =label.color =Sprite.y =Sprite.x |
|
601 | 601 |
~label.addr |
602 | 602 |
$loop NOP |
603 |
- ( draw ) DUP2 LDR #00 SWP #20 SUB #0008 MUL2 ,font ADD2 =SPRT.addr ~label.color =SPRT.color |
|
603 |
+ ( draw ) DUP2 LDR #00 SWP #20 SUB #0008 MUL2 ,font ADD2 =Sprite.addr ~label.color =Sprite.color |
|
604 | 604 |
( incr ) #0001 ADD2 |
605 |
- ( incr ) ~SPRT.x #0008 ADD2 =SPRT.x |
|
605 |
+ ( incr ) ~Sprite.x #0008 ADD2 =Sprite.x |
|
606 | 606 |
DUP2 LDR #00 NEQ ^$loop MUL JMPS |
607 | 607 |
POP2 |
608 | 608 |
( selection ) |
609 | 609 |
~selection.from ,document.body SUB2 ,draw-short JSR2 |
610 | 610 |
|
611 |
-RTS |
|
611 |
+RTN |
|
612 | 612 |
|
613 | 613 |
@font_hex ( 0-F TODO: should pull from @font instead.. ) |
614 | 614 |
[ |
... | ... |
@@ -697,13 +697,13 @@ RTS |
697 | 697 |
|
698 | 698 |
|d000 @ERROR BRK |
699 | 699 |
|
700 |
-|FF00 ;CNSL { pad 8 char 1 byte 1 short 2 } |
|
701 |
-|FF10 ;SCRN { width 2 height 2 pad 4 x 2 y 2 color 1 } |
|
702 |
-|FF20 ;SPRT { pad 8 x 2 y 2 addr 2 color 1 } |
|
703 |
-|FF30 ;CTRL { buttons 1 } |
|
704 |
-|FF40 ;KEYS { key 1 } |
|
705 |
-|FF50 ;MOUS { x 2 y 2 state 1 chord 1 xt 1 yt 1 } |
|
706 |
-|FF60 ;FILE { pad 8 name 2 length 2 load 2 save 2 } |
|
700 |
+|FF00 ;Console { pad 8 char 1 byte 1 short 2 } |
|
701 |
+|FF10 ;Screen { width 2 height 2 pad 4 x 2 y 2 color 1 } |
|
702 |
+|FF20 ;Sprite { pad 8 x 2 y 2 addr 2 color 1 } |
|
703 |
+|FF30 ;Controller { buttons 1 } |
|
704 |
+|FF40 ;Keys { key 1 } |
|
705 |
+|FF50 ;Mouse { x 2 y 2 state 1 chord 1 xt 1 yt 1 } |
|
706 |
+|FF60 ;File { pad 8 name 2 length 2 load 2 save 2 } |
|
707 | 707 |
|
708 | 708 |
|FFF0 .RESET .FRAME .ERROR ( vectors ) |
709 | 709 |
|FFF8 [ 30ff e0f3 b0f3 ] ( palette ) |
... | ... |
@@ -197,7 +197,7 @@ BRK |
197 | 197 |
~tileview.addr #0007 ADD2 LDR ~tileview.addr #0006 ADD2 STR |
198 | 198 |
~tileview.addr #0007 ADD2 STR |
199 | 199 |
|
200 |
-RTS |
|
200 |
+RTN |
|
201 | 201 |
|
202 | 202 |
@op_shiftdown |
203 | 203 |
|
... | ... |
@@ -211,14 +211,14 @@ RTS |
211 | 211 |
~tileview.addr LDR ~tileview.addr #0001 ADD2 STR |
212 | 212 |
~tileview.addr STR |
213 | 213 |
|
214 |
-RTS |
|
214 |
+RTN |
|
215 | 215 |
|
216 | 216 |
@redraw |
217 | 217 |
|
218 | 218 |
,draw-bankview JSR2 |
219 | 219 |
,draw-tileview JSR2 |
220 | 220 |
|
221 |
-RTS |
|
221 |
+RTN |
|
222 | 222 |
|
223 | 223 |
@draw-bankview |
224 | 224 |
|
... | ... |
@@ -288,7 +288,7 @@ RTS |
288 | 288 |
( incr ) ~SPRT.y #0008 ADD2 =SPRT.y |
289 | 289 |
,$ver ~pt.y #10 LTH JMP2? POP2 |
290 | 290 |
|
291 |
-RTS |
|
291 |
+RTN |
|
292 | 292 |
|
293 | 293 |
@draw-tileview |
294 | 294 |
|
... | ... |
@@ -386,7 +386,7 @@ RTS |
386 | 386 |
( incr ) ~SPRT.y #0008 ADD2 =SPRT.y |
387 | 387 |
,$tiles-ver ~pt.y #02 LTH JMP2? POP2 |
388 | 388 |
|
389 |
-RTS |
|
389 |
+RTN |
|
390 | 390 |
|
391 | 391 |
@draw-tileview-icn |
392 | 392 |
|
... | ... |
@@ -407,14 +407,14 @@ RTS |
407 | 407 |
~SPRT.x #0040 SUB2 =SPRT.x |
408 | 408 |
,$ver ~pt.y #08 LTH JMP2? POP2 |
409 | 409 |
|
410 |
-RTS |
|
410 |
+RTN |
|
411 | 411 |
|
412 | 412 |
@draw-cursor |
413 | 413 |
|
414 | 414 |
~mouse.x ~MOUS.x NEQU2 |
415 | 415 |
~mouse.y ~MOUS.y NEQU2 |
416 | 416 |
|
417 |
- #0000 EQU2 RTS? ( Return if unchanged ) |
|
417 |
+ #0000 EQU2 RTN? ( Return if unchanged ) |
|
418 | 418 |
|
419 | 419 |
( clear last cursor ) |
420 | 420 |
~mouse.x =SPRT.x |
... | ... |
@@ -432,7 +432,7 @@ RTS |
432 | 432 |
,tool_selector #00 ~bankview.mode #08 MUL ADD2 =SPRT.addr |
433 | 433 |
#12 =SPRT.color |
434 | 434 |
|
435 |
-RTS |
|
435 |
+RTN |
|
436 | 436 |
|
437 | 437 |
@draw-short ( short ) |
438 | 438 |
|
... | ... |
@@ -449,7 +449,7 @@ RTS |
449 | 449 |
,font_hex #00 ,addr #0001 ADD2 LDR #0f AND #08 MUL ADD2 =SPRT.addr |
450 | 450 |
( draw ) #02 =SPRT.color |
451 | 451 |
|
452 |
-RTS |
|
452 |
+RTN |
|
453 | 453 |
|
454 | 454 |
( Utils ) |
455 | 455 |
|
... | ... |
@@ -468,7 +468,7 @@ RTS |
468 | 468 |
( incr ) ~SCRN.y #0001 ADD2 =SCRN.y |
469 | 469 |
~SCRN.y ~rect.y2 #0001 ADD2 LTH2 ^$ver MUL JMPS |
470 | 470 |
|
471 |
-RTS |
|
471 |
+RTN |
|
472 | 472 |
|
473 | 473 |
@tool_selector [ 80c0 e0f0 f8e0 1000 ] |
474 | 474 |
@tool_hand [ 4040 4070 f8f8 f870 ] |
... | ... |
@@ -1,12 +1,9 @@ |
1 | 1 |
( tests/jump ) |
2 | 2 |
|
3 |
-%RTS { RSW2 JMP } |
|
4 |
-%JSR2 { PRG WSR2 JMP2 } |
|
5 |
-%JMC { JMP2? POP2 } |
|
6 |
- |
|
7 | 3 |
|0100 @RESET |
8 | 4 |
|
9 | 5 |
,test1 JSR2 |
6 |
+ ,test2 JSR2 |
|
10 | 7 |
|
11 | 8 |
BRK |
12 | 9 |
|
... | ... |
@@ -26,7 +23,7 @@ BRK |
26 | 23 |
|
27 | 24 |
#33 =Console.byte |
28 | 25 |
|
29 |
- ,skip1 #12 #34 LTH JMC |
|
26 |
+ ,skip1 #12 #34 LTH JMP2? POP2 |
|
30 | 27 |
#ff =Console.byte |
31 | 28 |
@skip1 |
32 | 29 |
|
... | ... |
@@ -36,7 +33,7 @@ BRK |
36 | 33 |
|
37 | 34 |
#44 =Console.byte |
38 | 35 |
|
39 |
-RTS |
|
36 |
+RTN |
|
40 | 37 |
|
41 | 38 |
@test2 |
42 | 39 |
|
... | ... |
@@ -51,7 +48,7 @@ RTS |
51 | 48 |
|
52 | 49 |
@end |
53 | 50 |
|
54 |
-RTS |
|
51 |
+RTN |
|
55 | 52 |
|
56 | 53 |
|c000 @FRAME |
57 | 54 |
|d000 @ERROR |
... | ... |
@@ -34,9 +34,9 @@ void op_brk(Uxn *u) { setflag(&u->status, FLAG_HALT, 1); } |
34 | 34 |
void op_lit(Uxn *u) { u->literal += 1; } |
35 | 35 |
void op_nop(Uxn *u) { (void)u; } |
36 | 36 |
void op_jmp(Uxn *u) { Uint8 a = pop8(&u->wst); u->ram.ptr += getflag(&u->status, FLAG_SIGN) ? (Sint8)a : a; } |
37 |
-void op_prg(Uxn *u) { push16(&u->wst, u->ram.ptr); } |
|
37 |
+ |
|
38 | 38 |
void op_jsr(Uxn *u) { Uint8 a = pop8(&u->wst); push16(&u->rst, u->ram.ptr); u->ram.ptr += getflag(&u->status, FLAG_SIGN) ? (Sint8)a : a; } |
39 |
-void op_rts(Uxn *u) { u->ram.ptr = pop16(&u->rst); } |
|
39 |
+void op_rtn(Uxn *u) { u->ram.ptr = pop16(&u->rst); } |
|
40 | 40 |
void op_ldr(Uxn *u) { Uint16 a = pop16(&u->wst); push8(&u->wst, mempeek8(u, a)); } |
41 | 41 |
void op_str(Uxn *u) { Uint16 a = pop16(&u->wst); Uint8 b = pop8(&u->wst); mempoke8(u, a, b); } |
42 | 42 |
/* Logic */ |
... | ... |
@@ -91,12 +91,12 @@ void op_gth16(Uxn *u) { Uint16 a = pop16(&u->wst), b = pop16(&u->wst); push8(&u- |
91 | 91 |
void op_lth16(Uxn *u) { Uint16 a = pop16(&u->wst), b = pop16(&u->wst); push8(&u->wst, getflag(&u->status, FLAG_SIGN) ? (Sint16)b < (Sint16)a : b < a); } |
92 | 92 |
|
93 | 93 |
void (*ops[])(Uxn *u) = { |
94 |
- op_brk, op_nop, op_lit, op_ldr, op_str, op_jmp, op_jsr, op_rts, |
|
94 |
+ op_brk, op_nop, op_lit, op_ldr, op_str, op_jmp, op_jsr, op_rtn, |
|
95 | 95 |
op_equ, op_neq, op_gth, op_lth, op_and, op_xor, op_rol, op_ror, |
96 | 96 |
op_pop, op_dup, op_swp, op_ovr, op_rot, op_nop, op_wsr, op_rsw, |
97 | 97 |
op_add, op_sub, op_mul, op_div, op_nop, op_nop, op_nop, op_nop, |
98 | 98 |
/* 16-bit */ |
99 |
- op_brk, op_nop16, op_lit16, op_ldr16, op_str16, op_jmp16, op_jsr16, op_rts, |
|
99 |
+ op_brk, op_nop16, op_lit16, op_ldr16, op_str16, op_jmp16, op_jsr16, op_rtn, |
|
100 | 100 |
op_equ16, op_neq16, op_gth16, op_lth16, op_and16, op_xor16, op_rol16, op_ror16, |
101 | 101 |
op_pop16, op_dup16, op_swp16, op_ovr16, op_rot16, op_nop, op_wsr16, op_rsw16, |
102 | 102 |
op_add16, op_sub16, op_mul16, op_div16, op_nop, op_nop, op_nop, op_nop |
... | ... |
@@ -106,12 +106,12 @@ Uint8 opr[][4] = { /* wstack-/+ rstack-/+ */ |
106 | 106 |
{0,0,0,0}, {0,0,0,0}, {0,0,0,0}, {2,1,0,0}, {3,0,0,0}, {1,0,0,0}, {1,0,0,2}, {0,0,2,0}, |
107 | 107 |
{2,1,0,0}, {2,1,0,0}, {2,1,0,0}, {2,1,0,0}, {2,1,0,0}, {2,1,0,0}, {2,1,0,0}, {2,1,0,0}, |
108 | 108 |
{1,0,0,0}, {1,2,0,0}, {2,2,0,0}, {2,3,0,0}, {3,3,0,0}, {0,0,0,0}, {1,0,0,1}, {0,1,1,0}, |
109 |
- {2,1,0,0}, {2,1,0,0}, {2,1,0,0}, {2,1,0,0}, {0,0,0,0}, {0,0,0,0}, {0,0,0,0}, {0,0,0,0}, |
|
109 |
+ {2,1,0,0}, {2,1,0,0}, {2,1,0,0}, {2,1,0,0}, {0,0,0,0}, {0,0,0,0}, {0,0,0,0}, {0,2,0,0}, |
|
110 | 110 |
/* 16-bit */ |
111 | 111 |
{0,0,0,0}, {0,0,0,0}, {0,0,0,0}, {2,2,0,0}, {4,0,0,0}, {2,0,0,0}, {2,0,0,0}, {0,0,0,0}, /* TODO */ |
112 | 112 |
{4,2,0,0}, {4,2,0,0}, {4,2,0,0}, {4,2,0,0}, {0,0,0,0}, {0,0,0,0}, {0,0,0,0}, {0,0,0,0}, /* TODO */ |
113 | 113 |
{0,0,0,0}, {0,0,0,0}, {0,0,0,0}, {0,0,0,0}, {0,0,0,0}, {0,0,0,0}, {2,0,0,2}, {0,2,2,0}, /* TODO */ |
114 |
- {4,2,0,0}, {4,2,0,0}, {4,2,0,0}, {4,2,0,0}, {0,0,0,0}, {0,0,0,0}, {0,0,0,0}, {0,0,0,0} |
|
114 |
+ {4,2,0,0}, {4,2,0,0}, {4,2,0,0}, {4,2,0,0}, {0,0,0,0}, {0,0,0,0}, {0,0,0,0}, {0,2,0,0} |
|
115 | 115 |
}; |
116 | 116 |
|
117 | 117 |
/* clang-format on */ |