BGP File Import does not work properly with native file handlers
Closed this issue · 2 comments
When importing BGP with native file handlers, tiles might be misaligned, resulting in this:
This is likely due to this part, as it calculates the amount of tilemap entry to fill using the number of tiles (not tilemap!), probably a copy paste from tiles filling:
https://github.com/SkyTemple/skytemple-rust/blob/bb7ed78b929974420baf76bc44593500eb795175/src/st_bgp.rs#L159
Also, tilemap do not need to be filled with dummy entries as there will always be 768 tilemap entries (which is what is done in the python equivalent)
The end result error is caused by the fact that tile entries (located after tilemap entries) must be 4-bytes aligned, which is normally always the case as the normal number of tilemaps (768 with 256x192 backgrounds) produces a number of bytes (768*2) that can be divided by 4 (except with this bad fill error because it can produce an odd number of tilemap entries)
Thanks for the report. How odd that nobody noticed this until now! I'll fix this for the next release.
Your observation isn't 100% correct, unless I misunderstood you:
The Python code fills up tilemap entries and tile entries to 1024. The only bug I see in relation to that in the Rust code is it using the number of tiles instead of tilemap entries for extending the tilemap entries.