From 25db1227eea234b8cbefaa93ba52fb1494235381 Mon Sep 17 00:00:00 2001 From: John-Paul Gignac Date: Fri, 11 Oct 2019 20:15:51 -0400 Subject: [PATCH] Make load routine wrap into next RAM bank (#165) --- loadsave.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/loadsave.c b/loadsave.c index 93c34ab4..19c2b772 100644 --- a/loadsave.c +++ b/loadsave.c @@ -170,7 +170,15 @@ LOAD() // IO addresses } else if(start < 0xc000) { // banked RAM - bytes_read = fread(RAM + ((uint16_t)memory_get_ram_bank() << 13) + start, 1, 0xc000 - start, f); + while(1) { + size_t len = 0xc000 - start; + bytes_read = fread(RAM + ((uint16_t)memory_get_ram_bank() << 13) + start, 1, len, f); + if(bytes_read < len) break; + + // Wrap into the next bank + start = 0xa000; + memory_set_ram_bank(1 + memory_get_ram_bank()); + } } else { // ROM }