uxn

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

commit 99c492d3856e76b479ee648a79fc9fec49d1183f
parent 0d055306a86b2645ce6131c1dd18b5066503e104
Author: neauoire <aliceffekt@gmail.com>
Date:   Sat, 11 Nov 2023 20:57:28 -0800

Store instance device in Uxn itself

Diffstat:
Msrc/uxn.c | 2+-
Msrc/uxn.h | 2+-
Msrc/uxncli.c | 4+---
Msrc/uxnemu.c | 16++++++----------
4 files changed, 9 insertions(+), 15 deletions(-)

diff --git a/src/uxn.c b/src/uxn.c @@ -48,7 +48,7 @@ uxn_eval(Uxn *u, Uint16 pc) case 0x00: case 0x20: switch(ins) { case 0x00: /* BRK */ return 1; - case 0x20: /* JCI */ t=T; SHIFT(-1) if(!t) { pc += 2; break; } + case 0x20: /* JCI */ t=T; SHIFT(-1) if(!t) { pc += 2; break; } /* fall-through */ case 0x40: /* JMI */ rr = ram + pc; pc += 2 + PEEK2(rr); break; case 0x60: /* JSI */ SHIFT( 2) rr = ram + pc; pc += 2; T2_(pc); pc += PEEK2(rr); break; case 0x80: /* LIT */ case 0xc0: SHIFT( 1) T = ram[pc++]; break; diff --git a/src/uxn.h b/src/uxn.h @@ -29,7 +29,7 @@ typedef struct { } Stack; typedef struct Uxn { - Uint8 *ram, *dev; + Uint8 *ram, dev[0x100]; Stack wst, rst; } Uxn; diff --git a/src/uxncli.c b/src/uxncli.c @@ -64,9 +64,7 @@ emu_end(Uxn *u) int main(int argc, char **argv) { - Uint8 dev[0x100] = {0}; - Uxn u; - u.dev = (Uint8 *)&dev; + Uxn u = {0}; int i = 1; if(i == argc) return system_error("usage", "uxncli [-v] file.rom [args..]"); diff --git a/src/uxnemu.c b/src/uxnemu.c @@ -486,11 +486,9 @@ emu_end(Uxn *u) int main(int argc, char **argv) { - Uint8 dev[0x100] = {0}; - Uxn u = {0}; - Uxn u_audio = {0}; - u.dev = (Uint8 *)&dev; - u_audio.dev = (Uint8 *)&dev; + Uint8 *ram; + char *rom; + Uxn u = {0}, u_audio = {0}; int i = 1; if(i == argc) return system_error("usage", "uxnemu [-v] | uxnemu [-f | -2x | -3x | --] file.rom [args...]"); @@ -508,11 +506,9 @@ main(int argc, char **argv) } } /* Start system. */ - Uint8 *ram = (Uint8 *)calloc(0x10000 * RAM_PAGES, sizeof(Uint8)); - char *rom = argv[i++]; - if(!system_init(&u, ram, rom)) - return system_error("Init", "Failed to initialize uxn."); - if(!system_init(&u_audio, ram, rom)) + ram = (Uint8 *)calloc(0x10000 * RAM_PAGES, sizeof(Uint8)); + rom = argv[i++]; + if(!system_init(&u, ram, rom) || !system_init(&u_audio, ram, rom)) return system_error("Init", "Failed to initialize uxn."); if(!emu_init(&u_audio)) return system_error("Init", "Failed to initialize varvara.");