øAslickproductions.org/forum/index.php?PHPSESSID=5f0fck550j2m4m2fpbtkj2vkm1&topic=1851.msg19541e:/My Web Sites/Slick Productions - FFIV Message Board/slickproductions.org/forum/indexc1b4.htmlslickproductions.org/forum/index.php?PHPSESSID=5f0fck550j2m4m2fpbtkj2vkm1&topic=1851.0e:/My Web Sites/Slick Productions - FFIV Message Board/slickproductions.org/forum/indexc1b4.html.zx±Fg^ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÈÐDðOKtext/htmlISO-8859-1gzip@øÕDðÿÿÿÿÿÿÿÿTue, 10 Mar 2020 08:06:31 GMT0ó°° ®0®P®€§²ð®°Fg^ÿÿÿÿÿÿÿÿ÷;Dð Changing spell effects outside of battle

Author Topic: Changing spell effects outside of battle  (Read 2245 times)

Pinkpuff

  • Flan Princess
  • *
  • Posts: 924
  • Find a Megalixir in Unprecedented Crisis!
    • View Profile
Changing spell effects outside of battle
« on: August 16, 2013, 11:22:38 AM »
Some spells have effects outside of battle and some don't. However, it is not obvious from the spell data which spells have such effects and which don't, not to mention what they are. This can be annoying for hacking since if you decide to change a spell, say, Sight, into something completely different, it will still have the effect of Sight when used outside of battle, which is probably not what you want.
  • How and where does the game store which spells do what outside of battle?
  • Is it possible to change what spells correspond to what out-of-battle effects?
  • Is it possible to disable certain effects altogether such that no spell has that effect?
  • Is it possible to have the same out-of-battle effect correspond to multiple spells?
  • Can we change what the effects themselves do, or (more realistically) their parameters?
Let's dance!

chillyfeez

  • FF4 Hacker
  • *
  • Posts: 1,285
  • Gender: Male
  • Go ahead, ask me about Angel Feathers!
    • View Profile
Re: Changing spell effects outside of battle
« Reply #1 on: August 16, 2013, 11:41:13 AM »
I presume you mean sight, warp and exit. Are you thinking of healing and metamorphosis spells as well?

Pinkpuff

  • Flan Princess
  • *
  • Posts: 924
  • Find a Megalixir in Unprecedented Crisis!
    • View Profile
Re: Changing spell effects outside of battle
« Reply #2 on: August 16, 2013, 11:47:15 AM »
All of the above.

Suppose I change, say, the Toad spell into something else, like a damage spell. Now if I use it outside of battle I probably don't want it toggling Toad status.
Let's dance!

Grimoire LD

  • FF4 Hacker
  • *
  • Posts: 1,684
    • View Profile
Re: Changing spell effects outside of battle
« Reply #3 on: August 17, 2013, 11:59:41 AM »
I did a bit of searching today but hit a wall when it came to the status spells. I'm not sure how the game says that This spell will inflict That status. On a minor note I did find the out-of-battle spells you can cast while a Pig or Frog though.

Code: [Select]
01B27F - C9 0E - CMP 0E - Checking to see what spells are past value 0E (Cure1)
01B283 - C9 13 - CMP 13 - Life1?


01B52E - C9 0E - CMP 0E - Start of Index of usable Spells outside of battle.
01B532 - C9 1C - CMP 1C - End of Index of usable Spells (Using spells outside of their intended range tends to have glitchy and game crashing effects)
01B539 - C9 12 - CMP 12 - Can be used while a Toad/Pig outside of battle- Esuna
01B54B - C9 19 - CMP 19 - Can be used while a Toad outside of battle - Toad
01B559 - C9 1A - CMP 1A - Can be used while a Pig outside of battle - Pig
01B570 - C9 16 - CMP 16 - Appears to be the "instant cast" of the Spell Number corresponding to Exit. Changing this alone will not change the Spell Number of Exit's effect however.
01B574 - C9 17 - CMP 17 - As above, but in regards to Sight.
01B578 - C9 1B - CMP 1B - Spell Number which corresponds to the Warp Event
-----------------------------


Grimoire LD

  • FF4 Hacker
  • *
  • Posts: 1,684
    • View Profile
Re: Changing spell effects outside of battle
« Reply #4 on: October 20, 2013, 03:22:40 PM »
Alright, I've taken another look at this because it was important for my FFIV-FFI mod and hopefully have come up with some decent results...

Something I did not notice is that spells are aligned in such a way that their usability is dependent on a range and index 0E-1B (Game looks at 1C but it is 1B, 1C is Venom, 1B is Warp).

01B27F - C9 0E - (CMP with 0E) is actually what spells to highlight and Only what spells to highlight.

$01/B283   C9 1C   CMP #$1C   A:0219   X:0248   Y:0000   P:envMxdIzC - This is where the index of usable spells end. So if you wanted to change the index of usable spells you would change these two values to whatever was desired. When I saw the value the first time I must have confused the 1C for a 13, I'm not really sure how I did that, but eh...

And here is the actual ranges of spells as well.

01B52E - C9 0E - CMP 0E - Start of Index of usable Spells outside of battle.
01B532 - C9 1C - CMP 1C - End of Index of usable Spells (Using spells outside of their intended range tends to have glitchy and game crashing effects)

I've tried to find anything more than that, but have so far come up empty handed, I'm afraid.

