Camera Fusion Event Instruction

From Final Fantasy Hacktics Wiki
Jump to navigation Jump to search
#   ROUTINE: CAMERA FUSION EVENT INSTRUCTION

8013db9c: 27bdff88 addiu r29,r29,-0x0078
8013dba0: 34040004 ori r4,r0,0x0004
8013dba4: afbf0074 sw r31,0x0074(r29)
8013dba8: afbe0070 sw r30,0x0070(r29)
8013dbac: afb7006c sw r23,0x006c(r29)
8013dbb0: afb60068 sw r22,0x0068(r29)
8013dbb4: afb50064 sw r21,0x0064(r29)
8013dbb8: afb40060 sw r20,0x0060(r29)
8013dbbc: afb3005c sw r19,0x005c(r29)
8013dbc0: afb20058 sw r18,0x0058(r29)
8013dbc4: afb10054 sw r17,0x0054(r29)
8013dbc8: 0c052752 jal 0x80149d48                   #   Set Thread Task ID (4);
8013dbcc: afb00050 sw r16,0x0050(r29)
8013dbd0: 0c04bbac jal 0x8012eeb0                   #   result_0x12eeb0 = ? 0x12eeb0 (0x47c);
8013dbd4: 3404047c ori r4,r0,0x047c
8013dbd8: 0c0532f0 jal 0x8014cbc0                   #   firstEventInstructionPtr = Get First Thread Parameter ();
8013dbdc: 0040f021 addu r30,r2,r0                   #   result_0x12eeb0
8013dbe0: 03c02021 addu r4,r30,r0                   #   result_0x12eeb0
8013dbe4: 3405047c ori r5,r0,0x047c
8013dbe8: 0c052fb6 jal 0x8014bed8                   #   ? 0x14bed8 (result_0x12eeb0, 0x47c);
8013dbec: 00408021 addu r16,r2,r0                   #   firstEventInstructionPtr
8013dbf0: 0200a021 addu r20,r16,r0                  #   eventInstructionPtr = firstEventInstructionPtr
8013dbf4: 0000b021 addu r22,r0,r0                   #   cameraInstructionCount = 0
8013dbf8: 34040019 ori r4,r0,0x0019                 #   0x19 = 25
8013dbfc: 3403001e ori r3,r0,0x001e                 #   0x1e = 30
                                                    #   do {
8013dc00: 92820000 lbu r2,0x0000(r20)               #       eventInstructionID = *eventInstructionPtr
8013dc04: 00000000 nop
8013dc08: 14440002 bne r2,r4,0x8013dc14             #       if (eventInstructionID == 0x19) {            // 0x19 = Camera
8013dc0c: 00000000 nop
8013dc10: 26d60001 addiu r22,r22,0x0001             #           cameraInstructionCount = cameraInstructionCount + 1
                                                    #       }
8013dc14: 10430008 beq r2,r3,0x8013dc38             #       if (eventInstructionID == 0x1e) break;       // 0x1e = CameraFusionEnd            
8013dc18: 00000000 nop
8013dc1c: 3c018015 lui r1,0x8015
8013dc20: 00220821 addu r1,r1,r2
8013dc24: 9022d170 lbu r2,-0x2e90(r1)               #       eventParameterLengthArray[eventInstructionID] 
8013dc28: 00000000 nop
8013dc2c: 24420001 addiu r2,r2,0x0001               #       eventParameterLengthArray[eventInstructionID] + 1
8013dc30: 0804f700 j 0x8013dc00
8013dc34: 0282a021 addu r20,r20,r2                  #       eventInstructionPtr = eventInstructionPtr + eventParameterLengthArray[eventInstructionID] + 1
                                                    #   } while (true);
