RoadrunnerWMC / FDGH-Converter

For FDGH files from HAL Laboratory games
GNU General Public License v3.0
17 stars 5 forks source link

Need Help to Edit XBIN4 in Kirby and the Forgotten Land #1

Closed JokerDKha closed 2 years ago

JokerDKha commented 2 years ago

Need help to edit XBIN4 of this game, can you try lookout? Thank's for your hard work. Sample File: [removed by @RoadrunnerWMC]

RoadrunnerWMC commented 2 years ago

Please don't post copyrighted game files. The one you posted isn't an FDGH file, anyway, so it's not in scope for this tool.

XBIN is just a thin wrapper around other file formats, defined like this (C-like pseudocode):

struct XbinHeader {
    char magic[4] = "XBIN";
    uint16_t endian = 0x1234;
    uint8_t version;  // 2 or 4
    // (1 pad byte here)
    uint32_t file_size;  // includes xbin header and unpadded embedded file data, nothing after that
    uint32_t metadata;  // seemingly always 0x3A4 or 0xFDE9; unknown meaning
#ifdef XBIN_VER_4
    uint32_t rloc_offset;  // offset of "RLOC", relative to start of file
#endif
}

struct XbinFile {
    struct XbinHeader header;
    char file_data[header.file_size];  // arbitrary contents
#ifdef XBIN_VER_4
    // (1-3 bytes of padding here)
    char rloc_magic[4] = "RLOC";  // unclear if this would flip with endianness; it's "RLOC" in little-endian
    char rloc_empty[8] = {0,0,0,0,0,0,0,0};
#endif
}

You can extract the file inside by removing the first 0x10 bytes (for XBIN 2), or the first 0x14 bytes and the last 0xC (for XBIN 4). I actually have a tool to do that (as well as the reverse operation, which is slightly more annoying), which I can add to the repo.

KatFL does have an FDGH file, though, and it currently breaks the tool. I'll see if I can add support for it.

JokerDKha commented 2 years ago

Im so much need editing this file for translation game. Thanks for support.

RoadrunnerWMC commented 2 years ago

I've added support for KatFL's FDGH file, and a new "xbin_cli.py" script that can add and remove XBIN wrappers to/from arbitrary files. Together, they should solve this issue. Good luck with your translation!

rewold commented 2 years ago

Thank you for the tool. But how do I edit this file? After the tool, the file becomes like this. How can I add characters to this file? sadasd

RoadrunnerWMC commented 2 years ago

I don't know anything about other (i.e. non-FDGH) files in Kirby games, sorry. :/