Updated mkuxn-fast to match uxn.c changes

This commit is contained in:
Andrew Alderwick 2021-08-05 18:38:25 +01:00
parent 352ae83858
commit 0a69a3417d
3 changed files with 13 additions and 11 deletions

View File

@ -187,7 +187,7 @@ local i = 0
local allops = { } local allops = { }
local wanted = false local wanted = false
for l in assert(io.lines('src/uxn.c')) do for l in assert(io.lines('src/uxn.c')) do
if l == 'void (*ops[])(Uxn *u) = {' then if l == 'static void (*ops[])(Uxn *u) = {' then
wanted = true wanted = true
elseif l == '};' then elseif l == '};' then
wanted = false wanted = false
@ -291,7 +291,7 @@ See etc/mkuxn-fast.moon for instructions.
local _continue_0 = false local _continue_0 = false
repeat repeat
local l = f:read('*l') local l = f:read('*l')
if l:match(' push') or l:match('[ *]pop') then if l:match(' push') or l:match('[ *]pop') or l:match('devpeek16') then
_continue_0 = true _continue_0 = true
break break
end end
@ -322,7 +322,7 @@ uxn_eval(Uxn *u, Uint16 vec)
if(u->dev[0].dat[0xf]) if(u->dev[0].dat[0xf])
return 0; return 0;
u->ram.ptr = vec; u->ram.ptr = vec;
if(u->wst.ptr > 0xf8) u->wst.ptr = 0xf8; if(u->wst.ptr > 0xf8) u->wst.ptr = 0xf8;
while(u->ram.ptr) { while(u->ram.ptr) {
instr = u->ram.dat[u->ram.ptr++]; instr = u->ram.dat[u->ram.ptr++];
switch(instr) { switch(instr) {

View File

@ -146,7 +146,7 @@ i = 0
allops = {} allops = {}
wanted = false wanted = false
for l in assert io.lines 'src/uxn.c' for l in assert io.lines 'src/uxn.c'
if l == 'void (*ops[])(Uxn *u) = {' if l == 'static void (*ops[])(Uxn *u) = {'
wanted = true wanted = true
elseif l == '};' elseif l == '};'
wanted = false wanted = false
@ -210,7 +210,7 @@ See etc/mkuxn-fast.moon for instructions.
wanted = true wanted = true
while true while true
l = f\read '*l' l = f\read '*l'
if l\match' push' or l\match'[ *]pop' if l\match' push' or l\match'[ *]pop' or l\match'devpeek16'
continue continue
if l == '/* Stack */' if l == '/* Stack */'
wanted = false wanted = false

View File

@ -22,17 +22,19 @@ See etc/mkuxn-fast.moon for instructions.
*/ */
#define MODE_RETURN 0x40
#define MODE_KEEP 0x80
#pragma mark - Operations #pragma mark - Operations
/* clang-format off */ /* clang-format off */
void mempoke8(Uint8 *m, Uint16 a, Uint8 b) { m[a] = b; } static void mempoke8(Uint8 *m, Uint16 a, Uint8 b) { m[a] = b; }
Uint8 mempeek8(Uint8 *m, Uint16 a) { return m[a]; } static Uint8 mempeek8(Uint8 *m, Uint16 a) { return m[a]; }
void devpoke8(Device *d, Uint8 a, Uint8 b) { d->dat[a & 0xf] = b; d->talk(d, a & 0x0f, 1); } static void devpoke8(Device *d, Uint8 a, Uint8 b) { d->dat[a & 0xf] = b; d->talk(d, a & 0x0f, 1); }
Uint8 devpeek8(Device *d, Uint8 a) { d->talk(d, a & 0x0f, 0); return d->dat[a & 0xf]; } static Uint8 devpeek8(Device *d, Uint8 a) { d->talk(d, a & 0x0f, 0); return d->dat[a & 0xf]; }
void mempoke16(Uint8 *m, Uint16 a, Uint16 b) { mempoke8(m, a, b >> 8); mempoke8(m, a + 1, b); } void mempoke16(Uint8 *m, Uint16 a, Uint16 b) { mempoke8(m, a, b >> 8); mempoke8(m, a + 1, b); }
Uint16 mempeek16(Uint8 *m, Uint16 a) { return (mempeek8(m, a) << 8) + mempeek8(m, a + 1); } Uint16 mempeek16(Uint8 *m, Uint16 a) { return (mempeek8(m, a) << 8) + mempeek8(m, a + 1); }
void devpoke16(Device *d, Uint8 a, Uint16 b) { devpoke8(d, a, b >> 8); devpoke8(d, a + 1, b); } static void devpoke16(Device *d, Uint8 a, Uint16 b) { devpoke8(d, a, b >> 8); devpoke8(d, a + 1, b); }
Uint16 devpeek16(Device *d, Uint16 a) { return (devpeek8(d, a) << 8) + devpeek8(d, a + 1); }
/* clang-format on */ /* clang-format on */