diff options
Diffstat (limited to 'apps/plugins/lib')
-rw-r--r-- | apps/plugins/lib/gray.h | 10 | ||||
-rw-r--r-- | apps/plugins/lib/gray_core.c | 216 | ||||
-rw-r--r-- | apps/plugins/lib/gray_draw.c | 37 | ||||
-rw-r--r-- | apps/plugins/lib/gray_parm.c | 16 |
4 files changed, 239 insertions, 40 deletions
diff --git a/apps/plugins/lib/gray.h b/apps/plugins/lib/gray.h index 96dec346cf..398462fd81 100644 --- a/apps/plugins/lib/gray.h +++ b/apps/plugins/lib/gray.h | |||
@@ -38,7 +38,8 @@ | |||
38 | 38 | ||
39 | /* Library initialisation and release */ | 39 | /* Library initialisation and release */ |
40 | int gray_init(struct plugin_api* newrb, unsigned char *gbuf, long gbuf_size, | 40 | int gray_init(struct plugin_api* newrb, unsigned char *gbuf, long gbuf_size, |
41 | bool buffered, int width, int bheight, int depth, long *buf_taken); | 41 | bool buffered, int width, int bheight, int depth, int gamma, |
42 | long *buf_taken); | ||
42 | void gray_release(void); | 43 | void gray_release(void); |
43 | 44 | ||
44 | /* Special functions */ | 45 | /* Special functions */ |
@@ -138,9 +139,12 @@ struct _gray_info | |||
138 | #endif | 139 | #endif |
139 | unsigned char *cur_buffer; /* start of current chunky pixel buffer */ | 140 | unsigned char *cur_buffer; /* start of current chunky pixel buffer */ |
140 | unsigned char *back_buffer;/* start of chunky pixel back buffer */ | 141 | unsigned char *back_buffer;/* start of chunky pixel back buffer */ |
142 | unsigned char idxtable[256]; /* calculated brightness -> index translation table */ | ||
143 | int fg_index; /* current foreground index */ | ||
144 | int bg_index; /* current background index */ | ||
145 | int fg_brightness; /* current foreground brightness, for returning */ | ||
146 | int bg_brightness; /* current background brightness, for returning */ | ||
141 | int drawmode; /* current draw mode */ | 147 | int drawmode; /* current draw mode */ |
142 | int fg_brightness; /* current foreground brightness */ | ||
143 | int bg_brightness; /* current background brightness */ | ||
144 | int curfont; /* current selected font */ | 148 | int curfont; /* current selected font */ |
145 | }; | 149 | }; |
146 | 150 | ||
diff --git a/apps/plugins/lib/gray_core.c b/apps/plugins/lib/gray_core.c index 6cc33e05da..ef41e7e215 100644 --- a/apps/plugins/lib/gray_core.c +++ b/apps/plugins/lib/gray_core.c | |||
@@ -33,7 +33,117 @@ struct plugin_api *_gray_rb = NULL; /* global api struct pointer */ | |||
33 | struct _gray_info _gray_info; /* global info structure */ | 33 | struct _gray_info _gray_info; /* global info structure */ |
34 | #ifndef SIMULATOR | 34 | #ifndef SIMULATOR |
35 | short _gray_random_buffer; /* buffer for random number generator */ | 35 | short _gray_random_buffer; /* buffer for random number generator */ |
36 | |||
37 | #if CONFIG_LCD == LCD_SSD1815 | ||
38 | /* measured and interpolated curve */ | ||
39 | static const unsigned char lcdlinear[256] = { | ||
40 | 0, 3, 5, 8, 11, 13, 16, 18, | ||
41 | 21, 23, 26, 28, 31, 33, 36, 38, | ||
42 | 40, 42, 45, 47, 49, 51, 53, 55, | ||
43 | 57, 59, 60, 62, 64, 66, 67, 69, | ||
44 | 70, 72, 73, 74, 76, 77, 78, 79, | ||
45 | 81, 82, 83, 84, 85, 86, 87, 88, | ||
46 | 88, 89, 90, 91, 92, 92, 93, 94, | ||
47 | 95, 95, 96, 97, 97, 98, 99, 99, | ||
48 | 100, 101, 102, 102, 103, 104, 104, 105, | ||
49 | 106, 106, 107, 107, 108, 109, 109, 110, | ||
50 | 111, 111, 112, 113, 113, 114, 114, 115, | ||
51 | 116, 116, 117, 117, 118, 119, 119, 120, | ||
52 | 120, 121, 121, 122, 122, 123, 123, 124, | ||
53 | 124, 125, 125, 126, 126, 127, 127, 128, | ||
54 | 128, 128, 129, 129, 130, 130, 131, 131, | ||
55 | 132, 132, 133, 133, 133, 134, 134, 135, | ||
56 | 135, 136, 136, 137, 137, 138, 138, 138, | ||
57 | 139, 139, 140, 140, 141, 141, 142, 142, | ||
58 | 143, 143, 144, 144, 145, 145, 146, 146, | ||
59 | 147, 147, 148, 148, 148, 149, 149, 150, | ||
60 | 150, 151, 151, 152, 152, 153, 153, 153, | ||
61 | 154, 154, 155, 155, 156, 156, 157, 157, | ||
62 | 158, 158, 158, 159, 159, 160, 160, 161, | ||
63 | 161, 162, 162, 163, 163, 164, 164, 165, | ||
64 | 165, 166, 167, 167, 168, 168, 169, 169, | ||
65 | 170, 171, 171, 172, 173, 173, 174, 175, | ||
66 | 176, 176, 177, 178, 179, 180, 181, 181, | ||
67 | 182, 183, 184, 185, 186, 188, 189, 190, | ||
68 | 191, 192, 194, 195, 196, 198, 199, 201, | ||
69 | 202, 204, 205, 207, 209, 211, 213, 215, | ||
70 | 217, 219, 222, 224, 226, 229, 231, 234, | ||
71 | 236, 239, 242, 244, 247, 250, 252, 255 | ||
72 | }; | ||
73 | #elif CONFIG_LCD == LCD_S1D15E06 | ||
74 | /* measured and interpolated curve */ | ||
75 | static const unsigned char lcdlinear[256] = { | ||
76 | 0, 5, 11, 16, 21, 27, 32, 37, | ||
77 | 42, 47, 51, 56, 60, 64, 68, 72, | ||
78 | 75, 78, 81, 84, 87, 89, 91, 93, | ||
79 | 95, 96, 98, 99, 101, 102, 103, 104, | ||
80 | 105, 106, 107, 108, 109, 110, 111, 111, | ||
81 | 112, 113, 113, 114, 115, 115, 116, 117, | ||
82 | 117, 118, 118, 119, 119, 120, 120, 121, | ||
83 | 121, 122, 122, 123, 123, 124, 124, 125, | ||
84 | 125, 126, 126, 127, 127, 127, 128, 128, | ||
85 | 129, 129, 130, 130, 131, 131, 132, 132, | ||
86 | 133, 133, 134, 134, 135, 135, 136, 136, | ||
87 | 137, 137, 138, 138, 138, 139, 139, 140, | ||
88 | 140, 141, 141, 141, 142, 142, 143, 143, | ||
89 | 143, 144, 144, 145, 145, 145, 146, 146, | ||
90 | 146, 147, 147, 147, 148, 148, 149, 149, | ||
91 | 149, 150, 150, 150, 151, 151, 151, 152, | ||
92 | 152, 153, 153, 153, 154, 154, 155, 155, | ||
93 | 155, 156, 156, 157, 157, 157, 158, 158, | ||
94 | 159, 159, 159, 160, 160, 161, 161, 162, | ||
95 | 162, 162, 163, 163, 164, 164, 164, 165, | ||
96 | 165, 166, 166, 167, 167, 167, 168, 168, | ||
97 | 169, 169, 170, 170, 170, 171, 171, 172, | ||
98 | 172, 173, 173, 174, 174, 175, 175, 176, | ||
99 | 176, 177, 177, 178, 178, 179, 179, 180, | ||
100 | 180, 181, 182, 182, 183, 184, 184, 185, | ||
101 | 186, 186, 187, 188, 188, 189, 190, 191, | ||
102 | 191, 192, 193, 194, 195, 196, 196, 197, | ||
103 | 198, 199, 200, 201, 202, 203, 204, 205, | ||
104 | 206, 207, 208, 209, 210, 211, 213, 214, | ||
105 | 215, 216, 218, 219, 220, 222, 223, 225, | ||
106 | 227, 228, 230, 232, 233, 235, 237, 239, | ||
107 | 241, 243, 245, 247, 249, 251, 253, 255 | ||
108 | }; | ||
36 | #endif | 109 | #endif |
110 | #else /* SIMULATOR */ | ||
111 | /* undo a (generic) PC display gamma of 2.0 to simulate target behaviour */ | ||
112 | static const unsigned char lcdlinear[256] = { | ||
113 | 0, 16, 23, 28, 32, 36, 39, 42, | ||
114 | 45, 48, 50, 53, 55, 58, 60, 62, | ||
115 | 64, 66, 68, 70, 71, 73, 75, 77, | ||
116 | 78, 80, 81, 83, 84, 86, 87, 89, | ||
117 | 90, 92, 93, 94, 96, 97, 98, 100, | ||
118 | 101, 102, 103, 105, 106, 107, 108, 109, | ||
119 | 111, 112, 113, 114, 115, 116, 117, 118, | ||
120 | 119, 121, 122, 123, 124, 125, 126, 127, | ||
121 | 128, 129, 130, 131, 132, 133, 134, 135, | ||
122 | 135, 136, 137, 138, 139, 140, 141, 142, | ||
123 | 143, 144, 145, 145, 146, 147, 148, 149, | ||
124 | 150, 151, 151, 152, 153, 154, 155, 156, | ||
125 | 156, 157, 158, 159, 160, 160, 161, 162, | ||
126 | 163, 164, 164, 165, 166, 167, 167, 168, | ||
127 | 169, 170, 170, 171, 172, 173, 173, 174, | ||
128 | 175, 176, 176, 177, 178, 179, 179, 180, | ||
129 | 181, 181, 182, 183, 183, 184, 185, 186, | ||
130 | 186, 187, 188, 188, 189, 190, 190, 191, | ||
131 | 192, 192, 193, 194, 194, 195, 196, 196, | ||
132 | 197, 198, 198, 199, 199, 200, 201, 201, | ||
133 | 202, 203, 203, 204, 204, 205, 206, 206, | ||
134 | 207, 208, 208, 209, 209, 210, 211, 211, | ||
135 | 212, 212, 213, 214, 214, 215, 215, 216, | ||
136 | 217, 217, 218, 218, 219, 220, 220, 221, | ||
137 | 221, 222, 222, 223, 224, 224, 225, 225, | ||
138 | 226, 226, 227, 228, 228, 229, 229, 230, | ||
139 | 230, 231, 231, 232, 233, 233, 234, 234, | ||
140 | 235, 235, 236, 236, 237, 237, 238, 238, | ||
141 | 239, 240, 240, 241, 241, 242, 242, 243, | ||
142 | 243, 244, 244, 245, 245, 246, 246, 247, | ||
143 | 247, 248, 248, 249, 249, 250, 250, 251, | ||
144 | 251, 252, 252, 253, 253, 254, 254, 255 | ||
145 | }; | ||
146 | #endif /* SIMULATOR */ | ||
37 | 147 | ||
38 | /* Prototypes */ | 148 | /* Prototypes */ |
39 | static inline void _deferred_update(void) __attribute__ ((always_inline)); | 149 | static inline void _deferred_update(void) __attribute__ ((always_inline)); |
@@ -84,6 +194,75 @@ static void _timer_isr(void) | |||
84 | } | 194 | } |
85 | #endif /* !SIMULATOR */ | 195 | #endif /* !SIMULATOR */ |
86 | 196 | ||
197 | /* fixed point exp() */ | ||
198 | static int exp_s16p16(int x) | ||
199 | { | ||
200 | int t; | ||
201 | int y = 0x00010000; | ||
202 | |||
203 | if (x == 0) | ||
204 | { | ||
205 | return y; | ||
206 | } | ||
207 | else if (x > 0) | ||
208 | { | ||
209 | t = x - 0x58b91; if (t >= 0) x = t, y <<= 8; | ||
210 | t = x - 0x2c5c8; if (t >= 0) x = t, y <<= 4; | ||
211 | t = x - 0x162e4; if (t >= 0) x = t, y <<= 2; | ||
212 | t = x - 0x0b172; if (t >= 0) x = t, y <<= 1; | ||
213 | } | ||
214 | else | ||
215 | { | ||
216 | t = x + 0x58b91; if (t < 0) x = t, y >>= 8; | ||
217 | t = x + 0x2c5c8; if (t < 0) x = t, y >>= 4; | ||
218 | t = x + 0x162e4; if (t < 0) x = t, y >>= 2; | ||
219 | t = x + 0x0b172; if (t < 0) x = t, y >>= 1; | ||
220 | x += 0x0b172; y >>= 1; | ||
221 | } | ||
222 | t = x - 0x067cd; if (t >= 0) x = t, y += y >> 1; | ||
223 | t = x - 0x03920; if (t >= 0) x = t, y += y >> 2; | ||
224 | t = x - 0x01e27; if (t >= 0) x = t, y += y >> 3; | ||
225 | t = x - 0x00f85; if (t >= 0) x = t, y += y >> 4; | ||
226 | t = x - 0x007e1; if (t >= 0) x = t, y += y >> 5; | ||
227 | t = x - 0x003f8; if (t >= 0) x = t, y += y >> 6; | ||
228 | t = x - 0x001fe; if (t >= 0) x = t, y += y >> 7; | ||
229 | if (x & 0x100) y += y >> 8; | ||
230 | if (x & 0x080) y += y >> 9; | ||
231 | if (x & 0x040) y += y >> 10; | ||
232 | if (x & 0x020) y += y >> 11; | ||
233 | if (x & 0x010) y += y >> 12; | ||
234 | if (x & 0x008) y += y >> 13; | ||
235 | if (x & 0x004) y += y >> 14; | ||
236 | if (x & 0x002) y += y >> 15; | ||
237 | if (x & 0x001) y += y >> 16; | ||
238 | |||
239 | return y; | ||
240 | } | ||
241 | |||
242 | /* fixed point log() */ | ||
243 | int log_s16p16(int x) | ||
244 | { | ||
245 | int t; | ||
246 | int y = 0xa65af; | ||
247 | |||
248 | if (x < 0x00008000) x <<=16, y -= 0xb1721; | ||
249 | if (x < 0x00800000) x <<= 8, y -= 0x58b91; | ||
250 | if (x < 0x08000000) x <<= 4, y -= 0x2c5c8; | ||
251 | if (x < 0x20000000) x <<= 2, y -= 0x162e4; | ||
252 | if (x < 0x40000000) x <<= 1, y -= 0x0b172; | ||
253 | t = x + (x >> 1); if ((t & 0x80000000) == 0) x = t, y -= 0x067cd; | ||
254 | t = x + (x >> 2); if ((t & 0x80000000) == 0) x = t, y -= 0x03920; | ||
255 | t = x + (x >> 3); if ((t & 0x80000000) == 0) x = t, y -= 0x01e27; | ||
256 | t = x + (x >> 4); if ((t & 0x80000000) == 0) x = t, y -= 0x00f85; | ||
257 | t = x + (x >> 5); if ((t & 0x80000000) == 0) x = t, y -= 0x007e1; | ||
258 | t = x + (x >> 6); if ((t & 0x80000000) == 0) x = t, y -= 0x003f8; | ||
259 | t = x + (x >> 7); if ((t & 0x80000000) == 0) x = t, y -= 0x001fe; | ||
260 | x = 0x80000000 - x; | ||
261 | y -= x >> 15; | ||
262 | |||
263 | return y; | ||
264 | } | ||
265 | |||
87 | /* Initialise the framework and prepare the greyscale display buffer | 266 | /* Initialise the framework and prepare the greyscale display buffer |
88 | 267 | ||
89 | arguments: | 268 | arguments: |
@@ -97,6 +276,8 @@ static void _timer_isr(void) | |||
97 | width = width in pixels (1..LCD_WIDTH) | 276 | width = width in pixels (1..LCD_WIDTH) |
98 | bheight = height in LCD pixel-block units (8 pixels) (1..LCD_HEIGHT/8) | 277 | bheight = height in LCD pixel-block units (8 pixels) (1..LCD_HEIGHT/8) |
99 | depth = number of bitplanes to use (1..32). | 278 | depth = number of bitplanes to use (1..32). |
279 | gamma = gamma value as s8p8 fixed point. gamma <= 0 means no | ||
280 | correction at all, i.e. no LCD linearisation as well. | ||
100 | 281 | ||
101 | result: | 282 | result: |
102 | = depth if there was enough memory | 283 | = depth if there was enough memory |
@@ -128,12 +309,14 @@ static void _timer_isr(void) | |||
128 | one situation where it will consume more memory on the sim than on the | 309 | one situation where it will consume more memory on the sim than on the |
129 | target: if you're allocating a low depth (< 8) without buffering. */ | 310 | target: if you're allocating a low depth (< 8) without buffering. */ |
130 | int gray_init(struct plugin_api* newrb, unsigned char *gbuf, long gbuf_size, | 311 | int gray_init(struct plugin_api* newrb, unsigned char *gbuf, long gbuf_size, |
131 | bool buffered, int width, int bheight, int depth, long *buf_taken) | 312 | bool buffered, int width, int bheight, int depth, int gamma, |
313 | long *buf_taken) | ||
132 | { | 314 | { |
133 | int possible_depth; | 315 | int possible_depth, i; |
134 | long plane_size, buftaken; | 316 | long plane_size, buftaken; |
317 | unsigned data; | ||
135 | #ifndef SIMULATOR | 318 | #ifndef SIMULATOR |
136 | int i, j; | 319 | int j; |
137 | #endif | 320 | #endif |
138 | 321 | ||
139 | _gray_rb = newrb; | 322 | _gray_rb = newrb; |
@@ -240,8 +423,33 @@ int gray_init(struct plugin_api* newrb, unsigned char *gbuf, long gbuf_size, | |||
240 | } | 423 | } |
241 | #endif | 424 | #endif |
242 | 425 | ||
426 | /* precalculate the value -> pattern index conversion table, taking | ||
427 | linearisation and gamma correction into account */ | ||
428 | if (gamma <= 0) | ||
429 | { | ||
430 | for (i = 0; i < 256; i++) | ||
431 | { | ||
432 | data = MULU16(depth, lcdlinear[i]) + 127; | ||
433 | _gray_info.idxtable[i] = (data + (data >> 8)) >> 8; | ||
434 | /* approx. data / 255 */ | ||
435 | } | ||
436 | } | ||
437 | else | ||
438 | { | ||
439 | for (i = 0; i < 256; i++) | ||
440 | { | ||
441 | data = exp_s16p16(gamma * (log_s16p16(i * 257 + 1) >> 8)); | ||
442 | data = (data - (data >> 8)) >> 8; /* approx. data /= 257 */ | ||
443 | data = MULU16(depth, lcdlinear[data]) + 127; | ||
444 | _gray_info.idxtable[i] = (data + (data >> 8)) >> 8; | ||
445 | /* approx. data / 255 */ | ||
446 | } | ||
447 | } | ||
448 | |||
449 | _gray_info.fg_index = 0; | ||
450 | _gray_info.bg_index = depth; | ||
243 | _gray_info.fg_brightness = 0; | 451 | _gray_info.fg_brightness = 0; |
244 | _gray_info.bg_brightness = depth; | 452 | _gray_info.bg_brightness = 255; |
245 | _gray_info.drawmode = DRMODE_SOLID; | 453 | _gray_info.drawmode = DRMODE_SOLID; |
246 | _gray_info.curfont = FONT_SYSFIXED; | 454 | _gray_info.curfont = FONT_SYSFIXED; |
247 | 455 | ||
diff --git a/apps/plugins/lib/gray_draw.c b/apps/plugins/lib/gray_draw.c index 6779b6eeb5..7e1197bd4b 100644 --- a/apps/plugins/lib/gray_draw.c +++ b/apps/plugins/lib/gray_draw.c | |||
@@ -32,12 +32,12 @@ | |||
32 | 32 | ||
33 | static void setpixel(unsigned char *address) | 33 | static void setpixel(unsigned char *address) |
34 | { | 34 | { |
35 | *address = _gray_info.fg_brightness; | 35 | *address = _gray_info.fg_index; |
36 | } | 36 | } |
37 | 37 | ||
38 | static void clearpixel(unsigned char *address) | 38 | static void clearpixel(unsigned char *address) |
39 | { | 39 | { |
40 | *address = _gray_info.bg_brightness; | 40 | *address = _gray_info.bg_index; |
41 | } | 41 | } |
42 | 42 | ||
43 | static void flippixel(unsigned char *address) | 43 | static void flippixel(unsigned char *address) |
@@ -61,7 +61,7 @@ void (* const _gray_pixelfuncs[8])(unsigned char *address) = { | |||
61 | void gray_clear_display(void) | 61 | void gray_clear_display(void) |
62 | { | 62 | { |
63 | int brightness = (_gray_info.drawmode & DRMODE_INVERSEVID) ? | 63 | int brightness = (_gray_info.drawmode & DRMODE_INVERSEVID) ? |
64 | _gray_info.fg_brightness : _gray_info.bg_brightness; | 64 | _gray_info.fg_index : _gray_info.bg_index; |
65 | 65 | ||
66 | _gray_rb->memset(_gray_info.cur_buffer, brightness, | 66 | _gray_rb->memset(_gray_info.cur_buffer, brightness, |
67 | MULU16(_gray_info.width, _gray_info.height)); | 67 | MULU16(_gray_info.width, _gray_info.height)); |
@@ -219,7 +219,7 @@ void gray_vline(int x, int y1, int y2) | |||
219 | if (_gray_info.drawmode & DRMODE_BG) | 219 | if (_gray_info.drawmode & DRMODE_BG) |
220 | { | 220 | { |
221 | fillopt = true; | 221 | fillopt = true; |
222 | bits = _gray_info.bg_brightness; | 222 | bits = _gray_info.bg_index; |
223 | } | 223 | } |
224 | } | 224 | } |
225 | else | 225 | else |
@@ -227,7 +227,7 @@ void gray_vline(int x, int y1, int y2) | |||
227 | if (_gray_info.drawmode & DRMODE_FG) | 227 | if (_gray_info.drawmode & DRMODE_FG) |
228 | { | 228 | { |
229 | fillopt = true; | 229 | fillopt = true; |
230 | bits = _gray_info.fg_brightness; | 230 | bits = _gray_info.fg_index; |
231 | } | 231 | } |
232 | } | 232 | } |
233 | pfunc = _gray_pixelfuncs[_gray_info.drawmode]; | 233 | pfunc = _gray_pixelfuncs[_gray_info.drawmode]; |
@@ -293,7 +293,7 @@ void gray_fillrect(int x, int y, int width, int height) | |||
293 | if (_gray_info.drawmode & DRMODE_BG) | 293 | if (_gray_info.drawmode & DRMODE_BG) |
294 | { | 294 | { |
295 | fillopt = true; | 295 | fillopt = true; |
296 | bits = _gray_info.bg_brightness; | 296 | bits = _gray_info.bg_index; |
297 | } | 297 | } |
298 | } | 298 | } |
299 | else | 299 | else |
@@ -301,7 +301,7 @@ void gray_fillrect(int x, int y, int width, int height) | |||
301 | if (_gray_info.drawmode & DRMODE_FG) | 301 | if (_gray_info.drawmode & DRMODE_FG) |
302 | { | 302 | { |
303 | fillopt = true; | 303 | fillopt = true; |
304 | bits = _gray_info.fg_brightness; | 304 | bits = _gray_info.fg_index; |
305 | } | 305 | } |
306 | } | 306 | } |
307 | pfunc = _gray_pixelfuncs[_gray_info.drawmode]; | 307 | pfunc = _gray_pixelfuncs[_gray_info.drawmode]; |
@@ -525,8 +525,7 @@ void gray_gray_bitmap_part(const unsigned char *src, int src_x, int src_y, | |||
525 | dst_end = dst_col + height; | 525 | dst_end = dst_col + height; |
526 | do | 526 | do |
527 | { | 527 | { |
528 | unsigned data = MULU16(_gray_info.depth, *src_col) + 127; | 528 | *dst_col++ = _gray_info.idxtable[*src_col]; |
529 | *dst_col++ = (data + (data >> 8)) >> 8; /* approx. data / 255 */ | ||
530 | src_col += stride; | 529 | src_col += stride; |
531 | } | 530 | } |
532 | while (dst_col < dst_end); | 531 | while (dst_col < dst_end); |
@@ -642,13 +641,8 @@ static void _writearray(unsigned char *address, const unsigned char *src, | |||
642 | 641 | ||
643 | "mov.b @%[src],r0 \n" /* load src byte */ | 642 | "mov.b @%[src],r0 \n" /* load src byte */ |
644 | "extu.b r0,r0 \n" /* extend unsigned */ | 643 | "extu.b r0,r0 \n" /* extend unsigned */ |
645 | "mulu %[dpth],r0 \n" /* macl = byte * depth; */ | 644 | "mov.b @(r0,%[trns]),r0\n" /* idxtable into pattern index */ |
646 | "sts macl,r1 \n" /* r1 = macl; */ | 645 | "extu.b r0,r0 \n" /* extend unsigned */ |
647 | "add #127,r1 \n" /* byte += 127; */ | ||
648 | "mov r1,r0 \n" | ||
649 | "shlr8 r1 \n" | ||
650 | "add r1,r0 \n" /* byte += byte >> 8; */ | ||
651 | "shlr8 r0 \n" /* byte >>= 8; */ | ||
652 | "shll2 r0 \n" | 646 | "shll2 r0 \n" |
653 | "mov.l @(r0,%[bpat]),r4\n" /* r4 = bitpattern[byte]; */ | 647 | "mov.l @(r0,%[bpat]),r4\n" /* r4 = bitpattern[byte]; */ |
654 | 648 | ||
@@ -693,7 +687,8 @@ static void _writearray(unsigned char *address, const unsigned char *src, | |||
693 | [stri]"r"(stride), | 687 | [stri]"r"(stride), |
694 | [dpth]"r"(_gray_info.depth), | 688 | [dpth]"r"(_gray_info.depth), |
695 | [bpat]"r"(_gray_info.bitpattern), | 689 | [bpat]"r"(_gray_info.bitpattern), |
696 | [rmsk]"r"(_gray_info.randmask) | 690 | [rmsk]"r"(_gray_info.randmask), |
691 | [trns]"r"(_gray_info.idxtable) | ||
697 | : /* clobbers */ | 692 | : /* clobbers */ |
698 | "r0", "r1", "r3", "r4", "r5", "macl", "pr" | 693 | "r0", "r1", "r3", "r4", "r5", "macl", "pr" |
699 | ); | 694 | ); |
@@ -811,12 +806,7 @@ static void _writearray(unsigned char *address, const unsigned char *src, | |||
811 | 806 | ||
812 | "clr.l %%d0 \n" | 807 | "clr.l %%d0 \n" |
813 | "move.b (%[src]),%%d0 \n" /* load src byte */ | 808 | "move.b (%[src]),%%d0 \n" /* load src byte */ |
814 | "mulu.w %[dpth],%%d0\n" /* byte = byte * depth; */ | 809 | "move.b (%%d0:l:1,%[trns]),%%d0\n" /* idxtable into pattern index */ |
815 | "add.l #127,%%d0 \n" /* byte += 127; */ | ||
816 | "move.l %%d0,%%d1 \n" | ||
817 | "lsr.l #8,%%d1 \n" | ||
818 | "add.l %%d1,%%d0 \n" /* byte += byte >> 8; */ | ||
819 | "lsr.l #8,%%d0 \n" /* byte >>= 8; */ | ||
820 | "move.l (%%d0:l:4,%[bpat]),%%d2\n" /* d2 = bitpattern[byte]; */ | 810 | "move.l (%%d0:l:4,%[bpat]),%%d2\n" /* d2 = bitpattern[byte]; */ |
821 | 811 | ||
822 | "mulu.w #75,%[rnd] \n" /* multiply by 75 */ | 812 | "mulu.w #75,%[rnd] \n" /* multiply by 75 */ |
@@ -852,6 +842,7 @@ static void _writearray(unsigned char *address, const unsigned char *src, | |||
852 | : /* inputs */ | 842 | : /* inputs */ |
853 | [stri]"r"(stride), | 843 | [stri]"r"(stride), |
854 | [bpat]"a"(_gray_info.bitpattern), | 844 | [bpat]"a"(_gray_info.bitpattern), |
845 | [trns]"a"(_gray_info.idxtable), | ||
855 | [dpth]"d"(_gray_info.depth), | 846 | [dpth]"d"(_gray_info.depth), |
856 | [rmsk]"d"(_gray_info.randmask) | 847 | [rmsk]"d"(_gray_info.randmask) |
857 | : /* clobbers */ | 848 | : /* clobbers */ |
diff --git a/apps/plugins/lib/gray_parm.c b/apps/plugins/lib/gray_parm.c index c6305421c1..a6064e3ad3 100644 --- a/apps/plugins/lib/gray_parm.c +++ b/apps/plugins/lib/gray_parm.c | |||
@@ -61,31 +61,27 @@ int gray_get_drawmode(void) | |||
61 | /* Set the foreground shade for subsequent drawing operations */ | 61 | /* Set the foreground shade for subsequent drawing operations */ |
62 | void gray_set_foreground(unsigned brightness) | 62 | void gray_set_foreground(unsigned brightness) |
63 | { | 63 | { |
64 | unsigned data = MULU16(_gray_info.depth, brightness & 0xFF) + 127; | 64 | _gray_info.fg_brightness = brightness; |
65 | 65 | _gray_info.fg_index = _gray_info.idxtable[brightness]; | |
66 | _gray_info.fg_brightness = (data + (data >> 8)) >> 8; /* approx. data / 255 */ | ||
67 | } | 66 | } |
68 | 67 | ||
69 | /* Return the current foreground shade */ | 68 | /* Return the current foreground shade */ |
70 | unsigned gray_get_foreground(void) | 69 | unsigned gray_get_foreground(void) |
71 | { | 70 | { |
72 | return (_gray_info.fg_brightness * 255 + (_gray_info.depth >> 1)) | 71 | return _gray_info.fg_brightness; |
73 | / _gray_info.depth; | ||
74 | } | 72 | } |
75 | 73 | ||
76 | /* Set the background shade for subsequent drawing operations */ | 74 | /* Set the background shade for subsequent drawing operations */ |
77 | void gray_set_background(unsigned brightness) | 75 | void gray_set_background(unsigned brightness) |
78 | { | 76 | { |
79 | unsigned data = MULU16(_gray_info.depth, brightness & 0xFF) + 127; | 77 | _gray_info.bg_brightness = brightness; |
80 | 78 | _gray_info.bg_index = _gray_info.idxtable[brightness]; | |
81 | _gray_info.bg_brightness = (data + (data >> 8)) >> 8; /* approx. data / 255 */ | ||
82 | } | 79 | } |
83 | 80 | ||
84 | /* Return the current background shade */ | 81 | /* Return the current background shade */ |
85 | unsigned gray_get_background(void) | 82 | unsigned gray_get_background(void) |
86 | { | 83 | { |
87 | return (_gray_info.bg_brightness * 255 + (_gray_info.depth >> 1)) | 84 | return _gray_info.bg_brightness; |
88 | / _gray_info.depth; | ||
89 | } | 85 | } |
90 | 86 | ||
91 | /* Set draw mode, foreground and background shades at once */ | 87 | /* Set draw mode, foreground and background shades at once */ |