diff options
Diffstat (limited to 'uisimulator/common')
-rw-r--r-- | uisimulator/common/lcd-common.c | 139 | ||||
-rw-r--r-- | uisimulator/common/lcd-common.h | 36 |
2 files changed, 5 insertions, 170 deletions
diff --git a/uisimulator/common/lcd-common.c b/uisimulator/common/lcd-common.c index d55cd0baa8..52a98eec58 100644 --- a/uisimulator/common/lcd-common.c +++ b/uisimulator/common/lcd-common.c | |||
@@ -22,141 +22,10 @@ | |||
22 | 22 | ||
23 | #include "lcd-common.h" | 23 | #include "lcd-common.h" |
24 | 24 | ||
25 | /*** Define our #includes ***/ | 25 | #include "lcd.h" |
26 | #ifdef WIN32 | ||
27 | #include <windows.h> | ||
28 | #include <process.h> | ||
29 | #include "uisw32.h" | ||
30 | #else | ||
31 | /* X11 */ | ||
32 | #include <stdio.h> | ||
33 | #include <string.h> | ||
34 | #include <stdarg.h> | ||
35 | #include <stdlib.h> | ||
36 | #include <ctype.h> | ||
37 | #include <sys/types.h> | ||
38 | #include <sys/stat.h> | ||
39 | #include <fcntl.h> | ||
40 | |||
41 | #include <errno.h> | ||
42 | #include <ctype.h> | ||
43 | #include <time.h> | ||
44 | |||
45 | #include "screenhack.h" | ||
46 | #endif | ||
47 | /**** End #includes ****/ | ||
48 | |||
49 | |||
50 | /*** Start global variables ***/ | ||
51 | #ifdef WIN32 | ||
52 | |||
53 | /* Simulate the target ui display */ | ||
54 | char bitmap[LCD_HEIGHT][LCD_WIDTH]; | ||
55 | |||
56 | BITMAPINFO2 bmi = | ||
57 | { | ||
58 | { sizeof (BITMAPINFOHEADER), | ||
59 | LCD_WIDTH, -LCD_HEIGHT, 1, 8, | ||
60 | BI_RGB, 0, 0, 0, 2, 2, }, | ||
61 | { | ||
62 | /* green background color */ | ||
63 | {UI_LCD_BGCOLOR, 0}, | ||
64 | /* black color */ | ||
65 | {UI_LCD_BLACK, 0} | ||
66 | } | ||
67 | |||
68 | }; | ||
69 | |||
70 | #else | ||
71 | extern Display *dpy; | ||
72 | unsigned char lcd_framebuffer_copy[LCD_WIDTH][LCD_HEIGHT/8]; | ||
73 | #endif | ||
74 | |||
75 | /* Both X11 and WIN32 use this */ | ||
76 | extern unsigned char lcd_framebuffer[LCD_WIDTH][LCD_HEIGHT/8]; | ||
77 | |||
78 | /*** End Global variables ***/ | ||
79 | |||
80 | 26 | ||
81 | /*** Externed functions ***/ | 27 | #ifdef WIN32 |
82 | #ifndef WIN32 | 28 | #include "lcd-win32.h" |
83 | extern void screen_resized(int width, int height); | ||
84 | |||
85 | /* From uibasic.c */ | ||
86 | extern void drawdots(int color, XPoint *points, int count); | ||
87 | #endif | ||
88 | |||
89 | /*** End Externed functions ***/ | ||
90 | |||
91 | |||
92 | |||
93 | /*** Begin Functions ***/ | ||
94 | void lcd_update() | ||
95 | { | ||
96 | #ifdef WIN32 | ||
97 | int x, y; | ||
98 | if(hGUIWnd == NULL) | ||
99 | _endthread (); | ||
100 | |||
101 | for(x = 0; x < LCD_WIDTH; x++) | ||
102 | for(y = 0; y < LCD_HEIGHT; y++) | ||
103 | bitmap[y][x] = ((lcd_framebuffer[x][y/8] >> (y & 7)) & 1); | ||
104 | |||
105 | InvalidateRect (hGUIWnd, NULL, FALSE); | ||
106 | |||
107 | Sleep (50); | ||
108 | #else | 29 | #else |
109 | int x, y, bit; | 30 | #include "lcd-x11.h" |
110 | int p=0, cp=0; | ||
111 | |||
112 | XPoint points[LCD_WIDTH * LCD_HEIGHT]; | ||
113 | XPoint clearpoints[LCD_WIDTH * LCD_HEIGHT]; | ||
114 | |||
115 | for(y=0; y<LCD_HEIGHT; y+=8) { | ||
116 | for(x=0; x<LCD_WIDTH; x++) { | ||
117 | if(lcd_framebuffer[x][y/8] || lcd_framebuffer_copy[x][y/8]) { | ||
118 | /* one or more bits/pixels are changed */ | ||
119 | unsigned char diff = | ||
120 | lcd_framebuffer[x][y/8] ^ lcd_framebuffer_copy[x][y/8]; | ||
121 | |||
122 | for(bit=0; bit<8; bit++) { | ||
123 | if(lcd_framebuffer[x][y/8]&(1<<bit)) { | ||
124 | /* set a dot */ | ||
125 | points[p].x = x + MARGIN_X; | ||
126 | points[p].y = y+bit + MARGIN_Y; | ||
127 | p++; | ||
128 | } | ||
129 | else if(diff &(1<<bit)) { | ||
130 | /* clear a dot */ | ||
131 | clearpoints[cp].x = x + MARGIN_X; | ||
132 | clearpoints[cp].y = y+bit + MARGIN_Y; | ||
133 | cp++; /* increase the point counter */ | ||
134 | } | ||
135 | } | ||
136 | } | ||
137 | } | ||
138 | } | ||
139 | |||
140 | /* copy a huge block */ | ||
141 | memcpy(lcd_framebuffer_copy, lcd_framebuffer, sizeof(lcd_framebuffer)); | ||
142 | |||
143 | drawdots(0, &clearpoints[0], cp); | ||
144 | drawdots(1, &points[0], p); | ||
145 | XSync(dpy,False); | ||
146 | |||
147 | #endif /* end WIN32*/ | ||
148 | } | ||
149 | |||
150 | #ifdef WIN32 | ||
151 | void lcd_backlight(bool on) | ||
152 | { | ||
153 | if(on) { | ||
154 | RGBQUAD blon = {UI_LCD_BGCOLORLIGHT, 0}; | ||
155 | bmi.bmiColors[0] = blon; | ||
156 | } else { | ||
157 | RGBQUAD blon = {UI_LCD_BGCOLOR, 0}; | ||
158 | bmi.bmiColors[0] = blon; | ||
159 | } | ||
160 | InvalidateRect (hGUIWnd, NULL, FALSE); | ||
161 | } | ||
162 | #endif | 31 | #endif |
diff --git a/uisimulator/common/lcd-common.h b/uisimulator/common/lcd-common.h index 08a5bbd3bb..8b78d8b85a 100644 --- a/uisimulator/common/lcd-common.h +++ b/uisimulator/common/lcd-common.h | |||
@@ -20,41 +20,7 @@ | |||
20 | * | 20 | * |
21 | ****************************************************************************/ | 21 | ****************************************************************************/ |
22 | 22 | ||
23 | #include "lcd.h" | 23 | |
24 | |||
25 | #ifdef WIN32 | ||
26 | #ifndef __LCDWIN32_H__ | ||
27 | #define __LCDWIN32_H__ | ||
28 | |||
29 | #include "uisw32.h" | ||
30 | #include "lcd.h" | ||
31 | |||
32 | typedef struct | ||
33 | { | ||
34 | BITMAPINFOHEADER bmiHeader; | ||
35 | RGBQUAD bmiColors[2]; | ||
36 | } BITMAPINFO2; | ||
37 | |||
38 | #ifdef HAVE_LCD_BITMAP | ||
39 | /* the display */ | ||
40 | extern unsigned char display[LCD_WIDTH][LCD_HEIGHT/8]; | ||
41 | #else | ||
42 | #define DISP_X 112 | ||
43 | #define DISP_Y 64 | ||
44 | #endif /* HAVE_LCD_BITMAP */ | ||
45 | |||
46 | /* the ui display */ | ||
47 | extern char bitmap[LCD_HEIGHT][LCD_WIDTH]; | ||
48 | /* bitmap information */ | ||
49 | extern BITMAPINFO2 bmi; | ||
50 | #endif /* __LCDWIN32_H__ */ | ||
51 | |||
52 | #else | ||
53 | /* X11 */ | ||
54 | #define MARGIN_X 3 | ||
55 | #define MARGIN_Y 3 | ||
56 | |||
57 | #endif /* WIN32 */ | ||
58 | 24 | ||
59 | 25 | ||
60 | 26 | ||