Browse code

Improved cli stack debugger

neauoire authored on 31/10/2023 18:24:00
Showing 6 changed files
... ...
@@ -96,16 +96,16 @@ screen_debugger(Uxn *u)
96 96
 	int i;
97 97
 	for(i = 0; i < 0x08; i++) {
98 98
 		Uint8 pos = u->wst.ptr - 4 + i;
99
-		Uint8 color = i > 4 ? 0x01 : !pos ? 0xc :
100
-			i == 4                        ? 0x8 :
101
-                                            0x2;
99
+		Uint8 color = i > 4 ? 0x01 : !pos ? 0xc
100
+			: i == 4                      ? 0x8
101
+										  : 0x2;
102 102
 		draw_byte(u->wst.dat[pos], i * 0x18 + 0x8, uxn_screen.height - 0x18, color);
103 103
 	}
104 104
 	for(i = 0; i < 0x08; i++) {
105 105
 		Uint8 pos = u->rst.ptr - 4 + i;
106
-		Uint8 color = i > 4 ? 0x01 : !pos ? 0xc :
107
-			i == 4                        ? 0x8 :
108
-                                            0x2;
106
+		Uint8 color = i > 4 ? 0x01 : !pos ? 0xc
107
+			: i == 4                      ? 0x8
108
+										  : 0x2;
109 109
 		draw_byte(u->rst.dat[pos], i * 0x18 + 0x8, uxn_screen.height - 0x10, color);
110 110
 	}
111 111
 	screen_blit(uxn_screen.fg, arrow, 0, 0x68, uxn_screen.height - 0x20, 3, 0, 0, 0);
... ...
@@ -16,8 +16,7 @@ WITH REGARD TO THIS SOFTWARE.
16 16
 */
17 17
 
18 18
 char *boot_rom;
19
-Uint8 dei_masks[0x100], deo_masks[0x100];
20
-Uint16 dev_vers[0x10], dei_mask[0x10], deo_mask[0x10];
19
+Uint16 dev_vers[0x10];
21 20
 
22 21
 static int
23 22
 system_load(Uxn *u, char *filename)
... ...
@@ -37,11 +36,13 @@ static void
37 36
 system_print(Stack *s, char *name)
38 37
 {
39 38
 	Uint8 i;
40
-	fprintf(stderr, "<%s>", name);
41
-	for(i = 0; i < s->ptr; i++)
42
-		fprintf(stderr, " %02x", s->dat[i]);
43
-	if(!i)
44
-		fprintf(stderr, " empty");
39
+	fprintf(stderr, "%s ", name);
40
+	for(i = 0; i < 9; i++) {
41
+		Uint8 pos = s->ptr - 4 + i;
42
+		fprintf(stderr, !pos ? "[%02x]" : i == 4 ? "<%02x>"
43
+												 : " %02x ",
44
+			s->dat[pos]);
45
+	}
45 46
 	fprintf(stderr, "\n");
46 47
 }
47 48
 
... ...
@@ -60,28 +61,10 @@ system_inspect(Uxn *u)
60 61
 	system_print(&u->rst, "rst");
61 62
 }
62 63
 
63
-void
64
-system_connect(Uint8 device, Uint8 ver, Uint16 dei, Uint16 deo)
65
-{
66
-	int i, d = (device << 0x4);
67
-	for(i = 0; i < 0x10; i++) {
68
-		dei_masks[d + i] = (dei >> i) & 0x1;
69
-		deo_masks[d + i] = (deo >> i) & 0x1;
70
-	}
71
-	dev_vers[device] = ver;
72
-	dei_mask[device] = dei;
73
-	deo_mask[device] = deo;
74
-}
75
-
76 64
 int
77 65
 system_version(char *name, char *date)
78 66
 {
79
-	int i;
80 67
 	printf("%s, %s.\n", name, date);
81
-	printf("Device Version Dei  Deo\n");
82
-	for(i = 0; i < 0x10; i++)
83
-		if(dev_vers[i])
84
-			printf("%6x %7d %04x %04x\n", i, dev_vers[i], dei_mask[i], deo_mask[i]);
85 68
 	return 0;
86 69
 }
87 70
 
... ...
@@ -17,7 +17,6 @@ WITH REGARD TO THIS SOFTWARE.
17 17
 
18 18
 extern char *boot_rom;
19 19
 
20
-void system_connect(Uint8 device, Uint8 ver, Uint16 dei, Uint16 deo);
21 20
 void system_reboot(Uxn *u, char *rom, int soft);
