Scale two one-byte values by a third one, which is treated as the numerator of a fraction whose demominator is 256.
In other words, it computes i,j * (scale / 256), ensuring that non-zero values passed in remain non zero, no matter how low the scale argument.
- Warning
- This function always modifies its arguments in place!
- Parameters
-
i | first value to scale |
j | second value to scale |
scale | scale factor, in n/256 units |
Definition at line 453 of file scale8.h.
453 {
454#if SCALE8_C == 1
455 uint8_t nonzeroscale = (
scale != 0) ? 1 : 0;
456 i = (i == 0) ? 0 : (((int)i * (int)(
scale)) >> 8) + nonzeroscale;
457 j = (j == 0) ? 0 : (((int)j * (int)(
scale)) >> 8) + nonzeroscale;
458#elif SCALE8_AVRASM == 1
462#else
463#error "No implementation for nscale8x2 available."
464#endif
465}
UISlider scale("Scale", 1.0f, 0.0f, 1.0f, 0.01f)
LIB8STATIC_ALWAYS_INLINE void cleanup_R1()
Clean up the r1 register after a series of *LEAVING_R1_DIRTY calls.
LIB8STATIC_ALWAYS_INLINE void nscale8_video_LEAVING_R1_DIRTY(uint8_t &i, fract8 scale)
In place modifying version of scale8_video() that does not clean up the R1 register on AVR.
References cleanup_R1(), LIB8STATIC, nscale8_video_LEAVING_R1_DIRTY(), and scale.