Author Topic: FF II: A Threat from Within - Expanded ROM = New Features!  (Read 35778 times)

chillyfeez

  • FF4 Hacker
  • *
  • Posts: 1,281
  • Gender: Male
  • Go ahead, ask me about Angel Feathers!
    • View Profile
Re: Final Fantasy IV: A Threat from Within (The Preview)
« Reply #15 on: February 24, 2014, 11:47:42 PM »
I was looking at Blank's level up table and I remembered what the issue is there.
The problem is, he uses DK Cecil's job slot and level up data, but Golbez's Actor and Character slot. This was the workaround to ensure he wouldn't have the same name as Ceo, who uses P Cecil's spot (as I recall, DK Cecil and P Cecil must have the same name, unless that was just a since-fixed bug in earlier versions of FF4kster).
Anyway, an unintended side effect of this is that Blank... is not fully compatible with FF4kster.
In some respects, that fact's just a minor inconvenience - to add him into the party, you simply "add DK Cecil," but to remove him, you have to "Remove Golbez," which is not an available option in FF4kster. So, I make the event remove DK Cecil, then edit it by hand in my hex editor. A sliver tedious, but no big deal.
For level up data, though, Blank is an ungodly nightmare. FF4kster can write his level up data just fine. Problem is, it can't read his level up data. So any time I edit any part of the ROM with FF4kster, his level up table gets screwed up again. Of course, now that I know this, and I am much better at all of this than I was when I first started this hack, I know I can fix his data once, then just make a patch that can be applied when needed. But I've gotta find the time (and motivation) to sit down and fix his level up data one more time - probably the most tedious FFIV hacking task in existence imho.
The good news is, that's the only issue with level up data. It seems, in my experience, that TNL only gets screwed up if you try to make a character begin at a level earlier than they normally would. My characters' level up tables all start at the same level or later. ...Unless there's an issue I haven't discovered yet...

LordGarmonde

  • Baigan
  • *
  • Posts: 271
  • Gender: Male
  • "Power only breeds war..."
    • View Profile
Re: Final Fantasy IV: A Threat from Within (The Preview)
« Reply #16 on: February 25, 2014, 06:34:23 AM »
The good news is, that's the only issue with level up data. It seems, in my experience, that TNL only gets screwed up if you try to make a character begin at a level earlier than they normally would. My characters' level up tables all start at the same level or later. ...Unless there's an issue I haven't discovered yet...

I'd imagine you'd be safe staying over the original minimums.

This is another reason I need to get my a** in gear and finish the formulaic replacement. I did mange to settle on extrapolated TNL values for those who are missing some due to starting level. It would, however, require some decent recoding in the game to reference them as needed and it would likely present a problem with FF4kster - but maybe not; in the editor it does list every character with rows or zeroes, so it might be able to figure it out.

The problem I have finishing up the formula replacement is one of accuracy. I can't satisfy myself to be close enough over the whole range and for all the characters. Now I'm giving thought to just storing a table from Level 1 - 69 that has the average TNL value accross all characters and then finding the best formula to calculate how far off and given character is. It's just not where my head is at moment; hopefully soon though because I can see where it can be used to escape problems like the above.

TNL Table - Extrapolated for All Characters:

http://slickproductions.org/forum/index.php?topic=1911.msg20136#msg20136
"Now I know; and knowing makes it even more confusing..."

chillyfeez

  • FF4 Hacker
  • *
  • Posts: 1,281
  • Gender: Male
  • Go ahead, ask me about Angel Feathers!
    • View Profile
Re: Final Fantasy IV: A Threat from Within (The Preview)
« Reply #17 on: March 02, 2014, 10:20:22 AM »
Quick update on progress (because v 0.2 is taking longer that originally planned)...

I've fixed all of the bugs Grimoire LD pointed out, except I haven't looked into Avon's invincibility not ending yet. I'm sure that will be a relatively quick fix, though, as it'sworked just fine in previous tests.

