Re: Some sprite data.

Discuss anything related to hacking ROMs of the Telefang games here.
Post Reply
Blaziken257
Posts: 983
Joined: Fri Dec 22, 2006 11:52 am

Re: Some sprite data.

Post by Blaziken257 »

There are two parts to this topic, because there are two separate things I found about sprites. One is basically an acre pointer to a group of sprites, and another part is the sprite itself. First, I'll go over the acre data for sprites, or at least I'll mention what I know.

For this, I have only been able to find data for the overworld. I have had no luck finding data for other locations.

The overworld data is from $E2C54-E2D53. Each acre is one byte long. It's worth noting that these bytes are not based on coordinates -- rather, they're based on the map data for the overworld. So if you hack the map data, then it will affect the sprites that go in the acre as well.

Now, let's find the exact address of the group of sprites you want to edit. In the upper-left, upper-right, and lower-left quadrants, the starting address is at $E2C54. Then, to find the address of the acre you want to edit, either go the acre you want to edit and look at RAM address $C903, or just look at the map data and find it that way. Then, take this value and add it to $E2C54. For example, let's edit the first acre you go to in the game. In the lower-left quadrant of the overworld, this is in the third row, fifth column. If you look at the map data (in this case, it's from $19C50E-19C54D, and the address for the third row and fifth column is located at $19C522), this value is $94. Or if you go to this acre in the game and look at RAM address $C903, it's also $94. Add this to $E2C54, and you get $E2CE8. This address is the data to the sprites.

Now let's change it to something else. It's $A4 right now, so let's change it to $A3, which is the data for the sprites to the left of this acre. Start the game up, and what happens?

Image

Hey, look! It has the sprites from the acre to the left!

Image

Well, that's all I know about overworld sprites. Unfortunately, I haven't figured out how to edit overworld sprites yet. I also haven't found this data for other areas yet. (I tried to find data for Toronko Water Source, but I haven't had any luck. You'd think it would be right near this data, but it doesn't seem to be.)

Though, I did find data for one sprite for in Toronko Water Station. In other words, I found its behavior, graphics, etc. Since all sprites are different in some way, let's just focus on the first one you see.

Image

First off, I found that the pointer table for sprites (I don't think it's limited to Toronko Village Water Source, either) is from $14956E-$14976D. (To calculate pointers, go here.) The pointer for the sprite that we're going to look at for now is from $1495FE-1495FF. This data is 32 58, meaning it points to $149832. The pointer after that, located at $149600-149601, is 62 58, meaning the next sprite starts at $149862. So the sprite we're looking at ends at the byte before this, at $149861.

The data from $149832-$149861 reads:

Code: Select all

FB A6 01 43 03 44 58 02 
04 5A 01 43 03 53 58 02 
FF FF 50 58 04 01 40 06 
43 33 36 86 81 41 02 19 
FF 5F 58 04 01 40 06 43 
33 36 86 81 41 02 1A FF
Confusing, isn't it? Well, I'll just explain everything that I know of. First, let's make the data easier to read:

Code: Select all

FB A6 01 43 03 44 58 02 
04 5A 01 43 03 53 58 02 FF FF 
50 58 04 01 40 06 43 33 36 86 81 41 02 19 FF 
5F 58 04 01 40 06 43 33 36 86 81 41 02 1A FF
Now let's explain what each byte does (at least to the best of my knowledge):

FB = I'm not sure exactly what this does. I know that changing this byte to certain values causes the sprite to disappear. It might be a flag of some sorts.

A6 = I have no idea what this does. This might be a flag of some sorts, especially when this guy says two different lines, depending on whether you beat Tabasco or not.

01 = The color of the sprite (green). Changing this to 00 makes it red. There are lots of values that cause the sprite to disappear. And some other values do some weird things. 10, 92, and D0 make it red, and he just stands there (and you can't even talk to him). 0B makes it red and either spins or blinks.

43 = One that I can figure out! This one is the starting coordinate. As with warps and items, the first nibble determines the position from the left, ranging from 0-9, and the second nibble determines the position from the top, ranging from 0-7. In this case, 43 will be 4 blocks from the left, 3 from the top.

03 = The sprite itself. This one is fun to play with.

44 58 = Pointer to more data about the sprite (like the walking and text and such). This points to $149844, which is the third row in the data above.

02 = I don't know what this does.

You'll notice that the second row is the same as the first, except that the first two bytes are different, the pointer is different, and there are two FF's at the end. So let's go over the differences:

04 5A = Probably another flag that has to do with whether you beat Tabasco or not.

53 58 = Another pointer. This one points to the data for the sprite that appears AFTER you beat Tabasco, which points to $149853 (the fourth row).

FF FF = I'm not sure about this, I'm guessing it's basically some end code or something. Judging from the large amount of FF FF's throughout this data, I'm guessing this is what it is.

Now let's look at the third and fourth rows (posting them again, so you don't have to keep scrolling up):

