From 5c358d12e3108ef5a1f1c205a64b07d85f153b15 Mon Sep 17 00:00:00 2001
From: zayan <Mohamed3.Zayan@live.uwe.ac.uk>
Date: Wed, 6 Mar 2024 04:43:20 -0500
Subject: [PATCH] Final changes

---
 kernel.c | 41 +++++++++++++++++++++++++++++++++++------
 1 file changed, 35 insertions(+), 6 deletions(-)

diff --git a/kernel.c b/kernel.c
index 088d1bd..415e93a 100644
--- a/kernel.c
+++ b/kernel.c
@@ -88,7 +88,21 @@ void terminal_putchar(char c) {
 	if (c == '\n'){
 		terminal_column = 0;
 		if (++terminal_row == VGA_HEIGHT){
-			terminal_row = 0;
+			/*terminal_row = 0;*/
+			terminal_row = VGA_HEIGHT - 1;
+			/*Perform scrolling by moving each row up by one*/
+			for (size_t y = 1;y < VGA_HEIGHT; y++){
+				for (size_t x = 0; x < VGA_WIDTH; x++){
+					size_t prev_index = (y - 1) * VGA_WIDTH + x;
+					size_t curr_index = y * VGA_WIDTH + x;
+					terminal_buffer[prev_index] = terminal_buffer[curr_index];
+}
+}
+			/*Clear the last row*/
+			size_t last_row_index = (VGA_HEIGHT - 1) * VGA_WIDTH;
+			for (size_t x = 0; x < VGA_WIDTH; x++) {
+			terminal_buffer[last_row_index + x] = make_vgaentry(' ',terminal_color);
+}
 }
 
 }else{
@@ -122,11 +136,26 @@ void kernel_main() {
    * This is normal.
    */
 
-/*Output "Hello World" in blue */
-terminal_setcolor(make_color(COLOR_BLUE, COLOR_BLACK));
-terminal_writestring("Hello, kernel World!\n");
-
-/*Output "Hello World" in red */
+/*Outputs "Hello World" in red once */
 terminal_setcolor(make_color(COLOR_RED, COLOR_BLACK));
 terminal_writestring("Hello, kernel World!\n");
+
+/*Outputs "Hello World" in white 6 times */
+terminal_setcolor(make_color(COLOR_WHITE, COLOR_BLACK));
+for (int i = 0; i < 6; i++){
+	terminal_writestring("Hello, kernel World!\n");
+}
+
+/*Outputs "Hello World" in blue 18 times */
+terminal_setcolor(make_color(COLOR_BLUE, COLOR_BLACK));
+for (int i = 0; i < 18; i++){
+	terminal_writestring("Hello, kernel World!\n");
+}
+
+/*Outputs "Hello World" in green 5 times */
+terminal_setcolor(make_color(COLOR_GREEN, COLOR_BLACK));
+for (int i = 0; i < 5; i++){
+	terminal_writestring("Hello, kernel World!\n");
+}
+
 }
-- 
GitLab