[release] BFLIM Extractor

Discussion in 'Wii U - Hacking & Backup Loaders' started by AboodXD, Aug 27, 2016.

  1. AboodXD
    OP

    AboodXD I hack NSMB games, and other shiz.

    Member
    2,705
    1,429
    Oct 11, 2014
    United Arab Emirates
    Not under a rock.
    BFLIM Extractor v2.1

    BFLIM Extractor is a tool for extracting and creating .bflim files used for layouts' textures in some of the Wii U games.

    Supported texture formats:
    • GX2_SURFACE_FORMAT_TCS_R8_G8_B8_A8_UNORM (ABGR8 / BGR8)
    • GX2_SURFACE_FORMAT_TCS_R8_G8_B8_A8_SRGB (ABGR8 SRGB / BGR8 SRGB)
    • GX2_SURFACE_FORMAT_TCS_R10_G10_B10_A2_UNORM (A2RGB10)
    • GX2_SURFACE_FORMAT_TCS_R5_G6_B5_UNORM (RGB565)
    • GX2_SURFACE_FORMAT_TC_R5_G5_B5_A1_UNORM (A1RGB5)
    • GX2_SURFACE_FORMAT_TC_R4_G4_B4_A4_UNORM (ARGB4)
    • GX2_SURFACE_FORMAT_TC_R8_UNORM (L8 / A8)
    • GX2_SURFACE_FORMAT_TC_R8_G8_UNORM (A8L8)
    • GX2_SURFACE_FORMAT_TC_R4_G4_UNORM (A4L4)
    • GX2_SURFACE_FORMAT_T_BC1_UNORM (BC1 / DXT1 / ETC1)
    • GX2_SURFACE_FORMAT_T_BC1_SRGB (BC1 SRGB / DXT1 SRGB)
    • GX2_SURFACE_FORMAT_T_BC2_UNORM (BC2 / DXT3)
    • GX2_SURFACE_FORMAT_T_BC2_SRGB (BC2 SRGB / DXT3 SRGB)
    • GX2_SURFACE_FORMAT_T_BC3_UNORM (BC3 / DXT5)
    • GX2_SURFACE_FORMAT_T_BC3_SRGB (BC3 SRGB / DXT5 SRGB)
    • GX2_SURFACE_FORMAT_T_BC4_UNORM (BC4L / BC4A)
    • GX2_SURFACE_FORMAT_T_BC5_UNORM (BC5)
    Download.
    Source code / Github.
     
    Last edited by AboodXD, Aug 9, 2017
  2. DarkGabbz

    DarkGabbz Resident XBOX Guy

    Member
    1,185
    652
    Dec 29, 2015
    Micronesia, Federated States of
    Modding Xbox'es
    Nice work.
     
  3. AboodXD
    OP

    AboodXD I hack NSMB games, and other shiz.

    Member
    2,705
    1,429
    Oct 11, 2014
    United Arab Emirates
    Not under a rock.
  4. iAqua

    iAqua

    Member
    2,842
    2,504
    Dec 7, 2015
    Antarctica
    Cool!
     
  5. EpicLPer

    EpicLPer Nice unless you give me a reason to hate you ;)

    Member
    923
    605
    Mar 13, 2015
    Austria
    Austria
    Any way to extract a whole folder at once?
     
  6. Ray Koopa

    Ray Koopa Obviously a Koopaling

    Member
    332
    221
    Aug 18, 2015
    Batch is your friend (converts all BFLIM files in Convert folder):
    Code:
    @ECHO OFF
    FOR %%f IN (Convert/*.bflim) DO (
        ECHO Converting: .\Convert\%%f
        BFLIM_EXTRACT Convert/%%f
    )
    Suggestions:
    - Please don't wait 5 seconds to display errors. Horrible in a batch process. Maybe just do that if started without any parameters to make users just clicking the exe see it.
    - Support output path
    - Don't open input files with write access (errors out when read-only flag set)

    I like your effort. Format 0x10 and 0xF is heavily used in MK8, looking forward for support. Sadly, the other formats are not unswizzled correctly most of the time.
    [​IMG]
     
    Last edited by Ray Koopa, Aug 27, 2016
    TotalInsanity4 and EpicLPer like this.
  7. Harmonia

    Harmonia GBAtemp Regular

    Member
    176
    90
    Dec 8, 2015
    Canada
    BC, Canada
    IT'S LIT
     
  8. EpicLPer

    EpicLPer Nice unless you give me a reason to hate you ;)

    Member
    923
    605
    Mar 13, 2015
    Austria
    Austria
    Suggestion: Add a /nowait option or something, also a /folder maybe to make it easier ;)

    But it's still early so yeah, we'll see :D

    PS.: Oh boy I'm so hyped for all the dick texture replacements people will come up with then lol (sarcasm)
     
    TotalInsanity4 likes this.
  9. Ray Koopa

    Ray Koopa Obviously a Koopaling

    Member
    332
    221
    Aug 18, 2015
    NOWAIT? You stole that name from Commander Keen right? :P
    Anyway, don't do that, a command line tool should never wait needlessy, so handle it cleverly just when displaying help.
     
  10. AboodXD
    OP

    AboodXD I hack NSMB games, and other shiz.

    Member
    2,705
    1,429
    Oct 11, 2014
    United Arab Emirates
    Not under a rock.
    All your requests are too easy to implement. :P

    @EpicLPer Use:
    Code:
    for %%f in (Path/*.bflim) do bflim_extract Path/%%f
    Files which end with ^l are RGBA32 files, those are 100% tested and they work perfectly.
    Files which end with ^o, ^p, or ^q are BC compressed, those are 100% tested, for some odd reason the output image gets cut in half... :/

    Everything else isn't supported, and will be soon.
     
    Last edited by AboodXD, Aug 28, 2016
  11. Spidey_BR

    Spidey_BR GBAtemp Regular

    Member
    199
    10
    Feb 1, 2008
    Brazil
    Nice work. Too bad my Python skills are ridiculous at best. I was hoping to fork and implement the requested changes right away (no sleep, error code semantics) just as a practice section.

    What are the references on these file formats?
     
  12. AboodXD
    OP

    AboodXD I hack NSMB games, and other shiz.

    Member
    2,705
    1,429
    Oct 11, 2014
    United Arab Emirates
    Not under a rock.
    Sorry but I didn't understand what you said.

    I love how Nintendo keeps reusing formats, as this format is the same as GFD (.gtx), except changes in header. :P
     
    Last edited by AboodXD, Aug 28, 2016
  13. Spidey_BR

    Spidey_BR GBAtemp Regular

    Member
    199
    10
    Feb 1, 2008
    Brazil
    I mean the documentation on how these formats work. Or are they industry standard for texture files?
     
  14. AboodXD
    OP

    AboodXD I hack NSMB games, and other shiz.

    Member
    2,705
    1,429
    Oct 11, 2014
    United Arab Emirates
    Not under a rock.
    I've already made a documentation of the GFD (A very similar format to BFLIM, they're both used on Wii U) File format, you can find it here:
    https://github.com/aboood40091/GTX-Extractor/wiki

    It's a bit incomplete but that doesn't matter that much. :P

    I can still make a documentation of the BFLIM File format if you want.

    Please note that both GFD and BFLIM formats are very complex.
     
    Last edited by AboodXD, Aug 28, 2016
  15. Ray Koopa

    Ray Koopa Obviously a Koopaling

    Member
    332
    221
    Aug 18, 2015
    Documentation never hurts, would be great if you can do it.
     
  16. AboodXD
    OP

    AboodXD I hack NSMB games, and other shiz.

    Member
    2,705
    1,429
    Oct 11, 2014
    United Arab Emirates
    Not under a rock.
    OK, I'll work on it. :)

    BTW, can I get a list of features you hope to see?
     
  17. Ray Koopa

    Ray Koopa Obviously a Koopaling

    Member
    332
    221
    Aug 18, 2015
    For me it's just the bugs I posted in my previous post, if you want =3
    - Don't wait 5 seconds
    - Don't open input files with write access
    - Look at the other format which completely throws up due to wrong swizzling (the greenish blocks)
     
  18. AboodXD
    OP

    AboodXD I hack NSMB games, and other shiz.

    Member
    2,705
    1,429
    Oct 11, 2014
    United Arab Emirates
    Not under a rock.
    Can you send me those BFLIM files to test? :)

    I don't understand, sorry. :(
     
  19. Ray Koopa

    Ray Koopa Obviously a Koopaling

    Member
    332
    221
    Aug 18, 2015
    If you call open, don't pass 'w'. That makes the program crash being incapable to open files with a read-only flag. Just open them with 'rb'. I send you the files as a PM
     
  20. AboodXD
    OP

    AboodXD I hack NSMB games, and other shiz.

    Member
    2,705
    1,429
    Oct 11, 2014
    United Arab Emirates
    Not under a rock.
    This is not the case, this is the line where the input file gets read:
    Code:
    with open(sys.argv[1], "rb") as inf: