From 46c231a4c591a6477e3ca9bcd9aa67d6a0813e1b Mon Sep 17 00:00:00 2001 From: "E. Almqvist" Date: Sun, 29 Aug 2021 13:20:35 +0200 Subject: [PATCH 1/4] printalign & alignment enum etc --- drivers/vga.c | 17 ++++++++++++++++- drivers/vga.h | 12 ++++++++++++ kernel/kernel.c | 11 ++++++++--- 3 files changed, 36 insertions(+), 4 deletions(-) diff --git a/drivers/vga.c b/drivers/vga.c index 2138ab7..545d71f 100644 --- a/drivers/vga.c +++ b/drivers/vga.c @@ -1,6 +1,7 @@ // VGA Graphics Library #include "vga.h" #include "../kernel/io.h" +#include "../lib/str.h" // Memory #define VGA_ADDRESS (char*)0xb8000 @@ -50,7 +51,7 @@ void set_cursor_pos(unsigned int col, unsigned int row) { void clear_screen() { for( int c = 0; c < MAX_COLS; c++ ) for( int r = 0; r < MAX_ROWS; r++ ) - writechar(0x20, c, r, 0x0f); + writechar(0x20, c, r, 0xf0); } /* @@ -66,4 +67,18 @@ void println(char* str, int attribute_byte) { cursor_row++; // Increment to next y-pos (newline) } +void printalign(char* str, int attribute_byte, enum align alignment) { + unsigned int strlenbuf = strlen(str); + + if( !alignment || alignment == LEFT ) { + print(str, attribute_byte); + } else if ( alignment == RIGHT ) { + set_cursor_pos(MAX_COLS - strlenbuf, cursor_row); + } else if ( alignment == MIDDLE ) { + set_cursor_pos((MAX_COLS/2) - (strlenbuf/2), cursor_row); + } + + print(str, attribute_byte); +} + diff --git a/drivers/vga.h b/drivers/vga.h index 983fb09..04306ae 100644 --- a/drivers/vga.h +++ b/drivers/vga.h @@ -1,7 +1,19 @@ +#define VGA_ADDRESS (char*)0xb8000 +#define VGA_ADDRESS_MAX (char*)0xb8fa0 + +#define MAX_ROWS 25 +#define MAX_COLS 80 + +static unsigned int cursor_row; +static unsigned int cursor_col; + +enum align {LEFT, RIGHT, MIDDLE}; + char* get_memory_charpos(unsigned int col, unsigned int row); void writechar(char c, unsigned int col, unsigned int row, int colorcode); void clear_screen(); void set_cursor_pos(); void print(); void println(); +void printalign(char* str, int attribute_byte, enum align alignment); void vga_init(); diff --git a/kernel/kernel.c b/kernel/kernel.c index 13aacf8..f59390f 100644 --- a/kernel/kernel.c +++ b/kernel/kernel.c @@ -6,13 +6,18 @@ void main() { vga_init(); // Initialize the screen first // i.e. clear the screen et cetera. - set_cursor_pos(28, 2); - print("eOS Version 0.1 2021", 0x0f); + char* title = "eOS Version 0.1 2021"; + set_cursor_pos(0, 2); + printalign(title, 0xf0, MIDDLE); + + char* subtitle = "A x86 operating system, licenced under GPL-2.0"; + set_cursor_pos(0, 3); + printalign(subtitle, 0xf8, MIDDLE); char* strbuf = "Hello"; char* str2 = "World!"; strbuf = strcat(strbuf, str2); set_cursor_pos(0, 0); - println(strbuf, 0x0f); + println(strbuf, 0xf0); } From d95dcc2e172b9d487eaabb18a68ec74accf62bde Mon Sep 17 00:00:00 2001 From: "E. Almqvist" Date: Sun, 29 Aug 2021 13:21:36 +0200 Subject: [PATCH 2/4] Change of string --- kernel/kernel.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/kernel/kernel.c b/kernel/kernel.c index f59390f..ad32614 100644 --- a/kernel/kernel.c +++ b/kernel/kernel.c @@ -15,8 +15,8 @@ void main() { printalign(subtitle, 0xf8, MIDDLE); - char* strbuf = "Hello"; - char* str2 = "World!"; + char* strbuf = "String concat: "; + char* str2 = "WORKS! :D"; strbuf = strcat(strbuf, str2); set_cursor_pos(0, 0); println(strbuf, 0xf0); From 3186c55451c38cbb032576fc5539cd89974d39c0 Mon Sep 17 00:00:00 2001 From: "E. Almqvist" Date: Sun, 29 Aug 2021 13:23:02 +0200 Subject: [PATCH 3/4] Cleanup --- drivers/vga.c | 7 ------- 1 file changed, 7 deletions(-) diff --git a/drivers/vga.c b/drivers/vga.c index 545d71f..959b491 100644 --- a/drivers/vga.c +++ b/drivers/vga.c @@ -3,13 +3,6 @@ #include "../kernel/io.h" #include "../lib/str.h" -// Memory -#define VGA_ADDRESS (char*)0xb8000 -#define VGA_ADDRESS_MAX (char*)0xb8fa0 - -#define MAX_ROWS 25 -#define MAX_COLS 80 - static unsigned int cursor_row = 0; static unsigned int cursor_col = 0; From bfe8e419df129daae95c07ad48c281620d1001be Mon Sep 17 00:00:00 2001 From: "E. Almqvist" Date: Sun, 29 Aug 2021 13:49:06 +0200 Subject: [PATCH 4/4] Preview update --- preview.png | Bin 1201 -> 3388 bytes 1 file changed, 0 insertions(+), 0 deletions(-) diff --git a/preview.png b/preview.png index 285c5d7dafa57d8a858398a7e6111f698a070d75..42cc7ae826d73de1d73b5532ecbeafa1d756d61a 100644 GIT binary patch literal 3388 zcmeHKSx}P+68?b|K_m>y075b{I)cjSDso9sK@mk14+4ZsK^+w&B$5LZ7!lnONrq)O zRs(SqcN7K)U?3!55QK0h%Ax^62zL;Y5E4lUxrTY)huy7t*($rLtE;-YzlZLwue*Od z9TI4|!Da&h0H#650?q({{r~{z`3e{}{V`16*b;|qrTGPGIng)n_6S0>;ug>fpopPt% zMxMzuM(quO>e(m9UQam!G?R5ME!%tAFWpSE-r864^KfVmv(o2*m3>uYoDMX_wf!7O z?bX-AZezwId;-NsxfCxfuigk8mfAa-Wnp9~O;KWnYDyyU-1zX6P@(hnbk>z9QhJ}b z*(bZQKQL;wzhz7`-&S6HJL%R_up2XIYwsXQ^hFW*Ya+mI0cV1t%O)G?T2?1aYj! zfL-C=@e=PyH@hsh2npsk6=;7Xu12_=JOuzR_Ni|K%4X!4l_;*Cxs)3pv0rhzXzN9O zBQWlnnbAGzw)q{Igi#v@@mFXAlTz-*-m`14sf+|KU1);Byulfvamw zIvyO5FSA`EXmBRq1DtuJRu_SjcGY6<|FGnC&BBmDjfPu#t}HXBA)O~;C|6ClI|*Cb z${Qf( z>#Jcs;BFTPunRx~z_)bsxoPI;MqFXq4?vi^`@8PSBWI$hsQlFlguy2AoFy42sSPT71dyceyU_9MOc0$x!X# zx0=V)6WMtQ>m`AhC%&xl1BY(o_JM^akIz~k#W{Qr8tOV?8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