Rotating Weapon Sprites in Custom Animations?[Resolved?]

I’ve been looking at how animations are rendered in the FEGBA games from the sprite sheets and OAM data that are dumped by FEditor.  It made me wonder about how the game takes weapon sprites and rotates them in some animations.

Using the Fighter for example, the attack windup uses a base body sprite, and uses a 32x32 axe sprite that is rotated as the axe falls behind his back for multiple frames.

Normally, I would redraw each frame separately as a new frame, but that would take up a lot of space on the sprite sheets (and in cases with many frames cause an OAM overflow).  Compared to the system of two sprites used in the stock animation, my method is practically barbaric.

Which made me wonder if there is a way to use rotation to save space on custom animations? Are there any tools out there that can do something like this, perhaps FEditor?  Could it be useful to do this for more complex animations that are in some cases too large?

Any animation veterans out there that have done something like this?

There’s certainly a way to do it, but I’m quite certain we don’t quite know how. Another good example would probably be the Hero shield which is hardcoded to rotate through the air and move (rather than being composed of many frames) but once again the exact mechanism is unknown.

Apart from the time saving aspect of doing that using layers and separate sprites in the creation process (which has no space saving effect upon insertion), this is pretty much an animation code issue, which no one has really plumbed the depths of save for @Hextator himself, to my knowledge.

It’s probably coded into the OAM manually (which I sort of know how to do but wouldn’t be able to hack it for you)

@Agro That uses the 0x26/0x27 command in the animation script correct? I know the FEditor documentation has a function to declare the thrown sprite, and I imagine the rotation and motion are preset. I might play around with that this week to see what it can do.

@Siuloir I was afraid that might me the case. I was hoping to make use of the individual assets and combining them as separate OBJ’s at render, but that would necessitate both the OAM coded to handle it, and for the sprite sheets to have each asset separate as well. @Hextator’s documentation has been a huge help to understand how the OAM data is formatted, but I have no idea how the sprite sheets are generated, let alone if individual assets can be added instead of full frames.

@CT075 It looks like rotations specifically use a transformation matrix to rotate the sprites, which I imagine are generated either beforehand or during the OAM data creation process. One could manually generate the matrix (based off of the angle of rotation and direction) and use it in the creation of the OAM data.

I am curious about making a sprite sheet and generating the OAM data based on it to test the functionality out. Is there any documentation about how FEditor generates its sprite sheets and OAM? It might prove useful for future tinkering.

The source code is pretty clean, you could try gleaning it from there.

Barring that my doc should have some info, some of which may have been from Nintenlord.

Here’s my Beans if you want info that I obtained from other people

Think of it like “Hextator’s Doc…of other peoples’ docs”

@Hextator I’ll be sure to add that to my list of “homework” to thumb through. I’ve been slowly working through the source code part by part to trace how things work, and it’s got plenty of annotations to help explain what’s going on.

Speaking of said research, I did a bit more reading on thrown sprites. I attempted to modify the Debug Script included in FEditor and added an extra 40x32 frame to throw, mainly to test out how the 0x26/0x27 commands operate.

Unfortunately, either the extra line I added to the start of the script is causing an error (unlikely but possible) or there is an issue actually inserting the frame onto the OAM sprite sheet.

I’ve traced it to a thrown error in the blit() function of GBAImage (Rectangle doesn’t fit within destination image), and there are 4 possibilities that throw it.

My best guess is that might take issue inserting the thrown sprite so close to the right edge of the sheet, but numerically everything seems to check out. It tries to insert a 5x4 tile sprite (32x32 square with an 8x32 column to the right for the palette) at location 0x1C (28th column, 0th row) on the OAM sprite sheet. Could the palette on the far right of the OAM sheet be causing the conflict, or is there another cause for the error?

best advice I can offer is to edit the source code to be less vague about where the exception is thrown

also yeah IS was way better at taking advantage of the GBA’s 2D sprite engine than FEditor is

for example FEditor calculates all sprite tiles as being 8 pixel aligned and can’t optimize for sprites that would otherwise fit in a smaller sprite shape had they been aligned

because I was young and new to programming when I wrote the algorithms for processing that stuff, which I had to come up with myself due to having no idea what the thing I was doing was even called

Reverse engineering is a rough business! Especially without having the handy tools IS had to compile all of their assets and data with.

I’ll try separating each condition to throw its own unique error and see where that takes me. Time to see how well my novice knowledge of Java code will do!

EDIT: Recompiling and running FEditor confirmed my suspicion that adding the throw sprite seems to cause the expected width to exceed the standard OAM sprite sheet dimensions. Has anyone else played around with inserting a throwable sprite before and run into this issue before?

EDIT 2: Did a little tweaking to the size requirement of a thrown sprite down to 32x32 pixels and retested the 0x26 command. Here’s a resulting screenshot just for fun!