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 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
267
268
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)
281 : "r0", "r1");
282 return j;
283
284
285
286
287
288
289
290
291
292
293
294
295
296
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().