From 431ee8e37d177abd03b836b12fbfc087b4c3ba6f Mon Sep 17 00:00:00 2001 From: Connor Olding Date: Fri, 10 Aug 2018 11:57:54 +0200 Subject: [PATCH] aggressively align data this works on console now, but locks up opening the main menu. same as emulator. --- fs.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/fs.py b/fs.py index 9ba9314..0810c95 100644 --- a/fs.py +++ b/fs.py @@ -39,6 +39,12 @@ def hexdump(data): butts = data[i * 16:i * 16 + 16] print(("{:06X} |" + " {:02X}" * len(butts)).format(i * 16, *butts)) +def pad_align_data(data): + if len(data) % 16 != 0: + return data + bytearray(16 - len(data) % 16) + else: + return data + def compress_fast(data, mode="best"): assert mode == "best", "only \"best\" mode is implemented for compress_fast" from poopen import poopen @@ -290,6 +296,7 @@ def create_rom(d): fmt = "compressed {:02}-{:03}.bin from {} bytes into {} ({:.2%})" percent = len(new_data) / len(data) if len(data) > 0 else 1 print(fmt.format(di, fi, len(data), len(new_data), percent)) + new_data = pad_align_data(new_data) size = len(new_data) f.write(W4(size)) offset += size