`convert_background.py` fails on `menu_file_selection_commands.tilemap.encoded`
KelseyHigham opened this issue ยท 5 comments
It fails with an IndexError. Console output:
๐ LADX-Disassembly-main % tools/convert_background.py decode src/data/backgrounds/menu_file_selection.tilemap.encoded --filler 0x7E --output src/data/backgrounds/menu_file_selection.tilemap
๐ LADX-Disassembly-main % tools/convert_background.py decode src/data/backgrounds/menu_file_selection_commands.tilemap.encoded --filler 0x7E
Traceback (most recent call last):
File "/Users/kelly/ROM hacks/LADX-Disassembly-main/tools/convert_background.py", line 54, in <module>
result = BackgroundCoder.decode(data, args.width, args.filler or 0x00)
File "/Users/kelly/ROM hacks/LADX-Disassembly-main/tools/lib/background_coder.py", line 39, in decode
while data[idx] != 0x00:
IndexError: index out of range
๐ช return status 1
note, replacing while data[idx] != 0x00:
with while idx < len(data) and data[idx] != 0x00:
will most likely fix the export, but on import it will not produce the right file, as the import will add the nul termination.
Nice catch. I'm a bit busy with real life those weeks, but if you feel you can make a patch out of it, I'll be glad to review it :)
maybe convert_background.py
could accept a --no_null_terminator
parameter, mandatory for both decode and encode for that file.
if you try to decode menu_file_selection_commands.tilemap.encoded
without the parameter, it can give you an error, and tell you to provide the parameter for both encode and decode.
I think that should catch most human errors.
That sounds definitely like a good fix ๐
I'll see if I have some time for this, but otherwise feel free to hack something and submit it.
note for anyone who gets bit by this in the meantime โ
you can replace the contents of menu_file_selection_commands.tilemap.encoded
with this:
99e20f 7e7e7e7e 0411001204 7e7e 020e0f18 7e
which basically says:
[info] ________ E R A S E ____ C O P Y __
ignore the first 3 bytes, and edit the rest normally.