Difference between revisions of "Get Number of Turns to Resolve(Alt)"

From Final Fantasy Hacktics Wiki
Jump to navigation Jump to search
 
(One intermediate revision by the same user not shown)
Line 1: Line 1:
  Ability loading?
+
  '''BATTLE.BIN''' - Get Number of Turns to Resolve(Alt)    ALTERNATIVE VERSION : [[Get_Number_of_Turns_to_Resolve]]
  00181720: 3c038019 lui r3,0x8019
+
---------------------------------------------------------------------------------------
  00181724: 8c63f51c lw r3,-0x0ae4(r3) load ?? ability slot counter?
+
Parameters : r4 = Unit ID
  00181728: 34020009 ori r2,r0,0x0009
+
              r5 = Ability CT
  0018172c: 14620004 bne r3,r2,0x00181740 branch if not 0x09 - active turn
+
              r6 = Pointer to AT List
  00181730: 00004021 addu r8,r0,r0
+
  00181734: 10a00002 beq r5,r0,0x00181740 branch if 0 CT
+
Returns : r2 = Nb of Turn to resolve
  00181738: 00000000 nop
+
          r2 = 0x0ff if resolution occurs after 40 Turns or Unit ID is invalid
  0018173c: 24a50001 addiu r5,r5,0x0001 CT + 1
+
----------------------------------------------------------------------------------------
  00181740: 00052a00 sll r5,r5,0x08 (CT + 1)* 128
+
  00181720: 3c038019 lui r3,0x8019           |
  00181744: 340a001f ori r10,r0,0x001f
+
  00181724: 8c63f51c lw r3,-0x0ae4(r3)       |{{f/load|8018f51c}} {{f/std|control variable}}
  00181748: 90c30000 lbu r3,0x0000(r6) AT list Unit ID
+
  00181728: 34020009 ori r2,r0,0x0009         |
  0018174c: 00000000 nop
+
  0018172c: 14620004 bne r3,r2,0x00181740     {{f/Cond|<nowiki>If Control value = 0x09 (Unit Active Turn)</nowiki>}}
  00181750: 30690040 andi r9,r3,0x0040 r9 = mounted check?
+
  00181730: 00004021 addu r8,r0,r0               |
  00181754: 3063001f andi r3,r3,0x001f
+
  00181734: 10a00002 beq r5,r0,0x00181740         {{f/Cond|If CT <> 0x00}}
  00181758: 106a0017 beq r3,r10,0x 001817b8              branch if Unit ID is 0x1f?
+
  00181738: 00000000 nop                             |{{f/std|}}
  0018175c: 340200ff ori r2,r0,0x00ff number of turns until resolution: 255
+
  0018173c: 24a50001 addiu r5,r5,0x0001               |{{f/std|CT + 1}}
  00181760: 94c70002 lhu r7,0x0002(r6)                   load units CT
+
  00181740: 00052a00 sll r5,r5,0x08           |{{f/std|(CT + 1)* 128}}
  00181764: 00000000 nop
+
  00181744: 340a001f ori r10,r0,0x001f       |
  00181768: 00e5102a slt r2,r7,r5 set if units CT < (CT + 1)* 128
+
                                            {{f/bloop|LOOP}}
  0018176c: 1440000d bne r2,r0,0x001817a4               branch if next unit after ability
+
  00181748: 90c30000 lbu r3,0x0000(r6)           |{{f/load|This iteration AT List Unit ID}}
  00181770: 00000000 nop
+
  0018174c: 00000000 nop                         |
  00181774: 14a70009 bne r5,r7,0x0018179c               branch if not same CT
+
  00181750: 30690040 andi r9,r3,0x0040           |{{f/std|Check Mount (?)}}
  00181778: 00000000 nop
+
  00181754: 3063001f andi r3,r3,0x001f           |{{f/std|Keep only ID}}
  0018177c: 14830003 bne r4,r3,0x0018178c branch if Unit ID <> Unit ID in AT list
+
  00181758: 106a0017 beq r3,r10,0x001817b8        {{f/Cond|If Unit ID is 0x1f (was 0xFF ?)}} {{f/loc| returns 0xff}} {{f/std|End of list ?}}
  00181780: 0064102a slt r2,r3,r4 r2 = 1 if AT list Unit ID < Unit ID?
