Unpacking an archive in a DS rom - .iear

Discussion in 'NDS - ROM Hacking and Translations' started by fuzzy_cheez2, Jun 24, 2012.

Jun 24, 2012
  1. fuzzy_cheez2
    OP

    Newcomer fuzzy_cheez2 Newbie

    Joined:
    Jun 26, 2011
    Messages:
    8
    Country:
    United States
    I'm trying to rip the sprites of a DS game called Sands of Destruction. All the graphics are stored in files with the extension ".iear". I am able to view the graphics in these using TiledGGD, but I read in a tutorial that this file is an archive which contains multiple NCBR and NCLR files. However, the tutorial did not explain how to unpack the archive. I was wondering if anyone could help me learn how to unpack these archives, as I do not know anything about how to do this.

    -snip-
     
  2. FAST6191

    Reporter FAST6191 Techromancer

    pip
    Joined:
    Nov 21, 2005
    Messages:
    21,713
    Country:
    United Kingdom
    Seems to be a fairly standard archive format as far as I can tell
    Starts with MAIN
    F0 = 240 decimal and is the amount of files it contains.
    At 10 hex there is JTBL and E0 01 in hex. Not sure what the latter means at this point.
    Starting at 20 hex there is a list of file locations and file sizes (no padding that I can see) 32 bits for each (needing a flip naturally)
    No file names in this archive that I can see unfortunately. I only used your link and did not check the game proper (sometimes there are files sitting alongside archives with names in but they are not important)
    Files packed end to end. Edit- on second thoughts each file seems to have something random for 10 hex after the files and this is messing up some of the programs I try to view them with (crystaltile2 and tinke are having issues with some of the files). I will have to check further.
    Unusually for the DS it does seem to end with ENDT and the rest of the 10 hex being 00 padded at 3F7FEO hex.

    If you just want to rip it I can help extract that archive
    Go to http://crackerscrap.com/ , click projects and get filecutter.
    Copy and paste the spoiler at the end of the post into text file and save it with the extension .bat
    Stick filecutter, the batch file and your 05.iear file in a directory and double click the batch file. 240 files should spring up with their correct extensions. As I had no file names I just used ascending numbers so I would guess 001.NCLR goes with 002.NANR, 003.NCBR and so forth but I did have a quick look and nothing appeared to be compressed within it and the palette might well hold for most if not all the files

    [​IMG]

    large batch file
     
    omarrrio and fuzzy_cheez2 like this.
  3. fuzzy_cheez2
    OP

    Newcomer fuzzy_cheez2 Newbie

    Joined:
    Jun 26, 2011
    Messages:
    8
    Country:
    United States
    Sorry for being a moron about posting that link.

    Anyways, thanks a lot for the help. I'm assuming I can't use the same batch file to extract the rest of the archives in the game data, so let me try and understand what you did here. In the batch, is the number before the file name the size of the file, and the number after it the location? I guess you used the values at the beginning to determine what the size and location of each file, but how did you determine the extension? If you go to that location in the hex, will the extension be there? And what do you mean when you say it "needs a flip"?

    Sorry for asking all these questions but I'm really new to this.
     
  4. FAST6191

    Reporter FAST6191 Techromancer

    pip
    Joined:
    Nov 21, 2005
    Messages:
    21,713
    Country:
    United Kingdom
    First yes that batch file is only for that and from what I saw it was mainly that character and one with a straight sword.

    Back to the matter at hand yeah I should have elaborated upon all that. What follows looks long but it really is not.

    When you first open the file it will look something like

    [​IMG]

    You can get stuff done but 10 clicks will make it nicer to look at
    I grouped everything by 32 bit set each line to 8 bytes wide and flipped it.

    Byte flipping.... ARM processors and more or less anything that is not x86/x64 will use little endian byte ordering where the lowest value bytes will be first and everything else comes later for a given length (in this case 32 bits). Flipping it which all good hex editors will do ( http://gbatemp.net/topic/326873-rom-hacking-hex-editors-mid-2012-discussion/ should net you something and http://sourceforge.net/projects/hexplorer/ appears to do it in the "edit - operations" option and tiny hexer also does well if you press edit - convert and use the big endian little endian options over 32 bits) makes it human readable.
    Left column location, right column size (or what I at least thought was size).
    [​IMG]

    Export as text (ICY has troubles here so you might want to find something else) and stick it in a spreadsheet

    One conversion to decimal later and in this case I had all the numbers I would need to feed filecutter (occasionally you might have to add something or take it away or do some other maths but today is nice) which meant everything else was so much copy and paste and use of the fill command. If we had the file names from somewhere else this would be where they get dumped in before being copied out to a text editor to make the batch file (tabs will still work but I like to replace them with spaces but that is trivial on any half decent text editor).

    The extensions. As I am only working with a batch file and filecutter I opted for the cheating method rather than programming something properly.
    The nice thing about SDK formats (I saw it and you mentioned it as well) is the first 4 bytes are the magic stamp which is just ASCII text and so the extension we tend to give these files/know them by. Luckily there were no extras today so a quick skip to the batch file up above and replace all the lengths with 4 but leave the start locations.
    Run it and you have 240 files named hopefully in order from the file itself that is just the extensions of the files they would normally be.
    New line is just 0d0a in hex so I made a file with that in it (and named it nl).
    Copy /b 001.file+nl+002.file+nl..........+nl+240.ext extensions.txt
    You should have the file names still from the batch file earlier so it is easy to make this command with another search and replace (I probably used a hex editor for that as text editors are sometimes reluctant to replace new line characters). The only might be that copy /b is limited to about 1000 files I think (might be 512) in which case you would build the first half, the second half and merge those files together.
    Run that and you have a text file with the extensions in order.

    Go back to the spreadsheet and stick the extension in. Generate a new batch file containing the proper sizes, names for the time being (now with extensions) and the start location.

    Run that and 240 files with their proper extensions should appear. At this point conventional parsing of SDK formats happens (I stuck them in donor file so crystlatile2 could play with them but you are not restricted to that (Oil of Vitriol, tinke, lowlines tools......)). Had they not all been SDK formats or formats with ASCII magic stamps (occasionally you get developers leave thumb.db or something inside them) it might have been slightly more troublesome in that I might have had to delete that line and go manual for the file but that is easy enough if it is just a handful of them.
     
  5. Barubary

    Newcomer Barubary Member

    Joined:
    Feb 27, 2009
    Messages:
    28
    Country:
    United States
    Alternatively, if you want to get the files in a hurry, just use this program to unpack .iear files. (you can use the command line, but just opening it as a Java program works as well)

    (I'm assuming that the format hasn't changed from when it was used in the Luminous Arc games though)
     
    1 person likes this.
  6. fuzzy_cheez2
    OP

    Newcomer fuzzy_cheez2 Newbie

    Joined:
    Jun 26, 2011
    Messages:
    8
    Country:
    United States
    Thanks for that program, it works very well. To be honest, I was struggling with the other method and the files seemed to be coming out wrong - the palettes were all scrambled.

    The only thing that's weird is that if I try to drop an NCGR or NCBR file into TiledGGD, I get the following error message:

    System.BadImageFormatException: Could not load file or assembly 'LuaInterface, Version=2.0.0.16708, Culture=neutral, PublicKeyToken=null' or one of its dependencies. An attempt was made to load a program with an incorrect format.

    Any idea what that might be? If you can't help, that's fine. I can still look at graphics by loading up the entire .iear archive in the program, and the palette files work just fine, which was my biggest concern.
     
  7. Barubary

    Newcomer Barubary Member

    Joined:
    Feb 27, 2009
    Messages:
    28
    Country:
    United States
    I've seen the error before, but I've yet to diagnose why it happens.

    You can use this program to view the contents of a NANR/NCER/NCBR(or NCGR)/NCLR file set instead. :)
    (or Tinke, if it supports loading separate files)
     
    1 person likes this.
  8. fuzzy_cheez2
    OP

    Newcomer fuzzy_cheez2 Newbie

    Joined:
    Jun 26, 2011
    Messages:
    8
    Country:
    United States
    That program works wonderfully. Thanks again!
     

Share This Page