Process World Conditional Set

From Final Fantasy Hacktics Wiki
Revision as of 16:28, 24 September 2020 by Glain (talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search
#   ROUTINE: Process World Conditional Set
#       Parameters:
#           r4 = (conditionalSetIndex) Conditional set index
#           r5 = (actionFlag) Flag to check on command result to determine return value
#       Returns:
#           r2 = {
#               0, if an action should not be performed
#               1, if an action should be performed
#           }

80091238: 27bdffd8 addiu r29,r29,-0x0028
8009123c: 3c03800d lui r3,0x800d
80091240: 8c634674 lw r3,0x4674(r3)                 #   conditonalBasePtr = *0x800d4674
80091244: 00042040 sll r4,r4,0x01                   #   (conditionalSetIndex * 2)
80091248: afbf0024 sw r31,0x0024(r29)
8009124c: afb40020 sw r20,0x0020(r29)
80091250: afb3001c sw r19,0x001c(r29)
80091254: afb20018 sw r18,0x0018(r29)
80091258: afb10014 sw r17,0x0014(r29)
8009125c: afb00010 sw r16,0x0010(r29)
80091260: 00832021 addu r4,r4,r3                    #   conditionalSetOffsetPtr = conditionalBasePtr + (conditionalSetIndex * 2)
80091264: 94820000 lhu r2,0x0000(r4)                #   conditionalSetOffset = *(conditionalSetOffsetPtr)
80091268: 3c04800d lui r4,0x800d
8009126c: 24844648 addiu r4,r4,0x4648               #   &conditionalSetPtr          // (0x800d4648)
80091270: 3042fffe andi r2,r2,0xfffe                #   conditionalSetOffset = conditionalSetOffset & 0xfffe            // (Must be an even number)
80091274: 00621821 addu r3,r3,r2                    #   conditonalBasePtr + conditionalSetOffset
80091278: ac830000 sw r3,0x0000(r4)                 #   conditionalSetPtr = conditonalBasePtr + conditionalSetOffset
8009127c: 3c02800d lui r2,0x800d
80091280: 8c424648 lw r2,0x4648(r2)                 #   conditionalSetPtr
80091284: 00a0a021 addu r20,r5,r0                   #   actionFlag
80091288: 94430000 lhu r3,0x0000(r2)                #   conditionalBlockOffset = *conditionalSetPtr
8009128c: 00000000 nop
80091290: 10600031 beq r3,r0,0x80091358             #   if (conditionalBlockOffset == 0) return 0;
80091294: 00008821 addu r17,r0,r0                   #   conditionalBlockIndex = 0
80091298: 24920004 addiu r18,r4,0x0004              #   &conditionalBlockPtr        // (0x800d464c)
8009129c: 24900008 addiu r16,r4,0x0008              #   &numberReadIndex            // (0x800d4650)
800912a0: 3c13800a lui r19,0x800a
800912a4: 2673ee50 addiu r19,r19,-0x11b0            #   functionTablePtr = 0x8009ee50
                                                    #   do {
800912a8: 3c02800d lui r2,0x800d
800912ac: 8c424674 lw r2,0x4674(r2)                 #       conditonalBasePtr
800912b0: 3063fffe andi r3,r3,0xfffe                #       conditionalBlockOffset = conditionalBlockOffset & 0xfffe    // (Must be an even number)
800912b4: a6400004 sh r0,0x0004(r18)                #       numberReadIndex = 0
800912b8: ae40fff8 sw r0,-0x0008(r18)               #       commandResult = 0       // (0x800d4644)
800912bc: 00431021 addu r2,r2,r3                    #       conditonalBasePtr + conditionalBlockOffset
800912c0: ae420000 sw r2,0x0000(r18)                #       conditionalBlockPtr = conditonalBasePtr + conditionalBlockOffset
                                                    #       do {
800912c4: 96030000 lhu r3,0x0000(r16)               #           numberReadIndex
800912c8: 3c04800d lui r4,0x800d
800912cc: 8c84464c lw r4,0x464c(r4)                 #           conditionalBlockPtr
800912d0: 00031040 sll r2,r3,0x01                   #           numberReadIndex * 2
800912d4: 00441021 addu r2,r2,r4                    #           conditionalBlockPtr + (numberReadIndex * 2)
800912d8: 94420000 lhu r2,0x0000(r2)                #           commandID = *(conditionalBlockPtr + (numberReadIndex * 2))
800912dc: 24630001 addiu r3,r3,0x0001               #           numberReadIndex + 1
800912e0: a6030000 sh r3,0x0000(r16)                #           numberReadIndex = numberReadIndex + 1
800912e4: 00021080 sll r2,r2,0x02                   #           commandID * 4
800912e8: 00531021 addu r2,r2,r19                   #           functionTablePtr + (commandID * 4)
800912ec: 8c420000 lw r2,0x0000(r2)                 #           functionPtr = *(functionTablePtr + (commandID * 4))
800912f0: 00000000 nop
800912f4: 0040f809 jalr r2,r31                      #           functionPtr ();
800912f8: 00000000 nop
800912fc: 8e02fff4 lw r2,-0x000c(r16)               #           commandResult
80091300: 00000000 nop
80091304: 30420003 andi r2,r2,0x0003                #           commandResult & 0x03
80091308: 1040ffee beq r2,r0,0x800912c4             #       } while ((commandResult & 0x03) == 0)
8009130c: 00000000 nop
80091310: 3c03800d lui r3,0x800d
80091314: 8c634644 lw r3,0x4644(r3)                 #       commandResult
80091318: 00000000 nop
8009131c: 30620001 andi r2,r3,0x0001                #       commandResult & 0x01
80091320: 10400003 beq r2,r0,0x80091330
80091324: 00741024 and r2,r3,r20                    #       commandResult & actionFlag
                                                    #       if (((commandResult & 0x01) != 0)
80091328: 1440000c bne r2,r0,0x8009135c             #           && ((commandResult & actionFlag) == 0))
8009132c: 34020001 ori r2,r0,0x0001                 #               return 1;
80091330: 26310001 addiu r17,r17,0x0001             #       conditionalBlockIndex = conditionalBlockIndex + 1
80091334: 3222ffff andi r2,r17,0xffff
80091338: 3c03800d lui r3,0x800d
8009133c: 8c634648 lw r3,0x4648(r3)                 #       conditionalSetPtr
80091340: 00021040 sll r2,r2,0x01                   #       (conditionalBlockIndex * 2)
80091344: 00431021 addu r2,r2,r3                    #       conditionalSetPtr + (conditionalBlockIndex * 2)
80091348: 94430000 lhu r3,0x0000(r2)                #       conditionalBlockOffset = conditionalSetPtr + (conditionalBlockIndex * 2)
8009134c: 00000000 nop
80091350: 1460ffd5 bne r3,r0,0x800912a8             #   } while (conditionalBlockOffset != 0);
80091354: 00000000 nop
80091358: 00001021 addu r2,r0,r0                    #   return 0;
8009135c: 8fbf0024 lw r31,0x0024(r29)
80091360: 8fb40020 lw r20,0x0020(r29)
80091364: 8fb3001c lw r19,0x001c(r29)
80091368: 8fb20018 lw r18,0x0018(r29)
8009136c: 8fb10014 lw r17,0x0014(r29)
80091370: 8fb00010 lw r16,0x0010(r29)
80091374: 27bd0028 addiu r29,r29,0x0028
80091378: 03e00008 jr r31
8009137c: 00000000 nop