øAslickproductions.org/forum/index.php?PHPSESSID=q4c29v6tmbbnv0gvgpv2lv9nn7&topic=1865.15e:/My Web Sites/Slick Productions - FFIV Message Board/slickproductions.org/forum/indexa3f4.htmlslickproductions.org/forum/index.php?board=13.160e:/My Web Sites/Slick Productions - FFIV Message Board/slickproductions.org/forum/indexa3f4.html.zx”@g^ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÈ…¬±OKtext/htmlISO-8859-1gzip8:Ö±ÿÿÿÿÿÿÿÿTue, 10 Mar 2020 07:40:27 GMT0ó°° ®0®P®€§²ð®”@g^ÿÿÿÿÿÿÿÿÍ&± How do summons work?

Author Topic: How do summons work?  (Read 4031 times)

chillyfeez

  • FF4 Hacker
  • *
  • Posts: 1,285
  • Gender: Male
  • Go ahead, ask me about Angel Feathers!
    • View Profile
Re: How do summons work?
« Reply #15 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!

Grimoire LD

  • FF4 Hacker
  • *
  • Posts: 1,684
    • View Profile
Re: How do summons work?
« Reply #16 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).

chillyfeez

  • FF4 Hacker
  • *
  • Posts: 1,285
  • Gender: Male
  • Go ahead, ask me about Angel Feathers!
    • View Profile
Re: How do summons work?
« Reply #17 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?

Grimoire LD

  • FF4 Hacker
  • *
  • Posts: 1,684
    • View Profile
Re: How do summons work?
« Reply #18 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.

chillyfeez

  • FF4 Hacker
  • *
  • Posts: 1,285
  • Gender: Male
  • Go ahead, ask me about Angel Feathers!
    • View Profile
Re: How do summons work?
« Reply #19 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.

chillyfeez

  • FF4 Hacker
  • *
  • Posts: 1,285
  • Gender: Male
  • Go ahead, ask me about Angel Feathers!
    • View Profile
Re: How do summons work?
« Reply #20 on: September 24, 2013, 12:19:47 PM »
Here's the summon spell determination (Asura, Bahamut, other) subroutine:
Code: [Select]
$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.

Grimoire LD

  • FF4 Hacker
  • *
  • Posts: 1,684
    • View Profile
Re: How do summons work?
« Reply #21 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.

chillyfeez

  • FF4 Hacker
  • *
  • Posts: 1,285
  • Gender: Male
  • Go ahead, ask me about Angel Feathers!
    • View Profile
Re: How do summons work?
« Reply #22 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...

chillyfeez

  • FF4 Hacker
  • *
  • Posts: 1,285
  • Gender: Male
  • Go ahead, ask me about Angel Feathers!
    • View Profile
Re: How do summons work?
« Reply #23 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.

Grimoire LD

  • FF4 Hacker
  • *
  • Posts: 1,684
    • View Profile
Re: How do summons work?
« Reply #24 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.

chillyfeez

  • FF4 Hacker
  • *
  • Posts: 1,285
  • Gender: Male
  • Go ahead, ask me about Angel Feathers!
    • View Profile
Re: How do summons work?
« Reply #25 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.

chillyfeez

  • FF4 Hacker
  • *
  • Posts: 1,285
  • Gender: Male
  • Go ahead, ask me about Angel Feathers!
    • View Profile
Re: How do summons work?
« Reply #26 on: October 03, 2013, 09:17:25 AM »
So I'm at the point where I can do this now:

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.

Grimoire LD

  • FF4 Hacker
  • *
  • Posts: 1,684
    • View Profile
Re: How do summons work?
« Reply #27 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?

chillyfeez

  • FF4 Hacker
  • *
  • Posts: 1,285
  • Gender: Male
  • Go ahead, ask me about Angel Feathers!
    • View Profile
Re: How do summons work?
« Reply #28 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.

chillyfeez

  • FF4 Hacker
  • *
  • Posts: 1,285
  • Gender: Male
  • Go ahead, ask me about Angel Feathers!
    • View Profile
Re: How do summons work?
« Reply #29 on: October 08, 2013, 10:15:34 PM »