Users browsing this thread: 1 Guest(s)
Changing and Replacing Combat Functions via Special Effects

#2
Posts: 61
Threads: 18
Thanks Received: 1
Thanks Given: 47
Joined: May 2014
Status
None
I've got two new special effects for us that work and one that doesn't work but seems very close to doing so.

FIRST REPLACEMENT - New Special Effect $14 - Mpwr^2/8 Added to damage

Code:
C2/3DF5: 8C 38 --> 90 67     Special ($14h) [20] now points to 6790
C2/4309: 8A 3E --> 90 67     Special ($14h) [20] now points to 6790

\\We changed both pointer tables because it looks like only the second one works for the spell during testing\\

C2/6790: E2 20        SEP #$20    (Set 8-bit Accumulator)
C2/6792: AD A0 11     LDA $11A0   (Mpwr)
C2/6795: EB           XBA
C2/6796: AD A0 11     LDA $11A0   (Mpwr)
C2/6799: 20 81 47     JSR $4781   (Multiply them together Mpwr * Mpwr)
C2/679C: C2 20           REP #$20    (Set 16-bit Accumulator)
C2/679E: 4A           LSR
C2/679F: 4A           LSR
C2/67A0: 4A           LSR      (Divide by 8)
C2/67A1: 18          CLC
C2/67A2: 6D B0 11     ADC $11B0   (Add to damage)
C2/67A5: 8D B0 11     STA $11B0   (Store in maximum damage)
C2/67A6: 60           RTS

Notice that I use XBA and JSR $4781 to multiply the $11A0 Mpwr together.  I then tried using $11A0 and $11A6....and it didn't work to create Mpwr*Vigor.  I have the same situation for the next formula below---I get a bit more daring by using the Y index to Lvl^2, but I have a suspicion that other data near those values (3B18) don't work when called by special effects.

The XBA and JSR technique was stolen from the Flare Star code, which I'll discuss in detail for my third, huge, formula:

SECOND REPLACEMENT - $03 - Lvl*Lvl Added to Damage


Code:
C2/3DD3: 43 3D ($03) --> B0 67   (jump to $67B0 as new special effect $03, 4th in weapon sfx menu in FF3usME,
                  replacing kill with X)
C2/42E7: 8A 3E ---->     B0 67

C2/67B0: E2 20        SEP #$20    (Set 8-bit Accumulator)
C2/67B2: B9 18 3B     LDA $3B18,Y (Level of attacker)
C2/67B5: EB           XBA
C2/67B6: B9 18 3B     LDA $3B18,Y (Level of attacker)
C2/67B9: 20 81 47     JSR $4781   (Multiply them together level * level)
C2/67BC: C2 20           REP #$20    (Set 16-bit Accumulator)
C2/67BE: 18          CLC
C2/67BF: 6D B0 11     ADC $11B0   (Add to damage)
C2/67C2: 8D B0 11     STA $11B0   (Store in maximum damage)
C2/67C5: 60           RTS

But first let's talk about how insanely great this is.  Would you rather have a sword that breaks, like ogre nix, or a sword that adds damage based on your Mpwr?  The limits of interesting combat are quickly destroyed with the prismatic expansion of damage formulas.  Do you really like having exploder in your Lore list?

But how much can we change?  I've recently read a lot of the Programming the 65816 document and have, of course, made some formulas that are much more sophisticated than a squared hero statistic.  This one isn't super sophisticated but it doesn't just do damage = your HP or dmg+HP, it does [(HP/64+1)+(MP/16+1)]^2 and replaces the damage from normal formulas:

Code:
HP+MP Damage Formula

OpCode        Registers->  X   B       A    Summary with comments    
C2 20        REP #20                16-bit mode    
B9 F4 3B    LDA, Y $3BF4            LDA, Y    HP
4A                        LSR    Divide by 2
4A                        LSR    4
4A                        LSR    8
4A                        LSR    16
4A                        LSR    32
4A                        LSR    64
1A                        INC    HP/64+1
48                        PHA    
B9 08 3C    LDA, Y $3C08            LDA, Y    MP
4A                        LSR    Divide by 2
4A                        LSR    4
4A                        LSR    8
4A                        LSR    16
1A                        INC    MP/16+1
8D 18 A7    STA $7A18            STA    Store at two bytes
68                        PLA    A=HP/64+1
18                        CLC    Clear carry before adding
6D 18 A7    ADC $7A18        HP+MP    ADC    Add stored MP/16+1
4A                        LSR    Divide by 2
E2 20        SEP #$20        HP+MP    8bit mode    
8D 18 A7    STA$7A18            STA    Store HP+MP at two bytes (A byte if 8-bit mode!)
EB        XBA        HP+MP        XBA    
18                        CLC    
6D 18 A7    ADC $7A18    HP+MP    HP+MP    ADC    Add stored HP+MP
C2 20        REP #20                16bit    
20 81 47    JSR $4781            JSR    Multiply them together
0A                        ASL    x2
8D 18 A7    STA $A718            STA    Store big value HP+MP at two bytes
B9 F4 3B    LDA, Y $3BF4            LDA, Y    HP
4A                        LSR    Divide by 2
4A                        LSR    4
18                        CLC    Clear carry before adding
6D 18 A7    ADC $A718            ADC    Add stored HP+MP
90 03        BCC +4                BCC    If carry wasn't set, overflow did not occur
A9 FF FF    ADC #$65535            LDA    Replace with 65535
8D B0 11    STA $11B0            STA    Store to replace dmg at 11B0
60                        RTS

And this time, for some reason, the formula doesn't work.  This code loads HP and MP data, reduces them to a # which will not exceed 1 byte, then goes into 8-bit mode to do the XBA JSR trick again.  The XBA trick swaps the high byte and low byte of the accumulator, with one of them (the high byte, I believe) referred to as "B" when in 8bit-mode, because there is no 2nd byte in 8bit-mod, but the space (and thus, the hex values there) is still there, it just isn't touched.  When you swap the low byte and high byte, you can multiply or divide the value by 256, or you can use the JSR $4781 multiplication subroutine to multiply the two bytes together, with the result in 16bit A.

The formula of this type is much more powerful because it multiplies 2 byte values like HP and MP together, although it's not perfectly ideal because I believe there is a lot of rounding down that occurs.

So why do the first two formulas work and this one doesn't? The same HP value is called by Valiant Knife, so that should be fine---but when I change the hero stats to be $11A0 (Mpwr) instead, the formula works brilliantly.

Does anyone know the values that can or can't be loaded during combat?
Below is the quick list of values I've found throughout C2:

Quote:    Speed (hero) - $11A4
    Stamina (hero) -  $11A2
    Magic Power of hero -  $11A0
    Vigor of hero - $11A6 -->Actually Vigor or BP or SP I think in some cases. Careful, this gets changed
    Vigor*2 or Mpwr - $11AE (this is weird)
    Level of attacker - $11AF (probably hero only)
    MDef - $3BB9,Y @ C/20CCC after    damage mod
    Def - $3BB8,Y
    HP of Hero - $3BF4, Y
    MP of Hero - $3C08,Y
    Max HP - $3C1C,Y (for hero only?)
    $3C1D,Y - High byte of Max HP (for hero only?)
    $3BF4,Y - HP (for hero only?)
    $3BF5,Y - High byte of HP (for hero only?)
    $3B2C,X - (attacker Vigor * 2)
    $11A8 - Hit rate (of spell checking for stamina blocking)
    $3C08,X - (MP)
    $3C30,X - (Max MP)


I should also mention that in this code, Y seems to be the attacker and X the target, but it seems extremely difficult to track the source of what's in the X or Y registers.
(Note: On the site the code text looks jilted but when editing it the code and comments are perfectly straight)
(To use these formulas by the way, FF3usME has the special effect box on the right when looking at a spell, and the special effect drop-down menu for weapons.  The first formula here is effect $14 in the spell menu, the 2nd is the "0x3" special effect for weapons, replacing the "Kill with X" effect.)
  Find
Quote  



Messages In This Thread
RE: Changing and Replacing Combat Functions via Special Effects - by ReturnerScum - 02-27-2016, 12:35 PM

Forum Jump:

Users browsing this thread: 1 Guest(s)


Theme by Madsiur2017Custom Graphics by JamesWhite