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
-
i | input value to scale |
scale | scale 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
277
278
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)
291 : "r0", "r1");
292 return j;
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307#else
308#error "No implementation for scale8_video_LEAVING_R1_DIRTY available."
309#endif
310}
References LIB8STATIC_ALWAYS_INLINE, and scale.
Referenced by fl::ColorFromPalette(), and hsv2rgb_rainbow().