From 223bc51e0e331abc296bb4f6884e0a8bf37ca040 Mon Sep 17 00:00:00 2001 From: Devine Lu Linvega Date: Mon, 1 Jul 2024 07:58:09 -0800 Subject: [PATCH] Removed masking in screen_deo --- src/devices/screen.c | 26 +++++++++++++------------- src/devices/screen.h | 2 +- src/devices/system.c | 7 +++---- src/devices/system.h | 2 +- src/uxn11.c | 9 ++++----- src/uxncli.c | 3 +-- 6 files changed, 23 insertions(+), 26 deletions(-) diff --git a/src/devices/screen.c b/src/devices/screen.c index 9c4b925..dc9260a 100644 --- a/src/devices/screen.c +++ b/src/devices/screen.c @@ -256,19 +256,19 @@ screen_dei(Uint8 addr) } void -screen_deo(Uint8 port) +screen_deo(Uint8 addr) { - switch(port) { - case 0x3: screen_resize(PEEK2(&uxn.dev[0x22]), uxn_screen.height, uxn_screen.scale); return; - case 0x5: screen_resize(uxn_screen.width, PEEK2(&uxn.dev[0x24]), uxn_screen.scale); return; - case 0x6: rMX = uxn.dev[0x26] & 0x1, rMY = uxn.dev[0x26] & 0x2, rMA = uxn.dev[0x26] & 0x4, rML = uxn.dev[0x26] >> 4, rDX = rMX << 3, rDY = rMY << 2; return; - case 0x8: - case 0x9: rX = (uxn.dev[0x28] << 8) | uxn.dev[0x29], rX = twos(rX); return; - case 0xa: - case 0xb: rY = (uxn.dev[0x2a] << 8) | uxn.dev[0x2b], rY = twos(rY); return; - case 0xc: - case 0xd: rA = (uxn.dev[0x2c] << 8) | uxn.dev[0x2d]; return; - case 0xe: { + switch(addr) { + case 0x23: screen_resize(PEEK2(&uxn.dev[0x22]), uxn_screen.height, uxn_screen.scale); return; + case 0x25: screen_resize(uxn_screen.width, PEEK2(&uxn.dev[0x24]), uxn_screen.scale); return; + case 0x26: rMX = uxn.dev[0x26] & 0x1, rMY = uxn.dev[0x26] & 0x2, rMA = uxn.dev[0x26] & 0x4, rML = uxn.dev[0x26] >> 4, rDX = rMX << 3, rDY = rMY << 2; return; + case 0x28: + case 0x29: rX = (uxn.dev[0x28] << 8) | uxn.dev[0x29], rX = twos(rX); return; + case 0x2a: + case 0x2b: rY = (uxn.dev[0x2a] << 8) | uxn.dev[0x2b], rY = twos(rY); return; + case 0x2c: + case 0x2d: rA = (uxn.dev[0x2c] << 8) | uxn.dev[0x2d]; return; + case 0x2e: { Uint8 ctrl = uxn.dev[0x2e]; Uint8 color = ctrl & 0x3; Uint8 *layer = ctrl & 0x40 ? uxn_screen.fg : uxn_screen.bg; @@ -297,7 +297,7 @@ screen_deo(Uint8 port) } return; } - case 0xf: { + case 0x2f: { Uint8 i; Uint8 ctrl = uxn.dev[0x2f]; Uint8 twobpp = !!(ctrl & 0x80); diff --git a/src/devices/screen.h b/src/devices/screen.h index 66ac7b1..2ad82d5 100644 --- a/src/devices/screen.h +++ b/src/devices/screen.h @@ -26,6 +26,6 @@ void screen_resize(Uint16 width, Uint16 height, int scale); void screen_redraw(); Uint8 screen_dei(Uint8 addr); -void screen_deo(Uint8 port); +void screen_deo(Uint8 addr); #define twos(v) (v & 0x8000 ? (int)v - 0x10000 : (int)v) diff --git a/src/devices/system.c b/src/devices/system.c index acb2086..277437b 100644 --- a/src/devices/system.c +++ b/src/devices/system.c @@ -101,12 +101,11 @@ system_dei(Uint8 addr) } void -system_deo(Uint8 port) +system_deo(Uint8 addr) { - Uint16 addr; - switch(port) { + switch(addr) { case 0x3: - addr = PEEK2(uxn.dev + 2); + Uint16 addr = PEEK2(uxn.dev + 2); if(uxn.ram[addr] == 0x0) { Uint8 value = uxn.ram[addr + 7]; Uint16 i, length = PEEK2(uxn.ram + addr + 1); diff --git a/src/devices/system.h b/src/devices/system.h index 60440fb..f9f0704 100644 --- a/src/devices/system.h +++ b/src/devices/system.h @@ -17,6 +17,6 @@ int system_error(char *msg, const char *err); int system_boot(Uint8 *ram, char *rom); Uint8 system_dei(Uint8 addr); -void system_deo(Uint8 port); +void system_deo(Uint8 addr); extern char *boot_rom; \ No newline at end of file diff --git a/src/uxn11.c b/src/uxn11.c index c3fa990..bb1d95b 100644 --- a/src/uxn11.c +++ b/src/uxn11.c @@ -59,16 +59,15 @@ emu_dei(Uint8 addr) void emu_deo(Uint8 addr, Uint8 value) { - Uint8 p = addr & 0x0f, d = addr & 0xf0; uxn.dev[addr] = value; - switch(d) { + switch(addr & 0xf0) { case 0x00: - system_deo(p); - if(p > 0x7 && p < 0xe) + system_deo(addr); + if(addr > 0x7 && addr < 0xe) screen_palette(); break; case 0x10: console_deo(addr); break; - case 0x20: screen_deo(p); break; + case 0x20: screen_deo(addr); break; case 0xa0: file_deo(addr); break; case 0xb0: file_deo(addr); break; } diff --git a/src/uxncli.c b/src/uxncli.c index e685c96..1cdf2de 100644 --- a/src/uxncli.c +++ b/src/uxncli.c @@ -34,10 +34,9 @@ emu_dei(Uint8 addr) void emu_deo(Uint8 addr, Uint8 value) { - Uint8 p = addr & 0x0f; uxn.dev[addr] = value; switch(addr & 0xf0) { - case 0x00: system_deo(p); break; + case 0x00: system_deo(addr); break; case 0x10: console_deo(addr); break; case 0xa0: file_deo(addr); break; case 0xb0: file_deo(addr); break;