uxn

Varvara Ordinator, written in ANSI C(SDL2)
git clone https://git.eamoncaddigan.net/uxn.git
Log | Files | Refs | README | LICENSE

commit 0aa4aeff41c6b7bc9f4d083c5b5ad071573d2db7
parent 390ae8138aa2363620a469207adda38a920e6b53
Author: Devine Lu Linvega <aliceffekt@gmail.com>
Date:   Sat, 28 Jan 2023 18:38:37 -0800

Load rom in chunks of 64kb

Diffstat:
Msrc/devices/file.c | 14+++++++++-----
1 file changed, 9 insertions(+), 5 deletions(-)

diff --git 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; }