Date: | 2013-02-01 16:06:32 (10 years 8 months ago) |
---|---|
Author: | Werner Almesberger |
Commit: | 47e5859c5b505b0a26eacc69b76fe1051e488008 |
Message: | ubb-la/gui.c: move sample retrieval to new function get_sample Better than open-coding this non-trivial formula over and over again. |
Files: |
ubb-la/gui.c (3 diffs) |
Change Details
ubb-la/gui.c | ||
---|---|---|
112 | 112 | static int user_ref = -1; |
113 | 113 | |
114 | 114 | |
115 | /* ----- Helper functions -------------------------------------------------- */ | |
116 | ||
117 | ||
118 | static inline uint8_t get_sample(const uint8_t *buf, unsigned i) | |
119 | { | |
120 | return (buf[i >> 1] >> 4*(~i & 1)) & 0xf; | |
121 | } | |
122 | ||
123 | ||
115 | 124 | /* ----- SDL initialization and screen-wide functions ---------------------- */ |
116 | 125 | |
117 | 126 | |
... | ... | |
254 | 263 | skip, nibbles, nibbles-skip, x0, x1, x1-x0, f, f*(nibbles-skip)); |
255 | 264 | x = x0; |
256 | 265 | for (i = skip; i != nibbles; i++) { |
257 | v = (buf[i >> 1] >> 4*(~i & 1)) & 0xf; | |
266 | v = get_sample(buf, i); | |
258 | 267 | for (j = 0; j != 4; j++) { |
259 | 268 | bit = (v >> j) & 1; |
260 | 269 | if (bit == last[j] || last[j] == -1) { |
... | ... | |
288 | 297 | changes[j] = 0; |
289 | 298 | } |
290 | 299 | while (i != n) { |
291 | v = (buf[i >> 1] >> 4*(~i & 1)) & 0xf; | |
300 | v = get_sample(buf, i); | |
292 | 301 | for (j = 0; j != 4; j++) { |
293 | 302 | bit = (v >> j) & 1; |
294 | 303 | if (bit != next[j]) { |
Branches:
master