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

Pinkpuff

  • Flan Princess
  • *
  • Posts: 923
  • Find a Megalixir in Unprecedented Crisis!
    • View Profile
Re: Developing a comprehensive editor for FF4
« Reply #735 on: March 16, 2014, 06:41:23 AM »
Updated again!

I'm tackling some of the stuff on my to-do-list. I added the targeting to the command editor, and you can now tell Cover to index by job rather than actor. As well I went ahead and made the assumption that the treasure index works the way I think it does. Let me know if anything goes wonkee.
Let's dance!

Grimoire LD

  • FF4 Hacker
  • *
  • Posts: 1,682
    • View Profile
Re: Developing a comprehensive editor for FF4
« Reply #736 on: March 16, 2014, 05:48:57 PM »
Looks like the Targeting works perfectly! That is so nice to have in the editor and cuts down on the need to jump to and fro with the Hex Editor and FF4kster. There's also another easy piece (at least I would imagine its easy) to implement that Chillyfeez discovered long ago, but it seems like the info fell through the cracks and that is the Charge Time for the various commands.

Quote from: Chillyfeez
there is a table in ROM at A0189 that contains one-byte-per-command references to the duration set to perform each command. Most of them are 00, which is immediate. 01 is not one second, though. These are pointers. I haven't tested all 256 options (and probably won't) but the following are used:
00: (most commands) immediate
01: (Charge) 5 seconds
02: (Dark Wave, a few others) 2 seconds
04: (Salve, Aim) 1 second
FE: (not used, but I tested it to see if it would crash the game - it doesn't) several hundred seconds

I'm unsure if its with a header or not, but it would make a nice addition.


However I did add another item to Rosa's House and the game... sort of well got a bit strange. The graphics glitched and not just the map graphics, even NPC's had black lines running through them.

For what its worth the item spot properly responded, but some item spots wouldn't yield their item any longer.
To try this for yourself go to Rosa's House, add a new Treasure Trigger and then load Baron up.

Pinkpuff

  • Flan Princess
  • *
  • Posts: 923
  • Find a Megalixir in Unprecedented Crisis!
    • View Profile
Re: Developing a comprehensive editor for FF4
« Reply #737 on: March 17, 2014, 06:37:59 AM »
Glad to hear something's working correctly on the first try ^_^;

Charge time: Awesome, thanks! And yeah that does sound familiar so I think it did fall through the cracks; there are probably several other things that met that fate, so I'm trying to be a bit more organized about things now. Anyway it looks like it will take some tinkering which I don't have time for right this minute but it's on the to-do-list.

As for the treasure thing, does a rom that has been loaded and saved (but not modified) using FF4kster show any signs of glitching, or is it just when you mess with the treasures?
Let's dance!

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 #738 on: March 17, 2014, 10:57:18 AM »
I got the same results as Grimoire LD. It looks like only a modified treasure list causes the glitching issue. Saving without making changes seems to be fine.

 :edit: OK, I've had a chance to investigate, and I think what should be happening is this: When adding a treasure to any given location, the way to make that treasure active is to increase byte 0C of the properties of each subsequent location by 01 (or by an amount equal to the amount of chests you're adding). Keep byte 0C of the map you're editing the same.
For instance, the treasure index byte of Baron Town is 00, meaning when searching for treasure contents in Baron, the game starts by looking at the first treasure. But it also references the treasure index of the next map, Village Mist. Mist's treasure index is 07, meaning once the game has accounted for 7 treasures in Baron, it will stop counting. By changing Mist's treasure index to 08, you activate all of Baron's chests, but negate one Mist chest, because you haven't yet adjusted the treasure index of the next map, Kaipo. Therefore, in order to add a chest seamlessly, you have to increase all subsequent locations' treasure indices by 01 (or remove a chest somewhere).