Pinkpuff

  • Flan Princess
  • *
  • Posts: 924
  • Find a Megalixir in Unprecedented Crisis!
    • View Profile
Re: Changing spell effects outside of battle
« Reply #5 on: November 02, 2013, 06:12:40 AM »
That's not what my rom has at those addresses...

1B52E-1B52F:  8E 33
1B530-1B53F:  CA 10 FA A9 FF A2 09 00 9D CA 34 CA 10 FA AD 01
Let's dance!

Grimoire LD

  • FF4 Hacker
  • *
  • Posts: 1,684
    • View Profile
Re: Changing spell effects outside of battle
« Reply #6 on: November 02, 2013, 09:34:48 AM »
Ah, that's because these aren't ROM addresses but LoRom addresses.

To find where there are in Rom adding 1FE00 to the result Normally takes you to them.

Which... hmm, header, non-header, that could cause some problems...

I'll grab the sequence of bytes from these spots and find their ROM location from there.


0xB47F-  C9 0E - (CMP with 0E) is actually what spells to highlight and Only what spells to highlight.
0xB483 - C9 1C - CMP 1C - CMP #$1C   A:0219   X:0248   Y:0000   P:envMxdIzC - This is where the index of usable spells end. So if you wanted to change the index of usable spells you would change these two values to whatever was desired. When I saw the value the first time I must have confused the 1C for a 13, I'm not really sure how I did that, but eh...

01B52E - C9 0E - CMP 0E - Start of Index of usable Spells outside of battle.
01B532 - C9 1C - CMP 1C - End of Index of usable Spells (Using spells outside of their intended range tends to have glitchy and game crashing effects)



And here is the actual ranges of spells as well.

0xB73E - C9 0E - CMP 0E - Start of Index of usable Spells outside of battle.
0xB733 - C9 1C - CMP 1C - End of Index of usable Spells (Using spells outside of their intended range tends to have glitchy and game crashing effects)


Sorry about that, I mostly post values from the LoRom for quick modification purposes of my own. Though if you'd like me to also post ROM equivalents to those, let me know and I'll do that as well.

chillyfeez

  • FF4 Hacker
  • *
  • Posts: 1,285
  • Gender: Male
  • Go ahead, ask me about Angel Feathers!
    • View Profile
Re: Changing spell effects outside of battle
« Reply #7 on: November 02, 2013, 11:44:20 AM »
Off topic, but relevant to the most recent post - I found a useful little tool on RHDN called the SNES ASM professional development kit http://www.romhacking.net/utilities/395/
While there is a definite algorithm for figuring ROM offsets based on LoROM and vice versa, using this is the quickest method I've found. Just punch a ROM address into its Goto and it jumps to the place in ROM, but with LoROM offsets. To go the other way, I usually just search for the first five bytes or so in my regular hex editor.
The ASM dev kit is useful too for writing custom code (its intended purpose) though not without its limitations. It has real trouble with 8/16 bit flags, and crashes if you enter aan ASM command that is invalid. Still, very useful thing to have in your hacking toolkit.

Pinkpuff

  • Flan Princess
  • *
  • Posts: 924
  • Find a Megalixir in Unprecedented Crisis!
    • View Profile
Re: Changing spell effects outside of battle
« Reply #8 on: November 03, 2013, 04:48:29 AM »
Ah, that's because these aren't ROM addresses but LoRom addresses.

To find where there are in Rom adding 1FE00 to the result Normally takes you to them.

Sorry about that, I mostly post values from the LoRom for quick modification purposes of my own. Though if you'd like me to also post ROM equivalents to those, let me know and I'll do that as well.

That explains it. Yeah the actual ROM addresses are the only ones useful for me for FF4kster. If that 1FE00 trick works reliably then it should be ok, otherwise I certainly would appreciate actual ROM addresses...
Let's dance!

Grimoire LD

  • FF4 Hacker
  • *
  • Posts: 1,684
    • View Profile
Re: Changing spell effects outside of battle
« Reply #9 on: November 03, 2013, 11:10:00 AM »
Oh, let me correct myself. I meant Subtract 1FE00 from the initial LoRom readout. Interesting tool Chillyfeez, I'll have to pick that up. There is an exception though and that's more to do with whether the rom has a header.
« Last Edit: November 03, 2013, 08:32:16 PM by Grimoire LD »

Grimoire LD

  • FF4 Hacker
  • *
  • Posts: 1,684
    • View Profile
Re: Changing spell effects outside of battle
« Reply #10 on: November 05, 2013, 07:30:44 AM »
Alright, this would ordinarily go in my Note thread, but it seems more pertinent to this discussion here, I've finally started to make real headway into the way the game decides and calculates out-of-battle spells, including a full disassembly of Curing Magic.

