Hi guys,
I hope you can help me with my problem, as my knowledge about assembly is a bit... let's call it amateur newbie level, lol. Anyway, I was trying to change a couple ability subroutines to rebalance some overpowered (in my opinion) abilities like X-Fight or Magic Sword. In particular, I'm trying to make enemy defense matter in these cases, by using 'Defense = Defense /2' or 'Defense = Defense /4' instead of 'Defense = 0'. I already did it successfully for X-Fight by looking at the disassembly (thanks to all those who helped in uncovering all that, by the way):
Command modifications to damage
C2/83BD: A6 32 LDX $32
C2/83BF: BD 1F 20 LDA $201F,X
C2/83C2: 29 40 AND #$40
C2/83C4: F0 06 BEQ $83CC
C2/83C6: C2 20 REP #$20
C2/83C8: 06 50 ASL $50 (Damage = Damage * 2)
C2/83CA: E2 20 SEP #$20
C2/83CC: BD 1F 20 LDA $201F,X
C2/83CF: 29 20 AND #$20
C2/83D1: F0 07 BEQ $83DA
C2/83D3: C2 20 REP #$20
C2/83D5: 46 50 LSR $50 (Damage = Damage / 2)
C2/83D7: 7B TDC
C2/83D8: E2 20 SEP #$20
C2/83DA: BD 1F 20 LDA $201F,X
C2/83DD: 29 10 AND #$10
C2/83DF: F0 06 BEQ $83E7
C2/83E1: C2 20 REP #$20
C2/83E3: 06 52 ASL $52 (M = M * 2)
C2/83E5: E2 20 SEP #$20
C2/83E7: BD 1F 20 LDA $201F,X
C2/83EA: 29 08 AND #$08
C2/83EC: F0 07 BEQ $83F5
C2/83EE: C2 20 REP #$20
C2/83F0: 46 52 LSR $52 (M = M / 2)
C2/83F2: 7B TDC
C2/83F3: E2 20 SEP #$20
C2/83F5: BD 1F 20 LDA $201F,X
C2/83F8: 29 04 AND #$04
C2/83FA: F0 04 BEQ $8400
C2/83FC: 7B TDC
C2/83FD: AA TAX
C2/83FE: 86 54 STX $54 (Defense = 0)
C2/8400: A6 49 LDX $49
C2/8402: BD 65 20 LDA $2065,X (Target Creature Type = Human?)
C2/8405: 10 0F BPL $8416
C2/8407: A6 32 LDX $32
C2/8409: BD 1F 20 LDA $201F,X
C2/840C: 29 01 AND #$01
C2/840E: F0 06 BEQ $8416
C2/8410: C2 20 REP #$20
C2/8412: 06 50 ASL $50 (Damage = Damage * 2)
C2/8414: E2 20 SEP #$20
C2/8416: A6 49 LDX $49
C2/8418: BD 1E 20 LDA $201E,X
C2/841B: 10 07 BPL $8424 (If Target is Defending)
C2/841D: C2 20 REP #$20
C2/841F: 46 52 LSR $52 (M = M / 2)
C2/8421: 7B TDC
C2/8422: E2 20 SEP #$20
C2/8424: BD 1E 20 LDA $201E,X
C2/8427: 29 40 AND #$40
C2/8429: F0 04 BEQ $842F (If Target is Guarding)
C2/842B: 7B TDC
C2/842C: AA TAX
C2/842D: 86 50 STX $50 (Damage = 0)
C2/842F: 60 RTS
Now, from what I understand by looking at these pieces:
C2/83C8: 06 50 ASL $50 (Damage = Damage * 2)
C2/83D5: 46 50 LSR $50 (Damage = Damage / 2)
C2/83E3: 06 52 ASL $52 (M = M * 2)
C2/83F0: 46 52 LSR $52 (M = M / 2)
C2/83FE: 86 54 STX $54 (Defense = 0)
C2/842D: 86 50 STX $50 (Damage = 0)
it seems like the second byte is a certain stat/parameter, and the first byte is how that stat/parameter is modified.
So it seems the second byte meanings are: 50 is the parameter for damage, 52 is for Damage multiplier, and 54 is defense
And the first byte meanings are: 06 = multiply by 2, 46 = divide by 2, and 86 = set to 0, correct?
So all I did was change the '86 54' to '46 54', and the result was that X-Fight no longer ignores defense but instead uses half the enemy's defense (I playtested against Omega and his very impressive 190 defense). 'Simple enough' I thought, so I was trying to do the same with Magic Sword, yet for some reason it didn't seem to work. Here's the subroutine for Magic Sword:
Magic Sword Modifiers to Physical
C2/8684: A6 32 LDX $32
C2/8686: BD 50 20 LDA $2050,X
C2/8689: 1D 51 20 ORA $2051,X
C2/868C: 1D 52 20 ORA $2052,X
C2/868F: 85 4D STA $4D ($4D = Magic Sword Element)
C2/8691: 1D 53 20 ORA $2053,X
C2/8694: 1D 54 20 ORA $2054,X
C2/8697: 1D 55 20 ORA $2055,X
C2/869A: F0 02 BEQ $869E
C2/869C: E6 60 INC $60
C2/869E: BD 55 20 LDA $2055,X
C2/86A1: 10 12 BPL $86B5
C2/86A3: C2 20 REP #$20
C2/86A5: 18 CLC
C2/86A6: A5 50 LDA $50
C2/86A8: 69 64 00 ADC #$0064 (Damage = Damage + 100)
C2/86AB: 85 50 STA $50
C2/86AD: 46 54 LSR $54
C2/86AF: 46 54 LSR $54 (Defense = Defense / 4)
C2/86B1: 7B TDC
C2/86B2: E2 20 SEP #$20
C2/86B4: 60 RTS
C2/86B5: A6 49 LDX $49
C2/86B7: BD 30 20 LDA $2030,X (Target has Elemental Absorb?)
C2/86BA: 25 4D AND $4D
C2/86BC: F0 07 BEQ $86C5
C2/86BE: E6 62 INC $62
C2/86C0: 64 54 STZ $54 (Defense = 0)
C2/86C2: 64 55 STZ $55
C2/86C4: 60 RTS
C2/86C5: BD 32 20 LDA $2032,X (Target has Elemental Immunity?)
C2/86C8: 25 4D AND $4D
C2/86CA: F0 03 BEQ $86CF
C2/86CC: E6 56 INC $56 (Attack Misses)
C2/86CE: 60 RTS
C2/86CF: BD 33 20 LDA $2033,X (Target has Elemental Half?)
C2/86D2: 25 4D AND $4D
C2/86D4: F0 05 BEQ $86DB
C2/86D6: 46 53 LSR $53
C2/86D8: 66 52 ROR $52 (M = M / 2)
C2/86DA: 60 RTS
C2/86DB: BD 34 20 LDA $2034,X (Target has Elemental Weakness)
C2/86DE: 85 0E STA $0E
C2/86E0: A6 32 LDX $32
C2/86E2: 3D 52 20 AND $2052,X (Level 3 Magic Sword?)
C2/86E5: F0 26 BEQ $870D
C2/86E7: A6 49 LDX $49
C2/86E9: BD 65 20 LDA $2065,X
C2/86EC: 29 20 AND #$20 (Target Creature type = Heavy?)
C2/86EE: F0 0B BEQ $86FB
C2/86F0: C2 20 REP #$20
C2/86F2: 06 50 ASL $50
C2/86F4: 06 50 ASL $50 (Damage = Damage * 4)
C2/86F6: 64 54 STZ $54 (Defense = 0)
C2/86F8: E2 20 SEP #$20
C2/86FA: 60 RTS
C2/86FB: BD 1A 20 LDA $201A,X
C2/86FE: 29 02 AND #$02 (Target Status1 = Zombie?)
C2/8700: D0 31 BNE $8733
C2/8702: BD 1A 20 LDA $201A,X
C2/8705: 09 80 ORA #$80
C2/8707: 9D 1A 20 STA $201A,X (Inflict Dead Status on Target)
C2/870A: E6 61 INC $61
C2/870C: 60 RTS
C2/870D: A5 0E LDA $0E
C2/870F: 3D 51 20 AND $2051,X (Level 2 Magic Sword?)
C2/8712: F0 10 BEQ $8724
C2/8714: C2 20 REP #$20
C2/8716: A5 50 LDA $50
C2/8718: 0A ASL (Damage = Damage * 2)
C2/8719: 18 CLC
C2/871A: 65 50 ADC $50 Damage = Damage + Damage * 2
C2/871C: 85 50 STA $50
C2/871E: 7B TDC
C2/871F: 85 54 STA $54 Defense = 0
C2/8721: E2 20 SEP #$20
C2/8723: 60 RTS
C2/8724: A5 0E LDA $0E
C2/8726: 3D 50 20 AND $2050,X (Level 1 Magic Sword?)
C2/8729: F0 08 BEQ $8733
C2/872B: C2 20 REP #$20
C2/872D: 06 50 ASL $50 (Damage = Damage * 2)
C2/872F: 64 54 STZ $54 Defense = 0
C2/8731: E2 20 SEP #$20
C2/8733: 60 RTS
Here I am a bit confused as to the meaning of certain operations, because according to this description, there are several different ways to write 'Defense = 0'.
In the Magic Sword Level 1 and Level 3 blocks: 64 54
In the Magic Sword Level 2 block: 85 54
In the command modification subroutine: 86 54
Three different values, yet according to this disassembly, all of them mean 'Defense = 0'?
My first attempt was to replace all these bold bytes with 46 (which I identified as 'divide by 2' above), but this didn't seem to work. The damage from an elemental-charged Magic Sword was still ignoring defense completely, so I must be missing something. Any ideas? As I said I'm just a beginner with no assembly knowledge at all, so any help is greatly appreciated.