Run Effect Block

From Final Fantasy Hacktics Wiki
Jump to navigation Jump to search
#   ROUTINE: RUN EFFECT BLOCK
#   Parameters:
#       r4 = (effectBlockID) Effect Block ID
#   Returns:
#       r2 = 0, if command function returned 2; 1, otherwise

801a4cf0: 27bdffe0 addiu r29,r29,-0x0020
801a4cf4: 00042400 sll r4,r4,0x10
801a4cf8: 00042403 sra r4,r4,0x10
801a4cfc: 00041140 sll r2,r4,0x05                   #   effectBlockID * 32
801a4d00: 00441023 subu r2,r2,r4                    #   effectBlockID * 31
801a4d04: 000210c0 sll r2,r2,0x03                   #   effectBlockID * 248
801a4d08: 3c03801c lui r3,0x801c
801a4d0c: 2463f02c addiu r3,r3,-0x0fd4              #   0x801bf02c
801a4d10: afb00010 sw r16,0x0010(r29)
801a4d14: 00438021 addu r16,r2,r3                   #   effectBlock = 0x801bf02c + (effectBlockID * 248)
801a4d18: afb10014 sw r17,0x0014(r29)
801a4d1c: 3c11801b lui r17,0x801b
801a4d20: 263167c8 addiu r17,r17,0x67c8             #   0x801b67c8
801a4d24: afbf0018 sw r31,0x0018(r29)
                                                    #   do {
801a4d28: 86030006 lh r3,0x0006(r16)                #       effectBlock.offset                                           
801a4d2c: 8e020008 lw r2,0x0008(r16)                #       effectBlock.basePointer
801a4d30: 00000000 nop
801a4d34: 00431021 addu r2,r2,r3                    #       effectBlock.basePointer + effectBlock.offset
801a4d38: 94420000 lhu r2,0x0000(r2)                #       effectCommandValue = *(effectBlock.basePointer + effectBlock.offset)
801a4d3c: 00000000 nop
801a4d40: 304201ff andi r2,r2,0x01ff                #       effectCommandID = effectCommandValue & 0x1ff
801a4d44: 00021080 sll r2,r2,0x02                   #       effectCommandID * 4
801a4d48: 00511021 addu r2,r2,r17                   #       commandFunctionPointer = 0x801b67c8 + (effectCommandID * 4)
801a4d4c: 8c420000 lw r2,0x0000(r2)                 #       commandFunction = *commandFunctionPointer
801a4d50: 00000000 nop
801a4d54: 0040f809 jalr r2,r31                      #       result = commandFunction(effectBlock);
801a4d58: 02002021 addu r4,r16,r0
801a4d5c: 00021400 sll r2,r2,0x10
801a4d60: 00021c03 sra r3,r2,0x10
801a4d64: 34020002 ori r2,r0,0x0002
801a4d68: 10620005 beq r3,r2,0x801a4d80             #       if (result == 2) return 0;
801a4d6c: 00000000 nop
801a4d70: 1460ffed bne r3,r0,0x801a4d28             #   } while (result != 0);
801a4d74: 34020001 ori r2,r0,0x0001                 #   return 1;
801a4d78: 08069361 j 0x801a4d84
801a4d7c: 00000000 nop
801a4d80: 00001021 addu r2,r0,r0                    
801a4d84: 8fbf0018 lw r31,0x0018(r29)
801a4d88: 8fb10014 lw r17,0x0014(r29)
801a4d8c: 8fb00010 lw r16,0x0010(r29)
801a4d90: 27bd0020 addiu r29,r29,0x0020
801a4d94: 03e00008 jr r31
801a4d98: 00000000 nop