Run Menu Thread (WORLD.BIN)

From Final Fantasy Hacktics Wiki
Jump to navigation Jump to search
#   ROUTINE: RUN MENU THREAD (WORLD.BIN)
#       Checks running status of thread with specified threadID.  If not running, initalizes it with specified function pointer from menu data.  Otherwise, returns thread running status.
#       Parameters:
#           r4 = (threadID) Thread ID to start or check
#           r5 = (menuData) Menu struct data
#       Returns:
#           r2 = Thread running status for specified threadID

8012ab78: 3c028019 lui r2,0x8019
8012ab7c: 8c42e430 lw r2,-0x1bd0(r2)                #   *0x8018e430
8012ab80: 27bdffe0 addiu r29,r29,-0x0020
8012ab84: afb00010 sw r16,0x0010(r29)
8012ab88: 00808021 addu r16,r4,r0                   #   threadID
8012ab8c: afb10014 sw r17,0x0014(r29)
8012ab90: 00a08821 addu r17,r5,r0                   #   menuData
8012ab94: 14400015 bne r2,r0,0x8012abec             #   if (*0x8018e430 == 0)
8012ab98: afbf0018 sw r31,0x0018(r29)               #   {
8012ab9c: 0c03ffbb jal 0x800ffeec                   #       isThreadRunning = Check Thread Running Status (WORLD.BIN) (threadID);
8012aba0: 00000000 nop
8012aba4: 14400015 bne r2,r0,0x8012abfc             #       if (isThreadRunning != 0)
8012aba8: 34020001 ori r2,r0,0x0001                 #           return 1;
8012abac: 8e250028 lw r5,0x0028(r17)                #       menuData.FunctionPointer
8012abb0: 3c01801d lui r1,0x801d
8012abb4: ac31d7e0 sw r17,-0x2820(r1)               #       *0x801cd7e0 = menuData
8012abb8: 0c03ff5c jal 0x800ffd70                   #       Initialize Thread (WORLD.BIN) (threadID, menuData.FunctionPointer);
8012abbc: 02002021 addu r4,r16,r0
8012abc0: 02002021 addu r4,r16,r0
8012abc4: 00003021 addu r6,r0,r0
8012abc8: 3c05801d lui r5,0x801d
8012abcc: 8ca5d7e0 lw r5,-0x2820(r5)
8012abd0: 0c03ffc2 jal 0x800fff08                   #       Store Thread Function Parameters (WORLD.BIN) (threadID, menuData, 0, 0);
8012abd4: 00003821 addu r7,r0,r0
8012abd8: 34030001 ori r3,r0,0x0001
8012abdc: 3c018019 lui r1,0x8019
8012abe0: ac23e430 sw r3,-0x1bd0(r1)                #       *0x8018e430 = 1
8012abe4: 0804aaff j 0x8012abfc                     #       return 1;
8012abe8: 34020001 ori r2,r0,0x0001
                                                    #   } else {
8012abec: 0c03ffbb jal 0x800ffeec
8012abf0: 02002021 addu r4,r16,r0                   #       isThreadRunning = Check Thread Running Status (WORLD.BIN) (threadID);
8012abf4: 3c018019 lui r1,0x8019
8012abf8: ac22e430 sw r2,-0x1bd0(r1)                #       *0x8018e430 = isThreadRunning
                                                    #       return isThreadRunning;
                                                    #   }
8012abfc: 8fbf0018 lw r31,0x0018(r29)
8012ac00: 8fb10014 lw r17,0x0014(r29)
8012ac04: 8fb00010 lw r16,0x0010(r29)
8012ac08: 27bd0020 addiu r29,r29,0x0020
8012ac0c: 03e00008 jr r31
8012ac10: 00000000 nop