... | ... |
@@ -21,10 +21,6 @@ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES |
21 | 21 |
WITH REGARD TO THIS SOFTWARE. |
22 | 22 |
*/ |
23 | 23 |
|
24 |
-#pragma mark - Core |
|
25 |
- |
|
26 |
-static Device *devsystem, *devconsole; |
|
27 |
- |
|
28 | 24 |
static int |
29 | 25 |
error(char *msg, const char *err) |
30 | 26 |
{ |
... | ... |
@@ -48,8 +44,6 @@ inspect(Stack *s, char *name) |
48 | 44 |
} |
49 | 45 |
} |
50 | 46 |
|
51 |
-#pragma mark - Devices |
|
52 |
- |
|
53 | 47 |
void |
54 | 48 |
system_deo_special(Device *d, Uint8 port) |
55 | 49 |
{ |
... | ... |
@@ -83,20 +77,19 @@ nil_deo(Device *d, Uint8 port) |
83 | 77 |
(void)port; |
84 | 78 |
} |
85 | 79 |
|
86 |
-#pragma mark - Generics |
|
87 |
- |
|
88 | 80 |
static int |
89 | 81 |
console_input(Uxn *u, char c) |
90 | 82 |
{ |
91 |
- devconsole->dat[0x2] = c; |
|
92 |
- return uxn_eval(u, GETVECTOR(devconsole)); |
|
83 |
+ Device *d = &u->dev[1]; |
|
84 |
+ d->dat[0x2] = c; |
|
85 |
+ return uxn_eval(u, GETVECTOR(d)); |
|
93 | 86 |
} |
94 | 87 |
|
95 | 88 |
static void |
96 | 89 |
run(Uxn *u) |
97 | 90 |
{ |
98 |
- Device *d = devconsole; |
|
99 |
- while((!u->dev[0].dat[0xf]) && (read(0, &d->dat[0x2], 1) > 0)) |
|
91 |
+ Device *d = &u->dev[0]; |
|
92 |
+ while((!d->dat[0xf]) && (read(0, &d->dat[0x2], 1) > 0)) |
|
100 | 93 |
uxn_eval(u, GETVECTOR(d)); |
101 | 94 |
} |
102 | 95 |
|
... | ... |
@@ -124,8 +117,8 @@ main(int argc, char **argv) |
124 | 117 |
if(!uxn_boot(&u, bank1, bank0 + PAGE_DEV, (Stack *)(bank0 + PAGE_WST), (Stack *)(bank0 + PAGE_RST))) |
125 | 118 |
return error("Boot", "Failed"); |
126 | 119 |
|
127 |
- /* system */ devsystem = uxn_port(&u, 0x0, system_dei, system_deo); |
|
128 |
- /* console */ devconsole = uxn_port(&u, 0x1, nil_dei, console_deo); |
|
120 |
+ /* system */ uxn_port(&u, 0x0, system_dei, system_deo); |
|
121 |
+ /* console */ uxn_port(&u, 0x1, nil_dei, console_deo); |
|
129 | 122 |
/* empty */ uxn_port(&u, 0x2, nil_dei, nil_deo); |
130 | 123 |
/* empty */ uxn_port(&u, 0x3, nil_dei, nil_deo); |
131 | 124 |
/* empty */ uxn_port(&u, 0x4, nil_dei, nil_deo); |
... | ... |
@@ -45,7 +45,7 @@ static SDL_Rect gRect; |
45 | 45 |
|
46 | 46 |
/* devices */ |
47 | 47 |
|
48 |
-static Device *devsystem, *devscreen, *devmouse, *devctrl, *devaudio0, *devconsole; |
|
48 |
+static Device *devsystem, *devscreen, *devmouse, *devctrl, *devaudio0; |
|
49 | 49 |
static Uint8 zoom = 1; |
50 | 50 |
static Uint32 stdin_event, audio0_event; |
51 | 51 |
|
... | ... |
@@ -260,7 +260,7 @@ start(Uxn *u, char *rom) |
260 | 260 |
if(!load(u, rom)) |
261 | 261 |
return error("Boot", "Failed to load rom."); |
262 | 262 |
/* system */ devsystem = uxn_port(u, 0x0, system_dei, system_deo); |
263 |
- /* console */ devconsole = uxn_port(u, 0x1, nil_dei, console_deo); |
|
263 |
+ /* console */ uxn_port(u, 0x1, nil_dei, console_deo); |
|
264 | 264 |
/* screen */ devscreen = uxn_port(u, 0x2, screen_dei, screen_deo); |
265 | 265 |
/* audio0 */ devaudio0 = uxn_port(u, 0x3, audio_dei, audio_deo); |
266 | 266 |
/* audio1 */ uxn_port(u, 0x4, audio_dei, audio_deo); |
... | ... |
@@ -407,8 +407,9 @@ do_shortcut(Uxn *u, SDL_Event *event) |
407 | 407 |
static int |
408 | 408 |
console_input(Uxn *u, char c) |
409 | 409 |
{ |
410 |
- devconsole->dat[0x2] = c; |
|
411 |
- return uxn_eval(u, GETVECTOR(devconsole)); |
|
410 |
+ Device *d = &u->dev[1]; |
|
411 |
+ d->dat[0x2] = c; |
|
412 |
+ return uxn_eval(u, GETVECTOR(d)); |
|
412 | 413 |
} |
413 | 414 |
|
414 | 415 |
static int |