[Cure1 Code
Code: [Select]
$01/B753 AF F5 97 0F LDA $0F97F5[$0F:97F5] A:B753 X:B737 Y:0320 P:eNvMxdIzc - Load A from Cure1's Power.
$01/B757 8D 91 1B STA $1B91  [$7E:1B91] A:B704 X:B737 Y:0320 P:envMxdIzc - Store A in 7E1B91
$01/B75A 80 4A BRA $4A    [$B7A6] A:B704 X:B737 Y:0320 P:envMxdIzc - Branch to 01B7A6
--------------------------------------------------------------------------------

Cure2 Code

Code: [Select]
$01/B75C AF FB 97 0F LDA $0F97FB[$0F:97FB] A:B75C X:B737 Y:0320 P:eNvMxdIzc - Load A from Cure2's Power.
$01/B760 8D 91 1B STA $1B91  [$7E:1B91] A:B70C X:B737 Y:0320 P:envMxdIzc - Store A in 7E1B91
$01/B763 80 41 BRA $41    [$B7A6] A:B70C X:B737 Y:0320 P:envMxdIzc - Branch to 01B7A6
----------------------------------------------------------------------------------------------------------

Cure3 Code
Code: [Select]
$01/B765 AF 01 98 0F LDA $0F9801[$0F:9801] A:B765 X:B737 Y:0320 P:eNvMxdIzc - Load A from Cure3's Power.
$01/B769 8D 91 1B STA $1B91  [$7E:1B91] A:B724 X:B737 Y:0320 P:envMxdIzc - Store A in 7E1B91.
$01/B76C 80 38 BRA $38    [$B7A6] A:B724 X:B737 Y:0320 P:envMxdIzc - Branch to 01B7A6.

Cure4 Code
Code: [Select]
$01/B76E AD BB 1B LDA $1BBB  [$7E:1BBB] A:B76E X:B737 Y:0320 P:eNvMxdIzc - Load A from 7E1BBB. (Is it being Multi-targeted)
$01/B771 F0 09 BEQ $09    [$B77C] A:B700 X:B737 Y:0320 P:envMxdIZc - If 00 branch to 01B77C
-------------------------------------------------------------------------------------
$01/B773 AF 07 98 0F LDA $0F9807[$0F:9807] A:B7FF X:B737 Y:0320 P:eNvMxdIzc - Load Cure 4's Power into A.
$01/B777 8D 91 1B STA $1B91  [$7E:1B91] A:B748 X:B737 Y:0320 P:envMxdIzc - Store A in 7E1B91.
$01/B77A 80 2A BRA $2A    [$B7A6] A:B748 X:B737 Y:0320 P:envMxdIzc - Branch to 01B7A6
--------------------------------------------------------------------------------------
$01/B77C A9 00 LDA #$00 A:B700 X:B737 Y:0320 P:envMxdIZc - Load 00 into A.
$01/B77E 20 87 B7 JSR $B787  [$01:B787] A:B700 X:B737 Y:0320 P:envMxdIZc - Jump to Subroutine.
-------------------------------------------------------------------------------------------
(Accessed at end of Routine)
$01/B781 1A INC A A:0700 X:1040 Y:0320 P:envMxdIZc +1 to A.
$01/B782 C9 05 CMP #$05 A:0701 X:1040 Y:0320 P:envMxdIzc - Has it gone through 5 Times for every character? (Which it can't because of the specific coding requirements...)
$01/B784 D0 F8 BNE $F8    [$B77E] A:0701 X:1040 Y:0320 P:eNvMxdIzc - If not branch back to 01B77E.
-------------------------------------------------------------------------------------------------------
$01/B786 60 RTS A:0705 X:0004 Y:0320 P:envMxdIZC - Return
-------------------------------------------------------------------------------------------
$01/B787 48 PHA A:B700 X:B737 Y:0320 P:envMxdIZc - Push A onto Stack.
$01/B788 20 B4 87 JSR $87B4  [$01:87B4] A:B700 X:B737 Y:0320 P:envMxdIZc - Jump to subroutine (??)
$01/B78B BD 8B 1B LDA $1B8B,x[$7E:1B8B] A:B700 X:0000 Y:0320 P:envMxdIZc - Load A from 7E1B8B.
$01/B78E F0 14 BEQ $14    [$B7A4] A:B7FF X:0000 Y:0320 P:eNvMxdIzc - If 00 branch to 0187B4.
$01/B790 A5 43 LDA $43    [$00:0143] A:B7FF X:0000 Y:0320 P:eNvMxdIzc - Load A from 143.
$01/B792 20 77 B9 JSR $B977  [$01:B977] A:B700 X:0000 Y:0320 P:envMxdIZc - Jump to Subroutine (Determining who it is being cast upon)
$01/B795 BD 03 00 LDA $0003,x[$7E:1043] A:1001 X:1040 Y:0320 P:envMxdIzc - Load Target's Status Byte 1.
$01/B798 30 0A BMI $0A    [$B7A4] A:1000 X:1040 Y:0320 P:envMxdIZc - If dead, skip.
$01/B79A C2 20 REP #$20 A:1000 X:1040 Y:0320 P:envMxdIZc - Reset Processor Status.
$01/B79C BD 09 00 LDA $0009,x[$7E:1049] A:1000 X:1040 Y:0320 P:envmxdIZc - Load A from Character's Max HP.
$01/B79F 9D 07 00 STA $0007,x[$7E:1047] A:076C X:1040 Y:0320 P:envmxdIzc - Store A in Character's Current HP.
$01/B7A2 E2 20 SEP #$20 A:076C X:1040 Y:0320 P:envmxdIzc - Set Processor Status
$01/B7A4 68 PLA A:076C X:1040 Y:0320 P:envMxdIzc - Pull A.
$01/B7A5 60 RTS A:0700 X:1040 Y:0320 P:envMxdIZc - Return
------------------------------------------------------------------------------------------------

General Spell Healing Code

Code: [Select]
$01/B7A6 A9 00 LDA #$00 A:B704 X:B737 Y:0320 P:envMxdIzc - Load 00 into A.
$01/B7A8 EB XBA A:B700 X:B737 Y:0320 P:envMxdIZc - Exchange B and A 8-bit Accumulators. (That is quite useful, I'll need to keep that in mind)
$01/B7A9 AD 91 1B LDA $1B91  [$7E:1B91] A:00B7 X:B737 Y:0320 P:eNvMxdIzc - Load A from 7E1B91.
$01/B7AC C2 20 REP #$20 A:0004 X:B737 Y:0320 P:envMxdIzc - Reset Processor Status.
$01/B7AE 0A ASL A A:0004 X:B737 Y:0320 P:envmxdIzc - x2 to A.
$01/B7AF 0A ASL A A:0008 X:B737 Y:0320 P:envmxdIzc - x2 to A
$01/B7B0 8D 91 1B STA $1B91  [$7E:1B91] A:0010 X:B737 Y:0320 P:envmxdIzc - Store A in 7E1B91.
$01/B7B3 E2 20 SEP #$20 A:0010 X:B737 Y:0320 P:envmxdIzc - Set Processor Status
$01/B7B5 A5 E8 LDA $E8    [$00:01E8] A:0010 X:B737 Y:0320 P:envMxdIzc - Load the value 01E8 into A.
$01/B7B7 20 07 90 JSR $9007  [$01:9007] A:0001 X:B737 Y:0320 P:envMxdIzc - Jump to Subroutine (Gets Targeting Info.)
$01/B7BA BD 18 00 LDA $0018,x[$7E:1058] A:1001 X:1040 Y:0320 P:envMxdIzc - Load Caster's Modified Will into A.
$01/B7BD 4A LSR A A:103C X:1040 Y:0320 P:envMxdIzc - /2
$01/B7BE 4A LSR A A:101E X:1040 Y:0320 P:envMxdIzc - /2
$01/B7BF 4A LSR A A:100F X:1040 Y:0320 P:envMxdIzc - /2
$01/B7C0 1A INC A A:1007 X:1040 Y:0320 P:envMxdIzC - /2
$01/B7C1 85 54 STA $54    [$00:0154] A:1008 X:1040 Y:0320 P:envMxdIzC - Store A in 0154
$01/B7C3 64 55 STZ $55    [$00:0155] A:1008 X:1040 Y:0320 P:envMxdIzC - Store Zero in 0155.
$01/B7C5 A9 00 LDA #$00 A:1008 X:1040 Y:0320 P:envMxdIzC - Load 00 into A.
$01/B7C7 EB XBA A:1000 X:1040 Y:0320 P:envMxdIZC Exchange B and A 8-Bit Accumulators
$01/B7C8 BD 18 00 LDA $0018,x[$7E:1058] A:0010 X:1040 Y:0320 P:envMxdIzC - Load Caster's Modified Will into A.
$01/B7CB 4A LSR A A:003C X:1040 Y:0320 P:envMxdIzC - /2.
$01/B7CC C2 20 REP #$20 A:001E X:1040 Y:0320 P:envMxdIzc - Reset Processor Status
$01/B7CE 18 CLC A:001E X:1040 Y:0320 P:envmxdIzc - Clear Carry Flag.
$01/B7CF 6D 91 1B ADC $1B91  [$7E:1B91] A:001E X:1040 Y:0320 P:envmxdIzc - Add Modified Will /2 onto the base power of the Cure.
$01/B7D2 85 57 STA $57    [$00:0157] A:002E X:1040 Y:0320 P:envmxdIzc - Store A in 57.
$01/B7D4 18 CLC A:002E X:1040 Y:0320 P:envmxdIzc - Clear Carry Flag.
$01/B7D5 65 57 ADC $57    [$00:0157] A:002E X:1040 Y:0320 P:envmxdIzc - Add the value of 57 onto A.
$01/B7D7 C6 54 DEC $54    [$00:0154] A:005C X:1040 Y:0320 P:envmxdIzc - -1 from a ticker of Modified Will/8
$01/B7D9 D0 F9 BNE $F9    [$B7D4] A:005C X:1040 Y:0320 P:envmxdIzc - Repeat this until the ticker reads 0.
(Thereby the formula for healing HP with spells outside of battle is...)
 (Base x 4 + (Will /2 x Will/8)
The rest of the routine is just cleaning matters and safeguards. They aren't too important to record. It does end at 01B849 which might be important for me later.

In addition to this is Float dealings...

Float Code

Code: [Select]
$01/B9CD BD 04 00 LDA $0004,x[$7E:1044] A:1001 X:1040 Y:0320 P:envMxdIzc - Load Target's Status Byte 2 into A.
$01/B9D0 09 40 ORA #$40 A:1000 X:1040 Y:0320 P:envMxdIZc - Add 40 if Applicable.
$01/B9D2 9D 04 00 STA $0004,x[$7E:1044] A:1040 X:1040 Y:0320 P:envMxdIzc - Store A in Target's Status Byte 2.

I can't see its functionality though if it were changed however, considering how few beneficial statuses are in FFIV in the first place. I feel I am close now. I can already make Sight look at a character basis. It may not be too difficult to exchange its event code for something more useful.

Grimoire LD

  • FF4 Hacker
  • *
  • Posts: 1,684
    • View Profile
Re: Changing spell effects outside of battle
« Reply #11 on: November 05, 2013, 04:06:39 PM »
Heal Code

Code: [Select]
$01/B84A A9 00 LDA #$00 A:B84A X:B737 Y:0320 P:eNvMxdIzc - Load 00 into A.
$01/B84C 20 55 B8 JSR $B855  [$01:B855] A:B800 X:B737 Y:0320 P:envMxdIZc - Jump to Subroutine (Targeting Info)
$01/B861 C2 20 REP #$20 A:1001 X:1040 Y:0320 P:envMxdIzc - Reset Processor Status.
$01/B863 BD 03 00 LDA $0003,x[$7E:1043] A:1001 X:1040 Y:0320 P:envmxdIzc - Load Target's Status Byte 1 into A.
$01/B866 29 80 7C AND #$7C80 A:0000 X:1040 Y:0320 P:envmxdIZc - Do... this... to get rid of status bits.
$01/B869 9D 03 00 STA $0003,x[$7E:1043] A:0000 X:1040 Y:0320 P:envmxdIZc  - Store A in Target's Status Byte 1.
$01/B86C E2 20 SEP #$20 A:0000 X:1040 Y:0320 P:envmxdIZc - Set Processor Status
$01/B86E 68 PLA A:0000 X:1040 Y:0320 P:envMxdIZc - Pull A from Stack.
$01/B86F 60 RTS A:0000 X:1040 Y:0320 P:envMxdIZc - Return.

Life1 Code

Code: [Select]
$01/B870 A9 00 LDA #$00 A:B870 X:B737 Y:0320 P:eNvMxdIzc - Load 00 into A.
$01/B872 8D BD 1B STA $1BBD  [$7E:1BBD] A:B800 X:B737 Y:0320 P:envMxdIZc - Store A in 7E1BBD.
$01/B875 20 7F B8 JSR $B87F  [$01:B87F] A:B800 X:B737 Y:0320 P:envMxdIZc - Jump to Subroutine (same targeting one as above, just a slightly different entrance point)
-------------------------------------------------------------------------------------------------

------------------------------------------------------------------------------------------------------
$01/B87F 48 PHA A:B800 X:B737 Y:0320 P:envMxdIZc - Push A onto Stack.
$01/B880 20 B4 87 JSR $87B4  [$01:87B4] A:B800 X:B737 Y:0320 P:envMxdIZc - Jump to Subroutine (Targeting)
------------------------------------------------------------------------------------------------------
$01/B883 BD 8B 1B LDA $1B8B,x[$7E:1B8B] A:B800 X:0000 Y:0320 P:envMxdIZc - Load A from 7E1B8B.
$01/B886 F0 2A BEQ $2A    [$B8B2] A:B8FF X:0000 Y:0320 P:eNvMxdIzc - If 00 branch to 01B8B2.
$01/B888 20 79 B9 JSR $B979  [$01:B979] A:B8FF X:0000 Y:0320 P:eNvMxdIzc - Jump to Subroutine (??)
$01/B88B BD 03 00 LDA $0003,x[$7E:1043] A:1001 X:1040 Y:0320 P:envMxdIzc - Load Target's Status Byte 1.
$01/B88E 10 22 BPL $22    [$B8B2] A:1000 X:1040 Y:0320 P:envMxdIZc - Are they alive? If so, branch to 03B8B2 (Return)
$01/B890 29 7F AND #$7F A:1080 X:1000 Y:0320 P:eNvMxdIzc - Add 7F (get rid of 80)
$01/B892 9D 03 00 STA $0003,x[$7E:1003] A:1000 X:1000 Y:0320 P:envMxdIZc - Store A in Target's Status byte 1.
$01/B895 BD 16 00 LDA $0016,x[$7E:1016] A:1000 X:1000 Y:0320 P:envMxdIZc - Load Target's Modified Vitality.
$01/B898 85 43 STA $43    [$00:0143] A:100B X:1000 Y:0320 P:envMxdIzc - Store Modified Vitality into 43.
$01/B89A C2 20 REP #$20 A:100B X:1000 Y:0320 P:envMxdIzc - Reset Processor Status.
$01/B89C A5 43 LDA $43    [$00:0143] A:100B X:1000 Y:0320 P:envmxdIzc - Load Modified Vitality into A (even though it already is...)
$01/B89E 0A ASL A A:000B X:1000 Y:0320 P:envmxdIzc - x2.
$01/B89F 0A ASL A A:0016 X:1000 Y:0320 P:envmxdIzc - x2
$01/B8A0 65 43 ADC $43    [$00:0143] A:002C X:1000 Y:0320 P:envmxdIzc - Add Modified Vitality onto that.
$01/B8A2 DD 09 00 CMP $0009,x[$7E:1009] A:0037 X:1000 Y:0320 P:envmxdIzc - Compare the value to max HP.
$01/B8A5 90 03 BCC $03    [$B8AA] A:0037 X:1000 Y:0320 P:eNvmxdIzc - If it is higher than max HP branch to 03B8AA
----------------------------------------------------------------------------------------------------------------------------------------------------

------------------------------------------------------------------------------------------------------------------------------------------------------
$01/B8AA 9D 07 00 STA $0007,x[$7E:1007] A:0037 X:1000 Y:0320 P:eNvmxdIzc - Store A in Target's HP.
$01/B8AD E2 20 SEP #$20 A:0037 X:1000 Y:0320 P:eNvmxdIzc - Set Processor Status.
$01/B8AF EE BD 1B INC $1BBD  [$7E:1BBD] A:0037 X:1000 Y:0320 P:eNvMxdIzc - +1 to 7E1BBD.
$01/B8B2 68 PLA A:0037 X:1000 Y:0320 P:envMxdIzc - Pull A from Stack.
$01/B8B3 60 RTS A:0002 X:1000 Y:0320 P:envMxdIzc - Return.
The underlying code of out-of-battle revival is here plain to see.

Modified Vitality x4 + Modified Vitality = Revival amount.

Life2 Code

Code: [Select]
$01/B8B4 A9 00 LDA #$00 A:B8B4 X:B737 Y:0320 P:eNvMxdIzc - Load 00 into A.
$01/B8B6 8D BD 1B STA $1BBD  [$7E:1BBD] A:B800 X:B737 Y:0320 P:envMxdIZc - Store A in 7E1BBD.
$01/B8B9 20 DE B8 JSR $B8DE  [$01:B8DE] A:B800 X:B737 Y:0320 P:envMxdIZc - Jump to Subroutine (Targeting)
---------------------------------------------------------------------------------------------------------------------
$01/B8BC 1A INC A A:B800 X:0000 Y:0320 P:envMxdIZc - +1 to A.
$01/B8BD C9 05 CMP #$05 A:B801 X:0000 Y:0320 P:envMxdIzc - Uh... what?
$01/B8BF D0 F8 BNE $F8    [$B8B9] A:B801 X:0000 Y:0320 P:eNvMxdIzc - Loop if it hasn't ?checked for all five party members?  to 01B8B9.
$01/B8C1 AD BD 1B LDA $1BBD  [$7E:1BBD] A:0005 X:0004 Y:0320 P:envMxdIZC - Load A from 7E1BBD.
$01/B8C4 D0 17 BNE $17    [$B8DD] A:0001 X:0004 Y:0320 P:envMxdIzC - Branch if not 00 to 01B8DD.
$01/B8DD 60 RTS A:0001 X:0004 Y:0320 P:envMxdIzC - Return.
------------------------------------------------------------------------------------------------------------------------
$01/B8DE 48 PHA A:B800 X:B737 Y:0320 P:envMxdIZc - Push A onto Stack.
$01/B8DF 20 B4 87 JSR $87B4  [$01:87B4] A:B800 X:B737 Y:0320 P:envMxdIZc - Jump to Subroutine (Targeting)
$01/B8E2 BD 8B 1B LDA $1B8B,x[$7E:1B8B] A:B800 X:0000 Y:0320 P:envMxdIZc - Load A from 7E1B8B
$01/B8E5 F0 22 BEQ $22    [$B909] A:B800 X:0000 Y:0320 P:envMxdIZc - If 00 branch to 01B909
------------------------------------------------------------------------------------------------------------------------------------------
$01/B8E7 20 79 B9 JSR $B979  [$01:B979] A:B8FF X:0002 Y:0320 P:eNvMxdIzc - Jump to Subroutine (Targeting?)
$01/B8EA BD 03 00 LDA $0003,x[$7E:1003] A:1000 X:1000 Y:0320 P:envMxdIZc - Load Target's Status Byte 1 into A.
$01/B8ED 10 1A BPL $1A    [$B909] A:1080 X:1000 Y:0320 P:eNvMxdIzc - If not dead branch to 01B909.
$01/B8EF A9 00 LDA #$00 A:1080 X:1000 Y:0320 P:eNvMxdIzc  - Load 00 into A.
$01/B8F1 9D 03 00 STA $0003,x[$7E:1003] A:1000 X:1000 Y:0320 P:envMxdIZc - Store A in Target's Status Byte 1.
$01/B8F4 BD 04 00 LDA $0004,x[$7E:1004] A:1000 X:1000 Y:0320 P:envMxdIZc - Load Target's Status Byte 2 into A.
$01/B8F7 29 7F AND #$7F A:1000 X:1000 Y:0320 P:envMxdIZc - Add 7F (getting rid of 80, meaning that Curse was intended to be outside of battle originally, thereby making this check now worthless)
$01/B8F9 9D 04 00 STA $0004,x[$7E:1004] A:1000 X:1000 Y:0320 P:envMxdIZc - Store A in Target's Status Byte 2.
$01/B8FC C2 20 REP #$20 A:1000 X:1000 Y:0320 P:envMxdIZc - Reset Processor Status
$01/B8FE BD 09 00 LDA $0009,x[$7E:1009] A:1000 X:1000 Y:0320 P:envmxdIZc - Load Target's Max HP.
$01/B901 9D 07 00 STA $0007,x[$7E:1007] A:00C8 X:1000 Y:0320 P:envmxdIzc - Store in Target's Current HP.
$01/B904 E2 20 SEP #$20 A:00C8 X:1000 Y:0320 P:envmxdIzc - Set Processor Status.
$01/B906 EE BD 1B INC $1BBD  [$7E:1BBD] A:00C8 X:1000 Y:0320 P:envMxdIzc - +1 to 7E1BBD.
----------------------------------------------------------------------------------------------------------------------------------------------
$01/B909 68 PLA A:B800 X:0000 Y:0320 P:envMxdIZc - Pull A.
$01/B90A 60 RTS A:B800 X:0000 Y:0320 P:envMxdIZc - Return (to earlier in the routine)

Now this is interesting! Apparently Curse was supposed to be carried out of battle, the Life formula makes clear mention of getting rid of it when revived, this makes no sense outside of battle unless Curse was originally supposed to be permanent status.

Size Code
Code: [Select]
$01/B90B A9 10 LDA #$10 A:B90B X:B737 Y:0320 P:eNvMxdIzc - Load 10 into A.
$01/B90D A0 03 00 LDY #$0003 A:B910 X:B737 Y:0320 P:envMxdIzc - Load 03 into Y.
$01/B910 80 0E BRA $0E    [$B920] A:B910 X:B737 Y:0003 P:envMxdIzc - Branch to 03B920
-----------------------------------------------------------------------------------------------------------------------

-----------------------------------------------------------------------------------------------------------------------------
$01/B920 85 48 STA $48    [$00:0148] A:B910 X:B737 Y:0003 P:envMxdIzc - Store A in 0148.
$01/B922 49 FF EOR #$FF A:B910 X:B737 Y:0003 P:envMxdIzc - Add FF to A.
$01/B924 85 49 STA $49    [$00:0149] A:B9EF X:B737 Y:0003 P:eNvMxdIzc - Store A in 149.
$01/B926 84 4B STY $4B    [$00:014B] A:B9EF X:B737 Y:0003 P:eNvMxdIzc - Store Y in 14B.
$01/B928 A9 00 LDA #$00 A:B9EF X:B737 Y:0003 P:eNvMxdIzc - Load 00 into A.
$01/B92A 20 33 B9 JSR $B933  [$01:B933] A:B900 X:B737 Y:0003 P:envMxdIZc - Jump to Subroutine (Targeting intro)
---------------------------------------------------------------------------------------------------------------------------
$01/B92D 1A INC A A:B900 X:0000 Y:0003 P:envMxdIZc - +1 to A.
$01/B92E C9 05 CMP #$05 A:B901 X:0000 Y:0003 P:envMxdIzc - Has it gone through 5 times?
$01/B930 D0 F8 BNE $F8    [$B92A] A:B901 X:0000 Y:0003 P:eNvMxdIzc - If not, loop back to 03B92A.
--------------------------------------------------------------------------------------------------------------------------------
$01/B933 48 PHA A:B900 X:B737 Y:0003 P:envMxdIZc - Push A onto Stack.
$01/B934 20 B4 87 JSR $87B4  [$01:87B4] A:B900 X:B737 Y:0003 P:envMxdIZc - Jump to Subroutine (Targeting)
$01/B937 BD 8B 1B LDA $1B8B,x[$7E:1B8B] A:B900 X:0000 Y:0003 P:envMxdIZc - Load A from 7E1B8B.
$01/B93A F0 17 BEQ $17    [$B953] A:B900 X:0000 Y:0003 P:envMxdIZc - Branch if 00 to 01B953.
---------------------------------------------------------------------------------------------------------------------------------------
$01/B93C 20 79 B9 JSR $B979  [$01:B979] A:B9FF X:0002 Y:0003 P:eNvMxdIzc - (Targeting?)
$01/B93F 86 4E STX $4E    [$00:014E] A:1000 X:1000 Y:0003 P:envMxdIZc - Store X in 014E.
$01/B941 64 50 STZ $50    [$00:0150] A:1000 X:1000 Y:0003 P:envMxdIZc - Store Zero in 0150.
$01/B943 B1 4E LDA ($4E),y[$7E:1003] A:1000 X:1000 Y:0003 P:envMxdIZc - Load Target's Status Byte 1 into A.
$01/B945 48 PHA A:1000 X:1000 Y:0003 P:envMxdIZc - Push A onto Stack
$01/B946 25 49 AND $49    [$00:0149] A:1000 X:1000 Y:0003 P:envMxdIZc - Add the value in 0149 onto A.
$01/B948 91 4E STA ($4E),y[$7E:1003] A:1000 X:1000 Y:0003 P:envMxdIZc - Store A in1 4E.
$01/B94A 68 PLA A:1000 X:1000 Y:0003 P:envMxdIZc  - Pull A.
$01/B94B 49 FF EOR #$FF A:1000 X:1000 Y:0003 P:envMxdIZc - Add FF onto A.
$01/B94D 25 48 AND $48    [$00:0148] A:10FF X:1000 Y:0003 P:eNvMxdIzc - Add the value in 0148 (10 from the start of routine)
$01/B94F 11 4E ORA ($4E),y[$7E:1003] A:1010 X:1000 Y:0003 P:envMxdIzc - Add that value onto Character's Status Byte1 .
$01/B951 91 4E STA ($4E),y[$7E:1003] A:1010 X:1000 Y:0003 P:envMxdIzc - Store Character's Status Byte 1.
--------------------------------------------------------------------------------------------------------------------------------------------
$01/B953 68 PLA A:B900 X:0000 Y:0003 P:envMxdIZc - Pull A from Stack.
$01/B954 60 RTS A:B900 X:0000 Y:0003 P:envMxdIZc - Return.

No new surprises there, it is clear that status healing is a uniform system. Looks to see who is the target, then target of that target, and goes on from there. Now things should get interesting...

Magic Menu Call (choice of targets)

Code: [Select]
$01/B955 C2 20 REP #$20 A:00F0 X:0000 Y:0308 P:envMxdIZc - Reset Processor Status
$01/B957 A9 57 02 LDA #$0257 A:00F0 X:0000 Y:0308 P:envmxdIZc - Load 0257 into A.
$01/B95A A2 00 03 LDX #$0300 A:0257 X:0000 Y:0308 P:envmxdIzc - Load 0300 into X.
$01/B95D A0 00 A2 LDY #$A200 A:0257 X:0300 Y:0308 P:envmxdIzc - Load A200 into Y.
$01/B960 54 7E 7E MVN 7E 7E A:0257 X:0300 Y:A200 P:eNvmxdIzc - ?Block Move Negative?
$01/B963 E2 20 SEP #$20 A:FFFF X:0558 Y:A458 P:eNvmxdIzc - Set Processor Status.
$01/B965 60 RTS A:FFFF X:0558 Y:A458 P:eNvMxdIzc - Return.
No idea how Any of that works.

Magic Menu Close (choice of targets)
Code: [Select]
$01/B966 C2 20 REP #$20 A:0001 X:BBEC Y:0018 P:eNvMxdIzc - Reset Processor Status.
$01/B968 A9 57 02 LDA #$0257 A:0001 X:BBEC Y:0018 P:eNvmxdIzc - Load 0257 into A.
$01/B96B A2 00 A2 LDX #$A200 A:0257 X:BBEC Y:0018 P:envmxdIzc - Load A200 into X.
$01/B96E A0 00 03 LDY #$0300 A:0257 X:A200 Y:0018 P:eNvmxdIzc - Load 0300 into Y.
$01/B971 54 7E 7E MVN 7E 7E A:0257 X:A200 Y:0300 P:envmxdIzc - ?Move Block Negative?
$01/B974 E2 20 SEP #$20 A:FFFF X:A458 Y:0558 P:envmxdIzc - Set Processor Status.
$01/B976 60 RTS A:FFFF X:A458 Y:0558 P:envMxdIzc - Return

As above, very little idea.


Exit/Sight Code

Code: [Select]
$01/B993 AD 04 1A LDA $1A04  [$7E:1A04] A:B993 X:B747 Y:0102 P:eNvMxdIzc - Load 7E1A04 into A.
$01/B996 29 20 AND #$20 A:B9B0 X:B747 Y:0102 P:eNvMxdIzc - Add 20.
$01/B998 F0 E8 BEQ $E8    [$B982] A:B920 X:B747 Y:0102 P:envMxdIzc - Branch if 00 to 01B982.
$01/B99A A9 04 LDA #$04 A:B920 X:B747 Y:0102 P:envMxdIzc - Load 04 into A. (That's not just any 04, that is an Event Specific 04!)
$01/B99C 80 09 BRA $09    [$B9A7] A:B904 X:B747 Y:0102 P:envMxdIzc - Branch to 03B9A7.
------------------------------------------------------------------------------------------------------------------------------------
$01/B99E AD 04 1A LDA $1A04  [$7E:1A04] A:B99E X:B747 Y:0103 P:eNvMxdIzc - Load 7E1A04 into A.
$01/B9A1 29 40 AND #$40 A:B940 X:B747 Y:0103 P:envMxdIzc - And 40.
$01/B9A3 F0 DD BEQ $DD    [$B982] A:B940 X:B747 Y:0103 P:envMxdIzc - Branch if 00 to 01B982.
$01/B9A5 A9 05 LDA #$05 A:B940 X:B747 Y:0103 P:envMxdIzc - Load 05 into A. (Event Specific)
---------------------------------------------------------------------------------------------------------------------------------
$01/B9A7 8D 03 1A STA $1A03  [$7E:1A03] A:B904 X:B747 Y:0102 P:envMxdIzc - Store A in 7E1A03.
$01/B9AA 20 DC B9 JSR $B9DC  [$01:B9DC] A:B904 X:B747 Y:0102 P:envMxdIzc - Jump to Subroutine (??)
$01/B9AD C2 20 REP #$20 A:0056 X:1040 Y:0102 P:envMxdIzC - Reset Processor Status
$01/B9AF 9D 0B 00 STA $000B,x[$7E:104B] A:0056 X:1040 Y:0102 P:envmxdIzC -  Store A in Caster's MP.
$01/B9B2 E2 20 SEP #$20 A:0056 X:1040 Y:0102 P:envmxdIzC - Set Processor Status.
$01/B9B4 22 B6 FD 1E JSL $1EFDB6[$1E:FDB6] A:0056 X:1040 Y:0102 P:envMxdIzC - Jump Long to 1EFDB6. (??)
$01/B9B8 AE 65 1A LDX $1A65  [$7E:1A65] A:0006 X:0006 Y:0102 P:envMxdIzc - Load A from 7E1A65.
$01/B9BB 9A TXS A:0006 X:02F1 Y:0102 P:envMxdIzc - Transfer X to Stack.
$01/B9BC 60 RTS A:0006 X:02F1 Y:0102 P:envMxdIzc - Return

And there we go! Finally a means to change the event trigger in a more than simple fashion (refer to this post for more information.) You could change Exit's event to something else say... Siren's Effect. This would be useful in differentiating it from the Emergency Exit item which would still have the normal effect. In addition you could change Dwarves' Bread event without having to worry about Sight also having that effect if you change Sight's event pointer.