øAslickproductions.org/forum/index.php?PHPSESSID=so1iojs5ocdn0o2vf0tti7fbu6&topic=1328.0e:/My Web Sites/Slick Productions - FFIV Message Board/slickproductions.org/forum/indexa9ea.htmlslickproductions.org/forum/index.php?PHPSESSID=so1iojs5ocdn0o2vf0tti7fbu6&board=17.0e:/My Web Sites/Slick Productions - FFIV Message Board/slickproductions.org/forum/indexa9ea.html.zx=õg^ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿȰUb'OKtext/htmlISO-8859-1gzip8:Öb'ÿÿÿÿÿÿÿÿTue, 10 Mar 2020 20:31:16 GMT0ó°° ®0®P®€§²ð®<õg^ÿÿÿÿÿÿÿÿ»5b' Spell Animation Guide v0.85

Author Topic: Spell Animation Guide v0.85  (Read 8763 times)

LightPhoenix

  • FF5 Hacker
  • *
  • Posts: 130
    • View Profile
Spell Animation Guide v0.85
« on: January 20, 2010, 01:50:13 PM »
Version 0.85 is out!

I didn't get nearly as far as I wanted to this month, so I'm calling it version 0.85.  Unfortunately my work schedule for the next three to four weeks is brutal, and I can't guarantee I'll make much progress on the guide.  I also don't get any time off for the holidays (I work at a hospital).  Nonetheless, my plan is to update this on or around January 1st.

I'm proud to say that of the main 128 functions, only two are unknown.  F7 is a complete unknown to me right now; it's used in Exploder, and may be an enemy-only function.  Removing it from the Blue spell has absolutely no discernible effect.  FC runs based on the target, sets a flag, and that's all I know.  I think it's a flag to change rows, since it's used in Pull.  Of the F5/F6 functions, I'd estimate about a third of them are known, including most of the F5 functions.  In particular, Missile and Roulette functions are giving me a bit of trouble.

I'd like people who read through to comment on anything confusing or unclear.  If there's any issues, I can try to clarify or fix anything.
« Last Edit: December 08, 2014, 04:44:43 AM by Jorgur »

Jorgur

  • Moderator
  • *
  • Posts: 437
  • Gender: Male
    • View Profile
Re: Magic Graphics Explained
« Reply #1 on: January 21, 2010, 04:52:45 AM »
This is great progress. We should now be able to add/replace magic to the game.

If you also find the lookup table for items, I can add the Sabre in v0.6 of my hack. ;)
Seing as the magic animations go by the common list, I am guessing that is also the case for weapons (and usables ?).

Note: The hacking guide has been updated and split into several documents. Check my topic for links.
« Last Edit: December 02, 2010, 09:46:47 AM by Jorgur »

LightPhoenix

  • FF5 Hacker
  • *
  • Posts: 130
    • View Profile
Re: Magic Graphics Explained
« Reply #2 on: January 29, 2010, 10:26:19 PM »
As it turns out, it's a little more complicated than it first seems.

One problem I was having was the "creature mask;" the color the monster changes when certain spells hit them (ie, blue for Ice, orange for Fire).  Changing the spell animation color didn't change this mask.

As it turns out, I was wrong about the meaning of one of the bytes.  The third byte isn't actually the animation shape.  The third byte is actually an animation routine.  This byte (and the high bit from the second byte, which as of yet I've never seen set) is passed to a variable ($F586) that in turn performs a lookup on a table at D9/7D42.  This table is a series of two-byte value indicating the address of the animation routine to perform.  These addresses all appear to be in the upper half of the D9 bank.

(Aside: they should be very easy to re-direct to expand)

The animation routines vary widely.  I'm still decoding them, but the basic format is a three-byte "header" whose purpose I have not discovered yet.  After the header are the instructions.  The end of the routine is given by a value of #FF.  This routine is read at (roughly) C1/C48A.

The instructions have two types.  Anything less than #80 is a simple frame call.  Anything with the bit 7 set (ie, above #7F) is a special instruction, given by the remaining bits.  Special instructions often take parameters, which are bytes that follow the instruction.  The number can vary, and is determined by the special instruction.

An example of the very simple code for Fire (at D9/8F5C):

Code: [Select]
00 20 00 80 0A 10 11 12 13 80 00 FF
The first three bytes are a header, whose function I have not determined.

The next byte is 80, which indicates a special function.  In this case, #80 indicates to use a creature mask of the color given in the next byte.  That makes this instruction 80 0A, and sets the creature mask to orange.  Changing the parameter on #80 does change the mask color; more on this below. 

