summaryrefslogtreecommitdiff
path: root/uisimulator/x11/lcd-x11.c
diff options
context:
space:
mode:
Diffstat (limited to 'uisimulator/x11/lcd-x11.c')
-rw-r--r--uisimulator/x11/lcd-x11.c109
1 files changed, 109 insertions, 0 deletions
diff --git a/uisimulator/x11/lcd-x11.c b/uisimulator/x11/lcd-x11.c
new file mode 100644
index 0000000000..9659426f02
--- /dev/null
+++ b/uisimulator/x11/lcd-x11.c
@@ -0,0 +1,109 @@
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
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
35/*
36 * Specific implementations for X11, using the generic LCD API and data.
37 */
38
39#include "lcd-x11.h"
40
41extern unsigned char display[LCD_WIDTH][LCD_HEIGHT/8];
42extern void screen_resized(int width, int height);
43extern Display *dpy;
44
45unsigned char display_copy[LCD_WIDTH][LCD_HEIGHT/8];
46
47void lcd_update (void)
48{
49 int x, y;
50 int p=0;
51 int bit;
52 XPoint points[LCD_WIDTH * LCD_HEIGHT];
53 int cp=0;
54 XPoint clearpoints[LCD_WIDTH * LCD_HEIGHT];
55
56#if 0
57 screen_resized(LCD_WIDTH, LCD_HEIGHT);
58
59 for(y=0; y<LCD_HEIGHT; y+=8) {
60 for(x=0; x<LCD_WIDTH; x++) {
61 if(display[x][y/8]) {
62 /* one or more bits/pixels are set */
63 for(bit=0; bit<8; bit++) {
64 if(display[x][y/8]&(1<<bit)) {
65 points[p].x = x + MARGIN_X;
66 points[p].y = y+bit + MARGIN_Y;
67 p++; /* increase the point counter */
68 }
69 }
70 }
71 }
72 }
73#else
74 for(y=0; y<LCD_HEIGHT; y+=8) {
75 for(x=0; x<LCD_WIDTH; x++) {
76 if(display[x][y/8] || display_copy[x][y/8]) {
77 /* one or more bits/pixels are changed */
78 unsigned char diff =
79 display[x][y/8] ^ display_copy[x][y/8];
80
81 for(bit=0; bit<8; bit++) {
82 if(display[x][y/8]&(1<<bit)) {
83 /* set a dot */
84 points[p].x = x + MARGIN_X;
85 points[p].y = y+bit + MARGIN_Y;
86 p++; /* increase the point counter */
87 }
88 else if(diff &(1<<bit)) {
89 /* clear a dot */
90 clearpoints[cp].x = x + MARGIN_X;
91 clearpoints[cp].y = y+bit + MARGIN_Y;
92 cp++; /* increase the point counter */
93 }
94 }
95 }
96 }
97 }
98
99 /* copy a huge block */
100 memcpy(display_copy, display, sizeof(display));
101
102#endif
103
104
105 drawdots(1, &points[0], p);
106 drawdots(0, &clearpoints[0], cp);
107 fprintf(stderr, "lcd_update: Draws %d pixels, clears %d pixels\n", p, cp);
108 XSync(dpy,False);
109}