Process Scenario Conditionals

From Final Fantasy Hacktics Wiki
Jump to navigation Jump to search
#   ROUTINE: PROCESS SCENARIO CONDITIONALS
#       Processes ATTACK.OUT scenario conditionals.
#       No parameters.
#       Returns:
#           r2  = 0, if an event should not be run
#               = 1, if an event should be run

801425b0: 27bdffd8 addiu r29,r29,-0x0028
801425b4: afb1001c sw r17,0x001c(r29)
801425b8: 00008821 addu r17,r0,r0                   #   count = 0
801425bc: afbf0020 sw r31,0x0020(r29)
801425c0: afb00018 sw r16,0x0018(r29)
801425c4: 00111040 sll r2,r17,0x01                  #   count * 2
                                                    #   do {
801425c8: 3c018004 lui r1,0x8004
801425cc: 00220821 addu r1,r1,r2
801425d0: 942275e0 lhu r2,0x75e0(r1)                #       offset = *(0x800475e0 + (count * 2))
801425d4: 00000000 nop
801425d8: 00021400 sll r2,r2,0x10
801425dc: 12200003 beq r17,r0,0x801425ec
801425e0: 00021c03 sra r3,r2,0x10                   #       offset
                                                    #       if (count != 0) {
801425e4: 10600022 beq r3,r0,0x80142670             #           if (offset == 0)
801425e8: 00000000 nop                              #               return 0;
                                                    #       }
801425ec: 000217c2 srl r2,r2,0x1f
801425f0: 00621021 addu r2,r3,r2
801425f4: 00021043 sra r2,r2,0x01
801425f8: 00021040 sll r2,r2,0x01                   #       offset
801425fc: 3c038005 lui r3,0x8005
80142600: 24639a18 addiu r3,r3,-0x65e8              #       conditionalBasePtr = 0x80049a18
80142604: 00438021 addu r16,r2,r3                   #       conditionalDataPtr = conditionalBasePtr + offset
                                                    #       do {
80142608: 86020008 lh r2,0x0008(r16)                #           conditionalValue5 = *(conditionalDataPtr + 8)
8014260c: 86040000 lh r4,0x0000(r16)                #           conditionalValue1 = *(conditionalDataPtr)
80142610: 86050002 lh r5,0x0002(r16)                #           conditionalValue2 = *(conditionalDataPtr + 2)
80142614: 86060004 lh r6,0x0004(r16)                #           conditionalValue3 = *(conditionalDataPtr + 4)
80142618: 86070006 lh r7,0x0006(r16)                #           conditionalValue4 = *(conditionalDataPtr + 6)
8014261c: 0c0509a5 jal 0x80142694                   #           resultCode = Process Scenario Conditional (conditionalValue1, conditionalValue2, conditionalValue3, conditionalValue4, conditionalValue5);
80142620: afa20010 sw r2,0x0010(r29)                #           conditionalValue5
80142624: 86030000 lh r3,0x0000(r16)                #           conditionalValue = *conditionalDataPtr
80142628: 3c018017 lui r1,0x8017
8014262c: 00230821 addu r1,r1,r3
80142630: 902396bc lbu r3,-0x6944(r1)               #           *(0x801696bc + conditionalValue)
80142634: 00000000 nop
80142638: 00031840 sll r3,r3,0x01                   #           paramLength = *(0x801696bc + conditionalValue) * 2
8014263c: 24630002 addiu r3,r3,0x0002               #           commandLength = paramLength + 2
80142640: 02038021 addu r16,r16,r3                  #           conditionalDataPtr = conditionalDataPtr + commandLength         // Move to next part of conditional
80142644: 00401821 addu r3,r2,r0                    #           resultCode
80142648: 34020001 ori r2,r0,0x0001
8014264c: 1062ffee beq r3,r2,0x80142608
80142650: 34020002 ori r2,r0,0x0002
                                                    #       } while (resultCode == 1);      // Keep running this conditional as long as the checks are being passed
80142654: 14620003 bne r3,r2,0x80142664             
80142658: 26310001 addiu r17,r17,0x0001             #       count = count + 1
                                                    #       if (resultCode == 2) {
8014265c: 0805099d j 0x80142674
80142660: 34020001 ori r2,r0,0x0001                 #           return 1;
                                                    #       }
80142664: 2a22000a slti r2,r17,0x000a
80142668: 1440ffd7 bne r2,r0,0x801425c8
8014266c: 00111040 sll r2,r17,0x01                  
                                                    #   } while (count < 10);
80142670: 00001021 addu r2,r0,r0                    #   return 0;
80142674: 8fbf0020 lw r31,0x0020(r29)
80142678: 8fb1001c lw r17,0x001c(r29)
8014267c: 8fb00018 lw r16,0x0018(r29)
80142680: 27bd0028 addiu r29,r29,0x0028
80142684: 03e00008 jr r31
80142688: 00000000 nop