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

Grimoire LD

  • FF4 Hacker
  • *
  • Posts: 1,684
    • View Profile
Re: Grimoire LD's Notes, Methods, and Hacks (FFI spell routines in FFIV!)
« Reply #165 on: December 28, 2013, 03:22:41 PM »
Oh Zeromus, you are nothing but trouble...

I'm finally at the end of testing this and have learned Zeromus will not let it go quietly...

There's a few special parts to the Zeromus battle which look specifically for Cecil, the Crystal, the Paladin, and everything else is considered Dead with 0 HP. I will have to go back and figure out why this is. It is nothing in the Event Script that's for certain.

It's all before the Golbez/FuSoYa battle or after that. It's difficult to say.

If you are Not Paladin Cecil - Lower HP to 0, set Status Byte 1 to 80 (Dead)

...Alright, the moment Zeromus does his "shaking" animation he kills all characters that aren't Paladin Cecil. A very exact place to put it, but okay.

And I found it! In RAM at...
$00/C21F   C9 0B   CMP #$0B   A:0001   X:0000   Y:0002   P:envMxdizc - Is it Paladin Cecil?

Just change this to whichever character you want to be alive with 1 HP, for my purposes that is 01

And finally the Crystal... I tackled this a long time ago actually...

RAM: 0x3A127 - C9 C8 (Compare Crystal Item Number)
RAM: 0x3A132 - C9 0B (Only this Unit ID may use the item designated as "Crystal")

ROM...

0x1A327 - C9 C8 (Compare Crystal Item Number)
0x1A332 - C9 0B (Only this Unit ID may use the item designated as "Crystal")


And finally one more check...

"If Unit 11 Uses Dark Magic" Counter that Zeromus has set up. I'll change that to 01 for my purposes.

And that is that! Finally my Solo Rydia Challenge patch is ready for release! And I can use this as a template for other Solo Challenge patches as well.

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 #166 on: December 28, 2013, 11:18:58 PM »
I was looking at your Advnc command...
First of all, it's a cool idea to invisibly change the command once it's been used. I've never had much luck deciphering what all of the "command menu data" means in in-battle RAM.
A couple of things on that, though:
1) Would the location of the command in RAM change depending on which of the character's command slots Advnc occupies? Not a big deal as long as nobody edits a hack that already has this set. Not as big a deal as...
2) Looks like you're changing the command based on an X that is set by the character's character slot. Fine if the character is in slot 0, because then X will be 0. But if thcharacter is in slot 1, then X will be 80, and "330F, 80" is 338F, which is another section of RAM. If my calculations are correct, you'd have to somehow make X equal to the character's slot times 1C for this to work right... Right?

Grimoire LD

  • FF4 Hacker
  • *
  • Posts: 1,684
    • View Profile
Re: Grimoire LD's Notes, Methods, and Hacks (FFI spell routines in FFIV!)
« Reply #167 on: December 28, 2013, 11:42:54 PM »
Thanks! The system is very wide open and has not been used to its full potential, though my uncreative self can only think to recreate things from other games, hehe.

For the first concern, the normal Hide command surprisingly does a balanced search through all five commands before seeing where it lays (Which is the Second Slot). It used a bit of code to do so originally. I didn't want to deal with that, so yes. It is fully dependent on its particular place in a character's command slots.

The second concern is troubling now that you mention it... the original Hide code uses "$03/E880   AE 34 35   LDX $3534  [$7E:3534]   A:0080   X:0000   Y:0000   P:eNvMxdizc - Load X from 7E3534." to keep track... I should have tried the command with more than the person in the first slot and saw that this would happen. I can only assume that the data in there looks specifically at the command options for each character. Hmm, maybe basing it more on the initial code for the relevant portions of Hide may have been the better idea.

Code: [Select]
$03/E876 A6 A6 LDX $A6    [$00:00A6] A:0003 X:0012 Y:0000 P:envMxdizc - Load Character Slot into A.
$03/E878 BD 06 20 LDA $2006,x[$7E:2006] A:0003 X:0000 Y:0000 P:envMxdiZc - Load Slot X's Status Byte 4.
$03/E87B 09 80 ORA #$80 A:0000 X:0000 Y:0000 P:envMxdiZc - Add 80.
$03/E87D 9D 06 20 STA $2006,x[$7E:2006] A:0080 X:0000 Y:0000 P:eNvMxdizc - Store A in Slot X's Status Byte 4.
$03/E880 AE 34 35 LDX $3534  [$7E:3534] A:0080 X:0000 Y:0000 P:eNvMxdizc - Load X from 7E3534.
$03/E883 64 A9 STZ $A9    [$00:00A9] A:0080 X:0000 Y:0000 P:envMxdiZc - Store Zero in A9.
----------------------------------------------------(Looping Point)------------------------------------------------------------------------
$03/E885 BD 03 33 LDA $3303,x[$7E:3303] A:0080 X:0000 Y:0000 P:envMxdiZc - Load A from 7E3303.
$03/E888 C9 09 CMP #$09 A:0000 X:0000 Y:0000 P:envMxdiZc - Is it 09? (Hide)
$03/E88A D0 07 BNE $07    [$E893] A:0000 X:0000 Y:0000 P:eNvMxdizc - If not, branch to 03E893.
-------------------------------------------------------------------------------------------------------------------------------------------
$03/E88C A9 1C LDA #$1C A:0009 X:0010 Y:0000 P:envMxdiZC - Load 1C into A. (Show)
$03/E88E 9D 03 33 STA $3303,x[$7E:3313] A:001C X:0010 Y:0000 P:envMxdizC - Store A in 7E3313. (Location of Command to Replace.)
$03/E891 80 08 BRA $08    [$E89B] A:001C X:0010 Y:0000 P:envMxdizC - Branch to 08.

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 #168 on: December 29, 2013, 01:19:42 AM »
Aha! From the bab-il docs:
Quote
3534-3535 Pointer into the 3302-338D area for the current or most recently
    referenced character. Equal to the slot number times 1C.
That's it! So if you insert a "LDX $3534" in there, that should make it work regardless of character slot (stick it just before editing the command data, like at 03/E89B).

Grimoire LD

  • FF4 Hacker
  • *
  • Posts: 1,684
    • View Profile
Re: Grimoire LD's Notes, Methods, and Hacks (FFI spell routines in FFIV!)
« Reply #169 on: December 29, 2013, 01:43:13 AM »
Good catch! I hadn't noticed that in the babil docs. That would seem to be the way the game intends to, phew. I thought I was going to have to tear it apart and start from scratch.

Grimoire LD

  • FF4 Hacker
  • *
  • Posts: 1,684
    • View Profile
Re: Grimoire LD's Notes, Methods, and Hacks (FFI spell routines in FFIV!)
« Reply #170 on: December 30, 2013, 09:25:23 PM »
That did the trick, just plugged it there in the end as you suggested and Now it works flawlessly!

Code: [Select]
$03/E876 A6 A6 LDX $A6    [$00:00A6] A:0003 X:0012 Y:0000 P:envMxdizc - Load User's Position into X.
$03/E878 A9 09 LDA #$09 A:0003 X:0000 Y:0000 P:envMxdiZc - Load 09 into A (Graphic for Berserk)
$03/E87A 8D C4 33 STA $33C4  [$7E:33C4] A:0009 X:0000 Y:0000 P:envMxdizc - Store A in Audiovisual Code.
$03/E87D BD 14 20 LDA $2014,x[$7E:2014] A:0009 X:0000 Y:0000 P:envMxdizc - Load User's Modified Strength into A.
$03/E880 7D 1D 20 ADC $201D,x[$7E:201D] A:000D X:0000 Y:0000 P:envMxdizc - Add User's Attack Base into A.
$03/E883 C9 FF CMP #$FF A:002E X:0000 Y:0000 P:envMxdizc - Is it above 255?
$03/E885 90 02 BCC $02    [$E889] A:002E X:0000 Y:0000 P:envMxdizc - If not branch to 03E889
-------------------------------------------------------------------------------------------------------------------------
(Code here to set Attack to FF) A9 FF
------------------------------------------------------------------------------------------------------------------------
$03/E889 8D 1D 20 STA $201D  [$7E:201D] A:002E X:0000 Y:0000 P:envMxdizc - Store A in User's Attack Base.
$03/E88C BD 2A 20 LDA $202A,x[$7E:202A] A:002E X:0000 Y:0000 P:envMxdizc - Load User's Defense Base into A.
$03/E88F FD 14 20 SBC $2014,x[$7E:2014] A:0011 X:0000 Y:0000 P:envMxdizc - Subtract A from User's Strength.
$03/E892 B0 02 BCS $02    [$E896] A:0003 X:0000 Y:0000 P:envMxdizC - If more than 00 branch to 03E896.
--------------------------------------------------------------------------------------------------------------------------
(Code here to set Defense to 01) A9 01
----------------------------------------------------------------------------------------------------------------------------
$03/E896 8D 2A 20 STA $202A  [$7E:202A] A:0003 X:0000 Y:0000 P:envMxdizC - Store A in User's Defense Base.
$03/E899 A9 1B LDA #$1B A:0003 X:0000 Y:0000 P:envMxdizC - Load 1B (Parry) into A.
$03/E89B AE 34 35 LDX $3534  [$7E:3534] A:001B X:0000 Y:0000 P:envMxdizc - Load Pointer to Current Character's Command
$03/E89E 9D 0F 33 STA $330F,x[$7E:330F] A:001B X:0000 Y:0000 P:envMxdiZc - Store Parry in Character's 4th Command.
$03/E8A1 60 RTS A:001B X:0000 Y:0000 P:envMxdiZc - Return