8013dc38: 26d60001 addiu r22,r22,0x0001             #   cameraInstructionCount = cameraInstructionCount + 1
8013dc3c: 3c028016 lui r2,0x8016
8013dc40: 8c425f9c lw r2,0x5f9c(r2)                 #   *0x80165f9c
8013dc44: 0200a021 addu r20,r16,r0                  #   eventInstructionPtr = firstEventInstructionPtr
8013dc48: 8c440078 lw r4,0x0078(r2)                 #   *(*0x80165f9c + 0x78)
8013dc4c: 0c051cb7 jal 0x801472dc                   #   ? 0x1472dc (*(*0x80165f9c + 0x78));
8013dc50: 0000a821 addu r21,r0,r0                   #   count = 0
8013dc54: 1ac00094 blez r22,0x8013dea8              #   if (cameraInstructionCount > 0) {
8013dc58: 00000000 nop
8013dc5c: 27a90010 addiu r9,r29,0x0010              #       localPtr
8013dc60: afa90038 sw r9,0x0038(r29)                #       localPtr
8013dc64: 0000b821 addu r23,r0,r0                   #       r23 = 0
8013dc68: 2409fff0 addiu r9,r0,-0x0010              #       -16
8013dc6c: afa90048 sw r9,0x0048(r29)                #       stack_0x48 = -16
                                                    #       do {
8013dc70: 16a00025 bne r21,r0,0x8013dd08
8013dc74: 00008821 addu r17,r0,r0                   #           innerCount = 0
                                                    #           if (count == 0) {
8013dc78: 02e03821 addu r7,r23,r0                   #               r23
8013dc7c: 3c058016 lui r5,0x8016
8013dc80: 24a55ed4 addiu r5,r5,0x5ed4               #               ptr = 0x80165ed4
8013dc84: 03c02021 addu r4,r30,r0                   #               r4 = result_0x12eeb0
8013dc88: 3c088016 lui r8,0x8016
8013dc8c: 8d085f9c lw r8,0x5f9c(r8)                 #               *0x80165f9c
8013dc90: 8fa60038 lw r6,0x0038(r29)                #               loopPtr = localPtr
                                                    #               do {
8013dc94: 94a20000 lhu r2,0x0000(r5)                #                   value = *ptr
8013dc98: 00000000 nop
8013dc9c: 00021080 sll r2,r2,0x02                   #                   value * 4
8013dca0: 00481021 addu r2,r2,r8                    #                   (value * 4) + *0x80165f9c
8013dca4: 8c420000 lw r2,0x0000(r2)                 #                   loadValue = *((value * 4) + *0x80165f9c)
8013dca8: 00871821 addu r3,r4,r7                    #                   r4 + r23
8013dcac: ac620004 sw r2,0x0004(r3)                 #                   *(r4 + r23 + 4) = loadValue
8013dcb0: acc20000 sw r2,0x0000(r6)                 #                   *loopPtr = loadValue
8013dcb4: 2a220003 slti r2,r17,0x0003
8013dcb8: 10400008 beq r2,r0,0x8013dcdc             #                   if (innerCount < 3) {
8013dcbc: 00000000 nop
8013dcc0: 8c620004 lw r2,0x0004(r3)                 #                       checkValue = *(r4 + r23 + 4)
8013dcc4: 00000000 nop
8013dcc8: 04410002 bgez r2,0x8013dcd4               #                       if (checkValue < 0) {
8013dccc: 00000000 nop
8013dcd0: 244203ff addiu r2,r2,0x03ff               #                           checkValue = checkValue + 0x03ff
                                                    #                       }
8013dcd4: 00021283 sra r2,r2,0x0a                   #                       checkValue / 1024
8013dcd8: ac620004 sw r2,0x0004(r3)                 #                       *(r4 + r23 + 4) = checkValue / 1024
                                                    #                   }
8013dcdc: 24c60004 addiu r6,r6,0x0004               #                   loopPtr = loopPtr + 4
8013dce0: 24a50002 addiu r5,r5,0x0002               #                   ptr = ptr + 2
8013dce4: 00871021 addu r2,r4,r7                    #                   r4 + r23
8013dce8: ac400000 sw r0,0x0000(r2)                 #                   *(r4 + r23) = 0
8013dcec: ac960080 sw r22,0x0080(r4)                #                   *(r4 + 128) = cameraInstructionCount
8013dcf0: 26310001 addiu r17,r17,0x0001             #                   innerCount = innerCount + 1
8013dcf4: 2a220007 slti r2,r17,0x0007
8013dcf8: 1440ffe6 bne r2,r0,0x8013dc94
8013dcfc: 248400a4 addiu r4,r4,0x00a4               #                   r4 = r4 + 0xa4  
                                                    #               } while (innerCount < 7);
