uxn

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

commit 0dcc3b4c2e12bf2a61e682e9168e8bdb469caae0
parent e20b572c2055a8205c386a4d3950bde66f3162cd
Author: Devine Lu Linvega <aliceffekt@gmail.com>
Date:   Tue, 31 Jan 2023 09:49:32 -0800

Simplified system_cmd

Diffstat:
Msrc/devices/system.c | 12++----------
Msrc/devices/system.h | 7+------
Msrc/uxncli.c | 3+--
Msrc/uxnemu.c | 5++---
4 files changed, 6 insertions(+), 21 deletions(-)

diff --git a/src/devices/system.c b/src/devices/system.c @@ -41,15 +41,8 @@ system_inspect(Uxn *u) /* RAM */ -Uint8 * -system_init(Mmu *m, Uint16 pages) -{ - m->pages = (Uint8 *)calloc(0x10000 * pages, sizeof(Uint8)); - return m->pages; -} - void -mmu_eval(Uint8 *ram, Uint16 addr) +system_cmd(Uint8 *ram, Uint16 addr) { Uint16 a = addr, i = 0; Uint8 o = ram[a++]; @@ -85,7 +78,7 @@ system_deo(Uxn *u, Uint8 *d, Uint8 port) switch(port) { case 0x3: PEKDEV(a, 0x2); - mmu_eval(u->ram, a); + system_cmd(u->ram, a); break; case 0xe: if(u->wst->ptr || u->rst->ptr) system_inspect(u); @@ -113,4 +106,3 @@ uxn_halt(Uxn *u, Uint8 instr, Uint8 err, Uint16 addr) } return 0; } - diff --git a/src/devices/system.h b/src/devices/system.h @@ -11,11 +11,6 @@ WITH REGARD TO THIS SOFTWARE. #define RAM_PAGES 0x10 -typedef struct { - Uint8 *pages; -} Mmu; - -Uint8 *system_init(Mmu *m, Uint16 pages); int system_load(Uxn *u, char *filename); -void system_inspect(Uxn *u); void system_deo(Uxn *u, Uint8 *d, Uint8 port); +void system_inspect(Uxn *u); diff --git a/src/uxncli.c b/src/uxncli.c @@ -78,10 +78,9 @@ main(int argc, char **argv) { Uxn u; int i; - Mmu mmu; if(argc < 2) return emu_error("Usage", "uxncli game.rom args"); - if(!uxn_boot(&u, system_init(&mmu, RAM_PAGES), emu_dei, emu_deo)) + if(!uxn_boot(&u, (Uint8 *)calloc(0x10000 * RAM_PAGES, sizeof(Uint8)), emu_dei, emu_deo)) return emu_error("Boot", "Failed"); if(!system_load(&u, argv[1])) return emu_error("Load", "Failed"); diff --git a/src/uxnemu.c b/src/uxnemu.c @@ -53,7 +53,6 @@ static Uint32 stdin_event, audio0_event; static Uint64 exec_deadline, deadline_interval, ms_interval; char *rom_path; -Mmu mmu; static int error(char *msg, const char *err) @@ -263,8 +262,8 @@ init(void) static int start(Uxn *u, char *rom) { - free(mmu.pages); - if(!uxn_boot(u, system_init(&mmu, RAM_PAGES), emu_dei, emu_deo)) + free(u->ram); + if(!uxn_boot(u, (Uint8 *)calloc(0x10000 * RAM_PAGES, sizeof(Uint8)), emu_dei, emu_deo)) return error("Boot", "Failed to start uxn."); if(!system_load(u, rom)) return error("Boot", "Failed to load rom.");