everything8215 / ff6tools

Browser-based editor for Final Fantasy ROMs
GNU General Public License v3.0
35 stars 7 forks source link

FFV Map data corruption and byte count request #23

Open PheonixMMKC777 opened 1 week ago

PheonixMMKC777 commented 1 week ago

I have a interseting problem... I started a Romhack of FFV, Did quite a bit in one sitting, saving and reopening testing multipltimes thoughout, to ensure my rom wasnt broken by anything at any point. I've been mainly editing events and some maps and at no point yesterday had my rom had broken or had any issues. I reopened the same Rom throught the day multiple times to to make sure that it wasnt corrupted. This morning I load up the rom in ff6tools, and the map data is all bugged. Ok bummer, but thats what backups are for. Litterally all my backups from the last day are bugged out, yet the day before in the editor, same rom files, everything was fine. Nothing was corrupted and was able to edit things freely, same exact smae file. Granted there was no way to tell if something was jacked up. Even now I can still laod the rom and play the game as nothing is wrong, ff6tools just freaks on reading the map data. My Rom wasnt expanded or anything, I don't recall optimizing the Rom either and this is the only tool I used. I think their might be an issue :(

Also request: Byte counter on current map. IDK how FF5 does it (RLE???), but just a byte coutner to keep from accidently using too many bytes on a pre-existing map. ex: BytesUsed / BytesTotal.

mogue commented 1 week ago

When you save a ROM it should give you a zip file including a JSON file with the same name as the ROM. It is important to keep this alongside the ROM to correctly reload in the editor.

By default the editor assumes an unmodified ROM but while editing data chunks might expand or shrink and get moved around. This modified information is kept track of in the JSON definition file, the JSON acts as a "project file" while the ROM is a "build" so to speak.

I strongly suspect this file being the issue either mismatched or missing JSON file.

see Saving a ROM: https://github.com/everything8215/ff6tools?tab=readme-ov-file#saving-a-rom

Regarding a byte counter for maps is problematic, Map data is custom LZSS compressed so more complex then RLE - trying to compress sections of a chunk is prone to being faulty due to many edge cases - recompressing a full chunk with each edit is a huge CPU overhead. So there is no simple elegant solution. You can try using the ROM Map.txt or parsing the JSON after you save to determine the bytes used. In any case working with compressed data tends to be tedious.

If you don't manage to recover your work make sure to reach out on ff6hacking forums or discord. There's always a way to find the bug and fix it.