Get Number of Turns to Resolve
Jump to navigation
Jump to search
# ROUTINE: Get Number of Turns to Resolve # Gets the number of turns to resolve an action with the specified parameters. ALTERNATIVE VERSION : Get_Number_of_Turns_to_Resolve(Alt) # Parameters: # r4 = (unitIndex) In-battle unit index (of acting unit) # r5 = (CT) Charge time (remaining) # r6 = (ATList) AT List # Returns: # r2 = Number of turns to resolve, or 0xff if the unit index is invalid or the number of turns would be greater than 40 80181720: 3c038019 lui r3,0x8019 80181724: 8c63f51c lw r3,-0x0ae4(r3) # actingState 80181728: 34020009 ori r2,r0,0x0009 8018172c: 14620004 bne r3,r2,0x80181740 80181730: 00004021 addu r8,r0,r0 # turnCount = 0 80181734: 10a00002 beq r5,r0,0x80181740 # if ((actingState == ACTING_STATE_ACTIVE_TURN) && (CT != 0)) { 80181738: 00000000 nop 8018173c: 24a50001 addiu r5,r5,0x0001 # CT = CT + 1 # } 80181740: 00052a00 sll r5,r5,0x08 # CT = CT << 8 80181744: 340a001f ori r10,r0,0x001f # 0x1f # atListPtr = &atList[0] # do { 80181748: 90c30000 lbu r3,0x0000(r6) # atListEntryFirstByte = *atListPtr 8018174c: 00000000 nop 80181750: 30690040 andi r9,r3,0x0040 # isUnitTurn = atListEntryFirstByte & 0x40 80181754: 3063001f andi r3,r3,0x001f # atUnitIndex = atListEntryFirstByte & 0x1f 80181758: 106a0017 beq r3,r10,0x801817b8 # if (atUnitIndex == 0x1f) return 0xff; // Is this possible? 8018175c: 340200ff ori r2,r0,0x00ff 80181760: 94c70002 lhu r7,0x0002(r6) # atCT = *(atListPtr + 2) 80181764: 00000000 nop 80181768: 00e5102a slt r2,r7,r5 8018176c: 1440000d bne r2,r0,0x801817a4 # if ((atCT >= CT) 80181770: 00000000 nop 80181774: 14a70009 bne r5,r7,0x8018179c # and ((atCT == CT) 80181778: 00000000 nop 8018177c: 14830003 bne r4,r3,0x8018178c # or (((unitIndex != atUnitIndex) and (atUnitIndex >= unitIndex)) 80181780: 0064102a slt r2,r3,r4 80181784: 15200005 bne r9,r0,0x8018179c # or (isUnitTurn)) 80181788: 00000000 nop 8018178c: 10400003 beq r2,r0,0x8018179c 80181790: 00000000 nop 80181794: 15200003 bne r9,r0,0x801817a4 # or (isUnitTurn))) 80181798: 00000000 nop # { 8018179c: 080605ee j 0x801817b8 # return turnCount; 801817a0: 310200ff andi r2,r8,0x00ff # } 801817a4: 25080001 addiu r8,r8,0x0001 # turnCount = turnCount + 1 801817a8: 29020028 slti r2,r8,0x0028 801817ac: 1440ffe6 bne r2,r0,0x80181748 801817b0: 24c60004 addiu r6,r6,0x0004 # atListPtr = atListPtr + 4 # } while (turnCount < 40); 801817b4: 340200ff ori r2,r0,0x00ff # return 0xff; 801817b8: 03e00008 jr r31 801817bc: 00000000 nop