You are right, though, that the counting resets with map 0x100 (Kokkol's smithy). I think it's safe to presume that those indices can be left alone

 :edit: heh - I just re-read what I wrote... I mean they can be independent of the first set of maps, not entirely left alone.
« Last Edit: March 17, 2014, 07:29:49 PM by chillyfeez »

Pinkpuff

  • Flan Princess
  • *
  • Posts: 923
  • Find a Megalixir in Unprecedented Crisis!
    • View Profile
Re: Developing a comprehensive editor for FF4
« Reply #739 on: March 17, 2014, 03:30:14 PM »
Ok so I implemented something that I think should fix it. See if it works correctly now...
Let's dance!

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 #740 on: March 17, 2014, 07:30:38 PM »
Cool. I'll try again in a bit. Will let you know.

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 #741 on: March 17, 2014, 11:26:09 PM »
Hmmm... It looks like the same problems are still happening - the graphics glitches as well as the treasures not redistributing right. Which is odd because as far as I can tell, the indices did change appropriately. It must be changing something else, too...?

Pinkpuff

  • Flan Princess
  • *
  • Posts: 923
  • Find a Megalixir in Unprecedented Crisis!
    • View Profile
Re: Developing a comprehensive editor for FF4
« Reply #742 on: March 18, 2014, 04:47:29 AM »
Does the issue appear if you:

Open rom in FF4kster -> Enter Trigger Editor -> (change nothing) -> Leave Trigger Editor -> Save ROM -> Exit FF4kster
Let's dance!

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 #743 on: March 18, 2014, 09:47:30 AM »
Yup

Pinkpuff

  • Flan Princess
  • *
  • Posts: 923
  • Find a Megalixir in Unprecedented Crisis!
    • View Profile
Re: Developing a comprehensive editor for FF4
« Reply #744 on: March 18, 2014, 04:43:19 PM »
It looks like it's generating the correct numbers for a while, but then it starts to diverge at whatever map contains AA70B (headered)... I think it's Tower of Babil B1?

Then it's fine again for the underworld until AAD20...
Let's dance!

JCE3000GT

  • Master of FF4
  • *
  • Posts: 1,425
  • Gender: Male
  • Vladof
    • View Profile
    • BlitzKrieg Innovations
Re: Developing a comprehensive editor for FF4
« Reply #745 on: March 18, 2014, 06:35:08 PM »
It looks like it's generating the correct numbers for a while, but then it starts to diverge at whatever map contains AA70B (headered)... I think it's Tower of Babil B1?

Then it's fine again for the underworld until AAD20...

That is the correct map for that offset. 

What can I do to help?

Pinkpuff

  • Flan Princess
  • *
  • Posts: 923
  • Find a Megalixir in Unprecedented Crisis!
    • View Profile
Re: Developing a comprehensive editor for FF4
« Reply #746 on: March 18, 2014, 06:51:26 PM »
What can I do to help?

Hm, good question!

I think it's just a question of finding a pattern. Why is it messing up there and not earlier or later? What is it about that map that distinguishes it from the others before it?

Right now my code basically starts at 0, assigns that to the first map, then counts the treasures in the current map, adds that to the running total, then moves to the next map. Writes the running total so far to that map's treasure index, then adds on the treasure in that map and so on. It resets to 0 at map 256 (start of the underworld).

Here's the exact code (in FreeBASIC) if it helps:
Code: [Select]
for i as Integer = 1 to total_maps
 if i = 256 then treasures = 0
 maps(i).treasure_index = treasures
 for j as Integer = 1 to maps(i).triggers.Length()
  t = maps(i).triggers.PointerAt(j)
  if t->treasure then treasures += 1
 next
next
Let's dance!

JCE3000GT

  • Master of FF4
  • *
  • Posts: 1,425
  • Gender: Male
  • Vladof
    • View Profile
    • BlitzKrieg Innovations
Re: Developing a comprehensive editor for FF4
« Reply #747 on: March 18, 2014, 10:39:49 PM »
Here's the RAW bytes for the map before Tower of Babil B1F (which is a Save room) and the Tower of Babil B1F (entrance) map itself.  So, B1F has 2 treasure chests; one at 12 04 and the other at 1A 0C.  Obviously the Save room has none.  I've also included the RAW trigger data with the treasure bolded for the Tower of Babil B1F. 

Map Index A6 Data:  08 A6 2F 0A 10 17 7C 86 00 80 C9 1C A7
Map Index A7 Data:  0A A7 AF 0A 10 17 9B 86 00 4A CB 1C A8

Map A7 Trigger Data:  2800 1204FE80D0 1A0CFE80D0 1513A895141C12CA96031906

Do you have a way to debug what your app is doing right at that point?  I usually do a msgbox on routines in my apps in Visual Basic when I need to run a debug if there is a problem.  I don't see a reason why it should bug out? 

Pinkpuff

  • Flan Princess
  • *
  • Posts: 923
  • Find a Megalixir in Unprecedented Crisis!
    • View Profile
Re: Developing a comprehensive editor for FF4
« Reply #748 on: March 19, 2014, 03:28:33 PM »
It writes the treasures so far before adding on the ones for the current map. So it's writing C9 for map A6 correctly, then seeing that map A6 has no chests, writes C9 again for map A7 (the original has CB instead). Then it adds the 2 chests from map A7 to get CB for map A8 (the original has CD instead). This seems to me to be the original breaking the pattern at this point. The question is, why?
Let's dance!

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 #749 on: March 19, 2014, 04:24:34 PM »
Now... is this at all related to the graphical glitch that seems to accompany any trigger changes?
Sems like that would be a weird association.