From e885241b95d3784b5206fa6fbad7aa6861e8bd48 Mon Sep 17 00:00:00 2001 From: Olivier Gayot Date: Sat, 10 Oct 2015 11:26:50 +0200 Subject: kfs: fixed printk every character to be displayed on the screen is two bytes long, not one Signed-off-by: Olivier Gayot --- src/main.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) (limited to 'src') diff --git a/src/main.c b/src/main.c index e4d3b4e..7c1172c 100644 --- a/src/main.c +++ b/src/main.c @@ -1,5 +1,6 @@ #define NB_COLS 80 #define NB_ROWS 25 +#define BPC 2 #define VIDEO_BUFFER 0xB8000 @@ -32,14 +33,15 @@ int printk(const char *str) for (int i = 0; str[i]; ++i) { /* TODO add the serial port handling */ - if ((long)addr >= offset + NB_COLS * NB_ROWS) { + if ((long)addr >= offset + NB_COLS * NB_ROWS * BPC) { /* shift up */ - addr -= NB_COLS; - my_memmove((void *)offset, (void *)offset + NB_COLS, NB_COLS * (NB_ROWS - 1)); - my_memset((void *)offset + NB_COLS * (NB_ROWS - 1), ' ', NB_ROWS); + addr -= NB_COLS * BPC; + my_memmove((void *)offset, (void *)offset + NB_COLS * BPC, NB_COLS * (NB_ROWS - 1) * BPC); + my_memset((void *)offset + NB_COLS * (NB_ROWS - 1) * BPC, ' ', NB_COLS * BPC); } - *addr++ = str[i]; + *addr = str[i]; + addr += BPC; ++count; } -- cgit v1.2.3