Users browsing this thread: 1 Guest(s)
Normalised Item Magic

#1
Posts: 281
Threads: 18
Thanks Received: 13
Thanks Given: 8
Joined: Mar 2014
Reputation: 8
Status
None
Title: Normalised Item Magic
Author: Seibaby
Version: 0.2
Release date: 30/04/2016
Applies to: FF3us 1.0 (MD5:E986575B98300F721CE27C180264D890)
Tested on: FF3us 1.0 (may or may not work on other versions; untested)
Download

Code:
Files included in this archive:
  readme.txt             - You're reading it
  rod-mod-H.ips          - The patch, for headered ROM
  rod-mod-N.ips          - The patch, for unheadered ROM
  rod-mod-alt-H.ips      - The alternate version, for headered ROM
  rod-mod-alt-N.ips      - The alternate version, for unheadered ROM
  anti-rod-mod-H.ips     - Anti-patch (both versions), for headered ROM
  anti-rod-mod-N.ips     - Anti patch (both versions), for unheadered ROM
                           (The anti-patches remove this patch and restore
                            original functionality)
  rod-mod.asm            - Assembly code for the patch
  rod-mod-alt.asm        - Assembly code for the alternate version
  rod-mod.txt            - Commented disassembly and commentary

Offsets affected:
  C2/18F3-C2/18FC

Additional original functions used:
  C2/382D - C2/3837 - Part of the weapon addition magic code
  (C2/151A - C2/151E) - (Part of the Spear damage bonus for Jump. Not used by
                         the main patch, only by one of the bonus options)

Introduction:
  Item Magic, aka breaking Rods (and Shields), normally produces unblockable, defense-ignoring spells that always do max damage, punch right through Reflect and doesn't even have the goddamn common courtesy of wiping off Clear status after they're done. While it is apparent that Square wanted Item Magic to never miss, it seems to me like a result of lazy programming that Rods and Shields became the unholy instruments of inescapable death and destruction that they are.

In the interest of improved game balance, this patch makes spells cast via an item consider all the steps of damage modification (Mdef, Shell, Morph, self damage, and random variance). Such spells will now remove Clear, but remain Unblockable and will still bypass Reflect.

The alternate version of this patch does not preserve the Unblockable and Non-reflectable attributes. Spells cast via items will bounce off Reflect, and may miss their targets. In other words, it makes spells cast via Item behave exactly like spells cast via the Magic command.  

BONUS: Check the included assembly for some optional modifications that increase damage instead of bypassing Reflect and Mblock.
 
 
Testing:
  I have tested this only briefly. If you encounter problems with this patch, please send feedback to me in this thread or in a PM.


Version history:
  0.2 Optimized code and reimplemented some original functionality.
  0.1 The first version (the alternative version in this release).


Credits and Thanks:
  Gi Nattak for requesting the original version of this patch, and
   initiating a discussion leading to its release.
  Kugawattan for providing a trail of thought that led me to develop
   the second version of this patch.
  Madsiur for encouraging the release of this patch and offering to
   host it on FF6hacking.com.
  Assassin for his invaluable commented disassembly of bank C2.

Assembly code
Code:
;Item magic removes Clear and doesn't ignore defense

hirom                   ;don't change this
;header                 ;uncomment this if your ROM has a header

org $C2382D
set_unblockable:
org $C218F3
JSR set_unblockable     ;(Set Not reflectable and Unblockable)
LDA #$80
TSB $B3                 ;(Clear ignore Clear)
DEC $3414               ;(Clear ignore damage modification)

Code:
;Alternate version - Item magic works like normal Magic

hirom                   ;don't change this
;header                 ;uncomment this if your ROM has a header

org $C218F3
LDA #$80
TSB $B3                ;(Clear Ignore Clear)
DEC $3414              ;(Clear ignore damage modification))
;-option 1---------------------------------------------------------------------
;JSR doubledmg          ;(Increase damage by 100%)
;org $C2151A
;doubledmg:
;-option 2---------------------------------------------------------------------
;INC $BD                ;(Increase damage by 50%)
;NOP
;-option 3---------------------------------------------------------------------
NOP #3                 ;(Do nothing)

Disassembly and commentary
Code:
Original code:
C2/1897: 9C 14 34     STZ $3414      (Set ignore damage modification)
C2/189A: A9 80        LDA #$80
C2/189C: 14 B3        TRB $B3        (Set Ignore Clear)
 This is the start of the code for the Item command. These instructions are necessary to let Potions etc. do fixed healing and not mess with Clear. 

C2/18F3: A9 02        LDA #$02
C2/18F5: 0C A3 11     TSB $11A3      (Set Not reflectable)
C2/18F8: A9 20        LDA #$20
C2/18FA: 0C A4 11     TSB $11A4      (Set unblockable)
This is where Item Magic gets its special properties. Looking at this code, it was obviously intentional to let Item Magic bypass Reflect and Mblock.
I believe it was Square's intention that, since you're sacrificing an item, the resulting spell should at least always hit its target.

