Daniel Stenberg | d20e6ee | 2002-03-26 10:06:28 +0000 | [diff] [blame] | 1 | /*************************************************************************** |
| 2 | * __________ __ ___. |
| 3 | * Open \______ \ ____ ____ | | _\_ |__ _______ ___ |
| 4 | * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / |
| 5 | * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < |
| 6 | * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ |
| 7 | * \/ \/ \/ \/ \/ |
| 8 | * $Id$ |
| 9 | * |
| 10 | * Copyright (C) 2002 by Daniel Stenberg <daniel@haxx.se> |
| 11 | * |
| 12 | * All files in this archive are subject to the GNU General Public License. |
| 13 | * See the file COPYING in the source tree root for full license agreement. |
| 14 | * |
| 15 | * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY |
| 16 | * KIND, either express or implied. |
| 17 | * |
| 18 | ****************************************************************************/ |
| 19 | |
Daniel Stenberg | 319d1f3 | 2002-03-26 10:59:39 +0000 | [diff] [blame] | 20 | #include <stdio.h> |
| 21 | #include <string.h> |
| 22 | #include <stdarg.h> |
| 23 | #include <stdlib.h> |
| 24 | #include <ctype.h> |
| 25 | #include <sys/types.h> |
| 26 | #include <sys/stat.h> |
| 27 | #include <fcntl.h> |
| 28 | |
| 29 | #include <errno.h> |
| 30 | #include <ctype.h> |
| 31 | #include <time.h> |
| 32 | |
| 33 | #include "screenhack.h" |
| 34 | |
Daniel Stenberg | d20e6ee | 2002-03-26 10:06:28 +0000 | [diff] [blame] | 35 | /* |
Daniel Stenberg | 319d1f3 | 2002-03-26 10:59:39 +0000 | [diff] [blame] | 36 | * Specific implementations for X11, using the generic LCD API and data. |
Daniel Stenberg | d20e6ee | 2002-03-26 10:06:28 +0000 | [diff] [blame] | 37 | */ |
| 38 | |
Daniel Stenberg | a1fd255 | 2002-03-26 14:27:03 +0000 | [diff] [blame] | 39 | #include "lcd-x11.h" |
Daniel Stenberg | 319d1f3 | 2002-03-26 10:59:39 +0000 | [diff] [blame] | 40 | |
Markus Braun | de8fbf0 | 2002-08-07 10:35:26 +0000 | [diff] [blame] | 41 | extern unsigned char lcd_framebuffer[LCD_WIDTH][LCD_HEIGHT/8]; |
Björn Stenberg | f9429cc | 2002-04-19 12:55:12 +0000 | [diff] [blame] | 42 | extern void screen_resized(int width, int height); |
| 43 | extern Display *dpy; |
Daniel Stenberg | 319d1f3 | 2002-03-26 10:59:39 +0000 | [diff] [blame] | 44 | |
Markus Braun | de8fbf0 | 2002-08-07 10:35:26 +0000 | [diff] [blame] | 45 | unsigned char lcd_framebuffer_copy[LCD_WIDTH][LCD_HEIGHT/8]; |
Daniel Stenberg | c154351 | 2002-04-27 23:41:41 +0000 | [diff] [blame] | 46 | |
Daniel Stenberg | ed6c7e4 | 2002-06-14 11:00:13 +0000 | [diff] [blame] | 47 | /* this is in uibasic.c */ |
| 48 | extern void drawdots(int color, XPoint *points, int count); |
| 49 | |
Daniel Stenberg | 319d1f3 | 2002-03-26 10:59:39 +0000 | [diff] [blame] | 50 | void lcd_update (void) |
| 51 | { |
Björn Stenberg | f9429cc | 2002-04-19 12:55:12 +0000 | [diff] [blame] | 52 | int x, y; |
| 53 | int p=0; |
| 54 | int bit; |
| 55 | XPoint points[LCD_WIDTH * LCD_HEIGHT]; |
Daniel Stenberg | c154351 | 2002-04-27 23:41:41 +0000 | [diff] [blame] | 56 | int cp=0; |
| 57 | XPoint clearpoints[LCD_WIDTH * LCD_HEIGHT]; |
Daniel Stenberg | 319d1f3 | 2002-03-26 10:59:39 +0000 | [diff] [blame] | 58 | |
Daniel Stenberg | c154351 | 2002-04-27 23:41:41 +0000 | [diff] [blame] | 59 | #if 0 |
Björn Stenberg | f9429cc | 2002-04-19 12:55:12 +0000 | [diff] [blame] | 60 | screen_resized(LCD_WIDTH, LCD_HEIGHT); |
| 61 | |
| 62 | for(y=0; y<LCD_HEIGHT; y+=8) { |
| 63 | for(x=0; x<LCD_WIDTH; x++) { |
Markus Braun | de8fbf0 | 2002-08-07 10:35:26 +0000 | [diff] [blame] | 64 | if(lcd_framebuffer[x][y/8]) { |
Björn Stenberg | f9429cc | 2002-04-19 12:55:12 +0000 | [diff] [blame] | 65 | /* one or more bits/pixels are set */ |
| 66 | for(bit=0; bit<8; bit++) { |
Markus Braun | de8fbf0 | 2002-08-07 10:35:26 +0000 | [diff] [blame] | 67 | if(lcd_framebuffer[x][y/8]&(1<<bit)) { |
Björn Stenberg | f9429cc | 2002-04-19 12:55:12 +0000 | [diff] [blame] | 68 | points[p].x = x + MARGIN_X; |
| 69 | points[p].y = y+bit + MARGIN_Y; |
| 70 | p++; /* increase the point counter */ |
| 71 | } |
| 72 | } |
| 73 | } |
Daniel Stenberg | 319d1f3 | 2002-03-26 10:59:39 +0000 | [diff] [blame] | 74 | } |
Daniel Stenberg | 319d1f3 | 2002-03-26 10:59:39 +0000 | [diff] [blame] | 75 | } |
Daniel Stenberg | c154351 | 2002-04-27 23:41:41 +0000 | [diff] [blame] | 76 | #else |
| 77 | for(y=0; y<LCD_HEIGHT; y+=8) { |
| 78 | for(x=0; x<LCD_WIDTH; x++) { |
Markus Braun | de8fbf0 | 2002-08-07 10:35:26 +0000 | [diff] [blame] | 79 | if(lcd_framebuffer[x][y/8] || lcd_framebuffer_copy[x][y/8]) { |
Daniel Stenberg | c154351 | 2002-04-27 23:41:41 +0000 | [diff] [blame] | 80 | /* one or more bits/pixels are changed */ |
| 81 | unsigned char diff = |
Markus Braun | de8fbf0 | 2002-08-07 10:35:26 +0000 | [diff] [blame] | 82 | lcd_framebuffer[x][y/8] ^ lcd_framebuffer_copy[x][y/8]; |
Daniel Stenberg | c154351 | 2002-04-27 23:41:41 +0000 | [diff] [blame] | 83 | |
| 84 | for(bit=0; bit<8; bit++) { |
Markus Braun | de8fbf0 | 2002-08-07 10:35:26 +0000 | [diff] [blame] | 85 | if(lcd_framebuffer[x][y/8]&(1<<bit)) { |
Daniel Stenberg | c154351 | 2002-04-27 23:41:41 +0000 | [diff] [blame] | 86 | /* set a dot */ |
| 87 | points[p].x = x + MARGIN_X; |
| 88 | points[p].y = y+bit + MARGIN_Y; |
| 89 | p++; /* increase the point counter */ |
| 90 | } |
| 91 | else if(diff &(1<<bit)) { |
| 92 | /* clear a dot */ |
| 93 | clearpoints[cp].x = x + MARGIN_X; |
| 94 | clearpoints[cp].y = y+bit + MARGIN_Y; |
| 95 | cp++; /* increase the point counter */ |
| 96 | } |
| 97 | } |
| 98 | } |
| 99 | } |
| 100 | } |
| 101 | |
| 102 | /* copy a huge block */ |
Markus Braun | de8fbf0 | 2002-08-07 10:35:26 +0000 | [diff] [blame] | 103 | memcpy(lcd_framebuffer_copy, lcd_framebuffer, sizeof(lcd_framebuffer)); |
Daniel Stenberg | c154351 | 2002-04-27 23:41:41 +0000 | [diff] [blame] | 104 | |
| 105 | #endif |
| 106 | |
Daniel Stenberg | c154351 | 2002-04-27 23:41:41 +0000 | [diff] [blame] | 107 | drawdots(0, &clearpoints[0], cp); |
Daniel Stenberg | 5ab87aa | 2002-04-30 13:29:08 +0000 | [diff] [blame] | 108 | drawdots(1, &points[0], p); |
Robert Hak | 38cb040 | 2002-05-03 06:54:41 +0000 | [diff] [blame] | 109 | /* Logf("lcd_update: Draws %d pixels, clears %d pixels", p, cp);*/ |
Björn Stenberg | f9429cc | 2002-04-19 12:55:12 +0000 | [diff] [blame] | 110 | XSync(dpy,False); |
Daniel Stenberg | 319d1f3 | 2002-03-26 10:59:39 +0000 | [diff] [blame] | 111 | } |