Frame Timing Related? (0x1bf38)
Jump to navigation
Jump to search
# ROUTINE: FRAME TIMING RELATED? 0x1bf38 # Something to do with frame timing? //finds square root of input. # Parameters: # r4 = (p1) input # Returns: sqrt(input) 8001bf38: 4884f000 mtc2 r4,gtedr30_lzcs # GTE LZCS = p1 // Leading zero count source data 8001bf3c: 00000000 nop 8001bf40: 00000000 nop # // From GTE notes: "Reading LZCR returns the leading 0 count of LZCS if LZCS is positive and the leading 1 count of LZCS if LZCS is negative." 8001bf44: 4802f800 mfc2 r2,gtedr31_lzcr # leadingZeroCount = GTE LZCR // Leading zero count result 8001bf48: 24010020 addiu r1,r0,0x0020 # 32 8001bf4c: 10410019 beq r2,r1,0x8001bfb4 # if (leadingZeroCount != 32) { 8001bf50: 00000000 nop 8001bf54: 30480001 andi r8,r2,0x0001 # leadingZeroCount & 1 // Never used.... 8001bf58: 240afffe addiu r10,r0,-0x0002 # 0xfffffffe 8001bf5c: 004a5024 and r10,r2,r10 # evenLeadingZeroCount = leadingZeroCount & 0xfffffffe 8001bf60: 2409001f addiu r9,r0,0x001f # 31 8001bf64: 012a4822 sub r9,r9,r10 # 31 - evenLeadingZeroCount 8001bf68: 00094843 sra r9,r9,0x01 # (31 - evenLeadingZeroCount) / 2 8001bf6c: 214bffe8 addi r11,r10,-0x0018 # evenLeadingZeroCount - 24 8001bf70: 05600003 bltz r11,0x8001bf80 # if ((evenLeadingZeroCount - 24) > 0) { 8001bf74: 00000000 nop 8001bf78: 01646004 sllv r12,r4,r11 # tempValue = p1 << (evenLeadingZeroCount - 24) 8001bf7c: 10000003 beq r0,r0,0x8001bf8c # } else { 8001bf80: 240b0018 addiu r11,r0,0x0018 # 24 8001bf84: 016a5822 sub r11,r11,r10 # 24 - evenLeadingZeroCount 8001bf88: 01646007 srav r12,r4,r11 # tempValue = p1 << (24 - evenLeadingZeroCount) # } 8001bf8c: 218cffc0 addi r12,r12,-0x0040 # tempValue - 64 8001bf90: 000c6040 sll r12,r12,0x01 # (tempValue - 64) * 2 8001bf94: 3c0d8003 lui r13,0x8003 8001bf98: 01ac6821 addu r13,r13,r12 8001bf9c: 85adb8b8 lh r13,-0x4748(r13) # squareRootMod = *(0x8002d8b8 + ((tempValue - 64) * 2)) 8001bfa0: 00000000 nop 8001bfa4: 012d6804 sllv r13,r13,r9 # squareRootMod << ((31 - evenLeadingZeroCount) / 2) 8001bfa8: 000d1302 srl r2,r13,0x0c # result = (squareRootMod << ((31 - evenLeadingZeroCount) / 2)) >> 12 8001bfac: 03e00008 jr r31 # return result; 8001bfb0: 00000000 nop # } 8001bfb4: 03e00008 jr r31 # return 0; 8001bfb8: 24020000 addiu r2,r0,0x0000