Go to most recent revision | Details | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
44 | pj | 1 | /* Project: OSLib |
2 | * Description: The OS Construction Kit |
||
3 | * Date: 1.6.2000 |
||
4 | * Idea by: Luca Abeni & Gerardo Lamastra |
||
5 | * |
||
6 | * OSLib is an SO project aimed at developing a common, easy-to-use |
||
7 | * low-level infrastructure for developing OS kernels and Embedded |
||
8 | * Applications; it partially derives from the HARTIK project but it |
||
9 | * currently is independently developed. |
||
10 | * |
||
11 | * OSLib is distributed under GPL License, and some of its code has |
||
12 | * been derived from the Linux kernel source; also some important |
||
13 | * ideas come from studying the DJGPP go32 extender. |
||
14 | * |
||
15 | * We acknowledge the Linux Community, Free Software Foundation, |
||
16 | * D.J. Delorie and all the other developers who believe in the |
||
17 | * freedom of software and ideas. |
||
18 | * |
||
19 | * For legalese, check out the included GPL license. |
||
20 | */ |
||
21 | |||
22 | /* Console output functions - part 2 */ |
||
23 | |||
24 | #include <ll/i386/hw-data.h> |
||
25 | #include <ll/i386/hw-instr.h> |
||
26 | #include <ll/i386/cons.h> |
||
27 | /* #include <xsys.h>*/ |
||
28 | #include <ll/i386/string.h> |
||
29 | #include <ll/i386/stdlib.h> |
||
30 | #include <ll/i386/stdio.h> |
||
31 | #include <ll/stdarg.h> |
||
32 | |||
33 | FILE(Cons2); |
||
34 | |||
35 | #define PAGE_SIZE 2048 |
||
36 | #define PAGE_MAX 8 |
||
37 | |||
38 | /* CGA compatible registers */ |
||
39 | |||
40 | #define CGA_INDEX_REG 0x3D4 |
||
41 | #define CGA_DATA_REG 0x3D5 |
||
42 | |||
43 | #define VIDEO_ADDRESS_MSB 0x0C |
||
44 | #define VIDEO_ADDRESS_LSB 0x0D |
||
45 | |||
46 | |||
47 | extern int active_page; |
||
48 | extern int visual_page; |
||
49 | static int curs_x[PAGE_MAX]; |
||
50 | static int curs_y[PAGE_MAX]; |
||
51 | extern BYTE bios_x, bios_y, bios_attr; |
||
52 | |||
53 | /* MG */ |
||
54 | int cons_columns; /* number of screen columns */ |
||
55 | int cons_rows; /* number of screen rows */ |
||
56 | |||
57 | void set_visual_page(int page) |
||
58 | { |
||
59 | unsigned short page_offset; |
||
60 | |||
61 | page_offset = page * PAGE_SIZE; |
||
62 | visual_page = page; |
||
63 | outp(CGA_INDEX_REG, VIDEO_ADDRESS_LSB); |
||
64 | outp(CGA_DATA_REG, page_offset & 0xFF); |
||
65 | outp(CGA_INDEX_REG, VIDEO_ADDRESS_MSB); |
||
66 | outp(CGA_DATA_REG, (page_offset >> 8) & 0xFF); |
||
67 | } |
||
68 | |||
69 | void set_active_page(int page) |
||
70 | { |
||
71 | curs_x[active_page] = bios_x; |
||
72 | curs_y[active_page] = bios_y; |
||
73 | bios_x = curs_x[page]; |
||
74 | bios_y = curs_y[page]; |
||
75 | active_page = page; |
||
76 | } |
||
77 | |||
78 | int get_visual_page(void) |
||
79 | { |
||
80 | return(visual_page); |
||
81 | } |
||
82 | |||
83 | int get_active_page(void) |
||
84 | { |
||
85 | return(active_page); |
||
86 | } |
||
87 | |||
88 | void _clear(char c,char attr,int x1,int y1,int x2,int y2) |
||
89 | { |
||
90 | register int i,j; |
||
91 | WORD w = attr; |
||
92 | |||
93 | w <<= 8; w |= c; |
||
94 | for (i = x1; i <= x2; i++) |
||
95 | for (j = y1; j <= y2; j++) |
||
96 | lmempokew((LIN_ADDR)(0xB8000 + 2*i+cons_columns*2*j + 2*active_page*PAGE_SIZE),w); |
||
97 | place(x1,y1); |
||
98 | bios_y = y1; |
||
99 | bios_x = x1; |
||
100 | } |
||
101 | |||
102 | void clear() |
||
103 | { |
||
104 | _clear(' ',bios_attr,0,0,(cons_columns-1),(cons_rows-1)); |
||
105 | } |
||
106 | |||
107 | void puts_xy(int x,int y,char attr,char *s) |
||
108 | { |
||
109 | LIN_ADDR v = (LIN_ADDR)(0xB8000 + (cons_columns*y+x)*2 + active_page*(2*PAGE_SIZE)); |
||
110 | while (*s != 0) { |
||
111 | /* REMEMBER! This is a macro! v++ is out to prevent side-effects */ |
||
112 | lmempokeb(v,*s); s++; v++; |
||
113 | lmempokeb(v,attr); v++; |
||
114 | } |
||
115 | } |
||
116 | |||
117 | void putc_xy(int x,int y,char attr,char c) |
||
118 | { |
||
119 | LIN_ADDR v = (LIN_ADDR)(0xB8000 + (cons_columns*y+x)*2 + active_page*(2*PAGE_SIZE)); |
||
120 | /* REMEMBER! This is a macro! v++ is out to prevent side-effects */ |
||
121 | lmempokeb(v,c); v++; |
||
122 | lmempokeb(v,attr); |
||
123 | } |
||
124 | |||
125 | char getc_xy(int x,int y,char *attr,char *c) |
||
126 | { |
||
127 | LIN_ADDR v = (LIN_ADDR)(0xB8000 + (cons_columns*y+x)*2 + active_page*(2*PAGE_SIZE)); |
||
128 | char r; |
||
129 | r = lmempeekb(v); v++; |
||
130 | if (c != NULL) *c = r; |
||
131 | r = lmempeekb(v); |
||
132 | if (attr != NULL) *attr = r; |
||
133 | return(r); |
||
134 | } |