News:

As a consequence of the forum being updated and repaired, the chatbox has been lost.
However, you can still come say hi on our Discord server!

Main Menu

A Guide to GS Compression Format 0

Started by Salanewt, 19, August, 2011, 12:14:00 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Salanewt

Hello everyone! Would you like to modify some of the graphics in your hack, but are unable to figure out where to start? Then this topic if for you. By reading this topic, you should be able to look into how the various compression formats seem to work.


---Finding and Understanding your Sprites---

The sprite database starts at x08300000, and each sprite set seems to take up about 20 bytes. If you want to find the details of one of the sets, you can take the following steps:

1 - Find your sprite in the editor.
2 - Multiply its value by 20
3 - Convert the result to hex.
4 - Add it to the offset x08300000. This should be your sprite.

I can go over more of this later, but one of these values indicates the compression format that is used. To find the frame that you want...

1 - Follow your sprite's first pointer.
2 - Pick a frame in the editor.
3 - Multiply its value by 4.
4 - Convert the result to hex.
5 - Add it to the first offset. Follow that offset.


---Palette Reference---


To get the value for a specific colour, you must add the column value with the row value. Eg. xDF will be the colour in the bottom right.


---Compression Format: 0---

Notable Sprites: Felix, Lemurian Ship, Idejima, PC Battle Sprites, GS1 Locations, etc.

This first format is fairly easy to understand, but it may get a little annoying if you don't take the right approach. Bytes x01 to xDF add a single pixel of the corresponding colour from the palette, while bytes xE0 - FF act as spacing/transparency. To finish the sprite, you add the byte x00.

x00 = Offset; in this format, it makes all following pixels transparent.
x01 = First colour of the palette.
xDF = Last colour of the palette.
xE0 = Spacing of one transparent pixel; for every addition of x01 to this value, you increase the spacing by one. This moves all following pixels over.
xFF = Maximum amount of spacing permitted.

So if you were to have x02, xE0, and x08 in that order, you would end up with having a red pixel, a transparent pixels, and a blue pixel at the end. Here is an example of a sprite I made, with the hex in the picture to show how I made it.


Notes:
- I did not use a byte of x00 to end the sprite in this example. The rest of the bytes are pushed passed the maximum dimensions, so they are not used for this sprite anyway.

Tips:
- Make the shape of the sprite first. It should be faster than building the shape and correctly placing pixels at the same time.
- The sprite has to update before you see the changes; either by leaving the room, or having a script/animation update it for you.


Edit: This is now only a guide on the one format, changed the title to match it.
Oh yeah baby, £ me harder.

Fusion is just a cheap tactic to make weak Adepts stronger.

Yoshi's Lighthouse is a hacking website in progress. Why not check it out if you like Yoshi or the Mario & Luigi games?

Misery

Format 0? Isn't that what the party's battle sprites use? That's seriously awesome! *.*
Also unexpectedly straightforward, even if it's a lot of work to do it manually.
I assume the size of the sprite is set elsewhere, and you only have to worry about the actual graphics data?
Also, how do we find offsets for sprites? It doesn't seem like they're displayed anywhere in the editor...

Salanewt

Ah, great questions - I should probably have tried to answer them before. I am going to paste this into the first post, but here is a method on finding them.

The sprite database starts at x08300000, and each sprite set seems to take up about 20 bytes. If you want to find the details of one of the sets, you can take the following steps:

1 - Find your sprite in the editor.
2 - Multiply its value by 20
3 - Convert the result to hex.
4 - Add it to the offset x08300000. This should be your sprite.

I don't know what most of the data is, but the frames for that sprite are held in the first offset.


QuoteFormat 0? Isn't that what the party's battle sprites use? That's seriously awesome! *.*

Those too, yeah. I take it that we technically have the ability to have a custom party now; not sure how portraits work though, I have been meaning to ask Atrius where they are stored... But other than portraits, we have enough to customize them now.

Edit: I thought I added info on Format 3 too? Maybe not, I will go ahead and do that right now.
Oh yeah baby, £ me harder.

Fusion is just a cheap tactic to make weak Adepts stronger.

Yoshi's Lighthouse is a hacking website in progress. Why not check it out if you like Yoshi or the Mario & Luigi games?

Atrius (He/Him)

#3
Well, yeah, if you're not going to use Format 3 properly you might as well just use Format 0.  Only setting those first two bytes to 0x00 completely defeats the format, and there's quite a bit more to it when you actually use it.

Also, have you tried your conversion technique?  I can guarantee you it doesn't work.
[sprite=220,4,0]I'm shaking my head in general disapproval of everything[/sprite]

Salanewt

I am not sure what the modifiers do, but it appears that they rearrange the pixels even further. Could you please explain what they do?

I tried it for Jenna, but I only did one of the frames. I guess most sprites have modifiers other than x00, so it worked for her frame because she had modifiers of x00. I will probably remove it from the Tips sections until further notice anyway.


