Event Instruction 0xe5: WaitForInstruction

From Final Fantasy Hacktics Wiki
Jump to navigation Jump to search
#   {E5} WaitForInstruction

00145964: 00151200 sll r2,r21,0x08              #   params.byte1 << 8
00145968: 0052b021 addu r22,r2,r18              #   WaitTaskID = (params.byte1 << 8) + params.byte0 (Load halfword value of parameter bytes)
0014596c: 3c118017 lui r17,0x8017         
00145970: 2631986c addiu r17,r17,-0x6794        #   Base pointer for thread array
                                                #   while (true) {
00145974: 0c0532a0 jal 0x0014ca80               #       Switch To Next Thread ();
00145978: 34100001 ori r16,r0,0x0001            #       index = 1
0014597c: 00101280 sll r2,r16,0x0a              #       threadOffset = index * sizeof(thread)
                                                #       do {
00145980: 00511821 addu r3,r2,r17               #           thread = (Base pointer for thread array) + threadOffset
00145984: 8c620048 lw r2,0x0048(r3)             #           thread.IsRunning
00145988: 00000000 nop                   
0014598c: 10400005 beq r2,r0,0x001459a4         #           if (thread.IsRunning != 0) {             // Thread is in use?
00145990: 00000000 nop                   
00145994: 8c62004c lw r2,0x004c(r3)             #               thread.TaskID
00145998: 00000000 nop                   
0014599c: 10560006 beq r2,r22,0x001459b8        #               if (thread.TaskID == WaitTaskID) break;
001459a0: 34020010 ori r2,r0,0x0010             
                                                #           }
001459a4: 26100001 addiu r16,r16,0x0001         #           index = index + 1        
001459a8: 2a020010 slti r2,r16,0x0010       
001459ac: 1440fff4 bne r2,r0,0x00145980
001459b0: 00101280 sll r2,r16,0x0a              #           threadOffset = index * sizeof(thread)
                                                #       } while (index < 16)

001459b4: 34020010 ori r2,r0,0x0010             #       16 (Number of threads)

001459b8: 1202015a beq r16,r2,0x00145f24        #       if (index == 16) break; 
001459bc: 00000000 nop                   
001459c0: 0805165d j 0x00145974                 #   }
001459c4: 00000000 nop