Oh, also, still trying to figure out the best course of action to deal with the occasional Agart minibosses not truly deactivating bug...

Additionally, fixed the level-up spell learning.

JCE3000GT made a title screen for me. Interestingly enough, when I patched that in the mysterious save game HP display bug stopped happening. Not sure if that was an intentional easter egg he threw in there...

Turns out, there WAS a since-corrected issue with FF4kster that caused DKnight and Paladin slots to have the same name. So now Blank fully uses DK Cecil's slot, which means:
-no need for a level-up workaround patch. All levelups work fine now.
-no more problems with Twincasting. Rydia will still get drawn in if she's in the party, but in the actual game she never will be.

What's been taking so long is the rest of my hacked Twin command. I've figured out (pretty sure) a way to allow it to use white or black-type spells, player's choice, without sacrificing the randomness factor.
Essentially, I cut out the Golbez/FuSoYa checks in the spell chooser, then did the following (I'll post an actual disassembly soon):
-set register Y to 0000
-load caster's enemy targeting byte
-if not 00, skip ahead
-if 00, set register Y to 0015 (15 is the difference between spell numbers of flare and w.meteo)
-RNG
-if RN = FF, normal fail routine
-if RN is over 40, skip ahead
-if RN is less than 40, +1 to register Y
-transfer Y to A
-add 40 to A
-rest of routine as normal
Also, changed the targeting options to split enemy/ally (defaults to enemy), replaced Comet with W.Meteo, and replaced W.Meteo and the dummy that follows it with a powerful cure spell ("W.Cure") and a target-all heal spell ("Esuna") respectively.

The result: if the player chooses to target one or all enemies, the game randomly chooses spell 40 or 41 (W.Meteo or Flare). If the player targets one or all allies, the game picks between 5E and 5F (W.Cure or Esuna).

I had planned to finish all of that yesterday, but then I accidentally spent the whole day investigating spell AV code (trying to write a unique image for W.Cure to visually distinguish it from Cure 4 and Cure Z). Not a significant amount of success there, though I discovered a few interesting things that on their own are no help. I may cut my losses for now in the interest of getting an updated patch out there.

So that's where I'm at right now, in case anyone was wondering.

chillyfeez

  • FF4 Hacker
  • *
  • Posts: 1,281
  • Gender: Male
  • Go ahead, ask me about Angel Feathers!
    • View Profile
Re: Final Fantasy IV: A Threat from Within (The Preview)
« Reply #18 on: March 02, 2014, 12:52:35 PM »
So my altered Twin routine works like a charm!
As above, the targeting (at 9FFD3) was changed from 60 to 70, so that the player can target one/all enemies/allies.
Also, the following spells were changed:
40 WMeteo (formerly Comet)
5E Esuna (formerly W.Meteo, now the same as Heal, except it can target all allies)
5F W.Cure (formerly the Dummy used - I think - by the Rod, now a really strong Cure spell)

The coding changes are thus:
Original (thanks Grimoire LD):
Code: [Select]
$03/E56E BD 00 20 LDA $2000,x[$7E:2080] A:0000 X:0080 Y:0005 P:envMxdiZc - Load Character 1's Character ID into A.
$03/E571 29 1F AND #$1F A:0089 X:0080 Y:0005 P:eNvMxdizc - -80? to A?
$03/E573 C9 13 CMP #$13 A:0009 X:0080 Y:0005 P:envMxdizc - (Palom and Porom are 08 and 09, not 13 and 15, I have no ide... FuSoYa and Golbez.) Is it FuSoYa?
$03/E575 F0 04 BEQ $04    [$E57B] A:0009 X:0080 Y:0005 P:eNvMxdizc - If so branch to 03E57B.
$03/E577 C9 15 CMP #$15 A:0009 X:0080 Y:0005 P:eNvMxdizc - Is it Golbez?
$03/E579 D0 04 BNE $04    [$E57F] A:0009 X:0080 Y:0005 P:eNvMxdizc - If not branch to 03E57F.
-----------------------------------------------------------------------------------------------------------------------------------------------------------
$03/E57B A9 5E LDA #$5E A:0015 X:0080 Y:0005 P:envMxdiZC - Load W. Meteo
$03/E57D 80 19 BRA $19    [$E598] A:005E X:0080 Y:0005 P:envMxdizC - Branch Always to 03E598.
-----------------------------------------------------------------------------------------------------------------------------------------------------------
$03/E57F 20 93 85 JSR $8593  [$03:8593] A:0009 X:0080 Y:0005 P:eNvMxdizc - Jump to Subroutine (where random number seems to be generated)
$03/E582 C9 FF CMP #$FF A:008F X:0011 Y:0005 P:eNvMxdizC - Was it FF (or higher)?
$03/E584 90 08 BCC $08    [$E58E] A:008F X:0011 Y:0005 P:eNvMxdizc - If not, branch to 03E58E.
---------------------------------------------------------------------------------------------------------------------------------------------------------------------------
$03/E586 A9 11 LDA #$11 A:00FF X:0033 Y:0007 P:envMxdiZC- Load x11 into A. (Failed Message)
$03/E588 8D CA 34 STA $34CA  [$7E:34CA] A:0011 X:001B Y:0005 P:envMxdizC - Store A in 7E34CA (Battle Message Area)
$03/E58B 4C A6 85 JMP $85A6  [$03:85A6] A:0011 X:001B Y:0005 P:envMxdizC - Jump to Subroutine which leads out of the Routine all together.
---------------------------------------------------------------------------------------------------------------------------------------------------------------------------
$03/E58E C9 40 CMP #$40 A:008F X:0011 Y:0005 P:eNvMxdizc - Is it less than 40?
$03/E590 90 04 BCC $04    [$E596] A:008F X:0011 Y:0005 P:envMxdizC - If so, branch to 03E596.
$03/E592 A9 41 LDA #$41 A:008F X:0011 Y:0005 P:envMxdizC - Load Flare into A.
$03/E594 80 02 BRA $02    [$E598] A:0041 X:0011 Y:0005 P:envMxdizC - Branch Always to 03E598.
---------------------------------------------------------------------------------------------------------------------------------------------------------------------------
$03/E596 A9 40 LDA #$40 A:0024 X:0064 Y:0007 P:eNvMxdizc - Load Comet

New code:
Code: [Select]
$03/E56E 5A          PHY                      ;In case the current value of Y is significant
$03/E56F A0 00 00    LDY #$0000              ;Set Y to 0000
$03/E572 BD 53 20    LDA $2053,x[$7E:2053]    ;Load caster's enemy targeting byte
$03/E575 D0 03       BNE $03    [$E57A]      ;if it is not zero, skip the next op
$03/E577 A0 1E 00    LDY #$001E              ;otherwise, load 001E into Y
$03/E57A EA          NOP                     
$03/E57B EA          NOP                     
$03/E57C EA          NOP                     
$03/E57D EA          NOP                     
$03/E57E EA          NOP                      ;space filler, placed here specifically in case other parts of the Twin routine rely on the proper position of the fail routine
$03/E57F 20 93 85    JSR $8593  [$03:8593]    ;Random number generator
$03/E582 C9 FF       CMP #$FF               
$03/E584 90 08       BCC $08    [$E58E]      ;If random number is less than FF, skip ahead
$03/E586 A9 11       LDA #$11               
$03/E588 8D CA 34    STA $34CA  [$7E:34CA]   
$03/E58B 4C A6 85    JMP $85A6  [$03:85A6]    ;otherwise, show "failed" message and end routine
$03/E58E C9 40       CMP #$40               
$03/E590 90 01       BCC $01    [$E593]      ;If random number is less than 40, skip the next op
$03/E592 C8          INY                  ;+1 to Y
$03/E593 98          TYA                  ;Transfer Y to A
$03/E594 7A          PLY                  ;Set Y back to whatever it was before we started
$03/E595 18          CLC                     
$03/E596 69 40       ADC #$40  ;Add 40 to A

Voila!

Now, for those who might be interested in using this in their own hacks, beware, this takes out the special consideration for which spell to use if the caster is Golbez or FuSoYa... which means there's a chance they will cast Flare on Zemus. At the very least, this would require a slight alteration of dialogue ("Use the Meteo!" Then they cast Flare?).

Grimoire LD

  • FF4 Hacker
  • *
  • Posts: 1,684
    • View Profile
Re: Final Fantasy IV: A Threat from Within (The Preview)
« Reply #19 on: March 02, 2014, 01:31:05 PM »
Glad to hear everything is working! And I have to say the idea to use targeting is a lot better of an idea than my own haphazard method. Though I am curious... when Porom initiates the Twincast and you target allies, does it hit all allies or will it only hit Palom? That problem is what  continues to confound me.

chillyfeez

  • FF4 Hacker
  • *
  • Posts: 1,281
  • Gender: Male
  • Go ahead, ask me about Angel Feathers!
    • View Profile
Re: Final Fantasy IV: A Threat from Within (The Preview)
« Reply #20 on: March 02, 2014, 01:57:00 PM »
I just tested... seems to work as planned.

Grimoire LD

  • FF4 Hacker
  • *
  • Posts: 1,684
    • View Profile
Re: Final Fantasy II: A Threat from Within (The Preview)
« Reply #21 on: March 02, 2014, 02:44:07 PM »
Hmm, where was Porom positioned? Because if she was in the middle of the party (first slot) she is "tied" with Palom in the "superior"/"inferior" twin issue goes.

If she's not in the middle slot and it works fine maybe its something I didn't account for in my original hack.

Also do you happen to know where the Level Up Tables are in 1.1? I can't seem to locate the document with info. on those.

chillyfeez

  • FF4 Hacker
  • *
  • Posts: 1,281
  • Gender: Male
  • Go ahead, ask me about Angel Feathers!
    • View Profile
Re: Final Fantasy II: A Threat from Within (The Preview)
« Reply #22 on: March 02, 2014, 04:12:17 PM »
I tested with her in slots 1 and 5 and it works fine, though palom may have been in slot 1 when porom was in 5, if that would make any difference...

Regarding level up data... I think it's the same regardless of version - 7B700 (pointers) and 7B728 (data)

chillyfeez

  • FF4 Hacker
  • *
  • Posts: 1,281
  • Gender: Male
  • Go ahead, ask me about Angel Feathers!
    • View Profile
Re: Final Fantasy II: A Threat from Within (The Preview)
« Reply #23 on: March 02, 2014, 04:48:32 PM »
Updated patch linked in the original post.

Still need to patch in Grimoire LD's version of Salve, as well as update the credits. Both will happen soon.

Regarding the Agart minibosses - now they don't disappear, they just say "don't hurt me!" After you defeat them. I tried a couple of different fixes, but nothing else solved the problem of the phantom minibosses. This was my least favorite option, but at least it works smoothly now.

Grimoire LD

  • FF4 Hacker
  • *
  • Posts: 1,684
    • View Profile
Re: Final Fantasy II: A Threat from Within (The Preview)
« Reply #24 on: March 02, 2014, 08:47:20 PM »
Thank you very much Chillyfeez! That might explain why I was having trouble pinpointing it. I forget exactly where FFII v1.1 offsets begin to differ from v1.0.

I think the Twin issue is something I may have inadvertently created with subpar hacking. No matter. I'll likely borrow some of what you did here then for an upgraded Twincast command.

Ah well, it might show that Furio is of a merciful sort to even spare the lives of monsters in his actions so I guess it works in a character development sort of manner, in that respect. My time will be crunched until Tuesday, but I'll make sure to give this a try then!

chillyfeez

  • FF4 Hacker
  • *
  • Posts: 1,281
  • Gender: Male
  • Go ahead, ask me about Angel Feathers!
    • View Profile
Re: Final Fantasy II: A Threat from Within (The Preview)
« Reply #25 on: March 03, 2014, 04:18:15 PM »
UPDATE
You're absolutely right, Grimoire. I think this was actually a case of subpar testing on my part...
 :isuck:
Porom won't use Twin on all party members unless she's in slot 1.
 :lame:

 :edit: OK, I figured out why my tests worked fine. Porom will target all party members as long as she is in an earlier slot than Palom. So if she's in slot 2 and Palom's in slot 3 through 5, no problem. The dominant twin bug happens if Palom is in an earlier slot. It's one of those things that is bothersome, but I think I can (grudgingly) live with. Maybe someday I'll investigate the matter more, but I've got too many other things I want to work on right now.
« Last Edit: March 03, 2014, 04:35:21 PM by chillyfeez »

chillyfeez

  • FF4 Hacker
  • *
  • Posts: 1,281
  • Gender: Male
  • Go ahead, ask me about Angel Feathers!
    • View Profile
Re: Final Fantasy II: A Threat from Within (The Preview)
« Reply #26 on: March 04, 2014, 03:32:57 PM »
Alright, I put on my supercool trench coat and Neo shades for this one...


I made a fix for the Dominant Twin problem.
Mind you, this is very specific to my hack, but the principle can transfer to other work as well.
Essentially, this gives Porom a new command (also called "Twin") that forces Palom to use Twin immediately, using targeting specified by Porom's command.
For my hack, I took over Boast (the last unused command), and had to squeeze the code into a bunch of different empty spaces (thereby using up just about every last bit of the 30000 block).

Here's the disassembly. Excuse the jumps - they were necessary to work around code that can't be moved at this point.
Code: [Select]
$03/EAC3 A2 00 00    LDX #$0000
$03/EAC6 BD 01 20    LDA $2001,x
$03/EAC9 29 0F       AND #$0F   
$03/EACB C9 07       CMP #$07    ;Check if Palom is in slot 1
$03/EACD F0 0D       BEQ $0D   
$03/EACF C2 20       REP #$20   
$03/EAD1 8A          TXA       
$03/EAD2 18          CLC       
$03/EAD3 69 80 00    ADC #$0080
$03/EAD6 AA          TAX       
$03/EAD7 7B          TDC       
$03/EAD8 E2 20       SEP #$20   
$03/EADA 80 EA       BRA $EA    ;If not, check if Palom is in slot 2, and so on until he's found
$03/EADC A9 10       LDA #$10   
$03/EADE 9D 51 20    STA $2051,x ;Store Twin (the real command) into Palom's next action
$03/EAE1 4C 58 F2    JMP $F258  ;(jump)
-----------------------------------------------
$03/F258 C2 20       REP #$20   
$03/F25A AD D3 26    LDA $26D3 
$03/F25D 9D 53 20    STA $2053,x ;Copy Porom's Target (enemy AND Ally) into Palom's target
$03/F260 8A          TXA        ;Move Palom's slot ID to A
$03/F261 4A          LSR A     
$03/F262 4A          LSR A     
$03/F263 4A          LSR A     
$03/F264 4A          LSR A     
$03/F265 4A          LSR A     
$03/F266 4A          LSR A     
$03/F267 4A          LSR A      ;Shift A to the right 7 times, changing it into the true representation of Palom's slot number (result will be 0, 1, 2, 3 or 4)
$03/F268 AA          TAX        ;Transfer A back to X
$03/F269 7B          TDC       
$03/F26A E2 20       SEP #$20   
$03/F26C E0 00 00    CPX #$0000
$03/F26F F0 06       BEQ $06   
$03/F271 18          CLC       
$03/F272 69 15       ADC #$15   
$03/F274 CA          DEX       
$03/F275 80 F5       BRA $F5    ;Essentially, multiply Palom's slot number by 0x15
$03/F277 AA          TAX        ;Then store the result in X
$03/F278 9E 07 2A    STZ $2A07,x ;Make Palom's wait time 00
$03/F27B A9 08       LDA #$08    ;Make Palom automatically perform the action in his Next Action byte (Which is now Twin)
$03/F27D 4C F5 FF    JMP $FFF5  ;(jump)
-----------------------------------------------
$03/FFF5 9D 09 2A    STA $2A09,x ;Make Palom perform action in his Next Action byte (continued)
$03/FFF8 EE 0A 39    INC $390A  ;Set the byte that makes changes to the "wait time" table stick
$03/FFFB CE C4 33    DEC $33C4  ;Decrease the AV code by 01 (this replaces Boast, which is one higher than Twin)
$03/FFFE 60          RTS    ;Return

An added bonus to this - the real Twin command (the one Palom has) can be used on one/all enemies allies but defaults to the enemy side; Porom's Twin command can too, but defaults to the Ally side (implying that Palom prefers the offensive but Porom prefers the restorative.

chillyfeez

  • FF4 Hacker
  • *
  • Posts: 1,281
  • Gender: Male
  • Go ahead, ask me about Angel Feathers!
    • View Profile
Re: Final Fantasy II: A Threat from Within (The Preview)
« Reply #27 on: March 04, 2014, 03:45:44 PM »
I also spliced Grimoire LD's Salve command into my hack, but I made a very slight change...

The BCS $36 at 03/E303 - I changed it to BCS $E6.
What this does is, if the item is above the last usable battle item (Heal potion), instead of returning a "failed" message, it moves on to check the next item. So now, Avon will Salve the first usable item in the party's inventory.

Latest version linked on the first post. Now including:
-Final revisions to Twin command
-Updated Salve command
-Updated credits sequence
« Last Edit: March 04, 2014, 03:54:05 PM by chillyfeez »

Grimoire LD

  • FF4 Hacker
  • *
  • Posts: 1,684
    • View Profile
Re: Final Fantasy II: A Threat from Within (The Preview)
« Reply #28 on: March 04, 2014, 08:31:49 PM »
Your change to Salve is pretty good! I might have to borrow that as well.

Alright then, looks like its time for a second go through. As this is a second playthrough you can probably expect a bit shorter response.

And there we go... with no extra training and without a Ninja assistant I managed to defeat Jinn at Level 11. I stole 20 Cure 1's from the enemies and 20 Ice Kunai from the Imp. It took a while but I managed to bring down Jinn without incident.

Looks like the new Twincast is working optimally. I've seen Esuna and W. Cure as well as Flare and W.Meteo.

Salve appears to be working correctly and even better than before.

Hmm, Avon's invincibility still seems to last forever... ah well. Looks like a welcome update in any case!

chillyfeez

  • FF4 Hacker
  • *
  • Posts: 1,281
  • Gender: Male
  • Go ahead, ask me about Angel Feathers!
    • View Profile
Re: Final Fantasy II: A Threat from Within (The Preview)
« Reply #29 on: March 04, 2014, 09:23:52 PM »
What the crap with Avon. I'd have sworn I fixed that. Maybe I somehow ended up making the Twin changes on a ROM that was pre-Invincibility fix?
Well, I'll have to go back and fix that again. I'm working inventory late tonight, so maybe tomorrow. Glad to see everything else seems to be in order.
I think it's kinda cool that you're coming up with ways to bork my game, btw. In some bizarre sense it makes the game more similar to the original.

Putting this demo out has re-sparked my enthusiasm for this hack. I keep coming up with little bits and pieces that I want to work in. I have to re-do Jinn so he has his sprite change (and of course fix invincibility), but then I'm going to get back to writing more of the story. In chapter two you have the option of hiring Ruby or Cinna to help out. Bet you can't guess where the next REMA mission will take Furio!