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 wanted = false
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
elseif l == '};' then
wanted = false
@ -291,7 +291,7 @@ See etc/mkuxn-fast.moon for instructions.
local _continue_0 = false
repeat
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
break
end
@ -322,7 +322,7 @@ uxn_eval(Uxn *u, Uint16 vec)
if(u->dev[0].dat[0xf])
return 0;
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) {
instr = u->ram.dat[u->ram.ptr++];
switch(instr) {

View File

@ -146,7 +146,7 @@ i = 0
allops = {}
wanted = false
for l in assert io.lines 'src/uxn.c'
if l == 'void (*ops[])(Uxn *u) = {'
if l == 'static void (*ops[])(Uxn *u) = {'
wanted = true
elseif l == '};'
wanted = false
@ -210,7 +210,7 @@ See etc/mkuxn-fast.moon for instructions.
wanted = true
while true
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
if l == '/* Stack */'
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
/* clang-format off */
void mempoke8(Uint8 *m, Uint16 a, Uint8 b) { m[a] = b; }
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); }
Uint8 devpeek8(Device *d, Uint8 a) { d->talk(d, a & 0x0f, 0); return d->dat[a & 0xf]; }
static void mempoke8(Uint8 *m, Uint16 a, Uint8 b) { m[a] = b; }
static Uint8 mempeek8(Uint8 *m, Uint16 a) { return m[a]; }
static void devpoke8(Device *d, Uint8 a, Uint8 b) { d->dat[a & 0xf] = b; d->talk(d, a & 0x0f, 1); }
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); }
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); }
Uint16 devpeek16(Device *d, Uint16 a) { return (devpeek8(d, a) << 8) + devpeek8(d, a + 1); }
static void devpoke16(Device *d, Uint8 a, Uint16 b) { devpoke8(d, a, b >> 8); devpoke8(d, a + 1, b); }
/* clang-format on */