override sandbox from load_rom

This commit is contained in:
aabacchus 2022-06-21 00:01:04 +01:00 committed by Devine Lu Linvega
parent d9cdf192a8
commit 387d802819
1 changed files with 5 additions and 4 deletions

View File

@ -138,7 +138,7 @@ file_check_sandbox(UxnFile *c)
} }
static Uint16 static Uint16
file_init(UxnFile *c, char *filename, size_t max_len) file_init(UxnFile *c, char *filename, size_t max_len, int override_sandbox)
{ {
char *p = c->current_filename; char *p = c->current_filename;
size_t len = sizeof(c->current_filename); size_t len = sizeof(c->current_filename);
@ -146,6 +146,7 @@ file_init(UxnFile *c, char *filename, size_t max_len)
if(len > max_len) len = max_len; if(len > max_len) len = max_len;
while(len) { while(len) {
if((*p++ = *filename++) == '\0') { if((*p++ = *filename++) == '\0') {
if(!override_sandbox) /* override sandbox for loading roms */
file_check_sandbox(c); file_check_sandbox(c);
return 0; return 0;
} }
@ -230,7 +231,7 @@ file_deo(Uint8 id, Uint8 *ram, Uint8 *d, Uint8 port)
break; break;
case 0x9: case 0x9:
PEKDEV(addr, 0x8); PEKDEV(addr, 0x8);
res = file_init(c, (char *)&ram[addr], 0x10000 - addr); res = file_init(c, (char *)&ram[addr], 0x10000 - addr, 0);
POKDEV(0x2, res); POKDEV(0x2, res);
break; break;
case 0xd: case 0xd:
@ -273,7 +274,7 @@ int
load_rom(Uxn *u, char *filename) load_rom(Uxn *u, char *filename)
{ {
int ret; int ret;
file_init(uxn_file, filename, strlen(filename) + 1); file_init(uxn_file, filename, strlen(filename) + 1, 1);
ret = file_read(uxn_file, &u->ram[PAGE_PROGRAM], 0x10000 - PAGE_PROGRAM); ret = file_read(uxn_file, &u->ram[PAGE_PROGRAM], 0x10000 - PAGE_PROGRAM);
reset(uxn_file); reset(uxn_file);
return ret; return ret;