Date:2013-02-01 16:06:32 (6 years 7 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
112112static int user_ref = -1;
113113
114114
115/* ----- Helper functions -------------------------------------------------- */
116
117
118static inline uint8_t get_sample(const uint8_t *buf, unsigned i)
119{
120    return (buf[i >> 1] >> 4*(~i & 1)) & 0xf;
121}
122
123
115124/* ----- SDL initialization and screen-wide functions ---------------------- */
116125
117126
...... 
254263        skip, nibbles, nibbles-skip, x0, x1, x1-x0, f, f*(nibbles-skip));
255264    x = x0;
256265    for (i = skip; i != nibbles; i++) {
257        v = (buf[i >> 1] >> 4*(~i & 1)) & 0xf;
266        v = get_sample(buf, i);
258267        for (j = 0; j != 4; j++) {
259268            bit = (v >> j) & 1;
260269            if (bit == last[j] || last[j] == -1) {
...... 
288297            changes[j] = 0;
289298        }
290299        while (i != n) {
291            v = (buf[i >> 1] >> 4*(~i & 1)) & 0xf;
300            v = get_sample(buf, i);
292301            for (j = 0; j != 4; j++) {
293302                bit = (v >> j) & 1;
294303                if (bit != next[j]) {

Archive Download the corresponding diff file

Branches:
master



interactive