Call Inner Subroutine

From Final Fantasy Hacktics Wiki
Jump to navigation Jump to search
#   ROUTINE: CALL INNER SUBROUTINE (ON MAIN THREAD)
#       This routine acts as a wrapper for a call to another routine, and forces the routine to run on the main thread (thread 0).
#
#       Parameters:
#           Parameters for inner subroutine: r4 - r7 with additional parameters on the stack, as usual
#           RAM_WORD[0x80173ca8] = [Address of subroutine to call]
#
#       Returns:
#           r2 = [Result of inner subroutine]

0014ceb4: 3c018015 lui r1,0x8015
0014ceb8: 00200821 addu r1,r1,r0
0014cebc: ac3fcf5c sw r31,-0x30a4(r1)               #   Save return address to 0x8014cf5c
0014cec0: 3c018017 lui r1,0x8017
0014cec4: 00200821 addu r1,r1,r0
0014cec8: 8c284038 lw r8,0x4038(r1)                 #   threadID
0014cecc: 00000000 nop
0014ced0: 11000015 beq r8,r0,0x0014cf28             #   if (threadID != 0) {
0014ced4: 00000000 nop
0014ced8: 3c018016 lui r1,0x8016
0014cedc: 00200821 addu r1,r1,r0
0014cee0: 8c285f98 lw r8,0x5f98(r1)                 #       threads[0]
0014cee4: 00000000 nop
0014cee8: 8d08003c lw r8,0x003c(r8)                 #       threads[0].StackPointer
0014ceec: 00000000 nop

0014cef0: 2108fff0 addi r8,r8,-0x0010               
0014cef4: ad1d0004 sw r29,0x0004(r8)                #       Save stack pointer
0014cef8: ad1f0008 sw r31,0x0008(r8)
0014cefc: 0100e821 addu r29,r8,r0                   #       [Stack pointer] = threads[0].StackPointer
0014cf00: 3c018017 lui r1,0x8017
0014cf04: 00200821 addu r1,r1,r0
0014cf08: 8c283ca8 lw r8,0x3ca8(r1)                 #       RAM_WORD[0x80173ca8]
0014cf0c: 00000000 nop
0014cf10: 0100f809 jalr r8,r31                      #       ROUTINE: Call subroutine at RAM_WORD[0x80173ca8]
0014cf14: 00000000 nop
0014cf18: 8fbf0008 lw r31,0x0008(r29)
0014cf1c: 8fbd0004 lw r29,0x0004(r29)               #       Load stack pointer back
0014cf20: 03e00008 jr r31                           #       Return (exit the routine)
0014cf24: 00000000 nop
                                                    #   }
0014cf28: 3c018017 lui r1,0x8017
0014cf2c: 00200821 addu r1,r1,r0
0014cf30: 8c283ca8 lw r8,0x3ca8(r1)                 #   RAM_WORD[0x80173ca8]
0014cf34: 00000000 nop
0014cf38: 0100f809 jalr r8,r31                      #   ROUTINE: Call routine at RAM_WORD[0x80173ca8]
0014cf3c: 00000000 nop
0014cf40: 3c018015 lui r1,0x8015
0014cf44: 00200821 addu r1,r1,r0
0014cf48: 8c3fcf5c lw r31,-0x30a4(r1)               #   Load return address from 0x8014cf5c
0014cf4c: 00000000 nop
0014cf50: 03e00008 jr r31                           #   Return (exit the routine)
0014cf54: 00000000 nop


Call Locations

00134de8: Display Projected Action Effect (Inner call is to Find Action Highest Order Status Effect)
00135148: Display Projected Action Effect (Inner call is to Find Action Highest Order Status Effect)