Wait For Thread

From Final Fantasy Hacktics Wiki
Jump to navigation Jump to search
#   ROUTINE: WAIT FOR THREAD
#       Waits for specified thread to be complete.
#       Parameters:
#           r4 = ThreadID

8014c9d0: 27bdffe8 addiu r29,r29,-0x0018
8014c9d4: afb00010 sw r16,0x0010(r29)
8014c9d8: 00048280 sll r16,r4,0x0a              #   ThreadID * sizeof(thread)
8014c9dc: afbf0014 sw r31,0x0014(r29)
                                                #   do {
8014c9e0: 0c0532a0 jal 0x8014ca80               #       Switch to next thread
8014c9e4: 00000000 nop
8014c9e8: 3c028016 lui r2,0x8016
8014c9ec: 8c425f98 lw r2,0x5f98(r2)             #       Base thread array pointer
8014c9f0: 00000000 nop
8014c9f4: 02021021 addu r2,r16,r2               #       thread = (Base thread array pointer) + (ThreadID * sizeof(thread))
8014c9f8: 8c420048 lw r2,0x0048(r2)             #       thread.IsInUse
8014c9fc: 00000000 nop
8014ca00: 1440fff7 bne r2,r0,0x8014c9e0         #   } while (thread.IsInUse)
8014ca04: 00000000 nop
8014ca08: 8fbf0014 lw r31,0x0014(r29)
8014ca0c: 8fb00010 lw r16,0x0010(r29)
8014ca10: 27bd0018 addiu r29,r29,0x0018
8014ca14: 03e00008 jr r31
8014ca18: 00000000 nop