Sin Call Function
(Redirected from Secondary sin call function)
Jump to navigation
Jump to search
Inputs: r4 = Angle value (0x0000 - 0x1000 // 0 - 360) output: r2 = sin(angle) * 4096 {0 <= r4 <= 90} r2 = sin(180 - angle) * 4096 {90 <= r4 <= 180} r2 = -sin(angle - 180) * 4096 {180 <= r4 <= 270} r2 = -sin(360 - angle) * 4096 {270 <= r4 <= 360} 0001bb98: 28820801 slti r2,r4,0x0801 Set if angle input < 0x0801 (<= 180 degrees) 0001bb9c: 10400010 beq r2,r0,0x0001bbe0 branch if angle > 180 degrees 0001bba0: 28820401 slti r2,r4,0x0401 set if angle input < 0x401 (<= 90 degrees) 0001bba4: 10400006 beq r2,r0,0x0001bbc0 branch if angle input > 90 degrees (less than 180, greater than 90). -x +y quadrant 0001bba8: 00041040 sll r2,r4,0x01 If less than 90 degrees (/): 0001bbac: 3c018003 lui r1,0x8003 0001bbb0: 00220821 addu r1,r1,r2 0001bbb4: 8422b0a4 lh r2,-0x4f5c(r1) Load sin(angle) 0001bbb8: 08006f08 j 0x0001bc20 0001bbbc: 00000000 nop if angle is > 90 degrees (\) 0001bbc0: 34020800 ori r2,r0,0x0800 r2 = 0x800 (180 degrees) 0001bbc4: 00441023 subu r2,r2,r4 180 - angle 0001bbc8: 00021040 sll r2,r2,0x01 0001bbcc: 3c018003 lui r1,0x8003 0001bbd0: 00220821 addu r1,r1,r2 0001bbd4: 8422b0a4 lh r2,-0x4f5c(r1) Load sin(angle) 0001bbd8: 08006f08 j 0x0001bc20 0001bbdc: 00000000 nop if angle > 270 degrees (-\) 0001bbe0: 28820c01 slti r2,r4,0x0c01 set if angle < 0x0c01 (angle < 270) 0001bbe4: 14400009 bne r2,r0,0x0001bc0c Branch if angle < 270 degrees 0001bbe8: 00041040 sll r2,r4,0x01 0001bbec: 34021000 ori r2,r0,0x1000 r2 = 360 degrees 0001bbf0: 00441023 subu r2,r2,r4 360 - angle 0001bbf4: 00021040 sll r2,r2,0x01 0001bbf8: 3c018003 lui r1,0x8003 0001bbfc: 00220821 addu r1,r1,r2 0001bc00: 8422b0a4 lh r2,-0x4f5c(r1) load sin(angle) 0001bc04: 08006f08 j 0x0001bc20 0001bc08: 00021023 subu r2,r0,r2 get negative if angle > 0x180 degrees (-/) 0001bc0c: 3c018003 lui r1,0x8003 0001bc10: 00220821 addu r1,r1,r2 0001bc14: 8422a0a4 lh r2,-0x5f5c(r1) load sin(angle - 180) 0001bc18: 00000000 nop 0001bc1c: 00021023 subu r2,r0,r2 get negative 0001bc20: 03e00008 jr r31 0001bc24: 00000000 nop