Added extra Expansion commands

This commit is contained in:
Devine Lu Linvega 2024-03-18 10:44:19 -07:00
parent 5d3cf8b614
commit 086b1d9a47
3 changed files with 23 additions and 9 deletions

View File

@ -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];

View File

@ -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 */

View File

@ -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"))