Again, thank you very much Chillyfeez!

Grimoire LD

  • FF4 Hacker
  • *
  • Posts: 1,684
    • View Profile
Re: Grimoire LD's Notes, Methods, and Hacks (FFI spell routines in FFIV!)
« Reply #171 on: January 04, 2014, 02:11:04 AM »
I love Magic Swordskills in video games and especially in Final Fantasy. With a routine which took me... a minute to cook up, I changed Blast's small routine(could probably even go somewhere smaller) to make this, it's a very simple routine which loads a Weapon Swing before the spell effect to simulate a Magic Sword.

Code: [Select]
$03/DCF0 A9 C0 LDA #$C0 A:0003 X:0046 Y:FFFF P:envMxdizc - Load Weapon Swing into A.
$03/DCF2 8D C4 33 STA $33C4  [$7E:33C4] A:00C0 X:0046 Y:FFFF P:eNvMxdizc - Store A in Audio/visual commands.
$03/DCF5 4C 88 D3 JMP $D388  [$03:D388] A:00C0 X:0046 Y:FFFF P:eNvMxdizc - Jump to Magic Routine.


Now maybe we can turn Cecil into a Paladin that Agrias would be proud of!

When you come down to it, there's a good amount of magic sets available. There is of course, Unused Kain and though possibly controversial, changing Porom's spellset and linking it to Rosa's for cost saving purposes could be done, and then there's FuSoYa's Complete Spell Sets. Hey game, do you know who already Has a nearly complete spell set for Black and White? That's right! Tellah! So use his spell sets for FuSoYa's and you can add in the missing spells through FuSoYa's entrance event.

That gives four extra spell-sets to play around with. Maybe not an ideal number, but it is better than none.


Now in larger news I am very close to figuring out what constitutes a menu opening!

Fight Command Access

Code: [Select]
$02/B9C1 C9 18 CMP #$18 A:0000 X:0000 Y:0006 P:eNvMxdIzc - Is it Ninja?
$02/B9C3 F0 64 BEQ $64    [$BA29] A:0000 X:0000 Y:0006 P:eNvMxdIzc - If so branch to Black Magic Menu.
$02/B9C5 C9 05 CMP #$05 A:0000 X:0000 Y:0006 P:eNvMxdIzc - Is it Dark Wave?
$02/B9C7 90 03 BCC $03    [$B9CC] A:0000 X:0000 Y:0006 P:eNvMxdIzc - If greater than Dark Wave use secondary Access Routine.
$02/B9CC 0A ASL A A:0000 X:0000 Y:0006 P:eNvMxdIzc - x2 A (to reach the proper address.)
$02/B9CD AA TAX A:0000 X:0000 Y:0006 P:envMxdIZc - Transfer A to X.
$02/B9CE BF E6 B9 02 LDA $02B9E6,x[$02:B9E6] A:0000 X:0000 Y:0006 P:envMxdIZc - Load Pointer from 02B9E6.
$02/B9D2 85 0E STA $0E    [$00:000E] A:00F2 X:0000 Y:0006 P:eNvMxdIzc - Store A in 0E.
$02/B9D4 BF E7 B9 02 LDA $02B9E7,x[$02:B9E7] A:00F2 X:0000 Y:0006 P:eNvMxdIzczc - Load A from 02B9E7.
$02/B9D8 85 0F STA $0F    [$00:000F] A:00B9 X:0000 Y:0006 P:eNvMxdIzc - Store A in 0F.
$02/B9DA 6C 0E 00 JMP ($000E)[$02:B9F2] A:00B9 X:0000 Y:0006 P:eNvMxdIzc - Jump to Fight Access Routine.

White Magic Command Access

Code: [Select]
$02/B9C5 C9 05 CMP #$05 A:0002 X:0004 Y:0000 P:eNvMxdIzc - Is it Dark Wave?
$02/B9C7 90 03 BCC $03    [$B9CC] A:0002 X:0004 Y:0000 P:eNvMxdIzc - If greater than Dark Wave, branch to
$02/B9CC 0A ASL A A:0002 X:0004 Y:0000 P:eNvMxdIzc - x2 A.
$02/B9CD AA TAX A:0004 X:0004 Y:0000 P:envMxdIzc - Transfer A to X
$02/B9CE BF E6 B9 02 LDA $02B9E6,x[$02:B9EA] A:0004 X:0004 Y:0000 P:envMxdIzc - Load A from 02B9E6+X.
$02/B9D2 85 0E STA $0E    [$00:000E] A:001C X:0004 Y:0000 P:envMxdIzc - Store A in 0E
$02/B9D4 BF E7 B9 02 LDA $02B9E7,x[$02:B9EB] A:001C X:0004 Y:0000 P:envMxdIzc - Load A from 02B9E7+X
$02/B9D8 85 0F STA $0F    [$00:000F] A:00BA X:0004 Y:0000 P:eNvMxdIzc - Store A in 0F.
$02/B9DA 6C 0E 00 JMP ($000E)[$02:BA1C] A:00BA X:0004 Y:0000 P:eNvMxdIzc - Jump to White Magic Access routine.

This is going to lead to an entirely new area to explore! Though for now I have confirmed that it works in a simple manner.

0000 - Fight
0001(turns to 2) - Item
0002(turns to 4) - White Magic
0003(turns to 6) - Black Magic
0004(turns to 8) - Summon Magic

The trick to All of this is what lays at 02B9E6...

And lo and behold, it is pointers to addresses!


F2 B9 - Fight
05 BA - Item
1C BA - White
29 BA - Black
36 BA - Summon
43 BA - ?? (Fight again?)

Fight Access Call
Code: [Select]
$02/B9F2 A9 80 LDA #$80 A:00B9 X:0000 Y:0004 P:eNvMxdIzc - Load 80 into A.
$02/B9F4 85 D8 STA $D8    [$00:00D8] A:0080 X:0000 Y:0004 P:eNvMxdIzc - Store A in D8.
$02/B9F6 A5 60 LDA $60    [$00:0060] A:0080 X:0000 Y:0004 P:eNvMxdIzc - Load A from 60.
$02/B9F8 85 D9 STA $D9    [$00:00D9] A:0000 X:0000 Y:0004 P:envMxdIZc - Store A in D9.
$02/B9FA A9 01 LDA #$01 A:0000 X:0000 Y:0004 P:envMxdIZc - Load 01 into A.
$02/B9FC 8D 91 EF STA $EF91  [$7E:EF91] A:0001 X:0000 Y:0004 P:envMxdIzc - Store A in 7EEF91.
$02/B9FF A9 04 LDA #$04 A:0001 X:0000 Y:0004 P:envMxdIzc - Load 04 into A.
$02/BA01 8D 23 18 STA $1823  [$7E:1823] A:0004 X:0000 Y:0004 P:envMxdIzc - Load this into Targeting matters.
$02/BA04 60 RTS A:0004 X:0000 Y:0004 P:envMxdIzc - Return.

Item Access Call

