øAslickproductions.org/forum/index.php?PHPSESSID=5f0fck550j2m4m2fpbtkj2vkm1&topic=1883.msg19420e:/My Web Sites/Slick Productions - FFIV Message Board/slickproductions.org/forum/index89d6.htmlslickproductions.org/forum/index.php?PHPSESSID=5f0fck550j2m4m2fpbtkj2vkm1&topic=1883.0e:/My Web Sites/Slick Productions - FFIV Message Board/slickproductions.org/forum/index89d6.html.zx×g^ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÈ'†OKtext/htmlISO-8859-1gzip@øÕ†ÿÿÿÿÿÿÿÿTue, 10 Mar 2020 04:59:24 GMT0ó°° ®0®P®€§²ð®Õg^ÿÿÿÿÿÿÿÿKY† Grimoire LD's Notes, Patches, and Hacks (Dark Knight/Paladin Swap In Battle!)

Author Topic: Grimoire LD's Notes, Patches, and Hacks (Dark Knight/Paladin Swap In Battle!)  (Read 78640 times)

Grimoire LD

  • FF4 Hacker
  • *
  • Posts: 1,684
    • View Profile
Re: Grimoire LD's Notes, Methods, and Hacks (Magic Activating with Fight!)
« Reply #120 on: October 11, 2013, 06:45:14 PM »
Hmm, yeah. I don't think the game is capable of showing one spell after another, unless there is something I'm missing. Otherwise the game will choose the last spell on the list. But I suspect that the game will be able to use several commands at once.

Well though I haven't yet got Steal to work like I want it to (Take away the Item Byte when it is achieved.) I did manage to add an FFIV:A capability to it which effectively makes it Mug.

The first ten bytes of Steal are this...

$03/E1CC   A9 17   LDA #$17   A:0003   X:002E   Y:0000   P:envMxdizc - Load 17 into A.
$03/E1CE   8D C8 34   STA $34C8  [$7E:34C8]   A:0017   X:002E   Y:0000   P:envMxdizc - Store A in 7E34C8
$03/E1D1   A9 10   LDA #$10   A:0017   X:002E   Y:0000   P:envMxdizc - Load 10 into A.
$03/E1D3   8D C7 34   STA $34C7  [$7E:34C7]   A:0010   X:002E   Y:0000   P:envMxdizc - Store A in 7E34C7

Which I've come to learn are just "Put Name of Command (In this case "Sneak" into a Message Box". Things that can easily be replaced. Besides, if we're using the skill we clearly know what skill is being used.

My replacement takes these ten bytes and does this...

$03/E1CC   AD B2 26   LDA $26B2  [$7E:26B2]   A:0003   X:002E   Y:0000   P:envMxdizc - Load Caster's Gauntlet into A.
$03/E1CF   C9 9D   CMP #$9D   A:009D   X:002E   Y:0000   P:eNvMxdizc - Is it Shadow Gauntlets? (For testing)
$03/E1D1   D0 03   BNE $03    [$E1D6]   A:009D   X:002E   Y:0000   P:envMxdiZC - If not, branch to 03E1D6 (rest of normal routine)
$03/E1D3   20 99 C4   JSR $C499  [$03:C499]   A:009D   X:002E   Y:0000   P:envMxdiZC - Jump to Fight Routine.

So whether you succeed, or fail. You will always deal some damage, making Steal on its own worthwhile if you have the right Gauntlet equipped.

It is so simple to do this, yet I cannot figure how to write a 00 into an item byte into a successful steal, oy...

Grimoire LD

  • FF4 Hacker
  • *
  • Posts: 1,684
    • View Profile
Re: Grimoire LD's Notes, Methods, and Hacks (Magic Activating with Fight!)
« Reply #121 on: October 11, 2013, 07:33:26 PM »
Let's finish this right! Just because I can't access it doesn't meant I can't jump to it.

Enemy Runs Away - Routine

Code: [Select]
$03/E1B2 A9 04 LDA #$04 A:0003 X:0028 Y:0000 P:envMxdizc - Load 04 into A.
$03/E1B4 8D E6 38 STA $38E6  [$7E:38E6] A:0004 X:0028 Y:0000 P:envMxdizc - Store A in 7E38E6
$03/E1B7 A6 A6 LDX $A6    [$00:00A6] A:0004 X:0028 Y:0000 P:envMxdizc - Load X from A6
$03/E1B9 BD 03 20 LDA $2003,x[$7E:2003] A:0004 X:0000 Y:0000 P:envMxdiZc - Load Indexed Slot's Status Byte 1 into A.
$03/E1BC 09 80 ORA #$80 A:0000 X:0000 Y:0000 P:envMxdiZc - Add 80 (Death) if applicable.
$03/E1BE 9D 03 20 STA $2003,x[$7E:2003] A:0080 X:0000 Y:0000 P:eNvMxdizc - Store A in Indexed Slot's Status Byte 1.
$03/E1C1 A9 05 LDA #$05 A:0080 X:0000 Y:0000 P:eNvMxdizc - Load 05 into A. (Ran Away)
$03/E1C3 8D CA 34 STA $34CA  [$7E:34CA] A:0005 X:0000 Y:0000 P:envMxdizc  - Store A in 7E34CA.
$03/E1C6 EE 0A 39 INC $390A  [$7E:390A] A:0005 X:0000 Y:0000 P:envMxdizc - +1 to 7E390A.
$03/E1C9 4C 9B 85 JMP $859B  [$03:859B] A:0005 X:0000 Y:0000 P:envMxdizc - Jump to Subroutine
$03/859B A9 F8 LDA #$F8 A:0005 X:0000 Y:0000 P:envMxdizc - Load F8 into A.
$03/859D 8D C2 33 STA $33C2  [$7E:33C2] A:00F8 X:0000 Y:0000 P:eNvMxdizc - Store A in 7E33C2.
$03/85A0 A9 03 LDA #$03 A:00F8 X:0000 Y:0000 P:eNvMxdizc - Load 03 into A.
$03/85A2 8D C3 33 STA $33C3  [$7E:33C3] A:0003 X:0000 Y:0000 P:envMxdizc - Store A in 7E33C3.
$03/85A5 60 RTS A:0003 X:0000 Y:0000 P:envMxdizc - Return

I'm of the opinion that this is completely unused by the game. The game opts to use Retreat over "Ran Away". What this might have been is possibly for a scrapped "Feared Away" sequence if an enemies Steal Prevention dropped too low, like in FFI and II (maybe III as well, can't recall). I never recalled "Ran Away" showing up in-game and it does give you the Exp as if you had defeated the foe, unlike Retreat does.

Though my memory could just be faulty.

assassin

  • Bane of Retards
  • *
  • Posts: 1,033
  • space bears are not gentle!
    • View Profile
    • My Barren Webpage
