Start searching for Highest Target Priority (0019c280)

From Final Fantasy Hacktics Wiki
Revision as of 01:49, 9 March 2017 by Dokurider (talk | contribs) (Updated documentation)
Jump to navigation Jump to search
Find Highest Target Priority
0019c280: 27bdfff0 addiu r29,r29,0xfff0
0019c284: 3c0d7fff lui r13,0x7fff
0019c288: 35adffff ori r13,r13,0xffff				r13 = Highest Current Target Priority (default value is 0x7fffffff)
0019c28c: 00005821 addu r11,r0,r0
0019c290: 0000c021 addu r24,r0,r0
0019c294: 3c08801a lui r8,0x801a
0019c298: 2508f3c4 addiu r8,r8,0xf3c4				r8 = Unit AI Data Pointer
0019c29c: 01007821 addu r15,r8,r0
0019c2a0: 01007021 addu r14,r8,r0
<Map Level Loop>
0019c2a4: 91020e3b lbu r2,0x0e3b(r8)				Load Max Y
0019c2a8: 00000000 nop
0019c2ac: 1840002d blez r2,0x0019c364				<Map Level++> if Max Y is negative
0019c2b0: 00003821 addu r7,r0,r0
0019c2b4: 0300c821 addu r25,r24,r0
0019c2b8: 25ea05f4 addiu r10,r15,0x05f4				r10 =
0019c2bc: 25c90b94 addiu r9,r14,0x0b94				r9 = Current Unit Target Priority
<Y Loop>
0019c2c0: 95230000 lhu r3,0x0000(r9)				Load Target Priority	
0019c2c4: 00000000 nop
0019c2c8: 10600020 beq r3,r0,0x0019c34c				<Y++> if Priority hasn't been set
0019c2cc: 00000000 nop
0019c2d0: 91020e3a lbu r2,0x0e3a(r8)				Load Max X
0019c2d4: 00000000 nop
0019c2d8: 1840001c blez r2,0x0019c34c				Branch if Max X is negative
0019c2dc: 00002821 addu r5,r0,r0
0019c2e0: 00606021 addu r12,r3,r0					r12 = Current Unit Target Priority
0019c2e4: 03281021 addu r2,r25,r8
0019c2e8: 24420174 addiu r2,r2,0x0174
0019c2ec: 00071900 sll r3,r7,0x04
0019c2f0: 00621821 addu r3,r3,r2
0019c2f4: 01403021 addu r6,r10,r0
<X Loop>
0019c2f8: 00ac1004 sllv r2,r12,r5					Target Priority >> Current X
0019c2fc: 30428000 andi r2,r2,0x8000
0019c300: 1040000c beq r2,r0,0x0019c334				Branch if this cell is not the current unit's cell
0019c304: 00000000 nop
0019c308: 84c40000 lh r4,0x0000(r6)
0019c30c: 90620000 lbu r2,0x0000(r3)
0019c310: 00042400 sll r4,r4,0x10
0019c314: 00822021 addu r4,r4,r2
0019c318: 01a4102a slt r2,r13,r4
0019c31c: 14400005 bne r2,r0,0x0019c334					Branch if this unit has a higher priority then the current highest
0019c320: 00000000 nop
0019c324: 00806821 addu r13,r4,r0						Set Current Unit as Current Highest Unit Priority
0019c328: a1050018 sb r5,0x0018(r8)						Save New Coordinates
0019c32c: a107001a sb r7,0x001a(r8)
0019c330: a10b0019 sb r11,0x0019(r8)
<X++>
0019c334: 24630001 addiu r3,r3,0x0001
0019c338: 91020e3a lbu r2,0x0e3a(r8)
0019c33c: 24a50001 addiu r5,r5,0x0001
0019c340: 00a2102a slt r2,r5,r2
0019c344: 1440ffec bne r2,r0,0x0019c2f8					Loop Max X times
0019c348: 24c60002 addiu r6,r6,0x0002
<Y++>
0019c34c: 254a0020 addiu r10,r10,0x0020
0019c350: 91020e3b lbu r2,0x0e3b(r8)
0019c354: 24e70001 addiu r7,r7,0x0001
0019c358: 00e2102a slt r2,r7,r2
0019c35c: 1440ffd8 bne r2,r0,0x0019c2c0					Loop Max Y times
0019c360: 25290002 addiu r9,r9,0x0002
<Map Level++>
0019c364: 27180120 addiu r24,r24,0x0120					
0019c368: 25ef0240 addiu r15,r15,0x0240
0019c36c: 256b0001 addiu r11,r11,0x0001
0019c370: 29620002 slti r2,r11,0x0002
0019c374: 1440ffcb bne r2,r0,0x0019c2a4					Loop twice
0019c378: 25ce0024 addiu r14,r14,0x0024
<Save ? to Unit Matrix Coordinates>
0019c37c: 91030019 lbu r3,0x0019(r8)					Load Unit Coordinates of highest Target Priority
0019c380: 9104001a lbu r4,0x001a(r8)
0019c384: 91050018 lbu r5,0x0018(r8)
0019c388: 000310c0 sll r2,r3,0x03
0019c38c: 00431021 addu r2,r2,r3
0019c390: 00021080 sll r2,r2,0x02
0019c394: 00481021 addu r2,r2,r8
0019c398: 24420b94 addiu r2,r2,0x0b94
0019c39c: 00042040 sll r4,r4,0x01
0019c3a0: 00822021 addu r4,r4,r2
0019c3a4: 34038000 ori r3,r0,0x8000
0019c3a8: 94820000 lhu r2,0x0000(r4)
0019c3ac: 00a31807 srav r3,r3,r5
0019c3b0: 00431026 xor r2,r2,r3
0019c3b4: a4820000 sh r2,0x0000(r4)
0019c3b8: 91020cbc lbu r2,0x0cbc(r8)
0019c3bc: 00000000 nop
0019c3c0: 2442ffff addiu r2,r2,0xffff
0019c3c4: a1020cbc sb r2,0x0cbc(r8)
0019c3c8: 27bd0010 addiu r29,r29,0x0010
0019c3cc: 03e00008 jr r31
0019c3d0: 00000000 nop