Subversion Repositories HelenOS

Rev

Rev 4326 | Rev 4525 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 4326 Rev 4457
Line 47... Line 47...
47
#include <ipc/fb.h>
47
#include <ipc/fb.h>
48
#include <ipc/ipc.h>
48
#include <ipc/ipc.h>
49
#include <ipc/ns.h>
49
#include <ipc/ns.h>
50
#include <ipc/services.h>
50
#include <ipc/services.h>
51
#include <libarch/ddi.h>
51
#include <libarch/ddi.h>
52
#include <console/style.h>
52
#include <io/style.h>
53
#include <console/color.h>
53
#include <io/color.h>
54
#include <sys/types.h>
54
#include <sys/types.h>
55
 
55
 
56
#include "ega.h"
56
#include "ega.h"
57
#include "../console/screenbuffer.h"
57
#include "../console/screenbuffer.h"
58
#include "main.h"
58
#include "main.h"
Line 68... Line 68...
68
#define EGA_IO_SIZE 2
68
#define EGA_IO_SIZE 2
69
 
69
 
70
int ega_normal_color = 0x0f;
70
int ega_normal_color = 0x0f;
71
int ega_inverted_color = 0xf0;
71
int ega_inverted_color = 0xf0;
72
 
72
 
73
#define NORMAL_COLOR        ega_normal_color       
73
#define NORMAL_COLOR        ega_normal_color
74
#define INVERTED_COLOR      ega_inverted_color
74
#define INVERTED_COLOR      ega_inverted_color
75
 
75
 
76
/* Allow only 1 connection */
76
/* Allow only 1 connection */
77
static int client_connected = 0;
77
static int client_connected = 0;
78
 
78
 
Line 93... Line 93...
93
        scr_addr[i * 2] = ' ';
93
        scr_addr[i * 2] = ' ';
94
        scr_addr[i * 2 + 1] = style;
94
        scr_addr[i * 2 + 1] = style;
95
    }
95
    }
96
}
96
}
97
 
97
 
98
static void cursor_goto(unsigned int row, unsigned int col)
98
static void cursor_goto(unsigned int col, unsigned int row)
99
{
99
{
100
    int ega_cursor;
100
    int ega_cursor;
101
 
101
 
102
    ega_cursor = col + scr_width * row;
102
    ega_cursor = col + scr_width * row;
103
   
103
   
Line 142... Line 142...
142
        for (i = 0; i < -rows * scr_width; i++)
142
        for (i = 0; i < -rows * scr_width; i++)
143
            ((short *)scr_addr)[i] = ((style << 8 ) + ' ');
143
            ((short *)scr_addr)[i] = ((style << 8 ) + ' ');
144
    }
144
    }
145
}
145
}
146
 
146
 
147
static void printchar(wchar_t c, unsigned int row, unsigned int col)
147
static void printchar(wchar_t c, unsigned int col, unsigned int row)
148
{
148
{
149
    scr_addr[(row * scr_width + col) * 2] = ega_glyph(c);
149
    scr_addr[(row * scr_width + col) * 2] = ega_glyph(c);
150
    scr_addr[(row * scr_width + col) * 2 + 1] = style;
150
    scr_addr[(row * scr_width + col) * 2 + 1] = style;
151
   
151
   
152
    cursor_goto(row, col + 1);
152
    cursor_goto(row, col + 1);
Line 239... Line 239...
239
}
239
}
240
 
240
 
241
static unsigned attr_to_ega_style(const attrs_t *a)
241
static unsigned attr_to_ega_style(const attrs_t *a)
242
{
242
{
243
    switch (a->t) {
243
    switch (a->t) {
-
 
244
    case at_style:
244
    case at_style: return style_to_ega_style(a->a.s.style);
245
        return style_to_ega_style(a->a.s.style);
-
 
246
    case at_rgb:
245
    case at_rgb: return rgb_to_ega_style(a->a.r.fg_color, a->a.r.bg_color);
247
        return rgb_to_ega_style(a->a.r.fg_color, a->a.r.bg_color);
-
 
248
    case at_idx:
246
    case at_idx: return color_to_ega_style(a->a.i.fg_color,
249
        return color_to_ega_style(a->a.i.fg_color,
247
        a->a.i.bg_color, a->a.i.flags);
250
            a->a.i.bg_color, a->a.i.flags);
-
 
251
    default:
248
    default: return INVERTED_COLOR;
252
        return INVERTED_COLOR;
249
    }
253
    }
250
}
254
}
251
 
255
 
252
static uint8_t ega_glyph(wchar_t ch)
256
static uint8_t ega_glyph(wchar_t ch)
253
{
257
{
Line 318... Line 322...
318
            clrscr();
322
            clrscr();
319
            retval = 0;
323
            retval = 0;
320
            break;
324
            break;
321
        case FB_PUTCHAR:
325
        case FB_PUTCHAR:
322
            c = IPC_GET_ARG1(call);
326
            c = IPC_GET_ARG1(call);
323
            row = IPC_GET_ARG2(call);
327
            col = IPC_GET_ARG2(call);
324
            col = IPC_GET_ARG3(call);
328
            row = IPC_GET_ARG3(call);
325
            if (col >= scr_width || row >= scr_height) {
329
            if (col >= scr_width || row >= scr_height) {
326
                retval = EINVAL;
330
                retval = EINVAL;
327
                break;
331
                break;
328
            }
332
            }
329
            printchar(c, row, col);
333
            printchar(c, col, row);
330
            retval = 0;
334
            retval = 0;
331
            break;
335
            break;
332
        case FB_CURSOR_GOTO:
336
        case FB_CURSOR_GOTO:
333
            row = IPC_GET_ARG1(call);
337
            col = IPC_GET_ARG1(call);
334
            col = IPC_GET_ARG2(call);
338
            row = IPC_GET_ARG2(call);
335
            if (row >= scr_height || col >= scr_width) {
339
            if (row >= scr_height || col >= scr_width) {
336
                retval = EINVAL;
340
                retval = EINVAL;
337
                break;
341
                break;
338
            }
342
            }
339
            cursor_goto(row, col);
343
            cursor_goto(col, row);
340
            retval = 0;
344
            retval = 0;
341
            break;
345
            break;
342
        case FB_SCROLL:
346
        case FB_SCROLL:
343
            i = IPC_GET_ARG1(call);
347
            i = IPC_GET_ARG1(call);
344
            if (i > scr_height || i < -((int) scr_height)) {
348
            if (i > scr_height || i < -((int) scr_height)) {