FastLED 3.9.15
Loading...
Searching...
No Matches

◆ scale8_video_LEAVING_R1_DIRTY()

LIB8STATIC_ALWAYS_INLINE uint8_t scale8_video_LEAVING_R1_DIRTY ( uint8_t i,
fract8 scale )

This version of scale8_video() does not clean up the R1 register on AVR.

If you are doing several "scale8_video()'s" in a row, use this, and then explicitly call cleanup_R1().

Warning
You MUST call cleanup_R1() after using this function!
Parameters
iinput value to scale
scalescale factor, in n/256 units
Returns
scaled value
See also
scale8_video()

Definition at line 268 of file scale8.h.

269 {
270#if SCALE8_C == 1 || defined(LIB8_ATTINY)
271 uint8_t j = (((int)i * (int)scale) >> 8) + ((i && scale) ? 1 : 0);
272 // uint8_t nonzeroscale = (scale != 0) ? 1 : 0;
273 // uint8_t j = (i == 0) ? 0 : (((int)i * (int)(scale) ) >> 8) +
274 // nonzeroscale;
275 return j;
276#elif SCALE8_AVRASM == 1
277 uint8_t j = 0;
278 asm volatile(" tst %[i]\n\t"
279 " breq L_%=\n\t"
280 " mul %[i], %[scale]\n\t"
281 " mov %[j], r1\n\t"
282 " breq L_%=\n\t"
283 " subi %[j], 0xFF\n\t"
284 "L_%=: \n\t"
285 : [j] "+d"(j) // r16-r31, restricted by subi
286 : [i] "r"(i), [scale] "r"(scale)
287 : "r0", "r1");
288 return j;
289 // uint8_t nonzeroscale = (scale != 0) ? 1 : 0;
290 // asm volatile(
291 // " tst %0 \n"
292 // " breq L_%= \n"
293 // " mul %0, %1 \n"
294 // " mov %0, r1 \n"
295 // " add %0, %2 \n"
296 // " clr __zero_reg__ \n"
297 // "L_%=: \n"
298 // : "+a" (i)
299 // : "a" (scale), "a" (nonzeroscale)
300 // : "r0", "r1");
301 // // Return the result
302 // return i;
303#else
304#error "No implementation for scale8_video_LEAVING_R1_DIRTY available."
305#endif
306}
UISlider scale("Scale", 1.0f, 0.0f, 1.0f, 0.01f)

References LIB8STATIC_ALWAYS_INLINE, and scale.

Referenced by fl::ColorFromPalette(), and hsv2rgb_rainbow().

+ Here is the caller graph for this function: