Load rom in chunks of 64kb

This commit is contained in:
Devine Lu Linvega 2023-01-28 18:38:37 -08:00
parent 390ae8138a
commit 0aa4aeff41
1 changed files with 9 additions and 5 deletions

View File

@ -286,9 +286,13 @@ file_dei(Uint8 id, Uint8 *d, Uint8 port)
int
load_rom(Uxn *u, char *filename)
{
int ret;
file_init(uxn_file, filename, strlen(filename) + 1, 1);
ret = file_read(uxn_file, &u->ram[PAGE_PROGRAM], 0x100000 - PAGE_PROGRAM);
reset(uxn_file);
return ret;
int l, i = 0;
FILE *f = fopen(filename, "rb");
if(!f)
return 0;
l = fread(&u->ram[PAGE_PROGRAM], 1, 0x10000 - PAGE_PROGRAM, f);
while(l && ++i < 15)
l = fread(u->ram + 0x10000 * i, 1, 0x10000, f);
fclose(f);
return 1;
}