Following that are individual frames to play: 10, 11, 12, 13. 

Next, we have another call to #80, this time with the parameter 00.  This indicates to clear the creature mask.

Finally, FF indicates the routine is over.

LightPhoenix

  • FF5 Hacker
  • *
  • Posts: 130
    • View Profile
Re: Magic Graphics Explained
« Reply #3 on: January 29, 2010, 10:51:24 PM »
(Part II: A Little More In Depth)

The parameters for #80 are not entirely straightforward:

Code: [Select]
00: Clear
02: Violet
0A: Orange
12: Blue
1A: Yellow
22: Green
2A: Grey/Purple (Periwinkle?)
32: Brown
3A: Lavender
42, 4A, 52, 5A, 62, 6A, 72: Black
7A: Gray

Looking at the code for #80, this increment of 08h becomes more apparent; the value gets divided by 8 to determine the color.  It also ignores any value higher than #0F (ie, above parameter 80).  I removed this restriction, and the function still worked, albeit with poor results.  None produced solid colors; most produced psychedelic rainbow patterns.  It looks like 42-72 are all blank masks; conceivably other colors could be added here.  They may be involved in the creature blinking when attacking though.

As an example of slightly more complicated functions, here are Ice (D9/914D) and Bolt (D9817C).

Code: [Select]
Ice
22 20 05 80 12 CA 08 5D CB 80 00 FF
Code: [Select]
Bolt
20 00 0A 80 1A 83 12 1E 83 80 1F 83 12 20 83 80
21 83 12 22 83 80 23 83 12 24 83 80 25 83 12 26
83 80 27 C3 03 B2 40 83 12 41 83 80 42 83 12 43
83 80 44 83 12 45 80 00 FF