+
  0018175c: 340200ff ori r2,r0,0x00ff                 |
  00181784: 15200005 bne r9,r0,0x0018179c branch if unit is mounted (no valid turns?)
+
  00181760: 94c70002 lhu r7,0x0002(r6)           |{{f/load|load units CT}}
  00181788: 00000000 nop
+
  00181764: 00000000 nop                         |
  0018178c: 10400003 beq r2,r0,0x0018179c Branch if unit had a turn before...?
+
  00181768: 00e5102a slt r2,r7,r5                 |{{f/std|set if units CT < (CT + 1)* 128}}
  00181790: 00000000 nop
+
  0018176c: 1440000d bne r2,r0,0x001817a4         {{f/Cond|If This Unit CT < (Ability CT+1)*128 : Go to }} {{f/loc|Next Iteration}}
  00181794: 15200003 bne r9,r0,0x001817a4 branch if unit is mounted? (again?)
+
  00181770: 00000000 nop                             |
  00181798: 00000000 nop
+
  00181774: 14a70009 bne r5,r7,0x0018179c             {{f/Cond|If Not Same CT : }} {{f/loc| returns Nb of turns}}
  0018179c: 080605ee j 0x001817b8
+
  00181778: 00000000 nop                                 |
  001817a0: 310200ff andi r2,r8,0x00ff return number of turns before resolution
+
                                                    '''Else : Same CT'''
  001817a4: 25080001 addiu r8,r8,0x0001 #entries in AT list
+
  0018177c: 14830003 bne r4,r3,0x0018178c                 {{f/Cond|If This AT Unit is the Acting Unit}}
  001817a8: 29020028 slti r2,r8,0x0028 limit = 0x28
+
  00181780: 0064102a slt r2,r3,r4                         |{{f/std|0x1 if AT Unit ID < Acting unit ID}}
  001817ac: 1440ffe6 bne r2,r0,0x00181748 Check next unit in AT list, 0x28 times (AT list limit is 40 bytes? 10 units?)
+
  00181784: 15200005 bne r9,r0,0x0018179c                     {{f/Cond|If Unit is not mounted}} {{f/loc| returns Nb of turns}} {{f/std|Mounted unit get no valid turns ?}}
  001817b0: 24c60004 addiu r6,r6,0x0004 AT list + 4
+
  00181788: 00000000 nop                                     |{{f/std|}}
 +
  0018178c: 10400003 beq r2,r0,0x0018179c                 {{f/Cond|If AT Unit ID > Acting Unit ID}} {{f/loc| returns Nb of turns}}
 +
  00181790: 00000000 nop                                     |
 +
  00181794: 15200003 bne r9,r0,0x001817a4                 {{f/Cond|If Mounted : }} {{f/loc|Next Iteration}}
 +
  00181798: 00000000 nop                                     |
 +
  0018179c: 080605ee j 0x001817b8                         {{f/jump|Exit and }} {{f/loc| returns Nb of turns}}
 +
  001817a0: 310200ff andi r2,r8,0x00ff                   |{{f/std|return number of turns before resolution}}
 +
  001817a4: 25080001 addiu r8,r8,0x0001           |{{f/std|AT list counter +1}}
 +
  001817a8: 29020028 slti r2,r8,0x0028           |{{f/std|<nowiki>limit = 0x28</nowiki>}}
 +
  001817ac: 1440ffe6 bne r2,r0,0x00181748     {{f/eloop|Loop 0x28 times }}
 +
  001817b0: 24c60004 addiu r6,r6,0x0004           |{{f/adr|AT list pointer + 4}}
 
  001817b4: 340200ff ori r2,r0,0x00ff
 
  001817b4: 340200ff ori r2,r0,0x00ff
 
  001817b8: 03e00008 jr r31
 
  001817b8: 03e00008 jr r31
 
  001817bc: 00000000 nop
 
  001817bc: 00000000 nop
 +
===Return location===
 +
'''Battle.bin'''
 +
00181aa4: [[Load_ability_data_for_skillset]]
 +
00181ae4: [[Load_ability_data_for_skillset]]
 +
001836a4: [[AT_List_Preview%3F]]

Latest revision as of 19:22, 3 August 2023

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?