Sort target list

From Final Fantasy Hacktics Wiki
Revision as of 20:31, 16 November 2021 by Orkney (talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search
r4 = target ID
Erase unit ID from target list, shifting all the remaining units
--------------------------------
0018ed7c: 00001821 addu r3,r0,r0            |r3 = 0x00
0018ed80: 308400ff andi r4,r4,0x00ff        |r4 = Target ID last bytes
0018ed84: 3c068019 lui r6,0x8019            |
0018ed88: 24c63877 addiu r6,r6,0x3877       |r6 = End of target list
0018ed8c: 340500ff ori r5,r0,0x00ff         |r5 = 0xff
0018ed90: 3c018019 lui r1,0x8019            @ LOOP 1 - Seek target in target list
0018ed94: 00230821 addu r1,r1,r3                 |r1 = 0x8019 + loop counter
0018ed98: 90223868 lbu r2,0x3868(r1)             |r2 = Target list beginning + loop counter
0018ed9c: 00000000 nop                           | 
0018eda0: 1444000f bne r2,r4,0x0018ede0          #if unit ID in target list = target ID  /Else branch to next loop
0018eda4: 2862000f slti r2,r3,0x000f                 |r2 = 0x01 while counter < 0x0f
0018eda8: 1040000b beq r2,r0,0x0018edd8              #if counter < 0x0f /Else branch to jump to end
0018edac: 00000000 nop                                   |
0018edb0: 3c018019 lui r1,0x8019                         @ LOOP2 - Shift unit ID in target list (removing target ID)
0018edb4: 00230821 addu r1,r1,r3                             |r1 = 0x8019 + loop1 counter (= target position in target list)
0018edb8: 90223869 lbu r2,0x3869(r1)                         |
0018edbc: 3c018019 lui r1,0x8019                             |r2 = unit ID in target list just after Target
0018edc0: 00230821 addu r1,r1,r3                             |r1 = 0x8019 + loop1 counter (= target position in target list)
0018edc4: a0223868 sb r2,0x3868(r1)                          |Shift unit ID in place of target ID
0018edc8: 24630001 addiu r3,r3,0x0001                        |counter +1
0018edcc: 2862000f slti r2,r3,0x000f                         |r2 = 0x01 if r3 < 0x0f
0018edd0: 1440fff7 bne r2,r0,0x0018edb0                  Λ  Loop if counter < 0x0f 
0018edd4: 00000000 nop                                   |
0018edd8: 08063b7c j 0x0018edf0                      #E   >> jump to end
0018eddc: a0c50000 sb r5,0x0000(r6)                      |store 0xff at the end of the list (erase last unit ID ?)
0018ede0: 24630001 addiu r3,r3,0x0001            |counter +1
0018ede4: 28620010 slti r2,r3,0x0010             |r2 = 0x01 if counter <= 0x0F
0018ede8: 1440ffe9 bne r2,r0,0x0018ed90     Λ Loop if counter <= 0x0F
0018edec: 00000000 nop                      
0018edf0: 03e00008 jr r31                   
0018edf4: 00000000 nop                      

Return Locations

0018bb24: Set some data for current attack