Removed indirection in system_deo

This commit is contained in:
Devine Lu Linvega 2024-06-29 11:16:15 -08:00
parent f785d15d65
commit d49514e257
4 changed files with 22 additions and 24 deletions

View File

@ -101,43 +101,41 @@ system_dei(Uint8 addr)
}
void
system_deo(Uxn *u, Uint8 *d, Uint8 port)
system_deo(Uint8 *d, Uint8 port)
{
Uint8 *ram;
Uint16 addr;
switch(port) {
case 0x3:
ram = u->ram;
addr = PEEK2(d + 2);
if(ram[addr] == 0x0) {
Uint8 value = ram[addr + 7];
Uint16 i, length = PEEK2(ram + addr + 1);
Uint16 dst_page = PEEK2(ram + addr + 3), dst_addr = PEEK2(ram + addr + 5);
if(uxn.ram[addr] == 0x0) {
Uint8 value = uxn.ram[addr + 7];
Uint16 i, length = PEEK2(uxn.ram + addr + 1);
Uint16 dst_page = PEEK2(uxn.ram + addr + 3), dst_addr = PEEK2(uxn.ram + addr + 5);
int dst = (dst_page % RAM_PAGES) * 0x10000;
for(i = 0; i < length; i++)
ram[dst + (Uint16)(dst_addr + i)] = value;
} else if(ram[addr] == 0x1) {
Uint16 i, length = PEEK2(ram + addr + 1);
Uint16 a_page = PEEK2(ram + addr + 3), a_addr = PEEK2(ram + addr + 5);
Uint16 b_page = PEEK2(ram + addr + 7), b_addr = PEEK2(ram + addr + 9);
uxn.ram[dst + (Uint16)(dst_addr + i)] = value;
} else if(uxn.ram[addr] == 0x1) {
Uint16 i, length = PEEK2(uxn.ram + addr + 1);
Uint16 a_page = PEEK2(uxn.ram + addr + 3), a_addr = PEEK2(uxn.ram + addr + 5);
Uint16 b_page = PEEK2(uxn.ram + addr + 7), b_addr = PEEK2(uxn.ram + addr + 9);
int src = (a_page % RAM_PAGES) * 0x10000, dst = (b_page % RAM_PAGES) * 0x10000;
for(i = 0; i < length; i++)
ram[dst + (Uint16)(b_addr + i)] = ram[src + (Uint16)(a_addr + i)];
} else if(ram[addr] == 0x2) {
Uint16 i, length = PEEK2(ram + addr + 1);
Uint16 a_page = PEEK2(ram + addr + 3), a_addr = PEEK2(ram + addr + 5);
Uint16 b_page = PEEK2(ram + addr + 7), b_addr = PEEK2(ram + addr + 9);
uxn.ram[dst + (Uint16)(b_addr + i)] = uxn.ram[src + (Uint16)(a_addr + i)];
} else if(uxn.ram[addr] == 0x2) {
Uint16 i, length = PEEK2(uxn.ram + addr + 1);
Uint16 a_page = PEEK2(uxn.ram + addr + 3), a_addr = PEEK2(uxn.ram + addr + 5);
Uint16 b_page = PEEK2(uxn.ram + addr + 7), b_addr = PEEK2(uxn.ram + addr + 9);
int src = (a_page % RAM_PAGES) * 0x10000, dst = (b_page % RAM_PAGES) * 0x10000;
for(i = length - 1; i != 0xffff; i--)
ram[dst + (Uint16)(b_addr + i)] = ram[src + (Uint16)(a_addr + i)];
uxn.ram[dst + (Uint16)(b_addr + i)] = uxn.ram[src + (Uint16)(a_addr + i)];
} else
fprintf(stderr, "Unknown Expansion Command 0x%02x\n", ram[addr]);
fprintf(stderr, "Unknown Expansion Command 0x%02x\n", uxn.ram[addr]);
break;
case 0x4:
u->wst.ptr = d[4];
uxn.wst.ptr = d[4];
break;
case 0x5:
u->rst.ptr = d[5];
uxn.rst.ptr = d[5];
break;
case 0xe:
system_inspect();

View File

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

View File

@ -63,7 +63,7 @@ emu_deo(Uint8 addr, Uint8 value)
uxn.dev[addr] = value;
switch(d) {
case 0x00:
system_deo(&uxn, &uxn.dev[d], p);
system_deo(&uxn.dev[d], p);
if(p > 0x7 && p < 0xe)
screen_palette(&uxn.dev[0x8]);
break;

View File

@ -37,7 +37,7 @@ emu_deo(Uint8 addr, Uint8 value)
Uint8 p = addr & 0x0f, d = addr & 0xf0;
uxn.dev[addr] = value;
switch(d) {
case 0x00: system_deo(&uxn, &uxn.dev[d], p); break;
case 0x00: system_deo(&uxn.dev[d], p); break;
case 0x10: console_deo(&uxn, &uxn.dev[d], p); break;
case 0xa0: file_deo(0, uxn.ram, &uxn.dev[d], p); break;
case 0xb0: file_deo(1, uxn.ram, &uxn.dev[d], p); break;