001af3a4 - 001af3d8

From Final Fantasy Hacktics Wiki
Revision as of 21:13, 28 January 2022 by Orkney (talk | contribs)
Jump to navigation Jump to search
Little math routine dedicated to arcing weapon trajectory

Parameters : r4 = (Attacker to target distance)*4096 = [AT distance]*4096

Returns : r2 = 0x54000 - ([AT distance]² *4096/336)
-------------------------------------------------------------------------------------------
001af3a4: 00042183 sra r4,r4,0x06           |r4 = [AT distance]*64
001af3a8: 00840018 mult r4,r4               | ([AT distance]*64)^2
001af3ac: 3c03801c lui r3,0x801c            |r3 = 0x801c0000
001af3b0: 8c638878 lw r3,-0x7788(r3)        |r3 = gravity mod ? 0xa8000 (12*28*2048) Higher value send arrow in the sky, but less far
001af3b4: 00001012 mflo r2                  |r2 = [AT distance]² * 4096
001af3b8: 000322c3 sra r4,r3,0x0b           |r4 = 0xa8000 / 2048 = 12*28
001af3bc: 00000000 nop                      |
001af3c0: 0044001a div r2,r4                |[AT distance]²* 4096 / 336
001af3c4: 00001012 mflo r2                  |r2 = [AT distance]²  * 4096 / 336
001af3c8: 000327c2 srl r4,r3,0x1f           |r4 = r3/ 2^31 = 0x00
001af3cc: 00641821 addu r3,r3,r4            |r3 = gravity mod + 0x00
001af3d0: 00031843 sra r3,r3,0x01           |r2 = gravity mod / 2 (0x54000)
001af3d4: 03e00008 jr r31                   |
001af3d8: 00621023 subu r2,r3,r2            |r2 = 0x54000 - ([AT distance]² *4096/336) = ([AT distance]² *12 ?) a height ?

Wiki Search flag

uses 0x801b8878 flagged as gravity mod  ( 801b8878 )

Return location

Battle.bin
001af434:

SCUS
None