22 21
 void system_inspect(Uxn *u);
23 22
 int system_version(char *emulator, char *date);
... ...
@@ -37,8 +37,6 @@ typedef struct Uxn {
37 37
 
38 38
 extern Uint8 emu_dei(Uxn *u, Uint8 addr);
39 39
 extern void emu_deo(Uxn *u, Uint8 addr, Uint8 value);
40
-extern Uint8 dei_masks[0x100], deo_masks[0x100];
41
-extern Uint16 dev_vers[0x10], dei_mask[0x10], deo_mask[0x10];
42 40
 
43 41
 /* built-ins */
44 42
 
... ...
@@ -68,15 +68,9 @@ main(int argc, char **argv)
68 68
 	int i = 1;
69 69
 	if(i == argc)
70 70
 		return system_error("usage", "uxncli [-v] file.rom [args..]");
71
-	/* Connect Varvara */
72
-	system_connect(0x0, SYSTEM_VERSION, SYSTEM_DEIMASK, SYSTEM_DEOMASK);
73
-	system_connect(0x1, CONSOLE_VERSION, CONSOLE_DEIMASK, CONSOLE_DEOMASK);
74
-	system_connect(0xa, FILE_VERSION, FILE_DEIMASK, FILE_DEOMASK);
75
-	system_connect(0xb, FILE_VERSION, FILE_DEIMASK, FILE_DEOMASK);
76
-	system_connect(0xc, DATETIME_VERSION, DATETIME_DEIMASK, DATETIME_DEOMASK);
77 71
 	/* Read flags */
78 72
 	if(argv[i][0] == '-' && argv[i][1] == 'v')
79
-		return system_version("Uxncli - Console Varvara Emulator", "30 Oct 2023");
73
+		return system_version("Uxncli - Console Varvara Emulator", "31 Oct 2023");
80 74
 	if(!system_init(&u, (Uint8 *)calloc(0x10000 * RAM_PAGES, sizeof(Uint8)), argv[i++]))
81 75
 		return system_error("Init", "Failed to initialize uxn.");
82 76
 	/* Game Loop */
... ...
@@ -546,23 +546,10 @@ main(int argc, char **argv)
546 546
 	int i = 1;
547 547
 	if(i == argc)
548 548
 		return system_error("usage", "uxnemu [-v] | uxnemu [-f | -2x | -3x | --] file.rom [args...]");
549
-	/* Connect Varvara */
550
-	system_connect(0x0, SYSTEM_VERSION, SYSTEM_DEIMASK, SYSTEM_DEOMASK);
551
-	system_connect(0x1, CONSOLE_VERSION, CONSOLE_DEIMASK, CONSOLE_DEOMASK);
552
-	system_connect(0x2, SCREEN_VERSION, SCREEN_DEIMASK, SCREEN_DEOMASK);
553
-	system_connect(0x3, AUDIO_VERSION, AUDIO_DEIMASK, AUDIO_DEOMASK);
554
-	system_connect(0x4, AUDIO_VERSION, AUDIO_DEIMASK, AUDIO_DEOMASK);
555
-	system_connect(0x5, AUDIO_VERSION, AUDIO_DEIMASK, AUDIO_DEOMASK);
556
-	system_connect(0x6, AUDIO_VERSION, AUDIO_DEIMASK, AUDIO_DEOMASK);
557
-	system_connect(0x8, CONTROL_VERSION, CONTROL_DEIMASK, CONTROL_DEOMASK);
558
-	system_connect(0x9, MOUSE_VERSION, MOUSE_DEIMASK, MOUSE_DEOMASK);
559
-	system_connect(0xa, FILE_VERSION, FILE_DEIMASK, FILE_DEOMASK);
560
-	system_connect(0xb, FILE_VERSION, FILE_DEIMASK, FILE_DEOMASK);
561
-	system_connect(0xc, DATETIME_VERSION, DATETIME_DEIMASK, DATETIME_DEOMASK);
562 549
 	/* Read flag. Right now, there can be only one. */
563 550
 	if(argv[i][0] == '-') {
564 551
 		if(argv[i][1] == 'v')
565
-			return system_version("Uxnemu - Graphical Varvara Emulator", "30 Oct 2023");
552
+			return system_version("Uxnemu - Graphical Varvara Emulator", "31 Oct 2023");
566 553
 		if(argv[i][1] == '-')
567 554
 			i++;
568 555
 		if(strcmp(argv[i], "-2x") == 0 || strcmp(argv[i], "-3x") == 0)