Named System device

This commit is contained in:
neauoire 2021-07-28 20:20:57 -07:00
parent b46d317b4f
commit 2c78f2cedf
2 changed files with 7 additions and 7 deletions

View File

@ -17,7 +17,7 @@ WITH REGARD TO THIS SOFTWARE.
#pragma mark - Core #pragma mark - Core
static Device *devconsole; static Device *devsystem, *devconsole;
static int static int
error(char *msg, const char *err) error(char *msg, const char *err)
@ -133,7 +133,7 @@ main(int argc, char **argv)
if(!loaduxn(&u, argv[1])) if(!loaduxn(&u, argv[1]))
return error("Load", "Failed"); return error("Load", "Failed");
portuxn(&u, 0x0, "system", system_talk); devsystem = portuxn(&u, 0x0, "system", system_talk);
devconsole = portuxn(&u, 0x1, "console", console_talk); devconsole = portuxn(&u, 0x1, "console", console_talk);
portuxn(&u, 0x2, "empty", nil_talk); portuxn(&u, 0x2, "empty", nil_talk);
portuxn(&u, 0x3, "empty", nil_talk); portuxn(&u, 0x3, "empty", nil_talk);

View File

@ -28,7 +28,7 @@ static SDL_Texture *fgTexture, *bgTexture;
static SDL_Rect gRect; static SDL_Rect gRect;
static Ppu ppu; static Ppu ppu;
static Apu apu[POLYPHONY]; static Apu apu[POLYPHONY];
static Device *devscreen, *devmouse, *devctrl, *devaudio0, *devconsole; static Device *devsystem, *devscreen, *devmouse, *devctrl, *devaudio0, *devconsole;
static Uint32 stdin_event; static Uint32 stdin_event;
#define PAD 4 #define PAD 4
@ -64,7 +64,7 @@ audio_callback(void *u, Uint8 *stream, int len)
static void static void
redraw(Uxn *u) redraw(Uxn *u)
{ {
if(u->dev[0].dat[0xe]) if(devsystem->dat[0xe])
inspect(&ppu, u->wst.dat, u->wst.ptr, u->rst.ptr, u->ram.dat); inspect(&ppu, u->wst.dat, u->wst.ptr, u->rst.ptr, u->ram.dat);
SDL_UpdateTexture(bgTexture, &gRect, ppu.bg.pixels, ppu.width * sizeof(Uint32)); SDL_UpdateTexture(bgTexture, &gRect, ppu.bg.pixels, ppu.width * sizeof(Uint32));
SDL_UpdateTexture(fgTexture, &gRect, ppu.fg.pixels, ppu.width * sizeof(Uint32)); SDL_UpdateTexture(fgTexture, &gRect, ppu.fg.pixels, ppu.width * sizeof(Uint32));
@ -78,7 +78,7 @@ redraw(Uxn *u)
static void static void
toggledebug(Uxn *u) toggledebug(Uxn *u)
{ {
u->dev[0].dat[0xe] = !u->dev[0].dat[0xe]; devsystem->dat[0xe] = !devsystem->dat[0xe];
redraw(u); redraw(u);
} }
@ -390,7 +390,7 @@ run(Uxn *u)
} }
} }
evaluxn(u, mempeek16(devscreen->dat, 0)); evaluxn(u, mempeek16(devscreen->dat, 0));
if(reqdraw || u->dev[0].dat[0xe]) if(reqdraw || devsystem->dat[0xe])
redraw(u); redraw(u);
if(!bench) { if(!bench) {
elapsed = (SDL_GetPerformanceCounter() - start) / (double)SDL_GetPerformanceFrequency() * 1000.0f; elapsed = (SDL_GetPerformanceCounter() - start) / (double)SDL_GetPerformanceFrequency() * 1000.0f;
@ -417,7 +417,7 @@ main(int argc, char **argv)
if(!init()) if(!init())
return error("Init", "Failed to initialize emulator."); return error("Init", "Failed to initialize emulator.");
portuxn(&u, 0x0, "system", system_talk); devsystem = portuxn(&u, 0x0, "system", system_talk);
devconsole = portuxn(&u, 0x1, "console", console_talk); devconsole = portuxn(&u, 0x1, "console", console_talk);
devscreen = portuxn(&u, 0x2, "screen", screen_talk); devscreen = portuxn(&u, 0x2, "screen", screen_talk);
devaudio0 = portuxn(&u, 0x3, "audio0", audio_talk); devaudio0 = portuxn(&u, 0x3, "audio0", audio_talk);