diff --git a/boot/bin/boot.bin b/boot/bin/boot.bin index 1b58b24..876622b 100644 Binary files a/boot/bin/boot.bin and b/boot/bin/boot.bin differ diff --git a/boot/bin/kernel.bin b/boot/bin/kernel.bin index 6dc08c0..b246411 100644 Binary files a/boot/bin/kernel.bin and b/boot/bin/kernel.bin differ diff --git a/boot/bin/kernel.img b/boot/bin/kernel.img index 2a5b757..3a780d8 100644 Binary files a/boot/bin/kernel.img and b/boot/bin/kernel.img differ diff --git a/boot/bin/kernel.o b/boot/bin/kernel.o index 2cb5f1b..589e1e3 100644 Binary files a/boot/bin/kernel.o and b/boot/bin/kernel.o differ diff --git a/boot/boot.asm b/boot/boot.asm index ea84c96..0230920 100644 --- a/boot/boot.asm +++ b/boot/boot.asm @@ -64,7 +64,7 @@ section code mov bx, 0x1000 ; location of the code being loaded from the hard disk mov ah, 0x02 - mov al, 25 ; number of sectors to read from the hard disk + mov al, 31 ; number of sectors to read from the hard disk mov ch, 0x00 mov dh, 0x00 mov cl, 0x02 diff --git a/boot/input.c b/boot/input.c index 1ee9844..f355015 100644 --- a/boot/input.c +++ b/boot/input.c @@ -5,6 +5,11 @@ int left_clicked, right_clicked, middle_clicked; int current_byte = 0; uint8_t bytes[4] = {0}; +int Scancode = -1; + +#define TRUE 1 +#define FALSE 0 + #define pic1_command 0x20 #define pic1_data 0x21 #define pic2_command 0xa0 @@ -98,11 +103,11 @@ void RemapPIC() { } void HandleISR1() { - inportb(0x60); + Scancode = inportb(0x60); outportb(0xa0, 0x20); outportb(0x20, 0x20); - clearScreen(0, 0, 255); + // clearScreen(0, 0, 0); } void HandleMouseInterrupt(); @@ -202,7 +207,7 @@ void HandleMousePacket() { uint8_t status = bytes[0]; int32_t change_x = (int32_t) bytes[1]; int32_t change_y = (int32_t)bytes[2]; - int mouse_speed = 3; + int mouse_speed = 2; if (status & x_overflow || status & y_overflow) return; @@ -237,3 +242,349 @@ void HandleMousePacket() { else if (y > VBE->y_resolution) y = VBE->y_resolution; } + +int shift_pressed = FALSE; +int caps_pressed = FALSE; +int escape_pressed = FALSE; +int backspace_pressed = FALSE; +int alt_pressed = FALSE; +int ctrl_pressed = FALSE; +int enter_pressed = FALSE; + +unsigned char ProcessScancode(int scancode) +{ + if (scancode == 0x01) + escape_pressed = TRUE; + + else if (scancode == 0x02) + if (shift_pressed == TRUE) + return '!'; + else + return '1'; + + else if (scancode == 0x03) + if (shift_pressed == TRUE) + return '"'; + else + return '2'; + + else if (scancode == 0x04) + if (shift_pressed == TRUE) + return '#'; + else + return '3'; + + else if (scancode == 0x05) + if (shift_pressed == TRUE) + return '$'; + else + return '4'; + + else if (scancode == 0x06) + if (shift_pressed == TRUE) + return '%'; + else + return '5'; + + else if (scancode == 0x07) + if (shift_pressed == TRUE) + return '^'; + else + return '6'; + + else if (scancode == 0x08) + if (shift_pressed == TRUE) + return '&'; + else + return '7'; + + else if (scancode == 0x09) + if (shift_pressed == TRUE) + return '*'; + else + return '8'; + + else if (scancode == 0x0A) + if (shift_pressed == TRUE) + return '('; + else + return '9'; + + else if (scancode == 0x0B) + if (shift_pressed == TRUE) + return ')'; + else + return '0'; + + else if (scancode == 0x0C) + if (shift_pressed == TRUE) + return '_'; + else + return '-'; + + else if (scancode == 0x0D) + if (shift_pressed == TRUE) + return '+'; + else + return '='; + + // Backspace + else if (scancode == 0x0E) + backspace_pressed = TRUE; + + else if (scancode == 0x0F) + return '\t'; + + else if (scancode == 0x10) + if (shift_pressed == TRUE || caps_pressed == TRUE) + return 'Q'; + else + return 'q'; + + else if (scancode == 0x11) + if (shift_pressed == TRUE || caps_pressed == TRUE) + return 'W'; + else + return 'w'; + + else if (scancode == 0x12) + if (shift_pressed == TRUE || caps_pressed == TRUE) + return 'E'; + else + return 'e'; + + else if (scancode == 0x13) + if (shift_pressed == TRUE || caps_pressed == TRUE) + return 'R'; + else + return 'r'; + + else if (scancode == 0x14) + if (shift_pressed == TRUE || caps_pressed == TRUE) + return 'T'; + else + return 't'; + + else if (scancode == 0x15) + if (shift_pressed == TRUE || caps_pressed == TRUE) + return 'Y'; + else + return 'y'; + + else if (scancode == 0x16) + if (shift_pressed == TRUE || caps_pressed == TRUE) + return 'U'; + else + return 'u'; + + else if (scancode == 0x17) + if (shift_pressed == TRUE || caps_pressed == TRUE) + return 'I'; + else + return 'i'; + + else if (scancode == 0x18) + if (shift_pressed == TRUE || caps_pressed == TRUE) + return 'O'; + else + return 'o'; + + else if (scancode == 0x19) + if (shift_pressed == TRUE || caps_pressed == TRUE) + return 'P'; + else + return 'p'; + + else if (scancode == 0x1A) + if (shift_pressed == TRUE) + return '{'; + else + return '['; + + else if (scancode == 0x1B) + if (shift_pressed == TRUE) + return '}'; + else + return ']'; + + // enter pressed + else if (scancode == 0x1C) + { + enter_pressed = TRUE; + return '\n'; + } + + // ctrl pressed + else if (scancode == 0x1D) + ctrl_pressed = TRUE; + + else if (scancode == 0x1E) + if (shift_pressed == TRUE || caps_pressed == TRUE) + return 'A'; + else + return 'a'; + + else if (scancode == 0x1F) + if (shift_pressed == TRUE || caps_pressed == TRUE) + return 'S'; + else + return 's'; + + else if (scancode == 0x20) + if (shift_pressed == TRUE || caps_pressed == TRUE) + return 'D'; + else + return 'd'; + + else if (scancode == 0x21) + if (shift_pressed == TRUE || caps_pressed == TRUE) + return 'F'; + else + return 'f'; + + else if (scancode == 0x22) + if (shift_pressed == TRUE || caps_pressed == TRUE) + return 'G'; + else + return 'g'; + + else if (scancode == 0x23) + if (shift_pressed == TRUE || caps_pressed == TRUE) + return 'H'; + else + return 'h'; + + else if (scancode == 0x24) + if (shift_pressed == TRUE || caps_pressed == TRUE) + return 'J'; + else + return 'j'; + + else if (scancode == 0x25) + if (shift_pressed == TRUE || caps_pressed == TRUE) + return 'K'; + else + return 'k'; + + else if (scancode == 0x26) + if (shift_pressed == TRUE || caps_pressed == TRUE) + return 'L'; + else + return 'l'; + + else if (scancode == 0x27) + if (shift_pressed == TRUE) + return ':'; + else + return ';'; + + else if (scancode == 0x28) + if (shift_pressed == TRUE) + return '@'; + else + return '\''; + + else if (scancode == 0x29) + if (shift_pressed == TRUE) + return '~'; + else + return '`'; + + // shift pressed + else if (scancode == 0x2A) + shift_pressed = TRUE; + + else if (scancode == 0x2B) + if (shift_pressed == TRUE) + return '|'; + else + return '\\'; + + else if (scancode == 0x2C) + if (shift_pressed == TRUE || caps_pressed == TRUE) + return 'Z'; + else + return 'z'; + + else if (scancode == 0x2D) + if (shift_pressed == TRUE || caps_pressed == TRUE) + return 'X'; + else + return 'x'; + + else if (scancode == 0x2E) + if (shift_pressed == TRUE || caps_pressed == TRUE) + return 'C'; + else + return 'c'; + + else if (scancode == 0x2F) + if (shift_pressed == TRUE || caps_pressed == TRUE) + return 'V'; + else + return 'v'; + + else if (scancode == 0x30) + if (shift_pressed == TRUE || caps_pressed == TRUE) + return 'B'; + else + return 'b'; + + else if (scancode == 0x31) + if (shift_pressed == TRUE || caps_pressed == TRUE) + return 'N'; + else + return 'n'; + + else if (scancode == 0x32) + if (shift_pressed == TRUE || caps_pressed == TRUE) + return 'M'; + else + return 'm'; + + else if (scancode == 0x33) + if (shift_pressed == TRUE) + return '<'; + else + return ','; + + else if (scancode == 0x34) + if (shift_pressed == TRUE) + return '>'; + else + return '.'; + + else if (scancode == 0x35) + if (shift_pressed == TRUE) + return '?'; + else + return '/'; + + // shift pressed + else if (scancode == 0x36) + shift_pressed = TRUE; + + // alt pressed + else if (scancode == 0x38) + alt_pressed = TRUE; + + else if (scancode == 0x39) + return ' '; + + // Caps pressed + else if (scancode == 0x3A) + if (caps_pressed == TRUE) + caps_pressed = FALSE; + else if (caps_pressed == FALSE) + caps_pressed = TRUE; + + // shift released + if (scancode == 0xAA) + shift_pressed = FALSE; + + // shift released + if (scancode == 0xB6) + shift_pressed = FALSE; + + return '\0'; +} \ No newline at end of file diff --git a/boot/main.c b/boot/main.c index a03a956..7d8bc95 100644 --- a/boot/main.c +++ b/boot/main.c @@ -1,7 +1,7 @@ #include "graphics/graphics.h" int start() { - VBEInfoBlock *VBE = (VBEInfoBlock *)VBEInfoAddress; + VBEInfoBlock *VBE = (VBEInfoBlock*) VBEInfoAddress; x = VBE->x_resolution / 2; y = VBE->y_resolution / 2; @@ -10,6 +10,10 @@ int start() { char header[] = "Welcome to Wyvern OS!"; char *p = header; + char characterBuffer[1000] = "\0"; + char *characterBufferPointer = characterBuffer; + int characterBufferLength = 0; + base = (unsigned int) &isr1; base12 = (unsigned int) &isr12; @@ -17,16 +21,34 @@ int start() { InitializeMouse(); while (1) { - clearScreen(181.0f / 255.0f * 16.0f, 232.0f / 255.0f * 32.0f, 255.0f / 255.0f * 16.0f); + char c = ProcessScancode(Scancode); + + if (backspace_pressed == TRUE) + { + characterBuffer[characterBufferLength - 1] = '\0'; + characterBufferLength--; + backspace_pressed = FALSE; + Scancode = -1; + } + else if (c != '\0') + { + characterBuffer[characterBufferLength] = c; + characterBuffer[characterBufferLength + 1] = '\0'; + characterBufferLength++; + Scancode = -1; + } + + clearScreen(90.0f / 255.0f * 16.0f, 120.0f / 255.0f * 32.0f, 120.0f / 255.0f * 16.0f); DrawRect(150, 140, 350, 40, 0, 0, 0); DrawString(getArialCharacter, font_arial_width, font_arial_height, p, 240, 150, 255, 255, 255); + DrawString(getArialCharacter, font_arial_width, font_arial_height, characterBufferPointer, 240, 180, 255, 255, 255); DrawRect(300, 300, 50, 50, 20, 200, 50); DrawRect(325, 325, 50, 50, 200, 50, 50); // DrawRect(x, y, 10, 10, 0, 0, 0); - DrawMouse(x, y, 40.0, 100.0 / 255.0 * 32, 100.0 / 255.0 * 16); + DrawMouse(x, y, 50.0, 150.0 / 255.0 * 32, 150.0 / 255.0 * 16); Flush(); } diff --git a/os.img b/os.img index 82d79ee..dc015a3 100644 Binary files a/os.img and b/os.img differ