Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/FastLED/FastLED.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMark Kriegsman <kriegsman@tr.org>2014-04-08 07:29:21 +0400
committerMark Kriegsman <kriegsman@tr.org>2014-04-08 07:29:21 +0400
commit161a3f06b2f07f654a13b9343442a228574976f2 (patch)
tree94dc699ba32dea1314d1b83dfb3c21a71e09deff
parent46464dbd4d8d570953ee42887b2611b080892382 (diff)
Fixing scale8_video( {X>0}, 0)
-rw-r--r--lib8tion.h15
1 files changed, 9 insertions, 6 deletions
diff --git a/lib8tion.h b/lib8tion.h
index a2e70fe4..74b8580f 100644
--- a/lib8tion.h
+++ b/lib8tion.h
@@ -484,18 +484,21 @@ LIB8STATIC uint8_t scale8( uint8_t i, fract8 scale)
LIB8STATIC uint8_t scale8_video( uint8_t i, fract8 scale)
{
#if SCALE8_C == 1 || defined(LIB8_ATTINY)
- uint8_t j = (((int)i * (int)scale) >> 8) + (i?1:0);
+ uint8_t j = (((int)i * (int)scale) >> 8) + ((i&&scale)?1:0);
// uint8_t nonzeroscale = (scale != 0) ? 1 : 0;
// uint8_t j = (i == 0) ? 0 : (((int)i * (int)(scale) ) >> 8) + nonzeroscale;
return j;
#elif SCALE8_AVRASM == 1
uint8_t j=0;
asm volatile(
- "mul %[i], %[scale]\n\t"
- "mov %[j], r1\n\t"
- "clr __zero_reg__\n\t"
- "cpse %[i], r1\n\t"
- "subi %[j], 0xFF\n\t"
+ " tst %[i]\n\t"
+ " breq L_%=\n\t"
+ " mul %[i], %[scale]\n\t"
+ " mov %[j], r1\n\t"
+ " clr __zero_reg__\n\t"
+ " cpse %[scale], r1\n\t"
+ " subi %[j], 0xFF\n\t"
+ "L_%=: \n\t"
: [j] "+a" (j)
: [i] "a" (i), [scale] "a" (scale)
: "r0", "r1");