Get Number of Turns to Resolve(Alt)

From Final Fantasy Hacktics Wiki
Revision as of 19:22, 3 August 2023 by Orkney (talk | contribs) (Orkney moved page Ability Loading? to Get Number of Turns to Resolve(Alt))
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search
BATTLE.BIN - Get Number of Turns to Resolve(Alt)     ALTERNATIVE VERSION : Get_Number_of_Turns_to_Resolve
---------------------------------------------------------------------------------------
Parameters : r4 = Unit ID
             r5 = Ability CT
             r6 = Pointer to AT List

Returns : r2 = Nb of Turn to resolve
          r2 = 0x0ff if resolution occurs after 40 Turns or Unit ID is invalid
----------------------------------------------------------------------------------------
00181720: 3c038019 lui r3,0x8019            |
00181724: 8c63f51c lw r3,-0x0ae4(r3)        |8018f51c control variable
00181728: 34020009 ori r2,r0,0x0009         |
0018172c: 14620004 bne r3,r2,0x00181740     #If Control value = 0x09 (Unit Active Turn)
00181730: 00004021 addu r8,r0,r0                |
00181734: 10a00002 beq r5,r0,0x00181740         #If CT <> 0x00
00181738: 00000000 nop                              |
0018173c: 24a50001 addiu r5,r5,0x0001               |CT + 1
00181740: 00052a00 sll r5,r5,0x08           |(CT + 1)* 128
00181744: 340a001f ori r10,r0,0x001f        |
                                            @LOOP
00181748: 90c30000 lbu r3,0x0000(r6)            |This iteration AT List Unit ID
0018174c: 00000000 nop                          |
00181750: 30690040 andi r9,r3,0x0040            |Check Mount (?)
00181754: 3063001f andi r3,r3,0x001f            |Keep only ID
00181758: 106a0017 beq r3,r10,0x001817b8        #If Unit ID is 0x1f (was 0xFF ?)  returns 0xff End of list ?
0018175c: 340200ff ori r2,r0,0x00ff                 |
00181760: 94c70002 lhu r7,0x0002(r6)            |load units CT
00181764: 00000000 nop                          |
00181768: 00e5102a slt r2,r7,r5                 |set if units CT < (CT + 1)* 128
0018176c: 1440000d bne r2,r0,0x001817a4         #If This Unit CT < (Ability CT+1)*128 : Go to  Next Iteration
00181770: 00000000 nop                              |
00181774: 14a70009 bne r5,r7,0x0018179c             #If Not Same CT :   returns Nb of turns
00181778: 00000000 nop                                  |
                                                    Else : Same CT
0018177c: 14830003 bne r4,r3,0x0018178c                 #If This AT Unit is the Acting Unit
00181780: 0064102a slt r2,r3,r4                         |0x1 if AT Unit ID < Acting unit ID
00181784: 15200005 bne r9,r0,0x0018179c                     #If Unit is not mounted  returns Nb of turns Mounted unit get no valid turns ?
00181788: 00000000 nop                                      |
0018178c: 10400003 beq r2,r0,0x0018179c                 #If AT Unit ID > Acting Unit ID  returns Nb of turns
00181790: 00000000 nop                                      |
00181794: 15200003 bne r9,r0,0x001817a4                 #If Mounted :  Next Iteration
00181798: 00000000 nop                                      |
0018179c: 080605ee j 0x001817b8                         >>Exit and   returns Nb of turns
001817a0: 310200ff andi r2,r8,0x00ff                    |return number of turns before resolution
001817a4: 25080001 addiu r8,r8,0x0001           |AT list counter +1
001817a8: 29020028 slti r2,r8,0x0028            |limit = 0x28
001817ac: 1440ffe6 bne r2,r0,0x00181748     Λ Loop 0x28 times 
001817b0: 24c60004 addiu r6,r6,0x0004           |AT list pointer + 4
001817b4: 340200ff ori r2,r0,0x00ff
001817b8: 03e00008 jr r31
001817bc: 00000000 nop

Return location

Battle.bin
00181aa4: Load_ability_data_for_skillset
00181ae4: Load_ability_data_for_skillset
001836a4: AT_List_Preview?