øAslickproductions.org/forum/index.php?PHPSESSID=5f0fck550j2m4m2fpbtkj2vkm1&topic=2017.0e:/My Web Sites/Slick Productions - FFIV Message Board/slickproductions.org/forum/index904c-2.htmlslickproductions.org/forum/index.php?PHPSESSID=5f0fck550j2m4m2fpbtkj2vkm1&board=8.140e:/My Web Sites/Slick Productions - FFIV Message Board/slickproductions.org/forum/index904c-2.html.zxÀ%h^ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÈð�‚jOKtext/htmlISO-8859-1gzip8:Ö‚jÿÿÿÿÿÿÿÿTue, 10 Mar 2020 23:58:17 GMT0ó°° ®0®P®€§²ð®À%h^¼‚j FF6 damage formula

Author Topic: FF6 damage formula  (Read 1106 times)

dn

  • Ymir
  • *
  • Posts: 14
    • View Profile
FF6 damage formula
« on: March 02, 2015, 06:06:42 PM »
Does anybody know how to get the "lost byte" in the damage formula to calculate correctly without simply capping it to 16-bits?
For reference:
Code: [Select]
C2/2BCE: E2 20        SEP #$20    (Set 8-bit Accumulator)
C2/2BD0: 6D AE 11     ADC $11AE   (add Vigor * 2 if character, or Vigor if monster)
C2/2BD3: EB           XBA
C2/2BD4: 69 00        ADC #$00    (add carry from the bottom byte of Attack
                                   into the top byte)
C2/2BD6: EB           XBA
C2/2BD7: 20 B7 47     JSR $47B7   (get 16-bit "Attack" * 8-bit level, and put
                                   24-bit product in Variables $E8 thru $EA)
C2/2BDA: A5 E8        LDA $E8
C2/2BDC: 85 EA        STA $EA     (use top byte of result as temporary variable,
                                   since it's generally 0 anyway.
                                   to see why that's a bad idea, keep reading.)
C2/2BDE: 68           PLA
C2/2BDF: 85 E8        STA $E8     (get attacker level again)
C2/2BE1: C2 20        REP #$20    (Set 16-bit Accumulator)
C2/2BE3: A5 E9        LDA $E9
C2/2BE5: EB           XBA         (A = bottom two bytes of the first multiplication
                                   result..  typically, we'll always have zero in the
                                   top byte, so we can ignore it.  but with a 255
                                   Battle Power weapon, Gauntlet, and a character at
                                   Level 99 with 128 Vigor, that product WILL need 3
                                   bytes.  failure to use that top byte in our next
                                   multiplication means we'll lose a lot of damage.
                                   BUG!)

C2/2BE6: 20 B7 47     JSR $47B7   (multiply 16-bit result of [Level * Attack] by
                                   our 8-bit level again, and put the new 24-bit
                                   product in Variables $E8 thru $EA.
                                   16-bit A will hold the new product DIV 256.)
C2/2BE9: 8D B0 11     STA $11B0   (Maximum Damage)
The original physical damage formula (which I am using as the basis) is:
Attack = Battle Power + (Vigor * 2).  Vigor * 2 is capped at 255.
$11B0 = Battle Power + ( (Level * Level * Attack) DIV 256 )

I've been wrestling for MONTHS trying to get a new damage formula in, roughly based on the original with different weights, and I lose the highest byte no matter what I do.

assassin

  • Bane of Retards
  • *
  • Posts: 1,033
  • space bears are not gentle!
    • View Profile
    • My Barren Webpage
Re: FF6 damage formula
« Reply #1 on: March 02, 2015, 06:23:56 PM »

dn

  • Ymir
  • *
  • Posts: 14
    • View Profile
Re: FF6 damage formula
« Reply #2 on: March 02, 2015, 06:30:10 PM »
Ahh, thanks. I knew I had seen an overflow fix somewhere, but I had forgotten where, and the only one I was able to find simply capped it at a 16-bit value.