From 689a9ff384b8891eed748abd998641a66f1a082a Mon Sep 17 00:00:00 2001 From: n-a-c-h <> Date: Tue, 7 Sep 2004 13:41:58 +0000 Subject: [PATCH] Fixed ROM enlargement by IPS when IPS is out of order. --- zsnes/src/patch.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/zsnes/src/patch.c b/zsnes/src/patch.c index d4150b2c..65e5f72b 100644 --- a/zsnes/src/patch.c +++ b/zsnes/src/patch.c @@ -140,7 +140,7 @@ void deinitPatch() void PatchUsingIPS() { unsigned char *ROM = (unsigned char *)romdata; - int location = 0, length = 0; + int location = 0, length = 0, last = 0; int sub = Header512 ? 512 : 0; IPSPatched = false; @@ -183,6 +183,7 @@ void PatchUsingIPS() { if (location >= maxromspace) { goto IPSDone; } ROM[location] = (unsigned char)IPSget(); + if (location > last) { last = location; } } else { @@ -202,6 +203,7 @@ void PatchUsingIPS() { if (location >= maxromspace) { goto IPSDone; } ROM[location] = newVal; + if (location > last) { last = location; } } } } @@ -217,10 +219,10 @@ void PatchUsingIPS() IPSPatched = true; //Adjust size values if the ROM was expanded - if (location > curromspace && location <= maxromspace) + if (last > curromspace) { - curromspace = location; - NumofBytes = location; + curromspace = last; + NumofBytes = last; NumofBanks = NumofBytes/32768; } @@ -234,7 +236,7 @@ void PatchUsingIPS() fclose(fp); } */ -} +} void findZipIPS(char *compressedfile) {