News: 11 March 2016 - Forum Rules

Author Topic: How to keep files the same size  (Read 2346 times)


  • Full Member
  • ***
  • Posts: 122
    • View Profile
    • Ripening Tingle's Balloon Trip of Love translation project
How to keep files the same size
« on: March 09, 2014, 01:29:22 pm »
I'm trying to replace graphics in a DS game. The graphics are located in custom archives so there are no tools to extract them, so I've been extracting them manually. Anyways, they're compressed with LZ77 compression so after I decompress them, I can view the graphics in crystal tile 2. After I modify it the decompressed file is the same size, but after I compress the modified file it's bigger (sometimes smaller) than the original compressed file. This is a problem because it has to be the same size to fit in the archive. Why is it doing this?


  • Sr. Member
  • ****
  • Posts: 308
    • View Profile
Re: How to keep files the same size
« Reply #1 on: March 09, 2014, 02:55:26 pm »
How to keep files the same size.
Long story short, you can't. Any kind of gfx decompression/recompression routine will change the hex string severely. I once changed one gfx dot in the SNES decompressed gfx and the recompression was totally different (regarding byte values and length).

This is why some games have a certain bank for gfx, which always has around 1000 bytes empty space at the end (just in case the recompression would take more space).

The same size can only be possible on sections, that have no compression.
« Last Edit: March 09, 2014, 03:00:37 pm by puzzledude »


  • Hero Member
  • *****
  • Posts: 643
    • View Profile
Re: How to keep files the same size
« Reply #2 on: March 09, 2014, 05:09:06 pm »
I think it is time for you to get some tools made to work with the custom archive format. This problem would be moot if you had the ability to just rebuild the archive.


  • Hero Member
  • *****
  • Posts: 3396
    • View Profile
Re: How to keep files the same size
« Reply #3 on: March 09, 2014, 07:44:15 pm »
What the others said. However should it be smaller then you can usually pad things back out to the original size and inject it back in, especially if the sub files in the archive are individually compressed.

On being bigger... assuming it is standard DS LZ compression (which I think it was) then you might also try some of the more exotic options of Cue's tools. Some of the others have such things as well but that is probably your best bet. In them they have a DS compatible compression but do it in such a way that you can occasionally get enough bytes that you will take note, with the DS and GBA before it being so free with memory and storage it tends not to matter but it is worth noting here.

Option 2 and one I do not suggest so much is repoint to the end of the archive file -- if you can unpack it then you can read it and know how to decode it (also repack it but that would take programming skills) and if it is just for one or two files then you can repoint the individual pointers to the end of the file and stick your modded stuff there.