diff options
author | Mark Kriegsman <kriegsman@tr.org> | 2014-11-06 16:55:38 +0300 |
---|---|---|
committer | Mark Kriegsman <kriegsman@tr.org> | 2014-11-06 16:55:38 +0300 |
commit | 0889b8058830fa82a7deb36a5f0f58f756468695 (patch) | |
tree | 1dad4ef7a41eaffc79c1be99d53a4df2638f84b0 | |
parent | 38e08de1dc039f2bd402787113672e7b537619c0 (diff) |
Slight speedup and code size reduction by changing 16-bit-shift+AND to 8-bit shift (ASL) with no AND needed afterwards. The compiler should have done this itself but didn't; film at 0x0B.
-rw-r--r-- | noise.cpp | 12 |
1 files changed, 6 insertions, 6 deletions
@@ -342,9 +342,9 @@ int8_t inoise8_raw(uint16_t x, uint16_t y, uint16_t z) uint8_t w = z; // Get a signed version of the above for the grad function - int8_t xx = (x>>1) & 0x7F; - int8_t yy = (y>>1) & 0x7F; - int8_t zz = (z>>1) & 0x7F; + int8_t xx = ((uint8_t)(x)>>1) & 0x7F; + int8_t yy = ((uint8_t)(y)>>1) & 0x7F; + int8_t zz = ((uint8_t)(z)>>1) & 0x7F; uint8_t N = 0x80; // u = FADE(u); v = FADE(v); w = FADE(w); @@ -386,8 +386,8 @@ int8_t inoise8_raw(uint16_t x, uint16_t y) uint8_t v = y; // Get a signed version of the above for the grad function - int8_t xx = (x>>1) & 0x7F; - int8_t yy = (y>>1) & 0x7F; + int8_t xx = ((uint8_t)(x)>>1) & 0x7F; + int8_t yy = ((uint8_t)(y)>>1) & 0x7F; uint8_t N = 0x80; // u = FADE(u); v = FADE(v); w = FADE(w); @@ -421,7 +421,7 @@ int8_t inoise8_raw(uint16_t x) uint8_t u = x; // Get a signed version of the above for the grad function - int8_t xx = (x>>1) & 0x7F; + int8_t xx = ((uint8_t)(x)>>1) & 0x7F; uint8_t N = 0x80; u = scale8(u,u); |