Also, the pointers to monster graphics seem to begin at x0868080C - And the majority of them use Compression Format 2. As such, I am going to take a look at some of them to see if I can add it to this guide successfully.
Oh yeah baby, £ me harder.

Fusion is just a cheap tactic to make weak Adepts stronger.

Yoshi's Lighthouse is a hacking website in progress. Why not check it out if you like Yoshi or the Mario & Luigi games?

Atrius (He/Him)

It's not a modifier, it's an offset.  Part of the data is in format 0, but it's combined with references to data from earlier sprites in the set.  Those two bytes are the offset to the data that defines those references.

As far as sprite format 2 goes, I'll give you a hint, it can use 2 different compression formats.  I hope you're good at working with data in binary format as well since much of the information in one of them is smaller than a byte.
[sprite=220,4,0]I'm shaking my head in general disapproval of everything[/sprite]

Salanewt

Hm, so this means that we can duplicate sprites and replace pixels that they use? Cool, thanks for the correction; I shall add that to the guide immediately.

Okay, thanks for the hint. I don't do too much in binary, but I should get started.
Oh yeah baby, £ me harder.

Fusion is just a cheap tactic to make weak Adepts stronger.

Yoshi's Lighthouse is a hacking website in progress. Why not check it out if you like Yoshi or the Mario & Luigi games?

Misery

Ok, decided to test this...
Let's start with something simple. Felix overworld sprite.
@ 0x08300050: 20 20 00 01 ... wait, what is this?
*looks at the next few bytes* ohh, a pointer. Let's see where it goes...
@ 0x08307BBC: yep, that's another set of pointers. I suppose the first one is the first sprite.
@ 0x08337D72: *copy data into notepad, fill out the spaces*
Ok, that's definitely the silhouette of Felix' index 0 sprite. First few colors check out as well. Success.

Quote from: Atrius on 19, August, 2011, 09:18:48 PM
It's not a modifier, it's an offset.  Part of the data is in format 0, but it's combined with references to data from earlier sprites in the set.  Those two bytes are the offset to the data that defines those references.

As far as sprite format 2 goes, I'll give you a hint, it can use 2 different compression formats.  I hope you're good at working with data in binary format as well since much of the information in one of them is smaller than a byte.
Why so mysterious? You seem to have this figured out already. Ok, this kind of conversion really doesn't seem like something you'd want to do "by hand". But still, I'm kinda curious now.

Atrius (He/Him)

#8
You wouldn't be able to view sprites in the editor if I hadn't figured it out already.  I mostly figure that since Salanewt didn't bother to ask me about the formats it was something he wanted to try to figure out on his own.  Though, knowing the formats is kinda pointless since most of them are fairly complex.  You wouldn't want to have to convert them by hand, and the sprite editor should make it into the next version of the GS:TLA Editor.


EDIT: Salanewt, your description of the offset in Format 3 is making me think you're assuming it's simpler than it is.  The offset itself doesn't point to any previous sprite.  Format 3 sprites can be constructed from random chunks of data from any previous sprite mixed with new data, not just one previous sprite with some of the pixels replaced.  The offset points to additional data stored in the current sprite that specifies where exactly to reuse old chunks from, how much, and when to use the new data instead.
[sprite=220,4,0]I'm shaking my head in general disapproval of everything[/sprite]

Misery

That's what I thought. And yeah, now that you mention it, he probably would have asked you about it already if he didn't really want to figure it out himself.

Well, I was toying with the idea of trying to make some kind of utility to convert graphics into the right format. Since you know, the next version could be a week or a year away for all I know. But on second thought, I wouldn't have any graphics to convert, and no matter how long it takes you to implement it into the editor, I still doubt I'll have a custom sprite sheet ready by then. So I guess my time would be better spent making graphics than trying to write a program that becomes obsolete by the time it's finished.

Is format 3 limited to data from the same sprite set, or can it take data from any sprite? I suspect the former, it already seems like it would be quite a bit trickier to effectively write something into that format than to read it. And that's when just checking for matching patterns within the same set, as opposed to all sprites.

Just keep up the good work, I guess. You know we appreciate it.

Salanewt

I wanted to figure some of it out on my own so I could see how some of these compression formats work; the games that I usually work with don't seem to have formats like these. However, I have decided to go figure some other stuff out now though.

Format 3: I would suspect that they use this for when NPCs nod or shake their heads and stuff, right? Just as an example...

Atrius? Would you be so kind as to explain anything that you feel should be explained? I can also add it to the first post if you want.
Oh yeah baby, £ me harder.

Fusion is just a cheap tactic to make weak Adepts stronger.

Yoshi's Lighthouse is a hacking website in progress. Why not check it out if you like Yoshi or the Mario & Luigi games?

Atrius (He/Him)

You're oversimplifying it, it's a compression format, it reuses any old data that the compression algorithm detects it can.  It's not like someone hand selects what to reuse.

This looks like a guide on how to hex edit these formats by hand, but that just isn't practical with compression.  It's too complex, you need tools to handle the calculations for you.
[sprite=220,4,0]I'm shaking my head in general disapproval of everything[/sprite]