1
+ #include <stddef.h>
2
+ #include <stdint.h>
3
+
4
+ #if defined(__linux__ )
5
+ #error "This code must be compiled with a cross-compiler"
6
+ #elif !defined(__i386__ )
7
+ #error "This code must be compiled with an x86-elf compiler"
8
+ #endif
9
+
10
+ volatile uint16_t * vga_buffer = (uint16_t * )0xB8000 ;
11
+ const int VGA_COLS = 80 ;
12
+ const int VGA_ROWS = 24 ;
13
+
14
+ int term_col = 0 ;
15
+ int term_row = 0 ;
16
+ uint8_t term_color = 0x1F ;
17
+
18
+ void term_init () {
19
+ for (int col = 0 ; col < VGA_COLS ; col ++ ) {
20
+ for (int row = 0 ; row < VGA_ROWS ; row ++ ) {
21
+ const size_t index = (VGA_COLS * row ) + col ;
22
+ vga_buffer [index ] = ((uint16_t )term_color << 8 ) | ' ' ;
23
+ }
24
+ }
25
+ }
26
+
27
+ void term_putc (char c ) {
28
+ switch (c ) {
29
+ case '\n' :
30
+ {
31
+ term_col = 0 ;
32
+ term_row ++ ;
33
+ break ;
34
+ }
35
+
36
+ default :
37
+ {
38
+ const size_t index = (VGA_COLS * term_row ) + term_col ;
39
+ vga_buffer [index ] = ((uint16_t )term_color << 8 ) | c ;
40
+ term_col ++ ;
41
+ break ;
42
+ }
43
+ }
44
+
45
+ if (term_col >= VGA_COLS ) {
46
+ term_col = 0 ;
47
+ term_row ++ ;
48
+ }
49
+
50
+ if (term_row >= VGA_ROWS ) {
51
+ term_col = 0 ;
52
+ term_row = 0 ;
53
+ }
54
+ }
55
+
56
+ void term_setpos (int col , int row ) {
57
+ term_col = col ;
58
+ term_row = row ;
59
+ }
60
+
61
+ void term_setbg (uint8_t color ) {
62
+ term_color = color ;
63
+ }
64
+
65
+ void term_print (const char * str ) {
66
+ for (size_t i = 0 ; str [i ] != '\0' ; i ++ ) {
67
+ term_putc (str [i ]);
68
+ }
69
+ }
70
+
71
+ void kernel_main () {
72
+ term_init ();
73
+ term_print ("\n" );
74
+ term_print (" BluDood Inc. BluShell Kernel 1.0 Setup\n" );
75
+ term_print (" ============================" );
76
+ term_setbg (0xF0 );
77
+ for (int i = 0 ; i <= 80 ; i ++ ) {
78
+ term_setpos (i , VGA_ROWS );
79
+ if (i == 60 ) {
80
+ term_print ("|" );
81
+ } else {
82
+ term_print (" " );
83
+ }
84
+ }
85
+ const char * bottom = "stay sussy" ;
86
+ for (size_t i = 0 ; bottom [i ] != '\0' ; i ++ ) {
87
+ term_setpos (i , VGA_ROWS );
88
+ term_putc (bottom [i ]);
89
+ }
90
+ term_setbg (0x1F );
91
+ term_setpos (3 , 4 );
92
+ term_print ("Welcome to Setup." );
93
+ term_setpos (3 , 6 );
94
+ term_print ("The Setup program prepared BluDood Inc. BluShell 1.0 to" );
95
+ term_setpos (3 , 7 );
96
+ term_print ("run on your computer." );
97
+ term_setpos (5 , 9 );
98
+ term_print (" * To set up BluShell now, press Enter." );
99
+ term_setpos (5 , 11 );
100
+ term_print (" * To learn more about Setup before continuingm press F1." );
101
+ term_setpos (5 , 13 );
102
+ term_print (" * To quit Setup without installing BluShell, press F3." );
103
+ term_setpos (3 , 15 );
104
+ term_print ("Note: BluShell is not functional. Nothing works :troll:" );
105
+ term_setpos (3 , 17 );
106
+ term_print ("Socials:" );
107
+ term_setpos (5 , 19 );
108
+ term_print (
"Email: [email protected] " );
109
+ term_setpos (5 , 21 );
110
+ term_print ("Twitter: @ItsBluDood" );
111
+ }
0 commit comments