Browse code

Updated mkuxn-fast to match uxn.c changes

Andrew Alderwick authored on 05/08/2021 17:38:25
Showing 3 changed files
... ...
@@ -187,7 +187,7 @@ local i = 0
187 187
 local allops = { }
188 188
 local wanted = false
189 189
 for l in assert(io.lines('src/uxn.c')) do
190
-  if l == 'void (*ops[])(Uxn *u) = {' then
190
+  if l == 'static void (*ops[])(Uxn *u) = {' then
191 191
     wanted = true
192 192
   elseif l == '};' then
193 193
     wanted = false
... ...
@@ -291,7 +291,7 @@ See etc/mkuxn-fast.moon for instructions.
291 291
     local _continue_0 = false
292 292
     repeat
293 293
       local l = f:read('*l')
294
-      if l:match(' push') or l:match('[ *]pop') then
294
+      if l:match(' push') or l:match('[ *]pop') or l:match('devpeek16') then
295 295
         _continue_0 = true
296 296
         break
297 297
       end
... ...
@@ -322,7 +322,7 @@ uxn_eval(Uxn *u, Uint16 vec)
322 322
 	if(u->dev[0].dat[0xf]) 
323 323
 		return 0;
324 324
 	u->ram.ptr = vec;
325
-  if(u->wst.ptr > 0xf8) u->wst.ptr = 0xf8;
325
+	if(u->wst.ptr > 0xf8) u->wst.ptr = 0xf8;
326 326
 	while(u->ram.ptr) {
327 327
 		instr = u->ram.dat[u->ram.ptr++];
328 328
 		switch(instr) {
... ...
@@ -146,7 +146,7 @@ i = 0
146 146
 allops = {}
147 147
 wanted = false
148 148
 for l in assert io.lines 'src/uxn.c'
149
-	if l == 'void (*ops[])(Uxn *u) = {'
149
+	if l == 'static void (*ops[])(Uxn *u) = {'
150 150
 		wanted = true
151 151
 	elseif l == '};'
152 152
 		wanted = false
... ...
@@ -210,7 +210,7 @@ See etc/mkuxn-fast.moon for instructions.
210 210
 	wanted = true
211 211
 	while true
212 212
 		l = f\read '*l'
213
-		if l\match' push' or l\match'[ *]pop'
213
+		if l\match' push' or l\match'[ *]pop' or l\match'devpeek16'
214 214
 			continue
215 215
 		if l == '/* Stack */'
216 216
 			wanted = false
... ...
@@ -22,17 +22,19 @@ See etc/mkuxn-fast.moon for instructions.
22 22
 
23 23
 */
24 24
 
25
+#define MODE_RETURN 0x40
26
+#define MODE_KEEP 0x80
27
+
25 28
 #pragma mark - Operations
26 29
 
27 30
 /* clang-format off */
28
-void   mempoke8(Uint8 *m, Uint16 a, Uint8 b) { m[a] = b; }
29
-Uint8  mempeek8(Uint8 *m, Uint16 a) { return m[a]; }
30
-void   devpoke8(Device *d, Uint8 a, Uint8 b) { d->dat[a & 0xf] = b; d->talk(d, a & 0x0f, 1); }
31
-Uint8  devpeek8(Device *d, Uint8 a) { d->talk(d, a & 0x0f, 0); return d->dat[a & 0xf];  }
31
+static void   mempoke8(Uint8 *m, Uint16 a, Uint8 b) { m[a] = b; }
32
+static Uint8  mempeek8(Uint8 *m, Uint16 a) { return m[a]; }
33
+static void   devpoke8(Device *d, Uint8 a, Uint8 b) { d->dat[a & 0xf] = b; d->talk(d, a & 0x0f, 1); }
34
+static Uint8  devpeek8(Device *d, Uint8 a) { d->talk(d, a & 0x0f, 0); return d->dat[a & 0xf];  }
32 35
 void   mempoke16(Uint8 *m, Uint16 a, Uint16 b) { mempoke8(m, a, b >> 8); mempoke8(m, a + 1, b); }
33 36
 Uint16 mempeek16(Uint8 *m, Uint16 a) { return (mempeek8(m, a) << 8) + mempeek8(m, a + 1); }
34
-void   devpoke16(Device *d, Uint8 a, Uint16 b) { devpoke8(d, a, b >> 8); devpoke8(d, a + 1, b); }
35
-Uint16 devpeek16(Device *d, Uint16 a) { return (devpeek8(d, a) << 8) + devpeek8(d, a + 1); }
37
+static void   devpoke16(Device *d, Uint8 a, Uint16 b) { devpoke8(d, a, b >> 8); devpoke8(d, a + 1, b); }
36 38
 
37 39
 /* clang-format on */
38 40