commit 0fd68e96f0ebfd880675f33128978d91a0b91ff6
parent d1ca328b9866e8cbdd6f9aeda7b3e8dc327ddd57
Author: Devine Lu Linvega <aliceffekt@gmail.com>
Date: Sun, 1 Jan 2023 12:04:54 -0800
Connecting new device ports to uxn core
Diffstat:
4 files changed, 31 insertions(+), 4 deletions(-)
diff --git a/src/uxn.c b/src/uxn.c
@@ -116,7 +116,7 @@ timeout:
/* clang-format on */
int
-uxn_boot(Uxn *u, Uint8 *ram)
+uxn_boot(Uxn *u, Uint8 *ram, Dei *dei, Deo *deo)
{
Uint32 i;
char *cptr = (char *)u;
diff --git a/src/uxn.h b/src/uxn.h
@@ -49,9 +49,14 @@ typedef struct Uxn {
Uint8 *ram;
Stack wst, rst;
Device dev[16];
+ Uint8 (*dei)(struct Uxn *u, Uint8 addr);
+ void (*deo)(struct Uxn *u, Uint8 addr, Uint8 value);
} Uxn;
-int uxn_boot(Uxn *u, Uint8 *ram);
+typedef Uint8 Dei(Uxn *u, Uint8 addr);
+typedef void Deo(Uxn *u, Uint8 addr, Uint8 value);
+
+int uxn_boot(Uxn *u, Uint8 *ram, Dei *dei, Deo *deo);
int uxn_eval(Uxn *u, Uint16 pc);
int uxn_interrupt(void);
int uxn_halt(Uxn *u, Uint8 error, Uint16 addr);
diff --git a/src/uxncli.c b/src/uxncli.c
@@ -24,6 +24,17 @@ error(char *msg, const char *err)
return 0;
}
+static Uint8
+emu_dei(Uxn *u, Uint8 addr)
+{
+ return 0;
+}
+
+static void
+emu_deo(Uxn *u, Uint8 addr, Uint8 v)
+{
+}
+
void
system_deo_special(Device *d, Uint8 port)
{
@@ -83,7 +94,7 @@ uxn_interrupt(void)
static int
start(Uxn *u)
{
- if(!uxn_boot(u, (Uint8 *)calloc(0x10000, sizeof(Uint8))))
+ if(!uxn_boot(u, (Uint8 *)calloc(0x10000, sizeof(Uint8)), emu_dei, emu_deo))
return error("Boot", "Failed");
/* system */ uxn_port(u, 0x0, system_dei, system_deo);
/* console */ uxn_port(u, 0x1, nil_dei, console_deo);
diff --git a/src/uxnemu.c b/src/uxnemu.c
@@ -176,6 +176,17 @@ init(void)
#pragma mark - Devices
+static Uint8
+emu_dei(Uxn *u, Uint8 addr)
+{
+ return 0;
+}
+
+static void
+emu_deo(Uxn *u, Uint8 addr, Uint8 v)
+{
+}
+
void
system_deo_special(Device *d, Uint8 port)
{
@@ -253,7 +264,7 @@ static int
start(Uxn *u, char *rom)
{
free(u->ram);
- if(!uxn_boot(u, calloc(0x10000, 1)))
+ if(!uxn_boot(u, calloc(0x10000, 1), emu_dei, emu_deo))
return error("Boot", "Failed to start uxn.");
if(!load(u, rom))
return error("Boot", "Failed to load rom.");