(file) Removed PEEK2 macros

This commit is contained in:
Devine Lu Linvega 2024-01-04 09:44:46 -08:00
parent 22af2ba9c3
commit 29823e5bd1
3 changed files with 31 additions and 29 deletions

View File

@ -242,46 +242,48 @@ file_delete(UxnFile *c)
return c->outside_sandbox ? 0 : unlink(c->current_filename); return c->outside_sandbox ? 0 : unlink(c->current_filename);
} }
/* file registers */
static Uint16 rL;
/* IO */ /* IO */
void void
file_deo(Uint8 id, Uint8 *ram, Uint8 *d, Uint8 port) file_deo(Uint8 id, Uint8 *ram, Uint8 *d, Uint8 port)
{ {
UxnFile *c = &uxn_file[id]; UxnFile *c = &uxn_file[id];
Uint16 addr, len, res; Uint16 addr, res;
switch(port) { switch(port) {
case 0x5: case 0x5:
addr = PEEK2(d + 0x4); addr = (d[0x4] << 8) | d[0x5];
len = PEEK2(d + 0xa); if(rL > 0x10000 - addr) rL = 0x10000 - addr;
if(len > 0x10000 - addr) res = file_stat(c, &ram[addr], rL);
len = 0x10000 - addr; d[0x2] = res >> 8, d[0x3] = res;
res = file_stat(c, &ram[addr], len); return;
POKE2(d + 0x2, res);
break;
case 0x6: case 0x6:
res = file_delete(c); res = file_delete(c);
POKE2(d + 0x2, res); d[0x2] = res >> 8, d[0x3] = res;
break; return;
case 0x9: case 0x9:
addr = PEEK2(d + 0x8); addr = (d[0x8] << 8) | d[0x9];
res = file_init(c, (char *)&ram[addr], 0x10000 - addr, 0); res = file_init(c, (char *)&ram[addr], 0x10000 - addr, 0);
POKE2(d + 0x2, res); d[0x2] = res >> 8, d[0x3] = res;
break; return;
case 0xa:
case 0xb:
rL = (d[0xa] << 8) | d[0xb];
return;
case 0xd: case 0xd:
addr = PEEK2(d + 0xc); addr = (d[0xc] << 8) | d[0xd];
len = PEEK2(d + 0xa); if(rL > 0x10000 - addr) rL = 0x10000 - addr;
if(len > 0x10000 - addr) res = file_read(c, &ram[addr], rL);
len = 0x10000 - addr; d[0x2] = res >> 8, d[0x3] = res;
res = file_read(c, &ram[addr], len); return;
POKE2(d + 0x2, res);
break;
case 0xf: case 0xf:
addr = PEEK2(d + 0xe); addr = (d[0xe] << 8) | d[0xf];
len = PEEK2(d + 0xa); if(rL > 0x10000 - addr) rL = 0x10000 - addr;
if(len > 0x10000 - addr) res = file_write(c, &ram[addr], rL, d[0x7]);
len = 0x10000 - addr; d[0x2] = res >> 8, d[0x3] = res;
res = file_write(c, &ram[addr], len, d[0x7]); return;
POKE2(d + 0x2, res);
break;
} }
} }

View File

@ -51,7 +51,7 @@ main(int argc, char **argv)
if(i == argc) if(i == argc)
return system_error("usage:", "uxncli [-v] file.rom [args..]"); return system_error("usage:", "uxncli [-v] file.rom [args..]");
if(argv[i][0] == '-' && argv[i][1] == 'v') 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++])) if(!system_init(&u, (Uint8 *)calloc(0x10000 * RAM_PAGES, sizeof(Uint8)), argv[i++]))
return system_error("Init", "Failed to initialize uxn."); return system_error("Init", "Failed to initialize uxn.");
/* eval */ /* eval */

View File

@ -497,7 +497,7 @@ main(int argc, char **argv)
/* flags */ /* flags */
if(argc > 1 && argv[i][0] == '-') { if(argc > 1 && argv[i][0] == '-') {
if(!strcmp(argv[i], "-v")) 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")) else if(!strcmp(argv[i], "-2x"))
set_zoom(2, 0); set_zoom(2, 0);
else if(!strcmp(argv[i], "-3x")) else if(!strcmp(argv[i], "-3x"))