diff --git a/src/devices/system.c b/src/devices/system.c index 1941afe..edd281e 100644 --- a/src/devices/system.c +++ b/src/devices/system.c @@ -109,15 +109,29 @@ system_deo(Uxn *u, Uint8 *d, Uint8 port) case 0x3: ram = u->ram; addr = PEEK2(d + 2); - if(ram[addr] == 0x1) { - Uint8 *cmd_addr = ram + addr + 1; - Uint16 i, length = PEEK2(cmd_addr); - Uint16 a_page = PEEK2(cmd_addr + 2), a_addr = PEEK2(cmd_addr + 4); - Uint16 b_page = PEEK2(cmd_addr + 6), b_addr = PEEK2(cmd_addr + 8); - int src = (a_page % RAM_PAGES) << 0x10, dst = (b_page % RAM_PAGES) << 0x10; + 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); + 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); + 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); + 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)]; + } else + fprintf(stderr, "Unknown Expansion Command 0x%02x\n", ram[addr]); break; case 0x4: u->wst.ptr = d[4]; diff --git a/src/uxncli.c b/src/uxncli.c index f55e23d..4e8e908 100755 --- a/src/uxncli.c +++ b/src/uxncli.c @@ -51,7 +51,7 @@ main(int argc, char **argv) if(i == argc) return system_error("usage:", "uxncli [-v] file.rom [args..]"); if(argv[i][0] == '-' && argv[i][1] == 'v') - return system_error("Uxncli - Varvara Emulator(CLI)", "4 Mar 2024."); + return system_error("Uxncli - Varvara Emulator(CLI)", "18 Mar 2024."); if(!system_init(&u, (Uint8 *)calloc(0x10000 * RAM_PAGES, sizeof(Uint8)), argv[i++])) return system_error("Init", "Failed to initialize uxn."); /* eval */ diff --git a/src/uxnemu.c b/src/uxnemu.c index c5233f8..a91a5c4 100644 --- a/src/uxnemu.c +++ b/src/uxnemu.c @@ -501,7 +501,7 @@ main(int argc, char **argv) /* flags */ if(argc > 1 && argv[i][0] == '-') { if(!strcmp(argv[i], "-v")) - return system_error("Uxnemu - Varvara Emulator(GUI)", "4 Mar 2024."); + return system_error("Uxnemu - Varvara Emulator(GUI)", "18 Mar 2024."); else if(!strcmp(argv[i], "-2x")) set_zoom(2, 0); else if(!strcmp(argv[i], "-3x"))