commit 25407c0
Devine Lu Linvega
·
2026-05-25 23:18:49 +0000 UTC
parent f900f01
Added screenshot to debugger
1 files changed,
+42,
-2
+42,
-2
1@@ -50,6 +50,7 @@ static inline void poke2(Uint8 *d, Uint16 v) { d[0] = v >> 8, d[1] = v; }
2 @|System ------------------------------------------------------------ */
3
4 static char *system_boot_path;
5+static void emu_screenshot();
6
7 static void
8 system_print(char *name, int r)
9@@ -119,13 +120,21 @@ system_deo_expansion(void)
10 fprintf(stderr, "Unknown command: %02x\n", ram[exp]);
11 }
12
13+static void
14+system_deo_print(void)
15+{
16+ if(dev[0xe] & 0x1)
17+ system_print("WST", 0), system_print("RST", 1);
18+ if(dev[0xe] & 0x2)
19+ emu_screenshot();
20+}
21+
22 /* clang-format off */
23
24 static Uint8 system_dei_wst(void) { return ptr[0]; }
25 static Uint8 system_dei_rst(void) { return ptr[1]; }
26 static void system_deo_wst(void) { ptr[0] = dev[4]; }
27 static void system_deo_rst(void) { ptr[1] = dev[5]; }
28-static void system_deo_print(void) { system_print("WST", 0), system_print("RST", 1); }
29
30 /* clang-format on */
31
32@@ -1107,6 +1116,36 @@ emu_restart(unsigned int soft)
33 uxn_eval(0x100);
34 }
35
36+static void
37+emu_screenshot(void)
38+{
39+ FILE *f;
40+ char filename[] = "_00x00.chr";
41+ int tx, ty, row, col, tw = screen_width / 8, th = screen_height / 8;
42+ put_size((Uint8 *)filename + 1, 2, tw);
43+ put_size((Uint8 *)filename + 4, 2, th);
44+ snprintf(filename, sizeof(filename), "_%02xx%02x.chr", tw, th);
45+ f = fopen(filename, "wb");
46+ if(f) {
47+ for(ty = 0; ty < th; ty++) {
48+ for(tx = 0; tx < tw; tx++) {
49+ Uint8 tile[16] = {0};
50+ for(row = 0; row < 8; row++) {
51+ const Uint8 *src = &screen_layers[(ty * 8 + row + 8) * screen_wmar2 + (tx * 8 + 8)];
52+ Uint8 b1 = 0, b2 = 0;
53+ for(col = 0; col < 8; col++) {
54+ Uint8 px = src[col];
55+ b1 |= ((px & 0x1) << (7 - col)), b2 |= (((px >> 2) & 0x1) << (7 - col));
56+ }
57+ tile[row] = b1, tile[row + 8] = b2;
58+ }
59+ fwrite(tile, 1, 16, f);
60+ }
61+ }
62+ fclose(f);
63+ }
64+}
65+
66 static Uint8
67 get_button(KeySym sym)
68 {
69@@ -1183,6 +1222,7 @@ emu_event(void)
70 case XK_F2: emu_deo(0xe, 0x1); break;
71 case XK_F4: console_close(), emu_restart(0); break;
72 case XK_F5: console_close(), emu_restart(1); break;
73+ case XK_F6: emu_deo(0xe, 0x2); break;
74 }
75 controller_down(get_button(sym));
76 if(sym == XK_Tab)
77@@ -1284,7 +1324,7 @@ main(int argc, char **argv)
78 {
79 int i = 1;
80 if(argc == 2 && argv[1][0] == '-' && argv[1][1] == 'v')
81- return !fprintf(stdout, "%s - Varvara Emulator, 20 May 2026.\n", argv[0]);
82+ return !fprintf(stdout, "%s - Varvara Emulator, 25 May 2026.\n", argv[0]);
83 else if(argc == 1)
84 return !fprintf(stdout, "usage: %s [-v] file.rom [args..]\n", argv[0]);
85 else if(!system_boot(argv[i++], argc > 2))