Any way, to reverse trim a rom?

Discussion in 'NDS - ROM Hacking and Translations' started by jackdanielchan, Sep 7, 2009.

  1. jackdanielchan

    jackdanielchan GBAtemp Advanced Fan

    Mar 15, 2009
    Does anyone know how to retrim a rom to it's original size? Any links would be nice too! I can't patch a trimmed rom btw...
  2. Kwartel

    Kwartel The fairest in all the land

    Apr 11, 2009
    Uhm I don't think so but you could also redownload the rom!!!
  3. jackdanielchan

    jackdanielchan GBAtemp Advanced Fan

    Mar 15, 2009
    I don't want to dowload the same rom twice, for two reasons one, we have crap internet, two I don't want to pirate the same game twice. Maybe there's a way to reinsart garbage data? I'm not to sure, but anyway, yeah help would be nice...
  4. FAST6191

    FAST6191 Techromancer

    pip Reporter
    Nov 21, 2005
    United Kingdom
    What patching method are you using for 1) it should be able to add data and 2) if it has a hash check of some form you should be able to bypass it.

    Still trimming involves removing junk data, reverse trimming would involve putting it back.

    Some tools might be able to do it but frankly a hex editor is probably easier.

    The junk data is probably 0000 0000 0000 until the end of the file.

    Two main ways:
    Have a large file of all 00's (personally I am going to suggest 32 megabytes of it) and copy /b it onto the rom.

    General idea is
    "copy /b trimmedrom.nds+00file.file+00file.file untrimmedrom.nds"

    repeat the 00file.file as many times as you like.

    Now you can cut the rom down to size again. Either use a hex editor or something like filecutter from cracker: (click projects)

    32 megabytes = 33,554,432 bytes or finishes at 0200 0000 (well technically 01FF FFFF is the last entry)

    64 megabytes = 67,108,864 bytes or finishes at 0400 0000

    128 megabytes =134,217,728 bytes or finishes at 0800 0000

    You can do the maths on the others as and when they come.

    Secondary knowledge: the DS rom has the size it is trimmed to (give or take the "safety" factor) at 80 hex in the rom:

    From megaman battle network 5 (EU version):
    C3 84 6E 01

    Which when you reverse it (think ABCD reads D C B A but with bytes)

    01 6E 84 C3 which is the end of the rom if you check it. This is how "safe" trimmers work, old style trimmers just cut until they no longer see 00.

    Notes: some carts, patchers and whatver else may use this junk space so just filling it back up may not restore the original hash but you only appear to want space.

    Some games use something other than 00 padding, some FF, some FF00FF00 or 00FF00FF and some might use something else entirely (although I have yet to see it on the DS).
  5. jackdanielchan

    jackdanielchan GBAtemp Advanced Fan

    Mar 15, 2009
    Uhhh, okaaay... I get what your saying, but I really can't be bothered to do that... Thanks for the help anyway...
  6. N-TG

    N-TG GBAtemp Fan

    Mar 15, 2009
    Greece, Thessaloniki
    You should usually do a copy of the original rom for backup.
    That what I do at least (for the patches and stuff)
  7. azerty1

    azerty1 GBAtemp Regular

    Mar 22, 2009
    ds cartridges come in different sizes, 8, 16, 32,...(powers of 2). so manufacturers just add a heckuva lot of empty bytes to the end of the game. Trimming is the process of removing those unnecessary bytes. FAST6191 basically says that all you need to do, is paste on some 00s to the end of your trimmed rom. for example, if you trimmed a 32 MB rom, and it's down to say, 22 MB, then you need to put 10 MB of 00s back into it.
    if you open the rom up in a hex editor, the final offset will be whatever 22MB of bytes is. so basically, you should take that number, subtract it from 0200 0000, then add that many 00s back into it.