commit 29823e5bd1514098781876674848279cdd6f4303
parent 22af2ba9c307ccb9b09d7d1d1c94334c8196ff21
Author: Devine Lu Linvega <aliceffekt@gmail.com>
Date: Thu, 4 Jan 2024 09:44:46 -0800
(file) Removed PEEK2 macros
Diffstat:
3 files changed, 31 insertions(+), 29 deletions(-)
diff --git a/src/devices/file.c b/src/devices/file.c
@@ -242,46 +242,48 @@ file_delete(UxnFile *c)
return c->outside_sandbox ? 0 : unlink(c->current_filename);
}
+/* file registers */
+
+static Uint16 rL;
+
/* IO */
void
file_deo(Uint8 id, Uint8 *ram, Uint8 *d, Uint8 port)
{
UxnFile *c = &uxn_file[id];
- Uint16 addr, len, res;
+ Uint16 addr, res;
switch(port) {
case 0x5:
- addr = PEEK2(d + 0x4);
- len = PEEK2(d + 0xa);
- if(len > 0x10000 - addr)
- len = 0x10000 - addr;
- res = file_stat(c, &ram[addr], len);
- POKE2(d + 0x2, res);
- break;
+ addr = (d[0x4] << 8) | d[0x5];
+ if(rL > 0x10000 - addr) rL = 0x10000 - addr;
+ res = file_stat(c, &ram[addr], rL);
+ d[0x2] = res >> 8, d[0x3] = res;
+ return;
case 0x6:
res = file_delete(c);
- POKE2(d + 0x2, res);
- break;
+ d[0x2] = res >> 8, d[0x3] = res;
+ return;
case 0x9:
- addr = PEEK2(d + 0x8);
+ addr = (d[0x8] << 8) | d[0x9];
res = file_init(c, (char *)&ram[addr], 0x10000 - addr, 0);
- POKE2(d + 0x2, res);
- break;
+ d[0x2] = res >> 8, d[0x3] = res;
+ return;
+ case 0xa:
+ case 0xb:
+ rL = (d[0xa] << 8) | d[0xb];
+ return;
case 0xd:
- addr = PEEK2(d + 0xc);
- len = PEEK2(d + 0xa);
- if(len > 0x10000 - addr)
- len = 0x10000 - addr;
- res = file_read(c, &ram[addr], len);
- POKE2(d + 0x2, res);
- break;
+ addr = (d[0xc] << 8) | d[0xd];
+ if(rL > 0x10000 - addr) rL = 0x10000 - addr;
+ res = file_read(c, &ram[addr], rL);
+ d[0x2] = res >> 8, d[0x3] = res;
+ return;
case 0xf:
- addr = PEEK2(d + 0xe);
- len = PEEK2(d + 0xa);
- if(len > 0x10000 - addr)
- len = 0x10000 - addr;
- res = file_write(c, &ram[addr], len, d[0x7]);
- POKE2(d + 0x2, res);
- break;
+ addr = (d[0xe] << 8) | d[0xf];
+ if(rL > 0x10000 - addr) rL = 0x10000 - addr;
+ res = file_write(c, &ram[addr], rL, d[0x7]);
+ d[0x2] = res >> 8, d[0x3] = res;
+ return;
}
}
diff --git 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)", "2 Jan 2024.");
+ return system_error("Uxncli - Varvara Emulator(CLI)", "4 Jan 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
@@ -497,7 +497,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)", "3 Jan 2024.");
+ return system_error("Uxnemu - Varvara Emulator(GUI)", "4 Jan 2024.");
else if(!strcmp(argv[i], "-2x"))
set_zoom(2, 0);
else if(!strcmp(argv[i], "-3x"))