News: 11 March 2016 - Forum Rules
Current Moderators - DarkSol, KingMike, MathOnNapkins, Azkadellia, Danke

Author Topic: [SOLVED] Huffman-compressed GBA graphics - help greatly appreciated  (Read 1917 times)

Ephraim225

  • Newbie
  • *
  • Posts: 2
    • View Profile
Okay, so I've been hacking a couple of Yu-gi-oh GBA games (The Sacred Cards and Reshef of Destruction) that compress a lot of their graphics with 8-bit mode Huffman rather than LZ77. (I know it's Huffman because all the pointers point to 0x28 bytes, which I believe indicates 8-bit mode Huffman) No graphics tools that I know of work with Huffman so it hasn't been easy to do what I want. The best I managed was the following process:

First, using Nintenlord's GBA Graphic Editor I insert the image into a blank ROM uncompressed, this allows me to get the raw image data and palette.

This is the image: http://imgur.com/bNO6mgt It's 80x80 and has 64 colors.

I then compressed the image data using this: http://www.romhacking.net/utilities/826/ and placed that and the palette into the ROM I'm using.

A few edited pointers later, this is the result: http://imgur.com/0sNuNp6

The interesting part is, the left-most column of pixels actually came out fine, but everything else, not so much.

So if anyone has an idea what I've done wrong, or if there's a better tool/method for this, please let me know.
« Last Edit: November 13, 2014, 02:24:52 am by Ephraim225 »

FAST6191

  • Hero Member
  • *****
  • Posts: 2561
    • View Profile
Re: Huffman-compressed GBA graphics - help greatly appreciated
« Reply #1 on: November 10, 2014, 09:00:23 pm »
Does it use SWI/BIOS Huffman or something more custom? If it is SWI than you might be able to dodge the need to decompress if you feel like editing the BIOS call into a more conventional copy of some form :angel:. You can still do that if it runs its own decompression routine but that gets marginally more annoying. I don't really have a flag dodge equivalent for Huffman (in LZ you can just set every flag to say decompressed rather than having to try to implement a compatible compression tool), short of nerfing the entire table anyway. Similarly I am not so hot at piecing back Huffman broken graphics as I am for LZ text or graphics so I can not see quite what went wrong there. Both games look like they are up to 128Mbit so you have a lot of space to play with.

If you are fighting GBA compression you might also like GBAcrusher from http://members.iinet.net.au/~freeaxs/gbacomp/
Mind you Cue's tools are good stuff so at best that is just an alternative you can use.

Better tools in general. If I am on the GBA and importing external images then I tend to favour crystaltile2 ( http://www.romhacking.net/utilities/818/ ), likewise if I can insert already compressed data then I will. Can't say I have ever used CT2's Huffman compression in a real project though. To import images (BMP or PNG format is best for obvious reasons) when in the tile editing view you click edit and then import image, you will want the appropriate tile size and alignment selected beforehand. It should then allow you a free moving image which a double click should then set.

Ephraim225

  • Newbie
  • *
  • Posts: 2
    • View Profile
Re: Huffman-compressed GBA graphics - help greatly appreciated
« Reply #2 on: November 13, 2014, 02:24:14 am »
Thanks for your suggestion but it turns out the problem was with the game itself:

http://forums.warsworldnews.com/viewtopic.php?f=11&t=13599

At any rate, problem solved~

henke37

  • Hero Member
  • *****
  • Posts: 643
    • View Profile
Re: [SOLVED] Huffman-compressed GBA graphics - help greatly appreciated
« Reply #3 on: November 13, 2014, 04:35:30 pm »
It could be that the game uses the built in delta decoding bios call.