diff options
Diffstat (limited to 'uisimulator/common/lcd-playersim.c')
-rw-r--r-- | uisimulator/common/lcd-playersim.c | 253 |
1 files changed, 62 insertions, 191 deletions
diff --git a/uisimulator/common/lcd-playersim.c b/uisimulator/common/lcd-playersim.c index 4c658438d6..1c877d4409 100644 --- a/uisimulator/common/lcd-playersim.c +++ b/uisimulator/common/lcd-playersim.c | |||
@@ -20,6 +20,7 @@ | |||
20 | #include "hwcompat.h" | 20 | #include "hwcompat.h" |
21 | 21 | ||
22 | #include "lcd.h" | 22 | #include "lcd.h" |
23 | #include "lcd-charcell.h" | ||
23 | #include "kernel.h" | 24 | #include "kernel.h" |
24 | #include "thread.h" | 25 | #include "thread.h" |
25 | #include <string.h> | 26 | #include <string.h> |
@@ -32,215 +33,85 @@ | |||
32 | 33 | ||
33 | /*** definitions ***/ | 34 | /*** definitions ***/ |
34 | 35 | ||
35 | #define CHAR_WIDTH 6 | 36 | bool sim_lcd_framebuffer[SIM_LCD_HEIGHT][SIM_LCD_WIDTH]; |
36 | #define CHAR_HEIGHT 8 | ||
37 | #define ICON_HEIGHT 12 | ||
38 | #define CHAR_PIXEL 2 | ||
39 | #define BORDER_MARGIN 1 | ||
40 | |||
41 | static int double_height=1; | ||
42 | extern bool lcd_display_redraw; | ||
43 | extern const unsigned short *lcd_ascii; | ||
44 | extern unsigned char hardware_buffer_lcd[11][2]; | ||
45 | 37 | ||
38 | static int double_height = 1; | ||
46 | 39 | ||
47 | void lcd_print_icon(int x, int icon_line, bool enable, char **icon) | 40 | void lcd_print_icon(int x, int icon_line, bool enable, char **icon) |
48 | { | 41 | { |
49 | int xpos = x; | 42 | int row, col; |
50 | int ypos = icon_line*(ICON_HEIGHT+(CHAR_HEIGHT*2+2)*CHAR_PIXEL); | 43 | int y = (ICON_HEIGHT+(CHAR_HEIGHT*2+2)*CHAR_PIXEL) * icon_line; |
51 | int row=0, col; | ||
52 | 44 | ||
53 | int p=0, cp=0; | 45 | y += BORDER_MARGIN; |
54 | struct coordinate points[SIM_LCD_WIDTH * SIM_LCD_HEIGHT]; | 46 | x += BORDER_MARGIN; |
55 | struct coordinate clearpoints[SIM_LCD_WIDTH * SIM_LCD_HEIGHT]; | ||
56 | 47 | ||
57 | while (icon[row]) { | 48 | for (row = 0; icon[row]; row++) |
58 | col=0; | 49 | { |
59 | while (icon[row][col]) { | 50 | for (col = 0; icon[row][col]; col++) |
60 | switch(icon[row][col]) { | 51 | { |
61 | case '*': | 52 | switch (icon[row][col]) |
62 | if (enable) { | 53 | { |
63 | /* set a dot */ | 54 | case '*': |
64 | points[p].x = xpos + col +BORDER_MARGIN; | 55 | sim_lcd_framebuffer[y+row][x+col] = enable; |
65 | points[p].y = ypos+row +BORDER_MARGIN; | 56 | break; |
66 | p++; /* increase the point counter */ | 57 | |
67 | } else { | 58 | case ' ': |
68 | /* clear a dot */ | 59 | sim_lcd_framebuffer[y+row][x+col] = false; |
69 | clearpoints[cp].x = xpos + col +BORDER_MARGIN; | 60 | break; |
70 | clearpoints[cp].y = ypos+row +BORDER_MARGIN; | 61 | } |
71 | cp++; /* increase the point counter */ | ||
72 | } | 62 | } |
73 | break; | ||
74 | case ' ': /* Clear bit */ | ||
75 | /* clear a dot */ | ||
76 | clearpoints[cp].x = xpos + col+BORDER_MARGIN; | ||
77 | clearpoints[cp].y = ypos+row+BORDER_MARGIN; | ||
78 | cp++; /* increase the point counter */ | ||
79 | break; | ||
80 | } | ||
81 | col++; | ||
82 | } | 63 | } |
83 | row++; | 64 | sim_lcd_update_rect(x, y, col, row); |
84 | } | 65 | /* icon drawing updates immediately */ |
85 | /* DEBUGF("icon draw %d/%d\n", p, cp);*/ | ||
86 | if (cp) | ||
87 | drawdots(0, &clearpoints[0], cp); | ||
88 | if (p) | ||
89 | drawdots(1, &points[0], p); | ||
90 | } | 66 | } |
91 | 67 | ||
92 | void lcd_print_char(int x, int y) | 68 | void lcd_print_char(int x, int y, unsigned char ch) |
93 | { | 69 | { |
94 | int xpos = x * CHAR_WIDTH * CHAR_PIXEL; | 70 | int xpos = x * CHAR_WIDTH*CHAR_PIXEL; |
95 | int ypos = y * CHAR_HEIGHT * CHAR_PIXEL + ICON_HEIGHT; | 71 | int ypos = y * CHAR_HEIGHT*CHAR_PIXEL + ICON_HEIGHT; |
96 | int col, row; | 72 | int row, col, r, c; |
97 | int p=0, cp=0; | 73 | |
98 | struct rectangle points[CHAR_HEIGHT*CHAR_WIDTH]; | 74 | if (double_height > 1 && y == 1) |
99 | struct rectangle clearpoints[CHAR_HEIGHT*CHAR_WIDTH]; | 75 | return; /* only one row available if text is double height */ |
100 | unsigned char ch=hardware_buffer_lcd[x][y]; | 76 | |
101 | static char bitmap_content[11*8][2*8]; | 77 | for (row = 0; row < 7; row ++) |
102 | 78 | { | |
103 | if (double_height == 2 && y == 1) | 79 | unsigned fontbitmap = (*font_player)[ch][row]; |
104 | return; /* only one row available if text is double height */ | 80 | int height = (row == 3) ? 1 : double_height; |
105 | 81 | ||
106 | for (col=0; col<5; col++) { | 82 | y = ypos + row * CHAR_PIXEL * double_height; |
107 | unsigned char fontbitmap=(*font_player)[ch][col]; | 83 | for (col = 0; col < 5; col++) |
108 | for (row=0; row<7; row++) { | 84 | { |
109 | char fontbit=fontbitmap&(1<<row); | 85 | bool fontbit = fontbitmap & (0x10 >> col); |
110 | int height=CHAR_PIXEL*double_height; | 86 | |
111 | int ypixel; | 87 | x = xpos + col * CHAR_PIXEL; |
112 | if (bitmap_content[x*8+col][y*8+row*double_height]!=fontbit || | 88 | for (r = 0; r < height * CHAR_PIXEL; r++) |
113 | bitmap_content[x*8+col][y*8+row*double_height+double_height-1]!= | 89 | for (c = 0; c < CHAR_PIXEL; c++) |
114 | fontbit) { | 90 | sim_lcd_framebuffer[y+r][x+c] = fontbit; |
115 | bitmap_content[x*8+col][y*8+row*double_height]=fontbit; | ||
116 | bitmap_content[x*8+col][y*8+row*double_height+double_height-1]=fontbit; | ||
117 | |||
118 | ypixel=CHAR_PIXEL*(double_height*row)+ypos; | ||
119 | if (double_height==2) { | ||
120 | if (row == 3) /* Adjust for blank row in the middle */ | ||
121 | height=CHAR_PIXEL; | ||
122 | } | ||
123 | |||
124 | if (fontbit) { | ||
125 | /* set a dot */ | ||
126 | points[p].x = xpos + col*CHAR_PIXEL +BORDER_MARGIN; | ||
127 | points[p].y = ypixel +BORDER_MARGIN; | ||
128 | points[p].width=CHAR_PIXEL; | ||
129 | points[p].height=height; | ||
130 | p++; /* increase the point counter */ | ||
131 | } else { | ||
132 | clearpoints[cp].x = xpos + col*CHAR_PIXEL +BORDER_MARGIN; | ||
133 | clearpoints[cp].y = ypixel +BORDER_MARGIN; | ||
134 | clearpoints[cp].width=CHAR_PIXEL; | ||
135 | clearpoints[cp].height=height; | ||
136 | cp++; | ||
137 | } | 91 | } |
138 | } | ||
139 | } | 92 | } |
140 | } | 93 | if (double_height > 1) |
141 | /* DEBUGF("print_char %d/%d\n", p, cp);*/ | 94 | { |
142 | if (cp) | 95 | y = ypos + 15*CHAR_PIXEL; |
143 | drawrectangles(0, &clearpoints[0], cp); | 96 | for (r = 0; r < CHAR_PIXEL; r++) |
144 | if (p) | 97 | for (c = 0; c < 5*CHAR_PIXEL; c++) |
145 | drawrectangles(1, &points[0], p); | 98 | sim_lcd_framebuffer[y+r][xpos+c] = false; |
146 | } | 99 | } |
147 | |||
148 | |||
149 | /* | ||
150 | * Draw a rectangle with upper left corner at (x, y) | ||
151 | * and size (nx, ny) | ||
152 | */ | ||
153 | void lcd_drawrect (int x, int y, int nx, int ny) | ||
154 | { | ||
155 | (void)x; | ||
156 | (void)y; | ||
157 | (void)nx; | ||
158 | (void)ny; | ||
159 | } | ||
160 | |||
161 | /* Invert a rectangular area at (x, y), size (nx, ny) */ | ||
162 | void lcd_invertrect (int x, int y, int nx, int ny) | ||
163 | { | ||
164 | (void)x; | ||
165 | (void)y; | ||
166 | (void)nx; | ||
167 | (void)ny; | ||
168 | } | ||
169 | |||
170 | void lcd_drawline( int x1, int y1, int x2, int y2 ) | ||
171 | { | ||
172 | (void)x1; | ||
173 | (void)x2; | ||
174 | (void)y1; | ||
175 | (void)y2; | ||
176 | } | ||
177 | |||
178 | void lcd_clearline( int x1, int y1, int x2, int y2 ) | ||
179 | { | ||
180 | (void)x1; | ||
181 | (void)x2; | ||
182 | (void)y1; | ||
183 | (void)y2; | ||
184 | } | ||
185 | |||
186 | /* | ||
187 | * Set a single pixel | ||
188 | */ | ||
189 | void lcd_drawpixel(int x, int y) | ||
190 | { | ||
191 | (void)x; | ||
192 | (void)y; | ||
193 | } | ||
194 | |||
195 | /* | ||
196 | * Clear a single pixel | ||
197 | */ | ||
198 | void lcd_clearpixel(int x, int y) | ||
199 | { | ||
200 | (void)x; | ||
201 | (void)y; | ||
202 | } | ||
203 | |||
204 | /* | ||
205 | * Invert a single pixel | ||
206 | */ | ||
207 | void lcd_invertpixel(int x, int y) | ||
208 | { | ||
209 | (void)x; | ||
210 | (void)y; | ||
211 | } | 100 | } |
212 | 101 | ||
213 | |||
214 | |||
215 | void lcd_double_height(bool on) | 102 | void lcd_double_height(bool on) |
216 | { | 103 | { |
217 | double_height = 1; | 104 | int newval = (is_new_player() && on) ? 2 : 1; |
218 | if (on) | 105 | |
219 | double_height = 2; | 106 | if (newval != double_height) |
220 | lcd_display_redraw=true; | ||
221 | lcd_update(); | ||
222 | } | ||
223 | |||
224 | void lcd_define_hw_pattern(int pat, const char *pattern) | ||
225 | { | ||
226 | int i, j; | ||
227 | unsigned char icon[8]; | ||
228 | memset(icon, 0, sizeof icon); | ||
229 | |||
230 | DEBUGF("Defining pattern %d:", pat); | ||
231 | for (j = 0; j <= 5; j++) { | ||
232 | for (i = 0; i < 7; i++) { | ||
233 | if ((pattern[i])&(1<<(j))) | ||
234 | icon[5-j] |= (1<<(i)); | ||
235 | } | ||
236 | } | ||
237 | for (i = 1; i <= 5; i++) | ||
238 | { | 107 | { |
239 | DEBUGF(" 0x%02x", icon[i]); | 108 | double_height = newval; |
240 | (*font_player)[pat][i-1] = icon[i]; | 109 | lcd_update(); |
241 | } | 110 | } |
242 | DEBUGF("\n"); | ||
243 | lcd_display_redraw=true; | ||
244 | lcd_update(); | ||
245 | } | 111 | } |
246 | 112 | ||
113 | void sim_lcd_define_pattern(int pat, const char *pattern) | ||
114 | { | ||
115 | if (pat < lcd_pattern_count) | ||
116 | memcpy((*font_player)[pat], pattern, 7); | ||
117 | } | ||