Set Target Tiles

From Final Fantasy Hacktics Wiki
Revision as of 05:43, 18 March 2017 by Dokurider (talk | contribs) (More notes)
Jump to navigation Jump to search

Returns:

-1 - Unit doesn't exist or Ability ID > 0x0170
0 - Ability cannot Follow Target
1 - Ability can Follow/Hit Target
2 - This routine is supposed to be able to return 2, but the jumps supporting this return value bypass reloading r31 to jump back to routine, causing them to loop right back to this routine. At least that's what I'm interpreting. 
3 - Ability could not generate Range panels
[0x0017a8c0] addiu r29,r29,-0x0048
[0x0017a8c4] addiu r5,r29,0x0010
[0x0017a8c8] sw r31,0x0040(r29)
[0x0017a8cc] sw r21,0x003c(r29)
[0x0017a8d0] sw r20,0x0038(r29)
[0x0017a8d4] sw r19,0x0034(r29)
[0x0017a8d8] sw r18,0x0030(r29)
[0x0017a8dc] jal 0x0005e22c                 Transfer Target ID? Through Mount Data
[0x0017a8e0] sw r16,0x0028(r29)
[0x0017a8e4] lbu r3,0x0010(r29)
[0x0017a8e8] nop
[0x0017a8ec] sltiu r2,r3,0x0015
[0x0017a8f0] beq r2,r0,0x0017aa40
[0x0017a8f4] addu r16,r0,r0
[0x0017a8f8] sll r2,r3,0x03
[0x0017a8fc] subu r2,r2,r3
[0x0017a900] sll r2,r2,0x06
[0x0017a904] lui r3,0x8019
[0x0017a908] addiu r3,r3,0x08cc
[0x0017a90c] addu r17,r2,r3
[0x0017a910] lbu r3,0x0001(r17)
[0x0017a914] ori r2,r0,0x00ff
[0x0017a918] beq r3,r2,0x0017aacc
[0x0017a91c] addiu r2,r0,-0x0001
[0x0017a920] lbu r2,0x0011(r29)
[0x0017a924] lui r1,0x8006
[0x0017a928] addu r1,r1,r2
[0x0017a92c] lbu r3,0x5cb4(r1)
[0x0017a930] nop
[0x0017a934] sltiu r2,r3,0x0010
[0x0017a938] beq r2,r0,0x0017aa84
[0x0017a93c] sll r2,r3,0x02
[0x0017a940] lui r1,0x8017
[0x0017a944] addu r1,r1,r2
[0x0017a948] lw r2,0x4068(r1)
[0x0017a94c] nop
[0x0017a950] jr r2
[0x0017a954] nop
[0x0017a958] lhu r20,0x0012(r29)
[0x0017a95c] j 0x0017aa28
[0x0017a960] ori r16,r0,0x0001
[0x0017a964] lbu r2,0x0091(r17)
[0x0017a968] nop
[0x0017a96c] andi r2,r2,0x0008
[0x0017a970] bne r2,r0,0x0017a988
[0x0017a974] ori r18,r0,0x0004
[0x0017a978] lbu r3,0x0003(r17)
[0x0017a97c] ori r2,r0,0x005d
[0x0017a980] bne r3,r2,0x0017a990
[0x0017a984] nop
[0x0017a988] j 0x0017aa28
[0x0017a98c] ori r16,r0,0x0002
[0x0017a990] ori r18,r0,0x0001
[0x0017a994] j 0x0017aa28
[0x0017a998] ori r16,r0,0x0002
[0x0017a99c] lbu r2,0x003a(r17)
[0x0017a9a0] ori r16,r0,0x0002
[0x0017a9a4] j 0x0017aa28
[0x0017a9a8] ori r18,r2,0x0080
[0x0017a9ac] jal 0x001810a0
[0x0017a9b0] addu r4,r17,r0
[0x0017a9b4] sll r2,r2,0x03
[0x0017a9b8] lui r1,0x8019
[0x0017a9bc] addu r1,r1,r2
[0x0017a9c0] lbu r2,-0x0734(r1)
[0x0017a9c4] nop
[0x0017a9c8] andi r2,r2,0x003f
[0x0017a9cc] lui r1,0x8006
[0x0017a9d0] addu r1,r1,r2
[0x0017a9d4] lbu r20,-0x1630(r1)
[0x0017a9d8] j 0x0017aa28
[0x0017a9dc] ori r16,r0,0x0001
[0x0017a9e0] lbu r2,0x0018(r29)
[0x0017a9e4] nop
[0x0017a9e8] addiu r2,r2,-0x0026
[0x0017a9ec] sltiu r2,r2,0x000a
[0x0017a9f0] beq r2,r0,0x0017aa40
[0x0017a9f4] ori r16,r0,0x0001
[0x0017a9f8] lbu r2,0x0018(r29)
[0x0017a9fc] j 0x0017aa28
[0x0017aa00] addiu r20,r2,0x0026
[0x0017aa04] jal 0x0017a518                   Set targeting for weapon attack 2
[0x0017aa08] addiu r4,r29,0x0010
[0x0017aa0c] j 0x0017aa24
[0x0017aa10] addu r19,r2,r0
[0x0017aa14] jal 0x00179dc8                   Set Ability Targeting?
[0x0017aa18] addiu r4,r29,0x0010
[0x0017aa1c] addu r19,r2,r0
[0x0017aa20] ori r21,r0,0x0010
[0x0017aa24] ori r2,r0,0x0001
[0x0017aa28] bne r16,r2,0x0017aaa0
[0x0017aa2c] ori r2,r0,0x0002
[0x0017aa30] andi r3,r20,0xffff
[0x0017aa34] sltiu r2,r3,0x0170
[0x0017aa38] bne r2,r0,0x0017aa48
[0x0017aa3c] sll r2,r3,0x03
[0x0017aa40] j 0x0017aad0
[0x0017aa44] addiu r2,r0,-0x0001
[0x0017aa48] subu r2,r2,r3
[0x0017aa4c] sll r2,r2,0x01
[0x0017aa50] lui r3,0x8006
[0x0017aa54] addiu r3,r3,-0x0410
[0x0017aa58] addu r2,r2,r3
[0x0017aa5c] lbu r18,0x0000(r2)
[0x0017aa60] lbu r3,0x0003(r2)
[0x0017aa64] lbu r21,0x0004(r2)
[0x0017aa68] andi r2,r3,0x0002
[0x0017aa6c] beq r2,r0,0x0017aa8c
[0x0017aa70] nop
[0x0017aa74] bne r18,r0,0x0017aa8c
[0x0017aa78] andi r2,r3,0x0020
[0x0017aa7c] bne r2,r0,0x0017aa8c
[0x0017aa80] nop
[0x0017aa84] j 0x0017aad0
[0x0017aa88] ori r2,r0,0x0002
[0x0017aa8c] sh r20,0x0012(r29)
[0x0017aa90] jal 0x0017a290                     Set panels affected by ability?
[0x0017aa94] addiu r4,r29,0x0010
[0x0017aa98] addu r19,r2,r0
[0x0017aa9c] ori r2,r0,0x0002
[0x0017aaa0] bne r16,r2,0x0017aab8
[0x0017aaa4] addu r4,r17,r0
[0x0017aaa8] jal 0x0017a16c                     calculate ability range with map parameters?
[0x0017aaac] andi r5,r18,0x00ff
[0x0017aab0] addu r19,r2,r0
[0x0017aab4] ori r21,r0,0x0010
[0x0017aab8] bne r19,r0,0x0017aac8
[0x0017aabc] andi r2,r21,0x0010
[0x0017aac0] j 0x0017aad0
[0x0017aac4] ori r2,r0,0x0003
[0x0017aac8] sltu r2,r0,r2
[0x0017aacc] lw r31,0x0040(r29)
[0x0017aad0] lw r21,0x003c(r29)
[0x0017aad4] lw r20,0x0038(r29)
[0x0017aad8] lw r19,0x0034(r29)
[0x0017aadc] lw r18,0x0030(r29)
[0x0017aae0] lw r17,0x002c(r29)
[0x0017aae4] lw r16,0x0028(r29)
[0x0017aae8] addiu r29,r29,0x0048
[0x0017aaec] jr r31
[0x0017aaf0] nop


Notes

j 0x0017aad0

There are two jumps in this routine that bypass reloading r31. This looks like a mistake to me, because it would just jump right back to this routine once it hits jr r31. Need to investigate the conditions for hitting these jumps...