3 /* This is a driver to implement, when possible, "high-level"
4 routines using only low level calls. This is to make it possible
5 to have accelerated functions for the individual drivers...
6 or to simply not bother with them. */
8 /* When creating new drivers, you need to assign all the functions that
9 that driver supports into the driver struct. If it is a supplementary
10 driver, it should make sure to perserve the old values. */
20 /* Here, we only want to add a driver if there is not one already
23 TRACE(console
, "GENERIC_Start\n");
25 if (!driver
.clearWindow
)
26 driver
.clearWindow
= GENERIC_ClearWindow
;
28 if (!driver
.scrollUpWindow
)
29 driver
.scrollUpWindow
= GENERIC_ScrollUpWindow
;
31 if (!driver
.scrollDownWindow
)
32 driver
.scrollDownWindow
= GENERIC_ScrollDownWindow
;
34 if (!driver
.getCharacter
)
35 driver
.getCharacter
= GENERIC_GetCharacter
;
38 void GENERIC_ClearWindow(char row1
, char col1
, char row2
, char col2
,
39 int bg_color
, int attribute
)
45 TRACE(console
, "GENERIC_ClearWindow()\n");
46 /* Abort if we have only partial functionality */
47 if (!(driver
.getCursorPosition
&& driver
.moveCursor
&& driver
.write
))
50 old_refresh
= CONSOLE_GetRefresh();
51 CONSOLE_SetRefresh(FALSE
);
53 CONSOLE_GetCursorPosition(&trow
, &tcol
);
55 for (x
= row1
; x
< row2
; x
++)
57 CONSOLE_MoveCursor(x
, col1
);
59 for (y
= col1
; y
< col2
; y
++)
61 CONSOLE_Write(' ', 0, bg_color
, attribute
);
64 CONSOLE_MoveCursor(trow
, tcol
);
66 CONSOLE_SetRefresh(old_refresh
);
68 TRACE(console
, "GENERIC_ClearWindow() completed.\n");
71 /* These are in-progress. I just haven't finished them yet... */
72 void GENERIC_ScrollUpWindow(char row1
, char col1
, char row2
, char col2
,
73 char lines
, int bg_color
, int attribute
)
81 TRACE(console
, "GENERIC_ScrollUpWindow()\n");
83 /* Abort if we have only partial functionality */
84 if (!(driver
.getCursorPosition
&& driver
.moveCursor
&& driver
.write
85 && driver
.getCharacterAtCursor
&& driver
.clearWindow
))
88 old_refresh
= CONSOLE_GetRefresh();
89 CONSOLE_SetRefresh(FALSE
);
91 CONSOLE_GetCursorPosition(&trow
, &tcol
);
93 for (x
= row1
+ lines
; x
< row2
; x
++)
95 for (y
= col1
; y
< col2
; y
++)
97 CONSOLE_MoveCursor(x
, y
);
98 CONSOLE_GetCharacterAtCursor(&ch
, &fg
, &bg
, &attr
);
99 CONSOLE_MoveCursor(x
- lines
, y
);
100 CONSOLE_Write(ch
, fg
, bg
, attr
);
103 CONSOLE_ClearWindow(row2
- lines
, col1
, row2
, col2
, bg_color
,
105 CONSOLE_MoveCursor(trow
, tcol
);
107 CONSOLE_SetRefresh(old_refresh
);
109 TRACE(console
, "GENERIC_ScrollUpWindow() completed.\n");
112 void GENERIC_ScrollDownWindow(char row1
, char col1
, char row2
, char col2
,
113 char lines
, int bg_color
, int attribute
)
121 TRACE(console
, "GENERIC_ScrollDownWindow()\n");
123 /* Abort if we have only partial functionality */
124 if (!(driver
.getCursorPosition
&& driver
.moveCursor
&& driver
.write
125 && driver
.getCharacterAtCursor
&& driver
.clearWindow
))
128 old_refresh
= CONSOLE_GetRefresh();
129 CONSOLE_SetRefresh(FALSE
);
131 CONSOLE_GetCursorPosition(&trow
, &tcol
);
133 for (x
= row2
- lines
; x
> row1
; x
--)
135 for (y
= col1
; y
< col2
; y
++)
137 CONSOLE_MoveCursor(x
, y
);
138 CONSOLE_GetCharacterAtCursor(&ch
, &fg
, &bg
, &attr
);
139 CONSOLE_MoveCursor(x
+ lines
, y
);
140 CONSOLE_Write(ch
, fg
, bg
, attr
);
143 CONSOLE_ClearWindow(row1
, col1
, row1
+ lines
, col2
, bg_color
,
145 CONSOLE_MoveCursor(trow
, tcol
);
147 CONSOLE_SetRefresh(old_refresh
);
149 TRACE(console
, "GENERIC_ScrollDownWindow() completed.\n");
153 char GENERIC_GetCharacter()
155 /* Keep getting keys until we get one with a char value */
156 char ch
= (char) 0, scan
;
160 CONSOLE_GetKeystroke(&ch
, &scan
);