+  RHDN Forum Archive
|-+  Romhacking
| |-+  ROM Hacking Discussion
| | |-+  Tool Idea: Modular/flexible decompressor
Pages: [1]
Author Topic: Tool Idea: Modular/flexible decompressor  (Read 639 times)
BigNailCow
Guest
« on: January 03, 2008, 03:30:51 am »

I had an idea just now, and I have no idea if it's been attempted before or if it already exists and I'm just not in the know.

Basically, think of a tile viewer, except that you can provide an arbitrary segment of code to decompress it.  The tool would come with several presets for common compression types, letting you choose between any loaded compression type and specify an offset in the ROM to begin decompressing, and show you the result graphically as a way to diagnose what type of compression it uses.  Of course it would need support for palettes, changing tile size if it's graphical, width/height of the viewport, etc.  And it would only work for complete data segments, obviously, since any coded thing is relative to the ROM and unable to (realistically) parse out.

Has this idea come up before?  I think it would be monumentally useful for people who know a location of compressed data, but don't want to trace through code to figure it out, or for people who think they might have a particular type of compression and would like a simple way to verify.

Edit: If this is correct, my question has been answered:

Quote from: Ryusui
The best way to confirm what compression is uses is to use an emulator with trace functionality and look at what it does to convert the compressed data into the uncompressed output.

If so, would this tool be useful?  I don't see it being too hard to make, except for the barrier of having to make some kind of scripting language or using some kind of markup language like XML so people could insert their own compression algorithms.
« Last Edit: January 03, 2008, 03:47:52 am by BigNailCow »
Neil
Guest
« Reply #1 on: January 03, 2008, 07:42:26 am »

both tmod and tilemolester allow plugins i believe. whether or not their flexible enough to allow for decompression code to be included in that plugin, I don't know. I've never bothered to try.
Disch
Guest
« Reply #2 on: January 03, 2008, 03:55:44 pm »

Laying out the compression format in an XML type file is enough to get a utility to be able to decompress it -- but recompression is another issue (and a much bigger task -- the compression scheme alone may not be enough to effectively compress data).  I guess if you're only looking to decompress this could work... but that's only half the job, isn't it?  What good is decompressing and editing the graphics if you can't put them back in the ROM?

I'm of the opinion that it'd be as hard or harder to write a plugin for such a utility than it would be to just write a simple standalone commandline program that compresses/recompresses graphical data.
DaMarsMan
Guest
« Reply #3 on: January 03, 2008, 04:02:16 pm »

I've never coded a compressor and I've done a lot of games with compression. There are many ways of bypassing writing a compressor. On SNES you can just DMA over the old data. LZSS you can do lazy compress where you just add the control byte FF (or sometimes 00) every 8 bytes. That actually makes it bigger than the original but if you find room it works. A flexible decompresser would be useful. I may actually code one for LZSS. It would be pretty simple.
Disch
Guest
« Reply #4 on: January 03, 2008, 04:10:35 pm »

Quote from: DaMarsMan on January 03, 2008, 04:02:16 pm
I've never coded a compressor and I've done a lot of games with compression.

I don't doubt you -- but I find that very suprising.
Nightcrawler
Guest
« Reply #5 on: January 03, 2008, 06:03:56 pm »

Quote from: Disch on January 03, 2008, 04:10:35 pm
Quote from: DaMarsMan on January 03, 2008, 04:02:16 pm
I've never coded a compressor and I've done a lot of games with compression.

I don't doubt you -- but I find that very suprising.

Hehe, I rarely bother to re-compress data either. I believe Gideon will tell you the same. If there's room to relocate things and what not, it's just a simpler way to go. The SNES lends itself well to the 'lazy' way out. Wink It's all about time to me. It takes enough of my life to do any of these projects. If I can get the same result in half the time, why not? Wink
Disch
Guest
« Reply #6 on: January 03, 2008, 06:41:03 pm »

I guess I seldom deal with compressed graphics.  Most of the compressed data I'm used to dealing with is level data -- and unless you want to write a small handful of new routines to load uncompressed levels, you pretty much have to recompress.

*shrug*  chalk it up to my lack of real world experience in ROM hacking   Grin
BigNailCow
Guest
« Reply #7 on: January 03, 2008, 09:33:39 pm »

The main use of the tool would just be to easily attempt to decompress a block of data under different algorithms, so you can look at the output and quickly figure out which type you're dealing with (without analyzing code).  The idea is that you, as a somewhat experienced romhacker, would simply need to identify the compression scheme to know what to do with it.  It may evolve if people are interested, but at its base it's simply a diagnostic tool.

When I figured out the compression for Shining Force 2's graphics, I didn't find it *too* difficult to code a recompressor.  It's about 99% accurate, there's just some residual bug that my loader might in fact be causing, so the recompressor might work flawlessly.  The part I really don't want to write is the pixel editor itself, so it would probably just be useful to have Import/Export.

If the tool is good enough, it could serve to actually be an answer for newbies who just want to do some simple graphic hacking, maybe on a game that isn't documented.
Nightcrawler
Guest
« Reply #8 on: January 04, 2008, 08:17:53 am »

Quote from: BigNailCow on January 03, 2008, 09:33:39 pm
The main use of the tool would just be to easily attempt to decompress a block of data under different algorithms, so you can look at the output and quickly figure out which type you're dealing with (without analyzing code).  The idea is that you, as a somewhat experienced romhacker, would simply need to identify the compression scheme to know what to do with it.  It may evolve if people are interested, but at its base it's simply a diagnostic tool

I'm not sure how useful that is going to be.  I've dealt with many games that use that same basic format RLE or LZxx (I'd say those two are the most common in cartridge based consoles), but none of them share the exact same details as far as how they derive length and lookup position for LZ. There's just so many different possible combinations. Even when it comes to RLE, there's always some custom variation thrown in.

Unfortunately, it's just not as easy as looking at data through some RLE or LZxx algorithm to determine what yours is.

Where it WOULD come in handy is when multiple games do share the exact same compression. Often times, developers will reuse their compression routines such as Nintendo on multiple games. Or for the GBA where many games use the standard BIOS compression.
DaMarsMan
Guest
« Reply #9 on: January 04, 2008, 02:02:19 pm »

I guess anyone who has the ability to figure out a decompressor would have the ability to compile it from source. I could see the use of the xml extensions though. That way if people wanted to decompress scripts from certain games we could just keep a database of the files. Kind of like what Feidian did for graphics.
tomaitheous
Guest
« Reply #10 on: January 04, 2008, 07:46:37 pm »

Tmod2 gives the user the ability to right plugins that can decompress. I just could never get DM to compile my source (missing some linker) :/

 ROM translators have it easy. For PCE CD games, 9 times out 10 you need to add a compression scheme, or rewrite a better one, or add a second stage compression scheme (after decompress LZSS, then decode DTE). Sega CD is probably a similar situation.

 Btw, has anyone come across delta encoding for text in a game or have written their encoder/compressor for one?
Pages: [1]  


Powered by SMF 1.1.4 | SMF © 2006-2007, Simple Machines LLC