From c2f857fc881fce55b335a0f8bf4f92503ecb253e Mon Sep 17 00:00:00 2001 From: Xnoe Date: Fri, 8 Apr 2022 00:49:26 +0100 Subject: [PATCH] Removed extra directories --- src/hello/hello.c | 40 ------ src/hello/hello.ld | 14 -- src/program/program.c | 20 --- src/program/program.ld | 14 -- src/world/world.c | 283 ----------------------------------------- src/world/world.ld | 14 -- 6 files changed, 385 deletions(-) delete mode 100644 src/hello/hello.c delete mode 100644 src/hello/hello.ld delete mode 100644 src/program/program.c delete mode 100644 src/program/program.ld delete mode 100644 src/world/world.c delete mode 100644 src/world/world.ld diff --git a/src/hello/hello.c b/src/hello/hello.c deleted file mode 100644 index b80c00f..0000000 --- a/src/hello/hello.c +++ /dev/null @@ -1,40 +0,0 @@ -#include "../common/common.h" - -void readline(int count, char* buffer) { - int index = 0; - char c; - while (index < count) { - if (read(1, 1, &c)) { - if (c == '\n') - break; - if (c == '\b') { - if (index == 0) - continue; - else { - index--; - buffer[index] = 0; - write(1, 0, &c); - continue; - } - } - - buffer[index++] = c; - write(1, 0, &c); - } - } - print("\n"); -} - -int main() { - print("Hello, World!\n"); - char buffer[32]; - while (1) { - for (int i=0; i<32; i++) - buffer[i] = 0; - print(">>> "); - readline(32, buffer); - print("You said: "); - print(buffer); - print("\n\n"); - } -} \ No newline at end of file diff --git a/src/hello/hello.ld b/src/hello/hello.ld deleted file mode 100644 index 1d78fe9..0000000 --- a/src/hello/hello.ld +++ /dev/null @@ -1,14 +0,0 @@ -OUTPUT_FORMAT(binary) -OUTPUT_ARCH(i386:i386) - -OUTPUT(build/hello/hello.bin) - -SECTIONS { - . = 0x20; - - .text : { - build/program_code_entry.o(.text) - build/hello/hello.o(.text) - build/common/common.o(.text) - } -} \ No newline at end of file diff --git a/src/program/program.c b/src/program/program.c deleted file mode 100644 index e220caf..0000000 --- a/src/program/program.c +++ /dev/null @@ -1,20 +0,0 @@ -#include "../kernel/types.h" -#include "../common/common.h" - -int main() { - print("Testing C code program\n"); - print("My strings are messed up for some reason...\n"); - - uint32_t alpha_size = filesize("HELLO TXT"); - char sizebuf[32]; - uint32_t index = int_to_decimal(alpha_size, sizebuf); - print(sizebuf+index); - print("\n"); - uint8_t* alpha_buffer = (uint8_t*)localalloc(alpha_size + 32); - print("alpha_buffer: "); - index = int_to_hex(alpha_buffer, sizebuf); - print(sizebuf+index); - print("\n"); - readfile("HELLO TXT", alpha_buffer); - print(alpha_buffer); -} \ No newline at end of file diff --git a/src/program/program.ld b/src/program/program.ld deleted file mode 100644 index 0bb6cb7..0000000 --- a/src/program/program.ld +++ /dev/null @@ -1,14 +0,0 @@ -OUTPUT_FORMAT(binary) -OUTPUT_ARCH(i386:i386) - -OUTPUT(build/program/program.bin) - -SECTIONS { - . = 0x20; - - .text : { - build/program_code_entry.o(.text) - build/program/program.o(.text) - build/common/common.o(.text) - } -} \ No newline at end of file diff --git a/src/world/world.c b/src/world/world.c deleted file mode 100644 index ab46aba..0000000 --- a/src/world/world.c +++ /dev/null @@ -1,283 +0,0 @@ -#include "../common/common.h" -#include - -typedef struct { - char* buffer; - int x; - int y; - uint32_t process; - uint32_t stdin; - uint32_t stdout; -} procbuffer; - -void scrollBuffer(char* buf) { - for (int y=0; y<56; y++) - for (int x=0; x<43; x++) - if (y != 55) - buf[y*43+x] = buf[(y+1)*43+x]; - else - buf[y*43+x] = ' '; -} - -void writeToBuf(char c, procbuffer* buf) { - switch (c) { - case '\n': - buf->x = 0; - buf->y++; - break; - - case '\b': - if (buf->x > 0) - buf->x--; - else if (buf->y > 0) { - buf->x = 42; - buf->y--; - } - buf->buffer[buf->y*43+buf->x] = ' '; - break; - - default: - buf->buffer[buf->y*43+buf->x++] = c; - } - if (buf->x == 43) { - buf->x = 0; - buf->y++; - } - if (buf->y == 56) { - buf->y--; - scrollBuffer(buf->buffer); - } -} - -void writeCountToBuf(int count, char* c, procbuffer* buf) { - while (count--) { - writeToBuf(*(c++), buf); - } -} - -void clearBuf(procbuffer* buf) { - for (int i=0; i<56*43;i++) { - buf->buffer[i] = ' '; - } - buf->x = 0; - buf->y = 0; -} - -void writeStrToBuf(char* c, procbuffer* b) { - char* s = c; - while(*s) - writeToBuf(*(s++), b); -} - -void displayBuf(procbuffer* b, int dx, int dy) { - char pset[9] = "\x1b[00;00H"; - for (int i=0; ibuffer+(43*i)); - pset[3]++; - if (pset[3] == 0x3a) { - pset[3] = 0x30; - pset[2]++; - } - } -} - -void setCurPos(int x, int y) { - char pset[9] = "\x1b[00;00H"; - for (int i=0; i\n", selectedBuf); - writeStrToBuf(" Loads and executes the program \n", selectedBuf); - writeStrToBuf("--------\n", selectedBuf); - } else if (strcmpcnt(4, buf, "kill")) { - if (selectedBuf->process) { - kill(selectedBuf->process); - clearBuf(selectedBuf); - selectedBuf->process = 0; - selectedBuf->stdin = 0; - selectedBuf->stdout = 0; - if (selectedBuf == &b1) { - selectedBuf = &b2; - } else { - selectedBuf = &b1; - } - } - } else if (strcmpcnt(4, buf, "load")) { - if (!selectedBuf->process) { - char* potFn = buf+5; - uint32_t fh = fopen(potFn); - selectedBuf->process = fork(fh); - selectedBuf->stdout = bindStdout(selectedBuf->process); - selectedBuf->stdin = bindStdin(selectedBuf->process); - fclose(fh); - } - } - } else { - if (selectedBuf->process) - write(1, selectedBuf->stdin, c); - } - } - - displayBuf(&b1, 2, 2); - displayBuf(&b2, 47, 2); - } -} \ No newline at end of file diff --git a/src/world/world.ld b/src/world/world.ld deleted file mode 100644 index 24586b1..0000000 --- a/src/world/world.ld +++ /dev/null @@ -1,14 +0,0 @@ -OUTPUT_FORMAT(binary) -OUTPUT_ARCH(i386:i386) - -OUTPUT(build/world/world.bin) - -SECTIONS { - . = 0x20; - - .text : { - build/program_code_entry.o(.text) - build/world/world.o(.text) - build/common/common.o(.text) - } -} \ No newline at end of file