mirror of https://github.com/E-Almqvist/eOS
commit
cd57cc46c0
@ -1,15 +1,18 @@ |
||||
#include "../drivers/vga.h" |
||||
#include "../lib/str.h" |
||||
#include "../lib/strf.h" |
||||
|
||||
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", 0xf0); |
||||
print("eOS Version 0.1 2021", 0x0f); |
||||
|
||||
/*
|
||||
|
||||
char* strbuf = "Hello"; |
||||
char* str2 = "World!"; |
||||
strbuf = strcat(strbuf, str2);
|
||||
set_cursor_pos(0, 0); |
||||
for( int i = 0; i < 255; i++ ) |
||||
println("X", i); |
||||
*/ |
||||
println(strbuf, 0x0f); |
||||
} |
||||
|
@ -0,0 +1 @@ |
||||
#include "memory.h" |
@ -0,0 +1,2 @@ |
||||
char* malloc(unsigned int size); |
||||
void mfree(char* p); |
@ -0,0 +1,28 @@ |
||||
#include "str.h" |
||||
|
||||
unsigned int strlen(char* str) { |
||||
unsigned int len = 0; |
||||
for( char* c = str; *c != '\0'; c++ ) // search for end-of-string
|
||||
len++; |
||||
|
||||
return len; |
||||
} |
||||
|
||||
char* strcat(char* buf, char* str) { |
||||
unsigned int bufferlen = strlen(buf); |
||||
|
||||
// remove the 0x0 char from the buffer
|
||||
*(buf + bufferlen) = 0x3f; // replace end-of-string
|
||||
// with a placeholder
|
||||
|
||||
// concat the str to buf
|
||||
int cc = 0; |
||||
for( char* c = str; *c != '\0'; c++ ) { |
||||
*(buf + bufferlen + cc) = *c; |
||||
cc++; |
||||
} |
||||
|
||||
*(buf + bufferlen + cc) = '\0'; // add end-of-string
|
||||
|
||||
return buf; |
||||
} |
@ -0,0 +1,2 @@ |
||||
unsigned int strlen(char* str); |
||||
char* strcat(char* buf, char* str); |
@ -0,0 +1,15 @@ |
||||
#include "strf.h" |
||||
|
||||
#define int_offset 48 |
||||
// 0:48 - 9:57
|
||||
|
||||
char* int_to_str(int i, char* strbuf) { |
||||
if( i == 0 ) { |
||||
return (char*)(int_offset); |
||||
} else { |
||||
char cbuf; |
||||
cbuf = (char)((i % 10) + int_offset); |
||||
|
||||
return int_to_str(i / 10, strbuf + cbuf); |
||||
} |
||||
} |
@ -0,0 +1 @@ |
||||
char* int_to_str(int i, char* strbuf); |
Loading…
Reference in new issue