Author Topic: Whose turn is it?  (Read 3296 times)

chillyfeez

  • FF4 Hacker
  • *
  • Posts: 1,285
  • Gender: Male
  • Go ahead, ask me about Angel Feathers!
    • View Profile
Re: Whose turn is it?
« Reply #15 on: November 07, 2013, 12:42:36 AM »
IT WORKS!
That was it - 7E390A. Somehow, setting that to 01 instead of the default 00 makes the game not reset the 08 timer status after the command is finished.
As a result, I now have a fully-functional Mime command! I'll clean up the code a bit tomorrow (I think I can cut out a few unneccessary commands) then post it for all to enjoy.
If there's any interest out there, I could make a patch that changes the game-crashing Dummy command into Mime. Would anyone want that? (I'll post the disassembly, too, of course)

Grimoire LD

  • FF4 Hacker
  • *
  • Posts: 1,684
    • View Profile
Re: Whose turn is it?
« Reply #16 on: November 07, 2013, 12:47:52 AM »
That sounds fantastic! I'm glad to see everything worked out well in the end. I wouldn't mind giving a Mime a spin.

xcmn

  • Mist Dragon
  • *
  • Posts: 2
    • View Profile
Re: Whose turn is it?
« Reply #17 on: November 07, 2013, 11:56:11 AM »
Please do. I'd love to have it in a hack. I'm especially keen on the humor a mime presents to the storyline.

chillyfeez

  • FF4 Hacker
  • *
  • Posts: 1,285
  • Gender: Male
  • Go ahead, ask me about Angel Feathers!
    • View Profile
