Target spritesheet calculations?

From Final Fantasy Hacktics Wiki
Revision as of 03:34, 24 October 2021 by Talcall (talk | contribs)
Jump to navigation Jump to search

Calculates which attacking animation to use based on the height difference of attacker and target. if for some reason a weapon is trying to use a swinging weapon, it defaults to animation 0x7A.

0008288c: 27bdffe0 addiu r29,r29,0xffe0
00082890: afb10014 sw r17,0x0014(r29)
00082894: 00808821 addu r17,r4,r0			r17 = misc data
00082898: afb20018 sw r18,0x0018(r29)
0008289c: 00a09021 addu r18,r5,r0			r18 = misc data
000828a0: afbf001c sw r31,0x001c(r29)
000828a4: 12200060 beq r17,r0,0x00082a28
000828a8: afb00010 sw r16,0x0010(r29)
000828ac: 12400055 beq r18,r0,0x00082a04
000828b0: 00000000 nop
000828b4: 92220006 lbu r2,0x0006(r17)		load attacker spritesheet
000828b8: 00000000 nop
000828bc: 2c42009b sltiu r2,r2,0x009b
000828c0: 14400006 bne r2,r0,0x000828dc		branch if not WEP/EFF sheet
000828c4: 3402000c ori r2,r0,0x000c
000828c8: 3c048009 lui r4,0x8009
000828cc: 90844365 lbu r4,0x4365(r4)		Load unit animation from here? (0x3e?)
000828d0: 86250070 lh r5,0x0070(r17)		load attack facing
000828d4: 08020a88 j 0x00082a20
000828d8: 00000000 nop
000828dc: 9224013b lbu r4,0x013b(r17)		load height mod
000828e0: 00000000 nop
000828e4: 14820009 bne r4,r2,0x0008290c		branch if not 0x0c
000828e8: 00000000 nop
000828ec: 0c06c118 jal 0x001b0460			--> 001b0460 - 001b04d8 returns r2 based on whatever... arctan is doing.
000828f0: 00000000 nop
000828f4: 3c018009 lui r1,0x8009
000828f8: 00220821 addu r1,r1,r2
000828fc: 90244388 lbu r4,0x4388(r1)		Loads 53, 54, or 55 depending on ^ that nonsense up there. (animations seem to be swinging up, 53 and 54 just barely, 55 way up)
00082900: 86250070 lh r5,0x0070(r17)		load attack facing
00082904: 08020a88 j 0x00082a20		Save animation and facing
00082908: 00000000 nop
0008290c: 8e420134 lw r2,0x0134(r18)		attacker? data
00082910: 00000000 nop
00082914: 9043018e lbu r3,0x018e(r2)		load evade type
00082918: 00000000 nop
0008291c: 1060000e beq r3,r0,0x00082958		branch if hit
00082920: 28620009 slti r2,r3,0x0009
00082924: 1440000c bne r2,r0,0x00082958		branch if < 0x09 (hit, guarded, arrow guard, nullified, missed, caught, cancelled by status)
00082928: 2862000c slti r2,r3,0x000c
0008292c: 1040000a beq r2,r0,0x00082958		branch if > 0x0c (error return)
00082930: 2862000a slti r2,r3,0x000a
00082934: 14400008 bne r2,r0,0x00082958		branch if 0x09 (reflected)
00082938: 00041040 sll r2,r4,0x01		r2 = height mod * 2
0008293c: 00441021 addu r2,r2,r4		height mod * 3
00082940: 3c018009 lui r1,0x8009
00082944: 00220821 addu r1,r1,r2
00082948: 90244364 lbu r4,0x4364(r1)		load change in animation for height mod of not 0xc? (0x3d, links to swinging really far down)
0008294c: 86250070 lh r5,0x0070(r17)		load attack facing
00082950: 08020a88 j 0x00082a20		jump to end
00082954: 00000000 nop
00082958: 92240004 lbu r4,0x0004(r17)		load unit misc ID
0008295c: 0c02371d jal 0x0008dc74			-->0008dc74 - 0008dc98 - Finds attacker's misc unit data, and their height.
00082960: 00000000 nop
00082964: 000287c2 srl r16,r2,0x1f		
00082968: 02028021 addu r16,r16,r2		compiler bullshit
0008296c: 00108043 sra r16,r16,0x01		r16 = attacker height / 2
00082970: 96220042 lhu r2,0x0042(r17)		load height mod
00082974: 92440004 lbu r4,0x0004(r18)		load unit misc ID
00082978: 0c02371d jal 0x0008dc74			-->0008dc74 - 0008dc98 - Finds target's misc unit data, and their height
0008297c: 02028023 subu r16,r16,r2		r16 = height / 2 - height mod
00082980: 00021fc2 srl r3,r2,0x1f
00082984: 00621821 addu r3,r3,r2
00082988: 00031843 sra r3,r3,0x01
0008298c: 00108400 sll r16,r16,0x10
00082990: 96420042 lhu r2,0x0042(r18)		load height mod
00082994: 00108403 sra r16,r16,0x10
00082998: 00621823 subu r3,r3,r2
0008299c: 00031c00 sll r3,r3,0x10
000829a0: 00031c03 sra r3,r3,0x10
000829a4: 02038023 subu r16,r16,r3		find the difference in height between the two units.
000829a8: 2a02fff5 slti r2,r16,-0x000b		r2 = true if < -0xb
000829ac: 1040000a beq r2,r0,0x000829d8	branch if > -0xb
000829b0: 2a02000c slti r2,r16,0x000c		r2 = true if < 0xc
000829b4: 9223013b lbu r3,0x013b(r17)		load height mod for animation
000829b8: 86250070 lh r5,0x0070(r17)		load attack facing
000829bc: 00031040 sll r2,r3,0x01
000829c0: 00431021 addu r2,r2,r3		height mod * 3
000829c4: 3c018009 lui r1,0x8009
000829c8: 00220821 addu r1,r1,r2
000829cc: 90244364 lbu r4,0x4364(r1)		load change in animation based on ^ that mess
000829d0: 08020a88 j 0x00082a20
000829d4: 00000000 nop
000829d8: 1440000a bne r2,r0,0x00082a04		Branch if difference in unit heights is < 0xc
000829dc: 00000000 nop
000829e0: 9223013b lbu r3,0x013b(r17)		load height mod for attack
000829e4: 86250070 lh r5,0x0070(r17)		load facing
000829e8: 00031040 sll r2,r3,0x01
000829ec: 00431021 addu r2,r2,r3
000829f0: 3c018009 lui r1,0x8009
000829f4: 00220821 addu r1,r1,r2
000829f8: 90244366 lbu r4,0x4366(r1)		load change in animation based on height mod
000829fc: 08020a88 j 0x00082a20
00082a00: 00000000 nop
00082a04: 9223013b lbu r3,0x013b(r17)		Load height mod
00082a08: 86250070 lh r5,0x0070(r17)		Load facing
00082a0c: 00031040 sll r2,r3,0x01
00082a10: 00431021 addu r2,r2,r3
00082a14: 3c018009 lui r1,0x8009
00082a18: 00220821 addu r1,r1,r2
00082a1c: 90244365 lbu r4,0x4365(r1)		load change in animation based on that height mod
00082a20: 0c020662 jal 0x00081988			store unit animation + facing
00082a24: 02203021 addu r6,r17,r0
00082a28: 8fbf001c lw r31,0x001c(r29)
00082a2c: 8fb20018 lw r18,0x0018(r29)
00082a30: 8fb10014 lw r17,0x0014(r29)
00082a34: 8fb00010 lw r16,0x0010(r29)
00082a38: 27bd0020 addiu r29,r29,0x0020
00082a3c: 03e00008 jr r31
00082a40: 00000000 nop