Code: Select all

50 58 04 01 40 06 43 33 36 86 81 41 02 19 FF 
5F 58 04 01 40 06 43 33 36 86 81 41 02 1A FF
50 58 and 5F 58 = More pointers! The third row is the text before you beat Tabasco, the fourth is the text after you beat him. Anyways, 50 58 points to $149850, and 5F 58 points to $14985F, which has data 02 19 and 02 1A, respectively (more on what this means later).

04 = Behavior of sprite. Here are some I found:
00 = Stand, facing a constant direction
01 = Stand, look around
02 = Sprint in one spot
03 = Bounce around
04 = Walk
05 = Stand (And it follows you horizontally for some reason)
06 = Crash!!!
07 = Crash!!!
08 = Crash!!!
I didn't find anything above 08, but I'm guessing everything 06 and above crashes.

01 = The speed at which the sprite moves (if he walks). The lower the number, the faster he goes. If you make this value 07 or higher, he won't even move after changing direction.

40 = The number of frames the sprite waits before changing direction. So in this case, the sprite will stand there for 64/60 of a second before changing direction.

06 = This one's fun. This determines how many positions the sprite goes to in a cycle (see below).

43 33 36 86 81 41 = Another fun one. Here are all the positions on the screen that the sprite goes to. Each byte uses the left-top nibble format, where the first nibble is the position from the left, and the second nibble determines the position from the top. So basically with this data, the sprite goes to the following locations in this order:
(4, 3)
(3, 3)
(3, 6)
(8, 6)
(8, 1)
(4, 1)
This one is fun to play around with. It's fun watching him go diagonally! If he bumps into a wall (or you, or your Denjuu following you), then he'll change direction and go in reverse order. There's no limit to how many positions you can do, either (well, actually, there is, it's 255, but that's really high...). Just change the 06 above to determine how many you want! If you add more, though, you'll have to shift the bytes to the right, meaning you have to adjust lots of pointers...

02 = A relative ROM bank related to text. It seems that the game takes this value and adds $45 to it, meaning it points to bank $47 (which equates to $47 x $4000 = $11C000) in this case. Some numbers seem to glitch, though, even if the bank is meant for text. I need to figure this one out.

19 and 1A (depending on whether you beat Tabasco or not) = This is a text pointer. First, the game finds the bank (see above), then it takes this value, multiplies it by 2 (since address pointers are 2 bytes long), then adds it to the starting address (in this case, $11C000). If you haven't beaten Tabasco yet, then it takes $19, multiplies it by 2 to get $32, then adds it to $11C000 to get $11C032. Then, at $11C032, it takes the pointer there (96 46 in Power/Speed, which means it goes to $11C696 for the text, or in Diamond/Jade, CA 4A, which goes to $11CACA). If you beat Tabasco, then instead takes $1A instead of $19, multiplies by 2 to get $34, and the pointer is at $11C034 instead of $11C032. This pointer is CC 46 in Power/Speed, which means the address for the text is at $11C6CC; in Diamond/Jade, the pointer is 16 4B, which points to $11CB16 for the text).

FF = Probably an end code.
User avatar
Sanqui
Posts: 736
Joined: Sun Dec 16, 2007 12:25 am

Re: Some sprite data.

Post by Sanqui »

...
...
... O_O

... woah. Great job !!

Seriously. Where do you get the time to figure these things out? :fungus:
User avatar
andwhyisit
Site Admin
Posts: 1199
Joined: Fri Dec 14, 2007 9:24 pm

Re: Some sprite data.

Post by andwhyisit »

I sense the makings of a map editor. :D

Seriously, good work. :)
Blaziken257
Posts: 983
Joined: Fri Dec 22, 2006 11:52 am

Re: Some sprite data.

Post by Blaziken257 »

Sanky wrote:...
...
... O_O

... woah. Great job !!

Seriously. Where do you get the time to figure these things out? :fungus:
I've been less busy than normal in the past few days, so I figured I'd find more things to hack. XD And you know, I was actually trying to hack some more aspects about moves, but I accidentally came across sprites instead.
andwhyisit wrote:I sense the makings of a map editor. :D

Seriously, good work. :)
Thanks. :) I'm not as comfortable with sprites as I am with tiles yet, though... so that'll have to wait... unless someone else can figure it out...
Milnivri(imported)
Posts: 351
Joined: Wed Dec 27, 2006 10:14 pm

Re: Some sprite data.

Post by Milnivri(imported) »

Woahh.... good work!

This is madness.. someones gotta make a map editor as good as AdvanceMap some day. :D
Post Reply