8013dd00: 0804f7a4 j 0x8013de90                                     
8013dd04: 26f70010 addiu r23,r23,0x0010             #               r23 = r23 + 16
                                                    #           } else {
8013dd08: 8fa90048 lw r9,0x0048(r29)                #               stack_0x48
8013dd0c: 00000000 nop
8013dd10: afa90030 sw r9,0x0030(r29)                #               stack_0x30 = stack_0x48
                                                    #               do {
8013dd14: 92830000 lbu r3,0x0000(r20)               #                   eventInstructionID = *eventInstructionPtr
8013dd18: 3402001f ori r2,r0,0x001f
8013dd1c: 14620005 bne r3,r2,0x8013dd34             #                   if (eventInstructionID == 0x1f) {               // 0x1f = Focus
8013dd20: 34020073 ori r2,r0,0x0073
8013dd24: 0c051d61 jal 0x80147584                   #                       ? 0x147584 (eventInstructionPtr + 1);
8013dd28: 26840001 addiu r4,r20,0x0001              
8013dd2c: 0804f795 j 0x8013de54
8013dd30: 00000000 nop                              
8013dd34: 14620006 bne r3,r2,0x8013dd50             #                   } else if (eventInstructionID == 0x73) {        // 0x73 (Unknown)
8013dd38: 34020038 ori r2,r0,0x0038
8013dd3c: 26840001 addiu r4,r20,0x0001
8013dd40: 0c051d29 jal 0x801474a4                   #                       ? 0x1474a4 (eventInstructionPtr + 1, sp + 16);
8013dd44: 27a50010 addiu r5,r29,0x0010
8013dd48: 0804f795 j 0x8013de54
8013dd4c: 00000000 nop
8013dd50: 14620007 bne r3,r2,0x8013dd70             #                   } else if (eventInstructionID == 0x38) {        // 0x38 = FocusSpeed
8013dd54: 34020019 ori r2,r0,0x0019
8013dd58: 26840001 addiu r4,r20,0x0001
8013dd5c: 27a50010 addiu r5,r29,0x0010
8013dd60: 0c051de0 jal 0x80147780                   #                       ? 0x147780 (eventInstructionPtr + 1, sp + 16, sp + 28);
8013dd64: 27a6001c addiu r6,r29,0x001c
8013dd68: 0804f795 j 0x8013de54
8013dd6c: 00000000 nop
8013dd70: 14620038 bne r3,r2,0x8013de54             #                   } 
                                                    #                   else if (eventInstructionID != 0x19) {          // 0x19 = Camera
8013dd74: 00008821 addu r17,r0,r0                   #                       innerCount = 0
8013dd78: 8fb20038 lw r18,0x0038(r29)               #                       r18 = stack_0x38
8013dd7c: 03c09821 addu r19,r30,r0                  #                       r19 = result_0x12eeb0
                                                    #                       do {