Re: Grimoire LD's Notes, Methods, and Hacks (Magic Activating with Fight!)
« Reply #122 on: October 12, 2013, 06:55:29 AM »
out of curiosity, how big is FF4's Battle Mechanics code?  in FF6, it's a little under half of a bank (C2), so about 26000 bytes.  exclude graphics and menu displaying stuff from this if possible.  (in FF6, i'm including the menu setups, but not their tile drawing or cursor navigation.)

Grimoire LD

  • FF4 Hacker
  • *
  • Posts: 1,684
    • View Profile
Re: Grimoire LD's Notes, Methods, and Hacks (Magic Activating with Fight!)
« Reply #123 on: October 12, 2013, 07:30:35 AM »
I believe that is generally unknown. FFIV has not been explored to the same extent as FFVI has been. It is difficult to even place a possible starting point, but if I had to I would say likely say this... 038000 to 03FFFF. I cannot get the game to breakpoint in battle before 038000 and I've never seen a 04XXXX value in battle.

Deathlike2

  • Moderator
  • *
  • Posts: 3,538
  • I'm looking at you, bitch!
    • View Profile
Re: Grimoire LD's Notes, Methods, and Hacks (Magic Activating with Fight!)
« Reply #124 on: October 12, 2013, 01:10:58 PM »
While you're at it... it would be nice to know how dropping money works (the probabilities) and if they are modified by anything (Cry is the only logical choice).
Working on the next Yet To Be Named FF4 "Hardtype" Hack Download Latest: v1.48

Video Demos: #1 #2 #3

Grimoire LD

  • FF4 Hacker
  • *
  • Posts: 1,684
    • View Profile
Re: Grimoire LD's Notes, Methods, and Hacks (Magic Activating with Fight!)
« Reply #125 on: October 12, 2013, 05:53:35 PM »
Hmm, yeah I'll take a look and see if I can't find anything in that regards.

This is it...

Code: [Select]
$03/8840 20 8B 85 JSR $858B  [$03:858B] A:0000 X:00C0 Y:0060 P:envMxdiZC - Generate Random Number (I have reason to believe this routine loads from 0-100 only not 0-256)
$03/8843 C9 32 CMP #$32 A:0014 X:0000 Y:0060 P:envMxdizc - Is it 32 or more?
$03/8845 B0 03 BCS $03    [$884A] A:0014 X:0000 Y:0060 P:eNvMxdizc  - If so branch to 03884A.
$03/8847 4C 20 89 JMP $8920  [$03:8920] A:0014 X:0000 Y:0060 P:eNvMxdizc - Jump to Subroutine (Return out of routine)
$03/8920 60 RTS A:0014 X:0000 Y:0060 P:eNvMxdizc

But there's something more here...
Code: [Select]
$03/883F 60 RTS A:0000 X:0280 Y:000F P:envMxdiZC (The routine before this is difficult to ascertain other than its cleaning statuses)
$03/871B 20 86 F1 JSR $F186  [$03:F186] A:0000 X:0280 Y:000F P:envMxdiZC - Jump to Subroutine 03F186
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
$03/F186 7B TDC A:0000 X:0280 Y:000F P:envMxdiZC - Transfer Direct Page
$03/F187 AA TAX A:0000 X:0280 Y:000F P:envMxdiZC - Transfer A to X
$03/F188 A8 TAY A:0000 X:0000 Y:000F P:envMxdiZC - Transfer A to Y
$03/F189 BD 41 20 LDA $2041,x[$7E:2041] A:0000 X:0000 Y:0000 P:envMxdiZC - Load Slot 1's Unknown(41) into A.
$03/F18C 9D 2D 20 STA $202D,x[$7E:202D] A:0002 X:0000 Y:0000 P:envMxdizC - Store A in Slot 1's ?Critical Hit Chance? (I wonder why...)
$03/F18F BD 42 20 LDA $2042,x[$7E:2042] A:0002 X:0000 Y:0000 P:envMxdizC - Load Slot 1's Unknown(42) into A.
$03/F192 9D 2E 20 STA $202E,x[$7E:202E] A:0014 X:0000 Y:0000 P:envMxdizC - Store A in Slot 1's Critical Hit Damage bonus.
$03/F195 B9 BF 38 LDA $38BF,y[$7E:38BF] A:0014 X:0000 Y:0000 P:envMxdizC - Load 7E38BF into A.
$03/F198 9D 03 20 STA $2003,x[$7E:2003] A:0000 X:0000 Y:0000 P:envMxdiZC - Store A in Slot 1's Status Byte 1.
$03/F19B B9 C0 38 LDA $38C0,y[$7E:38C0] A:0000 X:0000 Y:0000 P:envMxdiZC - Load 7E38C0 into A.
$03/F19E 9D 04 20 STA $2004,x[$7E:2004] A:0000 X:0000 Y:0000 P:envMxdiZC - Store A in Slot 1's Status Byte 2.
$03/F1A1 B9 C1 38 LDA $38C1,y[$7E:38C1] A:0000 X:0000 Y:0000 P:envMxdiZC - Load A in 7E38C1.
$03/F1A4 9D 06 20 STA $2006,x[$7E:2006] A:0000 X:0000 Y:0000 P:envMxdiZC - Store A in Slot 1's Status Byte 3.
$03/F1A7 20 BC 85 JSR $85BC  [$03:85BC] A:0000 X:0000 Y:0000 P:envMxdiZC - Jump to Subroutine (From here on it is a repeating cycle of 80 to reach all necessary points)

Well here's something of note... it's how the game takes the values from in-battle and puts them back into the normal positions.

Code: [Select]
$03/F1B2 7B TDC A:0000 X:0280 Y:000F P:envMxdiZC - Transfer Direct Page.
$03/F1B3 AA TAX A:0000 X:0280 Y:000F P:envMxdiZC - Transfer A to X.
$03/F1B4 A8 TAY A:0000 X:0000 Y:000F P:envMxdiZC - Transfer A to Y.
$03/F1B5 64 A9 STZ $A9    [$00:00A9] A:0000 X:0000 Y:0000 P:envMxdiZC - Store Zero in A9.
$03/F1B7 64 AB STZ $AB    [$00:00AB] A:0000 X:0000 Y:0000 P:envMxdiZC - Store Zero in AB.
$03/F1B9 BD 00 20 LDA $2000,x[$7E:2000] A:0000 X:0000 Y:0000 P:envMxdiZC - Load 2000 into A.
$03/F1BC 99 00 10 STA $1000,y[$7E:1000] A:0081 X:0000 Y:0000 P:eNvMxdizC - Store it into A.
$03/F1BF E8 INX A:0081 X:0000 Y:0000 P:eNvMxdizC - +1 X
$03/F1C0 C8 INY A:0081 X:0001 Y:0000 P:envMxdizC - +1 Y
$03/F1C1 E6 AB INC $AB    [$00:00AB] A:0081 X:0001 Y:0001 P:envMxdizC - +1 AB
$03/F1C3 A5 AB LDA $AB    [$00:00AB] A:0081 X:0001 Y:0001 P:envMxdizC - Load AB into A.
$03/F1C5 C9 40 CMP #$40 A:0001 X:0001 Y:0001 P:envMxdizC - Rinse and repeat until you fill up the unit's stats.
$03/F1C7 D0 F0 BNE $F0    [$F1B9] A:0001 X:0001 Y:0001 P:eNvMxdizc - As above.
--------------------------------------------------------

Do this 5 times for each party member...

Code: [Select]
$03/F1D0 AA TAX A:0080 X:0040 Y:0040 P:envmxdizc - Transfer A to X
$03/F1D1 7B TDC A:0080 X:0080 Y:0040 P:envmxdizc - Transfer Direct Page.
$03/F1D2 E2 20 SEP #$20 A:0000 X:0080 Y:0040 P:envmxdiZc - Set Processor.
$03/F1D4 E6 A9 INC $A9    [$00:00A9] A:0000 X:0080 Y:0040 P:envMxdiZc - +1 A9.
$03/F1D6 A5 A9 LDA $A9    [$00:00A9] A:0000 X:0080 Y:0040 P:envMxdizc - Load A9 into A
$03/F1D8 C9 05 CMP #$05 A:0001 X:0080 Y:0040 P:envMxdizc - Is it 5?
$03/F1DA D0 DB BNE $DB    [$F1B7] A:0001 X:0080 Y:0040 P:eNvMxdizc - If not, branch back to 03F1B7 to properly transfer data

Item Storing into Outside of Battle Space.

Code: [Select]
$03/F1DC 7B TDC A:0005 X:0280 Y:0140 P:envMxdiZC - Transfer Direct Page.
$03/F1DD AA TAX A:0000 X:0280 Y:0140 P:envMxdiZC - Transfer A to X.
$03/F1DE A8 TAY A:0000 X:0000 Y:0140 P:envMxdiZC - Transfer A to Y.
$03/F1DF 86 A9 STX $A9    [$00:00A9] A:0000 X:0000 Y:0000 P:envMxdiZC - Store X in A9.
$03/F1E1 BD 1B 32 LDA $321B,x[$7E:321B] A:0000 X:0000 Y:0000 P:envMxdiZC - Load Item Battle Spot.
$03/F1E4 99 40 14 STA $1440,y[$7E:1440] A:00C9 X:0000 Y:0000 P:eNvMxdizC - Store A in Item Spot.
$03/F1E7 F0 04 BEQ $04    [$F1ED] A:00C9 X:0000 Y:0000 P:eNvMxdizC - If 00 branch to 03F1ED.
$03/F1E9 C9 60 CMP #$60 A:00C9 X:0000 Y:0000 P:eNvMxdizC - Do this 60 times.
$03/F1EB D0 06 BNE $06    [$F1F3] A:00C9 X:0000 Y:0000 P:envMxdizC - If not done, branch to 03F1F3.
$03/F1F9 D0 04 BNE $04    [$F1FF] A:0002 X:0000 Y:0000 P:envMxdizC
$03/F1FF E8 INX A:0002 X:0000 Y:0000 P:envMxdizC - +1 to X
$03/F200 E8 INX A:0002 X:0001 Y:0000 P:envMxdizC - +1 to X
$03/F201 E8 INX A:0002 X:0002 Y:0000 P:envMxdizC - +1 to X
$03/F202 E8 INX A:0002 X:0003 Y:0000 P:envMxdizC - +1 to X.
$03/F203 C8 INY A:0002 X:0004 Y:0000 P:envMxdizC - +1 to Y.
$03/F204 C8 INY A:0002 X:0004 Y:0001 P:envMxdizC - +1 to Y.
$03/F205 E6 A9 INC $A9    [$00:00A9] A:0002 X:0004 Y:0002 P:envMxdizC +1 to A9.
$03/F207 A5 A9 LDA $A9    [$00:00A9] A:0002 X:0004 Y:0002 P:envMxdizC - Load A9.
$03/F209 C9 30 CMP #$30 A:0001 X:0004 Y:0002 P:envMxdizC - Has it done this 30 times?
$03/F20B D0 D4 BNE $D4    [$F1E1] A:0001 X:0004 Y:0002 P:eNvMxdizc - If not branch back to 03F1E1.

And there you have it! The chance to drop money when you run is purely a 50/50 chance  32/64 (because if it were 80/100  205/255 we would have noticed a long time ago)




Grimoire LD

  • FF4 Hacker
  • *
  • Posts: 1,684
    • View Profile
Re: Grimoire LD's Notes, Methods, and Hacks (Magic Activating with Fight!)
« Reply #126 on: October 13, 2013, 12:41:20 AM »
I rather like FFI and I think that some of its formulas could be put into FFIV and not seem that out of place. So my current goal is to replace (what I deem to be) useless or rare formulas, to make formulas that are more in-line with FFI's own. Now there might be a method to use some of the unused spell routine slots,  but I'm not 100% ready to go that far yet. But it would save a few formulas if it worked.

LOCK - (Focus - -Evasion Which will actually work in this hack!)

Replacing Tornado/Weak's formula


Lock Routine
Code: [Select]
$03/D453 AD 29 27 LDA $2729  [$7E:2729] A:0003 X:0006 Y:0000 P:envMxdizc - Load Target's Evasion into A.
$03/D456 ED 9D 28 SBC $289D  [$7E:289D] A:0000 X:0006 Y:0000 P:envMxdiZc - Subtract A from Lock's Spell Power.
$03/D459 10 02 BPL $02    [$D45D] A:00E6 X:0006 Y:0000 P:eNvMxdizc - If it is a positive number branch to 03D45D.
$03/D45B A9 00 LDA #$00 A:00E6 X:0006 Y:0000 P:eNvMxdizc - Load 00 into A.
$03/D45D 8D 29 27 STA $2729  [$7E:2729] A:0000 X:0006 Y:0000 P:envMxdiZc - Store A in Target's Evasion.
$03/D460 60 RTS A:0000 X:0006 Y:0000 P:envMxdiZc - Return

Replaces Shell Routine -
SLOW - Slow1 Routine (Basically the same as above. Both sequences are the same.) - Reduces Target's Accuracy
Code: [Select]
$03/D873 AD 1C 27 LDA $271C  [$7E:271C] A:0003 X:001C Y:FFFF P:envMxdizc - Load Target's Accuracy into A.
$03/D876 ED 9D 28 SBC $289D  [$7E:289D] A:004B X:001C Y:FFFF P:envMxdizc - Subtract A from Spell Power.
$03/D879 10 02 BPL $02    [$D87D] A:003B X:001C Y:FFFF P:envMxdizC - If it is still positive, branch to 03D87D.
-------------------------------------------------------------------------------------------------------------
(Same as above)
------------------------------------------------------------------------------------------------------------
$03/D87D 8D 1C 27 STA $271C  [$7E:271C] A:003B X:001C Y:FFFF P:envMxdizC - Store A in Target's Accuracy.
$03/D880 60 RTS A:003B X:001C Y:FFFF P:envMxdizC - Return


Replacing Modify Speed.

TMPR - Temper - Increases Attack.

Code: [Select]
$03/D897 AD 82 26 LDA $2682  [$7E:2682] A:0003 X:001E Y:0000 P:envMxdizc - Load Caster's Level into A.
$03/D89A 4A LSR A A:000A X:001E Y:0000 P:envMxdizc - Divide A by 2.
$03/D89B AA TAX A:0005 X:001E Y:0000 P:envMxdizc - Transfer A to X.
$03/D89C AD 1D 27 LDA $271D  [$7E:271D] A:0005 X:0005 Y:0000 P:envMxdizc - Load Target's Attack Base into A.
$03/D89F 8E A9 00 STX $00A9  [$7E:00A9] A:003C X:0005 Y:0000 P:envMxdizc - Store Caster's Level /2 into A9.
$03/D8A2 6D A9 00 ADC $00A9  [$7E:00A9] A:003C X:0005 Y:0000 P:envMxdizc - Add A9 onto A.
$03/D8A5 C9 FF CMP #$FF A:0041 X:0005 Y:0000 P:envMxdizc - Is it FF?
$03/D8A7 90 02 BCC $02    [$D8AB] A:0041 X:0005 Y:0000 P:envMxdizc - If it is below FF branch to 03D8AB.
----------------------------------------------------------------------------------------------------------------------------------------------------------
(Load FF into A to prevent an overflow)
---------------------------------------------------------------------------------------------------------------------------------------------------------------
$03/D8AB 8D 1D 27 STA $271D  [$7E:271D] A:0041 X:0005 Y:0000 P:envMxdizc - Store A in 7E271D.
$03/D8AE 60 RTS A:0041 X:0005 Y:0000 P:envMxdizc - Return

This works a bit different from the other spells and that's to give Temper a use all game long, technically. It will boost attack in this manner... Attack + Level/2. So it will continue to scale as you level up.

Replaces Hug
FAST - FFI Haste (+1 Attack Multiplier)

Code: [Select]
$03/DCFB AD 1B 27 LDA $271B  [$7E:271B] A:0003 X:0048 Y:0000 P:envMxdizc - Load Target's Attack Multiplier into A.
$03/DCFE 1A INC A A:0002 X:0048 Y:0000 P:envMxdizc - +1 to A.
$03/DCFF C9 0B CMP #$0B A:0003 X:0048 Y:0000 P:envMxdizc -Is it 0B?
$03/DD01 90 02 BCC $02    [$DD05] A:0003 X:0048 Y:0000 P:eNvMxdizc - If Lower than 0B branch to 03DD01.
------------------------------------------------------------
(Set it back to 0A)
-----------------------------------------------------------
$03/DD05 8D 1B 27 STA $271B  [$7E:271B] A:0003 X:0048 Y:0000 P:eNvMxdizc - Store A in Target's Attack Multiplier into A
$03/DD08 60 RTS A:0003 X:0048 Y:0000 P:eNvMxdizc - Return

I am Well aware of how easy a spell like this would be to abuse in FFIV, I'm not even sure if setting it to a Max of 10 Attack Multipliers is fair. I may have to go lower to balance it a little further, I'm not sure in what way though.

Replaces Reaction

SLO2 - Slowra (Decreases Enemy's Attack Multipliers by 2.)

Code: [Select]
$03/DD2F AD 1B 27 LDA $271B  [$7E:271B] A:0003 X:004C Y:0000 P:envMxdizc - Load Target's Attack Multiplier into A.
$03/DD32 3A DEC A A:0000 X:004C Y:0000 P:envMxdiZc - -1 to A.
$03/DD33 3A DEC A A:00FF X:004C Y:0000 P:eNvMxdizc - -1 to A.
$03/DD34 C9 02 CMP #$02 A:00FE X:004C Y:0000 P:eNvMxdizc - Is it less than 02?
$03/DD36 90 02 BCC $02    [$DD3A] A:00FE X:004C Y:0000 P:eNvMxdizC - If not, branch to 03DD3A
$03/DD38 A9 01 LDA #$01 A:00FE X:004C Y:0000 P:eNvMxdizC - If so, load 01 into A. (To prevent overflow_
$03/DD3A 8D 1B 27 STA $271B  [$7E:271B] A:0001 X:004C Y:0000 P:envMxdizC - Store A in 7E271B.
$03/DD3D 60 RTS A:0001 X:004C Y:0000 P:envMxdizC - Return.

This one is probably really easy to abuse as well. I should probably make some of these auto-fail if used on a boss. Or just set the "Hit Boss - No" bit.


Replaces Dispel

SABR - Saber (+16 Attack, +10 Accuracy)

Code: [Select]
$03/D8B0 AD 1D 27 LDA $271D  [$7E:271D] A:0003 X:0020 Y:0000 P:envMxdizc - Load Target's Attack into A.
$03/D8B3 69 10 ADC #$10 A:003C X:0020 Y:0000 P:envMxdizc - Add 10 (16) to A.
$03/D8B5 C9 80 CMP #$80 A:004C X:0020 Y:0000 P:envMxdizc - Is it 80? (128)
$03/D8B7 90 02 BCC $02    [$D8BB] A:004C X:0020 Y:0000 P:eNvMxdizc - If not, branch to 03D8BB
--------------------------------------------------------------------------------
Load 80 into A if so. (This is to prevent a Mage (Saber is a Self-cast spell) from jumping up to over 200 attack with repeated castings)
------------------------------------------------------------------------------
$03/D8BB 8D 1D 27 STA $271D  [$7E:271D] A:004C X:0020 Y:0000 P:eNvMxdizc - Store A in Target's Attack.
$03/D8BE AD 1C 27 LDA $271C  [$7E:271C] A:004C X:0020 Y:0000 P:eNvMxdizc - Load Target's Accuracy.
$03/D8C1 69 0A ADC #$0A A:004F X:0020 Y:0000 P:envMxdizc - Add 10.
$03/D8C3 C9 FF CMP #$FF A:0059 X:0020 Y:0000 P:envMxdizc - Is it FF (255?)
$03/D8C5 90 02 BCC $02    [$D8C9] A:0059 X:0020 Y:0000 P:envMxdizc - If less than FF branch to 03D8C9.
------------------------------------------------------------------------------
Load FF into A. I don't mind players having more than 100% accuracy. Especially if enemies will have access to these very same spells.
---------------------------------------------------------------------------
$03/D8C9 8D 1C 27 STA $271C  [$7E:271C] A:0059 X:0020 Y:0000 P:envMxdizc
$03/D8CC 60 RTS A:0059 X:0020 Y:0000 P:envMxdizc


Replacing Count Routine

HARM - (Dia, deals damage only to the Undead) Well setting that up took a lot less time than I thought it would. Trying to alter Holy routine to have such an effect, oy... I'm not going to bother. It has no elemental checks or anything of that accord. Obviously if it were Holy it would deal crushing damage to Zombies that would ordinarily be weak to it.

Code: [Select]
$03/DBB5 AD 40 27 LDA $2740  [$7E:2740] A:0003 X:0038 Y:0000 P:envMxdizc - Load Target's Creature Type into A.
$03/DBB8 29 80 AND #$80 A:0080 X:0038 Y:0000 P:eNvMxdizc - Is it Zombie?
$03/DBBA D0 01 BNE $01    [$DBBD] A:0080 X:0038 Y:0000 P:eNvMxdizc -If not, branch to 03DBBD.
--------------------------------------------------------------------------------------------
$03/DBBC 60 RTS A:0000 X:0038 Y:FFFF P:envMxdiZc - Return.
------------------------------------------------------------------------------------------------
$03/DBBD 20 AF C9 JSR $C9AF  [$03:C9AF] A:0080 X:0038 Y:0000 P:eNvMxdizc - Jump to Damage Determination.
$03/DBBE 60 RTS A:0080 X:0038 Y:FFFF P:envMxdiZc - Return.


Replaces Blink

RUSE (Or... FFI's Blink. Adds Evasion) This will be very simple so as to be able to use Blink's extremely small routine. No checks, so if people want to overflow themselves back to low evasion, then they can have it. It's set to 0A but I wonder if that's a bit high...

Code: [Select]
$03/D623 AD 29 27 LDA $2729  [$7E:2729] A:0003 X:0010 Y:0000 P:envMxdizc
$03/D626 69 0A ADC #$0A A:0016 X:0010 Y:0000 P:envMxdizc
$03/D628 8D 29 27 STA $2729  [$7E:2729] A:0020 X:0010 Y:0000 P:envMxdizc
$03/D62B 60 RTS A:0020 X:0010 Y:0000 P:envMxdizc


We are surprisingly nearly there. All that remains is implementing Fear (-"Steal Prevention" Current Str/2 (maybe 4) If "Steal Prevention" is less than user's level, do an RNG check. It is is less than 50/100 put 80 in Status Byte 1.) and the various Elemental Shields. (AFir, AIce, etc)


Unlike everything else I've ever done... I'll actually be releasing this mini-mod as a patch! Just don't expect any balancing or anything of that sort, it will only include the 14 new routines and maybe some enemy AI changes to make use of them. This is merely a proof of concept. It will include Monster's evasions reimplemented as well.
 :edit:
Now onto the rest...

Replacing Odin (Odin will instead be a Dark Elemental Attack that hits all foes)

AFir, AIce, ALit, NulMgc, NulAll - (The First three are obvious on what they do, NulMgc makes it so Instant Death attacks won't kill the target and NulAll decreases the amount of damage magic does by 50%. I cannot emulate that. So instead it will just give you all resistances from elementals and protection from instant death.)

NulFir, NulIce, NulLit
Code: [Select]
$03/DB5F AD A2 28 LDA $28A2  [$7E:28A2] A:0003 X:0036 Y:0000 P:envMxdizc - Load Spell's Elemental.
$03/DB62 D0 2D BNE $2D    [$DB91] A:0000 X:0036 Y:0000 P:envMxdiZc - If it has an Elemental branch to 03DB91. (Used to transfer to Fear Routine)
$03/DB64 AD 9D 28 LDA $289D  [$7E:289D] A:0000 X:0036 Y:0000 P:envMxdiZc - Load Spell's Power.
$03/DB67 F0 0E BEQ $0E    [$DB77] A:0001 X:0036 Y:0000 P:envMxdizc - If 00 branch to 03DB77. (NulMgc, NulAll portion)
$03/DB69 AA TAX A:0001 X:0036 Y:0000 P:envMxdizc - Transfer A to X.
$03/DB6A 8E A9 00 STX $00A9  [$7E:00A9] A:0001 X:0001 Y:0000 P:envMxdizc - Store Spell Power in A9.
$03/DB6D AD 25 27 LDA $2725  [$7E:2725] A:0001 X:0001 Y:0000 P:envMxdizc - Load Target's Elemental Resistance into A.
$03/DB70 0D A9 00 ORA $00A9  [$7E:00A9] A:0000 X:0001 Y:0000 P:envMxdiZc - Add Spell Power into A if applicable.
$03/DB73 8D 25 27 STA $2725  [$7E:2725] A:0001 X:0001 Y:0000 P:envMxdizc - Store A in Target's Elemental Resistance.
$03/DB76 60 RTS A:0001 X:0001 Y:0000 P:envMxdizc - Return

What this does is allows me to save a lot of code and add some versatility to it. The Spell Powers will be as follows... AFir - 01, AIce, 02, ALit, 04, you could make other Resistance spells as well like ADrk, 08, AHly, 10, AAir, 20, ADrn, 40 if so inclined.

NulMgc (NlDth)

Code: [Select]
$03/DB5F AD A2 28 LDA $28A2  [$7E:28A2] A:0003 X:0036 Y:0000 P:envMxdizc - Load Spell's Elemental into A.
$03/DB62 D0 2D BNE $2D    [$DB91] A:0000 X:0036 Y:0000 P:envMxdiZc - If not 00 branch to 03DB91.
$03/DB64 AD 9D 28 LDA $289D  [$7E:289D] A:0000 X:0036 Y:0000 P:envMxdiZc - Load Spell's Power into A.
$03/DB67 F0 0E BEQ $0E    [$DB77] A:0000 X:0036 Y:0000 P:envMxdiZc - If 00 branch to 03DB77
---------------------------------------------------------------------------------------------
(NulFire, Ice, Lit are in here)
------------------------------------------------------------------------------------------
$03/DB77 AD 2B 27 LDA $272B  [$7E:272B] A:0000 X:0036 Y:0000 P:envMxdiZc - Load Target's Status Resistance into A.
$03/DB7A 09 80 ORA #$80 A:0000 X:0036 Y:0000 P:envMxdiZc - Add 80 (Death to it.
$03/DB7C 8D 2B 27 STA $272B  [$7E:272B] A:0080 X:0036 Y:0000 P:eNvMxdizc - Store A in Target's Resistance.
$03/DB7F AD A4 28 LDA $28A4  [$7E:28A4] A:0080 X:0036 Y:0000 P:eNvMxdizc - Load Status Infliction Byt 2 (Not real, just for Spell) of Spell.
$03/DB82 D0 01 BNE $01    [$DB85] A:0080 X:0036 Y:0000 P:eNvMxdizc - If it is not 00 branch to 03DB85.
$03/DB84 60 RTS A:00C0 X:0036 Y:0000 P:eNvMxdizC - Return

This gets by the other elemental resistance checks by seeing if it has power in the first place and since NulAll does the same thing with added all elemental resistance it goes off of that but checks if the spell has a Status Ailment to inflict (which it won't because the right tools aren't in place) and moves onto the rest of the routine.

So we will pick up NulAll there so as not to repeat most of a routine...

NulAll
Code: [Select]
....
$03/DB77 AD 2B 27 LDA $272B  [$7E:272B] A:0000 X:0036 Y:0000 P:envMxdiZc - Load Status Resistance Byte 1 of Target into A.
$03/DB7A 09 80 ORA #$80 A:0000 X:0036 Y:0000 P:envMxdiZc - Add 80 if applicable (Death)
$03/DB7C 8D 2B 27 STA $272B  [$7E:272B] A:0080 X:0036 Y:0000 P:eNvMxdizc - Store A in Status Resistance Byte.
$03/DB7F AD A4 28 LDA $28A4  [$7E:28A4] A:0080 X:0036 Y:0000 P:eNvMxdizc - Load Status Byte 2 of Spell.
$03/DB82 D0 01 BNE $01    [$DB85] A:0080 X:0036 Y:0000 P:eNvMxdizc - If it is not 00 branch to 03DB85.
$03/DB85 AD 25 27 LDA $2725  [$7E:2725] A:0080 X:0036 Y:0000 P:eNvMxdizc - Load Target's Elemental Resistance into A.
$03/DB88 09 7F ORA #$07 A:0000 X:0036 Y:0000 P:envMxdiZc - Add Fire, Ice, and Lightning Resistance into A if applicable.
$03/DB8A 8D 25 27 STA $2725  [$7E:2725] A:0007 X:0036 Y:0000 P:envMxdizc - Store A in Target's Elemental Resistance.
$03/DB8D 60 RTS A:0007 X:0036 Y:0000 P:envMxdizc - Return.

Whew! Took a little bit of fancy coding (for me, this is all virtually new to me) but everything is working properly! I just hope I have enough bytes left in Odin to make Fear work properly...

 :edit: With one byte left to spare I completed Fear to the exactions I desired! (Granted I probably could have saved even more space if I used one Branching point for the Returns.

Code: [Select]
$03/DB5F AD A2 28 LDA $28A2  [$7E:28A2] A:0003 X:0036 Y:0000 P:envMxdizc - Load Spell's Elemental.
$03/DB62 D0 2A BNE $2A    [$DB8E] A:0001 X:0036 Y:0000 P:envMxdizc - Branch if not 00 to 03DB8E.
-----------------------------------------------------------------------------------------------------------------
The Resistance Routines are in here....
----------------------------------------------------------------------------------------------------------------
$03/DB8E AD 94 26 LDA $2694  [$7E:2694] A:0001 X:0036 Y:0000 P:envMxdizc - Load Caster's Strength into A.
$03/DB91 4A LSR A A:000D X:0036 Y:0000 P:envMxdizc /Strength by 2.
$03/DB92 4A LSR A A:0006 X:0036 Y:0000 P:envMxdizC /Strength by 2.
$03/DB93 AA TAX A:0003 X:0036 Y:0000 P:envMxdizc - Transfer A to X.
$03/DB94 8E A9 00 STX $00A9  [$7E:00A9] A:0003 X:0003 Y:0000 P:envMxdizc - Store X in A9.
$03/DB97 AD 2F 27 LDA $272F  [$7E:272F] A:0003 X:0003 Y:0000 P:envMxdizc - Load Target's "Steal Prevention".
$03/DB9A ED A9 00 SBC $00A9  [$7E:00A9] A:000B X:0003 Y:0000 P:envMxdizc - Subtract Steal Prevention from Caster's Strength divided by 4.
$03/DB9D 8D 2F 27 STA $272F  [$7E:272F] A:0007 X:0003 Y:0000 P:envMxdizC - Store A in Target's "Steal Prevention".
$03/DBA0 CD 82 26 CMP $2682  [$7E:2682] A:0007 X:0003 Y:0000 P:envMxdizC - Is it less than the caster's level?
$03/DBA3 90 01 BCC $01    [$DBA6] A:0007 X:0003 Y:0000 P:eNvMxdizc - If so, branch to 03DBA6.
--------------------------------------------------------
(Return within)
--------------------------------------------------------
$03/DBA6 20 8B 85 JSR $858B  [$03:858B] A:0007 X:0003 Y:0000 P:eNvMxdizc - Jump to Random Number Generator.
$03/DBA9 C9 32 CMP #$32 A:0034 X:0000 Y:0000 P:eNvMxdizc - Is it greater than 32?
$03/DBAB B0 01 BCS $01    [$DBAE] A:0034 X:0000 Y:0000 P:envMxdizC - If so branch to 03DBAE
----------------------------------------------------
(Another Return)
------------------------------------------------------
$03/DBAE A9 80 LDA #$80 A:0034 X:0000 Y:0000 P:envMxdizC - Load 80 (Death) into A.
$03/DBB0 8D 03 27 STA $2703  [$7E:2703] A:0080 X:0000 Y:0000 P:eNvMxdizC - Store A in Target's Status Byte 1.
$03/DBB3 60 RTS A:0080 X:0000 Y:0000 P:eNvMxdizC - Return


Phew! Now this was a wonderful experiment. I've managed to include all of the unique formulas from FFI into FFIV.
Ah wait, there is one more... While Protect exists in FFIV it is nowhere near as malleable as it seems in FFI. So I will fix that routine up and see if I can't have it load Spell Power instead of Default 5.

And that was a bit more of a pain than I was expecting... ah well it works, that's all that matters.

Changes made to Protect...

Code: [Select]
$03/D859 AE 9D 28 LDX $289D  [$7E:289D] A:0011 X:001A Y:0000 P:envMxdizc - Load Spell Power into X..
$03/D85C 8E A9 00 STX $00A9  [$7E:00A9] A:0011 X:4201 Y:0000 P:envMxdizc - Store X in A9.
$03/D85F 80 04 BRA $04    [$D865] A:0011 X:4201 Y:0000 P:envMxdizc - Branch to 03D865.
--------------------------------------------------------------------------------------

-------------------------------------------------------------------------------------
$03/D865 18 CLC A:0011 X:4201 Y:0000 P:envMxdizc - Clear Carry Flag.
$03/D866 AD 2A 27 LDA $272A  [$7E:272A] A:0011 X:4201 Y:0000 P:envMxdizc - Load Target's Physical Defense into A.
$03/D869 6D A9 00 ADC $00A9  [$7E:00A9] A:0011 X:4201 Y:0000 P:envMxdizc - Add Spell Power to A.
$03/D86C 80 01 BRA $01    [$D86F] A:0012 X:4201 Y:0000 P:envMxdizc - Branch to 03D86F.
$03/D86F 8D 2A 27 STA $272A  [$7E:272A] A:0012 X:4201 Y:0000 P:envMxdizc - Store A Target's Physical Defense.
$03/D872 60 RTS A:0012 X:4201 Y:0000 P:envMxdizc - Return.


I got rid of the Zeromus check to add in a "Look at Spell Power" routine and it uses that to load the + to Defense.

Now I am finished. This was only done to supplement FFIV's existing system. I could go much further and make spells and attacks more akin to FFI's. But I think this will do for now.


The Patch will be coming soon!
« Last Edit: October 13, 2013, 01:09:30 PM by Grimoire LD »

Grimoire LD

  • FF4 Hacker
  • *
  • Posts: 1,684
    • View Profile
Re: Grimoire LD's Notes, Methods, and Hacks (FFI spell routines in FFIV!)
« Reply #127 on: October 13, 2013, 01:23:35 PM »
My short adventure of adding in all of FFI's unique spell routines into FFIV is now complete.

FFIV now has

LOCK (Decreases Evasion) In exchange of Single Digit HP Formula (Weak, etc)
SLO1 (Decreases Enemy Accuracy) In exchange of Increase Magic Defense (Shell)
TMPR (Gives + to Attack) In exchange of Modify Speed (Slow, Fast)
FAST (+1 Attack Multiplier) In exchange of Hug (Hug)
SLO2 (-2 Multiplier) in exchange of Reaction (Reaction)
SABR (+16 Attack, +10 Accuracy) in exchange of Get Rid of Positive Status (Dispel) (Black Hole is still active)
HARM (Damage Only the Undead) in exchange of Add Count (Count)
RUSE (+ Evasion) in exchange of Add Image (Blink)
FEAR (Decreases Target's "Steal Prevention" by Caster's Str/4, if less than Caster's Level 50% chance of fleeing.) in exchange of Odin.
ALIT,AFIR,AICE,ARUB,WALL (ALit, AFir, AIce add resistance to the predictable elements. ARub (going to be referred to as NlDth) gives the target immunity from Instant Death attacks. Wall, cannot work like it does in FFI because of my lack of control over statuses. (as I am pretty sure that is what NulAll (WALL) likely is in FFI. Instead it adds +Instant Death Protection and the three elemental resistances) also in exchange of Odin.

Look forward to news about a patch coming up soon!

chillyfeez

  • FF4 Hacker
  • *
  • Posts: 1,285
  • Gender: Male
  • Go ahead, ask me about Angel Feathers!
    • View Profile
Re: Grimoire LD's Notes, Methods, and Hacks (All Spells Disassembly)
« Reply #128 on: October 16, 2013, 11:06:22 PM »
Note:
Another mystery solved!

Code for Command Starting Graphics...
Code: [Select]
00-BF - Assigned by Spell.

C0 - Weapon Swing
C1 - None
C2 - White Magic
C3 - Black Magic
C4 - Summon Magic (Also includes the party vanishing)
C5 - Dark Wave
C6 - Character Jumps into the Air
C7 - Character does their Special Pose. (Recall)
C8 - Spell Pose is Held as White Magic light shows (Sing)
C9 - Run from battle (Hide)
CA - Just normal Spell/Item Use pose. (Salve)
CB - Pray
CC - Special Pose - Weapon Attack (Aim)
CD - Spell Pose is Held while attack happens (Focus)
CE - Kick
CF - Gird
D0 - Twincasting
D1 - Boast
D2 - Cry
D3 - Cover
D4 - Peep
D5 - Crash (Just a normal spell casting pose)
D6 - Dart (When used outside of its normal routine, shows a hand stuck in the foe as used in Fight without a weapon)
D7 - Sneak
D8 - Ninja
D9 - Regen
DA - Change
DB - Parry
DC - Character runs all the way from one side of the screen to the other, back to the front. ??
DD - Normal Spell Casting Pose.
DE - Return from Jump
DF - Second part of Focus (Attack)

Do you happen to know how/when/where the game uses these codes? Is it possible to assign a different pose to a command, like a spell-casting stance when using the Dart command, for example?

Grimoire LD

  • FF4 Hacker
  • *
  • Posts: 1,684
    • View Profile
Re: Grimoire LD's Notes, Methods, and Hacks (FFI spell routines in FFIV!)
« Reply #129 on: October 16, 2013, 11:54:42 PM »
I thought I would but I now come to the realization that I do not, this is for several reasons now that I think on it. This is never actually related to the routines. You could change the routines to the end of days and you would not see a change in the animation undertaken in said routine.

Now I am intrigued... let me see the reason for that, though I suspect its going to be Index based, depending on command used.

Let's see for sure...

Code: [Select]
$03/B138 BD 51 20 LDA $2051,x[$7E:2051] A:0002 X:0000 Y:0000 P:envMxdiZc - Load Action Used into A.
$03/B13B C9 02 CMP #$02 A:0005 X:0000 Y:0000 P:envMxdizc - Is it Magic of any sort?
$03/B13D F0 08 BEQ $08    [$B147] A:0005 X:0000 Y:0000 P:envMxdizC - If so branch to 03B147.
$03/B13F C9 07 CMP #$07 A:0005 X:0000 Y:0000 P:envMxdizC - Is it Think?
$03/B141 F0 04 BEQ $04    [$B147] A:0005 X:0000 Y:0000 P:eNvMxdizc - If so branch to 03B147.
$03/B143 C9 20 CMP #$20 A:0005 X:0000 Y:0000 P:eNvMxdizc - Is it ?20?
$03/B145 D0 03 BNE $03    [$B14A] A:0005 X:0000 Y:0000 P:eNvMxdizc - If so branch to 03B14A.
$03/B14A 48 PHA A:0005 X:0000 Y:0000 P:eNvMxdizc - Push A onto Stack.
$03/B14B 18 CLC A:0005 X:0000 Y:0000 P:eNvMxdizc - Clear Carry Flag.
$03/B14C 69 C0 ADC #$C0 A:0005 X:0000 Y:0000 P:eNvMxdizc - Add C0 onto A.
$03/B14E 8D C4 33 STA $33C4  [$7E:33C4] A:00C5 X:0000 Y:0000 P:eNvMxdizc - Store A in Audio/Visual. (C5 is the Animation of Dark Wave)
$03/B151 C9 C1 CMP #$C1 A:00C5 X:0000 Y:0000 P:eNvMxdizc - Is it ?None? (possibly used as a return)
$03/B153 D0 02 BNE $02    [$B157] A:00C5 X:0000 Y:0000 P:envMxdizC - If not branch to 03B157.
--------------------------------------------

-----------------------------------------------
$03/B157 8D FF 35 STA $35FF  [$7E:35FF] A:00C5 X:0000 Y:0000 P:envMxdizC - Store A in 7E35FF.
$03/B15A 9C C5 33 STZ $33C5  [$7E:33C5] A:00C5 X:0000 Y:0000 P:envMxdizC - Store Zero in another byte of Audio/Visual code.
$03/B15D 68 PLA A:00C5 X:0000 Y:0000 P:envMxdizC - Pull A.
$03/B15E 0A ASL A A:0005 X:0000 Y:0000 P:envMxdizC - x2 to A.
$03/B15F AA TAX A:000A X:0000 Y:0000 P:envMxdizc - Transer A to X.
$03/B160 BF 7C B3 03 LDA $03B37C,x[$03:B386] A:000A X:000A Y:0000 P:envMxdizc - Draw out First two bytes of the location of subroutine.
$03/B164 85 80 STA $80    [$00:0080] A:00E9 X:000A Y:0000 P:eNvMxdizc - Store it in 80.
$03/B166 BF 7D B3 03 LDA $03B37D,x[$03:B387] A:00E9 X:000A Y:0000 P:eNvMxdizc - Draw out second two bytes of the location of subroutine. (E9E9 in this case)
$03/B16C A9 03 LDA #$03 A:00E9 X:000A Y:0000 P:eNvMxdizc - Load 03 into A.
$03/B16E 85 82 STA $82    [$00:0082] A:0003 X:000A Y:0000 P:envMxdizc - Store A in 82.
$03/B170 DC 80 00 JML [$0080][$03:E9E9] A:0003 X:000A Y:0000 P:envMxdizc - Jump to Subroutine (defined by 80, which now holds the location of Commands subroutine)

Well that was unfortunate. However there is nothing stopping you from changing the used graphic within the subroutine itself... I think. And it did completely reveal where the Command Subroutines are being held which will be the way to fix "crashes game".

The way it is set up does not leave room for variables, unfortunately. (Command Number + C0 = Graphic shown) With only Magics and Think given special priority because of their variable factors.





chillyfeez

  • FF4 Hacker
  • *
  • Posts: 1,285
  • Gender: Male
  • Go ahead, ask me about Angel Feathers!
    • View Profile
Re: Grimoire LD's Notes, Methods, and Hacks (FFI spell routines in FFIV!)
« Reply #130 on: October 17, 2013, 01:35:56 AM »
Yeah... as long as command subroutine loads after the AV byte is loaded (which it seems to do), should be able to work that into a custom code.
I've pretty much finished developing what I'm calling a "Copy" command.

I tried to make Mime, but ran into a pretty big problem - in order to make it work, you'd have to reload $2700-$277F (the target's temporarily stored data). Unfortunately, the routine that loads the data from the in-battle character record (within $2000-$267F) to the target's temporary record is the same routine that calls the command subroutine and its AV effect. So I can mostly make it work - the Mime performs the same action on the same target as the Mimicked character - but the AV happens twice. I can perhaps best describe the phenomenon like so:
Code: [Select]
Load caster's data
Load Mime target's data
JUMP TO (command effect subroutine)
-----Copy Mime target's last action and target into caster's same
-----JUMP TO
----------Load new target's data
----------Jump to new command effect subroutine (and then return)
----------Run active command's AV
----------Return
-----Return
Run active command's AV

To make matters worse, this freezes the game when the mimicked command is Jump (probably Hide, too). I don't think there's a way to make it work...

So then I got to thinking smaller-scale. My custom Copy command essentially uses a monster's last action against it. I've tested it and it works perfectly, except that when the command is "fight" - really the only monster command that doesn't count as a spell - the character doesn't swing their weapon. I should be able to fix that now.

Something just occurred to me, though... the AV isn't indexed on the front end, but what's done with that byte after it's loaded into $33C4? Maybe I'll look into that tomorrow (after typing the summon tutorial I've been avoiding).

Grimoire LD

  • FF4 Hacker
  • *
  • Posts: 1,684
    • View Profile
Re: Grimoire LD's Notes, Methods, and Hacks (FFI spell routines in FFIV!)
« Reply #131 on: October 17, 2013, 08:50:59 AM »
Hmm, yeah I noticed similar problems in using the Un-Berserked Avenger Sword. Though for the most part things seemed well in hand before trying to mimic magic outside White froze the game. I think your idea to have this character mimic only Monster actions is probably the best idea that can be arranged.

Are you wondering what happens to the byte at 33C4 or are you wondering what becomes of the routine it arrived at 33C4 on? If it's the latter it gets overwritten for its original value, has a x2 added to it (to find its proper routine offset) and then it is replace by a 3 which is likely how the game reaches the address 03XXXX for Command Routines.

chillyfeez

  • FF4 Hacker
  • *
  • Posts: 1,285
  • Gender: Male
  • Go ahead, ask me about Angel Feathers!
    • View Profile
Re: Grimoire LD's Notes, Methods, and Hacks (FFI spell routines in FFIV!)
« Reply #132 on: October 17, 2013, 09:38:23 AM »
Are you wondering what happens to the byte at 33C4 or are you wondering what becomes of the routine it arrived at 33C4 on? If it's the latter it gets overwritten for its original value, has a x2 added to it (to find its proper routine offset) and then it is replace by a 3 which is likely how the game reaches the address 03XXXX for Command Routines.

The former, actually. My guess is that the byte loaded into AV probably also gets an ASL and points to the AV sequence... whether that can be fully deciphered is another question, but if it leads to two byte pointers, then individual commands' movements are in fact replaceable (with those of other commands).

At any rate, this missing byte solved my Copy command!
Here's the code if anybody wants it:
Code: [Select]
AD 52 27  LDA $2752 ;Load target's last sub-action
F0 04     BEQ $04   ;If it's zero (not a spell), jump to the fight sequence
C9 A9     CMP #$A9  ;Compare it to A9 (the address of the highest desirable copied command)
90 0A     BCC $0A   ;If it's less (and therefore within desirable range), skip the fight sequence
A9 C0     LDA #$C0  ;Load Fight's AV identifier
8D C4 33  STA $33C4 ;Store into the AV loader byte in RAM
20 99 C4  JSR $C499 ;Jump to Fight subroutine
80 06     BRA $06   ;Jump to end
8D D2 26  STA $26D2 ;(having skipped past fight) Store target's last sub-action into caster's pending sub-action
20 46 CC  JSR $CC46 ;Jump to Magic subroutine
60        RTS

One limitation of this code that I am fine with - it only uses the action on the target, so you can't copy a monster's cure spell onto yourself. I'm OK with that. You CAN copy a white mage's cure spell back to them, so that's kinda neat.

Couple of things I haven't tested, but are probably problems (that can be fixed) -
I haven't tried to copy a party member's Dart. Items I've accounted for - they won't copy because useable items begin above A9. My guess, though, is that copying Dart will result in some weird spell being cast.
Copying summon spells will likely also be a problem, since castable summon spells get replaced in the sub-action byte by uncastable summon spells.
I think that these two issues can just be solved by changing the targeting options (in the index at 9FFC3) to "One enemy," thereby negating the ability to try copying a party member.

Grimoire LD

  • FF4 Hacker
  • *
  • Posts: 1,684
    • View Profile
Re: Grimoire LD's Notes, Methods, and Hacks (FFI spell routines in FFIV!)
« Reply #133 on: October 17, 2013, 09:57:59 AM »
That is some clever hacking! Fantastic work there Chillyfeez. So where is this code planned to be plugged into? The newly unused portion of Peep linked to the old 0000 of "Crashes Game"?

chillyfeez

  • FF4 Hacker
  • *
  • Posts: 1,285
  • Gender: Male
  • Go ahead, ask me about Angel Feathers!
    • View Profile
Re: Grimoire LD's Notes, Methods, and Hacks (FFI spell routines in FFIV!)
« Reply #134 on: October 17, 2013, 12:53:13 PM »
That's where I put it for testing purposes.
In the big hack I'm working on, It may replace some other command. What's nice about this is that it's a very short block of code, so It can replace just about anything (there are quite a few existing commands that I don't plan to use in my hack). I may need the big space you created by shortening Peep for something else. See, this, I think, would be a command available to my Blue Mage character, who would also have a "Blue" command, and possibly a "Learn" command, which would be entirely custom and (I think) a much longer string of code.