The code for weapon addition magic at C2/382D does the same thing, so we can call it instead, and free up some space for the function of this patch:
Modified code:
C2/18F3: 20 2D 38     JSR $382D      (Set Not reflectable, Set unblockable)
C2/18F5: A9 80        LDA #$80
C2/18F8: 04 B3        TSB $B3        (Clear ignore Clear)
C2/18FA: CE 14 34     DEC $3414      (Clear ignore damage modification)

(Alternate version - this version makes Item Magic behave like normal Magic)
Modified code:
C2/18F3: A9 80        LDA #$80
C2/18F5: 04 B3        TSB $B3        (Clear Ignore Clear)
C2/18F7: CE 14 34     DEC $3414      (Clear ignore damage modification)
(BONUS: Provided are two options for making use of the unused three bytes, note
 that the attached .ips files apply the third option: nothing)
C2/18FA: 20 1A 15     JSR $151A      (Increase damage by 100%)
-or----------------------------------------------------------------------------
C2/18FA: E6 BD        INC $BD        (Increase damage by 50%)
C2/18FC: EA           NOP
-or----------------------------------------------------------------------------
C2/18FA: EA EA EA     NOP #3         (Do nothing)
  Find
Quote  
[-] The following 3 users say Thank You to seibaby for this post:
  • Gi Nattak (04-28-2016), madsiur (04-29-2016), Robo Jesus (10-16-2016)

#2
Posts: 378
Threads: 94
Thanks Received: 17
Thanks Given: 26
Joined: Jul 2013
Reputation: 11
Status
Charmed
Interesting. I guess the developers felt that if you had to have your item break, the spell they would produce would be stronger.
I'm still deciding whether I should use this or not, because of what I just said. I'll see what I do.


Step forward, spriters! We are also responsible to make hacks look new and fresh, we are no less important than code or ASM hackers! CHARGE!!
Quote  

#3
Posts: 281
Threads: 18
Thanks Received: 13
Thanks Given: 8
Joined: Mar 2014
Reputation: 8
Status
None
@Gi Nattak, upon rereading your PM I must admit I'm a bit confused as to what you're asking for exactly. I thought you meant breaking Rods, as Throwing a Rod doesn't cast a spell. However, Throwing a Skean does cast a spell.

Do you want to modify the behaviour of Thrown weapons? Or spells cast by Throwing a Skean/Edge? And are you only interested in Ignore Clear specifically?

EDIT: because if so, what you suggested works fine, I just tested it.
Code:
C2/1895: 80 03   BRA $189A    ;Set Ignore Clear
  Find
Quote  

#4
Posts: 378
Threads: 94
Thanks Received: 17
Thanks Given: 26
Joined: Jul 2013
Reputation: 11
Status
Charmed
I don't know about Gi but I sure am interested on the behavior on thrown weapons.


Step forward, spriters! We are also responsible to make hacks look new and fresh, we are no less important than code or ASM hackers! CHARGE!!
Quote  

#5
Posts: 281
Threads: 18
Thanks Received: 13
Thanks Given: 8
Joined: Mar 2014
Reputation: 8
Status
None
(04-28-2016, 09:20 AM)Kugawattan Wrote: Interesting. I guess the developers felt that if you had to have your item break, the spell they would produce would be stronger.
I'm still deciding whether I should use this or not, because of what I just said. I'll see what I do.

I forgot what it was you wanted to do. Something with Throw?
  Find
Quote  

#6
Posts: 378
Threads: 94
Thanks Received: 17
Thanks Given: 26
Joined: Jul 2013
Reputation: 11
Status
Charmed
Making Thrown items not ignore defense. Perhaps also slighty increase the damage multiplier to compensate this fact.
I have physically tough enemies often in my hack so I don't want the player to use an easy way out :P


Step forward, spriters! We are also responsible to make hacks look new and fresh, we are no less important than code or ASM hackers! CHARGE!!
Quote  

#7
Posts: 281
Threads: 18
Thanks Received: 13
Thanks Given: 8
Joined: Mar 2014
Reputation: 8
Status
None
Well why didn't you say so? I have a mod like that lying around, too! Laugh

To make Thrown weapons not ignore defense