8013dd80: 02912021 addu r4,r20,r17                  #                           eventInstructionPtr + innerCount
8013dd84: 00912021 addu r4,r4,r17                   #                           eventInstructionPtr + (innerCount * 2)
8013dd88: 0c05181e jal 0x80146078                   #                           paramValue = Load Halfword (eventInstructionPtr + (innerCount * 2) + 1);
8013dd8c: 24840001 addiu r4,r4,0x0001               #                           eventInstructionPtr + (innerCount * 2) + 1
8013dd90: 00402821 addu r5,r2,r0                    #                           paramValue
8013dd94: 00051c00 sll r3,r5,0x10
8013dd98: 00031c03 sra r3,r3,0x10                   #                           paramValue
8013dd9c: 34022710 ori r2,r0,0x2710                 #                           0x2710
8013dda0: 1462000b bne r3,r2,0x8013ddd0             #                           if (paramValue == 0x2710) {
8013dda4: 2a220003 slti r2,r17,0x0003
8013dda8: 10400008 beq r2,r0,0x8013ddcc             #                               if (innerCount < 3) {
8013ddac: 00000000 nop
8013ddb0: 8e420000 lw r2,0x0000(r18)                #                                   r2 = *r18
8013ddb4: 00000000 nop
8013ddb8: 04410002 bgez r2,0x8013ddc4
8013ddbc: 2684000f addiu r4,r20,0x000f              #                                   eventInstructionPtr + 15
                                                    #                                   if (*r18 < 0) {
8013ddc0: 244203ff addiu r2,r2,0x03ff               #                                       r2 = r2 + 1023
                                                    #                                   }
8013ddc4: 0804f775 j 0x8013ddd4
8013ddc8: 00022a82 srl r5,r2,0x0a                   #                                   r5 = r2 / 1024
                                                    #                               } else {
8013ddcc: 96450000 lhu r5,0x0000(r18)               #                                   r5 = *r18
                                                    #                               }
                                                    #                           }
8013ddd0: 2684000f addiu r4,r20,0x000f              #                           eventInstructionPtr + 15             
                                                    
8013ddd4: 02778021 addu r16,r19,r23                 #                           r19 + r23
8013ddd8: 00051400 sll r2,r5,0x10
8013dddc: 00021403 sra r2,r2,0x10                   #                           r2 = r5
8013dde0: 0c05181e jal 0x80146078                   #                           paramValue = Load Halfword (eventInstructionPtr + 15);
8013dde4: ae020004 sw r2,0x0004(r16)                #                           *(r19 + r23 + 4) = r2
8013dde8: 00021400 sll r2,r2,0x10
8013ddec: 00021403 sra r2,r2,0x10                   #                           paramValue
8013ddf0: ae020000 sw r2,0x0000(r16)                #                           *(r19 + r23) = paramValue
8013ddf4: 8fa90030 lw r9,0x0030(r29)                #                           stack_0x30
8013ddf8: 00000000 nop
8013ddfc: 02691821 addu r3,r19,r9                   #                           r19 + stack_0x30
8013de00: 8c630000 lw r3,0x0000(r3)                 #                           *(r19 + stack_0x30)
8013de04: 8e040004 lw r4,0x0004(r16)                #                           *(r19 + r23 + 4)
8013de08: 00431021 addu r2,r2,r3                    #                           paramValue + *(r19 + stack_0x30)
8013de0c: ae020000 sw r2,0x0000(r16)                #                           *(r19 + r23) = paramValue + *(r19 + stack_0x30)
8013de10: 2a220003 slti r2,r17,0x0003
8013de14: 10400003 beq r2,r0,0x8013de24
8013de18: ae440000 sw r4,0x0000(r18)                #                           *r18 = *(r19 + r23 + 4)
                                                    #                           if (innerCount < 3) {
8013de1c: 00041280 sll r2,r4,0x0a                   #                               *(r19 + r23 + 4) * 1024
8013de20: ae420000 sw r2,0x0000(r18)                #                               *r18 = *(r19 + r23 + 4) * 1024
                                                    #                           }
8013de24: 34020004 ori r2,r0,0x0004
8013de28: 16220004 bne r17,r2,0x8013de3c
8013de2c: 26520004 addiu r18,r18,0x0004             #                           r18 = r18 + 4
                                                    #                           if (innerCount == 4) {
8013de30: 8e040004 lw r4,0x0004(r16)                       
8013de34: 0c051cb7 jal 0x801472dc                   #                               ? 0x1472dc (*(r19 + r23 + 4));
8013de38: 00000000 nop
                                                    #                           }
