A slickproductions.org /forum/index.php?PHPSESSID=5f0fck550j2m4m2fpbtkj2vkm1&action=printpage;topic=1865.0 e:/My Web Sites/Slick Productions - FFIV Message Board/slickproductions.org/forum/index3baf.html slickproductions.org /forum/index.php?PHPSESSID=5f0fck550j2m4m2fpbtkj2vkm1&topic=1865.0 e:/My Web Sites/Slick Productions - FFIV Message Board/slickproductions.org/forum/index3baf.html.z x Hg^ `D [~ OK text/html ISO-8859-1 gzip 0| [~ Tue, 10 Mar 2020 08:14:17 GMT 0 0 P Hg^ H% [~
Print Page - How do summons work?
Board of Slick
Library of the Ancients => Final Fantasy IV Research & Development => Topic started by: Pinkpuff on August 16, 2013, 12:53:02 PM
Title: How do summons work?
Post by: Pinkpuff on August 16, 2013, 12:53:02 PM
Summon spells seem to work differently from the other spells in the game. The spell you see in your player's spell list is not the actual summon effect spell itself. Rather it seems to simply be something that plays a particular animation, usually involving hiding the party, then launches another spell effect (e.g. "Bahamut" is launched by "Baham"), then unhides the party.
So the things I would love to be able to know/change about these are:
How does the summon spell (Baham) invoke the actual summon effect (Bahamut)?
Can we change which spells count as summon spells (i.e. which ones launch summons), and can we change how many of these there are?
Can we change which spell is launched by which summon? (e.g. Baham now launches, say, Reaction)
How are the summon animations invoked, and in what ways can we mess with it?
Title: Re: How do summons work?
Post by: chillyfeez on September 17, 2013, 01:05:10 PM
So this was an EXTREMELY long time coming, but I've found the Holy Grail.
The pointers for summoned monster image data (that is, which images are displayed when a summon spell is cast) are located at (ROM w/header) 689F0-68A11. Each pointer is two bytes long. Adding this value to D0000 gives you the location (in SNES LoROM) of the beginning of the graphic for the summoned monster. This is one of those things we'll be smacking ourselves about for years. The pointers are in that small block of non-graphical data right in the middle of all of the monster graphic data, immediately preceding the data for summoned monster graphics. :whoa:
There are still some important pieces to work out here: - The palette is referenced in a separate subroutine (specifically, it is picked at 029169 in LoROM), and I'm not quite sure how to change which palette is picked (there's a ton of rolling bytes preceding it, and it will take a long while to figure out exactly what needs to be changed in order to get a desired result). - I have not yet found how the game determines the "size," or more appropriately, the sprite arrangement, so a 4x4 monster can only be replaced by a 4x4 monster (so far). - Finally, since the pointer references a LoROM value at or above D0000, only image data that begins at 68200 (ROM w/header) can be used - D0000 through D7FFF does not exist in LoROM. The sort-of good news about this is that there is an empty block of code at 682C0 that is long enough to insert replacement images for up to three 4x4 monsters.
So, I've only hit the tip of the iceberg here, but we now know enough to be able to do this: (http://memberfiles.freewebs.com/22/01/115500122/photos/undefined/ImpImageChange.jpg)
Title: Re: How do summons work?
Post by: Grimoire LD on September 17, 2013, 01:22:21 PM
That is incredibly impressive work! Grand job Chillyfeez! I took a look at this a while back, but I didn't think my notes worth saving but something of what I found seemed to be size type, ah well. I'm sure that information will be found eventually.
That the pointers were randomly put aside right before Summoned Monster data is a bit strange. I wasn't expecting that to be the case at all. Very well done figuring that all out.
How did you find it, out of curiosity?
Title: Re: How do summons work?
Post by: chillyfeez on September 17, 2013, 01:47:18 PM
I followed your lead, breakpointing last action used... actually breakpointing the next byte, last subaction used. From there it was literally days worth of following bread crumbs. :edit: literally days, not literally breadcrumbs. :blush: When a spell is cast, its ID is copied into 26D2. At a certain point, the game checks if the value at 26D2 is between 31 and 3F. If it is, then it checks if it is 3E (Asura) or greater. If not, then it subtracts 31 (I haven't looked into Asura's specific subroutine yet, though I'm sure it involves picking one of her incarnations at random - Bahamut, being after Asura, also has a separate subroutine, but it probably is very similar to what is done with the previous thirteen spells), then adds 4D and stores back into 26D2.
26D2 becomes the point of reference for the rest of the casting. It's copied into 00E5 to determine the spell effect subroutine. It's copied into 34C8 to determine what spell name is displayed (during casting) It's copied into 33C5 to determine all audiovisual data - 33C5 then becomes the point of reference for the palette, graphics pointer, sprite arrangement, sound effect, and spell animation (separate from the monster summon image)
Title: Re: How do summons work?
Post by: Grimoire LD on September 17, 2013, 02:34:21 PM
That is essentially what I did, but for some reason at the time I didn't have a clear grasp on what I was seeing. Only in the past few weeks have I really applied myself to understanding what I'm reading instead of skipping through until I find something that seems familiar.
All in all this is a great start, I'm glad to see this work getting underway.
Title: Re: How do summons work?
Post by: chillyfeez on September 17, 2013, 07:13:47 PM
At a certain point, the game checks if the value at 26D2 is between 31 and 3F. If it is, then it checks if it is 3E (Asura) or greater. If not, then it subtracts 31 (I haven't looked into Asura's specific subroutine yet, though I'm sure it involves picking one of her incarnations at random - Bahamut, being after Asura, also has a separate subroutine, but it probably is very similar to what is done with the previous thirteen spells), then adds 4D and stores back into 26D2.
By the way, this is almost certainly why expanding the summon range has not proven successful. Making earlier spells into summons causes glitching when subtracting 31, and the game defaults to assuming later spells are Asura since they're higher than 3E. BUT, there's space enough for three more pointers after Bahamut, so with enough clever hacking it should be possible to add on at least three more summons pretty easily. I'll go into more detail with this after I've done some more tinkering.
Title: Re: How do summons work?
Post by: Grimoire LD on September 17, 2013, 07:25:44 PM
So with this do you now know the graphic pointers to the Summoned Monsters? It would be great to be able to have the player fight a summon (akin to FF4A's Lunar Ruins) like Shiva or Ramuh.
Title: Re: How do summons work?
Post by: chillyfeez on September 17, 2013, 09:09:39 PM
Well, yes, sort of. Technically, that's already known. The problem is that the graphical data for summoned monsters (that do not already appear as enemies) do not necessarily fit into any of the preset "sizes" for monsters, including the "special" sizes. I've successfully made enemies out of chocobos and sylphs, because they are 4x4 and 2x2, respectively (this was a while ago, though - I can't quite remember the pointers used, but I found them pretty easily by counting up from Imp). :edit: Imp begins at 68A18 (ROM w/header), and each sprite is 18 (hex) bytes long Shiva, Indra and Jinn (the only other three that do not appear as enemies) require quite a bit of work, and erasing the graphical data for a different monster using a program like tile layer. I suppose if one could figure out exactly how the game translates size bytes into sprite arrangements, then they could be changed and some of the seemingly useless ones could be better employed for this purpose. Unfortunately, I'm nowhere close to being able to do this.
Title: Re: How do summons work?
Post by: Grimoire LD on September 17, 2013, 09:57:07 PM
Ah, that is a slight bit of a shame. Oh well, I'm sure we'll get there eventually.
Title: Re: How do summons work?
Post by: Deathlike2 on September 18, 2013, 12:34:39 AM
Now only if you could tell us the probabilities of the Asura summon....
Title: Re: How do summons work?
Post by: chillyfeez on September 18, 2013, 04:55:59 AM
I've been focusing pretty exclusively on the graphics so far, but I know where the Asura subroutine is. Once I'm through with my current pursuit, I'll get into the Asura probabilities. Probably not today, but within the next few days for sure. I found the size/arrangement pointers AND the actual arrangement data late last night - including the animations (sprite changes, not the x,y movement - yet). I didn't have time to break it all down but I will this evening. Furthermore, now that I know how the sprite arrangements of summons work, I bet I'm not far from finding the same for monsters. I'll keep you posted.
Title: Re: How do summons work?
Post by: chillyfeez on September 18, 2013, 07:51:56 PM
OK, this still isn't complete, but I've got a lot more info here.
(in ROM w/header) 689f0-68a11: 2 byte pointers to summoned monster graphics (add pointer value to D0000 in SNES LoROM, or to 60200 in ROM)
6F460-6F481: 2 byte pointers to summoned monster sprite arrangement (add pointer value to D0000 in SNES LoROM, or to 60200 in ROM)
6F482-6F846: Summoned monster sprite arrangement data, each arrangement terminated by FF. Rows of sprites are numbered 0-7 in the tens place, each sprite within the row is numbered in the ones place beginning at 0 until the next row is reached. If a sprite space is left empty, add 80 (Hex) to the value.
XXXXX XX X XX XXXXXXX X XXX X XX XX XXXXXIf the summon is animated, the configuration of the alternating sprites follows the first configuration, using numbers in the ones place where the original configuration left off. So:
XXXXX XXXXX XX X XX XX X XX XXXXXXX AND XXXXXXX X XXX X OO OO XX XX O OOO O XXXXX XXXXX :edit: those sample arrangements are supposed to look like crude smiley faces, btw. It looks fine on my computer, but my tablet changes the font and it doesn't translate well. Sorry if they look weird.
There is a TON of unused space at 6EA20-6F45F and a sizeable block at 68448-688C7. Both can be pointed to for graphical data or tile arrangements if you want to get creative!
Up next - I'm gonna see if I can figure out how the game actually controls the sprite changes (how does it flutter like sylph, make one change like Shiva, among many others, rotate between three images like Asura?) :edit: Ugh. Once the initial image of the summoned monster is displayed, some really complicated stuff starts happening. Not sure I'll be deciphering the animation control process anytime soon.
Also, I'll be looking again at the palettes. I wasn't paying very close attention the first time around, but I'm beginning to wonder if maybe the summons have their own palettes, separate from those used for (enemy) monsters (which, of course, would be ideal)
Title: Re: How do summons work?
Post by: Grimoire LD on September 18, 2013, 09:59:25 PM
That is great news on the free space! Your documentation looks pretty defined moving forward. This is going quite well it appears.
Title: Re: How do summons work?
Post by: chillyfeez on September 18, 2013, 10:25:29 PM
Yeah, it won't be very easy for Pinkpuff to include this in FF4kster, but it turns out summons are very editable when you know where to look/what to change.
Title: Re: How do summons work?
Post by: Pinkpuff on September 19, 2013, 10:31:08 AM
FF4kster probably will not do much in the way of graphic editing but I'm still interested in this kind of thing for the sake of graphic/animation previews.
Title: Re: How do summons work?
Post by: chillyfeez on September 20, 2013, 10:10:25 AM
I'll be looking again at the palettes. I wasn't paying very close attention the first time around, but I'm beginning to wonder if maybe the summons have their own palettes, separate from those used for (enemy) monsters (which, of course, would be ideal)
Well, they do use the same palettes. The good news is, I found the table that assigns palettes to each summoned monster! It's at 7004C (ROM w/header). One byte per summon, addressed exactly the same way as the palettes for enemy monsters, so Imp is 00, Bomb is 55, Cocktric is 24, etc.
So now, simply by changing one byte, you can summon Dark Imp, or Balloon, Roc Baby, Wyvern.
Also, it's worth mentioning that we now have enough information to completely change the useless Imp spell into something cool like, say, Golbez's Shadow dragon!
Title: Re: How do summons work?
Post by: Grimoire LD on September 20, 2013, 11:24:04 AM
You have done incredible work Chillyfeez! Now we can modify Summons as we will to whatever monster we wish (Zeromus withstanding).
Title: Re: How do summons work?
Post by: chillyfeez on September 20, 2013, 04:31:14 PM
Thanks. Now, I didn't check - is that big empty block big enough to copy the image of any monster except Zeromus?
Title: Re: How do summons work?
Post by: Grimoire LD on September 22, 2013, 11:54:48 AM
Oh, I have no idea, I would just expect a monster that large to be out of scope for what could be set and chosen. I could be wrong though.
Title: Re: How do summons work?
Post by: chillyfeez on September 22, 2013, 08:32:17 PM
I think you're right about that. I think the way the game reads sprite arrangement data limits the height of a summoned monster to eight sprites (because everything starting with 8 or higher represents an empty space). That does exclude at least a few other monsters - Octomamm for one.
Title: Re: How do summons work?
Post by: chillyfeez on September 24, 2013, 12:19:47 PM
Here's the summon spell determination (Asura, Bahamut, other) subroutine:
$03/E03B C9 3E CMP #$3E A:0000 X:0000 Y:0000 ;Compare active spell with 3E (Asura) $03/E03D 90 1A BCC $1A [$E059] A:0000 X:0000 Y:0000 ;If less, jump down to 03/E059 $03/E03F C9 3F CMP #$3F A:0000 X:0000 Y:0000 ;If 3E or higher, compare active spell to 3F (Bahamut) $03/E041 D0 04 BNE $04 [$E047] A:0000 X:0000 Y:0000 ;If not 3F (and therefore Asura, jump down to 03/E047 $03/E043 A9 5D LDA #$5D A:0000 X:0000 Y:0000 ;If 3f (Bahamut), load 5D into memory $03/E045 80 18 BRA $18 [$E05F] A:0000 X:0000 Y:0000 ;Then jump down to 03/E05F (basically, end of routine) $03/E047 A2 00 00 LDX #$0000 A:0000 X:0000 Y:0000 [this is where we jump to if Asura] $03/E04A A9 02 LDA #$02 A:0000 X:0000 Y:0000 $03/E04C 20 79 83 JSR $8379 [$03:8379] A:0000 X:0000 Y:0000 ;Generate a random number between 00 and 02 $03/E04F 48 PHA A:0000 X:0000 Y:0000 $03/E050 A9 F8 LDA #$F8 A:0000 X:0000 Y:0000 $03/E052 8D D4 26 STA $26D4 [$7E:26D4] A:0000 X:0000 Y:0000 ;(Don't know what's going on here, seems irrelevant) $03/E055 68 PLA A:0000 X:0000 Y:0000 ;Look at random number $03/E056 18 CLC A:0000 X:0000 Y:0000 $03/E057 69 3E ADC #$3E A:0000 X:0000 Y:0000 ;Add 3E to random number (resulting in 3E-40) $03/E059 38 SEC A:0000 X:0000 Y:0000 [this is where we jump to if not Asura or Bahamut] $03/E05A E9 31 SBC #$31 A:0000 X:0000 Y:0000 ;Subtract 31 (resulting in D-F) $03/E05C 18 CLC A:0000 X:0000 Y:0000 $03/E05D 69 4D ADC #$4D A:0000 X:0000 Y:0000 ;Add 4D (resulting in 5A-5C) $03/E05F 8D D2 26 STA $26D2 [$7E:26D2] A:0000 X:0000 Y:0000 ;Make result new active spell $03/E062 EE 84 35 INC $3584 [$7E:3584] A:0000 X:0000 Y:0000 $03/E065 60 RTS A:0000 X:0000 Y:0000 It would seem that there is an even chance of getting each Asura, assuming the game does an adequate job of picking a random number between 00 and 02. In my trials, I seemed to be getting mostly 00s, less 02s, and only one or two 01s, but I didn't try enough to confidently admit weighting. I tried looking at the ops involved in the random number selection. Sort of followed it for about 20 ops (though didn't really grasp what was going on), then just clicked through the next 100 or so ops, marveling at the crazy crap that was happening, before finally giving up. So I am going to just run under the assumption that there is no way to affect the Asura probability.
Title: Re: How do summons work?
Post by: Grimoire LD on September 24, 2013, 12:42:33 PM
Very impressive! Now what you mentioned for...
$03/E052 8D D4 26 STA $26D4 [$7E:26D4] A:0000 X:0000 Y:0000 ;(Don't know what's going on here, seems irrelevant)
2680 is the Caster's Data. 26D4 would then be their 54th byte in data which according to the Tower of Babil Docs is...
54 next action party target(s)
This could be how the game over-rides the "dead targeting" when dealing with Asura's Life Spell, I can't really say for sure though.
So it seems as if the LDA XX and JSR 038379 are used in a variety of manners. Now that is quite intriguing. Making chests randomized may not actually be as difficult as I thought if all it takes is that simple formula.
Title: Re: How do summons work?
Post by: chillyfeez on September 28, 2013, 09:56:02 AM
So, I was playing around with manipulating summon images, and I discovered that I don't have all of the necessary information yet. It seems that, no matter how you change the sprite arrangement data, summon images will always occupy the same-sized rectangular area - which means that somewhere there is likely a table of summoned monster sizes like the table of monster sizes at 7015E (unfortunately, I checked, and summons don't use the same table as enemy monsters). :hmm: Back to the drawing board on this one...
Title: Re: How do summons work?
Post by: chillyfeez on September 30, 2013, 11:43:16 PM
So, just a quick update on my progress on this one. I found the missing data banks today. Yes, banks. Plural. You won't believe how ridiculously overcomplicated the process is to display a summoned monster Image. Not only is there the sprite arrangement data in the location I already specified above, the game also defines an arrangement of each 2x2 block of the monster's image (which also can be manipulated). Then, the size of the monster images is defined in a third location (nowhere near the rest of this data) as a grid of 2x2s. So, Imp, Bomb and Chocobo are 02 02, not 04 04 like you might expect. Incidentally, the summoned monsters' starting x/y locations are also defined in the data bank with their size (each summon has a 4 byte entry in the table). I still have to play with this a bit to figure out how it all works. At this point, I can change Imp into any monster that is eight sprites tall or less. I know it is possible to make them taller, because Odin, Leviatan and Asura all are taller, so I'll have to examine what's going on there to get an idea of how the game handles the height (remember, the difficulty is in the fact that sprites cannot be numbered 80 and above because then the game will read them as empty space). Of course, studying those three summons is complicated by the fact that they are all animated, so I've got my work cut out for me. Once I figure this all out, I'll post some pictures and a complete how-to.
Title: Re: How do summons work?
Post by: Grimoire LD on October 01, 2013, 12:49:19 AM
Oh my... now that sounds like a train wreck to sift through. Best of luck with it though.
Title: Re: How do summons work?
Post by: chillyfeez on October 01, 2013, 04:57:13 AM
Thanks - I can't even begin to imagine why they decided this was the best way to do this. It's like building a nuclear reactor in order to boil water to make pasta.
Title: Re: How do summons work?
Post by: chillyfeez on October 03, 2013, 09:17:25 AM
So I'm at the point where I can do this now: (http://memberfiles.freewebs.com/22/01/115500122/photos/undefined/SummonShadow-1.jpg) Once you realize how it's done, making tall (more than 8 sprites) monsters summonable is easy enough. Unfortunately (and I knew this but had forgotten), there seems to be something unique about the audiovisual routine of summon spells (the actual "spell" the monsters cast, not the image of the monster itself) that allows the summoned monster to go away and the party to return once the spell is over. So I can summon Shadow and make it cast Demolish, but then Shadow stays on the screen. So now I'm sifting through these audiovisual routines to see how they differ fundamentally from those of non-summoned monster spells.
Title: Re: How do summons work?
Post by: Grimoire LD on October 03, 2013, 09:56:18 AM
I never realized how tall the Shadow Dragon really was! Great work! As for the problem in making the sprites appear and disappear... F320 Determines visibility of party, FF:party hidden
Maybe set a breakpoint on that and use a normal summon?
Title: Re: How do summons work?
Post by: chillyfeez on October 03, 2013, 11:07:28 AM
Thank you, Grimoire, great idea! Hopefully this returns more fruitful results than the gibberish I've been looking at.
Title: Re: How do summons work?
Post by: chillyfeez on October 08, 2013, 10:15:34 PM
Cracked it. Refer to this thread: http://slickproductions.org/forum/index.php?topic=1890.0