Focus Speed Event Instruction
Jump to navigation
Jump to search
# ROUTINE: FOCUS SPEED EVENT INSTRUCTION # Parameters: # r4 = (params) Event instruction parameters # r5 = (p2) *(0x80165f9c) + 0x68 # r6 = (p3) *(0x80165f9c) + 0x74 80147780: 27bdffa0 addiu r29,r29,-0x0060 80147784: afb40048 sw r20,0x0048(r29) 80147788: 0080a021 addu r20,r4,r0 # params 8014778c: afb1003c sw r17,0x003c(r29) 80147790: 00a08821 addu r17,r5,r0 # p2OffsetPtr = p2 80147794: afb00038 sw r16,0x0038(r29) 80147798: 00c08021 addu r16,r6,r0 # p3 8014779c: afbf005c sw r31,0x005c(r29) 801477a0: afbe0058 sw r30,0x0058(r29) 801477a4: afb70054 sw r23,0x0054(r29) 801477a8: afb60050 sw r22,0x0050(r29) 801477ac: afb5004c sw r21,0x004c(r29) 801477b0: afb30044 sw r19,0x0044(r29) 801477b4: 0c05181e jal 0x80146078 # speed = Load Halfword (params); 801477b8: afb20040 sw r18,0x0040(r29) 801477bc: 00021400 sll r2,r2,0x10 801477c0: 00021403 sra r2,r2,0x10 # speed 801477c4: 26940003 addiu r20,r20,0x0003 # params + 3 801477c8: 00009821 addu r19,r0,r0 # r19 = 0 801477cc: 341e2710 ori r30,r0,0x2710 # 0x2710 801477d0: 27b70010 addiu r23,r29,0x0010 # localBasePtr 801477d4: 02e09021 addu r18,r23,r0 # localPtr = localBasePtr 801477d8: 0200a821 addu r21,r16,r0 # p3OffsetPtr = p3 801477dc: 02808021 addu r16,r20,r0 # paramPtr = params + 3 // First param of the following Camera instruction 801477e0: afa20030 sw r2,0x0030(r29) # speed # do { 801477e4: 0c05181e jal 0x80146078 # param = Load Halfword (paramPtr); 801477e8: 02002021 addu r4,r16,r0 801477ec: 00021400 sll r2,r2,0x10 801477f0: 00021c03 sra r3,r2,0x10 # param 801477f4: 147e0003 bne r3,r30,0x80147804 # if (param == 0x2710) { 801477f8: 00000000 nop 801477fc: 08051e09 j 0x80147824 80147800: ae400000 sw r0,0x0000(r18) # *localPtr = 0 # } else { 80147804: 8e220000 lw r2,0x0000(r17) # dividend = *p2OffsetPtr 80147808: 00000000 nop 8014780c: 04410002 bgez r2,0x80147818 # if (dividend < 0) { 80147810: 00000000 nop 80147814: 244203ff addiu r2,r2,0x03ff # dividend = dividend + 1023 # } 80147818: 00021283 sra r2,r2,0x0a # dividend / 1024 8014781c: 00621023 subu r2,r3,r2 # param - (dividend / 1024) 80147820: ae420000 sw r2,0x0000(r18) # *localPtr = param - (dividend / 1024) # } 80147824: 0c05181e jal 0x80146078 # param = Load Halfword (paramPtr + 6); 80147828: 26040006 addiu r4,r16,0x0006 8014782c: 00021400 sll r2,r2,0x10 80147830: 00021c03 sra r3,r2,0x10 # param 80147834: 147e0003 bne r3,r30,0x80147844 # if (param == 0x2710) { 80147838: 00000000 nop 8014783c: 08051e15 j 0x80147854 80147840: ae400010 sw r0,0x0010(r18) # *(localPtr + 16) = 0 # } else { 80147844: 8ea20000 lw r2,0x0000(r21) # *p3OffsetPtr 80147848: 00000000 nop 8014784c: 00621023 subu r2,r3,r2 # param - *p3OffsetPtr 80147850: ae420010 sw r2,0x0010(r18) # *(localPtr + 16) = param - *p3OffsetPtr # } 80147854: 8e420000 lw r2,0x0000(r18) # local = *localPtr 80147858: 00000000 nop 8014785c: 00420018 mult r2,r2 80147860: 00001812 mflo r3 # local * local 80147864: 8e420010 lw r2,0x0010(r18) # local2 = *(localPtr + 10) 80147868: 00000000 nop 8014786c: 00420018 mult r2,r2 80147870: 26b50004 addiu r21,r21,0x0004 # p3OffsetPtr = p3OffsetPtr + 4 80147874: 26100002 addiu r16,r16,0x0002 # paramPtr = paramPtr + 2 80147878: 26310004 addiu r17,r17,0x0004 # p2OffsetPtr = p2OffsetPtr + 4 8014787c: 26520004 addiu r18,r18,0x0004 # localPtr = localPtr + 4 80147880: 00001012 mflo r2 # local2 * local2 80147884: 02c2b021 addu r22,r22,r2 # r22 = r22 + (local2 * local2) // r22 starts as uninitialized register value????? 80147888: 26e2000c addiu r2,r23,0x000c # localBasePtr + 12 8014788c: 0242102a slt r2,r18,r2 80147890: 1440ffd4 bne r2,r0,0x801477e4 80147894: 02639821 addu r19,r19,r3 # r19 = r19 + (local * local) # } while (localPtr < (localBasePtr + 12)); 80147898: 00131040 sll r2,r19,0x01 # r19 * 2 8014789c: 0056102a slt r2,r2,r22 801478a0: 10400003 beq r2,r0,0x801478b0 # if ((r19 * 2) < r22) { 801478a4: 001617c2 srl r2,r22,0x1f 801478a8: 02c21021 addu r2,r22,r2 801478ac: 00029843 sra r19,r2,0x01 # r19 = (r22 * 2) / 2 # } 801478b0: 0c006fce jal 0x8001bf38 # result_0x1bf38 = Frame Timing Related? (0x1bf38) (r19); 801478b4: 02602021 addu r4,r19,r0 801478b8: 8fa70030 lw r7,0x0030(r29) # speed 801478bc: 00000000 nop 801478c0: 0047001a div r2,r7 801478c4: 00009812 mflo r19 # frames = result_0x1bf38 / speed 801478c8: 00000000 nop 801478cc: 16600002 bne r19,r0,0x801478d8 801478d0: 2684000e addiu r4,r20,0x000e # cameraFramesPtr = params + 17 # if (frames == 0) { 801478d4: 34130001 ori r19,r0,0x0001 # frames = 1 # } 801478d8: 00132c00 sll r5,r19,0x10 801478dc: 0c051825 jal 0x80146094 # Store Halfword (cameraFramesPtr, frames); 801478e0: 00052c03 sra r5,r5,0x10 801478e4: 8fbf005c lw r31,0x005c(r29) 801478e8: 8fbe0058 lw r30,0x0058(r29) 801478ec: 8fb70054 lw r23,0x0054(r29) 801478f0: 8fb60050 lw r22,0x0050(r29) 801478f4: 8fb5004c lw r21,0x004c(r29) 801478f8: 8fb40048 lw r20,0x0048(r29) 801478fc: 8fb30044 lw r19,0x0044(r29) 80147900: 8fb20040 lw r18,0x0040(r29) 80147904: 8fb1003c lw r17,0x003c(r29) 80147908: 8fb00038 lw r16,0x0038(r29) 8014790c: 27bd0060 addiu r29,r29,0x0060 80147910: 03e00008 jr r31 80147914: 00000000 nop