8013de3c: 26310001 addiu r17,r17,0x0001             #                           innerCount = innerCount + 1
8013de40: 2a220007 slti r2,r17,0x0007
8013de44: 1440ffce bne r2,r0,0x8013dd80
8013de48: 267300a4 addiu r19,r19,0x00a4             #                           r19 = r19 + 0xa4
                                                    #                       } while (innerCount < 7);
8013de4c: 0804f79d j 0x8013de74                     
8013de50: 26f70010 addiu r23,r23,0x0010             #                       r23 = r23 + 16
                                                    #                       break;
                                                    #                   }
8013de54: 92820000 lbu r2,0x0000(r20)               #                   eventInstructionID = *eventInstructionPtr
8013de58: 3c018015 lui r1,0x8015
8013de5c: 00220821 addu r1,r1,r2
8013de60: 9022d170 lbu r2,-0x2e90(r1)               #                   eventParameterLengthArray[eventInstructionID]
8013de64: 00000000 nop
8013de68: 24420001 addiu r2,r2,0x0001               #                   eventParameterLengthArray[eventInstructionID] + 1
8013de6c: 0804f745 j 0x8013dd14
8013de70: 0282a021 addu r20,r20,r2                  #                   eventInstructionPtr = eventInstructionPtr + eventParameterLengthArray[eventInstructionID] + 1
                                                    #               } while (true);
8013de74: 92820000 lbu r2,0x0000(r20)               #               eventInstructionID = *eventInstructionPtr
8013de78: 3c018015 lui r1,0x8015
8013de7c: 00220821 addu r1,r1,r2
8013de80: 9022d170 lbu r2,-0x2e90(r1)               #               eventParameterLengthArray[eventInstructionID]
8013de84: 00000000 nop
8013de88: 24420001 addiu r2,r2,0x0001               #               eventParameterLengthArray[eventInstructionID] + 1
8013de8c: 0282a021 addu r20,r20,r2                  #               eventInstructionPtr = eventInstructionPtr + eventParameterLengthArray[eventInstructionID] + 1
                                                    #           }
8013de90: 26b50001 addiu r21,r21,0x0001             #           count = count + 1
8013de94: 8fa90048 lw r9,0x0048(r29)                #           stack_0x48
8013de98: 02b6102a slt r2,r21,r22
8013de9c: 25290010 addiu r9,r9,0x0010               #           stack_0x48 + 16
8013dea0: 1440ff73 bne r2,r0,0x8013dc70
8013dea4: afa90048 sw r9,0x0048(r29)                #           stack_0x48 = stack_0x48 + 16
                                                    #       } while (count < cameraInstructionCount);
                                                    #   }
8013dea8: 3c128016 lui r18,0x8016
8013deac: 26525ed4 addiu r18,r18,0x5ed4             #   0x80165ed4
8013deb0: 03c08021 addu r16,r30,r0                  #   r16 = result_0x12eeb0
8013deb4: 0000a821 addu r21,r0,r0                   #   count = 0
8013deb8: 02408821 addu r17,r18,r0                  #   ptr = 0x80165ed4
                                                    #   do {
                                                    #       do {
8013debc: 3c028016 lui r2,0x8016
8013dec0: 94425fdc lhu r2,0x5fdc(r2)                #           *0x80165fdc
8013dec4: 00000000 nop
8013dec8: 14400009 bne r2,r0,0x8013def0             #           if (*0x80165fdc == 0) {
8013decc: 02002021 addu r4,r16,r0                   
8013ded0: 0c04f7ec jal 0x8013dfb0                   #               result_inner = Camera Fusion Inner Routine (r16, count);
8013ded4: 02a02821 addu r5,r21,r0
8013ded8: 96230000 lhu r3,0x0000(r17)               #               *ptr
8013dedc: 3c048016 lui r4,0x8016
8013dee0: 8c845f9c lw r4,0x5f9c(r4)                 #               *0x80165f9c
8013dee4: 00031880 sll r3,r3,0x02                   #               *ptr * 4
8013dee8: 00641821 addu r3,r3,r4                    #               *0x80165f9c + (*ptr * 4)
8013deec: ac620000 sw r2,0x0000(r3)                 #               *(*0x80165f9c + (*ptr * 4)) = result_inner
                                                    #           }
