... | ... |
@@ -24,7 +24,7 @@ static Uint8 blending[4][16] = { |
24 | 24 |
{1, 2, 3, 1, 1, 2, 3, 1, 1, 2, 3, 1, 1, 2, 3, 1}, |
25 | 25 |
{2, 3, 1, 2, 2, 3, 1, 2, 2, 3, 1, 2, 2, 3, 1, 2}}; |
26 | 26 |
|
27 |
-static void |
|
27 |
+void |
|
28 | 28 |
screen_change(Uint16 x1, Uint16 y1, Uint16 x2, Uint16 y2) |
29 | 29 |
{ |
30 | 30 |
if(x1 > uxn_screen.width && x2 > x1) return; |
... | ... |
@@ -129,6 +129,41 @@ screen_redraw(void) |
129 | 129 |
uxn_screen.x1 = uxn_screen.y1 = uxn_screen.x2 = uxn_screen.y2 = 0; |
130 | 130 |
} |
131 | 131 |
|
132 |
+/* clang-format off */ |
|
133 |
+ |
|
134 |
+Uint8 icons[] = { |
|
135 |
+ 0x00, 0x7c, 0x82, 0x82, 0x82, 0x82, 0x82, 0x7c, 0x00, 0x30, 0x10, 0x10, 0x10, 0x10, 0x10, |
|
136 |
+ 0x10, 0x00, 0x7c, 0x82, 0x02, 0x7c, 0x80, 0x80, 0xfe, 0x00, 0x7c, 0x82, 0x02, 0x1c, 0x02, |
|
137 |
+ 0x82, 0x7c, 0x00, 0x0c, 0x14, 0x24, 0x44, 0x84, 0xfe, 0x04, 0x00, 0xfe, 0x80, 0x80, 0x7c, |
|
138 |
+ 0x02, 0x82, 0x7c, 0x00, 0x7c, 0x82, 0x80, 0xfc, 0x82, 0x82, 0x7c, 0x00, 0x7c, 0x82, 0x02, |
|
139 |
+ 0x1e, 0x02, 0x02, 0x02, 0x00, 0x7c, 0x82, 0x82, 0x7c, 0x82, 0x82, 0x7c, 0x00, 0x7c, 0x82, |
|
140 |
+ 0x82, 0x7e, 0x02, 0x82, 0x7c, 0x00, 0x7c, 0x82, 0x02, 0x7e, 0x82, 0x82, 0x7e, 0x00, 0xfc, |
|
141 |
+ 0x82, 0x82, 0xfc, 0x82, 0x82, 0xfc, 0x00, 0x7c, 0x82, 0x80, 0x80, 0x80, 0x82, 0x7c, 0x00, |
|
142 |
+ 0xfc, 0x82, 0x82, 0x82, 0x82, 0x82, 0xfc, 0x00, 0x7c, 0x82, 0x80, 0xf0, 0x80, 0x82, 0x7c, |
|
143 |
+ 0x00, 0x7c, 0x82, 0x80, 0xf0, 0x80, 0x80, 0x80}; |
|
144 |
+ |
|
145 |
+/* clang-format on */ |
|
146 |
+ |
|
147 |
+void |
|
148 |
+draw_byte(Uint8 v, Uint16 x, Uint16 y, Uint8 color) |
|
149 |
+{ |
|
150 |
+ screen_blit(uxn_screen.fg, icons, v >> 4 << 3, x, y, color, 0, 0, 0); |
|
151 |
+ screen_blit(uxn_screen.fg, icons, (v & 0xf) << 3, x + 8, y, color, 0, 0, 0); |
|
152 |
+} |
|
153 |
+ |
|
154 |
+void |
|
155 |
+screen_debugger(Uxn *u) |
|
156 |
+{ |
|
157 |
+ int i; |
|
158 |
+ for(i = 0; i < u->wst.ptr + 1; i++) |
|
159 |
+ draw_byte(u->wst.dat[i], i * 0x18 + 0x8, uxn_screen.height - 0x18, 0x2); |
|
160 |
+ for(i = 0; i < u->rst.ptr + 1; i++) |
|
161 |
+ draw_byte(u->rst.dat[i], i * 0x18 + 0x8, uxn_screen.height - 0x10, 0x3); |
|
162 |
+ for(i = 0; i < 0x40; i++) { |
|
163 |
+ draw_byte(u->ram[i], (i & 0x7) * 0x18 + 0x8, ((i >> 3) << 3) + 0x8, 0x2 + !!u->ram[i]); |
|
164 |
+ } |
|
165 |
+} |
|
166 |
+ |
|
132 | 167 |
Uint8 |
133 | 168 |
screen_dei(Uxn *u, Uint8 addr) |
134 | 169 |
{ |
... | ... |
@@ -21,6 +21,8 @@ extern int emu_resize(int width, int height); |
21 | 21 |
|
22 | 22 |
void screen_palette(Uint8 *addr); |
23 | 23 |
void screen_resize(Uint16 width, Uint16 height); |
24 |
+void screen_change(Uint16 x1, Uint16 y1, Uint16 x2, Uint16 y2); |
|
24 | 25 |
void screen_redraw(void); |
26 |
+void screen_debugger(Uxn *u); |
|
25 | 27 |
Uint8 screen_dei(Uxn *u, Uint8 addr); |
26 | 28 |
void screen_deo(Uint8 *ram, Uint8 *d, Uint8 port); |
... | ... |
@@ -208,9 +208,14 @@ emu_resize(int width, int height) |
208 | 208 |
} |
209 | 209 |
|
210 | 210 |
static void |
211 |
-emu_redraw(void) |
|
211 |
+emu_redraw(Uxn *u) |
|
212 | 212 |
{ |
213 |
- screen_redraw(); |
|
213 |
+ if(u->dev[0x0e]) { |
|
214 |
+ screen_change(0, 0, uxn_screen.width, uxn_screen.height); |
|
215 |
+ screen_redraw(); |
|
216 |
+ screen_debugger(u); |
|
217 |
+ } else |
|
218 |
+ screen_redraw(); |
|
214 | 219 |
if(SDL_UpdateTexture(emu_texture, NULL, uxn_screen.pixels, uxn_screen.width * sizeof(Uint32)) != 0) |
215 | 220 |
system_error("SDL_UpdateTexture", SDL_GetError()); |
216 | 221 |
SDL_RenderClear(emu_renderer); |
... | ... |
@@ -362,7 +367,7 @@ handle_events(Uxn *u) |
362 | 367 |
if(event.type == SDL_QUIT) |
363 | 368 |
return 0; |
364 | 369 |
else if(event.type == SDL_WINDOWEVENT && event.window.event == SDL_WINDOWEVENT_EXPOSED) |
365 |
- emu_redraw(); |
|
370 |
+ emu_redraw(u); |
|
366 | 371 |
else if(event.type == SDL_DROPFILE) { |
367 | 372 |
screen_resize(WIDTH, HEIGHT); |
368 | 373 |
emu_start(u, event.drop.file, 0); |
... | ... |
@@ -392,7 +397,7 @@ handle_events(Uxn *u) |
392 | 397 |
else if(event.key.keysym.sym == SDLK_F1) |
393 | 398 |
set_zoom(zoom == 3 ? 1 : zoom + 1, 1); |
394 | 399 |
else if(event.key.keysym.sym == SDLK_F2) |
395 |
- system_inspect(u); |
|
400 |
+ u->dev[0x0e] = !u->dev[0x0e]; |
|
396 | 401 |
else if(event.key.keysym.sym == SDLK_F3) |
397 | 402 |
capture_screen(); |
398 | 403 |
else if(event.key.keysym.sym == SDLK_F4) |
... | ... |
@@ -484,7 +489,7 @@ run(Uxn *u, char *rom) |
484 | 489 |
next_refresh = now + frame_interval; |
485 | 490 |
uxn_eval(u, screen_vector); |
486 | 491 |
if(uxn_screen.x2) |
487 |
- emu_redraw(); |
|
492 |
+ emu_redraw(u); |
|
488 | 493 |
} |
489 | 494 |
if(screen_vector || uxn_screen.x2) { |
490 | 495 |
Uint64 delay_ms = (next_refresh - now) / ms_interval; |