summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid McMackins II <contact@mcmackins.org>2016-05-30 08:26:45 -0500
committerDavid McMackins II <contact@mcmackins.org>2016-05-30 08:26:45 -0500
commit2eb3d8406d2808305fba468a0f977cc42386fcbf (patch)
treee13fc57ea69f57f36e11435951b7076d6d0ec9a8
parent3bb9af80cee29e083762250df7e6e3e424abe375 (diff)
Always ensure unused ROM is filled with STOP
-rw-r--r--gbromgen.py20
1 files changed, 7 insertions, 13 deletions
diff --git a/gbromgen.py b/gbromgen.py
index 509fba2..d346927 100644
--- a/gbromgen.py
+++ b/gbromgen.py
@@ -159,21 +159,15 @@ def print_bank_info(n, written, verbose=False):
print(__title__ + ':', s)
def flush_bank(outfile, written):
+ if (ROMBANK_SIZE - written) % 2 != 0:
+ outfile.write(b'\x00')
+ written += 1
+
while written < ROMBANK_SIZE:
# This block fills the unused parts of the ROM bank with failure code.
- # It fills all spaces of 2 bytes with a STOP command, which will kill
- # the device. Ideally, there are an even number of bytes so that all
- # slack space is taken up by this command. In the event of an odd
- # number, a RET command is inserted in attempt to return execution to
- # some legitimate position in the game code. This way, the chance of an
- # accidental jump which causes data corruption is minimized. Better to
- # completely halt execution than to corrupt a save file.
- if written != ROMBANK_SIZE - 1:
- outfile.write(b'\x10\x00')
- written += 2
- else:
- outfile.write(b'\xC9')
- written += 1
+ # It fills all spaces of 2 bytes with a STOP command.
+ outfile.write(b'\x10\x00')
+ written += 2
return written