diff options
Diffstat (limited to 'firmware/drivers')
-rw-r--r-- | firmware/drivers/lcd-16bit-vert.c | 46 | ||||
-rw-r--r-- | firmware/drivers/lcd-16bit.c | 48 | ||||
-rw-r--r-- | firmware/drivers/lcd-1bit-vert.c | 56 | ||||
-rw-r--r-- | firmware/drivers/lcd-24bit.c | 48 | ||||
-rw-r--r-- | firmware/drivers/lcd-2bit-horz.c | 84 | ||||
-rw-r--r-- | firmware/drivers/lcd-2bit-vert.c | 76 | ||||
-rw-r--r-- | firmware/drivers/lcd-2bit-vi.c | 38 | ||||
-rw-r--r-- | firmware/drivers/lcd-bitmap-common.c | 2 | ||||
-rw-r--r-- | firmware/drivers/lcd-color-common.c | 2 |
9 files changed, 200 insertions, 200 deletions
diff --git a/firmware/drivers/lcd-16bit-vert.c b/firmware/drivers/lcd-16bit-vert.c index b336e78c78..8631271482 100644 --- a/firmware/drivers/lcd-16bit-vert.c +++ b/firmware/drivers/lcd-16bit-vert.c | |||
@@ -84,19 +84,19 @@ void lcd_hline(int x1, int x2, int y) | |||
84 | x1 = 0; | 84 | x1 = 0; |
85 | if (x2 >= lcd_current_viewport->width) | 85 | if (x2 >= lcd_current_viewport->width) |
86 | x2 = lcd_current_viewport->width-1; | 86 | x2 = lcd_current_viewport->width-1; |
87 | 87 | ||
88 | /* Adjust x1 and y to viewport */ | 88 | /* Adjust x1 and y to viewport */ |
89 | x1 += lcd_current_viewport->x; | 89 | x1 += lcd_current_viewport->x; |
90 | x2 += lcd_current_viewport->x; | 90 | x2 += lcd_current_viewport->x; |
91 | y += lcd_current_viewport->y; | 91 | y += lcd_current_viewport->y; |
92 | 92 | ||
93 | #if defined(HAVE_VIEWPORT_CLIP) | 93 | #if defined(HAVE_VIEWPORT_CLIP) |
94 | /********************* Viewport on screen clipping ********************/ | 94 | /********************* Viewport on screen clipping ********************/ |
95 | /* nothing to draw? */ | 95 | /* nothing to draw? */ |
96 | if (((unsigned)y >= (unsigned) LCD_HEIGHT) || (x1 >= LCD_WIDTH) | 96 | if (((unsigned)y >= (unsigned) LCD_HEIGHT) || (x1 >= LCD_WIDTH) |
97 | || (x2 < 0)) | 97 | || (x2 < 0)) |
98 | return; | 98 | return; |
99 | 99 | ||
100 | /* clipping */ | 100 | /* clipping */ |
101 | if (x1 < 0) | 101 | if (x1 < 0) |
102 | x1 = 0; | 102 | x1 = 0; |
@@ -143,19 +143,19 @@ void lcd_vline(int x, int y1, int y2) | |||
143 | y1 = 0; | 143 | y1 = 0; |
144 | if (y2 >= lcd_current_viewport->height) | 144 | if (y2 >= lcd_current_viewport->height) |
145 | y2 = lcd_current_viewport->height-1; | 145 | y2 = lcd_current_viewport->height-1; |
146 | 146 | ||
147 | /* adjust for viewport */ | 147 | /* adjust for viewport */ |
148 | x += lcd_current_viewport->x; | 148 | x += lcd_current_viewport->x; |
149 | y1 += lcd_current_viewport->y; | 149 | y1 += lcd_current_viewport->y; |
150 | y2 += lcd_current_viewport->y; | 150 | y2 += lcd_current_viewport->y; |
151 | 151 | ||
152 | #if defined(HAVE_VIEWPORT_CLIP) | 152 | #if defined(HAVE_VIEWPORT_CLIP) |
153 | /********************* Viewport on screen clipping ********************/ | 153 | /********************* Viewport on screen clipping ********************/ |
154 | /* nothing to draw? */ | 154 | /* nothing to draw? */ |
155 | if (( (unsigned) x >= (unsigned)LCD_WIDTH) || (y1 >= LCD_HEIGHT) | 155 | if (( (unsigned) x >= (unsigned)LCD_WIDTH) || (y1 >= LCD_HEIGHT) |
156 | || (y2 < 0)) | 156 | || (y2 < 0)) |
157 | return; | 157 | return; |
158 | 158 | ||
159 | /* clipping */ | 159 | /* clipping */ |
160 | if (y1 < 0) | 160 | if (y1 < 0) |
161 | y1 = 0; | 161 | y1 = 0; |
@@ -224,7 +224,7 @@ void ICODE_ATTR lcd_bitmap_part(const fb_data *src, int src_x, int src_y, | |||
224 | if ((width <= 0) || (height <= 0) || (x >= lcd_current_viewport->width) || | 224 | if ((width <= 0) || (height <= 0) || (x >= lcd_current_viewport->width) || |
225 | (y >= lcd_current_viewport->height) || (x + width <= 0) || (y + height <= 0)) | 225 | (y >= lcd_current_viewport->height) || (x + width <= 0) || (y + height <= 0)) |
226 | return; | 226 | return; |
227 | 227 | ||
228 | if (x < 0) | 228 | if (x < 0) |
229 | { | 229 | { |
230 | width += x; | 230 | width += x; |
@@ -237,23 +237,23 @@ void ICODE_ATTR lcd_bitmap_part(const fb_data *src, int src_x, int src_y, | |||
237 | src_y -= y; | 237 | src_y -= y; |
238 | y = 0; | 238 | y = 0; |
239 | } | 239 | } |
240 | 240 | ||
241 | if (x + width > lcd_current_viewport->width) | 241 | if (x + width > lcd_current_viewport->width) |
242 | width = lcd_current_viewport->width - x; | 242 | width = lcd_current_viewport->width - x; |
243 | if (y + height > lcd_current_viewport->height) | 243 | if (y + height > lcd_current_viewport->height) |
244 | height = lcd_current_viewport->height - y; | 244 | height = lcd_current_viewport->height - y; |
245 | 245 | ||
246 | /* adjust for viewport */ | 246 | /* adjust for viewport */ |
247 | x += lcd_current_viewport->x; | 247 | x += lcd_current_viewport->x; |
248 | y += lcd_current_viewport->y; | 248 | y += lcd_current_viewport->y; |
249 | 249 | ||
250 | #if defined(HAVE_VIEWPORT_CLIP) | 250 | #if defined(HAVE_VIEWPORT_CLIP) |
251 | /********************* Viewport on screen clipping ********************/ | 251 | /********************* Viewport on screen clipping ********************/ |
252 | /* nothing to draw? */ | 252 | /* nothing to draw? */ |
253 | if ((x >= LCD_WIDTH) || (y >= LCD_HEIGHT) | 253 | if ((x >= LCD_WIDTH) || (y >= LCD_HEIGHT) |
254 | || (x + width <= 0) || (y + height <= 0)) | 254 | || (x + width <= 0) || (y + height <= 0)) |
255 | return; | 255 | return; |
256 | 256 | ||
257 | /* clip image in viewport in screen */ | 257 | /* clip image in viewport in screen */ |
258 | if (x < 0) | 258 | if (x < 0) |
259 | { | 259 | { |
@@ -294,13 +294,13 @@ void ICODE_ATTR lcd_bitmap_transparent_part(const fb_data *src, int src_x, | |||
294 | { | 294 | { |
295 | fb_data *dst, *dst_end; | 295 | fb_data *dst, *dst_end; |
296 | int stride_dst; | 296 | int stride_dst; |
297 | 297 | ||
298 | /******************** Image in viewport clipping **********************/ | 298 | /******************** Image in viewport clipping **********************/ |
299 | /* nothing to draw? */ | 299 | /* nothing to draw? */ |
300 | if ((width <= 0) || (height <= 0) || (x >= lcd_current_viewport->width) || | 300 | if ((width <= 0) || (height <= 0) || (x >= lcd_current_viewport->width) || |
301 | (y >= lcd_current_viewport->height) || (x + width <= 0) || (y + height <= 0)) | 301 | (y >= lcd_current_viewport->height) || (x + width <= 0) || (y + height <= 0)) |
302 | return; | 302 | return; |
303 | 303 | ||
304 | if (x < 0) | 304 | if (x < 0) |
305 | { | 305 | { |
306 | width += x; | 306 | width += x; |
@@ -313,23 +313,23 @@ void ICODE_ATTR lcd_bitmap_transparent_part(const fb_data *src, int src_x, | |||
313 | src_y -= y; | 313 | src_y -= y; |
314 | y = 0; | 314 | y = 0; |
315 | } | 315 | } |
316 | 316 | ||
317 | if (x + width > lcd_current_viewport->width) | 317 | if (x + width > lcd_current_viewport->width) |
318 | width = lcd_current_viewport->width - x; | 318 | width = lcd_current_viewport->width - x; |
319 | if (y + height > lcd_current_viewport->height) | 319 | if (y + height > lcd_current_viewport->height) |
320 | height = lcd_current_viewport->height - y; | 320 | height = lcd_current_viewport->height - y; |
321 | 321 | ||
322 | /* adjust for viewport */ | 322 | /* adjust for viewport */ |
323 | x += lcd_current_viewport->x; | 323 | x += lcd_current_viewport->x; |
324 | y += lcd_current_viewport->y; | 324 | y += lcd_current_viewport->y; |
325 | 325 | ||
326 | #if defined(HAVE_VIEWPORT_CLIP) | 326 | #if defined(HAVE_VIEWPORT_CLIP) |
327 | /********************* Viewport on screen clipping ********************/ | 327 | /********************* Viewport on screen clipping ********************/ |
328 | /* nothing to draw? */ | 328 | /* nothing to draw? */ |
329 | if ((x >= LCD_WIDTH) || (y >= LCD_HEIGHT) | 329 | if ((x >= LCD_WIDTH) || (y >= LCD_HEIGHT) |
330 | || (x + width <= 0) || (y + height <= 0)) | 330 | || (x + width <= 0) || (y + height <= 0)) |
331 | return; | 331 | return; |
332 | 332 | ||
333 | /* clip image in viewport in screen */ | 333 | /* clip image in viewport in screen */ |
334 | if (x < 0) | 334 | if (x < 0) |
335 | { | 335 | { |
diff --git a/firmware/drivers/lcd-16bit.c b/firmware/drivers/lcd-16bit.c index 03c50f8ebf..6a76ba48ab 100644 --- a/firmware/drivers/lcd-16bit.c +++ b/firmware/drivers/lcd-16bit.c | |||
@@ -74,11 +74,11 @@ void lcd_hline(int x1, int x2, int y) | |||
74 | 74 | ||
75 | /******************** In viewport clipping **********************/ | 75 | /******************** In viewport clipping **********************/ |
76 | /* nothing to draw? */ | 76 | /* nothing to draw? */ |
77 | if (((unsigned)y >= (unsigned)lcd_current_viewport->height) || | 77 | if (((unsigned)y >= (unsigned)lcd_current_viewport->height) || |
78 | (x1 >= lcd_current_viewport->width) || | 78 | (x1 >= lcd_current_viewport->width) || |
79 | (x2 < 0)) | 79 | (x2 < 0)) |
80 | return; | 80 | return; |
81 | 81 | ||
82 | if (x1 < 0) | 82 | if (x1 < 0) |
83 | x1 = 0; | 83 | x1 = 0; |
84 | if (x2 >= lcd_current_viewport->width) | 84 | if (x2 >= lcd_current_viewport->width) |
@@ -88,14 +88,14 @@ void lcd_hline(int x1, int x2, int y) | |||
88 | x1 += lcd_current_viewport->x; | 88 | x1 += lcd_current_viewport->x; |
89 | x2 += lcd_current_viewport->x; | 89 | x2 += lcd_current_viewport->x; |
90 | y += lcd_current_viewport->y; | 90 | y += lcd_current_viewport->y; |
91 | 91 | ||
92 | #if defined(HAVE_VIEWPORT_CLIP) | 92 | #if defined(HAVE_VIEWPORT_CLIP) |
93 | /********************* Viewport on screen clipping ********************/ | 93 | /********************* Viewport on screen clipping ********************/ |
94 | /* nothing to draw? */ | 94 | /* nothing to draw? */ |
95 | if (((unsigned)y >= (unsigned) LCD_HEIGHT) || (x1 >= LCD_WIDTH) | 95 | if (((unsigned)y >= (unsigned) LCD_HEIGHT) || (x1 >= LCD_WIDTH) |
96 | || (x2 < 0)) | 96 | || (x2 < 0)) |
97 | return; | 97 | return; |
98 | 98 | ||
99 | /* clipping */ | 99 | /* clipping */ |
100 | if (x1 < 0) | 100 | if (x1 < 0) |
101 | x1 = 0; | 101 | x1 = 0; |
@@ -179,19 +179,19 @@ void lcd_vline(int x, int y1, int y2) | |||
179 | y1 = 0; | 179 | y1 = 0; |
180 | if (y2 >= lcd_current_viewport->height) | 180 | if (y2 >= lcd_current_viewport->height) |
181 | y2 = lcd_current_viewport->height-1; | 181 | y2 = lcd_current_viewport->height-1; |
182 | 182 | ||
183 | /* adjust for viewport */ | 183 | /* adjust for viewport */ |
184 | x += lcd_current_viewport->x; | 184 | x += lcd_current_viewport->x; |
185 | y1 += lcd_current_viewport->y; | 185 | y1 += lcd_current_viewport->y; |
186 | y2 += lcd_current_viewport->y; | 186 | y2 += lcd_current_viewport->y; |
187 | 187 | ||
188 | #if defined(HAVE_VIEWPORT_CLIP) | 188 | #if defined(HAVE_VIEWPORT_CLIP) |
189 | /********************* Viewport on screen clipping ********************/ | 189 | /********************* Viewport on screen clipping ********************/ |
190 | /* nothing to draw? */ | 190 | /* nothing to draw? */ |
191 | if (( (unsigned) x >= (unsigned)LCD_WIDTH) || (y1 >= LCD_HEIGHT) | 191 | if (( (unsigned) x >= (unsigned)LCD_WIDTH) || (y1 >= LCD_HEIGHT) |
192 | || (y2 < 0)) | 192 | || (y2 < 0)) |
193 | return; | 193 | return; |
194 | 194 | ||
195 | /* clipping */ | 195 | /* clipping */ |
196 | if (y1 < 0) | 196 | if (y1 < 0) |
197 | y1 = 0; | 197 | y1 = 0; |
@@ -224,7 +224,7 @@ void ICODE_ATTR lcd_bitmap_part(const fb_data *src, int src_x, int src_y, | |||
224 | if ((width <= 0) || (height <= 0) || (x >= lcd_current_viewport->width) || | 224 | if ((width <= 0) || (height <= 0) || (x >= lcd_current_viewport->width) || |
225 | (y >= lcd_current_viewport->height) || (x + width <= 0) || (y + height <= 0)) | 225 | (y >= lcd_current_viewport->height) || (x + width <= 0) || (y + height <= 0)) |
226 | return; | 226 | return; |
227 | 227 | ||
228 | if (x < 0) | 228 | if (x < 0) |
229 | { | 229 | { |
230 | width += x; | 230 | width += x; |
@@ -237,23 +237,23 @@ void ICODE_ATTR lcd_bitmap_part(const fb_data *src, int src_x, int src_y, | |||
237 | src_y -= y; | 237 | src_y -= y; |
238 | y = 0; | 238 | y = 0; |
239 | } | 239 | } |
240 | 240 | ||
241 | if (x + width > lcd_current_viewport->width) | 241 | if (x + width > lcd_current_viewport->width) |
242 | width = lcd_current_viewport->width - x; | 242 | width = lcd_current_viewport->width - x; |
243 | if (y + height > lcd_current_viewport->height) | 243 | if (y + height > lcd_current_viewport->height) |
244 | height = lcd_current_viewport->height - y; | 244 | height = lcd_current_viewport->height - y; |
245 | 245 | ||
246 | /* adjust for viewport */ | 246 | /* adjust for viewport */ |
247 | x += lcd_current_viewport->x; | 247 | x += lcd_current_viewport->x; |
248 | y += lcd_current_viewport->y; | 248 | y += lcd_current_viewport->y; |
249 | 249 | ||
250 | #if defined(HAVE_VIEWPORT_CLIP) | 250 | #if defined(HAVE_VIEWPORT_CLIP) |
251 | /********************* Viewport on screen clipping ********************/ | 251 | /********************* Viewport on screen clipping ********************/ |
252 | /* nothing to draw? */ | 252 | /* nothing to draw? */ |
253 | if ((x >= LCD_WIDTH) || (y >= LCD_HEIGHT) | 253 | if ((x >= LCD_WIDTH) || (y >= LCD_HEIGHT) |
254 | || (x + width <= 0) || (y + height <= 0)) | 254 | || (x + width <= 0) || (y + height <= 0)) |
255 | return; | 255 | return; |
256 | 256 | ||
257 | /* clip image in viewport in screen */ | 257 | /* clip image in viewport in screen */ |
258 | if (x < 0) | 258 | if (x < 0) |
259 | { | 259 | { |
@@ -272,7 +272,7 @@ void ICODE_ATTR lcd_bitmap_part(const fb_data *src, int src_x, int src_y, | |||
272 | if (y + height > LCD_HEIGHT) | 272 | if (y + height > LCD_HEIGHT) |
273 | height = LCD_HEIGHT - y; | 273 | height = LCD_HEIGHT - y; |
274 | #endif | 274 | #endif |
275 | 275 | ||
276 | src += stride * src_y + src_x; /* move starting point */ | 276 | src += stride * src_y + src_x; /* move starting point */ |
277 | dst = FBADDR(x, y); | 277 | dst = FBADDR(x, y); |
278 | stride_dst = lcd_current_viewport->buffer->stride; | 278 | stride_dst = lcd_current_viewport->buffer->stride; |
@@ -300,7 +300,7 @@ void ICODE_ATTR lcd_bitmap_transparent_part(const fb_data *src, int src_x, | |||
300 | if ((width <= 0) || (height <= 0) || (x >= lcd_current_viewport->width) || | 300 | if ((width <= 0) || (height <= 0) || (x >= lcd_current_viewport->width) || |
301 | (y >= lcd_current_viewport->height) || (x + width <= 0) || (y + height <= 0)) | 301 | (y >= lcd_current_viewport->height) || (x + width <= 0) || (y + height <= 0)) |
302 | return; | 302 | return; |
303 | 303 | ||
304 | if (x < 0) | 304 | if (x < 0) |
305 | { | 305 | { |
306 | width += x; | 306 | width += x; |
@@ -313,23 +313,23 @@ void ICODE_ATTR lcd_bitmap_transparent_part(const fb_data *src, int src_x, | |||
313 | src_y -= y; | 313 | src_y -= y; |
314 | y = 0; | 314 | y = 0; |
315 | } | 315 | } |
316 | 316 | ||
317 | if (x + width > lcd_current_viewport->width) | 317 | if (x + width > lcd_current_viewport->width) |
318 | width = lcd_current_viewport->width - x; | 318 | width = lcd_current_viewport->width - x; |
319 | if (y + height > lcd_current_viewport->height) | 319 | if (y + height > lcd_current_viewport->height) |
320 | height = lcd_current_viewport->height - y; | 320 | height = lcd_current_viewport->height - y; |
321 | 321 | ||
322 | /* adjust for viewport */ | 322 | /* adjust for viewport */ |
323 | x += lcd_current_viewport->x; | 323 | x += lcd_current_viewport->x; |
324 | y += lcd_current_viewport->y; | 324 | y += lcd_current_viewport->y; |
325 | 325 | ||
326 | #if defined(HAVE_VIEWPORT_CLIP) | 326 | #if defined(HAVE_VIEWPORT_CLIP) |
327 | /********************* Viewport on screen clipping ********************/ | 327 | /********************* Viewport on screen clipping ********************/ |
328 | /* nothing to draw? */ | 328 | /* nothing to draw? */ |
329 | if ((x >= LCD_WIDTH) || (y >= LCD_HEIGHT) | 329 | if ((x >= LCD_WIDTH) || (y >= LCD_HEIGHT) |
330 | || (x + width <= 0) || (y + height <= 0)) | 330 | || (x + width <= 0) || (y + height <= 0)) |
331 | return; | 331 | return; |
332 | 332 | ||
333 | /* clip image in viewport in screen */ | 333 | /* clip image in viewport in screen */ |
334 | if (x < 0) | 334 | if (x < 0) |
335 | { | 335 | { |
diff --git a/firmware/drivers/lcd-1bit-vert.c b/firmware/drivers/lcd-1bit-vert.c index 57abdb91a6..c86ced9b6c 100644 --- a/firmware/drivers/lcd-1bit-vert.c +++ b/firmware/drivers/lcd-1bit-vert.c | |||
@@ -219,7 +219,7 @@ static void ICODE_ATTR solidinvblock(FBFN(data) *address, unsigned mask, | |||
219 | unsigned bits) | 219 | unsigned bits) |
220 | { | 220 | { |
221 | unsigned data = *(char *)address; | 221 | unsigned data = *(char *)address; |
222 | 222 | ||
223 | bits = ~bits ^ data; | 223 | bits = ~bits ^ data; |
224 | *address = data ^ (bits & mask); | 224 | *address = data ^ (bits & mask); |
225 | } | 225 | } |
@@ -255,7 +255,7 @@ void LCDFN(clear_viewport)(void) | |||
255 | oldmode = CURRENT_VP->drawmode; | 255 | oldmode = CURRENT_VP->drawmode; |
256 | 256 | ||
257 | /* Invert the INVERSEVID bit and set basic mode to SOLID */ | 257 | /* Invert the INVERSEVID bit and set basic mode to SOLID */ |
258 | CURRENT_VP->drawmode = (~CURRENT_VP->drawmode & DRMODE_INVERSEVID) | | 258 | CURRENT_VP->drawmode = (~CURRENT_VP->drawmode & DRMODE_INVERSEVID) | |
259 | DRMODE_SOLID; | 259 | DRMODE_SOLID; |
260 | 260 | ||
261 | LCDFN(fillrect)(0, 0, CURRENT_VP->width, CURRENT_VP->height); | 261 | LCDFN(fillrect)(0, 0, CURRENT_VP->width, CURRENT_VP->height); |
@@ -271,7 +271,7 @@ void LCDFN(clear_viewport)(void) | |||
271 | /* Set a single pixel */ | 271 | /* Set a single pixel */ |
272 | void LCDFN(drawpixel)(int x, int y) | 272 | void LCDFN(drawpixel)(int x, int y) |
273 | { | 273 | { |
274 | if ( ((unsigned)x < (unsigned)CURRENT_VP->width) | 274 | if ( ((unsigned)x < (unsigned)CURRENT_VP->width) |
275 | && ((unsigned)y < (unsigned)CURRENT_VP->height) | 275 | && ((unsigned)y < (unsigned)CURRENT_VP->height) |
276 | #if defined(HAVE_VIEWPORT_CLIP) | 276 | #if defined(HAVE_VIEWPORT_CLIP) |
277 | && ((unsigned)x < (unsigned)LCDM(WIDTH)) | 277 | && ((unsigned)x < (unsigned)LCDM(WIDTH)) |
@@ -385,30 +385,30 @@ void LCDFN(hline)(int x1, int x2, int y) | |||
385 | x1 = x2; | 385 | x1 = x2; |
386 | x2 = x; | 386 | x2 = x; |
387 | } | 387 | } |
388 | 388 | ||
389 | /******************** In viewport clipping **********************/ | 389 | /******************** In viewport clipping **********************/ |
390 | /* nothing to draw? */ | 390 | /* nothing to draw? */ |
391 | if (((unsigned)y >= (unsigned)CURRENT_VP->height) || (x1 >= CURRENT_VP->width) | 391 | if (((unsigned)y >= (unsigned)CURRENT_VP->height) || (x1 >= CURRENT_VP->width) |
392 | || (x2 < 0)) | 392 | || (x2 < 0)) |
393 | return; | 393 | return; |
394 | 394 | ||
395 | if (x1 < 0) | 395 | if (x1 < 0) |
396 | x1 = 0; | 396 | x1 = 0; |
397 | if (x2 >= CURRENT_VP->width) | 397 | if (x2 >= CURRENT_VP->width) |
398 | x2 = CURRENT_VP->width-1; | 398 | x2 = CURRENT_VP->width-1; |
399 | 399 | ||
400 | /* adjust to viewport */ | 400 | /* adjust to viewport */ |
401 | x1 += CURRENT_VP->x; | 401 | x1 += CURRENT_VP->x; |
402 | x2 += CURRENT_VP->x; | 402 | x2 += CURRENT_VP->x; |
403 | y += CURRENT_VP->y; | 403 | y += CURRENT_VP->y; |
404 | 404 | ||
405 | #if defined(HAVE_VIEWPORT_CLIP) | 405 | #if defined(HAVE_VIEWPORT_CLIP) |
406 | /********************* Viewport on screen clipping ********************/ | 406 | /********************* Viewport on screen clipping ********************/ |
407 | /* nothing to draw? */ | 407 | /* nothing to draw? */ |
408 | if (((unsigned)y >= (unsigned) LCDM(HEIGHT)) || (x1 >= LCDM(WIDTH)) | 408 | if (((unsigned)y >= (unsigned) LCDM(HEIGHT)) || (x1 >= LCDM(WIDTH)) |
409 | || (x2 < 0)) | 409 | || (x2 < 0)) |
410 | return; | 410 | return; |
411 | 411 | ||
412 | /* clipping */ | 412 | /* clipping */ |
413 | if (x1 < 0) | 413 | if (x1 < 0) |
414 | x1 = 0; | 414 | x1 = 0; |
@@ -449,25 +449,25 @@ void LCDFN(vline)(int x, int y1, int y2) | |||
449 | /* nothing to draw? */ | 449 | /* nothing to draw? */ |
450 | if (((unsigned)x >= (unsigned)CURRENT_VP->width) || (y1 >= CURRENT_VP->height) | 450 | if (((unsigned)x >= (unsigned)CURRENT_VP->width) || (y1 >= CURRENT_VP->height) |
451 | || (y2 < 0)) | 451 | || (y2 < 0)) |
452 | return; | 452 | return; |
453 | 453 | ||
454 | if (y1 < 0) | 454 | if (y1 < 0) |
455 | y1 = 0; | 455 | y1 = 0; |
456 | if (y2 >= CURRENT_VP->height) | 456 | if (y2 >= CURRENT_VP->height) |
457 | y2 = CURRENT_VP->height-1; | 457 | y2 = CURRENT_VP->height-1; |
458 | 458 | ||
459 | /* adjust for viewport */ | 459 | /* adjust for viewport */ |
460 | y1 += CURRENT_VP->y; | 460 | y1 += CURRENT_VP->y; |
461 | y2 += CURRENT_VP->y; | 461 | y2 += CURRENT_VP->y; |
462 | x += CURRENT_VP->x; | 462 | x += CURRENT_VP->x; |
463 | 463 | ||
464 | #if defined(HAVE_VIEWPORT_CLIP) | 464 | #if defined(HAVE_VIEWPORT_CLIP) |
465 | /********************* Viewport on screen clipping ********************/ | 465 | /********************* Viewport on screen clipping ********************/ |
466 | /* nothing to draw? */ | 466 | /* nothing to draw? */ |
467 | if (( (unsigned) x >= (unsigned)LCDM(WIDTH)) || (y1 >= LCDM(HEIGHT)) | 467 | if (( (unsigned) x >= (unsigned)LCDM(WIDTH)) || (y1 >= LCDM(HEIGHT)) |
468 | || (y2 < 0)) | 468 | || (y2 < 0)) |
469 | return; | 469 | return; |
470 | 470 | ||
471 | /* clipping */ | 471 | /* clipping */ |
472 | if (y1 < 0) | 472 | if (y1 < 0) |
473 | y1 = 0; | 473 | y1 = 0; |
@@ -538,18 +538,18 @@ void LCDFN(fillrect)(int x, int y, int width, int height) | |||
538 | width = CURRENT_VP->width - x; | 538 | width = CURRENT_VP->width - x; |
539 | if (y + height > CURRENT_VP->height) | 539 | if (y + height > CURRENT_VP->height) |
540 | height = CURRENT_VP->height - y; | 540 | height = CURRENT_VP->height - y; |
541 | 541 | ||
542 | /* adjust for viewport */ | 542 | /* adjust for viewport */ |
543 | x += CURRENT_VP->x; | 543 | x += CURRENT_VP->x; |
544 | y += CURRENT_VP->y; | 544 | y += CURRENT_VP->y; |
545 | 545 | ||
546 | #if defined(HAVE_VIEWPORT_CLIP) | 546 | #if defined(HAVE_VIEWPORT_CLIP) |
547 | /********************* Viewport on screen clipping ********************/ | 547 | /********************* Viewport on screen clipping ********************/ |
548 | /* nothing to draw? */ | 548 | /* nothing to draw? */ |
549 | if ((x >= LCDM(WIDTH)) || (y >= LCDM(HEIGHT)) | 549 | if ((x >= LCDM(WIDTH)) || (y >= LCDM(HEIGHT)) |
550 | || (x + width <= 0) || (y + height <= 0)) | 550 | || (x + width <= 0) || (y + height <= 0)) |
551 | return; | 551 | return; |
552 | 552 | ||
553 | /* clip image in viewport in screen */ | 553 | /* clip image in viewport in screen */ |
554 | if (x < 0) | 554 | if (x < 0) |
555 | { | 555 | { |
@@ -646,7 +646,7 @@ void ICODE_ATTR LCDFN(bitmap_part)(const unsigned char *src, int src_x, | |||
646 | if ((width <= 0) || (height <= 0) || (x >= CURRENT_VP->width) | 646 | if ((width <= 0) || (height <= 0) || (x >= CURRENT_VP->width) |
647 | || (y >= CURRENT_VP->height) || (x + width <= 0) || (y + height <= 0)) | 647 | || (y >= CURRENT_VP->height) || (x + width <= 0) || (y + height <= 0)) |
648 | return; | 648 | return; |
649 | 649 | ||
650 | /* clip image in viewport */ | 650 | /* clip image in viewport */ |
651 | if (x < 0) | 651 | if (x < 0) |
652 | { | 652 | { |
@@ -668,14 +668,14 @@ void ICODE_ATTR LCDFN(bitmap_part)(const unsigned char *src, int src_x, | |||
668 | /* adjust for viewport */ | 668 | /* adjust for viewport */ |
669 | x += CURRENT_VP->x; | 669 | x += CURRENT_VP->x; |
670 | y += CURRENT_VP->y; | 670 | y += CURRENT_VP->y; |
671 | 671 | ||
672 | #if defined(HAVE_VIEWPORT_CLIP) | 672 | #if defined(HAVE_VIEWPORT_CLIP) |
673 | /********************* Viewport on screen clipping ********************/ | 673 | /********************* Viewport on screen clipping ********************/ |
674 | /* nothing to draw? */ | 674 | /* nothing to draw? */ |
675 | if ((x >= LCDM(WIDTH)) || (y >= LCDM(HEIGHT)) | 675 | if ((x >= LCDM(WIDTH)) || (y >= LCDM(HEIGHT)) |
676 | || (x + width <= 0) || (y + height <= 0)) | 676 | || (x + width <= 0) || (y + height <= 0)) |
677 | return; | 677 | return; |
678 | 678 | ||
679 | /* clip image in viewport in screen */ | 679 | /* clip image in viewport in screen */ |
680 | if (x < 0) | 680 | if (x < 0) |
681 | { | 681 | { |
@@ -706,7 +706,7 @@ void ICODE_ATTR LCDFN(bitmap_part)(const unsigned char *src, int src_x, | |||
706 | bfunc = LCDFN(blockfuncs)[CURRENT_VP->drawmode]; | 706 | bfunc = LCDFN(blockfuncs)[CURRENT_VP->drawmode]; |
707 | mask = 0xFFu << (shift + src_y); | 707 | mask = 0xFFu << (shift + src_y); |
708 | mask_bottom = 0xFFu >> (~ny & 7); | 708 | mask_bottom = 0xFFu >> (~ny & 7); |
709 | 709 | ||
710 | if (shift == 0) | 710 | if (shift == 0) |
711 | { | 711 | { |
712 | bool copyopt = (CURRENT_VP->drawmode == DRMODE_SOLID); | 712 | bool copyopt = (CURRENT_VP->drawmode == DRMODE_SOLID); |
@@ -719,9 +719,9 @@ void ICODE_ATTR LCDFN(bitmap_part)(const unsigned char *src, int src_x, | |||
719 | { | 719 | { |
720 | const unsigned char *src_row = src; | 720 | const unsigned char *src_row = src; |
721 | FBFN(data) *dst_row = dst; | 721 | FBFN(data) *dst_row = dst; |
722 | 722 | ||
723 | dst_end = dst_row + width; | 723 | dst_end = dst_row + width; |
724 | do | 724 | do |
725 | bfunc(dst_row++, mask, *src_row++); | 725 | bfunc(dst_row++, mask, *src_row++); |
726 | while (dst_row < dst_end); | 726 | while (dst_row < dst_end); |
727 | } | 727 | } |
@@ -751,7 +751,7 @@ void ICODE_ATTR LCDFN(bitmap_part)(const unsigned char *src, int src_x, | |||
751 | FBFN(data) *dst_col = dst++; | 751 | FBFN(data) *dst_col = dst++; |
752 | unsigned mask_col = mask; | 752 | unsigned mask_col = mask; |
753 | unsigned data = 0; | 753 | unsigned data = 0; |
754 | 754 | ||
755 | for (y = ny; y >= 8; y -= 8) | 755 | for (y = ny; y >= 8; y -= 8) |
756 | { | 756 | { |
757 | data |= *src_col << shift; | 757 | data |= *src_col << shift; |
diff --git a/firmware/drivers/lcd-24bit.c b/firmware/drivers/lcd-24bit.c index 65fa01f37f..5ee290efe3 100644 --- a/firmware/drivers/lcd-24bit.c +++ b/firmware/drivers/lcd-24bit.c | |||
@@ -869,11 +869,11 @@ void lcd_hline(int x1, int x2, int y) | |||
869 | 869 | ||
870 | /******************** In viewport clipping **********************/ | 870 | /******************** In viewport clipping **********************/ |
871 | /* nothing to draw? */ | 871 | /* nothing to draw? */ |
872 | if (((unsigned)y >= (unsigned)lcd_current_viewport->height) || | 872 | if (((unsigned)y >= (unsigned)lcd_current_viewport->height) || |
873 | (x1 >= lcd_current_viewport->width) || | 873 | (x1 >= lcd_current_viewport->width) || |
874 | (x2 < 0)) | 874 | (x2 < 0)) |
875 | return; | 875 | return; |
876 | 876 | ||
877 | if (x1 < 0) | 877 | if (x1 < 0) |
878 | x1 = 0; | 878 | x1 = 0; |
879 | if (x2 >= lcd_current_viewport->width) | 879 | if (x2 >= lcd_current_viewport->width) |
@@ -883,14 +883,14 @@ void lcd_hline(int x1, int x2, int y) | |||
883 | x1 += lcd_current_viewport->x; | 883 | x1 += lcd_current_viewport->x; |
884 | x2 += lcd_current_viewport->x; | 884 | x2 += lcd_current_viewport->x; |
885 | y += lcd_current_viewport->y; | 885 | y += lcd_current_viewport->y; |
886 | 886 | ||
887 | #if defined(HAVE_VIEWPORT_CLIP) | 887 | #if defined(HAVE_VIEWPORT_CLIP) |
888 | /********************* Viewport on screen clipping ********************/ | 888 | /********************* Viewport on screen clipping ********************/ |
889 | /* nothing to draw? */ | 889 | /* nothing to draw? */ |
890 | if (((unsigned)y >= (unsigned) LCD_HEIGHT) || (x1 >= LCD_WIDTH) | 890 | if (((unsigned)y >= (unsigned) LCD_HEIGHT) || (x1 >= LCD_WIDTH) |
891 | || (x2 < 0)) | 891 | || (x2 < 0)) |
892 | return; | 892 | return; |
893 | 893 | ||
894 | /* clipping */ | 894 | /* clipping */ |
895 | if (x1 < 0) | 895 | if (x1 < 0) |
896 | x1 = 0; | 896 | x1 = 0; |
@@ -935,19 +935,19 @@ void lcd_vline(int x, int y1, int y2) | |||
935 | y1 = 0; | 935 | y1 = 0; |
936 | if (y2 >= lcd_current_viewport->height) | 936 | if (y2 >= lcd_current_viewport->height) |
937 | y2 = lcd_current_viewport->height-1; | 937 | y2 = lcd_current_viewport->height-1; |
938 | 938 | ||
939 | /* adjust for viewport */ | 939 | /* adjust for viewport */ |
940 | x += lcd_current_viewport->x; | 940 | x += lcd_current_viewport->x; |
941 | y1 += lcd_current_viewport->y; | 941 | y1 += lcd_current_viewport->y; |
942 | y2 += lcd_current_viewport->y; | 942 | y2 += lcd_current_viewport->y; |
943 | 943 | ||
944 | #if defined(HAVE_VIEWPORT_CLIP) | 944 | #if defined(HAVE_VIEWPORT_CLIP) |
945 | /********************* Viewport on screen clipping ********************/ | 945 | /********************* Viewport on screen clipping ********************/ |
946 | /* nothing to draw? */ | 946 | /* nothing to draw? */ |
947 | if (( (unsigned) x >= (unsigned)LCD_WIDTH) || (y1 >= LCD_HEIGHT) | 947 | if (( (unsigned) x >= (unsigned)LCD_WIDTH) || (y1 >= LCD_HEIGHT) |
948 | || (y2 < 0)) | 948 | || (y2 < 0)) |
949 | return; | 949 | return; |
950 | 950 | ||
951 | /* clipping */ | 951 | /* clipping */ |
952 | if (y1 < 0) | 952 | if (y1 < 0) |
953 | y1 = 0; | 953 | y1 = 0; |
@@ -978,7 +978,7 @@ void ICODE_ATTR lcd_bitmap_part(const fb_data *src, int src_x, int src_y, | |||
978 | if ((width <= 0) || (height <= 0) || (x >= lcd_current_viewport->width) || | 978 | if ((width <= 0) || (height <= 0) || (x >= lcd_current_viewport->width) || |
979 | (y >= lcd_current_viewport->height) || (x + width <= 0) || (y + height <= 0)) | 979 | (y >= lcd_current_viewport->height) || (x + width <= 0) || (y + height <= 0)) |
980 | return; | 980 | return; |
981 | 981 | ||
982 | if (x < 0) | 982 | if (x < 0) |
983 | { | 983 | { |
984 | width += x; | 984 | width += x; |
@@ -991,23 +991,23 @@ void ICODE_ATTR lcd_bitmap_part(const fb_data *src, int src_x, int src_y, | |||
991 | src_y -= y; | 991 | src_y -= y; |
992 | y = 0; | 992 | y = 0; |
993 | } | 993 | } |
994 | 994 | ||
995 | if (x + width > lcd_current_viewport->width) | 995 | if (x + width > lcd_current_viewport->width) |
996 | width = lcd_current_viewport->width - x; | 996 | width = lcd_current_viewport->width - x; |
997 | if (y + height > lcd_current_viewport->height) | 997 | if (y + height > lcd_current_viewport->height) |
998 | height = lcd_current_viewport->height - y; | 998 | height = lcd_current_viewport->height - y; |
999 | 999 | ||
1000 | /* adjust for viewport */ | 1000 | /* adjust for viewport */ |
1001 | x += lcd_current_viewport->x; | 1001 | x += lcd_current_viewport->x; |
1002 | y += lcd_current_viewport->y; | 1002 | y += lcd_current_viewport->y; |
1003 | 1003 | ||
1004 | #if defined(HAVE_VIEWPORT_CLIP) | 1004 | #if defined(HAVE_VIEWPORT_CLIP) |
1005 | /********************* Viewport on screen clipping ********************/ | 1005 | /********************* Viewport on screen clipping ********************/ |
1006 | /* nothing to draw? */ | 1006 | /* nothing to draw? */ |
1007 | if ((x >= LCD_WIDTH) || (y >= LCD_HEIGHT) | 1007 | if ((x >= LCD_WIDTH) || (y >= LCD_HEIGHT) |
1008 | || (x + width <= 0) || (y + height <= 0)) | 1008 | || (x + width <= 0) || (y + height <= 0)) |
1009 | return; | 1009 | return; |
1010 | 1010 | ||
1011 | /* clip image in viewport in screen */ | 1011 | /* clip image in viewport in screen */ |
1012 | if (x < 0) | 1012 | if (x < 0) |
1013 | { | 1013 | { |
@@ -1026,7 +1026,7 @@ void ICODE_ATTR lcd_bitmap_part(const fb_data *src, int src_x, int src_y, | |||
1026 | if (y + height > LCD_HEIGHT) | 1026 | if (y + height > LCD_HEIGHT) |
1027 | height = LCD_HEIGHT - y; | 1027 | height = LCD_HEIGHT - y; |
1028 | #endif | 1028 | #endif |
1029 | 1029 | ||
1030 | src += stride * src_y + src_x; /* move starting point */ | 1030 | src += stride * src_y + src_x; /* move starting point */ |
1031 | dst = FBADDR(x, y); | 1031 | dst = FBADDR(x, y); |
1032 | 1032 | ||
@@ -1052,7 +1052,7 @@ void ICODE_ATTR lcd_bitmap_transparent_part(const fb_data *src, int src_x, | |||
1052 | if ((width <= 0) || (height <= 0) || (x >= lcd_current_viewport->width) || | 1052 | if ((width <= 0) || (height <= 0) || (x >= lcd_current_viewport->width) || |
1053 | (y >= lcd_current_viewport->height) || (x + width <= 0) || (y + height <= 0)) | 1053 | (y >= lcd_current_viewport->height) || (x + width <= 0) || (y + height <= 0)) |
1054 | return; | 1054 | return; |
1055 | 1055 | ||
1056 | if (x < 0) | 1056 | if (x < 0) |
1057 | { | 1057 | { |
1058 | width += x; | 1058 | width += x; |
@@ -1065,23 +1065,23 @@ void ICODE_ATTR lcd_bitmap_transparent_part(const fb_data *src, int src_x, | |||
1065 | src_y -= y; | 1065 | src_y -= y; |
1066 | y = 0; | 1066 | y = 0; |
1067 | } | 1067 | } |
1068 | 1068 | ||
1069 | if (x + width > lcd_current_viewport->width) | 1069 | if (x + width > lcd_current_viewport->width) |
1070 | width = lcd_current_viewport->width - x; | 1070 | width = lcd_current_viewport->width - x; |
1071 | if (y + height > lcd_current_viewport->height) | 1071 | if (y + height > lcd_current_viewport->height) |
1072 | height = lcd_current_viewport->height - y; | 1072 | height = lcd_current_viewport->height - y; |
1073 | 1073 | ||
1074 | /* adjust for viewport */ | 1074 | /* adjust for viewport */ |
1075 | x += lcd_current_viewport->x; | 1075 | x += lcd_current_viewport->x; |
1076 | y += lcd_current_viewport->y; | 1076 | y += lcd_current_viewport->y; |
1077 | 1077 | ||
1078 | #if defined(HAVE_VIEWPORT_CLIP) | 1078 | #if defined(HAVE_VIEWPORT_CLIP) |
1079 | /********************* Viewport on screen clipping ********************/ | 1079 | /********************* Viewport on screen clipping ********************/ |
1080 | /* nothing to draw? */ | 1080 | /* nothing to draw? */ |
1081 | if ((x >= LCD_WIDTH) || (y >= LCD_HEIGHT) | 1081 | if ((x >= LCD_WIDTH) || (y >= LCD_HEIGHT) |
1082 | || (x + width <= 0) || (y + height <= 0)) | 1082 | || (x + width <= 0) || (y + height <= 0)) |
1083 | return; | 1083 | return; |
1084 | 1084 | ||
1085 | /* clip image in viewport in screen */ | 1085 | /* clip image in viewport in screen */ |
1086 | if (x < 0) | 1086 | if (x < 0) |
1087 | { | 1087 | { |
diff --git a/firmware/drivers/lcd-2bit-horz.c b/firmware/drivers/lcd-2bit-horz.c index 35a2be5b2c..b2114ba830 100644 --- a/firmware/drivers/lcd-2bit-horz.c +++ b/firmware/drivers/lcd-2bit-horz.c | |||
@@ -8,7 +8,7 @@ | |||
8 | * $Id$ | 8 | * $Id$ |
9 | * | 9 | * |
10 | * LCD driver for horizontally-packed 2bpp greyscale display | 10 | * LCD driver for horizontally-packed 2bpp greyscale display |
11 | * | 11 | * |
12 | * Based on code from the rockbox lcd's driver | 12 | * Based on code from the rockbox lcd's driver |
13 | * | 13 | * |
14 | * Copyright (c) 2006 Seven Le Mesle (sevlm@free.fr) | 14 | * Copyright (c) 2006 Seven Le Mesle (sevlm@free.fr) |
@@ -199,7 +199,7 @@ static void flippixel(int x, int y) | |||
199 | { | 199 | { |
200 | unsigned mask = pixmask[x & 3]; | 200 | unsigned mask = pixmask[x & 3]; |
201 | fb_data *address = FBADDR(x>>2,y); | 201 | fb_data *address = FBADDR(x>>2,y); |
202 | 202 | ||
203 | *address ^= mask; | 203 | *address ^= mask; |
204 | } | 204 | } |
205 | 205 | ||
@@ -362,7 +362,7 @@ fb_data* lcd_get_backdrop(void) | |||
362 | static inline void setblock(fb_data *address, unsigned mask, unsigned bits) | 362 | static inline void setblock(fb_data *address, unsigned mask, unsigned bits) |
363 | { | 363 | { |
364 | unsigned data = *address; | 364 | unsigned data = *address; |
365 | 365 | ||
366 | bits ^= data; | 366 | bits ^= data; |
367 | *address = data ^ (bits & mask); | 367 | *address = data ^ (bits & mask); |
368 | } | 368 | } |
@@ -402,7 +402,7 @@ void lcd_clear_viewport(void) | |||
402 | lastmode = lcd_current_viewport->drawmode; | 402 | lastmode = lcd_current_viewport->drawmode; |
403 | 403 | ||
404 | /* Invert the INVERSEVID bit and set basic mode to SOLID */ | 404 | /* Invert the INVERSEVID bit and set basic mode to SOLID */ |
405 | lcd_current_viewport->drawmode = (~lastmode & DRMODE_INVERSEVID) | | 405 | lcd_current_viewport->drawmode = (~lastmode & DRMODE_INVERSEVID) | |
406 | DRMODE_SOLID; | 406 | DRMODE_SOLID; |
407 | 407 | ||
408 | lcd_fillrect(0, 0, lcd_current_viewport->width, lcd_current_viewport->height); | 408 | lcd_fillrect(0, 0, lcd_current_viewport->width, lcd_current_viewport->height); |
@@ -492,7 +492,7 @@ void lcd_drawline(int x1, int y1, int x2, int y2) | |||
492 | 492 | ||
493 | for (i = 0; i < numpixels; i++) | 493 | for (i = 0; i < numpixels; i++) |
494 | { | 494 | { |
495 | if ( ((unsigned)x < (unsigned)lcd_current_viewport->width) | 495 | if ( ((unsigned)x < (unsigned)lcd_current_viewport->width) |
496 | && ((unsigned)y < (unsigned)lcd_current_viewport->height) | 496 | && ((unsigned)y < (unsigned)lcd_current_viewport->height) |
497 | #if defined(HAVE_VIEWPORT_CLIP) | 497 | #if defined(HAVE_VIEWPORT_CLIP) |
498 | && ((unsigned)x < (unsigned)LCD_WIDTH) | 498 | && ((unsigned)x < (unsigned)LCD_WIDTH) |
@@ -531,13 +531,13 @@ void lcd_hline(int x1, int x2, int y) | |||
531 | x1 = x2; | 531 | x1 = x2; |
532 | x2 = nx; | 532 | x2 = nx; |
533 | } | 533 | } |
534 | 534 | ||
535 | /******************** In viewport clipping **********************/ | 535 | /******************** In viewport clipping **********************/ |
536 | /* nothing to draw? */ | 536 | /* nothing to draw? */ |
537 | if (((unsigned)y >= (unsigned)lcd_current_viewport->height) || (x1 >= lcd_current_viewport->width) | 537 | if (((unsigned)y >= (unsigned)lcd_current_viewport->height) || (x1 >= lcd_current_viewport->width) |
538 | || (x2 < 0)) | 538 | || (x2 < 0)) |
539 | return; | 539 | return; |
540 | 540 | ||
541 | if (x1 < 0) | 541 | if (x1 < 0) |
542 | x1 = 0; | 542 | x1 = 0; |
543 | if (x2 >= lcd_current_viewport->width) | 543 | if (x2 >= lcd_current_viewport->width) |
@@ -547,14 +547,14 @@ void lcd_hline(int x1, int x2, int y) | |||
547 | x1 += lcd_current_viewport->x; | 547 | x1 += lcd_current_viewport->x; |
548 | x2 += lcd_current_viewport->x; | 548 | x2 += lcd_current_viewport->x; |
549 | y += lcd_current_viewport->y; | 549 | y += lcd_current_viewport->y; |
550 | 550 | ||
551 | #if defined(HAVE_VIEWPORT_CLIP) | 551 | #if defined(HAVE_VIEWPORT_CLIP) |
552 | /********************* Viewport on screen clipping ********************/ | 552 | /********************* Viewport on screen clipping ********************/ |
553 | /* nothing to draw? */ | 553 | /* nothing to draw? */ |
554 | if (((unsigned)y >= (unsigned) LCD_HEIGHT) || (x1 >= LCD_WIDTH) | 554 | if (((unsigned)y >= (unsigned) LCD_HEIGHT) || (x1 >= LCD_WIDTH) |
555 | || (x2 < 0)) | 555 | || (x2 < 0)) |
556 | return; | 556 | return; |
557 | 557 | ||
558 | /* clipping */ | 558 | /* clipping */ |
559 | if (x1 < 0) | 559 | if (x1 < 0) |
560 | x1 = 0; | 560 | x1 = 0; |
@@ -567,7 +567,7 @@ void lcd_hline(int x1, int x2, int y) | |||
567 | nx = x2 - (x1 & ~3); | 567 | nx = x2 - (x1 & ~3); |
568 | mask = 0xFFu >> (2 * (x1 & 3)); | 568 | mask = 0xFFu >> (2 * (x1 & 3)); |
569 | mask_right = 0xFFu << (2 * (~nx & 3)); | 569 | mask_right = 0xFFu << (2 * (~nx & 3)); |
570 | 570 | ||
571 | for (; nx >= 4; nx -= 4) | 571 | for (; nx >= 4; nx -= 4) |
572 | { | 572 | { |
573 | bfunc(dst++, mask, 0xFFu); | 573 | bfunc(dst++, mask, 0xFFu); |
@@ -598,8 +598,8 @@ void lcd_vline(int x, int y1, int y2) | |||
598 | /* nothing to draw? */ | 598 | /* nothing to draw? */ |
599 | if (((unsigned)x >= (unsigned)lcd_current_viewport->width) || (y1 >= lcd_current_viewport->height) | 599 | if (((unsigned)x >= (unsigned)lcd_current_viewport->width) || (y1 >= lcd_current_viewport->height) |
600 | || (y2 < 0)) | 600 | || (y2 < 0)) |
601 | return; | 601 | return; |
602 | 602 | ||
603 | if (y1 < 0) | 603 | if (y1 < 0) |
604 | y1 = 0; | 604 | y1 = 0; |
605 | if (y2 >= lcd_current_viewport->height) | 605 | if (y2 >= lcd_current_viewport->height) |
@@ -609,26 +609,26 @@ void lcd_vline(int x, int y1, int y2) | |||
609 | y1 += lcd_current_viewport->y; | 609 | y1 += lcd_current_viewport->y; |
610 | y2 += lcd_current_viewport->y; | 610 | y2 += lcd_current_viewport->y; |
611 | x += lcd_current_viewport->x; | 611 | x += lcd_current_viewport->x; |
612 | 612 | ||
613 | #if defined(HAVE_VIEWPORT_CLIP) | 613 | #if defined(HAVE_VIEWPORT_CLIP) |
614 | /********************* Viewport on screen clipping ********************/ | 614 | /********************* Viewport on screen clipping ********************/ |
615 | /* nothing to draw? */ | 615 | /* nothing to draw? */ |
616 | if (( (unsigned) x >= (unsigned)LCD_WIDTH) || (y1 >= LCD_HEIGHT) | 616 | if (( (unsigned) x >= (unsigned)LCD_WIDTH) || (y1 >= LCD_HEIGHT) |
617 | || (y2 < 0)) | 617 | || (y2 < 0)) |
618 | return; | 618 | return; |
619 | 619 | ||
620 | /* clipping */ | 620 | /* clipping */ |
621 | if (y1 < 0) | 621 | if (y1 < 0) |
622 | y1 = 0; | 622 | y1 = 0; |
623 | if (y2 >= LCD_HEIGHT) | 623 | if (y2 >= LCD_HEIGHT) |
624 | y2 = LCD_HEIGHT-1; | 624 | y2 = LCD_HEIGHT-1; |
625 | #endif | 625 | #endif |
626 | 626 | ||
627 | bfunc = lcd_blockfuncs[lcd_current_viewport->drawmode]; | 627 | bfunc = lcd_blockfuncs[lcd_current_viewport->drawmode]; |
628 | dst = FBADDR(x>>2,y1); | 628 | dst = FBADDR(x>>2,y1); |
629 | stride_dst = LCD_FBSTRIDE(lcd_current_viewport->buffer->stride, 0); | 629 | stride_dst = LCD_FBSTRIDE(lcd_current_viewport->buffer->stride, 0); |
630 | mask = pixmask[x & 3]; | 630 | mask = pixmask[x & 3]; |
631 | 631 | ||
632 | dst_end = dst + (y2 - y1) * stride_dst; | 632 | dst_end = dst + (y2 - y1) * stride_dst; |
633 | do | 633 | do |
634 | { | 634 | { |
@@ -686,14 +686,14 @@ void lcd_fillrect(int x, int y, int width, int height) | |||
686 | /* adjust for viewport */ | 686 | /* adjust for viewport */ |
687 | x += lcd_current_viewport->x; | 687 | x += lcd_current_viewport->x; |
688 | y += lcd_current_viewport->y; | 688 | y += lcd_current_viewport->y; |
689 | 689 | ||
690 | #if defined(HAVE_VIEWPORT_CLIP) | 690 | #if defined(HAVE_VIEWPORT_CLIP) |
691 | /********************* Viewport on screen clipping ********************/ | 691 | /********************* Viewport on screen clipping ********************/ |
692 | /* nothing to draw? */ | 692 | /* nothing to draw? */ |
693 | if ((x >= LCD_WIDTH) || (y >= LCD_HEIGHT) | 693 | if ((x >= LCD_WIDTH) || (y >= LCD_HEIGHT) |
694 | || (x + width <= 0) || (y + height <= 0)) | 694 | || (x + width <= 0) || (y + height <= 0)) |
695 | return; | 695 | return; |
696 | 696 | ||
697 | /* clip image in viewport in screen */ | 697 | /* clip image in viewport in screen */ |
698 | if (x < 0) | 698 | if (x < 0) |
699 | { | 699 | { |
@@ -717,7 +717,7 @@ void lcd_fillrect(int x, int y, int width, int height) | |||
717 | nx = width - 1 + (x & 3); | 717 | nx = width - 1 + (x & 3); |
718 | mask = 0xFFu >> (2 * (x & 3)); | 718 | mask = 0xFFu >> (2 * (x & 3)); |
719 | mask_right = 0xFFu << (2 * (~nx & 3)); | 719 | mask_right = 0xFFu << (2 * (~nx & 3)); |
720 | 720 | ||
721 | for (; nx >= 4; nx -= 4) | 721 | for (; nx >= 4; nx -= 4) |
722 | { | 722 | { |
723 | unsigned char *dst_col = dst; | 723 | unsigned char *dst_col = dst; |
@@ -770,7 +770,7 @@ void ICODE_ATTR lcd_mono_bitmap_part(const unsigned char *src, int src_x, | |||
770 | if ((width <= 0) || (height <= 0) || (x >= lcd_current_viewport->width) || | 770 | if ((width <= 0) || (height <= 0) || (x >= lcd_current_viewport->width) || |
771 | (y >= lcd_current_viewport->height) || (x + width <= 0) || (y + height <= 0)) | 771 | (y >= lcd_current_viewport->height) || (x + width <= 0) || (y + height <= 0)) |
772 | return; | 772 | return; |
773 | 773 | ||
774 | if (x < 0) | 774 | if (x < 0) |
775 | { | 775 | { |
776 | width += x; | 776 | width += x; |
@@ -787,17 +787,17 @@ void ICODE_ATTR lcd_mono_bitmap_part(const unsigned char *src, int src_x, | |||
787 | width = lcd_current_viewport->width - x; | 787 | width = lcd_current_viewport->width - x; |
788 | if (y + height > lcd_current_viewport->height) | 788 | if (y + height > lcd_current_viewport->height) |
789 | height = lcd_current_viewport->height - y; | 789 | height = lcd_current_viewport->height - y; |
790 | 790 | ||
791 | x += lcd_current_viewport->x; /* adjust for viewport */ | 791 | x += lcd_current_viewport->x; /* adjust for viewport */ |
792 | y += lcd_current_viewport->y; /* adjust for viewport */ | 792 | y += lcd_current_viewport->y; /* adjust for viewport */ |
793 | 793 | ||
794 | #if defined(HAVE_VIEWPORT_CLIP) | 794 | #if defined(HAVE_VIEWPORT_CLIP) |
795 | /********************* Viewport on screen clipping ********************/ | 795 | /********************* Viewport on screen clipping ********************/ |
796 | /* nothing to draw? */ | 796 | /* nothing to draw? */ |
797 | if ((x >= LCD_WIDTH) || (y >= LCD_HEIGHT) | 797 | if ((x >= LCD_WIDTH) || (y >= LCD_HEIGHT) |
798 | || (x + width <= 0) || (y + height <= 0)) | 798 | || (x + width <= 0) || (y + height <= 0)) |
799 | return; | 799 | return; |
800 | 800 | ||
801 | /* clip image in viewport in screen */ | 801 | /* clip image in viewport in screen */ |
802 | if (x < 0) | 802 | if (x < 0) |
803 | { | 803 | { |
@@ -820,7 +820,7 @@ void ICODE_ATTR lcd_mono_bitmap_part(const unsigned char *src, int src_x, | |||
820 | src += stride * (src_y >> 3) + src_x; /* move starting point */ | 820 | src += stride * (src_y >> 3) + src_x; /* move starting point */ |
821 | src_y &= 7; | 821 | src_y &= 7; |
822 | src_end = src + width; | 822 | src_end = src + width; |
823 | 823 | ||
824 | dst = FBADDR(x >> 2,y); | 824 | dst = FBADDR(x >> 2,y); |
825 | stride_dst = LCD_FBSTRIDE(lcd_current_viewport->buffer->stride, 0); | 825 | stride_dst = LCD_FBSTRIDE(lcd_current_viewport->buffer->stride, 0); |
826 | dst_end = dst + height * stride_dst; | 826 | dst_end = dst + height * stride_dst; |
@@ -835,7 +835,7 @@ void ICODE_ATTR lcd_mono_bitmap_part(const unsigned char *src, int src_x, | |||
835 | do | 835 | do |
836 | { | 836 | { |
837 | const unsigned char *src_col = src++; | 837 | const unsigned char *src_col = src++; |
838 | unsigned data = (*src_col ^ dmask) >> src_y; | 838 | unsigned data = (*src_col ^ dmask) >> src_y; |
839 | fb_data *dst_col = dst; | 839 | fb_data *dst_col = dst; |
840 | int fg, bg; | 840 | int fg, bg; |
841 | long bo; | 841 | long bo; |
@@ -847,7 +847,7 @@ void ICODE_ATTR lcd_mono_bitmap_part(const unsigned char *src, int src_x, | |||
847 | data = *src_col ^ dmask; \ | 847 | data = *src_col ^ dmask; \ |
848 | } \ | 848 | } \ |
849 | } while (0) | 849 | } while (0) |
850 | 850 | ||
851 | switch (drmode) | 851 | switch (drmode) |
852 | { | 852 | { |
853 | case DRMODE_COMPLEMENT: | 853 | case DRMODE_COMPLEMENT: |
@@ -861,7 +861,7 @@ void ICODE_ATTR lcd_mono_bitmap_part(const unsigned char *src, int src_x, | |||
861 | } | 861 | } |
862 | while (dst_col < dst_end); | 862 | while (dst_col < dst_end); |
863 | break; | 863 | break; |
864 | 864 | ||
865 | case DRMODE_BG: | 865 | case DRMODE_BG: |
866 | if (lcd_backdrop) | 866 | if (lcd_backdrop) |
867 | { | 867 | { |
@@ -919,7 +919,7 @@ void ICODE_ATTR lcd_mono_bitmap_part(const unsigned char *src, int src_x, | |||
919 | do | 919 | do |
920 | { | 920 | { |
921 | unsigned block = *dst_col; | 921 | unsigned block = *dst_col; |
922 | *dst_col = block ^ ((block ^ ((data & 0x01) ? | 922 | *dst_col = block ^ ((block ^ ((data & 0x01) ? |
923 | fg : *(dst_col + bo))) & dst_mask); | 923 | fg : *(dst_col + bo))) & dst_mask); |
924 | 924 | ||
925 | dst_col += stride_dst; | 925 | dst_col += stride_dst; |
@@ -981,10 +981,10 @@ void ICODE_ATTR lcd_bitmap_part(const unsigned char *src, int src_x, | |||
981 | 981 | ||
982 | /******************** Image in viewport clipping **********************/ | 982 | /******************** Image in viewport clipping **********************/ |
983 | /* nothing to draw? */ | 983 | /* nothing to draw? */ |
984 | if ((width <= 0) || (height <= 0) || (x >= lcd_current_viewport->width) || | 984 | if ((width <= 0) || (height <= 0) || (x >= lcd_current_viewport->width) || |
985 | (y >= lcd_current_viewport->height) || (x + width <= 0) || (y + height <= 0)) | 985 | (y >= lcd_current_viewport->height) || (x + width <= 0) || (y + height <= 0)) |
986 | return; | 986 | return; |
987 | 987 | ||
988 | if (x < 0) | 988 | if (x < 0) |
989 | { | 989 | { |
990 | width += x; | 990 | width += x; |
@@ -1005,14 +1005,14 @@ void ICODE_ATTR lcd_bitmap_part(const unsigned char *src, int src_x, | |||
1005 | /* adjust for viewport */ | 1005 | /* adjust for viewport */ |
1006 | x += lcd_current_viewport->x; | 1006 | x += lcd_current_viewport->x; |
1007 | y += lcd_current_viewport->y; | 1007 | y += lcd_current_viewport->y; |
1008 | 1008 | ||
1009 | #if defined(HAVE_VIEWPORT_CLIP) | 1009 | #if defined(HAVE_VIEWPORT_CLIP) |
1010 | /********************* Viewport on screen clipping ********************/ | 1010 | /********************* Viewport on screen clipping ********************/ |
1011 | /* nothing to draw? */ | 1011 | /* nothing to draw? */ |
1012 | if ((x >= LCD_WIDTH) || (y >= LCD_HEIGHT) | 1012 | if ((x >= LCD_WIDTH) || (y >= LCD_HEIGHT) |
1013 | || (x + width <= 0) || (y + height <= 0)) | 1013 | || (x + width <= 0) || (y + height <= 0)) |
1014 | return; | 1014 | return; |
1015 | 1015 | ||
1016 | /* clip image in viewport in screen */ | 1016 | /* clip image in viewport in screen */ |
1017 | if (x < 0) | 1017 | if (x < 0) |
1018 | { | 1018 | { |
@@ -1044,7 +1044,7 @@ void ICODE_ATTR lcd_bitmap_part(const unsigned char *src, int src_x, | |||
1044 | 1044 | ||
1045 | mask = 0xFF00u >> (2 * (shift + src_x)); | 1045 | mask = 0xFF00u >> (2 * (shift + src_x)); |
1046 | mask_right = 0xFFu << (2 * (~nx & 3)); | 1046 | mask_right = 0xFFu << (2 * (~nx & 3)); |
1047 | 1047 | ||
1048 | shift *= 2; | 1048 | shift *= 2; |
1049 | dst_end = dst + height * stride_dst; | 1049 | dst_end = dst + height * stride_dst; |
1050 | do | 1050 | do |
@@ -1053,11 +1053,11 @@ void ICODE_ATTR lcd_bitmap_part(const unsigned char *src, int src_x, | |||
1053 | unsigned char *dst_row = dst; | 1053 | unsigned char *dst_row = dst; |
1054 | unsigned mask_row = mask >> 8; | 1054 | unsigned mask_row = mask >> 8; |
1055 | unsigned data = 0; | 1055 | unsigned data = 0; |
1056 | 1056 | ||
1057 | for (x = nx; x >= 4; x -= 4) | 1057 | for (x = nx; x >= 4; x -= 4) |
1058 | { | 1058 | { |
1059 | data = (data << 8) | *src_row++; | 1059 | data = (data << 8) | *src_row++; |
1060 | 1060 | ||
1061 | if (mask_row & 0xFF) | 1061 | if (mask_row & 0xFF) |
1062 | { | 1062 | { |
1063 | setblock(dst_row, mask_row, data >> shift); | 1063 | setblock(dst_row, mask_row, data >> shift); |
diff --git a/firmware/drivers/lcd-2bit-vert.c b/firmware/drivers/lcd-2bit-vert.c index a099c45e98..6a476495d0 100644 --- a/firmware/drivers/lcd-2bit-vert.c +++ b/firmware/drivers/lcd-2bit-vert.c | |||
@@ -260,7 +260,7 @@ static void ICODE_ATTR solidblock(fb_data *address, unsigned mask, | |||
260 | { | 260 | { |
261 | unsigned data = *address; | 261 | unsigned data = *address; |
262 | unsigned bgp = bg_pattern; | 262 | unsigned bgp = bg_pattern; |
263 | 263 | ||
264 | bits = bgp ^ ((bgp ^ fg_pattern) & bits); | 264 | bits = bgp ^ ((bgp ^ fg_pattern) & bits); |
265 | *address = data ^ ((data ^ bits) & mask); | 265 | *address = data ^ ((data ^ bits) & mask); |
266 | } | 266 | } |
@@ -270,7 +270,7 @@ static void ICODE_ATTR solidimgblock(fb_data *address, unsigned mask, | |||
270 | { | 270 | { |
271 | unsigned data = *address; | 271 | unsigned data = *address; |
272 | unsigned bgp = *(address + lcd_backdrop_offset); | 272 | unsigned bgp = *(address + lcd_backdrop_offset); |
273 | 273 | ||
274 | bits = bgp ^ ((bgp ^ fg_pattern) & bits); | 274 | bits = bgp ^ ((bgp ^ fg_pattern) & bits); |
275 | *address = data ^ ((data ^ bits) & mask); | 275 | *address = data ^ ((data ^ bits) & mask); |
276 | } | 276 | } |
@@ -310,7 +310,7 @@ static void ICODE_ATTR solidinvblock(fb_data *address, unsigned mask, | |||
310 | { | 310 | { |
311 | unsigned data = *address; | 311 | unsigned data = *address; |
312 | unsigned fgp = fg_pattern; | 312 | unsigned fgp = fg_pattern; |
313 | 313 | ||
314 | bits = fgp ^ ((fgp ^ bg_pattern) & bits); | 314 | bits = fgp ^ ((fgp ^ bg_pattern) & bits); |
315 | *address = data ^ ((data ^ bits) & mask); | 315 | *address = data ^ ((data ^ bits) & mask); |
316 | } | 316 | } |
@@ -320,7 +320,7 @@ static void ICODE_ATTR solidimginvblock(fb_data *address, unsigned mask, | |||
320 | { | 320 | { |
321 | unsigned data = *address; | 321 | unsigned data = *address; |
322 | unsigned fgp = fg_pattern; | 322 | unsigned fgp = fg_pattern; |
323 | 323 | ||
324 | bits = fgp ^ ((fgp ^ *(address + lcd_backdrop_offset)) & bits); | 324 | bits = fgp ^ ((fgp ^ *(address + lcd_backdrop_offset)) & bits); |
325 | *address = data ^ ((data ^ bits) & mask); | 325 | *address = data ^ ((data ^ bits) & mask); |
326 | } | 326 | } |
@@ -347,7 +347,7 @@ void lcd_set_backdrop(fb_data* backdrop) | |||
347 | lcd_pixelfuncs = lcd_pixelfuncs_backdrop; | 347 | lcd_pixelfuncs = lcd_pixelfuncs_backdrop; |
348 | lcd_blockfuncs = lcd_blockfuncs_backdrop; | 348 | lcd_blockfuncs = lcd_blockfuncs_backdrop; |
349 | } | 349 | } |
350 | else | 350 | else |
351 | { | 351 | { |
352 | lcd_backdrop_offset = 0; | 352 | lcd_backdrop_offset = 0; |
353 | lcd_pixelfuncs = lcd_pixelfuncs_bgcolor; | 353 | lcd_pixelfuncs = lcd_pixelfuncs_bgcolor; |
@@ -419,7 +419,7 @@ void lcd_clear_viewport(void) | |||
419 | /* Set a single pixel */ | 419 | /* Set a single pixel */ |
420 | void lcd_drawpixel(int x, int y) | 420 | void lcd_drawpixel(int x, int y) |
421 | { | 421 | { |
422 | if ( ((unsigned)x < (unsigned)lcd_current_viewport->width) | 422 | if ( ((unsigned)x < (unsigned)lcd_current_viewport->width) |
423 | && ((unsigned)y < (unsigned)lcd_current_viewport->height) | 423 | && ((unsigned)y < (unsigned)lcd_current_viewport->height) |
424 | #if defined(HAVE_VIEWPORT_CLIP) | 424 | #if defined(HAVE_VIEWPORT_CLIP) |
425 | && ((unsigned)x < (unsigned)LCD_WIDTH) | 425 | && ((unsigned)x < (unsigned)LCD_WIDTH) |
@@ -494,7 +494,7 @@ void lcd_drawline(int x1, int y1, int x2, int y2) | |||
494 | 494 | ||
495 | for (i = 0; i < numpixels; i++) | 495 | for (i = 0; i < numpixels; i++) |
496 | { | 496 | { |
497 | if ( ((unsigned)x < (unsigned)lcd_current_viewport->width) | 497 | if ( ((unsigned)x < (unsigned)lcd_current_viewport->width) |
498 | && ((unsigned)y < (unsigned)lcd_current_viewport->height) | 498 | && ((unsigned)y < (unsigned)lcd_current_viewport->height) |
499 | #if defined(HAVE_VIEWPORT_CLIP) | 499 | #if defined(HAVE_VIEWPORT_CLIP) |
500 | && ((unsigned)x < (unsigned)LCD_WIDTH) | 500 | && ((unsigned)x < (unsigned)LCD_WIDTH) |
@@ -534,12 +534,12 @@ void lcd_hline(int x1, int x2, int y) | |||
534 | x1 = x2; | 534 | x1 = x2; |
535 | x2 = x; | 535 | x2 = x; |
536 | } | 536 | } |
537 | 537 | ||
538 | /******************** In viewport clipping **********************/ | 538 | /******************** In viewport clipping **********************/ |
539 | /* nothing to draw? */ | 539 | /* nothing to draw? */ |
540 | if (((unsigned)y >= (unsigned)lcd_current_viewport->height) || (x1 >= lcd_current_viewport->width) | 540 | if (((unsigned)y >= (unsigned)lcd_current_viewport->height) || (x1 >= lcd_current_viewport->width) |
541 | || (x2 < 0)) | 541 | || (x2 < 0)) |
542 | return; | 542 | return; |
543 | 543 | ||
544 | if (x1 < 0) | 544 | if (x1 < 0) |
545 | x1 = 0; | 545 | x1 = 0; |
@@ -550,14 +550,14 @@ void lcd_hline(int x1, int x2, int y) | |||
550 | x1 += lcd_current_viewport->x; | 550 | x1 += lcd_current_viewport->x; |
551 | x2 += lcd_current_viewport->x; | 551 | x2 += lcd_current_viewport->x; |
552 | y += lcd_current_viewport->y; | 552 | y += lcd_current_viewport->y; |
553 | 553 | ||
554 | #if defined(HAVE_VIEWPORT_CLIP) | 554 | #if defined(HAVE_VIEWPORT_CLIP) |
555 | /********************* Viewport on screen clipping ********************/ | 555 | /********************* Viewport on screen clipping ********************/ |
556 | /* nothing to draw? */ | 556 | /* nothing to draw? */ |
557 | if (((unsigned)y >= (unsigned) LCD_HEIGHT) || (x1 >= LCD_WIDTH) | 557 | if (((unsigned)y >= (unsigned) LCD_HEIGHT) || (x1 >= LCD_WIDTH) |
558 | || (x2 < 0)) | 558 | || (x2 < 0)) |
559 | return; | 559 | return; |
560 | 560 | ||
561 | /* clipping */ | 561 | /* clipping */ |
562 | if (x1 < 0) | 562 | if (x1 < 0) |
563 | x1 = 0; | 563 | x1 = 0; |
@@ -598,25 +598,25 @@ void lcd_vline(int x, int y1, int y2) | |||
598 | /* nothing to draw? */ | 598 | /* nothing to draw? */ |
599 | if (((unsigned)x >= (unsigned)lcd_current_viewport->width) || (y1 >= lcd_current_viewport->height) | 599 | if (((unsigned)x >= (unsigned)lcd_current_viewport->width) || (y1 >= lcd_current_viewport->height) |
600 | || (y2 < 0)) | 600 | || (y2 < 0)) |
601 | return; | 601 | return; |
602 | 602 | ||
603 | if (y1 < 0) | 603 | if (y1 < 0) |
604 | y1 = 0; | 604 | y1 = 0; |
605 | if (y2 >= lcd_current_viewport->height) | 605 | if (y2 >= lcd_current_viewport->height) |
606 | y2 = lcd_current_viewport->height-1; | 606 | y2 = lcd_current_viewport->height-1; |
607 | 607 | ||
608 | /* adjust for viewport */ | 608 | /* adjust for viewport */ |
609 | y1 += lcd_current_viewport->y; | 609 | y1 += lcd_current_viewport->y; |
610 | y2 += lcd_current_viewport->y; | 610 | y2 += lcd_current_viewport->y; |
611 | x += lcd_current_viewport->x; | 611 | x += lcd_current_viewport->x; |
612 | 612 | ||
613 | #if defined(HAVE_VIEWPORT_CLIP) | 613 | #if defined(HAVE_VIEWPORT_CLIP) |
614 | /********************* Viewport on screen clipping ********************/ | 614 | /********************* Viewport on screen clipping ********************/ |
615 | /* nothing to draw? */ | 615 | /* nothing to draw? */ |
616 | if (( (unsigned) x >= (unsigned)LCD_WIDTH) || (y1 >= LCD_HEIGHT) | 616 | if (( (unsigned) x >= (unsigned)LCD_WIDTH) || (y1 >= LCD_HEIGHT) |
617 | || (y2 < 0)) | 617 | || (y2 < 0)) |
618 | return; | 618 | return; |
619 | 619 | ||
620 | /* clipping */ | 620 | /* clipping */ |
621 | if (y1 < 0) | 621 | if (y1 < 0) |
622 | y1 = 0; | 622 | y1 = 0; |
@@ -687,18 +687,18 @@ void lcd_fillrect(int x, int y, int width, int height) | |||
687 | width = lcd_current_viewport->width - x; | 687 | width = lcd_current_viewport->width - x; |
688 | if (y + height > lcd_current_viewport->height) | 688 | if (y + height > lcd_current_viewport->height) |
689 | height = lcd_current_viewport->height - y; | 689 | height = lcd_current_viewport->height - y; |
690 | 690 | ||
691 | /* adjust for viewport */ | 691 | /* adjust for viewport */ |
692 | x += lcd_current_viewport->x; | 692 | x += lcd_current_viewport->x; |
693 | y += lcd_current_viewport->y; | 693 | y += lcd_current_viewport->y; |
694 | 694 | ||
695 | #if defined(HAVE_VIEWPORT_CLIP) | 695 | #if defined(HAVE_VIEWPORT_CLIP) |
696 | /********************* Viewport on screen clipping ********************/ | 696 | /********************* Viewport on screen clipping ********************/ |
697 | /* nothing to draw? */ | 697 | /* nothing to draw? */ |
698 | if ((x >= LCD_WIDTH) || (y >= LCD_HEIGHT) | 698 | if ((x >= LCD_WIDTH) || (y >= LCD_HEIGHT) |
699 | || (x + width <= 0) || (y + height <= 0)) | 699 | || (x + width <= 0) || (y + height <= 0)) |
700 | return; | 700 | return; |
701 | 701 | ||
702 | /* clip image in viewport in screen */ | 702 | /* clip image in viewport in screen */ |
703 | if (x < 0) | 703 | if (x < 0) |
704 | { | 704 | { |
@@ -817,14 +817,14 @@ void ICODE_ATTR lcd_mono_bitmap_part(const unsigned char *src, int src_x, | |||
817 | /* adjust for viewport */ | 817 | /* adjust for viewport */ |
818 | x += lcd_current_viewport->x; | 818 | x += lcd_current_viewport->x; |
819 | y += lcd_current_viewport->y; | 819 | y += lcd_current_viewport->y; |
820 | 820 | ||
821 | #if defined(HAVE_VIEWPORT_CLIP) | 821 | #if defined(HAVE_VIEWPORT_CLIP) |
822 | /********************* Viewport on screen clipping ********************/ | 822 | /********************* Viewport on screen clipping ********************/ |
823 | /* nothing to draw? */ | 823 | /* nothing to draw? */ |
824 | if ((x >= LCD_WIDTH) || (y >= LCD_HEIGHT) | 824 | if ((x >= LCD_WIDTH) || (y >= LCD_HEIGHT) |
825 | || (x + width <= 0) || (y + height <= 0)) | 825 | || (x + width <= 0) || (y + height <= 0)) |
826 | return; | 826 | return; |
827 | 827 | ||
828 | /* clip image in viewport in screen */ | 828 | /* clip image in viewport in screen */ |
829 | if (x < 0) | 829 | if (x < 0) |
830 | { | 830 | { |
@@ -856,7 +856,7 @@ void ICODE_ATTR lcd_mono_bitmap_part(const unsigned char *src, int src_x, | |||
856 | mask_bottom = 0xFFFFu >> (2 * (~ny & 7)); | 856 | mask_bottom = 0xFFFFu >> (2 * (~ny & 7)); |
857 | 857 | ||
858 | bfunc = lcd_blockfuncs[lcd_current_viewport->drawmode]; | 858 | bfunc = lcd_blockfuncs[lcd_current_viewport->drawmode]; |
859 | 859 | ||
860 | if (shift == 0) | 860 | if (shift == 0) |
861 | { | 861 | { |
862 | unsigned dmask1, dmask2, data; | 862 | unsigned dmask1, dmask2, data; |
@@ -868,7 +868,7 @@ void ICODE_ATTR lcd_mono_bitmap_part(const unsigned char *src, int src_x, | |||
868 | { | 868 | { |
869 | const unsigned char *src_row = src; | 869 | const unsigned char *src_row = src; |
870 | fb_data *dst_row = dst + stride_dst; | 870 | fb_data *dst_row = dst + stride_dst; |
871 | 871 | ||
872 | dst_end = dst_row + width; | 872 | dst_end = dst_row + width; |
873 | 873 | ||
874 | if (dmask1 != 0) | 874 | if (dmask1 != 0) |
@@ -895,7 +895,7 @@ void ICODE_ATTR lcd_mono_bitmap_part(const unsigned char *src, int src_x, | |||
895 | /* & 0xFFu is unnecessary here - dmask1 can't exceed that*/ | 895 | /* & 0xFFu is unnecessary here - dmask1 can't exceed that*/ |
896 | dmask2 &= (mask_bottom >> 8); | 896 | dmask2 &= (mask_bottom >> 8); |
897 | dst_end = dst + width; | 897 | dst_end = dst + width; |
898 | 898 | ||
899 | if (dmask1 != 0) | 899 | if (dmask1 != 0) |
900 | { | 900 | { |
901 | if (dmask2 != 0) | 901 | if (dmask2 != 0) |
@@ -931,8 +931,8 @@ void ICODE_ATTR lcd_mono_bitmap_part(const unsigned char *src, int src_x, | |||
931 | fb_data *dst_col = dst++; | 931 | fb_data *dst_col = dst++; |
932 | unsigned mask_col = mask; | 932 | unsigned mask_col = mask; |
933 | unsigned data = 0; | 933 | unsigned data = 0; |
934 | 934 | ||
935 | for (y = ny; y >= 8; y -= 8) | 935 | for (y = ny; y >= 8; y -= 8) |
936 | { | 936 | { |
937 | data |= *src_col << shift; | 937 | data |= *src_col << shift; |
938 | 938 | ||
@@ -995,7 +995,7 @@ void ICODE_ATTR lcd_bitmap_part(const fb_data *src, int src_x, int src_y, | |||
995 | if ((width <= 0) || (height <= 0) || (x >= lcd_current_viewport->width) | 995 | if ((width <= 0) || (height <= 0) || (x >= lcd_current_viewport->width) |
996 | || (y >= lcd_current_viewport->height) || (x + width <= 0) || (y + height <= 0)) | 996 | || (y >= lcd_current_viewport->height) || (x + width <= 0) || (y + height <= 0)) |
997 | return; | 997 | return; |
998 | 998 | ||
999 | if (x < 0) | 999 | if (x < 0) |
1000 | { | 1000 | { |
1001 | width += x; | 1001 | width += x; |
@@ -1016,14 +1016,14 @@ void ICODE_ATTR lcd_bitmap_part(const fb_data *src, int src_x, int src_y, | |||
1016 | /* adjust for viewport */ | 1016 | /* adjust for viewport */ |
1017 | x += lcd_current_viewport->x; | 1017 | x += lcd_current_viewport->x; |
1018 | y += lcd_current_viewport->y; | 1018 | y += lcd_current_viewport->y; |
1019 | 1019 | ||
1020 | #if defined(HAVE_VIEWPORT_CLIP) | 1020 | #if defined(HAVE_VIEWPORT_CLIP) |
1021 | /********************* Viewport on screen clipping ********************/ | 1021 | /********************* Viewport on screen clipping ********************/ |
1022 | /* nothing to draw? */ | 1022 | /* nothing to draw? */ |
1023 | if ((x >= LCD_WIDTH) || (y >= LCD_HEIGHT) | 1023 | if ((x >= LCD_WIDTH) || (y >= LCD_HEIGHT) |
1024 | || (x + width <= 0) || (y + height <= 0)) | 1024 | || (x + width <= 0) || (y + height <= 0)) |
1025 | return; | 1025 | return; |
1026 | 1026 | ||
1027 | /* clip image in viewport in screen */ | 1027 | /* clip image in viewport in screen */ |
1028 | if (x < 0) | 1028 | if (x < 0) |
1029 | { | 1029 | { |
@@ -1052,7 +1052,7 @@ void ICODE_ATTR lcd_bitmap_part(const fb_data *src, int src_x, int src_y, | |||
1052 | 1052 | ||
1053 | mask = 0xFFu << (2 * (shift + src_y)); | 1053 | mask = 0xFFu << (2 * (shift + src_y)); |
1054 | mask_bottom = 0xFFu >> (2 * (~ny & 3)); | 1054 | mask_bottom = 0xFFu >> (2 * (~ny & 3)); |
1055 | 1055 | ||
1056 | if (shift == 0) | 1056 | if (shift == 0) |
1057 | { | 1057 | { |
1058 | for (; ny >= 4; ny -= 4) | 1058 | for (; ny >= 4; ny -= 4) |
@@ -1063,9 +1063,9 @@ void ICODE_ATTR lcd_bitmap_part(const fb_data *src, int src_x, int src_y, | |||
1063 | { | 1063 | { |
1064 | const fb_data *src_row = src; | 1064 | const fb_data *src_row = src; |
1065 | fb_data *dst_row = dst; | 1065 | fb_data *dst_row = dst; |
1066 | 1066 | ||
1067 | dst_end = dst_row + width; | 1067 | dst_end = dst_row + width; |
1068 | do | 1068 | do |
1069 | setblock(dst_row++, mask, *src_row++); | 1069 | setblock(dst_row++, mask, *src_row++); |
1070 | while (dst_row < dst_end); | 1070 | while (dst_row < dst_end); |
1071 | } | 1071 | } |
@@ -1095,7 +1095,7 @@ void ICODE_ATTR lcd_bitmap_part(const fb_data *src, int src_x, int src_y, | |||
1095 | fb_data *dst_col = dst++; | 1095 | fb_data *dst_col = dst++; |
1096 | unsigned mask_col = mask; | 1096 | unsigned mask_col = mask; |
1097 | unsigned data = 0; | 1097 | unsigned data = 0; |
1098 | 1098 | ||
1099 | for (y = ny; y >= 4; y -= 4) | 1099 | for (y = ny; y >= 4; y -= 4) |
1100 | { | 1100 | { |
1101 | data |= *src_col << shift; | 1101 | data |= *src_col << shift; |
diff --git a/firmware/drivers/lcd-2bit-vi.c b/firmware/drivers/lcd-2bit-vi.c index 035e8b6d0d..c09bbce2e0 100644 --- a/firmware/drivers/lcd-2bit-vi.c +++ b/firmware/drivers/lcd-2bit-vi.c | |||
@@ -437,7 +437,7 @@ void LCDFN(clear_viewport)(void) | |||
437 | lastmode = CURRENT_VP->drawmode; | 437 | lastmode = CURRENT_VP->drawmode; |
438 | 438 | ||
439 | /* Invert the INVERSEVID bit and set basic mode to SOLID */ | 439 | /* Invert the INVERSEVID bit and set basic mode to SOLID */ |
440 | CURRENT_VP->drawmode = (~lastmode & DRMODE_INVERSEVID) | | 440 | CURRENT_VP->drawmode = (~lastmode & DRMODE_INVERSEVID) | |
441 | DRMODE_SOLID; | 441 | DRMODE_SOLID; |
442 | 442 | ||
443 | LCDFN(fillrect)(0, 0, CURRENT_VP->width, CURRENT_VP->height); | 443 | LCDFN(fillrect)(0, 0, CURRENT_VP->width, CURRENT_VP->height); |
@@ -452,7 +452,7 @@ void LCDFN(clear_viewport)(void) | |||
452 | /* Set a single pixel */ | 452 | /* Set a single pixel */ |
453 | void LCDFN(drawpixel)(int x, int y) | 453 | void LCDFN(drawpixel)(int x, int y) |
454 | { | 454 | { |
455 | if ( ((unsigned)x < (unsigned)CURRENT_VP->width) | 455 | if ( ((unsigned)x < (unsigned)CURRENT_VP->width) |
456 | && ((unsigned)y < (unsigned)CURRENT_VP->height) | 456 | && ((unsigned)y < (unsigned)CURRENT_VP->height) |
457 | #if defined(HAVE_VIEWPORT_CLIP) | 457 | #if defined(HAVE_VIEWPORT_CLIP) |
458 | && ((unsigned)x < (unsigned)LCDM(WIDTH)) | 458 | && ((unsigned)x < (unsigned)LCDM(WIDTH)) |
@@ -527,7 +527,7 @@ void LCDFN(drawline)(int x1, int y1, int x2, int y2) | |||
527 | 527 | ||
528 | for (i = 0; i < numpixels; i++) | 528 | for (i = 0; i < numpixels; i++) |
529 | { | 529 | { |
530 | if ( ((unsigned)x < (unsigned)CURRENT_VP->width) | 530 | if ( ((unsigned)x < (unsigned)CURRENT_VP->width) |
531 | && ((unsigned)y < (unsigned)CURRENT_VP->height) | 531 | && ((unsigned)y < (unsigned)CURRENT_VP->height) |
532 | #if defined(HAVE_VIEWPORT_CLIP) | 532 | #if defined(HAVE_VIEWPORT_CLIP) |
533 | && ((unsigned)x < (unsigned)LCDM(WIDTH)) | 533 | && ((unsigned)x < (unsigned)LCDM(WIDTH)) |
@@ -567,13 +567,13 @@ void LCDFN(hline)(int x1, int x2, int y) | |||
567 | x1 = x2; | 567 | x1 = x2; |
568 | x2 = x; | 568 | x2 = x; |
569 | } | 569 | } |
570 | 570 | ||
571 | /******************** In viewport clipping **********************/ | 571 | /******************** In viewport clipping **********************/ |
572 | /* nothing to draw? */ | 572 | /* nothing to draw? */ |
573 | if (((unsigned)y >= (unsigned)CURRENT_VP->height) || (x1 >= CURRENT_VP->width) | 573 | if (((unsigned)y >= (unsigned)CURRENT_VP->height) || (x1 >= CURRENT_VP->width) |
574 | || (x2 < 0)) | 574 | || (x2 < 0)) |
575 | return; | 575 | return; |
576 | 576 | ||
577 | if (x1 < 0) | 577 | if (x1 < 0) |
578 | x1 = 0; | 578 | x1 = 0; |
579 | if (x2 >= CURRENT_VP->width) | 579 | if (x2 >= CURRENT_VP->width) |
@@ -589,8 +589,8 @@ void LCDFN(hline)(int x1, int x2, int y) | |||
589 | /* nothing to draw? */ | 589 | /* nothing to draw? */ |
590 | if (((unsigned)y >= (unsigned) LCDM(HEIGHT)) || (x1 >= LCDM(WIDTH)) | 590 | if (((unsigned)y >= (unsigned) LCDM(HEIGHT)) || (x1 >= LCDM(WIDTH)) |
591 | || (x2 < 0)) | 591 | || (x2 < 0)) |
592 | return; | 592 | return; |
593 | 593 | ||
594 | /* clipping */ | 594 | /* clipping */ |
595 | if (x1 < 0) | 595 | if (x1 < 0) |
596 | x1 = 0; | 596 | x1 = 0; |
@@ -642,14 +642,14 @@ void LCDFN(vline)(int x, int y1, int y2) | |||
642 | y1 += CURRENT_VP->y; | 642 | y1 += CURRENT_VP->y; |
643 | y2 += CURRENT_VP->y; | 643 | y2 += CURRENT_VP->y; |
644 | x += CURRENT_VP->x; | 644 | x += CURRENT_VP->x; |
645 | 645 | ||
646 | #if defined(HAVE_VIEWPORT_CLIP) | 646 | #if defined(HAVE_VIEWPORT_CLIP) |
647 | /********************* Viewport on screen clipping ********************/ | 647 | /********************* Viewport on screen clipping ********************/ |
648 | /* nothing to draw? */ | 648 | /* nothing to draw? */ |
649 | if (( (unsigned) x >= (unsigned)LCDM(WIDTH)) || (y1 >= LCDM(HEIGHT)) | 649 | if (( (unsigned) x >= (unsigned)LCDM(WIDTH)) || (y1 >= LCDM(HEIGHT)) |
650 | || (y2 < 0)) | 650 | || (y2 < 0)) |
651 | return; | 651 | return; |
652 | 652 | ||
653 | /* clipping */ | 653 | /* clipping */ |
654 | if (y1 < 0) | 654 | if (y1 < 0) |
655 | y1 = 0; | 655 | y1 = 0; |
@@ -707,7 +707,7 @@ void LCDFN(fillrect)(int x, int y, int width, int height) | |||
707 | if ((width <= 0) || (height <= 0) || (x >= CURRENT_VP->width) | 707 | if ((width <= 0) || (height <= 0) || (x >= CURRENT_VP->width) |
708 | || (y >= CURRENT_VP->height) || (x + width <= 0) || (y + height <= 0)) | 708 | || (y >= CURRENT_VP->height) || (x + width <= 0) || (y + height <= 0)) |
709 | return; | 709 | return; |
710 | 710 | ||
711 | if (x < 0) | 711 | if (x < 0) |
712 | { | 712 | { |
713 | width += x; | 713 | width += x; |
@@ -726,14 +726,14 @@ void LCDFN(fillrect)(int x, int y, int width, int height) | |||
726 | /* adjust for viewport */ | 726 | /* adjust for viewport */ |
727 | x += CURRENT_VP->x; | 727 | x += CURRENT_VP->x; |
728 | y += CURRENT_VP->y; | 728 | y += CURRENT_VP->y; |
729 | 729 | ||
730 | #if defined(HAVE_VIEWPORT_CLIP) | 730 | #if defined(HAVE_VIEWPORT_CLIP) |
731 | /********************* Viewport on screen clipping ********************/ | 731 | /********************* Viewport on screen clipping ********************/ |
732 | /* nothing to draw? */ | 732 | /* nothing to draw? */ |
733 | if ((x >= LCDM(WIDTH)) || (y >= LCDM(HEIGHT)) | 733 | if ((x >= LCDM(WIDTH)) || (y >= LCDM(HEIGHT)) |
734 | || (x + width <= 0) || (y + height <= 0)) | 734 | || (x + width <= 0) || (y + height <= 0)) |
735 | return; | 735 | return; |
736 | 736 | ||
737 | /* clip image in viewport in screen */ | 737 | /* clip image in viewport in screen */ |
738 | if (x < 0) | 738 | if (x < 0) |
739 | { | 739 | { |
@@ -855,14 +855,14 @@ void ICODE_ATTR LCDFN(mono_bitmap_part)(const unsigned char *src, int src_x, | |||
855 | /* adjust for viewport */ | 855 | /* adjust for viewport */ |
856 | x += CURRENT_VP->x; | 856 | x += CURRENT_VP->x; |
857 | y += CURRENT_VP->y; | 857 | y += CURRENT_VP->y; |
858 | 858 | ||
859 | #if defined(HAVE_VIEWPORT_CLIP) | 859 | #if defined(HAVE_VIEWPORT_CLIP) |
860 | /********************* Viewport on screen clipping ********************/ | 860 | /********************* Viewport on screen clipping ********************/ |
861 | /* nothing to draw? */ | 861 | /* nothing to draw? */ |
862 | if ((x >= LCDM(WIDTH)) || (y >= LCDM(HEIGHT)) | 862 | if ((x >= LCDM(WIDTH)) || (y >= LCDM(HEIGHT)) |
863 | || (x + width <= 0) || (y + height <= 0)) | 863 | || (x + width <= 0) || (y + height <= 0)) |
864 | return; | 864 | return; |
865 | 865 | ||
866 | /* clip image in viewport in screen */ | 866 | /* clip image in viewport in screen */ |
867 | if (x < 0) | 867 | if (x < 0) |
868 | { | 868 | { |
@@ -1029,10 +1029,10 @@ void ICODE_ATTR LCDFN(bitmap_part)(const FBFN(data) *src, int src_x, | |||
1029 | #if defined(HAVE_VIEWPORT_CLIP) | 1029 | #if defined(HAVE_VIEWPORT_CLIP) |
1030 | /********************* Viewport on screen clipping ********************/ | 1030 | /********************* Viewport on screen clipping ********************/ |
1031 | /* nothing to draw? */ | 1031 | /* nothing to draw? */ |
1032 | if ((x >= LCDM(WIDTH)) || (y >= LCDM(HEIGHT)) | 1032 | if ((x >= LCDM(WIDTH)) || (y >= LCDM(HEIGHT)) |
1033 | || (x + width <= 0) || (y + height <= 0)) | 1033 | || (x + width <= 0) || (y + height <= 0)) |
1034 | return; | 1034 | return; |
1035 | 1035 | ||
1036 | /* clip image in viewport in screen */ | 1036 | /* clip image in viewport in screen */ |
1037 | if (x < 0) | 1037 | if (x < 0) |
1038 | { | 1038 | { |
diff --git a/firmware/drivers/lcd-bitmap-common.c b/firmware/drivers/lcd-bitmap-common.c index 94829b5d0c..9cd3ba3774 100644 --- a/firmware/drivers/lcd-bitmap-common.c +++ b/firmware/drivers/lcd-bitmap-common.c | |||
@@ -613,7 +613,7 @@ void LCDFN(nine_segment_bmp)(const struct bitmap* bm, int x, int y, | |||
613 | LCDFN(bmp_part)(bm, src_x, src_y_top, dst_x, dst_y_top, w, seg_h); | 613 | LCDFN(bmp_part)(bm, src_x, src_y_top, dst_x, dst_y_top, w, seg_h); |
614 | LCDFN(bmp_part)(bm, src_x, src_y_btm, dst_x, dst_y_btm, w, seg_h); | 614 | LCDFN(bmp_part)(bm, src_x, src_y_btm, dst_x, dst_y_btm, w, seg_h); |
615 | } | 615 | } |
616 | 616 | ||
617 | /* left & right in a single loop */ | 617 | /* left & right in a single loop */ |
618 | src_y = corner_h; | 618 | src_y = corner_h; |
619 | dst_y = corner_h; | 619 | dst_y = corner_h; |
diff --git a/firmware/drivers/lcd-color-common.c b/firmware/drivers/lcd-color-common.c index 60e95a25ca..3abc671770 100644 --- a/firmware/drivers/lcd-color-common.c +++ b/firmware/drivers/lcd-color-common.c | |||
@@ -586,7 +586,7 @@ void lcd_gradient_fillrect_part(int x, int y, int width, int height, | |||
586 | int x1, x2; | 586 | int x1, x2; |
587 | x1 = x; | 587 | x1 = x; |
588 | x2 = x + width; | 588 | x2 = x + width; |
589 | 589 | ||
590 | if (height == 0) return; | 590 | if (height == 0) return; |
591 | 591 | ||
592 | step_mul = (1 << 16) / src_height; | 592 | step_mul = (1 << 16) / src_height; |