Rev 4338 | Rev 4343 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 4338 | Rev 4342 | ||
---|---|---|---|
Line 70... | Line 70... | ||
70 | int ega_inverted_color = 0xf0; |
70 | int ega_inverted_color = 0xf0; |
71 | 71 | ||
72 | #define NORMAL_COLOR ega_normal_color |
72 | #define NORMAL_COLOR ega_normal_color |
73 | #define INVERTED_COLOR ega_inverted_color |
73 | #define INVERTED_COLOR ega_inverted_color |
74 | 74 | ||
75 | #define EGA_STYLE(fg,bg) ((fg) > (bg) ? NORMAL_COLOR : INVERTED_COLOR) |
- | |
76 | - | ||
77 | /* Allow only 1 connection */ |
75 | /* Allow only 1 connection */ |
78 | static int client_connected = 0; |
76 | static int client_connected = 0; |
79 | 77 | ||
80 | static unsigned int scr_width; |
78 | static unsigned int scr_width; |
81 | static unsigned int scr_height; |
79 | static unsigned int scr_height; |
82 | static char *scr_addr; |
80 | static char *scr_addr; |
83 | 81 | ||
84 | static unsigned int style; |
82 | static unsigned int style; |
85 | 83 | ||
- | 84 | static unsigned attr_to_ega_style(const attrs_t *a); |
|
- | 85 | ||
86 | static void clrscr(void) |
86 | static void clrscr(void) |
87 | { |
87 | { |
88 | int i; |
88 | int i; |
89 | 89 | ||
90 | for (i = 0; i < scr_width * scr_height; i++) { |
90 | for (i = 0; i < scr_width * scr_height; i++) { |
Line 154... | Line 154... | ||
154 | { |
154 | { |
155 | int i; |
155 | int i; |
156 | 156 | ||
157 | for (i = 0; i < scr_width * scr_height; i++) { |
157 | for (i = 0; i < scr_width * scr_height; i++) { |
158 | scr_addr[i * 2] = data[i].character; |
158 | scr_addr[i * 2] = data[i].character; |
159 | /* FIXME |
- | |
160 | scr_addr[i * 2 + 1] = EGA_STYLE(data[i].style.fg_color, |
159 | scr_addr[i * 2 + 1] = attr_to_ega_style(&data[i].attrs); |
161 | data[i].style.bg_color); |
- | |
162 | */ |
- | |
163 | } |
160 | } |
164 | } |
161 | } |
165 | 162 | ||
166 | static int save_screen(void) |
163 | static int save_screen(void) |
167 | { |
164 | { |
Line 186... | Line 183... | ||
186 | else |
183 | else |
187 | return EINVAL; |
184 | return EINVAL; |
188 | return i; |
185 | return i; |
189 | } |
186 | } |
190 | 187 | ||
- | 188 | static int style_to_ega_style(int style) |
|
- | 189 | { |
|
- | 190 | unsigned int ega_style; |
|
- | 191 | ||
- | 192 | switch (style) { |
|
- | 193 | case STYLE_NORMAL: |
|
- | 194 | ega_style = INVERTED_COLOR; |
|
- | 195 | break; |
|
- | 196 | case STYLE_EMPHASIS: |
|
- | 197 | ega_style = INVERTED_COLOR | 4; |
|
- | 198 | break; |
|
- | 199 | default: |
|
- | 200 | return INVERTED_COLOR; |
|
- | 201 | } |
|
- | 202 | ||
- | 203 | return ega_style; |
|
- | 204 | } |
|
- | 205 | ||
- | 206 | static unsigned int color_to_ega_style(int fg_color, int bg_color, int attr) |
|
- | 207 | { |
|
- | 208 | unsigned int style; |
|
- | 209 | ||
- | 210 | style = (fg_color & 7) | ((bg_color & 7) << 4); |
|
- | 211 | if (attr & CATTR_BRIGHT) |
|
- | 212 | style = style | 0x08; |
|
- | 213 | ||
- | 214 | return style; |
|
- | 215 | } |
|
- | 216 | ||
- | 217 | static unsigned int rgb_to_ega_style(uint32_t fg, uint32_t bg) |
|
- | 218 | { |
|
- | 219 | return (fg > bg) ? NORMAL_COLOR : INVERTED_COLOR; |
|
- | 220 | } |
|
- | 221 | ||
- | 222 | static unsigned attr_to_ega_style(const attrs_t *a) |
|
- | 223 | { |
|
- | 224 | switch (a->t) { |
|
- | 225 | case at_style: return style_to_ega_style(a->a.s.style); |
|
- | 226 | case at_rgb: return rgb_to_ega_style(a->a.r.fg_color, a->a.r.bg_color); |
|
- | 227 | case at_idx: return color_to_ega_style(a->a.i.fg_color, |
|
- | 228 | a->a.i.bg_color, a->a.i.flags); |
|
- | 229 | default: return INVERTED_COLOR; |
|
- | 230 | } |
|
- | 231 | } |
|
191 | 232 | ||
192 | static void ega_client_connection(ipc_callid_t iid, ipc_call_t *icall) |
233 | static void ega_client_connection(ipc_callid_t iid, ipc_call_t *icall) |
193 | { |
234 | { |
194 | int retval; |
235 | int retval; |
195 | ipc_callid_t callid; |
236 | ipc_callid_t callid; |
196 | ipc_call_t call; |
237 | ipc_call_t call; |
197 | char c; |
238 | char c; |
198 | unsigned int row, col; |
239 | unsigned int row, col; |
199 | int bgcolor,fgcolor; |
240 | int bg_color, fg_color, attr; |
- | 241 | uint32_t bg_rgb, fg_rgb; |
|
200 | keyfield_t *interbuf = NULL; |
242 | keyfield_t *interbuf = NULL; |
201 | size_t intersize = 0; |
243 | size_t intersize = 0; |
202 | int i; |
244 | int i; |
203 | 245 | ||
204 | if (client_connected) { |
246 | if (client_connected) { |
Line 277... | Line 319... | ||
277 | else |
319 | else |
278 | cursor_disable(); |
320 | cursor_disable(); |
279 | retval = 0; |
321 | retval = 0; |
280 | break; |
322 | break; |
281 | case FB_SET_STYLE: |
323 | case FB_SET_STYLE: |
- | 324 | style = style_to_ega_style(IPC_GET_ARG1(call)); |
|
282 | retval = 0; |
325 | retval = 0; |
283 | switch (IPC_GET_ARG1(call)) { |
- | |
284 | case STYLE_NORMAL: style = INVERTED_COLOR; break; |
- | |
285 | case STYLE_EMPHASIS: style = INVERTED_COLOR | 4; break; |
- | |
286 | default: retval = EINVAL; |
- | |
287 | } |
- | |
288 | break; |
326 | break; |
289 | case FB_SET_COLOR: |
327 | case FB_SET_COLOR: |
290 | fgcolor = IPC_GET_ARG1(call); |
328 | fg_color = IPC_GET_ARG1(call); |
291 | bgcolor = IPC_GET_ARG2(call); |
329 | bg_color = IPC_GET_ARG2(call); |
292 | style = (fgcolor & 7) | ((bgcolor & 7) << 4); |
- | |
293 | if (IPC_GET_ARG3(call) & CATTR_BRIGHT) |
330 | attr = IPC_GET_ARG3(call); |
294 | style = style | 0x08; |
331 | style = color_to_ega_style(fg_color, bg_color, attr); |
295 | retval = 0; |
332 | retval = 0; |
296 | break; |
333 | break; |
297 | case FB_SET_RGB_COLOR: |
334 | case FB_SET_RGB_COLOR: |
298 | fgcolor = IPC_GET_ARG1(call); |
335 | fg_rgb = IPC_GET_ARG1(call); |
299 | bgcolor = IPC_GET_ARG2(call); |
336 | bg_rgb = IPC_GET_ARG2(call); |
300 | style = EGA_STYLE(fgcolor, bgcolor); |
337 | style = rgb_to_ega_style(fg_rgb, bg_rgb); |
301 | retval = 0; |
338 | retval = 0; |
302 | break; |
339 | break; |
303 | case FB_VP_DRAW_PIXMAP: |
340 | case FB_VP_DRAW_PIXMAP: |
304 | i = IPC_GET_ARG2(call); |
341 | i = IPC_GET_ARG2(call); |
305 | retval = print_screen(i); |
342 | retval = print_screen(i); |
Line 333... | Line 370... | ||
333 | size_t sz; |
370 | size_t sz; |
334 | 371 | ||
335 | ega_ph_addr = (void *) sysinfo_value("fb.address.physical"); |
372 | ega_ph_addr = (void *) sysinfo_value("fb.address.physical"); |
336 | scr_width = sysinfo_value("fb.width"); |
373 | scr_width = sysinfo_value("fb.width"); |
337 | scr_height = sysinfo_value("fb.height"); |
374 | scr_height = sysinfo_value("fb.height"); |
- | 375 | ||
338 | if(sysinfo_value("fb.blinking")) |
376 | if(sysinfo_value("fb.blinking")) { |
339 | { |
- | |
340 | ega_normal_color &= 0x77; |
377 | ega_normal_color &= 0x77; |
341 | ega_inverted_color &= 0x77; |
378 | ega_inverted_color &= 0x77; |
342 | } |
379 | } |
- | 380 | ||
343 | style = NORMAL_COLOR; |
381 | style = NORMAL_COLOR; |
344 | 382 | ||
345 | iospace_enable(task_get_id(), (void *) EGA_IO_ADDRESS, 2); |
383 | iospace_enable(task_get_id(), (void *) EGA_IO_ADDRESS, 2); |
346 | 384 | ||
347 | sz = scr_width * scr_height * 2; |
385 | sz = scr_width * scr_height * 2; |