Mulscale
Jump to navigation
Jump to search
mulscale <Result> <Factor 1> <Factor 2> <Right Shift>
In C terms, this command performs roughly the expression <Result> = (<Factor 1> * <Factor 2>) >> <Right Shift>
.
In CON terms, it is very similar to the following series of commands:
set <Result> <Factor 1> mul <Result> <Factor 2> shiftr <Result> <Right Shift>
The main difference is that the calculation uses 64 bits to prevent overflow, while using gamevars for intermediate values would limit it to 31 bits.
For example, sin or cos use a scaling factor of 1:16384, corresponding to a 14 bit shift. So if you wanted to scale the result with a certain length, you would do:
sin Sine sprite[].ang mulscale Result Length Sine 14