Normally, Thrown weapons are treated as Items (which must ignore defense, row, safe/shell etc to work properly). The item usage setup code has a branch that separates non-magical items (Tools, Skeans that don't use a spell, and Thrown weapons) from magical items (Potions, etc.).

However, the setting of the Ignore Defense property occurs before that branch:
Code:
Original code:
C2/2A44: A9 21        LDA #$21
C2/2A46: 8D A2 11     STA $11A2     (Set to ignore defense, physical attack)

Modified code:
C2/2A44: A9 01        LDA #$01
C2/2A46: 8D A2 11     STA $11A2     (Set to physical attack)
Code:
C2/2A74: B0 66        BCS $2ADC     (branch if Skean or Item Magic or Tools)
Code:
Original code:
C2/2A76: A9 01        LDA #$01
C2/2A78: 1C A2 11     TRB $11A2     (Sets to magical attack)

Modified code:
C2/2A76: A9 20        LDA #$20
C2/2A78: 8D A2 11     STA $11A2     (Sets to ignore defense and magical attack)

Both the pieces of code before and after the branch simply set the variable 11A2 to different values.

the first bit (#$01) in $11A2 is 1 if physical (0 if magical)
the fifth bit (#$20) in $11A2 is 1 if the attack ignores defense

This is pretty much all we need to know to make this hack. Don't set ignore defense before the branch, only set physical attack. Set magical attack AND ignore defense after the branch. 
So, physical items will not ignore defense, but magical ones still will (so Potions will work properly). Note that this doesn't affect Skeans, since they call upon the magic code to cast a spell instead.

TRB just flips off the bits indicated in the accumulator, but we can't use it to flip one bit on and
the other off. It's okay though, nothing else has changed in $11A2 between the two instructions, so
we can use STA to just set it to a new value.

NOTE: making Thrown weapons not defense-ignoring also makes them do half damage to targets in the back Row, which obviously makes no sense for Throw. Unfortunately, the two properties are intertwined in the damage modification code and not easily separated. Fixing this issue requires a bigger hack, preferably one that allows the damage modification code to accept a byte as input, check each bit individually, and turn off or on the 7 different properties of damage modification accordingly. Then we could have attacks that ignore row, but not defense, or any other combination. Some day I may tackle that kind of hack...

If all of this is over your head, just copy and paste the following code into an .asm file and use xkas to apply the patch:
Code:
;Make Throw not Ignore Defense, Safe/Shell, Row, Defend, etc...

hirom         ;can't touch this DUUN DUN DUN DUN, DUN-DUN, DUN-DUN can't touch this
;header       ;uncomment if headered ROM

org $C22A44
LDA #$01
STA $11A2     ;(Set to physical attack)

org $C22A76
LDA #$20
STA $11A2     ;(Sets to ignore defense and magical attack)

By the way, the damage incrementor for Throw is here:
Code:
C2/188D: A9 02        LDA #$02
C2/188F: 85 BD        STA $BD        (Increment damage by 100%)
In other words, just grab a hex editor and change C2/188E from 02 to something slightly higher. Each increase by one increases damage by 50%.
  Find
Quote  

#8
Posts: 378
Threads: 94
Thanks Received: 17
Thanks Given: 26
Joined: Jul 2013
Reputation: 11
Status
Charmed
As friggin awesome as this looks like, I'm afraid I can't really use it if it doesn't ignore row...the character who can throw already specializes in long range attacking...


Step forward, spriters! We are also responsible to make hacks look new and fresh, we are no less important than code or ASM hackers! CHARGE!!
Quote  

#9
Posts: 1,633
Threads: 56
Thanks Received: 13
Thanks Given: 84
Joined: Apr 2014
Reputation: 12
Status
Atma
I thought Gi Nattak's problem was solved with Hatzen's patch on tools/scroll... maybe i'm wrong?
Nice patch anyway  Wink


THE GREATEST CHALLENGE OF ALL TIMES AWAITS:
http://www.ff6hacking.com/forums/showthr...p?tid=2593
DO YOU HAVE WHAT IT TAKES TO SLAY A GOD?
------------------------------------------------------------------------
Tenkarider's project #2 is started: FF6 Curse of the Madsiur Joke (CotMJ)
http://www.ff6hacking.com/forums/showthr...p?tid=2755
What happens when Madsiur tweaks your account? This full game hack will show that!
  Find
Quote  

#10
Posts: 281
Threads: 18
Thanks Received: 13
Thanks Given: 8
Joined: Mar 2014
Reputation: 8
Status
None
@Kugawattan: you misunderstand. Throw still does full damage from the back row. However, the TARGET'S row now modifies damage (as in, if the target hit with the thrown weapon is in the back row, they take half damage).

This should only be an issue with monsters using Throw on characters. I believe monsters always start out in the front row and can't change it (unless they're somehow hit with R.Polarity).

This applies to Morph and Defend, too, by the way (both halves damage taken). Again, not a big issue unless your mod relies heavily on monsters throwing pointy stuff at your characters.
  Find
Quote  



Forum Jump:

Users browsing this thread: 1 Guest(s)


Theme by Madsiur2017Custom Graphics by JamesWhite