commit 61c7f9f0c19f8548b97cc98725f392e1d65776c5
parent cd30b48665e491d1cb61a9b64bda016e7cf011d1
Author: neauoire <aliceffekt@gmail.com>
Date: Tue, 11 Jan 2022 14:38:55 -0800
Removed device globals
Diffstat:
2 files changed, 12 insertions(+), 18 deletions(-)
diff --git a/src/uxncli.c b/src/uxncli.c
@@ -21,10 +21,6 @@ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
WITH REGARD TO THIS SOFTWARE.
*/
-#pragma mark - Core
-
-static Device *devsystem, *devconsole;
-
static int
error(char *msg, const char *err)
{
@@ -48,8 +44,6 @@ inspect(Stack *s, char *name)
}
}
-#pragma mark - Devices
-
void
system_deo_special(Device *d, Uint8 port)
{
@@ -83,20 +77,19 @@ nil_deo(Device *d, Uint8 port)
(void)port;
}
-#pragma mark - Generics
-
static int
console_input(Uxn *u, char c)
{
- devconsole->dat[0x2] = c;
- return uxn_eval(u, GETVECTOR(devconsole));
+ Device *d = &u->dev[1];
+ d->dat[0x2] = c;
+ return uxn_eval(u, GETVECTOR(d));
}
static void
run(Uxn *u)
{
- Device *d = devconsole;
- while((!u->dev[0].dat[0xf]) && (read(0, &d->dat[0x2], 1) > 0))
+ Device *d = &u->dev[0];
+ while((!d->dat[0xf]) && (read(0, &d->dat[0x2], 1) > 0))
uxn_eval(u, GETVECTOR(d));
}
@@ -124,8 +117,8 @@ main(int argc, char **argv)
if(!uxn_boot(&u, bank1, bank0 + PAGE_DEV, (Stack *)(bank0 + PAGE_WST), (Stack *)(bank0 + PAGE_RST)))
return error("Boot", "Failed");
- /* system */ devsystem = uxn_port(&u, 0x0, system_dei, system_deo);
- /* console */ devconsole = uxn_port(&u, 0x1, nil_dei, console_deo);
+ /* system */ uxn_port(&u, 0x0, system_dei, system_deo);
+ /* console */ uxn_port(&u, 0x1, nil_dei, console_deo);
/* empty */ uxn_port(&u, 0x2, nil_dei, nil_deo);
/* empty */ uxn_port(&u, 0x3, nil_dei, nil_deo);
/* empty */ uxn_port(&u, 0x4, nil_dei, nil_deo);
diff --git a/src/uxnemu.c b/src/uxnemu.c
@@ -45,7 +45,7 @@ static SDL_Rect gRect;
/* devices */
-static Device *devsystem, *devscreen, *devmouse, *devctrl, *devaudio0, *devconsole;
+static Device *devsystem, *devscreen, *devmouse, *devctrl, *devaudio0;
static Uint8 zoom = 1;
static Uint32 stdin_event, audio0_event;
@@ -260,7 +260,7 @@ start(Uxn *u, char *rom)
if(!load(u, rom))
return error("Boot", "Failed to load rom.");
/* system */ devsystem = uxn_port(u, 0x0, system_dei, system_deo);
- /* console */ devconsole = uxn_port(u, 0x1, nil_dei, console_deo);
+ /* console */ uxn_port(u, 0x1, nil_dei, console_deo);
/* screen */ devscreen = uxn_port(u, 0x2, screen_dei, screen_deo);
/* audio0 */ devaudio0 = uxn_port(u, 0x3, audio_dei, audio_deo);
/* audio1 */ uxn_port(u, 0x4, audio_dei, audio_deo);
@@ -407,8 +407,9 @@ do_shortcut(Uxn *u, SDL_Event *event)
static int
console_input(Uxn *u, char c)
{
- devconsole->dat[0x2] = c;
- return uxn_eval(u, GETVECTOR(devconsole));
+ Device *d = &u->dev[1];
+ d->dat[0x2] = c;
+ return uxn_eval(u, GETVECTOR(d));
}
static int