uxn

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

commit 28b92650420100de16e307e7dc074bfae3cd3f9a
parent a82f7d79f8a23d29505d15f018cde3733f7299e4
Author: neauoire <aliceffekt@gmail.com>
Date:   Thu,  6 Jan 2022 18:49:54 -0800

Let us make a device page in shadow memory

Diffstat:
Msrc/uxn.c | 4++--
Msrc/uxn.h | 3++-
Msrc/uxncli.c | 2+-
Msrc/uxnemu.c | 4++--
4 files changed, 7 insertions(+), 6 deletions(-)

diff --git a/src/uxn.c b/src/uxn.c @@ -108,7 +108,7 @@ err: /* clang-format on */ int -uxn_boot(Uxn *u, Stack *wst, Stack *rst, Uint8 *memory) +uxn_boot(Uxn *u, Uint8 *ram, Uint8 *dev, Stack *wst, Stack *rst) { Uint32 i; char *cptr = (char *)u; @@ -116,7 +116,7 @@ uxn_boot(Uxn *u, Stack *wst, Stack *rst, Uint8 *memory) cptr[i] = 0x00; u->wst = wst; u->rst = rst; - u->ram = memory; + u->ram = ram; return 1; } diff --git a/src/uxn.h b/src/uxn.h @@ -16,6 +16,7 @@ typedef signed short Sint16; typedef unsigned int Uint32; #define PAGE_PROGRAM 0x0100 +#define PAGE_DEV 0xfd00 #define PAGE_WST 0xfe00 #define PAGE_RST 0xff00 @@ -45,7 +46,7 @@ typedef struct Uxn { Device dev[16]; } Uxn; -int uxn_boot(Uxn *u, Stack *wst, Stack *rst, Uint8 *memory); +int uxn_boot(Uxn *u, Uint8 *ram, Uint8 *dev, Stack *wst, Stack *rst); int uxn_eval(Uxn *u, Uint16 pc); int uxn_halt(Uxn *u, Uint8 error, Uint16 addr); Device *uxn_port(Uxn *u, Uint8 id, Uint8 (*deifn)(Device *, Uint8), void (*deofn)(Device *, Uint8)); diff --git a/src/uxncli.c b/src/uxncli.c @@ -143,7 +143,7 @@ main(int argc, char **argv) shadow = (Uint8 *)calloc(0xffff, sizeof(Uint8)); memory = (Uint8 *)calloc(0xffff, sizeof(Uint8)); - if(!uxn_boot(&u, (Stack *)(shadow + PAGE_WST), (Stack *)(shadow + PAGE_RST), memory)) + if(!uxn_boot(&u, memory, shadow + PAGE_DEV, (Stack *)(shadow + PAGE_WST), (Stack *)(shadow + PAGE_RST))) return error("Boot", "Failed"); /* system */ devsystem = uxn_port(&u, 0x0, system_dei, system_deo); diff --git a/src/uxnemu.c b/src/uxnemu.c @@ -278,9 +278,9 @@ start(Uxn *u, char *rom) memory = (Uint8 *)calloc(0xffff, sizeof(Uint8)); shadow = (Uint8 *)calloc(0xffff, sizeof(Uint8)); - if(!uxn_boot(&hypervisor, (Stack *)(shadow + 0xfc00), (Stack *)(shadow + 0xfd00), shadow)) + if(!uxn_boot(&hypervisor, shadow, shadow + PAGE_DEV, (Stack *)(shadow + 0xfb00), (Stack *)(shadow + 0xfc00))) return error("Boot", "Failed to start uxn."); - if(!uxn_boot(u, (Stack *)(shadow + PAGE_WST), (Stack *)(shadow + PAGE_RST), memory)) + if(!uxn_boot(u, memory, shadow + PAGE_DEV, (Stack *)(shadow + PAGE_WST), (Stack *)(shadow + PAGE_RST))) return error("Boot", "Failed to start uxn."); if(!load(&hypervisor, "hypervisor.rom")) error("Hypervisor", "No debugger found.");