diff options
Diffstat (limited to 'uisimulator/lcd.c')
-rw-r--r-- | uisimulator/lcd.c | 23 |
1 files changed, 19 insertions, 4 deletions
diff --git a/uisimulator/lcd.c b/uisimulator/lcd.c index 8607477d82..4909b5cc49 100644 --- a/uisimulator/lcd.c +++ b/uisimulator/lcd.c | |||
@@ -22,6 +22,9 @@ | |||
22 | */ | 22 | */ |
23 | 23 | ||
24 | #include "lcd.h" | 24 | #include "lcd.h" |
25 | #ifdef LCD_DEBUG | ||
26 | #include <stdio.h> | ||
27 | #endif | ||
25 | 28 | ||
26 | #define DISP_X LCD_WIDTH /* Display width in pixels */ | 29 | #define DISP_X LCD_WIDTH /* Display width in pixels */ |
27 | #define DISP_Y LCD_HEIGHT /* Display height in pixels */ | 30 | #define DISP_Y LCD_HEIGHT /* Display height in pixels */ |
@@ -40,7 +43,7 @@ | |||
40 | #define ASCII_MIN 0x20 /* First char in table */ | 43 | #define ASCII_MIN 0x20 /* First char in table */ |
41 | #define ASCII_MAX 0x7f /* Last char in table */ | 44 | #define ASCII_MAX 0x7f /* Last char in table */ |
42 | 45 | ||
43 | static const unsigned char char_gen[ASCII_MAX-ASCII_MIN+1][CHAR_X-1] = | 46 | static const unsigned char lcd_font_data[ASCII_MAX-ASCII_MIN+1][CHAR_X-1] = |
44 | { | 47 | { |
45 | 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x20-0x2f */ | 48 | 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x20-0x2f */ |
46 | 0x00, 0x00, 0x4f, 0x00, 0x00, | 49 | 0x00, 0x00, 0x4f, 0x00, 0x00, |
@@ -154,8 +157,8 @@ static const unsigned char char_gen[ASCII_MAX-ASCII_MIN+1][CHAR_X-1] = | |||
154 | */ | 157 | */ |
155 | unsigned char display[LCD_HEIGHT/8][LCD_WIDTH]; | 158 | unsigned char display[LCD_HEIGHT/8][LCD_WIDTH]; |
156 | 159 | ||
157 | static unsigned char lcd_y; /* Current pixel row */ | 160 | static int lcd_y; /* Current pixel row */ |
158 | static unsigned char lcd_x; /* Current pixel column */ | 161 | static int lcd_x; /* Current pixel column */ |
159 | 162 | ||
160 | /* | 163 | /* |
161 | * Set current x,y position | 164 | * Set current x,y position |
@@ -165,7 +168,15 @@ void lcd_position(int x, int y) | |||
165 | if (x >= 0 && x < DISP_X && y >= 0 && y < DISP_Y) { | 168 | if (x >= 0 && x < DISP_X && y >= 0 && y < DISP_Y) { |
166 | lcd_x = x; | 169 | lcd_x = x; |
167 | lcd_y = y; | 170 | lcd_y = y; |
171 | #ifdef LCD_DEBUG | ||
172 | fprintf(stderr, "lcd_position: set to %d, %d\n", x, y); | ||
173 | #endif | ||
168 | } | 174 | } |
175 | #ifdef LCD_DEBUG | ||
176 | else | ||
177 | fprintf(stderr, "lcd_position: not set\n"); | ||
178 | #endif | ||
179 | |||
169 | } | 180 | } |
170 | 181 | ||
171 | /* | 182 | /* |
@@ -202,7 +213,7 @@ void lcd_char (int ch, char invert) | |||
202 | 213 | ||
203 | /* Write each char column */ | 214 | /* Write each char column */ |
204 | for (col = 0; col < CHAR_X-1; col++) { | 215 | for (col = 0; col < CHAR_X-1; col++) { |
205 | unsigned long data = (char_gen[ch-ASCII_MIN][col] << shift) ^ invert; | 216 | unsigned long data = (lcd_font_data[ch-ASCII_MIN][col] << shift) ^ invert; |
206 | dp[0][col] = (dp[0][col] & mask) | data; | 217 | dp[0][col] = (dp[0][col] & mask) | data; |
207 | if (lcd_y < DISP_Y-8) | 218 | if (lcd_y < DISP_Y-8) |
208 | dp[1][col] = (dp[1][col] & (mask >> 8)) | (data >> 8); | 219 | dp[1][col] = (dp[1][col] & (mask >> 8)) | (data >> 8); |
@@ -221,6 +232,10 @@ void lcd_string(const char *text, char invert) | |||
221 | { | 232 | { |
222 | int ch; | 233 | int ch; |
223 | 234 | ||
235 | #ifdef LCD_DEBUG | ||
236 | fprintf(stderr, "lcd_string: output %s at %d, %d\n", | ||
237 | text, lcd_x, lcd_y); | ||
238 | #endif | ||
224 | while ((ch = *text++) != '\0') { | 239 | while ((ch = *text++) != '\0') { |
225 | if (lcd_y > DISP_Y-CHAR_Y) { | 240 | if (lcd_y > DISP_Y-CHAR_Y) { |
226 | /* Scroll (8 pixels) */ | 241 | /* Scroll (8 pixels) */ |