diff options
Diffstat (limited to 'uisimulator/sdl/lcd-x11.c')
-rw-r--r-- | uisimulator/sdl/lcd-x11.c | 212 |
1 files changed, 0 insertions, 212 deletions
diff --git a/uisimulator/sdl/lcd-x11.c b/uisimulator/sdl/lcd-x11.c deleted file mode 100644 index c30d857d8c..0000000000 --- a/uisimulator/sdl/lcd-x11.c +++ /dev/null | |||
@@ -1,212 +0,0 @@ | |||
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 | #include "system.h" | ||
35 | #include "config.h" | ||
36 | |||
37 | /* | ||
38 | * Specific implementations for X11, using the generic LCD API and data. | ||
39 | */ | ||
40 | |||
41 | #include "lcd-x11.h" | ||
42 | #include "lcd-playersim.h" | ||
43 | |||
44 | #include <SDL.h> | ||
45 | |||
46 | extern SDL_Surface *surface; | ||
47 | |||
48 | extern void screen_resized(int width, int height); | ||
49 | extern bool lcd_display_redraw; | ||
50 | |||
51 | #ifdef HAVE_LCD_BITMAP | ||
52 | #if LCD_DEPTH==16 | ||
53 | fb_data lcd_framebuffer_copy[LCD_HEIGHT][LCD_WIDTH*2]; | ||
54 | #else | ||
55 | fb_data lcd_framebuffer_copy[LCD_HEIGHT][LCD_WIDTH]; | ||
56 | #endif | ||
57 | |||
58 | void lcd_update (void) | ||
59 | { | ||
60 | /* update a full screen rect */ | ||
61 | lcd_update_rect(0, 0, LCD_WIDTH, LCD_HEIGHT); | ||
62 | } | ||
63 | |||
64 | void lcd_update_rect(int x_start, int y_start, | ||
65 | int width, int height) | ||
66 | { | ||
67 | int x; | ||
68 | int y; | ||
69 | int p=0; | ||
70 | int xmax; | ||
71 | int ymax; | ||
72 | int colors[LCD_WIDTH * LCD_HEIGHT]; | ||
73 | struct coordinate points[LCD_WIDTH * LCD_HEIGHT]; | ||
74 | |||
75 | #if 0 | ||
76 | fprintf(stderr, "%04d: lcd_update_rect(%d, %d, %d, %d)\n", | ||
77 | counter++, x_start, y_start, width, height); | ||
78 | #endif | ||
79 | ymax = y_start + height; | ||
80 | xmax = x_start + width; | ||
81 | |||
82 | if(xmax > LCD_WIDTH) | ||
83 | xmax = LCD_WIDTH; | ||
84 | if(ymax >= LCD_HEIGHT) | ||
85 | ymax = LCD_HEIGHT; | ||
86 | |||
87 | for (x = x_start; x < xmax; x++) | ||
88 | for (y = y_start; y < ymax; y++) | ||
89 | { | ||
90 | #if LCD_DEPTH == 1 | ||
91 | Uint32 sdl_white = SDL_MapRGB(surface->format, 255, 255, 255); | ||
92 | Uint32 sdl_black = SDL_MapRGB(surface->format, 0, 0, 0); | ||
93 | points[p].x = x + MARGIN_X; | ||
94 | points[p].y = y + MARGIN_Y; | ||
95 | colors[p] = ((lcd_framebuffer[y/8][x] >> (y & 7)) & 1) ? sdl_black : sdl_white; | ||
96 | #elif LCD_DEPTH == 2 | ||
97 | unsigned gray = ((lcd_framebuffer[y/4][x] >> (2 * (y & 3))) & 3) * 85; | ||
98 | points[p].x = x + MARGIN_X; | ||
99 | points[p].y = y + MARGIN_Y; | ||
100 | colors[p] = SDL_MapRGB(surface->format, 255-gray, 255-gray, 255-gray); | ||
101 | #elif LCD_DEPTH == 16 | ||
102 | #if LCD_PIXELFORMAT == RGB565SWAPPED | ||
103 | unsigned short pixel = swap16(lcd_framebuffer[y][x]); | ||
104 | unsigned r = ((pixel >> 11) & 0x1f) << 3; | ||
105 | unsigned g = ((pixel >> 5) & 0x3f) << 2; | ||
106 | unsigned b = (pixel & 0x1f) << 3; | ||
107 | points[p].x = x + MARGIN_X; | ||
108 | points[p].y = y + MARGIN_Y; | ||
109 | colors[p] = SDL_MapRGB(surface->format, r, g, b); | ||
110 | #else | ||
111 | unsigned r = ((lcd_framebuffer[y][x] >> 11) & 0x1f) << 3; | ||
112 | unsigned g = ((lcd_framebuffer[y][x] >> 5) & 0x3f) << 2; | ||
113 | unsigned b = ((lcd_framebuffer[y][x]) & 0x1f) << 3; | ||
114 | points[p].x = x + MARGIN_X; | ||
115 | points[p].y = y + MARGIN_Y; | ||
116 | colors[p] = SDL_MapRGB(surface->format, r, g, b); | ||
117 | #endif | ||
118 | #endif | ||
119 | p++; | ||
120 | } | ||
121 | |||
122 | dots(colors, &points[0], p); | ||
123 | /* printf("lcd_update_rect: Draws %d pixels, clears %d pixels\n", p, cp);*/ | ||
124 | SDL_UpdateRect(surface, 0, 0, 0, 0); | ||
125 | lcd_display_redraw=false; | ||
126 | } | ||
127 | |||
128 | #ifdef LCD_REMOTE_HEIGHT | ||
129 | extern unsigned char lcd_remote_framebuffer[LCD_REMOTE_HEIGHT/8][LCD_REMOTE_WIDTH]; | ||
130 | unsigned char lcd_remote_framebuffer_copy[LCD_REMOTE_HEIGHT/8][LCD_REMOTE_WIDTH]; | ||
131 | |||
132 | #define REMOTE_START_Y (LCD_HEIGHT + 2*MARGIN_Y) | ||
133 | |||
134 | void lcd_remote_update (void) | ||
135 | { | ||
136 | lcd_remote_update_rect(0, 0, LCD_REMOTE_WIDTH, LCD_REMOTE_HEIGHT); | ||
137 | } | ||
138 | |||
139 | void lcd_remote_update_rect(int x_start, int y_start, | ||
140 | int width, int height) | ||
141 | { | ||
142 | int x; | ||
143 | int y; | ||
144 | int p=0; | ||
145 | int xmax; | ||
146 | int ymax; | ||
147 | struct coordinate points[LCD_REMOTE_WIDTH * LCD_REMOTE_HEIGHT]; | ||
148 | int colors[LCD_REMOTE_WIDTH * LCD_REMOTE_HEIGHT]; | ||
149 | Uint32 sdl_white = SDL_MapRGB(surface->format, 255, 255, 255); | ||
150 | Uint32 sdl_black = SDL_MapRGB(surface->format, 0, 0, 0); | ||
151 | |||
152 | #if 0 | ||
153 | fprintf(stderr, "%04d: lcd_update_rect(%d, %d, %d, %d)\n", | ||
154 | counter++, x_start, y_start, width, height); | ||
155 | #endif | ||
156 | ymax = y_start + height; | ||
157 | xmax = x_start + width; | ||
158 | |||
159 | if(xmax > LCD_REMOTE_WIDTH) | ||
160 | xmax = LCD_REMOTE_WIDTH; | ||
161 | if(ymax >= LCD_REMOTE_HEIGHT) | ||
162 | ymax = LCD_REMOTE_HEIGHT; | ||
163 | |||
164 | for (x = x_start; x < xmax; x++) | ||
165 | for (y = y_start; y < ymax; y++) { | ||
166 | colors[p] = ((lcd_remote_framebuffer[y/8][x] >> (y & 7)) & 1) ? sdl_black : sdl_white; | ||
167 | points[p].x = x + MARGIN_X; | ||
168 | points[p].y = y + MARGIN_Y + REMOTE_START_Y; | ||
169 | p++; | ||
170 | } | ||
171 | |||
172 | dots(colors, &points[0], p); | ||
173 | /* printf("lcd_update_rect: Draws %d pixels, clears %d pixels\n", p, cp);*/ | ||
174 | SDL_UpdateRect(surface, 0, 0, 0, 0); | ||
175 | lcd_display_redraw=false; | ||
176 | } | ||
177 | |||
178 | |||
179 | #endif | ||
180 | |||
181 | #endif | ||
182 | #ifdef HAVE_LCD_CHARCELLS | ||
183 | |||
184 | /* Defined in lcd-playersim.c */ | ||
185 | extern void lcd_print_char(int x, int y); | ||
186 | extern unsigned char lcd_buffer[2][11]; | ||
187 | |||
188 | extern unsigned char hardware_buffer_lcd[11][2]; | ||
189 | static unsigned char lcd_buffer_copy[11][2]; | ||
190 | |||
191 | void lcd_update (void) | ||
192 | { | ||
193 | bool changed=false; | ||
194 | int x, y; | ||
195 | for (y=0; y<2; y++) { | ||
196 | for (x=0; x<11; x++) { | ||
197 | if (lcd_display_redraw || | ||
198 | lcd_buffer_copy[x][y] != hardware_buffer_lcd[x][y]) { | ||
199 | lcd_buffer_copy[x][y] = hardware_buffer_lcd[x][y]; | ||
200 | lcd_print_char(x, y); | ||
201 | changed=true; | ||
202 | } | ||
203 | } | ||
204 | } | ||
205 | if (changed) | ||
206 | { | ||
207 | SDL_UpdateRect(surface, 0, 0, 0, 0); | ||
208 | } | ||
209 | lcd_display_redraw=false; | ||
210 | } | ||
211 | |||
212 | #endif | ||