Re: Whose turn is it?
« Reply #18 on: November 07, 2013, 11:20:06 PM »
Well, "cleaning the code up" took a long time, and ended up making the code about twice as long - but I believe I accounted for all instances that would make the command screw up.
The patch is attached. Apply to a headered 1.1 FFIIUS ROM (won't work on any others). This will turn the Dummied "makes game crash" command (the one after Peep) into Mime.
The only typically available commands that can't be mimed are Gird, Cover and Hide - Plus Mime itself. All spells (including summons) will Mime perfectly but will cost the appropriate amount of MP (so test on a character with MP). Throw and Item work fine as well (miming item may not expend the item...).
You can only Mime party members - Miming monsters will fail (but you can use my Copy command to copy monsters' attacks).

Here's the disassembly:
Code: [Select]
$03/FEF0 C2 20       REP #$20               
$03/FEF2 A6 A6       LDX $A6    [$00:06A6]   ;Load active character's slot into x
$03/FEF4 E2 20       SEP #$20               
$03/FEF6 AD 51 27    LDA $2751  [$00:2751]   ;Load target's last action used into A
$03/FEF9 C9 0F       CMP #$0F                ;Is it Gird?
$03/FEFB F0 71       BEQ $71    [$FF6E]      ;If so, jump to the end (fail mime)
$03/FEFD C9 13       CMP #$13                ;Is it Cover?
$03/FEFF F0 6D       BEQ $6D    [$FF6E]      ;If so, jump to the end (fail mime)
$03/FF01 C9 09       CMP #$09                ;Is it Hide?
$03/FF03 F0 69       BEQ $69    [$FF6E]      ;If so, jump to the end (fail mime)
$03/FF05 C9 15       CMP #$15                ;Is it Mime?
$03/FF07 F0 65       BEQ $65    [$FF6E]      ;If so, jump to the end (fail mime)
$03/FF09 C9 22       CMP #$22                ;Is it Regen-in-progress?
$03/FF0B D0 04       BNE $04    [$FF11]      ;If not, skip to next check
$03/FF0D A9 19       LDA #$19                ;If so, change to Regen
$03/FF0F 80 1E       BRA $1E    [$FF2F]      ;Then jump past this round of checks
$03/FF11 C9 20       CMP #$20                ;Is it Twincast?
$03/FF13 D0 04       BNE $04    [$FF19]      ;If not, skip to next check
$03/FF15 A9 02       LDA #$02                ;If so, change to Spellcast
$03/FF17 80 16       BRA $16    [$FF2F]      ;Then jump past this round of checks
$03/FF19 C9 1E       CMP #$1E                ;Is it Jump's return?
$03/FF1B D0 04       BNE $04    [$FF21]      ;If not, skip to next check
$03/FF1D A9 06       LDA #$06                ;If so, change to Jump
$03/FF1F 80 0E       BRA $0E    [$FF2F]      ;Then skip past this round of checks
$03/FF21 C9 1F       CMP #$1F                ;Is it Charge's return?
$03/FF23 D0 04       BNE $04    [$FF29]      ;If not, skip to next check
$03/FF25 A9 0D       LDA #$0D                ;If so, change to Charge
$03/FF27 80 06       BRA $06    [$FF2F]      ;Then skip past this round of checks
$03/FF29 C9 1C       CMP #$1C                ;Compare to Show
$03/FF2B 90 02       BCC $02    [$FF2F]      ;If an earlier command, then continue
$03/FF2D 80 3F       BRA $3F    [$FF6E]      ;If Show or later, jump to the end (fail mime)
$03/FF2F 9D 51 20    STA $2051,x[$00:2051]   ;Store A in active character's next action
$03/FF32 AD 52 27    LDA $2752  [$00:2752]   ;Load target's last spell used into A
$03/FF35 C9 4D       CMP #$4D                ;Compare to (uncastable) Imp
$03/FF37 90 17       BCC $17    [$FF50]      ;If an earlier spell, skip past this round of checks
$03/FF39 C9 5A       CMP #$5A                ;Comepare to (uncastable) Asura #1
$03/FF3B B0 05       BCS $05    [$FF42]      ;If yes or higher, skip ahead
$03/FF3D 18          CLC                     
$03/FF3E E9 1B       SBC #$1B               
$03/FF40 80 0E       BRA $0E    [$FF50]      ;If (uncastable) Imp through (uncastable) Leviatan, then switch to the castable version and skip past the rest of these checks
$03/FF42 C9 5D       CMP #$5D                ;Compare to (uncastable) Bahamut
$03/FF44 B0 04       BCS $04    [$FF4A]      ;If yes or higher, skip ahead
$03/FF46 A9 3E       LDA #$3E                ;If (uncastable) Asura #1, 2 or 3, then change to castable Asura
$03/FF48 80 06       BRA $06    [$FF50]      ;Then skip past the rest of these checks
$03/FF4A C9 5E       CMP #$5E                ;Is it higher than (uncastable) Bahamut?
$03/FF4C B0 02       BCS $02    [$FF50]      ;If so, skip ahead
$03/FF4E A9 3F       LDA #$3F                ;If (uncastable) Bahamut, change to castable Bahamut
$03/FF50 9D 52 20    STA $2052,x[$00:2052]   ;Store A in active character's next spell to cast
$03/FF53 AD 53 27    LDA $2753  [$00:2753]   
$03/FF56 9D 53 20    STA $2053,x[$00:2053]   
$03/FF59 AD 54 27    LDA $2754  [$00:2754]   
$03/FF5C 9D 54 20    STA $2054,x[$00:2054]   ;Load target's last target into A, then store A into active character's next target
$03/FF5F A9 03       LDA #$03               
$03/FF61 20 C8 85    JSR $85C8  [$00:85C8]   
$03/FF64 A9 08       LDA #$08               
$03/FF66 9D 06 2A    STA $2A06,x[$00:2B46]   
$03/FF69 EE 0A 39    INC $390A  [$00:390A]   ;Apply the status that makes active character automatically take next action
$03/FF6C 80 0F       BRA $0F    [$FF7D]      ;Then skip ahead 
$03/FF6E A9 00       LDA #$00               
$03/FF70 8D CA 34    STA $34CA  [$00:34CA]   
$03/FF73 A9 F8       LDA #$F8               
$03/FF75 8D C6 33    STA $33C6  [$00:33C6]   
$03/FF78 A9 03       LDA #$03               
$03/FF7A 8D C7 33    STA $33C7  [$00:33C7]   ;Display "Nothing Happened."
$03/FF7D A9 DB       LDA #$DB               
$03/FF7F 8D C4 33    STA $33C4  [$00:33C4]   ;Apply the "Parry" stance
$03/FF82 60          RTS   

Because of the length of the code, I couldn't simply use Grimoire LD's shortened Peep extra space, because it takes up too much space. I discovered, though, that the last ~110 (hex) bytes in the 30000s (LoROM) are free, so that's where the Mime code is.

Oh, by the way, the only change this patch will make is to create Mime - you'll still have to assign the command to a character.

Enjoy!
« Last Edit: November 09, 2013, 12:40:43 PM by chillyfeez »

chillyfeez

  • FF4 Hacker
  • *
  • Posts: 1,285
  • Gender: Male
  • Go ahead, ask me about Angel Feathers!
    • View Profile
Re: Whose turn is it?
« Reply #19 on: November 08, 2013, 12:13:28 AM »
By the way, Grimoire, any thoughts from your research on why "Nothing happened" isn't happening?

Grimoire LD

  • FF4 Hacker
  • *
  • Posts: 1,684
    • View Profile
Re: Whose turn is it?
« Reply #20 on: November 08, 2013, 07:51:21 AM »
I tried to delve into this a little but came up with little to no answer. All I can say is that ordinarily an 80 is put into 7E34C5 from very early in the command subroutines, (but not within their specific section) that without that there the game assumes there is no message. Try to plug an 80 in there with an instruction and see if that might solve the problem.

chillyfeez

  • FF4 Hacker
  • *
  • Posts: 1,285
  • Gender: Male
  • Go ahead, ask me about Angel Feathers!
    • View Profile
Re: Whose turn is it?
« Reply #21 on: November 08, 2013, 09:31:32 AM »
Will do. Thanks.

... so that didn't work.
 :bah:

I'm gonna try looking into this a bit, but honestly, I don't think it matters enough to spend a whole lot of time on... who would want to mimic crappy commands like Gird and Hide anyway?
« Last Edit: November 09, 2013, 12:35:55 AM by chillyfeez »

chillyfeez

  • FF4 Hacker
  • *
  • Posts: 1,285
  • Gender: Male
  • Go ahead, ask me about Angel Feathers!
    • View Profile
Re: Whose turn is it?
« Reply #22 on: November 09, 2013, 12:50:56 PM »
OK - Figured it out with a relatively simple fix - the disassembly and patch are updated in the post above.

For those interested, I followed the code from an unsuccessful jump (tried to jump on self for a guaranteed fail) to just outside of Jump's subroutine, then compared the trail with that of Fight and Mime. What I found was that Jump was loading "F8 03" into 7E33C6-33C7 somewhere before the subroutine, and Fight and Mime were not. Fight loads different values there, and Mime was loading nothing. So, I made a failed Mime load the same values a failed Jump does - Bingo! Now the player knows when a command can't be Mimed.

Pinkpuff

  • Flan Princess
  • *
  • Posts: 924
  • Find a Megalixir in Unprecedented Crisis!
    • View Profile
Re: Whose turn is it?
« Reply #23 on: November 10, 2013, 06:38:23 AM »
Does this patch move anything around of any significance code wise? If so, saving with FF4kster might fool up something unexpectedly.
Let's dance!

chillyfeez

  • FF4 Hacker
  • *
  • Posts: 1,285
  • Gender: Male
  • Go ahead, ask me about Angel Feathers!
    • View Profile
Re: Whose turn is it?
« Reply #24 on: November 10, 2013, 09:31:08 AM »
Granted I haven't updated my FF4kster since September or so, but the version I have is still compatible. The only thing this does is change a command pointer (the one for the unusable "game crash" command) and adds some code into a place that was previously all "FFs."
I would be concerned about how the patch might affect the version that you release once Grimoire is done breaking down his command editables that he is working on for you presently, since that deals directly with code in the battle commands (though none of what he is posting overlaps with any of the code in my Mime patch).

Grimoire LD

  • FF4 Hacker
  • *
  • Posts: 1,684
    • View Profile
Re: Whose turn is it?
« Reply #25 on: November 10, 2013, 12:19:40 PM »
Indeed, your patch doesn't really hurt anything in a default sense and uses unused (and wasted) resources all around. The one thing you did add to likely was the Command Pointer table (changing the 0000 for the Crash command), which is something the editor will likely never touch. It's nothing like tearing apart existing routines to make them work better for you, instead you added a while routine without swallowing up anything else, but even so these still work fine with FF4kster.