Code: [Select]
$02/BA05 9C 9A EF STZ $EF9A  [$7E:EF9A] A:00BA X:0002 Y:0000 P:eNvMxdIzc - Store Zer in 7EEF9A.
$02/BA08 A9 05 LDA #$05 A:00BA X:0002 Y:0000 P:eNvMxdIzc - Load 05 into A.
$02/BA0A 8D 23 18 STA $1823  [$7E:1823] A:0005 X:0002 Y:0000 P:envMxdIzc - Load this into Targeting matters.
$02/BA0D 9C 94 EF STZ $EF94  [$7E:EF94] A:0005 X:0002 Y:0000 P:envMxdIzc - Store Zero into 7EEF94.
$02/BA10 9C 97 EF STZ $EF97  [$7E:EF97] A:0005 X:0002 Y:0000 P:envMxdIzc - Store Zero into 7EEF97.
$02/BA13 9C 98 EF STZ $EF98  [$7E:EF98] A:0005 X:0002 Y:0000 P:envMxdIzc - Store Zero into 7EEF98
$02/BA16 9C 99 EF STZ $EF99  [$7E:EF99] A:0005 X:0002 Y:0000 P:envMxdIzc (as above_
$02/BA19 4C E2 AA JMP $AAE2  [$02:AAE2] A:0005 X:0002 Y:0000 P:envMxdIzc - Jump to 02AAE2.

White Magic Access Call
Code: [Select]
$02/BA1C A9 00 LDA #$00 A:00BA X:0004 Y:0000 P:eNvMxdIzc -  - Load 00 into A (Spell Menu Position)
$02/BA1E 8D 93 EF STA $EF93  [$7E:EF93] A:0000 X:0004 Y:0000 P:envMxdIZc - Store A in 7EEF93.
$02/BA21 A9 09 LDA #$09 A:0000 X:0004 Y:0000 P:envMxdIZc - Load 09 into A
$02/BA23 8D 23 18 STA $1823  [$7E:1823] A:0009 X:0004 Y:0000 P:envMxdIzc - Store A in Targeting Matters.
$02/BA26 4C 57 AB JMP $AB57  [$02:AB57] A:0009 X:0004 Y:0000 P:envMxdIzc - Jump to 02AB57.

Black Magic Access Call

Code: [Select]
$02/BA29 A9 60 LDA #$60 A:00BA X:0006 Y:0000 P:eNvMxdIzc - Load 60 into A (Spell Menu Position)
$02/BA2B 8D 93 EF STA $EF93  [$7E:EF93] A:0060 X:0006 Y:0000 P:envMxdIzc - Store A in 7EEF93.
$02/BA2E A9 09 LDA #$09 A:0060 X:0006 Y:0000 P:envMxdIzc - Load 09 into A.
$02/BA30 8D 23 18 STA $1823  [$7E:1823] A:0009 X:0006 Y:0000 P:envMxdIzc - Store A in Targeting Matters.
$02/BA33 4C 77 AB JMP $AB77  [$02:AB77] A:0009 X:0006 Y:0000 P:envMxdIzc - Jump to 02AB77.

Summon Magic Access Call

Code: [Select]
$02/BA36 A9 C0 LDA #$C0 A:00BA X:0008 Y:0000 P:eNvMxdIzc - Load C0 into A (Spell Menu Position)
$02/BA38 8D 93 EF STA $EF93  [$7E:EF93] A:00C0 X:0008 Y:0000 P:eNvMxdIzc - Store A in 7EEF93.
$02/BA3B A9 09 LDA #$09 A:00C0 X:0008 Y:0000 P:eNvMxdIzc - Load 09 into A.
$02/BA3D 8D 23 18 STA $1823  [$7E:1823] A:0009 X:0008 Y:0000 P:envMxdIzc - Store A in Targeting Matters.
$02/BA40 4C 98 AB JMP $AB98  [$02:AB98] A:0009 X:0008 Y:0000 P:envMxdIzc - Jump to 02AB98.

Most Other Commands Access Call

Code: [Select]
$02/BA43 A9 80 LDA #$80 A:00BA X:000A Y:0004 P:eNvMxdIzc - Load 80 into A.
$02/BA45 85 D8 STA $D8    [$00:00D8] A:0080 X:000A Y:0004 P:eNvMxdIzc - Store A in D8.
$02/BA47 A5 60 LDA $60    [$00:0060] A:0080 X:000A Y:0004 P:eNvMxdIzc - Load 60 into A.
$02/BA49 85 D9 STA $D9    [$00:00D9] A:0000 X:000A Y:0004 P:envMxdIZc - Store A in D9.
$02/BA4B A9 01 LDA #$01 A:0000 X:000A Y:0004 P:envMxdIZc - Load 01 into A.
$02/BA4D 8D 91 EF STA $EF91  [$7E:EF91] A:0001 X:000A Y:0004 P:envMxdIzc - Store A 7EEF91.
$02/BA50 A9 07 LDA #$07 A:0001 X:000A Y:0004 P:envMxdIzc - Load 07  into A.
$02/BA52 8D 23 18 STA $1823  [$7E:1823] A:0007 X:000A Y:0004 P:envMxdIzc - Load A into Targeting Matters.
$02/BA55 60 RTS A:0007 X:000A Y:0004 P:envMxdIzc - Return.

Now Ninja is handled a little differently. Ninja is looked at...
$02/B9C1   C9 18   CMP #$18   A:0000   X:0000   Y:0006   P:eNvMxdIzc -
$02/B9C3   F0 64   BEQ $64    [$BA29]   A:0000   X:0000   Y:0006   P:eNvMxdIzc - Here.

And as we know from above that links Directly to Black Magic. Right before this is a CMP 16 which must look at the Dart Menu.

Now interestingly enough though there is a Special unique formula for Dark Wave... but its never used. The only difference in this data is a 07 instead of a 04. Now modifying this, it seems to be targeting in someway...

00 - Cursor vanishes
01 - Cursor stays on Command
02 - Seems to force the cursor left onto the Parry Command, causing the Parry Command to be shown throughout the fight.
03 - Same as above, except with Change.
04 - Normal Targeting
05 - Targeting as if from Item Menu (with normal command menu still showing, causes graphical anomalies)
06 - Freeze
07 - Normal Targeting as far as I can tell.
08 - Auto-Attack on Self
09 - Magic Menu Targeting
0A - Forces open the Black Magic Menu over the Commands and HP of characters, with the selections still being the commands.


I will fill in the data above tomorrow. It is very late where I am and this information was discovered last minute and I just couldn't leave it hanging, hehe.

 :edit: Bah, I need sleep...

Dark Wave Access

Code: [Select]
(Same as Above)
$02/B9C5 C9 05 CMP #$05 A:0005 X:0004 Y:0004 P:eNvMxdIzc
$02/B9C7 90 03 BCC $03    [$B9CC] A:0005 X:0004 Y:0004 P:envMxdIZC
$02/B9C9 4C 43 BA JMP $BA43  [$02:BA43] A:0005 X:0004 Y:0004 P:envMxdIZC
---------------------------------------------------------------------------------------------------
$02/BA43 A9 80 LDA #$80 A:0005 X:0004 Y:0004 P:envMxdIZC
$02/BA45 85 D8 STA $D8    [$00:00D8] A:0080 X:0004 Y:0004 P:eNvMxdIzC
$02/BA47 A5 60 LDA $60    [$00:0060] A:0080 X:0004 Y:0004 P:eNvMxdIzC
$02/BA49 85 D9 STA $D9    [$00:00D9] A:0001 X:0004 Y:0004 P:envMxdIzC
$02/BA4B A9 01 LDA #$01 A:0001 X:0004 Y:0004 P:envMxdIzC
$02/BA4D 8D 91 EF STA $EF91  [$7E:EF91] A:0001 X:0004 Y:0004 P:envMxdIzC
$02/BA50 A9 07 LDA #$07 A:0001 X:0004 Y:0004 P:envMxdIzC
$02/BA52 8D 23 18 STA $1823  [$7E:1823] A:0007 X:0004 Y:0004 P:envMxdIzC
$02/BA55 60 RTS A:0007 X:0004 Y:0004 P:envMxdIzC

Wait! This is the same exact thing as 05? Why doesn't it just go down the normal line then?! Bah...

Dart Command Access

Code: [Select]
(Same as Item Above)
$02/B9DE A9 08 LDA #$08 A:0016 X:0008 Y:0004 P:envMxdIZC -
$02/B9E0 8D 9A EF STA $EF9A  [$7E:EF9A] A:0008 X:0008 Y:0004 P:envMxdIzC
$02/B9E3 4C 08 BA JMP $BA08  [$02:BA08] A:0008 X:0008 Y:0004 P:envMxdIzC
-----------------------------------------------------------------------------------------------
$02/BA08 A9 05 LDA #$05 A:0008 X:0008 Y:0004 P:envMxdIzC
$02/BA0A 8D 23 18 STA $1823  [$7E:1823] A:0005 X:0008 Y:0004 P:envMxdIzC
$02/BA0D 9C 94 EF STZ $EF94  [$7E:EF94] A:0005 X:0008 Y:0004 P:envMxdIzC
$02/BA10 9C 97 EF STZ $EF97  [$7E:EF97] A:0005 X:0008 Y:0004 P:envMxdIzC
$02/BA13 9C 98 EF STZ $EF98  [$7E:EF98] A:0005 X:0008 Y:0004 P:envMxdIzC
$02/BA16 9C 99 EF STZ $EF99  [$7E:EF99] A:0005 X:0008 Y:0004 P:envMxdIzC
$02/BA19 4C E2 AA JMP $AAE2  [$02:AAE2] A:0005 X:0008 Y:0004 P:envMxdIzC

Same as Item Access, I guess that was to be expected. That felt like a waste of 10 minutes editing that I could have used on sleep, hehe.
« Last Edit: January 04, 2014, 11:34:20 AM 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 #172 on: January 04, 2014, 11:34:50 AM »
Post above updated with comments on the various links to the Menus.

Grimoire LD

  • FF4 Hacker
  • *
  • Posts: 1,684
    • View Profile
Re: Grimoire LD's Notes, Methods, and Hacks (FFI spell routines in FFIV!)
« Reply #173 on: January 04, 2014, 01:24:12 PM »
I've put this off for too long...

Heal/Remove All Status Except... Routine

Code: [Select]
$03/D6FB F0 0A BEQ $0A    [$D707] A:0000 X:0016 Y:FFFF P:envMxdiZc - If 00 branch to 03D707
-------------------------------------------------------------------------------------------------------------------------------------

-------------------------------------------------------------------------------------------------------------------------------------------
$03/D707 AD D2 26 LDA $26D2  [$7E:26D2] A:0000 X:0016 Y:FFFF P:envMxdiZc - Load Current Action Taken.
$03/D70A C9 12 CMP #$12 A:0012 X:0016 Y:FFFF P:envMxdizc - Is it Heal?
$03/D70C F0 07 BEQ $07    [$D715] A:0012 X:0016 Y:FFFF P:envMxdiZC - If so branch to 03D715.
-----------------------------------------------------------------------------------------------------------------------
$03/D70E C9 86 CMP #$86 A:004B X:0016 Y:0000 P:envMxdizC - Is it (Enemy Spell) Heal?
$03/D710 F0 03 BEQ $03    [$D715] A:004B X:0016 Y:0000 P:eNvMxdizc - If so branch to 03D715.
$03/D712 4C 83 D7 JMP $D783  [$03:D783] A:004B X:0016 Y:0000 P:eNvMxdizc - Jump to 03D783.
----------------------------------------------------------------------------------------------------------------------------
$03/D715 A5 CE LDA $CE    [$00:00CE] A:0012 X:0016 Y:FFFF P:envMxdiZC - Load ?Character ID? into A.
$03/D717 10 03 BPL $03    [$D71C] A:0001 X:0016 Y:FFFF P:envMxdizC - Branch if less than 80 (being used by a PC)
----------------------------------------------------------------------------------------------------------------------------------

-------------------------------------------------------------------------------------------------------------------------------------
$03/D71C AA TAX A:0001 X:0016 Y:FFFF P:envMxdizC - Transfer A to X.
$03/D71D 9E 60 35 STZ $3560,x[$7E:3561] A:0001 X:0001 Y:FFFF P:envMxdizC - Store Zero in 7E3560+X.
$03/D720 AD 03 27 LDA $2703  [$7E:2703] A:0001 X:0001 Y:FFFF P:envMxdizC - Load Target's Status Byte 1.
$03/D723 85 A9 STA $A9    [$00:00A9] A:0000 X:0001 Y:FFFF P:envMxdiZC - Store A in A9.
$03/D725 29 80 AND #$80 A:0000 X:0001 Y:FFFF P:envMxdiZC - Add 80 (thus getting rid of all ailments Except Death)
$03/D727 8D 03 27 STA $2703  [$7E:2703] A:0000 X:0001 Y:FFFF P:envMxdiZC - Store A in Target's Status Byte 1.
$03/D72A AD 04 27 LDA $2704  [$7E:2704] A:0000 X:0001 Y:FFFF P:envMxdiZC - Load Target's Status Byte 2.
$03/D72D 85 AA STA $AA    [$00:00AA] A:0008 X:0001 Y:FFFF P:envMxdizC - Store A in AA.
$03/D72F 29 44 AND #$44 A:0008 X:0001 Y:FFFF P:envMxdizC - Get rid of Calcification, Petrify,Charm, Sleep, Paralyze and Curse)
$03/D731 8D 04 27 STA $2704  [$7E:2704] A:0000 X:0001 Y:FFFF P:envMxdiZC -Store A in Target's Status Byte 2.
$03/D734 A9 10 LDA #$10 A:0000 X:0001 Y:FFFF P:envMxdiZC - Load 10 into A.
$03/D736 8D 3B 27 STA $273B  [$7E:273B] A:0010 X:0001 Y:FFFF P:envMxdizC - Store 7E273B into A. (Resets Speed? I had no idea that Heal actually reset speed! It does! That means Heal could actually work against you if you hasted this unit previously. Interesting...)
$03/D739 A5 CF LDA $CF    [$00:00CF] A:0010 X:0001 Y:FFFF P:envMxdizC - Load the value in CF into A.
$03/D73B 0A ASL A A:0001 X:0001 Y:FFFF P:envMxdizC - x2 A.
$03/D73C AA TAX A:0002 X:0001 Y:FFFF P:envMxdizc - Transfer A to X.
$03/D73D BD EB 29 LDA $29EB,x[$7E:29ED] A:0002 X:0002 Y:FFFF P:envMxdizc - Load Bitmask of Status.
$03/D740 29 E6 AND #$E6 A:0040 X:0002 Y:FFFF P:envMxdizc - ??
$03/D742 9D EB 29 STA $29EB,x[$7E:29ED] A:0040 X:0002 Y:FFFF P:envMxdizc - Store A in  Bitmask of Status.
$03/D745 A5 A9 LDA $A9    [$00:00A9] A:0040 X:0002 Y:FFFF P:envMxdizc - Load A from A9.
$03/D747 29 40 AND #$40 A:0000 X:0002 Y:FFFF P:envMxdiZc - Ignore Stop Timer?
$03/D749 D0 08 BNE $08    [$D753] A:0000 X:0002 Y:FFFF P:envMxdiZc - Branch if not 00 to 03D753.
$03/D74B A5 AA LDA $AA    [$00:00AA] A:0000 X:0002 Y:FFFF P:envMxdiZc - Load A from AA.
$03/D74D 29 30 AND #$30 A:0008 X:0002 Y:FFFF P:envMxdizc - ??
$03/D74F F0 1D BEQ $1D    [$D76E] A:0000 X:0002 Y:FFFF P:envMxdiZc - Branch if 00 to 03D76E
-------------------------------------------------------------------------------------------------------------------

---------------------------------------------------------------------------------------------------------------------
$03/D76E A5 A9 LDA $A9    [$00:00A9] A:0000 X:0002 Y:FFFF P:envMxdiZc - Load A from A9.
$03/D770 29 08 AND #$08 A:0000 X:0002 Y:FFFF P:envMxdiZc - ??
$03/D772 F0 0E BEQ $0E    [$D782] A:0000 X:0002 Y:FFFF P:envMxdiZc - If 00 branch to 03D782
-----------------------------------------------------------------------------------

---------------------------------------------------------------------------------------
$03/D782 60 RTS A:0000 X:0002 Y:FFFF P:envMxdiZc - Return.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
(Accessed only by Status Healing that is not the Heal Spells)
$03/D783 AD 03 27 LDA $2703  [$7E:2703] A:004B X:0016 Y:0000 P:eNvMxdizc - Load Target's Status Byte 1.
$03/D786 85 8A STA $8A    [$00:008A] A:0000 X:0016 Y:0000 P:envMxdiZc - Store A in 8A.
$03/D788 2D A3 28 AND $28A3  [$7E:28A3] A:0000 X:0016 Y:0000 P:envMxdiZc - Add the value from Skill's Status Byte 1 onto A, if applicable.
$03/D78B 8D 03 27 STA $2703  [$7E:2703] A:0000 X:0016 Y:0000 P:envMxdiZc - Store A in Target's Status Byte 1.
$03/D78E AD 04 27 LDA $2704  [$7E:2704] A:0000 X:0016 Y:0000 P:envMxdiZc - Load Target's Status Byte 2 onto A.
$03/D791 85 8B STA $8B    [$00:008B] A:0000 X:0016 Y:0000 P:envMxdiZc - Store A in 8B.
$03/D793 2D A4 28 AND $28A4  [$7E:28A4] A:0000 X:0016 Y:0000 P:envMxdiZc - Add the value from Skill's Status Byte 2 onto A, if applicable.
$03/D796 8D 04 27 STA $2704  [$7E:2704] A:0000 X:0016 Y:0000 P:envMxdiZc - Store A in Target's Status Byte 2.
$03/D799 AD A3 28 LDA $28A3  [$7E:28A3] A:0000 X:0016 Y:0000 P:envMxdiZc - Load value from Skill's Status 1 into A.
$03/D79C 49 FF EOR #$FF A:00FE X:0016 Y:0000 P:eNvMxdizc - Exclusive Or onto A.
$03/D79E 85 8C STA $8C    [$00:008C] A:0001 X:0016 Y:0000 P:envMxdizc - Store A in 8C.
$03/D7A0 AD A4 28 LDA $28A4  [$7E:28A4] A:0001 X:0016 Y:0000 P:envMxdizc - Load A from 7E28A4.
$03/D7A3 49 FF EOR #$FF A:00FF X:0016 Y:0000 P:eNvMxdizc - Exclusive Or onto A.
$03/D7A5 85 8D STA $8D    [$00:008D] A:0000 X:0016 Y:0000 P:envMxdiZc - Store A in 8D
$03/D7A7 A5 8A LDA $8A    [$00:008A] A:0000 X:0016 Y:0000 P:envMxdiZc - Load A from 8A.
$03/D7A9 29 01 AND #$01 A:0000 X:0016 Y:0000 P:envMxdiZc - Erase all but Poison
$03/D7AB F0 12 BEQ $12    [$D7BF] A:0000 X:0016 Y:0000 P:envMxdiZc - If 00 branch to 03D7BF.
--------------------------------------------------------------------------------------------------------------------------
$03/D7AD A5 8C LDA $8C    [$00:008C] A:0001 X:0016 Y:0000 P:envMxdizc - Load A from 8C.
$03/D7AF 29 01 AND #$01 A:0001 X:0016 Y:0000 P:envMxdizc - Erase all but Poison.
$03/D7B1 F0 0C BEQ $0C    [$D7BF] A:0001 X:0016 Y:0000 P:envMxdizc - Branch if 00 to 03D7BF.
$03/D7B3 A5 CF LDA $CF    [$00:00CF] A:0001 X:0016 Y:0000 P:envMxdizc - Load A from CF.
$03/D7B5 0A ASL A A:0000 X:0016 Y:0000 P:envMxdiZc - x2 A.
$03/D7B6 AA TAX A:0000 X:0016 Y:0000 P:envMxdiZc - Transfer A to X.
$03/D7B7 BD EB 29 LDA $29EB,x[$7E:29EB] A:0000 X:0000 Y:0000 P:envMxdiZc - Load A from Bitmask of Status.
$03/D7BA 29 EF AND #$EF A:0050 X:0000 Y:0000 P:envMxdizc - Place-10 to it.
$03/D7BC 9D EB 29 STA $29EB,x[$7E:29EB] A:0040 X:0000 Y:0000 P:envMxdizc - Store A in Bitmask of Status.
----------------------------------------------------------------------------------------------------------------------------
$03/D7BF A5 8A LDA $8A    [$00:008A] A:0000 X:0016 Y:0000 P:envMxdiZc - Load A from 8A.
$03/D7C1 29 40 AND #$40 A:0000 X:0016 Y:0000 P:envMxdiZc - Erase all but Stone.
$03/D7C3 F0 11 BEQ $11    [$D7D6] A:0000 X:0016 Y:0000 P:envMxdiZc - Branch if 00 to 03D7D6.
--------------------------------------------------------------------------------------------------------------------------------

---------------------------------------------------------------------------------------------------------------------------------
$03/D7D6 A5 8B LDA $8B    [$00:008B] A:0000 X:0016 Y:0000 P:envMxdiZc - Load A from 8B.
$03/D7D8 29 30 AND #$30 A:0000 X:0016 Y:0000 P:envMxdiZc - Erase all but Sleep and Paralyze.
$03/D7DA F0 15 BEQ $15    [$D7F1] A:0000 X:0016 Y:0000 P:envMxdiZc - Branch if 00 to 03D7F1.
------------------------------------------------------------------------------------------------------------------------------------

-------------------------------------------------------------------------------------------------------------------------------------
$03/D7F1 A5 8B LDA $8B    [$00:008B] A:0000 X:0016 Y:0000 P:envMxdiZc - Load A from 8B.
$03/D7F3 29 08 AND #$08 A:0000 X:0016 Y:0000 P:envMxdiZc - Erase all but Charm.
$03/D7F5 F0 1A BEQ $1A    [$D811] A:0000 X:0016 Y:0000 P:envMxdiZc - Branch if 00 to 03D811.
--------------------------------------------------------------------------------------------------------------------------------------

--------------------------------------------------------------------------------------------------------------------------------------
$03/D811 A5 8B LDA $8B    [$00:008B] A:0000 X:0016 Y:0000 P:envMxdiZc - Load A from 8B.
$03/D813 29 03 AND #$03 A:0000 X:0016 Y:0000 P:envMxdiZc - Erase all but Calcify and Petrify.
$03/D815 F0 12 BEQ $12    [$D829] A:0000 X:0016 Y:0000 P:envMxdiZc - Branch if 00 to 03D829.
-----------------------------------------------------------------------------------------------------------------------------------------

-------------------------------------------------------------------------------------------------------------------------------------------
$03/D829 60 RTS A:0000 X:0016 Y:0000 P:envMxdiZc





There's a few things I simply don't have the knowledge to access or fathom their purpose. That said this was informative. I at least learned that Heal resets Speed. This means that you could potentially use that against Cagnazzo when he uses Haste.

Come to think of it, I guess it was always a given that Heal was special, considering it has nothing in its information for its actual spell. Well that solves that ?mystery?.

 :edit: Generic healing spells and healing items go through a completely different process as labeled above. The stuff at the end likely relates to timers, I'd imagine.
« Last Edit: January 04, 2014, 02:10:30 PM by Grimoire LD »

LordGarmonde

  • Baigan
  • *
  • Posts: 271
  • Gender: Male
  • "Power only breeds war..."
    • View Profile
Re: Grimoire LD's Notes, Methods, and Hacks (FFI spell routines in FFIV!)
« Reply #174 on: January 04, 2014, 02:56:20 PM »
Nice - that's a good find! You =  :cycle:

Also - Healing Cagnazzo to slow him down - I'm laughing picturing that - if I do that I want him to have a battle message of  :wtf:
"Now I know; and knowing makes it even more confusing..."

Grimoire LD

  • FF4 Hacker
  • *
  • Posts: 1,684
    • View Profile
Re: Grimoire LD's Notes, Methods, and Hacks (FFI spell routines in FFIV!)
« Reply #175 on: January 04, 2014, 06:31:55 PM »
Here's some information on entering battle and levels...

Ally Level Calculations

Code: [Select]
$03/8C99 B9 40 35 LDA $3540,y[$7E:3541] A:0000 X:0080 Y:0001 P:eNvMxdIzc - Load 7E3540 into A.
$03/8C9C D0 10 BNE $10    [$8CAE] A:0000 X:0080 Y:0001 P:envMxdIZc - If not 00 Branch to 038CAE.
$03/8C9E 18 CLC A:0000 X:0080 Y:0001 P:envMxdIZc - Clear Carry Flag.
$03/8C9F BD 02 20 LDA $2002,x[$7E:2082] A:0000 X:0080 Y:0001 P:envMxdIZc - Load Character's Level into A.
$03/8CA2 65 A9 ADC $A9    [$00:00A9] A:000A X:0080 Y:0001 P:envMxdIzc - Add it to A9 (where the other character's levels are added up)
$03/8CA4 85 A9 STA $A9    [$00:00A9] A:0014 X:0080 Y:0001 P:envMxdIzc - Store A in A9.
$03/8CA6 A9 00 LDA #$00 A:0014 X:0080 Y:0001 P:envMxdIzc - Load 00 into A.
$03/8CA8 65 AA ADC $AA    [$00:00AA] A:0000 X:0080 Y:0001 P:envMxdIZc - Add ?00? into AA.
$03/8CAA 85 AA STA $AA    [$00:00AA] A:0000 X:0080 Y:0001 P:envMxdIZc - Store A in AA.
$03/8CAC E6 AD INC $AD    [$00:00AD] A:0000 X:0080 Y:0001 P:envMxdIZc - +1 to AD.
$03/8CAE 20 BC 85 JSR $85BC  [$03:85BC] A:0000 X:0080 Y:0001 P:envMxdIzc - Jump to Subroutine 0385BC
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~```
$03/85BC C2 20 REP #$20 A:0000 X:0080 Y:0001 P:envMxdIzc - Reset Processor Status
$03/85BE 8A TXA A:0000 X:0080 Y:0001 P:envmxdIzc - Transfer X to A.
$03/85BF 18 CLC A:0080 X:0080 Y:0001 P:envmxdIzc - Clear Carry Flag.
$03/85C0 69 80 00 ADC #$0080 A:0080 X:0080 Y:0001 P:envmxdIzc - Add 80 to A.
$03/85C3 AA TAX A:0100 X:0080 Y:0001 P:envmxdIzc - Transfer A to X.
$03/85C4 7B TDC A:0100 X:0100 Y:0001 P:envmxdIzc - Transfer Direct Page.
$03/85C5 E2 20 SEP #$20 A:0000 X:0100 Y:0001 P:envmxdIZc - Set Processor Status to 2 Bytes.
$03/85C7 60 RTS A:0000 X:0100 Y:0001 P:envMxdIZc - Return
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
$03/8CB1 C8 INY A:0000 X:0100 Y:0001 P:envMxdIZc - +1 to Y.
$03/8CB2 C0 05 00 CPY #$0005 A:0000 X:0100 Y:0002 P:envMxdIzc - Has it checked all five slots?
$03/8CB5 D0 E2 BNE $E2    [$8C99] A:0000 X:0100 Y:0002 P:eNvMxdIzc - If not loop back to 038C99
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Monster Level Calculation

Code: [Select]
$03/8CB7 B9 40 35 LDA $3540,y[$7E:3545] A:0000 X:0280 Y:0005 P:envMxdIZC - Load 7E3545 into A.
$03/8CBA D0 10 BNE $10    [$8CCC] A:0000 X:0280 Y:0005 P:envMxdIZC - Branch if not 00 to 038CCC.
$03/8CBC 18 CLC A:0000 X:0280 Y:0005 P:envMxdIZC - Clear Carry Flag.
$03/8CBD BD 02 20 LDA $2002,x[$7E:2282] A:0000 X:0280 Y:0005 P:envMxdIZc - Load Monster Level into A.
$03/8CC0 65 AB ADC $AB    [$00:00AB] A:0005 X:0280 Y:0005 P:envMxdIzc - Add this value to AB.
$03/8CC2 85 AB STA $AB    [$00:00AB] A:0005 X:0280 Y:0005 P:envMxdIzc - Store A in AB.
$03/8CC4 A9 00 LDA #$00 A:0005 X:0280 Y:0005 P:envMxdIzc - Load 00 into A.
$03/8CC6 65 AC ADC $AC    [$00:00AC] A:0000 X:0280 Y:0005 P:envMxdIZc - Add this to AC.
$03/8CC8 85 AC STA $AC    [$00:00AC] A:0000 X:0280 Y:0005 P:envMxdIZc - Store A in AC.
$03/8CCA E6 AE INC $AE    [$00:00AE] A:0000 X:0280 Y:0005 P:envMxdIZc - +1 to AE.
$03/8CCC 20 BC 85 JSR $85BC  [$03:85BC] A:0000 X:0280 Y:0005 P:envMxdIzc - Jump to Subroutine (above)
$03/8CCF C8 INY A:0000 X:0300 Y:0005 P:envMxdIZc - +1 to Y.
$03/8CD0 C0 08 00 CPY #$0008 A:0000 X:0300 Y:0006 P:envMxdIzc - Has it looked at all Eight Monster Slots?
$03/8CD3 D0 E2 BNE $E2    [$8CB7] A:0000 X:0300 Y:0006 P:eNvMxdIzc - If not branch back to 038CB7

For some reason Ally Levels are rolled over 10 times...
Code: [Select]
$03/8CD5 A6 A9 LDX $A9    [$00:00A9] A:0000 X:0400 Y:0008 P:envMxdIZC - Load X from Ally's Accumulated Levels.
$03/8CD7 8E 45 39 STX $3945  [$7E:3945] A:0000 X:001E Y:0008 P:envMxdIzC - Store X in 7E3945.
$03/8CDA A5 AD LDA $AD    [$00:00AD] A:0000 X:001E Y:0008 P:envMxdIzC - Load A from Amount of Characters.
$03/8CDC AA TAX A:0003 X:001E Y:0008 P:envMxdIzC - Transfer A to X.
$03/8CDD 8E 47 39 STX $3947  [$7E:3947] A:0003 X:0003 Y:0008 P:envMxdIzC - Store X in 7E3947.
$03/8CE0 20 07 84 JSR $8407  [$03:8407] A:0003 X:0003 Y:0008 P:envMxdIzC - Jump to Subroutine
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
$03/8407 C2 20 REP #$20 A:0003 X:0003 Y:0008 P:envMxdIzC - Reset Processor Status
$03/8409 9C 49 39 STZ $3949  [$7E:3949] A:0003 X:0003 Y:0008 P:envmxdIzC - Store Zero in 7E3949.
$03/840C 9C 4B 39 STZ $394B  [$7E:394B] A:0003 X:0003 Y:0008 P:envmxdIzC - Store Zero in 7E394B.
$03/840F AD 45 39 LDA $3945  [$7E:3945] A:0003 X:0003 Y:0008 P:envmxdIzC - Load Accumulated Ally Levels into A.
$03/8412 F0 2B BEQ $2B    [$843F] A:001E X:0003 Y:0008 P:envmxdIzC - Branch if 00 (Wha...?) to 03843F.
$03/8414 AD 47 39 LDA $3947  [$7E:3947] A:001E X:0003 Y:0008 P:envmxdIzC - Load Amount of Allies into A.
$03/8417 F0 26 BEQ $26    [$843F] A:0003 X:0003 Y:0008 P:envmxdIzC - Branch if 00 (Sigh...) to 03843F.
$03/8419 18 CLC A:0003 X:0003 Y:0008 P:envmxdIzC - Clear Carry Flag.
$03/841A A2 10 00 LDX #$0010 A:0003 X:0003 Y:0008 P:envmxdIzc - Load 10 into X.
--------------------------------------------------------------(Looping Point)---------------------------------------------------
$03/841D 2E 45 39 ROL $3945  [$7E:3945] A:0003 X:0010 Y:0008 P:envmxdIzc - x2 Ally Levels.
$03/8420 2E 4B 39 ROL $394B  [$7E:394B] A:0003 X:0010 Y:0008 P:envmxdIzc - x2
$03/8423 38 SEC A:0003 X:0010 Y:0008 P:envmxdIZc - Set Carry Flag.
$03/8424 AD 4B 39 LDA $394B  [$7E:394B] A:0003 X:0010 Y:0008 P:envmxdIZC - Load A from 7E394B.
$03/8427 ED 47 39 SBC $3947  [$7E:3947] A:0000 X:0010 Y:0008 P:envmxdIZC - Subtract Amount of Characters from 7E3947.
$03/842A 8D 4B 39 STA $394B  [$7E:394B] A:FFFD X:0010 Y:0008 P:eNvmxdIzc - Store A in 7E394B.
$03/842D B0 0A BCS $0A    [$8439] A:FFFD X:0010 Y:0008 P:eNvmxdIzc - Branch if More than 00 to 038439.
$03/842F AD 4B 39 LDA $394B  [$7E:394B] A:FFFD X:0010 Y:0008 P:eNvmxdIzc - Load 7E394B into A.
$03/8432 6D 47 39 ADC $3947  [$7E:3947] A:FFFD X:0010 Y:0008 P:eNvmxdIzc - Add the value in 7E3947 onto A.
$03/8435 8D 4B 39 STA $394B  [$7E:394B] A:0000 X:0010 Y:0008 P:envmxdIZC - Store A in 7E394B.
$03/8438 18 CLC A:0000 X:0010 Y:0008 P:envmxdIZC - Clear Carry Flag.
$03/8439 2E 49 39 ROL $3949  [$7E:3949] A:0000 X:0010 Y:0008 P:envmxdIZc - x2 the value in 7E3949 (which is currently 0)
$03/843C CA DEX A:0000 X:0010 Y:0008 P:envmxdIZc - -1 from .
$03/843D D0 DE BNE $DE    [$841D] A:0000 X:000F Y:0008 P:envmxdIzc - Branch if... ?Not 00? (likely using X as a base) to 03841D.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~`````
$03/843F 7B TDC A:0000 X:0000 Y:0008 P:envmxdIZc - Transfer Direct Page.
$03/8440 E2 20 SEP #$20 A:0000 X:0000 Y:0008 P:envmxdIZc - Set Processor Status.
$03/8442 60 RTS A:0000 X:0000 Y:0008 P:envMxdIZc - Return
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
$03/8CE3 AE 49 39 LDX $3949  [$7E:3949] A:0000 X:0000 Y:0008 P:envMxdIZc - Load Final Value (0A) from Median into X.
$03/8CE6 8A TXA A:0000 X:000A Y:0008 P:envMxdIzc - Transfer X to A.
$03/8CE7 8D D4 38 STA $38D4  [$7E:38D4] A:000A X:000A Y:0008 P:envMxdIzc - Store Median Ally Level in 7E38D4.
$03/8CEA 7B TDC A:000A X:000A Y:0008 P:envMxdIzc - Transfer Direct Page.
$03/8CEB A6 AB LDX $AB    [$00:00AB] A:0000 X:000A Y:0008 P:envMxdIZc - Load Accumulated Enemy Levels.
$03/8CED 8E 45 39 STX $3945  [$7E:3945] A:0000 X:000F Y:0008 P:envMxdIzc - Store X in 7E3945.
$03/8CF0 A5 AE LDA $AE    [$00:00AE] A:0000 X:000F Y:0008 P:envMxdIzc - Load Accumulated amount of enemies.
$03/8CF2 AA TAX A:0003 X:000F Y:0008 P:envMxdIzc - Transfer A to X.
$03/8CF3 8E 47 39 STX $3947  [$7E:3947] A:0003 X:0003 Y:0008 P:envMxdIzc - Store X in 7E3947.
$03/8CF6 20 07 84 JSR $8407  [$03:8407] A:0003 X:0003 Y:0008 P:envMxdIzc - Jump to Subroutine (same one as above.)

Median Ally /Enemy Level vs. RNG
Code: [Select]
$03/8CF9 AE 49 39 LDX $3949  [$7E:3949] A:0000 X:0000 Y:0008 P:envMxdIZc - Load X from Median Enemy Level.
$03/8CFC 8A TXA A:0000 X:0005 Y:0008 P:envMxdIzc - Transfer X to A.
$03/8CFD 8D D5 38 STA $38D5  [$7E:38D5] A:0005 X:0005 Y:0008 P:envMxdIzc - Store Median Enemy Level in 7E38D5,
$03/8D00 7B TDC A:0005 X:0005 Y:0008 P:envMxdIzc - Transfer Direct Page.
$03/8D01 7B TDC A:0000 X:0005 Y:0008 P:envMxdIZc - Transfer Direct Page (Coding Error?)
$03/8D02 AA TAX A:0000 X:0005 Y:0008 P:envMxdIZc - Transfer A to X.
$03/8D03 86 A9 STX $A9    [$00:00A9] A:0000 X:0000 Y:0008 P:envMxdIZc - Store Enemy Median Level into A9.
$03/8D05 E6 A9 INC $A9    [$00:00A9] A:0000 X:0000 Y:0008 P:envMxdIZc - +1 to A9,
$03/8D07 E6 AA INC $AA    [$00:00AA] A:0000 X:0000 Y:0008 P:envMxdIzc - +1 to AA
$03/8D09 A9 63 LDA #$63 A:0000 X:0000 Y:0008 P:envMxdIzc - Load 63 (100) into A.
$03/8D0B 20 79 83 JSR $8379  [$03:8379] A:0063 X:0000 Y:0008 P:envMxdIzc - Load 100 into Random Number Generator.
$03/8D0ECD D4 38 CMP $38D4  [$7E:38D4] A:0014 X:0000 Y:0008 P:envMxdIzc - Compare Random Number to Median Ally Level.
$03/8D11 B0 02 BCS $02    [$8D15] A:0014 X:0000 Y:0008 P:envMxdIzC - If less than Random Number branch to 038D15.
---------------------------------------------------------------------------------------------------------------------------------------------------------------
$03/8D13 E6 A9 INC $A9    [$00:00A9] A:0007 X:0000 Y:0008 P:eNvMxdIzc +1 to A9.
-----------------------------------------------------------------------------------------------------------------------------------------------------------------
$03/8D15 20 8B 85 JSR $858B  [$03:858B] A:0014 X:0000 Y:0008 P:envMxdIzC - Jump to a Different Random Number Generator
$03/8D18 CD D5 38 CMP $38D5  [$7E:38D5] A:0057 X:0000 Y:0008 P:envMxdIzc - Compare Random Number to Median Enemy Level.
$03/8D1B B0 02 BCS $02    [$8D1F] A:0057 X:0000 Y:0008 P:envMxdIzC - If less than Random Number branch to 038D1F
-------------------------------------------------------------------------------------------------------------------------------------------------------------------
$03/8D1D E6 AA INC $AA    [$00:00AA] A:0051 X:0000 Y:0008 P:eNvMxdIzc - +1 to AA.
--------------------------------------------------------------------------------------------------------------------------------------------------------------
$03/8D1F A5 A9 LDA $A9    [$00:00A9] A:0057 X:0000 Y:0008 P:envMxdIzC - Load A9 into A. (which it won't be 01 if the Ally RNG check succeeded)
$03/8D21 C5 AA CMP $AA    [$00:00AA] A:0001 X:0000 Y:0008 P:envMxdIzC - Compare it to AA.
$03/8D23 F0 29 BEQ $29    [$8D4E] A:0001 X:0000 Y:0008 P:envMxdIZC - If they equal branch to 038D4E.
---------------------------------------------------------------------------------------------------------------------------------
(Ally Success)
$03/8D25 90 08 BCC $08    [$8D2F] A:0002 X:0000 Y:0008 P:envMxdIzC - If 00 branch to 038D2F (I can't see how it could be 00...)
$03/8D27 EE D7 38 INC $38D7  [$7E:38D7] A:0002 X:0000 Y:0008 P:envMxdIzC - +1 to 7E38D7 (When these two are both 01, they cause First Strikes)
$03/8D2A EE D8 38 INC $38D8  [$7E:38D8] A:0002 X:0000 Y:0008 P:envMxdIzC - +1 to 7E38D8
$03/8D2D 80 1F BRA $1F    [$8D4E] A:0002 X:0000 Y:0008 P:envMxdIzC - Branch always to 038D4E.
------------------------------------------------------------------------------------------------------------------------------------------------
(Monster Success)
$03/8D2F A9 80 LDA #$80 A:0001 X:0000 Y:0008 P:eNvMxdIzc - Load 80 into A
$03/8D31 8D D7 38 STA $38D7  [$7E:38D7] A:0080 X:0000 Y:0008 P:eNvMxdIzc - Store A in 7E38D7. (Causes Ambush)
$03/8D34 8D D8 38 STA $38D8  [$7E:38D8] A:0080 X:0000 Y:0008 P:eNvMxdIzc - Store A in 7E38D8.
$03/8D37 AD D5 38 LDA $38D5  [$7E:38D5] A:0080 X:0000 Y:0008 P:eNvMxdIzc - Load A from 7E38D5.
$03/8D3A 4A LSR A A:0063 X:0000 Y:0008 P:envMxdIzc - Divide it by 2.
$03/8D3B 85 A9 STA $A9    [$00:00A9] A:0031 X:0000 Y:0008 P:envMxdIzC - Store A in A9.
$03/8D3D 7B TDC A:0031 X:0000 Y:0008 P:envMxdIzC - Transfer Direct Page.
$03/8D3E AA TAX A:0000 X:0000 Y:0008 P:envMxdIZC - Transfer A to X.
$03/8D3F AD D4 38 LDA $38D4  [$7E:38D4] A:0000 X:0000 Y:0008 P:envMxdIZC - Load Median Ally Level into A.
$03/8D42 20 79 83 JSR $8379  [$03:8379] A:000A X:0000 Y:0008 P:envMxdIzC - Jump to Random Number Generator. (0-Party Level)
$03/8D45 C5 A9 CMP $A9    [$00:00A9] A:0000 X:0000 Y:0008 P:envMxdIzc - Is it less than Enemy Level/2?
$03/8D47 B0 05 BCS $05    [$8D4E] A:0000 X:0000 Y:0008 P:eNvMxdIzc - If so branch to 038D4E.
$03/8D49 A9 08 LDA #$08 A:0000 X:0000 Y:0008 P:eNvMxdIzc - Load 08 into A.
$03/8D4B 8D 81 35 STA $3581  [$7E:3581] A:0008 X:0000 Y:0008 P:envMxdIzc - Store A in 7E35811 (Back Attack)
---------------------------------------------------------------------------------------------------------------------------------------
$03/8D4E 7B TDC A:0001 X:0000 Y:0008 P:envMxdIZC - Transfer Direct Page
$03/8D4F AA TAX A:0000 X:0000 Y:0008 P:envMxdIZC - Transfer A to X.
$03/8D50 A8 TAY A:0000 X:0000 Y:0008 P:envMxdIZC - Transfer A to Y.
$03/8D51 86 C7 STX $C7    [$00:00C7] A:0000 X:0000 Y:0000 P:envMxdIZC - Store X in C7.
$03/8D53 B9 40 35 LDA $3540,y[$7E:3540] A:0000 X:0000 Y:0000 P:envMxdIZC - Load A from 7E3540.
$03/8D56 D0 11 BNE $11    [$8D69] A:0000 X:0000 Y:0000 P:envMxdIZC - If not 00 branch to 038D69.
$03/8D58 A5 C7 LDA $C7    [$00:00C7] A:0000 X:0000 Y:0000 P:envMxdIZC - Load A from C7.
$03/8D5A D0 28 BNE $28    [$8D84] A:0000 X:0000 Y:0000 P:envMxdIZC - Branch if Not 00 to 038D84.
$03/8D5C BD 00 20 LDA $2000,x[$7E:2000] A:0000 X:0000 Y:0000 P:envMxdIZC - Load Character ID into A.
$03/8D5F 29 1F AND #$1F A:0081 X:0000 Y:0000 P:eNvMxdIzC - Get rid of 80.
$03/8D61 C9 20 CMP #$20 A:0001 X:0000 Y:0000 P:envMxdIzC - Is it 20? (Invalid, Normally Dark Knight Cecil)
$03/8D63 F0 1F BEQ $1F    [$8D84] A:0001 X:0000 Y:0000 P:eNvMxdIzc - If so branch to 038D84.
$03/8D65 C9 01 CMP #$01 A:0001 X:0000 Y:0000 P:eNvMxdIzc - Is it Dark Knight Cecil (Normally Paladin)
$03/8D67 F0 18 BEQ $18    [$8D81] A:0001 X:0000 Y:0000 P:envMxdIZC - If so branch to 038D81.
-------------------------------------------------------------------------------------------------------------------------------------------------
(I have left new areas an am back in the area that makes Cover work that means this is done.)

And there we go! Judging by this data the higher your level is the more likely you are to get a First strike, and vice versa with enemies. The enemy level is never directly confronted by the ally level, but both are put into RNG's of 1-100. If the Player succeeds they get a First Strike. If the Enemy succeeds they get an Ambush, then the Party Level is put as the limit in an RNG vs. the Enemy Level/2 and should the Enemy Level still be higher, a Back Attack occurs.

Now that was quite a fun little trip! And another piece of the puzzle solved!






LordGarmonde

  • Baigan
  • *
  • Posts: 271
  • Gender: Male
  • "Power only breeds war..."
    • View Profile
Re: Grimoire LD's Notes, Methods, and Hacks (Back Attacks/First Strike Info!)
« Reply #176 on: January 04, 2014, 06:41:05 PM »
YES! You rock so hard dude!  :banonsmash:

Also - I layed out the general terms of my plan...I'll write it up in a step-by step this evening/tomorrow...but it's a long post, don't go unless you're ready for battle. - lol

But what you've got here...  :childish:
"Now I know; and knowing makes it even more confusing..."

LordGarmonde

  • Baigan
  • *
  • Posts: 271
  • Gender: Male
  • "Power only breeds war..."
    • View Profile
Re: Grimoire LD's Notes, Methods, and Hacks (Back Attacks/First Strike Info!)
« Reply #177 on: January 04, 2014, 11:50:05 PM »
Found it. Aim is programmed in a way which makes it Very difficult to change without significantly modifying its code. This is how it works... It starts out as a 0000 Accumulator. Then it is Decremented once. Resetting it to FF. And there you have it. That's how the game gets the FF. Maybe taking a further look at the data will show me a solution, hmm...

I just caught that post in my crusing around the forum - what are your feelings on that as a method? Is it something that in my mind I should keep as a good tool, or don't do it unless you have to. A couple other noob Assembly questions I have are with the method above, what happens to all the flags, do any of them reset? My other question is why do this at all - is it really that much faster as opposed to reading it from somewhere, or just assigning it as a constant...I'm definitely missing something I think...

Maybe it's sleep  :sleep:   - lol
"Now I know; and knowing makes it even more confusing..."

Grimoire LD

  • FF4 Hacker
  • *
  • Posts: 1,684
    • View Profile
Re: Grimoire LD's Notes, Methods, and Hacks (Back Attacks/First Strike Info!)
« Reply #178 on: January 05, 2014, 01:35:39 AM »
I don't like how its used here because it cuts down on what you can logically do with the instruction. As a tool to set things to FFFF it saves one or two bytes and those bytes may be quite precious in the long run.

However... http://slickproductions.org/forum/index.php?topic=1883.msg19351#msg19351

I eventually got around it and took control of Aim to make it work for me the way I desired. (at least somewhat. I would still rather have Barrage, but this is nice as well)

What annoys me now most about their Aim command, is that its extremely haphazard. There is a specific byte that controls whether an attack Can miss or not, all they technically had to do was trigger that byte. But hey, more space to play around with I suppose.

Code: [Select]
$03/E836 AD 9C 26 LDA $269C  [$7E:269C] A:0003 X:0018 Y:0000 P:envMxdizc - Load Caster's Physical Attack Percent.
$03/E839 48 PHA A:0034 X:0018 Y:0000 P:envMxdizc - Push A.
$03/E83A AD 29 27 LDA $2729  [$7E:2729] A:0034 X:0018 Y:0000 P:envMxdizc - Load Enemies (Non-existent) Evasion.
$03/E83D 48 PHA A:0000 X:0018 Y:0000 P:envMxdiZc - Push A.
$03/E83E 7B TDC A:0000 X:0018 Y:0000 P:envMxdiZc - Transfer Direct Page (thereby making it 00)
$03/E83F 8D 29 27 STA $2729  [$7E:2729] A:0000 X:0018 Y:0000 P:envMxdiZc - Store 00 in Target's Evasion.
$03/E842 3A DEC A A:0000 X:0018 Y:0000 P:envMxdiZc -1 to A.
$03/E843 8D 9C 26 STA $269C  [$7E:269C] A:00FF X:0018 Y:0000 P:eNvMxdizc - Store A  (FF - 255%) into Physical Attack Percent.

They didn't use it correctly, they wasted bytes, and they screwed up their intention. Aim might be the worst programmed Command in the game due to inefficiency on their part.

When a routine is left Completely, the game will ordinarily enter a "cleaning" routine. A very long, very boring process of code, indeed. In this there are no bytes being triggered. Assiging FF as a constant would have been A9 FF, rather than just 3A. In this case it saved one byte... and wasted so many others...

Grimoire LD

  • FF4 Hacker
  • *
  • Posts: 1,684
    • View Profile
Re: Grimoire LD's Notes, Methods, and Hacks (Back Attacks/First Strike Info!)
« Reply #179 on: January 05, 2014, 02:24:39 PM »
Wow... Barrage (FFIII DS, FFT:War of the Lions) was a Stupidly easy thing to program in the end... at least in a basic form...

Because of space limitations I decided to call it (Arrow Symbol)Strm (Arrow Storm) after a tactic common to the Romance of the Three Kingdoms series.

Code: [Select]
$03/E836 20 99 C4 JSR $C499  [$03:C499] A:0003 X:0018 Y:0000 P:envMxdizc - Fight Routine x4
$03/E839 20 99 C4 JSR $C499  [$03:C499] A:0000 X:750E Y:0018 P:envMxdiZC
$03/E83C 20 99 C4 JSR $C499  [$03:C499] A:0000 X:750E Y:0018 P:envMxdiZC
$03/E83F 20 99 C4 JSR $C499  [$03:C499] A:0000 X:750E Y:0018 P:envMxdiZC
$03/E842 60 RTS A:0000 X:750E Y:0018 P:envMxdiZC - Return
Yes, four normal attacks. I honestly thought this was going to cause an overflow problem with the arrows, but to my amazement the game Properly decrements them without overflowing. (And if used with less than 3 Arrows you will no longer have any arrows) And as you'd expect it deals x4 Damage (though without my Infinite Arrow-Glitch fix it still has that problem as you'd expect.)


Now, these all add up properly, but there's still two pieces I'm missing. This first is how to divide the damage by 2. I may need to look back at the original Aim Command for guidance... Specifically at...

$03/E836   AD 9C 26   LDA $269C  [$7E:269C]   A:0003   X:0018   Y:0000   P:envMxdizc - Load Caster's Physical Attack Percent.
$03/E839   48    PHA   A:0034   X:0018   Y:0000   P:envMxdizc - Push A.

That seems like a fine start to a recipe actually.

Well... I learned something through this experience... Never Ever Forget to Retrieve Your Pushed Values!!

For roughly an hour I was looking at my preliminary code, wondering what I was doing wrong, when it finally dawned on me that because I was testing the pure functionality I never retrieved the Pushed value back and this causes a system crash.

So I now have Arrowstorm working like Barrage from FFT:War of the Lions! 4 half-damage attack that takes 4 Ammo for roughly 2x damage (but it attacks four times so even more chance of a status infliction if applicable)

Arrowstorm

Code: [Select]
$03/E836 AD 9D 26 LDA $269D  [$7E:269D] A:0003 X:0018 Y:0000 P:envMxdizc - Load Caster's Physical Attack Base.
$03/E839 48 PHA A:0053 X:0018 Y:0000 P:envMxdizc - Push A onto Stack.
$03/E83A 4A LSR A A:0053 X:0018 Y:0000 P:envMxdizc - Divide Physical Attack Base by 2.
$03/E83B 8D 9D 26 STA $269D  [$7E:269D] A:0029 X:0018 Y:0000 P:envMxdizC - Store A in Physical Attack Base.
$03/E83E 20 99 C4 JSR $C499  [$03:C499] A:0029 X:0018 Y:0000 P:envMxdizC - Fight Routine x 4
$03/E841 20 99 C4 JSR $C499  [$03:C499] A:0000 X:750E Y:0018 P:envMxdiZC
$03/E844 20 99 C4 JSR $C499  [$03:C499] A:0000 X:750E Y:0018 P:envMxdiZC
$03/E847 20 99 C4 JSR $C499  [$03:C499] A:0000 X:750E Y:0018 P:envMxdiZC
$03/E84A 68 PLA A:0000 X:750E Y:0018 P:envMxdiZC - Pull A
$03/E84B 8D 9D 26 STA $269D  [$7E:269D] A:0053 X:750E Y:0018 P:envMxdizC - Store A in Physical Attack Base (original value)
$03/E84E 60 RTS A:0053 X:750E Y:0018 P:envMxdizC - Return


Now, FFIII's Barrage is a little trickier to get down...

The way that works is each shot deals full damage +another 10-40% depending on the Job Level. To mimic this, (as well as I can...) I would instead make it look at Strength. At
0-39 Str. There would be no bonus. 40-60 1/8 Bonus in Damage, 60-99 1/4 Bonus in damage. It might encourage people to use Rosa in a Strength set-up rather than always going for the Will set-up possibly. But this seems like it will take a bit more space than Aim actually supports. So I'll have to hold off on that for now.

Though I suppose I could make a variant... (looks back at how he programmed Aura originally...) Yes. Instead make it so that Two Attacks will occur automatically. And if you have over 45 Strength a third one happens and at over 60 strength a fourth one occurs.

Barrage (Arrowstorm) FFIII "Style" (Sort of)

Code: [Select]
$03/E836 20 99 C4 JSR $C499  [$03:C499] A:0003 X:0018 Y:0000 P:envMxdizc - Fight Routine
$03/E839 20 99 C4 JSR $C499  [$03:C499] A:0000 X:750E Y:0018 P:envMxdiZC - Fight Routine
$03/E83C AD 94 26 LDA $2694  [$7E:2694] A:0000 X:750E Y:0018 P:envMxdiZC - Load Modified Strength
$03/E83F C9 2D CMP #$2D A:005D X:750E Y:0018 P:envMxdizC - Is it 45 or Higher?
$03/E841 90 0E BCC $0E    [$E851] A:005D X:750E Y:0018 P:envMxdizC - If lower branch to 03E851
$03/E843 20 99 C4 JSR $C499  [$03:C499] A:005D X:750E Y:0018 P:envMxdizC - Fight Routine
$03/E846 AD 94 26 LDA $2694  [$7E:2694] A:0000 X:750E Y:0018 P:envMxdiZC - Load Modified Strength
$03/E849 C9 3C CMP #$3C A:005D X:750E Y:0018 P:envMxdizC - Is it 60 or Higher?
$03/E84B 90 04 BCC $04    [$E851] A:005D X:750E Y:0018 P:envMxdizC - If lower branch to 03E851
$03/E84D 20 99 C4 JSR $C499  [$03:C499] A:005D X:750E Y:0018 P:envMxdizC - Fight Routine
$03/E850 60 RTS A:0000 X:750E Y:0018 P:envMxdiZC - Return

Geez, I must really love the Aim Command, I've now made three variants for it!