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 262 of file scale8.h.

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

References LIB8STATIC_ALWAYS_INLINE, and scale.

Referenced by ColorFromPalette(), and hsv2rgb_rainbow().

+ Here is the caller graph for this function: