From 0aa4aeff41c6b7bc9f4d083c5b5ad071573d2db7 Mon Sep 17 00:00:00 2001 From: Devine Lu Linvega Date: Sat, 28 Jan 2023 18:38:37 -0800 Subject: [PATCH] Load rom in chunks of 64kb --- src/devices/file.c | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/src/devices/file.c b/src/devices/file.c index 549b963..19d80bd 100644 --- a/src/devices/file.c +++ b/src/devices/file.c @@ -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; }