From e1b2f8f14b717edd693e1e07635af18284ff09d8 Mon Sep 17 00:00:00 2001 From: neauoire Date: Wed, 16 Aug 2023 14:31:40 -0700 Subject: [PATCH] Tightened screen debugger redraw --- src/devices/screen.c | 18 +++++++----------- src/devices/system.c | 6 ++++-- src/uxn.c | 2 +- 3 files changed, 12 insertions(+), 14 deletions(-) diff --git a/src/devices/screen.c b/src/devices/screen.c index ad6805a..1ce8c8e 100644 --- a/src/devices/screen.c +++ b/src/devices/screen.c @@ -85,6 +85,7 @@ draw_byte(Uint8 v, Uint16 x, Uint16 y, Uint8 color) { screen_blit(uxn_screen.fg, icons, v >> 4 << 3, x, y, color, 0, 0, 0); screen_blit(uxn_screen.fg, icons, (v & 0xf) << 3, x + 8, y, color, 0, 0, 0); + screen_change(x, y, x + 0x10, y + 0x8); } static void @@ -147,26 +148,21 @@ screen_resize(Uint16 width, Uint16 height) void screen_redraw(Uxn *u) { + int i, j, o, y; Uint8 *fg = uxn_screen.fg, *bg = uxn_screen.bg; + Uint16 w = uxn_screen.width, h = uxn_screen.height; + Uint16 x1 = uxn_screen.x1, y1 = uxn_screen.y1; + Uint16 x2 = uxn_screen.x2 > w ? w : uxn_screen.x2, y2 = uxn_screen.y2 > h ? h : uxn_screen.y2; Uint32 palette[16], *pixels = uxn_screen.pixels; - int i, x, y, w = uxn_screen.width, h = uxn_screen.height, x1, y1, x2, y2; - x1 = uxn_screen.x1; - y1 = uxn_screen.y1; - x2 = uxn_screen.x2 > w ? w : uxn_screen.x2; - y2 = uxn_screen.y2 > h ? h : uxn_screen.y2; uxn_screen.x1 = uxn_screen.y1 = 0xffff; uxn_screen.x2 = uxn_screen.y2 = 0; - if(u->dev[0x0e]) { - screen_change(0, 0, w, h); + if(u->dev[0x0e]) screen_debugger(u); - } for(i = 0; i < 16; i++) palette[i] = uxn_screen.palette[(i >> 2) ? (i >> 2) : (i & 3)]; for(y = y1; y < y2; y++) - for(x = x1; x < x2; x++) { - i = x + y * w; + for(o = y * w, i = x1 + o, j = x2 + o; i < j; i++) pixels[i] = palette[fg[i] << 2 | bg[i]]; - } } Uint8 diff --git a/src/devices/system.c b/src/devices/system.c index 389ee0c..ef90eea 100644 --- a/src/devices/system.c +++ b/src/devices/system.c @@ -114,10 +114,12 @@ system_init(Uxn *u, Uint8 *ram, char *rom) void system_deo(Uxn *u, Uint8 *d, Uint8 port) { + Uint8 *ram; + Uint16 addr; switch(port) { case 0x3: - Uint8 *ram = u->ram; - Uint16 addr = PEEK2(d + 2); + ram = u->ram; + addr = PEEK2(d + 2); if(ram[addr] == 0x1) { Uint16 i, length = PEEK2(ram + addr + 1); Uint16 a_page = PEEK2(ram + addr + 1 + 2), a_addr = PEEK2(ram + addr + 1 + 4); diff --git a/src/uxn.c b/src/uxn.c index d367181..9e307e8 100644 --- a/src/uxn.c +++ b/src/uxn.c @@ -46,7 +46,7 @@ uxn_eval(Uxn *u, Uint16 pc) switch(!(ins & 0x1f) ? (0 - (ins >> 5)) & 0xff : ins & 0x3f) { /* IMM */ case 0x00: /* BRK */ return 1; - case 0xff: /* JCI */ if(!s->dat[--s->ptr]) { pc += 2; break; } + case 0xff: /* JCI */ if(!s->dat[--s->ptr]) { pc += 2; break; } /* else fallthrough */ case 0xfe: /* JMI */ pc += PEEK2(ram + pc) + 2; break; case 0xfd: /* JSI */ SET(0, 2) PUT2(pc + 2) pc += PEEK2(ram + pc) + 2; break; case 0xfc: /* LITr */ case 0xfa: SET(0, 1) PUT1(ram[pc++]) break;