Browse code

Connecting new device ports to uxn core

Devine Lu Linvega authored on 01/01/2023 20:04:54
Showing 4 changed files
... ...
@@ -116,7 +116,7 @@ timeout:
116 116
 /* clang-format on */
117 117
 
118 118
 int
119
-uxn_boot(Uxn *u, Uint8 *ram)
119
+uxn_boot(Uxn *u, Uint8 *ram, Dei *dei, Deo *deo)
120 120
 {
121 121
 	Uint32 i;
122 122
 	char *cptr = (char *)u;
... ...
@@ -49,9 +49,14 @@ typedef struct Uxn {
49 49
 	Uint8 *ram;
50 50
 	Stack wst, rst;
51 51
 	Device dev[16];
52
+	Uint8 (*dei)(struct Uxn *u, Uint8 addr);
53
+	void (*deo)(struct Uxn *u, Uint8 addr, Uint8 value);
52 54
 } Uxn;
53 55
 
54
-int uxn_boot(Uxn *u, Uint8 *ram);
56
+typedef Uint8 Dei(Uxn *u, Uint8 addr);
57
+typedef void Deo(Uxn *u, Uint8 addr, Uint8 value);
58
+
59
+int uxn_boot(Uxn *u, Uint8 *ram, Dei *dei, Deo *deo);
55 60
 int uxn_eval(Uxn *u, Uint16 pc);
56 61
 int uxn_interrupt(void);
57 62
 int uxn_halt(Uxn *u, Uint8 error, Uint16 addr);
... ...
@@ -24,6 +24,17 @@ error(char *msg, const char *err)
24 24
 	return 0;
25 25
 }
26 26
 
27
+static Uint8
28
+emu_dei(Uxn *u, Uint8 addr)
29
+{
30
+	return 0;
31
+}
32
+
33
+static void
34
+emu_deo(Uxn *u, Uint8 addr, Uint8 v)
35
+{
36
+}
37
+
27 38
 void
28 39
 system_deo_special(Device *d, Uint8 port)
29 40
 {
... ...
@@ -83,7 +94,7 @@ uxn_interrupt(void)
83 94
 static int
84 95
 start(Uxn *u)
85 96
 {
86
-	if(!uxn_boot(u, (Uint8 *)calloc(0x10000, sizeof(Uint8))))
97
+	if(!uxn_boot(u, (Uint8 *)calloc(0x10000, sizeof(Uint8)), emu_dei, emu_deo))
87 98
 		return error("Boot", "Failed");
88 99
 	/* system   */ uxn_port(u, 0x0, system_dei, system_deo);
89 100
 	/* console  */ uxn_port(u, 0x1, nil_dei, console_deo);
... ...
@@ -176,6 +176,17 @@ init(void)
176 176
 
177 177
 #pragma mark - Devices
178 178
 
179
+static Uint8
180
+emu_dei(Uxn *u, Uint8 addr)
181
+{
182
+	return 0;
183
+}
184
+
185
+static void
186
+emu_deo(Uxn *u, Uint8 addr, Uint8 v)
187
+{
188
+}
189
+
179 190
 void
180 191
 system_deo_special(Device *d, Uint8 port)
181 192
 {
... ...
@@ -253,7 +264,7 @@ static int
253 264
 start(Uxn *u, char *rom)
254 265
 {
255 266
 	free(u->ram);
256
-	if(!uxn_boot(u, calloc(0x10000, 1)))
267
+	if(!uxn_boot(u, calloc(0x10000, 1), emu_dei, emu_deo))
257 268
 		return error("Boot", "Failed to start uxn.");
258 269
 	if(!load(u, rom))
259 270
 		return error("Boot", "Failed to load rom.");