From a68503538b0f32554c6e1d5a1fb2bc11c79acb8f Mon Sep 17 00:00:00 2001 From: ngiddings Date: Mon, 19 Apr 2021 06:56:49 -0500 Subject: [PATCH] putc() advances lines when screen is full --- src/x86/putc.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/x86/putc.c b/src/x86/putc.c index fad6f72..bc510b5 100644 --- a/src/x86/putc.c +++ b/src/x86/putc.c @@ -35,6 +35,7 @@ size_t cursor = 0; const size_t tab_width = 4; const size_t line_width = 80; +const size_t line_count = 25; int initialize_screen() { @@ -62,6 +63,21 @@ int putchar(int c) screen[cursor].c = (char) c; cursor++; } + if(cursor >= line_count * line_width) + { + for(int i = 0; i < line_count * line_width; i++) + { + if(i < (line_count - 1) * line_width) + { + screen[i] = screen[i + line_width]; + } + else + { + screen[i].c = ' '; + } + } + cursor -= line_width; + } return c; }