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

Grimoire LD

  • FF4 Hacker
  • *
  • Posts: 1,682
    • View Profile
Re: Developing a comprehensive editor for FF4
« Reply #615 on: December 23, 2013, 03:23:46 PM »
Ahem... yes, yes, that is what that meant. Not very clear at all, but you got the gist of it, hehe. It should probably read...

When Caster's Status Byte 1 is the same as Status Determination always use Specific Spell rather than a randomized spell.

Pretty much what you have there, yeah.

Pinkpuff

  • Flan Princess
  • *
  • Posts: 923
  • Find a Megalixir in Unprecedented Crisis!
    • View Profile
Re: Developing a comprehensive editor for FF4
« Reply #616 on: December 30, 2013, 05:21:26 AM »
Progress Update

I put the tile editor on the back burner and began coding the map editor using hard-coded tiles (ripped directly from FF4Tools). What this means is that for now, the tiles will always look the same no matter what has been changed about them (i.e. even if you hack something that was formerly a warp tile into not warping, it will still appear as a warp tile in the editor), and they will have a fixed palette no matter what the map's palette is.

Currently, it gives you a menu of maps at the top and highlighting a map will display the correct tileset on the left side and will give you a preview of the top left 16-tile x 16-tile corner of the map in the center. While this map looks correct for almost all maps, overworld and underground/lunar alike, there are certain maps that look messed up and I'm not sure why. The "Glitch World" maps are all messed up of course but I was expecting that. I'm talking about things like, the ice shield treasure room in the Tower of Babel looks messed up while the icebrand room looks just fine.

