Removed masking in screen_deo

This commit is contained in:
Devine Lu Linvega 2024-07-01 07:58:09 -08:00
parent 44c501ba91
commit 223bc51e0e
6 changed files with 23 additions and 26 deletions

View File

@ -256,19 +256,19 @@ screen_dei(Uint8 addr)
} }
void void
screen_deo(Uint8 port) screen_deo(Uint8 addr)
{ {
switch(port) { switch(addr) {
case 0x3: screen_resize(PEEK2(&uxn.dev[0x22]), uxn_screen.height, uxn_screen.scale); return; case 0x23: 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 0x25: 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 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 0x8: case 0x28:
case 0x9: rX = (uxn.dev[0x28] << 8) | uxn.dev[0x29], rX = twos(rX); return; case 0x29: rX = (uxn.dev[0x28] << 8) | uxn.dev[0x29], rX = twos(rX); return;
case 0xa: case 0x2a:
case 0xb: rY = (uxn.dev[0x2a] << 8) | uxn.dev[0x2b], rY = twos(rY); return; case 0x2b: rY = (uxn.dev[0x2a] << 8) | uxn.dev[0x2b], rY = twos(rY); return;
case 0xc: case 0x2c:
case 0xd: rA = (uxn.dev[0x2c] << 8) | uxn.dev[0x2d]; return; case 0x2d: rA = (uxn.dev[0x2c] << 8) | uxn.dev[0x2d]; return;
case 0xe: { case 0x2e: {
Uint8 ctrl = uxn.dev[0x2e]; Uint8 ctrl = uxn.dev[0x2e];
Uint8 color = ctrl & 0x3; Uint8 color = ctrl & 0x3;
Uint8 *layer = ctrl & 0x40 ? uxn_screen.fg : uxn_screen.bg; Uint8 *layer = ctrl & 0x40 ? uxn_screen.fg : uxn_screen.bg;
@ -297,7 +297,7 @@ screen_deo(Uint8 port)
} }
return; return;
} }
case 0xf: { case 0x2f: {
Uint8 i; Uint8 i;
Uint8 ctrl = uxn.dev[0x2f]; Uint8 ctrl = uxn.dev[0x2f];
Uint8 twobpp = !!(ctrl & 0x80); Uint8 twobpp = !!(ctrl & 0x80);

View File

@ -26,6 +26,6 @@ void screen_resize(Uint16 width, Uint16 height, int scale);
void screen_redraw(); void screen_redraw();
Uint8 screen_dei(Uint8 addr); 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) #define twos(v) (v & 0x8000 ? (int)v - 0x10000 : (int)v)

View File

@ -101,12 +101,11 @@ system_dei(Uint8 addr)
} }
void void
system_deo(Uint8 port) system_deo(Uint8 addr)
{ {
Uint16 addr; switch(addr) {
switch(port) {
case 0x3: case 0x3:
addr = PEEK2(uxn.dev + 2); Uint16 addr = PEEK2(uxn.dev + 2);
if(uxn.ram[addr] == 0x0) { if(uxn.ram[addr] == 0x0) {
Uint8 value = uxn.ram[addr + 7]; Uint8 value = uxn.ram[addr + 7];
Uint16 i, length = PEEK2(uxn.ram + addr + 1); Uint16 i, length = PEEK2(uxn.ram + addr + 1);

View File

@ -17,6 +17,6 @@ int system_error(char *msg, const char *err);
int system_boot(Uint8 *ram, char *rom); int system_boot(Uint8 *ram, char *rom);
Uint8 system_dei(Uint8 addr); Uint8 system_dei(Uint8 addr);
void system_deo(Uint8 port); void system_deo(Uint8 addr);
extern char *boot_rom; extern char *boot_rom;

View File

@ -59,16 +59,15 @@ emu_dei(Uint8 addr)
void void
emu_deo(Uint8 addr, Uint8 value) emu_deo(Uint8 addr, Uint8 value)
{ {
Uint8 p = addr & 0x0f, d = addr & 0xf0;
uxn.dev[addr] = value; uxn.dev[addr] = value;
switch(d) { switch(addr & 0xf0) {
case 0x00: case 0x00:
system_deo(p); system_deo(addr);
if(p > 0x7 && p < 0xe) if(addr > 0x7 && addr < 0xe)
screen_palette(); screen_palette();
break; break;
case 0x10: console_deo(addr); 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 0xa0: file_deo(addr); break;
case 0xb0: file_deo(addr); break; case 0xb0: file_deo(addr); break;
} }

View File

@ -34,10 +34,9 @@ emu_dei(Uint8 addr)
void void
emu_deo(Uint8 addr, Uint8 value) emu_deo(Uint8 addr, Uint8 value)
{ {
Uint8 p = addr & 0x0f;
uxn.dev[addr] = value; uxn.dev[addr] = value;
switch(addr & 0xf0) { switch(addr & 0xf0) {
case 0x00: system_deo(p); break; case 0x00: system_deo(addr); break;
case 0x10: console_deo(addr); break; case 0x10: console_deo(addr); break;
case 0xa0: file_deo(addr); break; case 0xa0: file_deo(addr); break;
case 0xb0: file_deo(addr); break; case 0xb0: file_deo(addr); break;