summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOlivier Gayot <duskcoder@gmail.com>2015-10-10 11:26:50 +0200
committerOlivier Gayot <duskcoder@gmail.com>2015-10-10 11:28:13 +0200
commite885241b95d3784b5206fa6fbad7aa6861e8bd48 (patch)
tree58dd0173771433cd5125fece26e9143ff106e53e
parent59974248187229378f1df28b224a2d02e2d13fe4 (diff)
kfs: fixed printk
every character to be displayed on the screen is two bytes long, not one Signed-off-by: Olivier Gayot <duskcoder@gmail.com>
-rw-r--r--src/main.c12
1 files changed, 7 insertions, 5 deletions
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;
}