Author Topic: Developing FF4kster: a comprehensive editor for FF4  (Read 223640 times)

chillyfeez

  • FF4 Hacker
  • *
  • Posts: 1,234
  • Gender: Male
  • Go ahead, ask me about Angel Feathers!
    • View Profile
Re: Developing a comprehensive editor for FF4
« Reply #525 on: November 24, 2013, 11:44:52 AM »
Hi, LordGarmonde, and welcome. It was only about a year and a half ago that I started posting here. In addition to being a vast storehouse of knowledge on the subject, this is a great place to level-grind ffiv hacking skills by bouncing ideas off of others.

Anyway, this is something I've wondered out loud about before, but haven't actually ever looked into. I don't believe I've ever seen any documentation on changing world map geography, aside of course from actually editing the map (with yousei's or by hand with a hex editor). I'd be interested in seeing what you come up with.

One caveat about the tools you're using: yousei's uses only version 1.0, and FF4Kster is really only fully compatible with v1.1 (specifically, it won't properly modify battle commands and level up data for v1.0, possibly more). Best workaround for this is to make map edits with yousei's, then patch the changes into a 1.1 ROM for use with pretty much any other editing tool.

You might try, by the way: find where in RAM the game loads the current world map data (might be known, I'm not sure), set a breakpoint to one of the tiles that changes with an event, then set and clear the event flag to observe the changes. Hope that helps!

Pinkpuff

  • Flan Princess
  • *
  • Posts: 923
  • Find a Megalixir in Unprecedented Crisis!
    • View Profile
Re: Developing a comprehensive editor for FF4
« Reply #526 on: November 26, 2013, 04:02:03 AM »
Latest update uploaded! I added the Fight parameters but disabled the autobattle editor until I can get it to write (and edit!) the golbez scripts correctly. I know what I have to do in order to accomplish that, I just have to get around to doing it.

First off: You are all my heroes. I love FF4 and I've picked at it over the years but this site and the editors and research you've done rivals the work of every scientist I've ever worked with.

I would just like to echo this sentiment. It's because of everyone's dedication and research that FF4kster was even possible to begin with. The people here really go above and beyond the call of duty and I'm trying my best to compile it all into one neat package. My vision is that this editor will someday be to FF4 what FF Hackster is to FF1.

That said I hope to keep on with my own projects because it's so much fun breathing life anew into this game. Hopefully this is a new contribution and if not please point my noobness in the right direction. I've been working with Yousei's map editor and PinkPuff's (amazing!) program to mess around with the events surrounding Mist; particularly in regard to how it changes the world map.

I hope to someday soon have a map editor incorporated into FF4kster. In fact I think once the autobattles are working I might just take that on as the next component to tackle. (I'll still be doing misc updates with the info found in the wishlist threads as I go of course.)
Let's dance!

Grimoire LD

  • FF4 Hacker
  • *
  • Posts: 1,676
    • View Profile
Re: Developing a comprehensive editor for FF4
« Reply #527 on: November 26, 2013, 02:14:29 PM »
I'm glad to see the information was well worth it! I'll try to add in the other commands since it seems you properly translated this all to the editor!

Looks like all of the Fight Command parameters work flawlessly, that is good news. I wasn't sure if they would translate directly into the editor but they work great! Let's see... next should be the Magic Routine (White/Black/Call/Ninja along with several other commands which end up using it)

But since White/Black/Call/Ninja all use the same format to access spells, it's understandable that they would all have the same parameters.


The important parts in the Magic Routine that can be easily modified is the starting point of Magic and where White Magic (Will based spells) and All Other Magic begins as well as the Magic Animations starting points. Somehow Phoenix tied that to the character at the start of the Magic, I'm not certain... at all... how he managed it.

Magic Routine

Basic Magic Routine which all spells run through including, Type of Magic Animations and Stats Decided For Magic

  • Type of Magic Animation End Points
    • White Magic Animation End:1CF24
    • Black Magic Animation End : 1CF28
    • Summon Magic Animation End: 1CF2C

  • Stat Used in Magic Casting
    • White Magic Casting End:1D0BD
    • Stat to Use in Magic Casting: 1D0C4

Note: Now this requires a bit of explanation... 19 is the first Black Magic  Spell, Toad. Which is what the game checks to see if it is outside of White Magic and same is done with Imp and Bahamut respectively.

Secondly the White Magic Casting also looks at Toad (19 again), to see if it should add the +1 to the Address to read Will instead of Wisdom, if it is above Toad it skips this check and goes with Straight Wisdom.

The second address is the Caster's Modified Wisdom +X (if applicable) the X is only used if it read the spell under 19. In ROM this gets bit-flipped and looks like 9726 but is actually the address 2697, Modified Wisdom.


Sorry if its not as concise as the first Fight one was.

 :edit: I missed your first post, sounds like you're onto something LordGarmonde! It will be interesting to see how that all ends up actually working!
« Last Edit: November 26, 2013, 02:26:31 PM by Grimoire LD »

Pinkpuff

  • Flan Princess
  • *
  • Posts: 923
  • Find a Megalixir in Unprecedented Crisis!
    • View Profile
Re: Developing a comprehensive editor for FF4
« Reply #528 on: November 27, 2013, 04:03:10 AM »
Updated yet again! This time Boast parameters, as well as the magic ranges in the above post, but they have been put into the Features Editor section rather than the Command Editor. Also I have not incorporated the "stat to cast magic with". If there is significant demand for this feature then I will put it in, after all it is always fun to be able to toy with things and that's what the editor is about anyway, but I've also established a sort of fuzziness with certain things for the sake of reducing the amount of detail the user needs to know about the inner workings of the ROM in order to use FF4kster to achieve the effects they're expecting.

For example, when you change the "Key Items" range, it affects whether they get highlighted as key items, whether they can be dropped, etc. all at once, even though we know how to manipulate all those features indpendently. This is because I'm running under the assumption that, the vast majority of the time, when you want to change something into (or out of) being a key item, you want all those features to change. The white magic animation and white magic stat ranges have been lumped together for the same reason, and unless there is significant demand otherwise I think I'll leave the magic stats alone, especially since they need to be one apart from each other. It would be unlikely to occur to someone that changing white magic to using VIT would cause black magic to change to using AGI as a side effect, and would probably find such behaviour confusing. So, that coupled with the low probability that someone would want to change the magic stats anyway led me to decide to leave that out for now.

I'm glad to see the information was well worth it! I'll try to add in the other commands since it seems you properly translated this all to the editor!

 :childish: I'll eventually be incorporating everything relevant that's been posted here and in the wishlist threads, but it will be bit by bit and in no particular order, just based on what I feel like working on all the time.

Looks like all of the Fight Command parameters work flawlessly, that is good news. I wasn't sure if they would translate directly into the editor but they work great!

Glad to hear it! Hopefully we'll have as much luck with the rest of them!
Let's dance!

Grimoire LD

  • FF4 Hacker
  • *
  • Posts: 1,676
    • View Profile
Re: Developing a comprehensive editor for FF4
« Reply #529 on: November 27, 2013, 12:41:47 PM »
Updated yet again! This time Boast parameters, as well as the magic ranges in the above post, but they have been put into the Features Editor section rather than the Command Editor. Also I have not incorporated the "stat to cast magic with". If there is significant demand for this feature then I will put it in, after all it is always fun to be able to toy with things and that's what the editor is about anyway, but I've also established a sort of fuzziness with certain things for the sake of reducing the amount of detail the user needs to know about the inner workings of the ROM in order to use FF4kster to achieve the effects they're expecting.

For example, when you change the "Key Items" range, it affects whether they get highlighted as key items, whether they can be dropped, etc. all at once, even though we know how to manipulate all those features indpendently. This is because I'm running under the assumption that, the vast majority of the time, when you want to change something into (or out of) being a key item, you want all those features to change. The white magic animation and white magic stat ranges have been lumped together for the same reason, and unless there is significant demand otherwise I think I'll leave the magic stats alone, especially since they need to be one apart from each other. It would be unlikely to occur to someone that changing white magic to using VIT would cause black magic to change to using AGI as a side effect, and would probably find such behaviour confusing. So, that coupled with the low probability that someone would want to change the magic stats anyway led me to decide to leave that out for now.

A new update already? You are on a roll! I'll try to add some more parameters to this post.

Haha, your reasoning behind not changing the magic stat decider is well thought out. It would be too complicated without additional explanations (and it seems so few people read the readme that it could cause problems. Not to mention it seems pretty rare that someone would want to change Magic from Wisdom/Will to... Equipped Weapon, or something rather nonsensical like that in the first place.

Looks like the Magic moving works (though as always I would be a little cautious about changing the Summon range as their animation does cause the characters to vanish and if the right Effect isn't used they won't reappear.) However if you plan on making the "summon" spell- (Imp to summon Imp, etc...) that does work ideally. In fact now that I think on it... what is the issue with casting the Summon Spells on their own?

As for the Boast parameters... I've noticed a bit of a glitch. What you added Sets it to the chosen value rather than Incrementing the existing value. Did you only change the amount and stat parameters? Or was there another thing that was dealt with there? I just tested it on a Clean Rom and it still seems to happen.

Quote
:childish: I'll eventually be incorporating everything relevant that's been posted here and in the wishlist threads, but it will be bit by bit and in no particular order, just based on what I feel like working on all the time.

That's a good way to handle it. That way you don't become so bogged down by forcing yourself to work on an area you may not want to tackle at that moment.

Quote
Glad to hear it! Hopefully we'll have as much luck with the rest of them!

Heh, well aside from Boast's oddities (everything else works right about it. Just the Setting rather than Incrementing portion is the problem) everything in this update works great! Being able to free up the Summon Spells for one can really expand the amount of usable ability slots.

 :edit:

0x1ECD3 69 10   ADC #$10   A:0012   X:0000   Y:0000   P:envMxdizc - Add 10 (in hex) to it. By chance did that 69 somehow get changed? That's the actual "Add to Value" instruction.

 :edit: 2: No, that's not the problem. I just looked it up in a Hex Editor, its untouched, hmm...

Oh! There's the problem! And it's my fault for not being clear enough.

ROM...
0x1ECD0   BD 17 20   LDA $2017,x[$7E:2017]   A:0010   X:0000   Y:0000   P:envMxdiZc - Load User's Modified Wisdom.
0x1ECD3 69 10   ADC #$10   A:0012   X:0000   Y:0000   P:envMxdizc - Add 10 (in hex) to it.

AND ADD...

0x1ECDB   9D 17 20   STA $2017,x[$7E:2017]   A:0022   X:0000   Y:0000   P:eNvMxdizc - Store A in User's Modified Wisdom

I forgot that Crucial step. I'm sorry about that.

What you could actually do with this is load one value (say... Will) and load that onto another Stat + Value. So if someone wanted to make a Caster's Defense Power - Will+5. They couldn't stack it because it would still continue to read from Will.

Again, very sorry for not clarifying the "Store A in..." portion.
« Last Edit: November 27, 2013, 01:12:51 PM by Grimoire LD »

chillyfeez

  • FF4 Hacker
  • *
  • Posts: 1,234
  • Gender: Male
  • Go ahead, ask me about Angel Feathers!
    • View Profile
Re: Developing a comprehensive editor for FF4
« Reply #530 on: November 27, 2013, 02:47:20 PM »
Grimoire - do you mean what happens if you cast 4D imp instead of 31 imp? They never disappear, and the palette will be wrong, too. I haveno clue why, considering the fact that the party's reappearance s coded into that part of the spell...

Grimoire LD

  • FF4 Hacker
  • *
  • Posts: 1,676
    • View Profile
Re: Developing a comprehensive editor for FF4
« Reply #531 on: November 27, 2013, 03:23:09 PM »
That is true, but what isn't coded is the "Summon Orbs" which vanishes the party. (having already past the point of "All Other Spells" in Animations) It seems without a proper appearance/disappearance animation the game may react this way. I don't currently have time at the moment, but try and add the Actual Summon spell to a Magic List after moving the default Summon Orb Animation up into the 4D Imp. That might help explain some things.

Pinkpuff

  • Flan Princess
  • *
  • Posts: 923
  • Find a Megalixir in Unprecedented Crisis!
    • View Profile
Re: Developing a comprehensive editor for FF4
« Reply #532 on: November 27, 2013, 04:15:44 PM »
Ok so in other words, the save routine should additionally write the "stat to increase" byte to 1ECDC, correct?
Let's dance!

Grimoire LD

  • FF4 Hacker
  • *
  • Posts: 1,676
    • View Profile
Re: Developing a comprehensive editor for FF4
« Reply #533 on: November 27, 2013, 04:34:49 PM »
Indeed, that is correct. I need to be more careful with that sort of thing.

chillyfeez

  • FF4 Hacker
  • *
  • Posts: 1,234
  • Gender: Male
  • Go ahead, ask me about Angel Feathers!
    • View Profile
Re: Developing a comprehensive editor for FF4
« Reply #534 on: November 27, 2013, 09:26:54 PM »
If I'm not mistaken, the subroutine that makes the summon orbs appear and makes the party disappear is the same one that subtracts 31 and adds 4D to the current subaction. If I'm right about that, then there would still be significant problems... I think this was all done just so Asura could choose from three different spells. What a waste...

Grimoire LD

  • FF4 Hacker
  • *
  • Posts: 1,676
    • View Profile
Re: Developing a comprehensive editor for FF4
« Reply #535 on: November 28, 2013, 12:09:53 AM »
Indeed I think that was its purpose as quizzical as it is but those instructions are also easily located in my disassembly of the Magic Routine, specifically the -31 portion which would cause the problems in most ordinary situations.
Code: [Select]
$03/E050 C9 3E CMP #$3E A:0033 X:0000 Y:0000 P:eNvMxdizc - Is it Asura?
$03/E052 90 1A BCC $1A    [$E06E] A:0033 X:0000 Y:0000 P:eNvMxdizc - If it is less than Asura branch to 03E06E
------------------------------------------------------------------------------------------------------------------------------------------------

--------------------------------------------------------------------------------------------------------------------------------------------------
$03/E06E 38 SEC A:0033 X:0000 Y:0000 P:eNvMxdizc - Set Carry Flag
$03/E06F E9 31 SBC #$31 A:0033 X:0000 Y:0000 P:eNvMxdizC - Subtract 31 from A.
$03/E071 18 CLC A:0002 X:0000 Y:0000 P:envMxdizC - Clear Carry Flag.
$03/E072 69 4D ADC #$4D A:0002 X:0000 Y:0000 P:envMxdizc - Add 4D to A.
$03/E074 8D D2 26 STA $26D2  [$7E:26D2] A:004F X:0000 Y:0000 P:envMxdizc - Store A in Next Action to Take.
$03/E077 EE 84 35 INC $3584  [$7E:3584] A:004F X:0000 Y:0000 P:envMxdizc - +1 to 7E3584.
$03/E07A 60 RTS A:004F X:0000 Y:0000 P:envMxdizc - Return to 03CD33.

chillyfeez

  • FF4 Hacker
  • *
  • Posts: 1,234
  • Gender: Male
  • Go ahead, ask me about Angel Feathers!
    • View Profile
Re: Developing a comprehensive editor for FF4
« Reply #536 on: November 28, 2013, 01:20:13 AM »
It would be possible to make more summon spells if you were willing to have only one (nonrandom) Asura, but man, it'd be so much work for the relatively worthless privilege of keeping Imp.
Actually adding entirely new and extra summons into the mix (by expanding the range in either direction) would be extremely complicated because of all of the new pointers, data, etc. you would have to add into the mix, not to mention how the introduction of new pointers would necessarily push the existing sprite and tile data forward, thus rendering the existing pointers invalid... I'm fed up with the process just thinking about it.

The better use of the range info would probably be to decrease the amount of summons in favor of more black or white magic spells...

Displacer

  • FF4 Hacker
  • *
  • Posts: 27
    • View Profile
Re: Developing a comprehensive editor for FF4
« Reply #537 on: November 29, 2013, 08:37:19 AM »
Here we go:
Code: [Select]
Enemy Formation Table (70200-711FF)
Each formation is represented by 8 bytes:

Byte 0:
 Bit 0: ?
 Bit 1: ?
 Bit 2: ?
 Bit 3: Forced Back Attack
 Bit 4: Enemies Have Boss Death
 Bit 5: Monster(s) 3 Begin In Eggs
 Bit 6: Monster(s) 2 Begin In Eggs
 Bit 7: Monster(s) 1 Begin In Eggs

Byte 1: Monster(s) 1 Type

Byte 2: Monster(s) 2 Type

Byte 3: Monster(s) 3 Type

Byte 4: Qty. of Each Monster Type (max 8 altogether)
 Bit 0-1: ?
 Bit 2-3: Monster(s) 3 Qty.
 Bit 4-5: Monster(s) 2 Qty.
 Bit 6-7: Monster(s) 1 Qty.

Byte 5: Preset Monster Arrangement
 -Values 00-91
 -Total qty. of monsters is limited by arrangement

Byte 6:
 Bit 0: Can't Run
 Bit 1: No Game Over (think impossible Dark Elf battle)
 Bits 2-3: Battle Music (Regular/Boss/Fiend/No Change)
 Bit 4: Character Battle (Edward v. Tellah, etc.)
 Bit 5: Auto Battle (not sure where the AI is for these?)
 Bit 6: Floating
 Bit 7: Transparent (Breath, Mind)

Byte 7: ?
The unknown bits and byte seem to be insignificant, or at least not worth changing.

In case anyone's interested, the so-smart-it's-stupid way I traced this: Took two identical files, changed the monster type of group 1 from imp to basilisk (using zyrthofar's editor), created an .ips patch, read the patch with my hex editor to determine the altered location. Voila!

Bits 0-2 of byte 0 are used to load sets of data, a lot of sets. It is used as an offset to load these sets. There are 2 sets of 8 bytes that are loaded first, located at 16/FBAC and 16/FBDC. It is also used to load 2 sets of 4 bytes each. Located at 16/FC0C and 16/FC24. Here is the loading code ($29A4 holds byte 0):

Code: [Select]
02/8ECA: AD A4 29     LDA $29A4
02/8ECD: 29 07        AND #$07
02/8ECF: 0A           ASL
02/8ED0: 0A           ASL
02/8ED1: 48           PHA
02/8ED2: 0A           ASL
02/8ED3: AA           TAX
02/8ED4: 7B           TDC
02/8ED5: A8           TAY
02/8ED6: BF DC FB 16  LDA $16FBDC,X
02/8EDA: 99 CB 6C     STA $6CCB,Y
02/8EDD: BF AC FB 16  LDA $16FBAC,X
02/8EE1: 99 D3 6C     STA $6CD3,Y
02/8EE4: E8           INX
02/8EE5: C8           INY
02/8EE6: C0 08 00     CPY #$0008
02/8EE9: D0 EB        BNE $8ED6
02/8EEB: 7B           TDC
02/8EEC: A8           TAY
02/8EED: 68           PLA
02/8EEE: AA           TAX
02/8EEF: BF 0C FC 16  LDA $16FC0C,X
02/8EF3: 99 DB 6C     STA $6CDB,Y
02/8EF6: BF 24 FC 16  LDA $16FC24,X
02/8EFA: 99 DF 6C     STA $6CDF,Y
02/8EFD: C8           INY
02/8EFE: E8           INX
02/8EFF: C0 04 00     CPY #$0004
02/8F02: D0 EB        BNE $8EEF

chillyfeez

  • FF4 Hacker
  • *
  • Posts: 1,234
  • Gender: Male
  • Go ahead, ask me about Angel Feathers!
    • View Profile
Re: Developing a comprehensive editor for FF4
« Reply #538 on: November 29, 2013, 01:29:57 PM »
Any insight about how the data loaded by those three bits affects the battle?

Displacer

  • FF4 Hacker
  • *
  • Posts: 27
    • View Profile
Re: Developing a comprehensive editor for FF4
« Reply #539 on: November 29, 2013, 02:06:15 PM »
I set a breakpoint at that routine and oddly enough, I've only had it hit once, the battle in mist when Rydia causes the quake, but that's as far as I have save states into the game so it may be used elsewhere as well. It hasn't hit with normal battles, including the one with the mist dragon.

It seems though that it has opened up a whole can of data being used. For instance, some of those data sets are used to access pointers at 0D/FD6D. These are pointers to data sets at 0D/FD89. These are used in sets of 3, each with a FF terminator. I'm wondering if they are for the 3 monster sets in a battle. The Rydia battle uses the first pointer, and the 3 sets it uses are:

Code: [Select]
01 00 FF
03 02 FF
05 04 FF

I have no clue what these are, just guesses at present. Man, those coders sure did like their pointers...

 :edit:

OK, those appear to be graphic positioning data. I would assume top, middle, and bottom. If you change those numbers, rydia's graphic is broken up and moved around.
« Last Edit: November 29, 2013, 04:08:05 PM by Displacer »