uxn

Varvara Ordinator, written in ANSI C(SDL2)
git clone https://git.eamoncaddigan.net/uxn.git
Log | Files | Refs | README | LICENSE

commit 0a69a3417de5243fc286a25f77185881cbd8a48d
parent 352ae83858dfb9aa6514f3603463fe71e48da77e
Author: Andrew Alderwick <andrew@alderwick.co.uk>
Date:   Thu,  5 Aug 2021 18:38:25 +0100

Updated mkuxn-fast to match uxn.c changes

Diffstat:
Metc/mkuxn-fast.lua | 6+++---
Metc/mkuxn-fast.moon | 4++--
Msrc/uxn-fast.c | 14++++++++------
3 files changed, 13 insertions(+), 11 deletions(-)

diff --git a/etc/mkuxn-fast.lua b/etc/mkuxn-fast.lua @@ -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) { diff --git a/etc/mkuxn-fast.moon b/etc/mkuxn-fast.moon @@ -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 diff --git a/src/uxn-fast.c b/src/uxn-fast.c @@ -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 */