summaryrefslogtreecommitdiff
path: root/apps/misc.c
diff options
context:
space:
mode:
Diffstat (limited to 'apps/misc.c')
-rw-r--r--apps/misc.c84
1 files changed, 50 insertions, 34 deletions
diff --git a/apps/misc.c b/apps/misc.c
index d1b5c2274f..1c19c155d2 100644
--- a/apps/misc.c
+++ b/apps/misc.c
@@ -274,6 +274,8 @@ static const unsigned char bmpheader[] =
274#endif 274#endif
275}; 275};
276 276
277static void (*screen_dump_hook)(int fh) = NULL;
278
277void screen_dump(void) 279void screen_dump(void)
278{ 280{
279 int fh; 281 int fh;
@@ -298,56 +300,70 @@ void screen_dump(void)
298 if (fh < 0) 300 if (fh < 0)
299 return; 301 return;
300 302
301 write(fh, bmpheader, sizeof(bmpheader)); 303 if (screen_dump_hook)
302
303 /* BMP image goes bottom up */
304#if LCD_DEPTH == 1
305 for (by = LCD_HEIGHT/8 - 1; by >= 0; by--)
306 { 304 {
307 memset(&line_block[0][0], 0, sizeof(line_block)); 305 screen_dump_hook(fh);
306 }
307 else
308 {
309 write(fh, bmpheader, sizeof(bmpheader));
308 310
309 for (bx = 0; bx < LCD_WIDTH/8; bx++) 311 /* BMP image goes bottom up */
312#if LCD_DEPTH == 1
313 for (by = LCD_HEIGHT/8 - 1; by >= 0; by--)
310 { 314 {
311 dst_mask = 0x01; 315 memset(&line_block[0][0], 0, sizeof(line_block));
312 for (ix = 7; ix >= 0; ix--) 316
317 for (bx = 0; bx < LCD_WIDTH/8; bx++)
313 { 318 {
314 src_byte = lcd_framebuffer[by][8*bx+ix]; 319 dst_mask = 0x01;
315 src_mask = 0x01; 320 for (ix = 7; ix >= 0; ix--)
316 for (iy = 7; iy >= 0; iy--)
317 { 321 {
318 if (src_byte & src_mask) 322 src_byte = lcd_framebuffer[by][8*bx+ix];
319 line_block[iy][bx] |= dst_mask; 323 src_mask = 0x01;
320 src_mask <<= 1; 324 for (iy = 7; iy >= 0; iy--)
325 {
326 if (src_byte & src_mask)
327 line_block[iy][bx] |= dst_mask;
328 src_mask <<= 1;
329 }
330 dst_mask <<= 1;
321 } 331 }
322 dst_mask <<= 1;
323 } 332 }
333
334 write(fh, &line_block[0][0], sizeof(line_block));
324 } 335 }
325
326 write(fh, &line_block[0][0], sizeof(line_block));
327 }
328#elif LCD_DEPTH == 2 336#elif LCD_DEPTH == 2
329 for (by = LCD_HEIGHT/4 - 1; by >= 0; by--) 337 for (by = LCD_HEIGHT/4 - 1; by >= 0; by--)
330 {
331 memset(&line_block[0][0], 0, sizeof(line_block));
332
333 for (bx = 0; bx < LCD_WIDTH/2; bx++)
334 { 338 {
335 src_byte = lcd_framebuffer[by][2*bx]; 339 memset(&line_block[0][0], 0, sizeof(line_block));
336 src_byte2 = lcd_framebuffer[by][2*bx+1]; 340
337 for (iy = 3; iy >= 0; iy--) 341 for (bx = 0; bx < LCD_WIDTH/2; bx++)
338 { 342 {
339 line_block[iy][bx] = ((src_byte & 3) << 4) | (src_byte2 & 3); 343 src_byte = lcd_framebuffer[by][2*bx];
340 src_byte >>= 2; 344 src_byte2 = lcd_framebuffer[by][2*bx+1];
341 src_byte2 >>= 2; 345 for (iy = 3; iy >= 0; iy--)
346 {
347 line_block[iy][bx] = ((src_byte & 3) << 4) | (src_byte2 & 3);
348 src_byte >>= 2;
349 src_byte2 >>= 2;
350 }
342 } 351 }
343 }
344 352
345 write(fh, &line_block[0][0], sizeof(line_block)); 353 write(fh, &line_block[0][0], sizeof(line_block));
354 }
355#endif /* LCD_DEPTH */
346 } 356 }
347#endif 357
348 close(fh); 358 close(fh);
349} 359}
350#endif 360
361void screen_dump_set_hook(void (*hook)(int fh))
362{
363 screen_dump_hook = hook;
364}
365
366#endif /* HAVE_LCD_BITMAP */
351 367
352/* parse a line from a configuration file. the line format is: 368/* parse a line from a configuration file. the line format is:
353 369