2 * Copyright © 2016 Keith Packard <keithp@keithp.com>
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation, either version 2 of the License, or
7 * (at your option) any later version.
9 * This program is distributed in the hope that it will be useful, but
10 * WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * General Public License for more details.
16 #include "ao_console.h"
20 static uint8_t console_row, console_col;
22 #define ao_console_bitmap ao_vga_bitmap
24 static uint8_t console_rows, console_cols;
27 ao_console_scroll(void)
29 ao_copy(&ao_console_bitmap,
31 ao_console_bitmap.width,
32 ao_console_bitmap.height - ao_font.height,
36 ao_rect(&ao_console_bitmap,
38 (console_rows - 1) * ao_font.height,
39 ao_console_bitmap.width,
46 ao_console_cursor(void)
48 ao_rect(&ao_console_bitmap,
49 console_col * ao_font.width,
50 console_row * ao_font.height,
58 ao_console_clear(void)
60 ao_rect(&ao_console_bitmap,
62 ao_console_bitmap.width,
63 ao_console_bitmap.height,
69 ao_console_space(void)
71 ao_rect(&ao_console_bitmap,
72 console_col * ao_font.width,
73 console_row * ao_font.height,
81 ao_console_newline(void)
83 if (++console_row == console_rows) {
90 ao_console_putchar(char c)
92 if (' ' <= c && c < 0x7f) {
97 ao_text(&ao_console_bitmap,
98 console_col * ao_font.width,
99 console_row * ao_font.height + ao_font.ascent,
103 if (++console_col == console_cols) {
105 ao_console_newline();
114 console_col += 8 - (console_col & 7);
115 if (console_col >= console_cols) {
117 ao_console_newline();
121 ao_console_newline();
124 console_col = console_row = 0;
138 ao_console_init(void)
140 console_cols = ao_console_bitmap.width / ao_font.width;
141 console_rows = ao_console_bitmap.height / ao_font.height;
144 ao_add_stdio(_ao_ps2_pollchar,