Browse code

Named System device

neauoire authored on 29/07/2021 03:20:57
Showing 2 changed files
... ...
@@ -17,7 +17,7 @@ WITH REGARD TO THIS SOFTWARE.
17 17
 
18 18
 #pragma mark - Core
19 19
 
20
-static Device *devconsole;
20
+static Device *devsystem, *devconsole;
21 21
 
22 22
 static int
23 23
 error(char *msg, const char *err)
... ...
@@ -133,7 +133,7 @@ main(int argc, char **argv)
133 133
 	if(!loaduxn(&u, argv[1]))
134 134
 		return error("Load", "Failed");
135 135
 
136
-	portuxn(&u, 0x0, "system", system_talk);
136
+	devsystem = portuxn(&u, 0x0, "system", system_talk);
137 137
 	devconsole = portuxn(&u, 0x1, "console", console_talk);
138 138
 	portuxn(&u, 0x2, "empty", nil_talk);
139 139
 	portuxn(&u, 0x3, "empty", nil_talk);
... ...
@@ -28,7 +28,7 @@ static SDL_Texture *fgTexture, *bgTexture;
28 28
 static SDL_Rect gRect;
29 29
 static Ppu ppu;
30 30
 static Apu apu[POLYPHONY];
31
-static Device *devscreen, *devmouse, *devctrl, *devaudio0, *devconsole;
31
+static Device *devsystem, *devscreen, *devmouse, *devctrl, *devaudio0, *devconsole;
32 32
 static Uint32 stdin_event;
33 33
 
34 34
 #define PAD 4
... ...
@@ -64,7 +64,7 @@ audio_callback(void *u, Uint8 *stream, int len)
64 64
 static void
65 65
 redraw(Uxn *u)
66 66
 {
67
-	if(u->dev[0].dat[0xe])
67
+	if(devsystem->dat[0xe])
68 68
 		inspect(&ppu, u->wst.dat, u->wst.ptr, u->rst.ptr, u->ram.dat);
69 69
 	SDL_UpdateTexture(bgTexture, &gRect, ppu.bg.pixels, ppu.width * sizeof(Uint32));
70 70
 	SDL_UpdateTexture(fgTexture, &gRect, ppu.fg.pixels, ppu.width * sizeof(Uint32));
... ...
@@ -78,7 +78,7 @@ redraw(Uxn *u)
78 78
 static void
79 79
 toggledebug(Uxn *u)
80 80
 {
81
-	u->dev[0].dat[0xe] = !u->dev[0].dat[0xe];
81
+	devsystem->dat[0xe] = !devsystem->dat[0xe];
82 82
 	redraw(u);
83 83
 }
84 84
 
... ...
@@ -390,7 +390,7 @@ run(Uxn *u)
390 390
 			}
391 391
 		}
392 392
 		evaluxn(u, mempeek16(devscreen->dat, 0));
393
-		if(reqdraw || u->dev[0].dat[0xe])
393
+		if(reqdraw || devsystem->dat[0xe])
394 394
 			redraw(u);
395 395
 		if(!bench) {
396 396
 			elapsed = (SDL_GetPerformanceCounter() - start) / (double)SDL_GetPerformanceFrequency() * 1000.0f;
... ...
@@ -417,7 +417,7 @@ main(int argc, char **argv)
417 417
 	if(!init())
418 418
 		return error("Init", "Failed to initialize emulator.");
419 419
 
420
-	portuxn(&u, 0x0, "system", system_talk);
420
+	devsystem = portuxn(&u, 0x0, "system", system_talk);
421 421
 	devconsole = portuxn(&u, 0x1, "console", console_talk);
422 422
 	devscreen = portuxn(&u, 0x2, "screen", screen_talk);
423 423
 	devaudio0 = portuxn(&u, 0x3, "audio0", audio_talk);