8013def0: 26310002 addiu r17,r17,0x0002             #           ptr = ptr + 2
8013def4: 26b50001 addiu r21,r21,0x0001             #           count = count + 1
8013def8: 2aa20003 slti r2,r21,0x0003
8013defc: 1440ffef bne r2,r0,0x8013debc
8013df00: 261000a4 addiu r16,r16,0x00a4             #           r16 = r16 + 0xa4
                                                    #       } while (count < 3);
8013df04: 34150003 ori r21,r0,0x0003                #       count = 3
8013df08: 26510006 addiu r17,r18,0x0006             #       ptr = 0x80165eda
                                                    #       do {
8013df0c: 02002021 addu r4,r16,r0
8013df10: 0c04f7ec jal 0x8013dfb0                   #           result_inner = Camera Fusion Inner Routine (r16, count);
8013df14: 02a02821 addu r5,r21,r0
8013df18: 96230000 lhu r3,0x0000(r17)               #           value = *ptr
8013df1c: 26310002 addiu r17,r17,0x0002             #           ptr = ptr + 2
8013df20: 26b50001 addiu r21,r21,0x0001             #           count = count + 1
8013df24: 3c048016 lui r4,0x8016
8013df28: 8c845f9c lw r4,0x5f9c(r4)                 #           *0x80165f9c
8013df2c: 00031880 sll r3,r3,0x02                   #           value * 4
8013df30: 00641821 addu r3,r3,r4                    #           (value * 4) + *0x80165f9c
8013df34: ac620000 sw r2,0x0000(r3)                 #           *((value * 4) + *0x80165f9c) = result_inner
8013df38: 2aa20007 slti r2,r21,0x0007
8013df3c: 1440fff3 bne r2,r0,0x8013df0c
8013df40: 261000a4 addiu r16,r16,0x00a4             #           r16 = r16 + 0xa4
                                                    #       } while (count < 7);
8013df44: 8fc3028c lw r3,0x028c(r30)                #       *(result_0x12eeb0 + 0x28c)
8013df48: 34020001 ori r2,r0,0x0001
8013df4c: 10620007 beq r3,r2,0x8013df6c             #       if (*(result_0x12eeb0 + 0x28c) == 1) break;
8013df50: 00000000 nop
8013df54: 0c051839 jal 0x801460e4                   #       ? 0x1460e4 ();
8013df58: 03c08021 addu r16,r30,r0
8013df5c: 0c0532a0 jal 0x8014ca80                   #       Switch To Next Thread ();
8013df60: 0000a821 addu r21,r0,r0                   #       count = 0
8013df64: 0804f7af j 0x8013debc
8013df68: 02408821 addu r17,r18,r0                  #       ptr = 0x80165ed4
                                                    #   } while (true);
8013df6c: 0c04bc13 jal 0x8012f04c                   #   ? 0x12f04c (result_0x12eeb0);
8013df70: 03c02021 addu r4,r30,r0
8013df74: 0c053256 jal 0x8014c958                   #   Stop Current Thread ();
8013df78: 00000000 nop
8013df7c: 8fbf0074 lw r31,0x0074(r29)
8013df80: 8fbe0070 lw r30,0x0070(r29)
8013df84: 8fb7006c lw r23,0x006c(r29)
8013df88: 8fb60068 lw r22,0x0068(r29)
8013df8c: 8fb50064 lw r21,0x0064(r29)
8013df90: 8fb40060 lw r20,0x0060(r29)
8013df94: 8fb3005c lw r19,0x005c(r29)
8013df98: 8fb20058 lw r18,0x0058(r29)
8013df9c: 8fb10054 lw r17,0x0054(r29)
8013dfa0: 8fb00050 lw r16,0x0050(r29)
8013dfa4: 27bd0078 addiu r29,r29,0x0078
8013dfa8: 03e00008 jr r31
8013dfac: 00000000 nop