LIB: pm_cmath
CStyle Lib: Math operations
pmrom_cmath.s
Type: Source File
Dependency: pm_init.s and pm_cstyle.s
Including Rules: Must be after ROM (PM_HEADER) declaration and in bank 0
Functions
Absolute value
c_abs num
[CVar] num: 16-bits number
Returns: Absolute value of num
Compute square root
c_sqrt num
[CVar] num: 16-bits number
Returns: Square root of num
Initialize random number generator
c_srand num
[CVar] num: 16-bits number
No return
Generate pseudo-random number
c_rand
Returns: 16-bits random number
Generate fast random number
c_randf
Returns: 16-bits random number
This function is much faster than c_rand because it uses the Pokémon-Mini hardware to re-seed instead of mathematical operations.
Accurancy is completely unpredictable.
Return sine of an angle
c_sin angle
[CVar] angle: angle (0x0000 = 0º, 0x0080 = 180º, 0x0100 = 360º)
Returns: sine value in fixed point 8.8
Return cosine of an angle
c_cos angle
[CVar] angle: angle (0x0000 = 0º, 0x0080 = 180º, 0x0100 = 360º)
Returns: cosine value in fixed point 8.8
Return tangent of an angle
c_tan angle
[CVar] angle: angle (0x0000 = 0º, 0x0080 = 180º, 0x0100 = 360º)
Returns: tangent value in fixed point 8.8
Compute arc sine
c_asin sinvalue
[CVar] sinvalue: Sine value in fixed point 8.8
Returns: Angle (0x0000 = 0º, 0x0040 = 90º, 0xFFC0 = -90º)
Compute arc cosine
c_acos cosvalue
[CVar] cosvalue: Cosine value in fixed point 8.8
Returns: Angle (0x0000 = 0º, 0x0040 = 90º, 0xFFC0 = -90º)
Compute arc tangent
c_atan tanvalue
[CVar] tanvalue: Tangent value in fixed point 8.8
Returns: Angle (0x0000 = 0º, 0x0040 = 90º, 0xFFC0 = -90º)
Compute arc tangent with two parameters
c_atan2 yval, xval
[CVar] yval: Number representing the y-coordinate
[CVar] xval: Number representing the x-coordinate
Returns: Angle (0x0000 = 0º, 0x0080 = 180º, 0xFF80 = -180º)
Unsigned 16-bits multiplication
c_umul multiplicand, multiplier
[CVar] multiplicand: Unsigned 16-bits value
[CVar] multiplier: Unsigned 16-bits value
Returns: Product of multiplication
Signed 16-bits multiplication
c_smul multiplicand, multiplier
[CVar] multiplicand: Unsigned 16-bits value
[CVar] multiplier: Unsigned 16-bits value
Returns: Product of multiplication
Unsigned 16-bits division
c_udiv dividend, divisor
[CVar] dividend: Unsigned 16-bits value
[CVar] divisor: Unsigned 16-bits value
Returns: Quotient of division
Signed 16-bits division
c_sdiv dividend, divisor
[CVar] dividend: Unsigned 16-bits value
[CVar] divisor: Unsigned 16-bits value
Returns: Quotient of division
Unsigned 16-bits modulus
c_umod dividend, divisor
[CVar] dividend: Unsigned 16-bits value
[CVar] divisor: Unsigned 16-bits value
Returns: Remainer of division
Signed 16-bits modulus
c_smod dividend, divisor
[CVar] dividend: Unsigned 16-bits value
[CVar] divisor: Unsigned 16-bits value
Returns: Remainer of division
Number search in incrementing array
c_nisearch nkey, table_addr, sizen
[CVar] nkey: Number key for the search
[CPtr] table_addr: Array table of 16-bits to search
[CVar] sizen: Size of the table in bytes
Returns: Offset of the table in words
Number search in decrementing array
c_ndsearch nkey, table_addr, sizen
[CVar] nkey: Number key for the search
[CPtr] table_addr: Array table of 16-bits to search
[CVar] sizen: Size of the table in bytes
Returns: Offset of the table in words