From 599af82d6d264c84118cd9407dd03323f0a1cb38 Mon Sep 17 00:00:00 2001
From: Christian Cunningham <cc@localhost>
Date: Thu, 23 Dec 2021 14:35:38 -0800
Subject: Added Graphics Initialization Output

---
 src/cpu/irq.c      |  6 ++++--
 src/graphics/lfb.c |  3 ++-
 src/graphics/lfb.h |  4 ++++
 src/sys/core.c     | 27 +++++++++++++++++++++------
 src/sys/timer.c    |  4 ++--
 5 files changed, 33 insertions(+), 11 deletions(-)

(limited to 'src')

diff --git a/src/cpu/irq.c b/src/cpu/irq.c
index a6ed5e4..1329534 100644
--- a/src/cpu/irq.c
+++ b/src/cpu/irq.c
@@ -44,8 +44,9 @@ void c_irq_handler(void) {
 					if (off < 2048) {
 						// Newline Case
 						if (data == 0x0D) {
+							for(int i = off; i>=0;i--)
+								cmd[i] = 0x0;
 							off = 0;
-							cmd[0] = 0x0;
 						// Backspace Case
 						} else if (data == 0x08 || data == 0x7F) {
 							if (off > 0) {
@@ -69,8 +70,9 @@ void c_irq_handler(void) {
 						}
 					} else if (off == 2048) {
 						if (data == 0x0D) {
+							for(int i = off; i>=0;i--)
+								cmd[i] = 0x0;
 							off = 0;
-							cmd[0] = 0x0;
 						} else if (data == 0x08 || data == 0x7F) {
 							if (off > 0) {
 								off -= 1;
diff --git a/src/graphics/lfb.c b/src/graphics/lfb.c
index 5e307f4..5494dde 100644
--- a/src/graphics/lfb.c
+++ b/src/graphics/lfb.c
@@ -4,6 +4,7 @@
 #include "../graphics/homer.h"
 #include "../graphics/glyphs.h"
 
+#define GRAPHICS_LFB_C
 unsigned int width, height, pitch, isrgb;   /* dimensions and channel order */
 unsigned char *lfb;                         /* raw frame buffer address */
 
@@ -79,7 +80,7 @@ void lfb_showpicture()
 	unsigned char *ptr=lfb;
 	char *data=homer_data, pixel[4];
 
-	ptr += (height-homer_height)/2*pitch + (width-homer_width)*2;
+	ptr = lfb + (height-homer_height)*pitch + (width-homer_width)*4;
 	for(y=0;y<homer_height;y++) {
 		for(x=0;x<homer_width;x++) {
 			HEADER_PIXEL(data, pixel);
diff --git a/src/graphics/lfb.h b/src/graphics/lfb.h
index ac2e284..2361ec4 100644
--- a/src/graphics/lfb.h
+++ b/src/graphics/lfb.h
@@ -4,6 +4,10 @@
 #define GG_MAX_X 128
 #define GG_MAX_Y 96
 
+#ifndef GRAPHICS_LFB_C
+extern unsigned int width, height, pitch, isrgb;   /* dimensions and channel order */
+#endif
+
 void lfb_init();
 void lfb_showpicture();
 
diff --git a/src/sys/core.c b/src/sys/core.c
index f5d7ca1..929c7a5 100644
--- a/src/sys/core.c
+++ b/src/sys/core.c
@@ -10,8 +10,6 @@
 #include "../sys/timer.h"
 #include "../sys/power.h"
 
-//extern void init_graphics(void);
-
 #ifndef VERSION
 char* os_info_v = "?";
 #else
@@ -85,6 +83,7 @@ void output_irq_status(void) {
 	} else {
 		write_cstring(&g_Drawer, "Disabled", 0xFF0000);
 	}
+
 	// Check TIMER IRQ
 	write_string(&g_Drawer, "\nTIMER: ");
 	if (ib_val & (1<<0)) {
@@ -104,8 +103,8 @@ void output_irq_status(void) {
 void postinit() {
 	// OS Info
 	write_cstring(&g_Drawer, "DendritOS", 0xFF0000);
-	write_cstring(&g_Drawer, " v", 0x00FF00);
-	write_cstring(&g_Drawer, os_info_v, 0x00FF00);
+	write_cstring(&g_Drawer, " v", 0x00FFFF);
+	write_cstring(&g_Drawer, os_info_v, 0x00FFFF);
 	write_string(&g_Drawer, " #");
 	if (lock_mutex(&exe_cnt_m, SYS_PID) == 0) {
 		write_10(&g_Drawer, *(exe_cnt_m.addr));
@@ -114,10 +113,26 @@ void postinit() {
 	// Commands
 	write_string(&g_Drawer, "\nMonitor Ctrl-A m  Exit: Ctrl-A x");
 	write_string(&g_Drawer, "\nTimer: Ctrl-T");
-	// Timer Status
-	//uart_string("Timer: \033[92mEnabled\033[0m");
+
 	// GPU IRQ Statuses
 	write_string(&g_Drawer, "\n");
 	output_irq_status();
 	write_string(&g_Drawer, "\n> ");
+
+	unsigned int x = g_Drawer.x;
+	unsigned int y = g_Drawer.y;
+	g_Drawer.x = 0;
+	g_Drawer.y = 12;
+	write_string(&g_Drawer, "VIDEO: ");
+	write_cstring(&g_Drawer, "Enabled ", 0x00FF00);
+	write_10(&g_Drawer, width);
+	write_string(&g_Drawer, "x");
+	write_10(&g_Drawer, height);
+	if(isrgb) {
+		write_string(&g_Drawer, " RGB");
+	} else {
+		write_string(&g_Drawer, " BGR");
+	}
+	g_Drawer.x = x;
+	g_Drawer.y = y;
 }
diff --git a/src/sys/timer.c b/src/sys/timer.c
index 8e333c4..b82ac2c 100644
--- a/src/sys/timer.c
+++ b/src/sys/timer.c
@@ -24,8 +24,8 @@ void c_timer() {
 	if (lock_mutex(&exe_cnt_m, SCHED_PID) == 0) {
 		*(exe_cnt_m.addr) += 1;
 		write_cstring(&g_Drawer, "DendritOS", 0xFF0000);
-		write_cstring(&g_Drawer, " v", 0x00FF00);
-		write_cstring(&g_Drawer, os_info_v, 0x00FF00);
+		write_cstring(&g_Drawer, " v", 0x00FFFF);
+		write_cstring(&g_Drawer, os_info_v, 0x00FFFF);
 		write_string(&g_Drawer, " #");
 		write_10(&g_Drawer, *(exe_cnt_m.addr));
 		release_mutex(&exe_cnt_m, SCHED_PID);
-- 
cgit v1.2.1