Prev: CD3A Up: Map Next: CDEC
CDD6: Multiplies C by the top three bits of A, then divides by 8 with rounding
Used by the routines at build_curve_table and build_height_table.
Input
A Multiplier (number to multiply by) e.g. $A0, $E7, $20, $C0, $E6
C Multiplicand (value to multiply) e.g. $05, $02, $05, $03, $FE
Output
A Result e.g. $03, $02, $01, $02, $FE
scale_curvature_or_height CDD6 LD B,$03 3 iterations only
CDD8 LD E,A Copy of multiplier to destroy
CDD9 XOR A Initialise total to zero
mult_loop CDDA RL E Shift the most significant bit out of multiplier
CDDC JR NC,mult_continue If it was set then increase total by multiplicand
CDDE ADD A,C
mult_continue CDDF ADD A,A Double the total
CDE0 DJNZ mult_loop While iterations remain, goto mult_loop
CDE2 RRA Undo final doubling
CDE3 SRA A Divide by 8 with rounding
CDE5 SRA A
CDE7 SRA A
CDE9 ADC A,$00
CDEB RET Return
Prev: CD3A Up: Map Next: CDEC