I've uploaded the current working version so if you guys want to take a look at it and see if you can find a pattern, by all means please do so. Also let me know if it's slow updating; it seems to run fine under linux but when I compiled it for windows it seemed to take forever to update the tileset and the map. However it could simply be an emulator issue (it's been known to be sluggish with certain things anyway).
Let's dance!

Grimoire LD

  • FF4 Hacker
  • *
  • Posts: 1,682
    • View Profile
Re: Developing a comprehensive editor for FF4
« Reply #617 on: December 30, 2013, 06:39:37 AM »
That was a pretty fast implementation! I'll take a look at the newest version to see what's working and what might be a bit askewed then.

 :edit: Now this is interesting! I love actually being able to look at the Glitch Worlds, are they being displayed properly from the data, or are they being read in some different manner? (As in could we potentially alter them to make them fully functioning maps?)


Troia Castle Crystal Room also seems to be rather screwed up as well, it looks to be reading the next map (Troia Hospital).

Baron Castle White Magic School looks to be reading the next map data (Desert Background), while the Desert Background likely has the wrong tileset all together, the Training Room (Is that even a map in FFII SNES?) looks to be having the same problem. The same applies to the Cave Magnes Crystal Room, it looks to be reading the data of the next map, possibly. There is always the distinct possibility that the Crystal Chambers have one set that is called upon by the map data itself (since they all look the same)

Cave Magnes Save Point Room looks to be using the wrong tile arrangement all around.

All of the "Airships" are screwed up, I expect this to be because there is one general map called for those sorts of events.

Cid's Falling mountain background isn't using the correct tile arrangement.

Hmm, the Cave Eblan Savepoint room also looks to be askewed. Is it maybe copying its map data from the Sewer Savepoint?

Baron Empty Throne Room is probably another map which is copying data from elsewhere.

Both docks show a white background.

All inns and shops are askewed starting from Mist Inn. I suspect that to be because they are likely reading from earlier arrangements. Inns however are mostly unique so that is a little troubling...

The other Babil Treasure Rooms are likely reading off of the main one, which is the Icebrand room.

The floors w/ Lugae/Ice Mail/Airship are likely copies again.

I need to head to work, but that seems to be the case here. A lot of these are copies so they don't have default map data.




« Last Edit: December 30, 2013, 07:57:44 AM by Grimoire LD »

Grimoire LD

  • FF4 Hacker
  • *
  • Posts: 1,682
    • View Profile
Re: Developing a comprehensive editor for FF4
« Reply #618 on: December 30, 2013, 09:09:51 PM »
Yes, looking in the editor The "Troia Crystal Chamber" uses Index 74. That means that it is actually reading its Map Data from Fabul's Crystal Chamber, and this likely follows suit with the other Crystal Chambers.

Baron Castle's Magic Schools both use the same index of 102, meaning that there is no individual graphics for the White Magic School

Cave Magnes Crystal Room uses Index 74 as expected.

Cave Magnes' Second Save Point Room uses the index of its earlier Save Point Index 146.

Most Airships use Index 195 as their base.

Interestingly enough the Tower of Zot and Tower of Babel use the same Index as well, 166.

Cave Eblan Save Point Room uses Index 61.

Second Empty Airship uses 195.

All normal Chocobo Forests use 207 as their Index.

Baron's Empty Throne Room uses Index 44 as a base.

Tower of Wishes - Final Battle uses Index 23 from the normal Tower of Wishes.

I cannot say what is wrong with the "Small Dock" map, it has no repeat index.

Mist Inn uses Index 7 (I guess there is a generic Inn and its apparently Troia's)

Mist Weapons uses Index 8 (Troia's Weapon Shop)
Mist Armor uses Index 9 (Troia's Armor Shop)

Kaipo, Mysidia, Mythril, and Baron Items follows suit with using Troia's shops as a base.

Ending - Tower of Wishes uses Index 23 as expected.

The ending stuff is clearly taken from their respective copies (Except for Palom and Leonora's Area, that Index is correct though from Underground Index 49)

The Tower of Babil Treasure Rooms all take their Index from 21.

The Babil Copies from the other side are 38, 39. and 40 Index. (The First instance, the second copy is the real one)

The second instance of the Lunar Whale uses Index 44.

Sealed Cave Crystal Room uses Index 13.


And that is that! There's nothing wrong with the way you have parsed the maps. They are just using copied indexes for data that isn't actually there.



Pinkpuff

  • Flan Princess
  • *
  • Posts: 923
  • Find a Megalixir in Unprecedented Crisis!
    • View Profile
Re: Developing a comprehensive editor for FF4
« Reply #619 on: December 31, 2013, 05:54:14 AM »
I see, thank you! So it has to do with the "map index" of the given map... I should actually be able to code that in pretty easily so that it displays correctly. I'll just have to put something in the readme that reminds people that changing a map that shares an index with another map will change both maps. And if they don't read the readme well... that's not my fault  :happy:

Is the "town water background" coming up as a bunch of cargo boxes for you? For me it seems to be using the airship tileset instead of the town one. This matches what's in its map info data; it says it "should" be using tileset 0 but we know from playing the game that it somehow "knows" that it should be using town tileset...
 :hmm:
Let's dance!

Grimoire LD

  • FF4 Hacker
  • *
  • Posts: 1,682
    • View Profile
Re: Developing a comprehensive editor for FF4
« Reply #620 on: December 31, 2013, 09:19:38 AM »
Yeah, the Town Water Background does come up as a bunch of boxes. There is nothing in Tileset 0 that would correspond to water indeed, let's see then...

Also, now that you added the map section, when you go to change certain things like Events, the entire background becomes a bright pink, I can't think that's intentional.

Alright, it seems my theory was right on the dot. The background of any given area will use the tileset that is native to the area. For instance if you change the water background from Town Water Background to the Castle Background you'll see its not proper. It would appear the designers knew this and didn't bother to give the Town Water Background its own proper tileset for some reason, relying on the tileset of Towns to do it for them.

Grimoire LD

  • FF4 Hacker
  • *
  • Posts: 1,682
    • View Profile
Re: Developing a comprehensive editor for FF4
« Reply #621 on: January 01, 2014, 11:07:45 PM »
Happy new year! I unfortunately have to start the new year with a glitch in the editor...

When you switch Level Ups from one character to another some other level ups get Really screwed up in the process. Just try switching say Rydia and Cecil's Level Ups and then change Tellah's to Rosa's and watch the points needed to level up and the level up bonuses themselves, Sky Rocket!

Pinkpuff

  • Flan Princess
  • *
  • Posts: 923
  • Find a Megalixir in Unprecedented Crisis!
    • View Profile
Re: Developing a comprehensive editor for FF4
« Reply #622 on: January 02, 2014, 06:08:28 AM »
Happy new year! I unfortunately have to start the new year with a glitch in the editor...

Happy new year to you as well! And that's not unfortunate! If there are bugs in my program I want to know about them right away so that I can smash them!  :banonsmash:

And on that note, I uploaded the latest version again which now has fixed:
  • Maps displaying wrong index map (certain background maps will still have the "wrong" tileset such as the town water bg though)
  • Pink box appearing in event editor (this is a side effect of my changing screen modes to accomodate loading bmp files; I thought I found all of them but if there are any more instances of pink zones appearing let me know)
  • Level ups getting messed up from changing actor level up links
One thing to note about the levelups if you go messing with the levelup links for the actors, is that I think it's possible to just outright lose levelup data now, at least as far as the editor is concerned. For example, let's say you changed Cecil's levelup link to point to Rydia's levelups but then didn't change Rydia's (or anyone else's) to Cecil's. Now when you open the editor, Cecil's former levelups will just be gone, with no way to access them from within the editor, and both Rydia's and Cecil's levelups will now be called Cecil's. I can't think of a good way to fix that right now but I'll keep it in the back of my mind as something to brainstorm at some point.
Let's dance!

Grimoire LD

  • FF4 Hacker
  • *
  • Posts: 1,682
    • View Profile
Re: Developing a comprehensive editor for FF4
« Reply #623 on: January 02, 2014, 10:32:07 AM »
Hmm, that makes sense that such a thing would occur. So Level Up Index is not a single byte then, but something that is copied into the character's data itself? I was under the impression it was a byte in an initial character's data somewhere. A very nice addition if it is not.

Went looking for more pink boxes, I found another when you go to add a spell to a skillset, the box that holds the level when the spell is to be learned turns Pink when you exit out of it.

Ouch, the Message editing section has it as bad as the Event Editor section did, an entire bright pink screen when you go to edit a field message (Battle Messages work fine)

Ah right, this reminds me of a thing that has bothered me for a while. Do we not have an Underground NPC Index available? Since every mention in the editor refers to the Overworld NPC Index, even in the Underground it uses those names.

But that seems to be it as far as I could make out.

Hmm... I just tested out the Level Up switching and took your words to heart so I changed Dark Knight Cecil's to Tellah's Level Ups and immediately gave Tellah Dark Knight Cecil's Level Ups now this had the effect of erasing Tellah's level-ups all together...

My suggestion is when a Level Up is switched, that immediately the person who is losing their level-up set should be given the other person's level-ups.

Pinkpuff

  • Flan Princess
  • *
  • Posts: 923
  • Find a Megalixir in Unprecedented Crisis!
    • View Profile
Re: Developing a comprehensive editor for FF4
« Reply #624 on: January 02, 2014, 12:33:59 PM »
Hmm, that makes sense that such a thing would occur. So Level Up Index is not a single byte then, but something that is copied into the character's data itself? I was under the impression it was a byte in an initial character's data somewhere. A very nice addition if it is not.
...
Hmm... I just tested out the Level Up switching and took your words to heart so I changed Dark Knight Cecil's to Tellah's Level Ups and immediately gave Tellah Dark Knight Cecil's Level Ups now this had the effect of erasing Tellah's level-ups all together...

What's happening there is that there's a list of pointers, each corresponding to an actor, that point to a set of levelup data. Some point to the same set of data (e.g. Child Rydia and Adult Rydia). So when you change one of the pointers and don't change anything else to what it used to be, so that nothing points to that set of levelup data anymore, then when you load the rom again, it just reads the pointers and doesn't see that there's a set of data with nothing pointing to it.

Went looking for more pink boxes, I found another when you go to add a spell to a skillset, the box that holds the level when the spell is to be learned turns Pink when you exit out of it.

Ouch, the Message editing section has it as bad as the Event Editor section did, an entire bright pink screen when you go to edit a field message (Battle Messages work fine)

Thanks, I'll get on it.

Ah right, this reminds me of a thing that has bothered me for a while. Do we not have an Underground NPC Index available? Since every mention in the editor refers to the Overworld NPC Index, even in the Underground it uses those names.

I had forgotten completely about that... I'll see what I can do. Thanks for the reminder.

My suggestion is when a Level Up is switched, that immediately the person who is losing their level-up set should be given the other person's level-ups.

I'm not sure I understand... Suppose I want to change the plot a little at the end of the game and instead of Kain 3 I need a Yang 3. So I change Kain 3's levelups to Yang's levelups. Would Yang and Yang 2's levelups then become Kain's?
Let's dance!

Grimoire LD

  • FF4 Hacker
  • *
  • Posts: 1,682
    • View Profile
Re: Developing a comprehensive editor for FF4
« Reply #625 on: January 02, 2014, 01:36:25 PM »
Hmm, well that does appear to be what is happening. Though Cecil's level-ups were changed to Tellah's, Tellah's entire Level up Data was erased, despite Tellah 1 still having the normal Tellah Level-up Data (because I switched his data to Dark Knight Cecil's beforehand) which is nothing. By changing this, Tellah 2 and 3 still have Dark Knight Cecil's Level-up Data,. So I think that might be what is going on regardless of the case and  Cecil's data reads it as Cecil's Level Up Data.

JCE3000GT

  • Master of FF4
  • *
  • Posts: 1,425
  • Gender: Male
  • Vladof
    • View Profile
    • BlitzKrieg Innovations
Re: Developing a comprehensive editor for FF4
« Reply #626 on: January 02, 2014, 11:16:44 PM »
Also I have an observation about the level up editor.  On the later levels (50+ or so) the MP increased byte is also used by the experience needed for level up.  It starts with $20 and moves on to $40--what this means if you put in a value that exceeds $BF for example the exp needed for level up increases as well.  As an example put $FA on Rydia or Rosa's level 40 MP level up data and you'll see the required exp for level up goes into well above 300,000. 

My recommendation is to have the max MP increased per level up not exceed 191 ($BF) or make it an even 190 ($BE).  Or you can be safe and cap it at 160 (A0)--I haven't tested it any further.  :)

Let me know if you need a further explanation. 

Pinkpuff

  • Flan Princess
  • *
  • Posts: 923
  • Find a Megalixir in Unprecedented Crisis!
    • View Profile
Re: Developing a comprehensive editor for FF4
« Reply #627 on: January 03, 2014, 06:12:41 AM »
Hmm, well that does appear to be what is happening. Though Cecil's level-ups were changed to Tellah's, Tellah's entire Level up Data was erased, despite Tellah 1 still having the normal Tellah Level-up Data (because I switched his data to Dark Knight Cecil's beforehand) which is nothing. By changing this, Tellah 2 and 3 still have Dark Knight Cecil's Level-up Data,. So I think that might be what is going on regardless of the case and  Cecil's data reads it as Cecil's Level Up Data.

So if I understand correctly... you changed Cecil's levelups to Tellah's, right? So now the situation is the actors DK Cecil, Tellah 1, Tellah 2, and Tellah 3 all have Tellah's levelups. Next, you changed Tellah 1's levelups to Cecil's. So now the situation is Tellah 1 has Cecil's (old) levelups and now actors DK Cecil, Tellah 2, and Tellah 3 all have what were Tellah's levelups, correct? Now you save rom and exit, then when you load up the editor you should see this:
ActorLevelups
DK CecilDK Cecil
Tellah 1Tellah
Tellah 2DK Cecil
Tellah 3DK Cecil

But when you look in the character editor you'll find that the levelups that are being called "DK Cecil" are actually what Tellah's were originally, and the levelups that are being called "Tellah" are what DK Cecil's were originally. This behaviour is "correct" and I'll explain why:

Levelup data is stored by character, but the pointers to the levelup data are stored by actor (thanks, FF4 programmers). What this means is I can't just read levelup data along with the rest of the character data. I have to read it with the actor data and assign it to the corresponding character as I go. So let's just do a quick trace of this process with the data changes made above:
  • Read first actor: DK Cecil
  • Pointer to levelup data: (points to what used to be Tellah's levelups)
  • Is this pointing to data I've already read so far: No (I haven't read any so far, this is the first one)
  • What character corresponds to this actor: DK Cecil
  • Assign DK Cecil (character) this levelup pointer (hence making what used to be Tellah's levelups to now be labelled as Cecil's)
  • ... read some more actors ...
  • Read actor: Tellah 1
  • Pointer to levelup data: (points to what used to be DK Cecil's levelups)
  • Is this pointing to data I've already read so far: No (Cecil's had been changed to something else, so this is the first one pointing to his old levelups)
  • What character corresponds to this actor: Tellah
  • Assign Tellah (character) this levelup pointer
  • ... read some more actors ...
  • Read actor: Tellah 2 (Tellah 3 will operate the same way as this)
  • Pointer to levelup data: (points to what used to be Tellah's levelups)
  • Is this pointing to data I've already read so far: Yes
  • Therefore we look at which character is the first one with this data: DK Cecil (thus it will be labelled DK Cecil's levelups)
  • What character corresponds to this actor: Tellah
  • This character already has levelup data so no assignment needed

Now let's suppose instead that you hadn't assigned Cecil's levelups to anyone. You left all Tellah's actors alone and just changed Cecil to have Tellah's levelups. Now when you save and re-load, the following happens:
  • Read first actor: DK Cecil
  • Read levelup pointer: (points to what used to be Tellah's levelup data)
  • Assign it to DK Cecil (character)
  • ... read some more actors ...
  • Read actor: Tellah 1 (the other Tellahs will all work like this)
  • Read levelup pointer: (also points to what used to be Tellah's levelup data, but would now be lablelled DK Cecil)
  • Assign it to Tellah (character)
  • ... read the rest of the actors, none of which point to what used to be DK Cecil's levelups ...

Notice that now there is nothing pointing to DK Cecil's former levelups. What this means is that the data is still there, it's hasn't been deleted or overwritten or anything, there's just no way to access it from within the editor. If you were to manually go in with a hex editor and update the pointer for one of the characters to point to DK Cecil's old levelups, they'd all be there and completely accessible.

Actually now that I think about it they might get overwritten in the saving process since nothing is pointing to it; the levelups that are actually being used might all just get written sequentially and the pointers computed based on that, in which case what I said above wouldn't hold true for DK Cecil but depending on what else you changed you might be able to salvage, say, FuSoYa's had you done that with his levelups rather than Cecil's.

Ideally, I'd like to be able to read all the levelup data regardless of whether anything points to it or not; that way you can assign pointers to whatever levelup sets you like without having to worry about it since the entire data set would always be read and written. But it's tricky to do that because of the way those particular pointers work. They care about the character's starting level. If you start at level 10, it will result in a different pointer from if you start at 15, even if the data begins at the same memory address. This means that in order to read the levelup data correctly I need to know the corresponding character's starting level, meaning it has to have a corresponding character.

Also I have an observation about the level up editor.  On the later levels (50+ or so) the MP increased byte is also used by the experience needed for level up.  It starts with $20 and moves on to $40--what this means if you put in a value that exceeds $BF for example the exp needed for level up increases as well.  As an example put $FA on Rydia or Rosa's level 40 MP level up data and you'll see the required exp for level up goes into well above 300,000. 

My recommendation is to have the max MP increased per level up not exceed 191 ($BF) or make it an even 190 ($BE).  Or you can be safe and cap it at 160 (A0)--I haven't tested it any further.  :)

Let me know if you need a further explanation. 

When you do this in FF4kster the result is that the MP ends up getting capped to 31 and the TNL goes bonkers. So I'm just going to do the lazy thing for now and cap it at 31.  :childish:
Let's dance!

Grimoire LD

  • FF4 Hacker
  • *
  • Posts: 1,682
    • View Profile
Re: Developing a comprehensive editor for FF4
« Reply #628 on: January 03, 2014, 09:18:09 AM »
I see... I had no idea level was so absolutely important to the starting point of the level-up system. What a mess Square... I'm afraid I can't think of any remedy to make that work better.

Pinkpuff

  • Flan Princess
  • *
  • Posts: 923
  • Find a Megalixir in Unprecedented Crisis!
    • View Profile
Re: Developing a comprehensive editor for FF4
« Reply #629 on: January 03, 2014, 09:43:39 AM »
I'll probably think of some way around it eventually, but for now I'm going to keep focusing on the map editor.
Let's dance!