summaryrefslogtreecommitdiff
path: root/src/kernel/vga.c
diff options
context:
space:
mode:
authorBenji Dial <Benji3.141@gmail.com>2019-12-24 22:31:22 -0500
committerBenji Dial <Benji3.141@gmail.com>2019-12-24 22:31:22 -0500
commitf5f0f5ddae199121daebcd2213aabd81686cc074 (patch)
tree91d8d29ea497e282f841849e620d43f8fcafcfcc /src/kernel/vga.c
parenta947a7a143029ee8ef5cb4a4232d7439b8a79670 (diff)
downloadportland-os-f5f0f5ddae199121daebcd2213aabd81686cc074.tar.gz
start of 0.0.9 branch, using multiboot this time
Diffstat (limited to 'src/kernel/vga.c')
-rw-r--r--src/kernel/vga.c37
1 files changed, 37 insertions, 0 deletions
diff --git a/src/kernel/vga.c b/src/kernel/vga.c
index 046dda7..e3e2516 100644
--- a/src/kernel/vga.c
+++ b/src/kernel/vga.c
@@ -18,6 +18,7 @@ OF THIS SOFTWARE.
*/
#include "vga.h"
+#include <stdbool.h>
uint16_t cursor_pos = 0;
uint8_t color = 0xf0;
@@ -62,6 +63,42 @@ void put_sz(uint8_t *sz) {
put_char(*(sz++));
}
+void put_16(uint16_t n) {
+ bool s = false;
+ if (n / 10000) {
+ put_char((uint8_t)'0' + n / 10000);
+ s = true;
+ }
+ n %= 10000;
+ if (n / 1000 || s) {
+ put_char((uint8_t)'0' + n / 1000);
+ s = true;
+ }
+ n %= 1000;
+ if (n / 100 || s) {
+ put_char((uint8_t)'0' + n / 100);
+ s = true;
+ }
+ n %= 100;
+ if (n / 10 || s) {
+ put_char((uint8_t)'0' + n / 10);
+ s = true;
+ }
+ put_char((uint8_t)'0' + n % 10);
+}
+
+void put_32_hex(uint32_t n) {
+ for (uint8_t i = 0; i < 4; ++i) {
+ put_char(n / 0xf0000000 + (n < 0xa0000000 ? (uint8_t)'0' : (uint8_t)'a' - 1));
+ n <<= 4;
+ }
+ put_char('_');
+ for (uint8_t i = 0; i < 4; ++i) {
+ put_char(n / 0xf0000000 + (n < 0xa0000000 ? (uint8_t)'0' : (uint8_t)'a' - 1));
+ n <<= 4;
+ }
+}
+
void move_cursor(uint8_t col, uint8_t row) {
cursor_pos = (col + row * cols) * 2;
}