|
|
|
@ -21,7 +21,7 @@ int get_offset_col(int offset);
|
|
|
|
|
*/
|
|
|
|
|
void kprint_at(char *message, int col, int row) {
|
|
|
|
|
/* Set cursor if col/row are negative */
|
|
|
|
|
int offset;
|
|
|
|
|
int offset, i = 0;
|
|
|
|
|
if (col >= 0 && row >= 0)
|
|
|
|
|
offset = get_offset(col, row);
|
|
|
|
|
else {
|
|
|
|
@ -31,7 +31,6 @@ void kprint_at(char *message, int col, int row) {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Loop through message and print it */
|
|
|
|
|
int i = 0;
|
|
|
|
|
while (message[i] != 0) {
|
|
|
|
|
offset = print_char(message[i++], col, row, WHITE_ON_BLACK);
|
|
|
|
|
/* Compute row/col for next iteration */
|
|
|
|
@ -67,6 +66,9 @@ void kprint_backspace() {
|
|
|
|
|
*/
|
|
|
|
|
int print_char(char c, int col, int row, char attr) {
|
|
|
|
|
uint8_t *vidmem = (uint8_t*) VIDEO_ADDRESS;
|
|
|
|
|
int offset;
|
|
|
|
|
int i;
|
|
|
|
|
char *last_line;
|
|
|
|
|
if (!attr) attr = WHITE_ON_BLACK;
|
|
|
|
|
|
|
|
|
|
/* Error control: print a red 'E' if the coords aren't right */
|
|
|
|
@ -76,7 +78,6 @@ int print_char(char c, int col, int row, char attr) {
|
|
|
|
|
return get_offset(col, row);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int offset;
|
|
|
|
|
if (col >= 0 && row >= 0) offset = get_offset(col, row);
|
|
|
|
|
else offset = get_cursor_offset();
|
|
|
|
|
|
|
|
|
@ -94,14 +95,13 @@ int print_char(char c, int col, int row, char attr) {
|
|
|
|
|
|
|
|
|
|
/* Check if the offset is over screen size and scroll */
|
|
|
|
|
if (offset >= MAX_ROWS * MAX_COLS * 2) {
|
|
|
|
|
int i;
|
|
|
|
|
for (i = 1; i < MAX_ROWS; i++)
|
|
|
|
|
for (i = 1; i < MAX_ROWS; i++)
|
|
|
|
|
memory_copy((uint8_t*)(get_offset(0, i) + VIDEO_ADDRESS),
|
|
|
|
|
(uint8_t*)(get_offset(0, i-1) + VIDEO_ADDRESS),
|
|
|
|
|
MAX_COLS * 2);
|
|
|
|
|
|
|
|
|
|
/* Blank last line */
|
|
|
|
|
char *last_line = (char*) (get_offset(0, MAX_ROWS-1) + (uint8_t*) VIDEO_ADDRESS);
|
|
|
|
|
last_line = (char*) (get_offset(0, MAX_ROWS-1) + (uint8_t*) VIDEO_ADDRESS);
|
|
|
|
|
for (i = 0; i < MAX_COLS * 2; i++) last_line[i] = 0;
|
|
|
|
|
|
|
|
|
|
offset -= 2 * MAX_COLS;
|
|
|
|
@ -116,8 +116,9 @@ int get_cursor_offset() {
|
|
|
|
|
* 1. Ask for high byte of the cursor offset (data 14)
|
|
|
|
|
* 2. Ask for low byte (data 15)
|
|
|
|
|
*/
|
|
|
|
|
int offset;
|
|
|
|
|
port_byte_out(REG_SCREEN_CTRL, 14);
|
|
|
|
|
int offset = port_byte_in(REG_SCREEN_DATA) << 8; /* High byte: << 8 */
|
|
|
|
|
offset = port_byte_in(REG_SCREEN_DATA) << 8; /* High byte: << 8 */
|
|
|
|
|
port_byte_out(REG_SCREEN_CTRL, 15);
|
|
|
|
|
offset += port_byte_in(REG_SCREEN_DATA);
|
|
|
|
|
return offset * 2; /* Position * size of character cell */
|
|
|
|
|