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

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

References LIB8STATIC_ALWAYS_INLINE, and scale.

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

+ Here is the caller graph for this function: