From 48a608c8959fc696184bc1af2f67ecd07c0381ba Mon Sep 17 00:00:00 2001 From: Loic Guegan Date: Sun, 4 Apr 2021 14:03:26 +0200 Subject: [PATCH] Add utilities functions --- src/bringelle.c | 7 ++----- src/utils/print.c | 48 +++++++++++++++++++++++++++++++++++++++++++++-- src/utils/print.h | 6 ++++++ src/utils/types.h | 8 ++++++++ 4 files changed, 62 insertions(+), 7 deletions(-) create mode 100644 src/utils/types.h diff --git a/src/bringelle.c b/src/bringelle.c index 4c8e39f..d8bbe82 100644 --- a/src/bringelle.c +++ b/src/bringelle.c @@ -1,11 +1,8 @@ #include "utils/print.h" - - - void bringelle(){ - putchar('L'); - putchar('L'); + clear(); + print("Booting Bringelle..."); while(1); } diff --git a/src/utils/print.c b/src/utils/print.c index c7c94d4..8fab941 100644 --- a/src/utils/print.c +++ b/src/utils/print.c @@ -1,7 +1,51 @@ #include "print.h" +#include "types.h" + +#define MAX_COL 80 +#define MAX_LINE 25 + +char *video=(char *)0xB8000; +u8 col=0; +u8 line=0; void putchar(char c){ - char *video=(char *)0xB8000; - video[0]=c; + // Print char + video[col*2+MAX_COL*line*2]=c; + // Refresh location + col+=1; + if(col>= MAX_COL){ + col=0; + line+=1; + if(line>=MAX_LINE){ + line=MAX_LINE-1; + scrollup(); + } + } +} + +void print(char *str){ + int i=0; + while(str[i]!='\0'){ + putchar(str[i]); + i++; + } +} + +void clear(){ + for(char i=0;i