diff --git a/src/devices/file.c b/src/devices/file.c index 9cc4b47..29246af 100644 --- a/src/devices/file.c +++ b/src/devices/file.c @@ -140,19 +140,20 @@ retry_realpath(const char *file_name) return NULL; } if(notdriveroot(file_name)) { + /* TODO: use a macro instead of '/' for absolute path first character so that other systems can work */ /* if a relative path, prepend cwd */ getcwd(p, sizeof(p)); if(strlen(p) + strlen(DIR_SEP_STR) + fnlen >= PATH_MAX) { errno = ENAMETOOLONG; return NULL; } - strcat(p, DIR_SEP_STR); + strcat(p, DIR_SEP_STR); /* TODO: use a macro instead of '/' for the path delimiter */ } strcat(p, file_name); while((r = realpath(p, NULL)) == NULL) { if(errno != ENOENT) return NULL; - x = strrchr(p, DIR_SEP_CHAR); + x = strrchr(p, DIR_SEP_CHAR); /* TODO: path delimiter macro */ if(x) *x = '\0'; else diff --git a/src/devices/system.c b/src/devices/system.c index 192d1b0..e41daa4 100644 --- a/src/devices/system.c +++ b/src/devices/system.c @@ -14,8 +14,6 @@ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE. */ -#define PAGE_INDEX(bank, addr) ((bank) * PAGE_SIZE + ((addr) & PAGE_MASK)) - char *boot_path; static void @@ -86,37 +84,26 @@ system_deo(Uint8 port) { switch(port) { case 0x3: { + Uint16 value; Uint16 addr = PEEK2(uxn.dev + 2); Uint8 *aptr = uxn.ram + addr; Uint16 length = PEEK2(aptr + 1); if(uxn.ram[addr] == 0x0) { - unsigned int src_bank = PEEK2(aptr + 3); - unsigned int src_addr = PEEK2(aptr + 5); - Uint16 value = uxn.ram[addr + 7]; - if(src_bank < RAM_PAGES) { - unsigned int a = src_addr; - unsigned int b = a + length; - for(; a < b; uxn.ram[PAGE_INDEX(src_bank, a++)] = value); - } + unsigned int a = PEEK2(aptr + 3) * PAGE_SIZE + PEEK2(aptr + 5); + unsigned int b = a + length; + value = uxn.ram[addr + 7]; + for(; a < b; uxn.ram[a++] = value); } else if(uxn.ram[addr] == 0x1) { - unsigned int src_bank = PEEK2(aptr + 3); - unsigned int src_addr = PEEK2(aptr + 5); - unsigned int dst_bank = PEEK2(aptr + 7); - unsigned int dst_addr = PEEK2(aptr + 9); - if(src_bank < RAM_PAGES && dst_bank < RAM_PAGES) { - unsigned int src_last = src_addr + length; - for(; src_addr < src_last; uxn.ram[PAGE_INDEX(dst_bank, dst_addr++)] = uxn.ram[PAGE_INDEX(src_bank, src_addr++)]); - } + unsigned int a = PEEK2(aptr + 3) * PAGE_SIZE + PEEK2(aptr + 5); + unsigned int b = a + length; + unsigned int c = PEEK2(aptr + 7) * PAGE_SIZE + PEEK2(aptr + 9); + for(; a < b; uxn.ram[c++] = uxn.ram[a++]); } else if(uxn.ram[addr] == 0x2) { - unsigned int src_bank = PEEK2(aptr + 3); - unsigned int src_addr = PEEK2(aptr + 5); - unsigned int dst_bank = PEEK2(aptr + 7); - unsigned int dst_addr = PEEK2(aptr + 9); - if(src_bank < RAM_PAGES && dst_bank < RAM_PAGES) { - unsigned int src_last = src_addr + length; - unsigned int dst_last = dst_addr + length; - for(; src_last > src_addr; uxn.ram[PAGE_INDEX(dst_bank, --dst_last)] = uxn.ram[PAGE_INDEX(src_bank, --src_last)]); - } + unsigned int a = PEEK2(aptr + 3) * PAGE_SIZE + PEEK2(aptr + 5); + unsigned int b = a + length; + unsigned int c = PEEK2(aptr + 7) * PAGE_SIZE + PEEK2(aptr + 9); + unsigned int d = c + length; + for(; b >= a; uxn.ram[--d] = uxn.ram[--b]); } else fprintf(stderr, "Unknown Expansion Command 0x%02x\n", uxn.ram[addr]); break; diff --git a/src/uxn.h b/src/uxn.h index a8b174d..1b7e660 100644 --- a/src/uxn.h +++ b/src/uxn.h @@ -19,7 +19,6 @@ WITH REGARD TO THIS SOFTWARE. #define STEP_MAX 0x80000000 #define PAGE_PROGRAM 0x0100 #define PAGE_SIZE 0x10000 -#define PAGE_MASK 0xffff typedef unsigned char Uint8; typedef signed char Sint8; diff --git a/src/uxnemu.c b/src/uxnemu.c index d70f82a..08d56b8 100644 --- a/src/uxnemu.c +++ b/src/uxnemu.c @@ -469,7 +469,7 @@ main(int argc, char **argv) /* flags */ if(argc > 1 && argv[i][0] == '-') { if(!strcmp(argv[i], "-v")) - return system_error("Uxn(gui) - Varvara Emulator", "4 Apr 2025."); + return system_error("Uxn(gui) - Varvara Emulator", "27 Jun 2025."); else if(!strcmp(argv[i], "-2x")) set_zoom(2, 0); else if(!strcmp(argv[i], "-3x"))