FF6 Hacking
Magitek cost magic points - Printable Version

+- FF6 Hacking (https://www.ff6hacking.com/forums)
+-- Forum: Discussion Forums (https://www.ff6hacking.com/forums/forum-5.html)
+--- Forum: Magitek Research Facility (https://www.ff6hacking.com/forums/forum-9.html)
+--- Thread: Magitek cost magic points (/thread-1172.html)



Magitek cost magic points - ppml - 10-17-2011

There is a possibility that the Magitek command (Heald Force Tek Missile, Fire Beam, etc.) consume magic points? Try to modify it but in the battle FF3usme magic points do not decrease, as is this accomplished?


RE: Magitek cost magic points - Angelo26 - 10-17-2011

Even though you mark the option in usME, the game's code is not recognizing it...here's why:

Code:
(Determine MP cost of a spell/attack)

C2/4F08: DA           PHX
C2/4F09: 08           PHP
C2/4F0A: 7B           TDC        (16-bit A = 0.  this means the returned spell cost will
                                  default to zero.)
C2/4F0B: A9 40        LDA #$40
C2/4F0D: 14 B1        TRB $B1
C2/4F0F: D0 42        BNE $4F53

C2/4F11: AD 7A 3A     LDA $3A7A  (get command #)
C2/4F14: C9 19        CMP #$19
C2/4F16: F0 0C        BEQ $4F24  (branch if it's Summon)
C2/4F18: C9 0C        CMP #$0C
C2/4F1A: F0 08        BEQ $4F24  (branch if it's Lore)
C2/4F1C: C9 02        CMP #$02
C2/4F1E: F0 04        BEQ $4F24  (branch if it's Magic)
C2/4F20: C9 17        CMP #$17
C2/4F22: D0 2F        BNE $4F53  (branch if it's not X-Magic)
C2/4F24: C2 10        REP #$10   (Set 16-bit X and Y)
C2/4F26: AD 7B 3A     LDA $3A7B  (get attack #)
C2/4F29: E0 08 00     CPX #$0008
C2/4F2C: B0 19        BCS $4F47  (branch if it's a monster attacker.  they don't have
                                  menus containing MP data, nor relics that can
                                  alter MP costs.)
C2/4F2E: DA           PHX
C2/4F2F: AA           TAX
C2/4F30: BD 84 30     LDA $3084,X  (get this spell's index relative to start of Magic menu?
                                    i believe the Lore menu follows the Magic menu in memory.)
C2/4F33: FA           PLX
C2/4F34: C9 FF        CMP #$FF
C2/4F36: F0 1B        BEQ $4F53   (if it's somehow not in the menu, branch?)
C2/4F38: C2 20        REP #$20    (Set 16-bit Accumulator)
C2/4F3A: 0A           ASL
C2/4F3B: 0A           ASL         (multiply offset by 4, as each spell menu entry has 4 bytes:
                                    Spell index number, Unknown [related to spell availability],
                                    Spell aiming, MP cost)
C2/4F3C: 7D 2C 30     ADC $302C,X (add starting address of character's Magic menu?)
C2/4F3F: AA           TAX
C2/4F40: E2 20        SEP #$20    (Set 8-bit Accumulator)
C2/4F42: BD 03 00     LDA $0003,X (get MP cost from character's menu data.  it usually
                                   matches the spell data, but Gold Hairpin, Economizer,
                                   and Step Mine's special formula can make it vary.)
C2/4F45: 80 0D        BRA $4F54   (clean up stack and exit)
C2/4F47: EB           XBA
C2/4F48: A9 0E        LDA #$0E
C2/4F4A: 20 81 47     JSR $4781   (attack # * 14)
C2/4F4D: AA           TAX
C2/4F4E: BF C5 6A C4  LDA $C46AC5,X  (read MP cost from spell data)
C2/4F52: EB           XBA
C2/4F53: EB           XBA
C2/4F54: 28           PLP
C2/4F55: FA           PLX
C2/4F56: 60           RTS

Look at this specific code now:
Code:
C2/4F11: AD 7A 3A     LDA $3A7A  (get command #)
C2/4F14: C9 19        CMP #$19
C2/4F16: F0 0C        BEQ $4F24  (branch if it's Summon)
C2/4F18: C9 0C        CMP #$0C
C2/4F1A: F0 08        BEQ $4F24  (branch if it's Lore)
C2/4F1C: C9 02        CMP #$02
C2/4F1E: F0 04        BEQ $4F24  (branch if it's Magic)
C2/4F20: C9 17        CMP #$17
C2/4F22: D0 2F        BNE $4F53  (branch if it's not X-Magic)

If the command is summon, lore, magic or Xmagic, the game will pull the MP cost for the spell/attack; otherwise, it won't.