Ice is an interesting one, but relatively straightforward.  The CA/CB function is a loop (#CA: start loop, #CB: end loop), with the first parameter being number of frames and the second being the starting frame.  Changing 08 to a lower number will result in a partial animation.  Changing it to 00 or greater than 08 crashes the game.  Putting in the frames manually (ie, 5D 5E 5F 60) does play the animation fine, albeit only half the animation since it's eight frames.  Obviously, using the loop is smaller than listing out every frame individually (4 bytes versus 8 bytes).

Bolt has a long function.  #83 superficially appears to control the animation color mask.  I believe this can be used for dynamic control of color; for Bolt this gives it a flashing animation as it switched between 83 12 and 83 80 (which I believe indicates no override from the master table).  Note that in the master table, #12 indicates a blue color; it does the same here.  I don't yet know what #C3 and #B2 do yet (or if it's one function #C3 with three parameters).  I'll need to look at the code and experiment.

I have a couple of very busy weeks ahead of me.  I'll try to keep up on the research, but it may be a couple of weeks before I post again.  After the 14th things should go a little smoother.

Jorgur

  • Moderator
  • *
  • Posts: 437
  • Gender: Male
    • View Profile
Re: Magic Graphics Explained
« Reply #4 on: January 30, 2010, 06:43:15 AM »
Another good piece of progress. Good work, as usual.

It doesn't come as a surprise that each spell has its own routine, seeing as how different the spells can be. Weapon animations, however, I'm not so sure about. I would be happy to give you some advice on how to put down the missing pieces, but my guess is that you would prefer doing it on your own (like I do).

You should make a document on this, or if you don't have time, I could document it in your name (I have plenty of time :p). Perhaps a little later though, when everything has been tested and solved in detail.

LightPhoenix

  • FF5 Hacker
  • *
  • Posts: 130
    • View Profile
Re: Magic Graphics Explained
« Reply #5 on: February 05, 2010, 01:14:12 PM »
Just dropping by to say I'm still working on the animation codes.

I've a clue where to start on weapon animations, but any information you might have I'd be glad to take.  I do enjoy the challenge of doing it myself, but unfortunately my time is not free.

I'm working on a document, and I'm writing down everything that I find.  I tend to be a perfectionist, so I'm holding off on releasing a doc until I've got most of it down.  Additionally, I'm occasionally wrong about stuff; the bytes in the master data being one.  So putting out incorrect information is not something I'm keen on doing.

After next weekend (the 14th) my time is freed up significantly, so I'll have more time to test then.

LightPhoenix

  • FF5 Hacker
  • *
  • Posts: 130
    • View Profile
Re: Magic Graphics Explained
« Reply #6 on: March 08, 2010, 11:57:20 AM »
Another month, another post!

I'm making some decent progress on the animation routines.  I've documented roughly 32 of the 128 special commands, although to fully understand some of the them I think I'll have to look at the assembly.  I have a feeling some of them are specially designed for individual spells, and may not have general utility with assembly hacking. 

Unfortunately the documentation process is less straightforward than plugging in numbers.  Many commands are designed to work with each other (as a simple example, C8 XX and C9 indicate a loop, with XX being the number of loops).  This means I have to analyze the routines individually.  For Black/White/Time it wasn't too rough, but Summons for example are fairly complex.

I've also elucidated two of the three bytes in the header: the first is a reference to a table at C1/B31C (two one-byte values) that gives the height and width, and the second is the animation speed.  I'm relatively certain the third value is also a lookup, but I haven't looked into it yet.

I've made no progress on the swinging weapon animations, although I may take a stab at it so I don't burn myself out on the animation routine commands.

I would estimate it will take at least another month or two for me to get all the codes documented.  Because of this, I intend on releasing an early version of the guide I'm writing, as well as some references (ie, tables).  Most likely this will be by the end of the week.

Jorgur

  • Moderator
  • *
  • Posts: 437
  • Gender: Male
    • View Profile
Re: Magic Graphics Explained
« Reply #7 on: March 08, 2010, 01:57:09 PM »
Yay, more progress! :cookie:
Info on spell animations will come in handy later, because I plan on modifying some of them in my hack (e.g. Ice 3). I am coming closer to finishing v0.6, but I won't be changing spell animations at least until v0.7. If you feel like it, could you at least see if you can find the location of the weapon animations for me? All I need is basically to copy the an animation to another, so that would be a big help.

By the way, how is the C1 disassembly coming along?
« Last Edit: March 09, 2010, 09:45:11 AM by Jorgur »

LightPhoenix

  • FF5 Hacker
  • *
  • Posts: 130
    • View Profile
Re: Magic Graphics Explained
« Reply #8 on: March 11, 2010, 12:56:26 PM »
Ice 3 is a neat one, lots of usable codes.  I got a lot of the main ones (Animation Offset, Loop Routine) from Ice 3.

I'll see what I can do vis a vis the weapon animations.  Right now I'm more focused on the magic animations, but I can at least give it a look.  My suspicion is that it will use a similar system to the magic animations.

The C1 disassembly is basically stalled while I work on animations.  The bank itself is somewhat fragmented and convoluted, but generally controls battle animation in general.  For example, the assembly for all the special commands is in C1 (and takes up a good chunk of it).  I'm confident C1 is where the weapon animations are as well.  What makes it difficult is that there a large number of tables within C1 itself, so I'm finding I often have to go back and disassemble individual bits of code... even code that at first glance looks okay.

LightPhoenix

  • FF5 Hacker
  • *
  • Posts: 130
    • View Profile
Battle Animation Guide (Updated 5/4/10)
« Reply #9 on: March 12, 2010, 10:57:45 AM »
[EDIT]Updated to 0.7, with several more magic animations.  More notes below.

[EDIT]I've just updated the guide to 0.6.  No new work has been done on the magic animations.  However, the guide now includes weapon animation information, researched by request of Jorgur.  Also, the Master Tables have been added to the main guide.  Therefore, I've removed that file.

****

The Animation Guide is the main file, and contains a relatively complete rundown of what I have so far.  With it, basic changes in magic animation (and magic in general) should be possible.  If there are any changes or clarifications that you feel should be made, please let me know.  Note that I don't know everything about the system yet; some aspects have been a little elusive.  I will continue to update this file as I learn more.  The current version is 0.5.

The second file is a list of Animation Routines which I use as a reference for testing.  This is very rough, contains no explanations or clarifications, and basically is just a dump file so I don't have to keep referring to the ROM during testing.

As I said, I do intend to continue updating the guide with more information.  Any updates will be posted in this thread, and I'll edit this post to point them out.
« Last Edit: May 04, 2010, 09:19:27 PM by LightPhoenix »

Jorgur

  • Moderator
  • *
  • Posts: 437
  • Gender: Male
    • View Profile
Re: Magic Animation Guide
« Reply #10 on: March 12, 2010, 04:32:01 PM »
This is impressive, to say the least. I did not really expect so much information already in the first version. As usual, I do have some comments though.
As I open the main document, the first thing I notice is that the amount of text is rather large. I like reading guides containing figures and examples, as opposed to having to read through blocks of text to understand something. Therefore I find it a little tedious to read in the beginning.

After that point, however, the lists start appearing. These are lightweight and informative, and seem to be well organized. "Routine Command List" and "Routine Commands" are particularly interesting. Like you say, the information is not quite complete enough yet to fully edit spells, but with some work here the guide would be a powerful asset indeed.

I see you refer to the animations as "routines". This can cause confusion. To me, the word "routine" only refers to machine code (but I don't know if that's just me). Maybe "script" is more appropriate?

I have not read through the guide in detail, seeing as how in-depth the animation data goes. Later, when I decide to move onto graphical editing I will probably be able to deliver more specific feedback.
« Last Edit: March 12, 2010, 06:43:27 PM by Jorgur »

LightPhoenix

  • FF5 Hacker
  • *
  • Posts: 130
    • View Profile
Re: Magic Animation Guide
« Reply #11 on: March 20, 2010, 08:04:38 AM »
Jorgur, thanks for the feedback!  Personally, I like a little explanation to go along with the lists.  Looking over the guide, it is a little long-winded and light on examples.  Specifically, at this point I'm going to have to include the master table in it as well.

I wanted a break from deciphering the animation scripts, and since you asked about weapon animations, I decided to look into that.  As it turns out, those are included in the Master Table as well.  I haven't figured it all out yet, but I'll give you what I have since I know you're interested.  I located a series of scripts that corresponded to weapons; the table referencing these is at D9/9E34.  This table is loaded at C1/A12B, where X is obtained from $F586. $F586 is set from the Master Table.  I was looking at the basic Staff attack, which used row 1F8 from the Master Table (ie, D8/38EE,X, where X = 1F8).

The weapon script is run separately from the magic scripts; there's different code for parsing, and it looks like the commands might be different.  I'll know more as I look into it more.
« Last Edit: March 27, 2010, 12:47:28 PM by LightPhoenix »

Jorgur

  • Moderator
  • *
  • Posts: 437
  • Gender: Male
    • View Profile
Re: Battle Animation Guide (Updated 3/27/10)
« Reply #12 on: March 29, 2010, 09:43:11 AM »
Quote
$F586 is set from the Master Table.  I was looking at the basic Staff attack, which used row 1F8 from the Master Table (ie, D8/38EE,X, where X = 1F8).
Haha, I tried finding the data with that scribbled info without any luck.

Okay, checking the new file now...

This is great! Exactly what I needed. I should be able to add new weapons to v0.6 now.
The guide has improved a bit from last version, but I still think it needs more work. The document is clearly dominated by ROM data rips. They are nice to use as examples to look at, but mostly I can use the hex editor to view ROM data.

LightPhoenix

  • FF5 Hacker
  • *
  • Posts: 130
    • View Profile
Re: Battle Animation Guide (Updated 5/4/10)
« Reply #13 on: May 04, 2010, 09:35:54 PM »
It's been a month, and I apologize for not updating sooner.  Chaotic times and all that.  I may be moving in the next month or two, so that may impact updates.

I've got a pretty good chunk of the animation commands done.  At this point, a lot of it is involving looking at the assembly to figure out what's going on.  An excellent example would be the "Priority" commands; basically they control the Z-stack, but the only reason I figured it out was because it altered the SNES VRAM stuff.  I wouldn't have been able to figure it out without Anomie's excellent doc.

As suspected, Byte 4 of the Master Table contains data that certain animation commands use.  I don't have it entirely figured out yet.  I'm beginning to suspect the third byte of the routine header also contains information on sprite processing.

I've done a lot of work on understanding how sprites are accessed.  I'm not prepared in the least to write it up.  To tell the truth, I don't understand a lot of it yet.  I think it was already known that magic sprites are stored starting at D9/0000 in 3BPP format.  Byte 1 of the Master Table is converted in a convoluted manner to get a starting position added to D9/0000.  It's not a simple formula at all.  The sprite is copied to 7F/D000, where it is presumably processed and drawn to the screen.  While the formula is complex, the potential to add new battle sprites seems very possible and dare I say easy on this end.  In theory, you could simply redirect D9/0000 (this is directly referenced) to a new E-bank or F-bank even.

Now, the actual frame commands (ie, 10 11 12 13 in Fire) in the routines are a little trickier.  It looks like those are actually commands as well.  It looks like they determine how frames are processed.  I'm really not sure what's going on here, and the assembly isn't really helping either.  Somehow this must indicate how to draw the sprites, but I'm really at a loss how.  I'll be pursuing this a bit more as I try to finish up the animation commands.

Jorgur

  • Moderator
  • *
  • Posts: 437
  • Gender: Male
    • View Profile
Re: Battle Animation Guide (Updated 5/4/10)
« Reply #14 on: June 30, 2010, 11:37:48 PM »
Do you think the document is completed enough to be submitted to the main site?