diff options
Diffstat (limited to 'uisimulator/common/lcd-playersim.c')
-rw-r--r-- | uisimulator/common/lcd-playersim.c | 315 |
1 files changed, 106 insertions, 209 deletions
diff --git a/uisimulator/common/lcd-playersim.c b/uisimulator/common/lcd-playersim.c index a804cc4b7e..7c9685c5db 100644 --- a/uisimulator/common/lcd-playersim.c +++ b/uisimulator/common/lcd-playersim.c | |||
@@ -29,74 +29,114 @@ | |||
29 | #include "system.h" | 29 | #include "system.h" |
30 | 30 | ||
31 | #include "font-player.h" | 31 | #include "font-player.h" |
32 | #include "lcd-playersim.h" | ||
32 | 33 | ||
33 | /*** definitions ***/ | 34 | /*** definitions ***/ |
34 | 35 | ||
35 | #define CHAR_WIDTH 6 | 36 | #define CHAR_WIDTH 6 |
36 | #define CHAR_HEIGHT 8 | 37 | #define CHAR_HEIGHT 8 |
37 | #define ICON_HEIGHT 10 | 38 | #define ICON_HEIGHT 24 |
39 | #define CHAR_PIXEL 4 | ||
40 | #define BORDER_MARGIN 1 | ||
38 | 41 | ||
39 | unsigned char lcd_framebuffer[LCD_WIDTH][LCD_HEIGHT/8]; | 42 | unsigned char lcd_buffer[2][11]; |
40 | 43 | ||
41 | static int double_height=1; | 44 | static int double_height=1; |
45 | extern bool lcd_display_redraw; | ||
46 | extern unsigned const char *lcd_ascii; | ||
47 | |||
42 | 48 | ||
43 | void lcd_print_icon(int x, int icon_line, bool enable, char **icon) | 49 | void lcd_print_icon(int x, int icon_line, bool enable, char **icon) |
44 | { | 50 | { |
45 | int xpos = x; | 51 | int xpos = x; |
46 | int ypos = icon_line*(ICON_HEIGHT+CHAR_HEIGHT*2); | 52 | int ypos = icon_line*(ICON_HEIGHT+CHAR_HEIGHT*2); |
47 | int row=0, col; | 53 | int row=0, col; |
54 | |||
55 | int p=0, cp=0; | ||
56 | struct coordinate points[LCD_WIDTH * LCD_HEIGHT]; | ||
57 | struct coordinate clearpoints[LCD_WIDTH * LCD_HEIGHT]; | ||
48 | 58 | ||
49 | while (icon[row]) { | 59 | while (icon[row]) { |
50 | col=0; | 60 | col=0; |
51 | while (icon[row][col]) { | 61 | while (icon[row][col]) { |
52 | lcd_framebuffer[xpos+col][(ypos+row)/8] &= ~(1<<((row+ypos)&7)); | 62 | switch(icon[row][col]) { |
53 | if (enable) { | 63 | case '*': |
54 | if (icon[row][col]=='*') { | 64 | if (enable) { |
55 | lcd_framebuffer[xpos+col][(ypos+row)/8] |= 1<<((row+ypos)&7); | 65 | /* set a dot */ |
56 | } | 66 | points[p].x = xpos + col +BORDER_MARGIN; |
67 | points[p].y = ypos+row +BORDER_MARGIN; | ||
68 | p++; /* increase the point counter */ | ||
69 | } else { | ||
70 | /* clear a dot */ | ||
71 | clearpoints[cp].x = xpos + col +BORDER_MARGIN; | ||
72 | clearpoints[cp].y = ypos+row +BORDER_MARGIN; | ||
73 | cp++; /* increase the point counter */ | ||
74 | } | ||
75 | break; | ||
76 | case ' ': /* Clear bit */ | ||
77 | /* clear a dot */ | ||
78 | clearpoints[cp].x = xpos + col+BORDER_MARGIN; | ||
79 | clearpoints[cp].y = ypos+row+BORDER_MARGIN; | ||
80 | cp++; /* increase the point counter */ | ||
81 | break; | ||
57 | } | 82 | } |
58 | col++; | 83 | col++; |
59 | } | 84 | } |
60 | row++; | 85 | row++; |
61 | } | 86 | } |
62 | lcd_update(); | 87 | drawdots(0, &clearpoints[0], cp); |
88 | drawdots(1, &points[0], p); | ||
63 | } | 89 | } |
64 | 90 | ||
65 | void lcd_print_char(int x, int y, unsigned char ch) | 91 | void lcd_print_char(int x, int y) |
66 | { | 92 | { |
67 | int xpos = x * CHAR_WIDTH; | 93 | int xpos = x * CHAR_WIDTH * CHAR_PIXEL; |
68 | int ypos = y * CHAR_HEIGHT; | 94 | int ypos = y * CHAR_HEIGHT * CHAR_PIXEL + ICON_HEIGHT; |
69 | int col, row; | 95 | int col, row; |
70 | int y2; | 96 | int p=0, cp=0; |
71 | // double_height=2; | 97 | struct rectangle points[CHAR_HEIGHT*CHAR_WIDTH]; |
98 | struct rectangle clearpoints[CHAR_HEIGHT*CHAR_WIDTH]; | ||
99 | unsigned char ch=lcd_buffer[y][x]; | ||
100 | |||
72 | if (double_height == 2 && y == 1) | 101 | if (double_height == 2 && y == 1) |
73 | return; /* Second row can't be printed in double height. ??*/ | 102 | return; /* Second row can't be printed in double height. ??*/ |
74 | 103 | ||
75 | xpos*=2; | 104 | /* Clear all char |
76 | 105 | clearpoints[cp].x = xpos +BORDER_MARGIN; | |
77 | /* printf("(%d,%d)='%d'\n", x, y, ch);*/ | 106 | clearpoints[cp].y = ypos +BORDER_MARGIN; |
107 | clearpoints[cp].width=CHAR_WIDTH*CHAR_PIXEL; | ||
108 | clearpoints[cp].height=7*CHAR_PIXEL*double_height; | ||
109 | cp++; | ||
110 | */ | ||
78 | for (col=0; col<5; col++) { | 111 | for (col=0; col<5; col++) { |
79 | for (row=0; row<7; row++) { | 112 | for (row=0; row<7; row++) { |
80 | for (y2=0; y2<double_height*2; y2++) { | 113 | char fontbit=(*font_player)[ch][col]&(1<<row); |
81 | int y; | 114 | int height=CHAR_PIXEL*double_height; |
82 | unsigned char bitval; | ||
83 | 115 | ||
84 | if (double_height*row >=7) | 116 | y=CHAR_PIXEL*(double_height*row)+ypos; |
85 | y2+=double_height; | 117 | if (double_height==2) { |
86 | y=y2+double_height*2*row+2*ypos+ICON_HEIGHT; | 118 | if (row == 3) /* Adjust for blank row in the middle */ |
119 | height=CHAR_PIXEL; | ||
120 | } | ||
87 | 121 | ||
88 | bitval=3<<((y&6)); | 122 | if (fontbit) { |
89 | if (font_player[ch][col]&(1<<row)) { | 123 | /* set a dot */ |
90 | lcd_framebuffer[xpos+col*2][y/8] |= bitval; | 124 | points[p].x = xpos + col*CHAR_PIXEL +BORDER_MARGIN; |
91 | 125 | points[p].y = y +BORDER_MARGIN; | |
92 | } else { | 126 | points[p].width=CHAR_PIXEL; |
93 | lcd_framebuffer[xpos+col*2][y/8] &= ~bitval; | 127 | points[p].height=height; |
94 | } | 128 | p++; /* increase the point counter */ |
95 | lcd_framebuffer[xpos+col*2+1][y/8] = | 129 | } else { |
96 | lcd_framebuffer[xpos+col*2][y/8]; | 130 | clearpoints[cp].x = xpos + col*CHAR_PIXEL +BORDER_MARGIN; |
131 | clearpoints[cp].y = y +BORDER_MARGIN; | ||
132 | clearpoints[cp].width=CHAR_PIXEL; | ||
133 | clearpoints[cp].height=height; | ||
134 | cp++; | ||
97 | } | 135 | } |
98 | } | 136 | } |
99 | } | 137 | } |
138 | drawrectangles(0, &clearpoints[0], cp); | ||
139 | drawrectangles(1, &points[0], p); | ||
100 | } | 140 | } |
101 | 141 | ||
102 | 142 | ||
@@ -106,189 +146,35 @@ void lcd_print_char(int x, int y, unsigned char ch) | |||
106 | */ | 146 | */ |
107 | void lcd_drawrect (int x, int y, int nx, int ny) | 147 | void lcd_drawrect (int x, int y, int nx, int ny) |
108 | { | 148 | { |
109 | int i; | 149 | (void)x; |
110 | 150 | (void)y; | |
111 | if (x > LCD_WIDTH) | 151 | (void)nx; |
112 | return; | 152 | (void)ny; |
113 | if (y > LCD_HEIGHT) | ||
114 | return; | ||
115 | |||
116 | if (x + nx > LCD_WIDTH) | ||
117 | nx = LCD_WIDTH - x; | ||
118 | if (y + ny > LCD_HEIGHT) | ||
119 | ny = LCD_HEIGHT - y; | ||
120 | |||
121 | /* vertical lines */ | ||
122 | for (i = 0; i < ny; i++) { | ||
123 | DRAW_PIXEL(x, (y + i)); | ||
124 | DRAW_PIXEL((x + nx - 1), (y + i)); | ||
125 | } | ||
126 | |||
127 | /* horizontal lines */ | ||
128 | for (i = 0; i < nx; i++) { | ||
129 | DRAW_PIXEL((x + i),y); | ||
130 | DRAW_PIXEL((x + i),(y + ny - 1)); | ||
131 | } | ||
132 | } | 153 | } |
133 | 154 | ||
134 | /* Invert a rectangular area at (x, y), size (nx, ny) */ | 155 | /* Invert a rectangular area at (x, y), size (nx, ny) */ |
135 | void lcd_invertrect (int x, int y, int nx, int ny) | 156 | void lcd_invertrect (int x, int y, int nx, int ny) |
136 | { | 157 | { |
137 | int i, j; | 158 | (void)x; |
138 | 159 | (void)y; | |
139 | if (x > LCD_WIDTH) | 160 | (void)nx; |
140 | return; | 161 | (void)ny; |
141 | if (y > LCD_HEIGHT) | ||
142 | return; | ||
143 | |||
144 | if (x + nx > LCD_WIDTH) | ||
145 | nx = LCD_WIDTH - x; | ||
146 | if (y + ny > LCD_HEIGHT) | ||
147 | ny = LCD_HEIGHT - y; | ||
148 | |||
149 | for (i = 0; i < nx; i++) | ||
150 | for (j = 0; j < ny; j++) | ||
151 | INVERT_PIXEL((x + i), (y + j)); | ||
152 | } | 162 | } |
153 | 163 | ||
154 | void lcd_drawline( int x1, int y1, int x2, int y2 ) | 164 | void lcd_drawline( int x1, int y1, int x2, int y2 ) |
155 | { | 165 | { |
156 | int numpixels; | 166 | (void)x1; |
157 | int i; | 167 | (void)x2; |
158 | int deltax, deltay; | 168 | (void)y1; |
159 | int d, dinc1, dinc2; | 169 | (void)y2; |
160 | int x, xinc1, xinc2; | ||
161 | int y, yinc1, yinc2; | ||
162 | |||
163 | deltax = abs(x2 - x1); | ||
164 | deltay = abs(y2 - y1); | ||
165 | |||
166 | if(deltax >= deltay) | ||
167 | { | ||
168 | numpixels = deltax; | ||
169 | d = 2 * deltay - deltax; | ||
170 | dinc1 = deltay * 2; | ||
171 | dinc2 = (deltay - deltax) * 2; | ||
172 | xinc1 = 1; | ||
173 | xinc2 = 1; | ||
174 | yinc1 = 0; | ||
175 | yinc2 = 1; | ||
176 | } | ||
177 | else | ||
178 | { | ||
179 | numpixels = deltay; | ||
180 | d = 2 * deltax - deltay; | ||
181 | dinc1 = deltax * 2; | ||
182 | dinc2 = (deltax - deltay) * 2; | ||
183 | xinc1 = 0; | ||
184 | xinc2 = 1; | ||
185 | yinc1 = 1; | ||
186 | yinc2 = 1; | ||
187 | } | ||
188 | numpixels++; /* include endpoints */ | ||
189 | |||
190 | if(x1 > x2) | ||
191 | { | ||
192 | xinc1 = -xinc1; | ||
193 | xinc2 = -xinc2; | ||
194 | } | ||
195 | |||
196 | if(y1 > y2) | ||
197 | { | ||
198 | yinc1 = -yinc1; | ||
199 | yinc2 = -yinc2; | ||
200 | } | ||
201 | |||
202 | x = x1; | ||
203 | y = y1; | ||
204 | |||
205 | for(i=0; i<numpixels; i++) | ||
206 | { | ||
207 | DRAW_PIXEL(x,y); | ||
208 | |||
209 | if(d < 0) | ||
210 | { | ||
211 | d += dinc1; | ||
212 | x += xinc1; | ||
213 | y += yinc1; | ||
214 | } | ||
215 | else | ||
216 | { | ||
217 | d += dinc2; | ||
218 | x += xinc2; | ||
219 | y += yinc2; | ||
220 | } | ||
221 | } | ||
222 | } | 170 | } |
223 | 171 | ||
224 | void lcd_clearline( int x1, int y1, int x2, int y2 ) | 172 | void lcd_clearline( int x1, int y1, int x2, int y2 ) |
225 | { | 173 | { |
226 | int numpixels; | 174 | (void)x1; |
227 | int i; | 175 | (void)x2; |
228 | int deltax, deltay; | 176 | (void)y1; |
229 | int d, dinc1, dinc2; | 177 | (void)y2; |
230 | int x, xinc1, xinc2; | ||
231 | int y, yinc1, yinc2; | ||
232 | |||
233 | deltax = abs(x2 - x1); | ||
234 | deltay = abs(y2 - y1); | ||
235 | |||
236 | if(deltax >= deltay) | ||
237 | { | ||
238 | numpixels = deltax; | ||
239 | d = 2 * deltay - deltax; | ||
240 | dinc1 = deltay * 2; | ||
241 | dinc2 = (deltay - deltax) * 2; | ||
242 | xinc1 = 1; | ||
243 | xinc2 = 1; | ||
244 | yinc1 = 0; | ||
245 | yinc2 = 1; | ||
246 | } | ||
247 | else | ||
248 | { | ||
249 | numpixels = deltay; | ||
250 | d = 2 * deltax - deltay; | ||
251 | dinc1 = deltax * 2; | ||
252 | dinc2 = (deltax - deltay) * 2; | ||
253 | xinc1 = 0; | ||
254 | xinc2 = 1; | ||
255 | yinc1 = 1; | ||
256 | yinc2 = 1; | ||
257 | } | ||
258 | numpixels++; /* include endpoints */ | ||
259 | |||
260 | if(x1 > x2) | ||
261 | { | ||
262 | xinc1 = -xinc1; | ||
263 | xinc2 = -xinc2; | ||
264 | } | ||
265 | |||
266 | if(y1 > y2) | ||
267 | { | ||
268 | yinc1 = -yinc1; | ||
269 | yinc2 = -yinc2; | ||
270 | } | ||
271 | |||
272 | x = x1; | ||
273 | y = y1; | ||
274 | |||
275 | for(i=0; i<numpixels; i++) | ||
276 | { | ||
277 | CLEAR_PIXEL(x,y); | ||
278 | |||
279 | if(d < 0) | ||
280 | { | ||
281 | d += dinc1; | ||
282 | x += xinc1; | ||
283 | y += yinc1; | ||
284 | } | ||
285 | else | ||
286 | { | ||
287 | d += dinc2; | ||
288 | x += xinc2; | ||
289 | y += yinc2; | ||
290 | } | ||
291 | } | ||
292 | } | 178 | } |
293 | 179 | ||
294 | /* | 180 | /* |
@@ -296,7 +182,8 @@ void lcd_clearline( int x1, int y1, int x2, int y2 ) | |||
296 | */ | 182 | */ |
297 | void lcd_drawpixel(int x, int y) | 183 | void lcd_drawpixel(int x, int y) |
298 | { | 184 | { |
299 | DRAW_PIXEL(x,y); | 185 | (void)x; |
186 | (void)y; | ||
300 | } | 187 | } |
301 | 188 | ||
302 | /* | 189 | /* |
@@ -304,7 +191,8 @@ void lcd_drawpixel(int x, int y) | |||
304 | */ | 191 | */ |
305 | void lcd_clearpixel(int x, int y) | 192 | void lcd_clearpixel(int x, int y) |
306 | { | 193 | { |
307 | CLEAR_PIXEL(x,y); | 194 | (void)x; |
195 | (void)y; | ||
308 | } | 196 | } |
309 | 197 | ||
310 | /* | 198 | /* |
@@ -312,21 +200,28 @@ void lcd_clearpixel(int x, int y) | |||
312 | */ | 200 | */ |
313 | void lcd_invertpixel(int x, int y) | 201 | void lcd_invertpixel(int x, int y) |
314 | { | 202 | { |
315 | INVERT_PIXEL(x,y); | 203 | (void)x; |
204 | (void)y; | ||
316 | } | 205 | } |
317 | 206 | ||
318 | void lcd_clear_display(void) | 207 | void lcd_clear_display(void) |
319 | { | 208 | { |
320 | memset (lcd_framebuffer, 0, sizeof lcd_framebuffer); | 209 | int x, y; |
210 | for (y=0; y<2; y++) { | ||
211 | for (x=0; x<11; x++) { | ||
212 | lcd_buffer[y][x++]=lcd_ascii[' ']; | ||
213 | } | ||
214 | } | ||
215 | lcd_update(); | ||
321 | } | 216 | } |
322 | 217 | ||
323 | void lcd_puts(int x, int y, unsigned char *str) | 218 | void lcd_puts(int x, int y, unsigned char *str) |
324 | { | 219 | { |
325 | int i; | 220 | int i; |
326 | for (i=0; *str && x<11; i++) | 221 | for (i=0; *str && x<11; i++) |
327 | lcd_print_char(x++, y, *str++); | 222 | lcd_buffer[y][x++]=lcd_ascii[*str++]; |
328 | for (; x<11; x++) | 223 | for (; x<11; x++) |
329 | lcd_print_char(x, y, ' '); | 224 | lcd_buffer[y][x]=lcd_ascii[' ']; |
330 | lcd_update(); | 225 | lcd_update(); |
331 | } | 226 | } |
332 | 227 | ||
@@ -353,14 +248,16 @@ void lcd_define_pattern(int which, char *pattern, int length) | |||
353 | } | 248 | } |
354 | for (i = 1; i <= 5; i++) | 249 | for (i = 1; i <= 5; i++) |
355 | { | 250 | { |
356 | font_player[pat][i-1] = icon[i]; | 251 | (*font_player)[pat][i-1] = icon[i]; |
357 | } | 252 | } |
253 | lcd_display_redraw=true; | ||
254 | lcd_update(); | ||
358 | } | 255 | } |
359 | 256 | ||
360 | extern void lcd_puts(int x, int y, unsigned char *str); | 257 | extern void lcd_puts(int x, int y, unsigned char *str); |
361 | 258 | ||
362 | void lcd_putc(int x, int y, unsigned char ch) | 259 | void lcd_putc(int x, int y, unsigned char ch) |
363 | { | 260 | { |
364 | lcd_print_char(x, y, ch); | 261 | lcd_buffer[y][x]=lcd_ascii[ch]; |
365 | lcd_update(); | 262 | lcd_update(); |
366 | } | 263 | } |