From f0ae0c7c36daa977c3a0edf9ad2983aa465854f7 Mon Sep 17 00:00:00 2001 From: Morten Delenk Date: Sun, 29 May 2016 08:30:53 +0200 Subject: [PATCH] Added a 128x96 Textmode renderer using 8x8 tiles on an 1024x768 SVGA screen. You can change resolution by modifying boot.S and textDISP.hpp --- kernel/hal/x86/blk/BlockDevice.cpp | 2 +- kernel/hal/x86/blk/ide.cpp | 2 +- kernel/hal/x86/boot/boot.S | 5 +- kernel/hal/x86/c_include/multiboot.h | 39 +++- kernel/hal/x86/c_include/stdfnt.h | 260 +++++++++++++++++++++++++++ kernel/hal/x86/c_include/string.h | 1 + kernel/hal/x86/include/base.hpp | 4 +- kernel/hal/x86/include/textDISP.hpp | 78 ++++---- kernel/hal/x86/init/init.cpp | 2 + kernel/hal/x86/io/serial.cpp | 4 +- kernel/hal/x86/io/textDISP.cpp | 51 +++++- kernel/hal/x86/string.c | 13 ++ kernel/kernel/include/syscall.hpp | 64 +++---- std.fnt | Bin 0 -> 8199 bytes test.elf | Bin 0 -> 18560 bytes user/include/mtgos.hpp | 67 +++---- user/mtgos.cpp | 17 +- user/test.cpp | 3 +- 18 files changed, 488 insertions(+), 124 deletions(-) create mode 100644 kernel/hal/x86/c_include/stdfnt.h create mode 100644 std.fnt create mode 100755 test.elf diff --git a/kernel/hal/x86/blk/BlockDevice.cpp b/kernel/hal/x86/blk/BlockDevice.cpp index dfba2a6..ab57e86 100644 --- a/kernel/hal/x86/blk/BlockDevice.cpp +++ b/kernel/hal/x86/blk/BlockDevice.cpp @@ -20,7 +20,7 @@ namespace MTGosHAL { BlockDevice::BlockDevice(): numDevices(0), ata0(0x1F0,0), ata1(0x170,1), ata2(0x1E8,2), ata3(0x168,3) { if(getDriveCnt()==0) { - err<<"Not a single device was found!\n"; + //err<<"Not a single device was found!\n"; } } auto BlockDevice::getDriveCnt() -> int32_t {return ata0.getDriveCnt()+ata1.getDriveCnt()+ata2.getDriveCnt()+ata3.getDriveCnt();} diff --git a/kernel/hal/x86/blk/ide.cpp b/kernel/hal/x86/blk/ide.cpp index 5ed31ec..bdb2b4e 100644 --- a/kernel/hal/x86/blk/ide.cpp +++ b/kernel/hal/x86/blk/ide.cpp @@ -36,7 +36,7 @@ namespace MTGosHAL { numDevices++; } } else { - err << "ATA device could not be found!\n"; + //err << "ATA device could not be found!\n"; } outb(baseport+ALTCMD,0x40); inb(baseport+CMD); diff --git a/kernel/hal/x86/boot/boot.S b/kernel/hal/x86/boot/boot.S index 05f6263..413b4c1 100644 --- a/kernel/hal/x86/boot/boot.S +++ b/kernel/hal/x86/boot/boot.S @@ -1,11 +1,14 @@ .section multiboot #define MB_MAGIC 0x1BADB002 -#define MB_FLAGS 0x0 +#define MB_FLAGS 0x7 #define MB_CHECKSUM -(MB_MAGIC + MB_FLAGS) .align 4 .int MB_MAGIC .int MB_FLAGS .int MB_CHECKSUM +.int 0,0,0,0,0 +.int 0 +.int 1024, 768, 32 .section .text .extern init .global _start diff --git a/kernel/hal/x86/c_include/multiboot.h b/kernel/hal/x86/c_include/multiboot.h index b5c1bce..93b1454 100644 --- a/kernel/hal/x86/c_include/multiboot.h +++ b/kernel/hal/x86/c_include/multiboot.h @@ -268,7 +268,42 @@ struct multiboot_apm_info multiboot_uint16_t cseg_16_len; multiboot_uint16_t dseg_len; }; - +struct MODE_INFO +{ + unsigned short ModeAttributes ; + unsigned char WinAAttributes ; + unsigned char WinBAttributes ; + unsigned short WinGranularity ; + unsigned short WinSize ; + unsigned short WinASegment ; + unsigned short WinBSegment ; + unsigned int WinFuncPtr ; + unsigned short BytesPerScanLine ; + unsigned short XResolution ; + unsigned short YResolution ; + unsigned char XCharSize ; + unsigned char YCharSize ; + unsigned char NumberOfPlanes ; + unsigned char BitsPerPixel ; + unsigned char NumberOfBanks ; + unsigned char MemoryModel ; + unsigned char BankSize ; + unsigned char NumberOfImagePages ; + unsigned char Reserved_page ; + unsigned char RedMaskSize ; + unsigned char RedMaskPos ; + unsigned char GreenMaskSize ; + unsigned char GreenMaskPos ; + unsigned char BlueMaskSize ; + unsigned char BlueMaskPos ; + unsigned char ReservedMaskSize ; + unsigned char ReservedMaskPos ; + unsigned char DirectColorModeInfo ; + unsigned int PhysBasePtr ; + unsigned int OffScreenMemOffset ; + unsigned short OffScreenMemSize ; + unsigned char Reserved[206] ; +}__attribute__ ((packed)); #endif /* ! ASM_FILE */ -#endif /* ! MULTIBOOT_HEADER */ \ No newline at end of file +#endif /* ! MULTIBOOT_HEADER */ diff --git a/kernel/hal/x86/c_include/stdfnt.h b/kernel/hal/x86/c_include/stdfnt.h new file mode 100644 index 0000000..2539d9b --- /dev/null +++ b/kernel/hal/x86/c_include/stdfnt.h @@ -0,0 +1,260 @@ +//Thanks to masterq32 for this font! +//You should check out his OS project (https://github.com/MasterQ32/DasOS) +uint8_t font[256][8] = { + { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }, // ? + { 0x00, 0x00, 0x0D, 0x12, 0x12, 0x09, 0x09, 0x00 }, // ? + { 0x00, 0x00, 0x11, 0x11, 0x11, 0x19, 0x16, 0x00 }, // ? + { 0x00, 0x00, 0x11, 0x11, 0x0A, 0x0A, 0x04, 0x00 }, // ? + { 0x00, 0x00, 0x11, 0x11, 0x15, 0x15, 0x0A, 0x00 }, // ? + { 0x00, 0x02, 0x06, 0x0E, 0x06, 0x02, 0x00, 0x00 }, // ? + { 0x04, 0x0E, 0x1F, 0x0E, 0x0E, 0x00, 0x00, 0x00 }, // ? + { 0x00, 0x00, 0x0E, 0x0E, 0x1F, 0x0E, 0x04, 0x00 }, // ? + { 0x08, 0x14, 0x04, 0x04, 0x04, 0x05, 0x02, 0x00 }, // ? + { 0x00, 0x11, 0x0A, 0x04, 0x0A, 0x11, 0x00, 0x00 }, // ? + { 0x00, 0x00, 0x00, 0x0E, 0x0A, 0x0E, 0x00, 0x00 }, // ? + { 0x00, 0x00, 0x00, 0x04, 0x0E, 0x04, 0x00, 0x00 }, // ? + { 0x00, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00 }, // ? + { 0x00, 0x00, 0x00, 0x07, 0x02, 0x02, 0x02, 0x00 }, // ? + { 0x06, 0x08, 0x06, 0x08, 0x06, 0x00, 0x00, 0x00 }, // ? + { 0x1F, 0x03, 0x03, 0x0F, 0x03, 0x03, 0x03, 0x00 }, // ? + { 0x1C, 0x04, 0x04, 0x04, 0x05, 0x06, 0x04, 0x00 }, // ? + { 0x18, 0x10, 0x13, 0x10, 0x10, 0x00, 0x00, 0x00 }, // ? + { 0x06, 0x08, 0x04, 0x02, 0x0E, 0x00, 0x00, 0x00 }, // ? + { 0x00, 0x00, 0x10, 0x08, 0x04, 0x02, 0x1F, 0x00 }, // ? + { 0x06, 0x09, 0x09, 0x06, 0x00, 0x00, 0x00, 0x00 }, // ? + { 0x0D, 0x03, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00 }, // ? + { 0x0E, 0x04, 0x04, 0x04, 0x04, 0x00, 0x00, 0x00 }, // ? + { 0x10, 0x0C, 0x03, 0x0C, 0x10, 0x00, 0x1F, 0x00 }, // ? + { 0x08, 0x08, 0x1F, 0x04, 0x1F, 0x02, 0x02, 0x00 }, // ? + { 0x01, 0x06, 0x18, 0x06, 0x01, 0x00, 0x1F, 0x00 }, // ? + { 0x00, 0x00, 0x1C, 0x00, 0x00, 0x00, 0x00, 0x00 }, // ? + { 0x00, 0x00, 0x1E, 0x02, 0x0E, 0x02, 0x1E, 0x00 }, // ? + { 0x00, 0x04, 0x08, 0x1F, 0x08, 0x04, 0x00, 0x00 }, // ? + { 0x00, 0x00, 0x1D, 0x15, 0x15, 0x15, 0x1D, 0x00 }, // ? + { 0x04, 0x0E, 0x15, 0x04, 0x04, 0x04, 0x04, 0x00 }, // ? + { 0x04, 0x04, 0x04, 0x04, 0x15, 0x0E, 0x04, 0x00 }, // ? + { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }, // + { 0x04, 0x04, 0x04, 0x04, 0x00, 0x04, 0x04, 0x00 }, // ! + { 0x0A, 0x0A, 0x0A, 0x00, 0x00, 0x00, 0x00, 0x00 }, // " + { 0x0A, 0x0A, 0x1F, 0x0A, 0x1F, 0x0A, 0x0A, 0x00 }, // # + { 0x02, 0x0A, 0x0E, 0x08, 0x08, 0x00, 0x00, 0x00 }, // $ + { 0x03, 0x13, 0x08, 0x04, 0x02, 0x19, 0x18, 0x00 }, // % + { 0x02, 0x05, 0x05, 0x02, 0x15, 0x09, 0x16, 0x00 }, // & + { 0x04, 0x04, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00 }, // ' + { 0x08, 0x04, 0x02, 0x02, 0x02, 0x04, 0x08, 0x00 }, // ( + { 0x02, 0x04, 0x08, 0x08, 0x08, 0x04, 0x02, 0x00 }, // ) + { 0x00, 0x04, 0x15, 0x0E, 0x15, 0x04, 0x00, 0x00 }, // * + { 0x00, 0x04, 0x04, 0x1F, 0x04, 0x04, 0x00, 0x00 }, // + + { 0x00, 0x00, 0x00, 0x00, 0x06, 0x04, 0x02, 0x00 }, // , + { 0x00, 0x00, 0x00, 0x1F, 0x00, 0x00, 0x00, 0x00 }, // - + { 0x00, 0x00, 0x00, 0x00, 0x00, 0x06, 0x06, 0x00 }, // . + { 0x00, 0x10, 0x08, 0x04, 0x02, 0x01, 0x00, 0x00 }, // / + { 0x0E, 0x11, 0x19, 0x15, 0x13, 0x11, 0x0E, 0x00 }, // 0 + { 0x04, 0x06, 0x04, 0x04, 0x04, 0x04, 0x0E, 0x00 }, // 1 + { 0x0E, 0x11, 0x10, 0x08, 0x04, 0x02, 0x1F, 0x00 }, // 2 + { 0x1F, 0x08, 0x04, 0x08, 0x10, 0x11, 0x0E, 0x00 }, // 3 + { 0x08, 0x0C, 0x0A, 0x09, 0x1F, 0x08, 0x08, 0x00 }, // 4 + { 0x1F, 0x01, 0x0F, 0x10, 0x10, 0x11, 0x0E, 0x00 }, // 5 + { 0x0C, 0x02, 0x01, 0x0F, 0x11, 0x11, 0x0E, 0x00 }, // 6 + { 0x1F, 0x10, 0x08, 0x04, 0x02, 0x02, 0x02, 0x00 }, // 7 + { 0x0E, 0x11, 0x11, 0x0E, 0x11, 0x11, 0x0E, 0x00 }, // 8 + { 0x0E, 0x11, 0x11, 0x1E, 0x10, 0x08, 0x06, 0x00 }, // 9 + { 0x00, 0x06, 0x06, 0x00, 0x06, 0x06, 0x00, 0x00 }, // : + { 0x00, 0x06, 0x06, 0x00, 0x06, 0x04, 0x02, 0x00 }, // ; + { 0x08, 0x04, 0x02, 0x01, 0x02, 0x04, 0x08, 0x00 }, // < + { 0x00, 0x00, 0x1F, 0x00, 0x1F, 0x00, 0x00, 0x00 }, // = + { 0x02, 0x04, 0x08, 0x10, 0x08, 0x04, 0x02, 0x00 }, // > + { 0x0E, 0x11, 0x10, 0x08, 0x04, 0x00, 0x04, 0x00 }, // ? + { 0x0E, 0x11, 0x15, 0x1D, 0x05, 0x01, 0x1E, 0x00 }, // @ + { 0x0E, 0x11, 0x11, 0x1F, 0x11, 0x11, 0x11, 0x00 }, // A + { 0x0F, 0x11, 0x11, 0x0F, 0x11, 0x11, 0x0F, 0x00 }, // B + { 0x0E, 0x11, 0x01, 0x01, 0x01, 0x11, 0x0E, 0x00 }, // C + { 0x0F, 0x11, 0x11, 0x11, 0x11, 0x11, 0x0F, 0x00 }, // D + { 0x1F, 0x01, 0x01, 0x0F, 0x01, 0x01, 0x1F, 0x00 }, // E + { 0x1F, 0x01, 0x01, 0x0F, 0x01, 0x01, 0x01, 0x00 }, // F + { 0x0E, 0x11, 0x01, 0x1D, 0x11, 0x11, 0x1E, 0x00 }, // G + { 0x11, 0x11, 0x11, 0x1F, 0x11, 0x11, 0x11, 0x00 }, // H + { 0x0E, 0x04, 0x04, 0x04, 0x04, 0x04, 0x0E, 0x00 }, // I + { 0x1C, 0x08, 0x08, 0x08, 0x08, 0x09, 0x06, 0x00 }, // J + { 0x11, 0x09, 0x05, 0x03, 0x05, 0x09, 0x11, 0x00 }, // K + { 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x1F, 0x00 }, // L + { 0x11, 0x1B, 0x15, 0x15, 0x11, 0x11, 0x11, 0x00 }, // M + { 0x11, 0x11, 0x13, 0x15, 0x19, 0x11, 0x11, 0x00 }, // N + { 0x0E, 0x11, 0x11, 0x11, 0x11, 0x11, 0x0E, 0x00 }, // O + { 0x0F, 0x11, 0x11, 0x0F, 0x01, 0x01, 0x01, 0x00 }, // P + { 0x0E, 0x11, 0x11, 0x11, 0x15, 0x09, 0x16, 0x00 }, // Q + { 0x0F, 0x11, 0x11, 0x0F, 0x05, 0x09, 0x11, 0x00 }, // R + { 0x1E, 0x01, 0x01, 0x0E, 0x10, 0x10, 0x0F, 0x00 }, // S + { 0x1F, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x00 }, // T + { 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x0E, 0x00 }, // U + { 0x11, 0x11, 0x11, 0x11, 0x0A, 0x0A, 0x04, 0x00 }, // V + { 0x11, 0x11, 0x11, 0x15, 0x15, 0x15, 0x0A, 0x00 }, // W + { 0x11, 0x11, 0x0A, 0x04, 0x0A, 0x11, 0x11, 0x00 }, // X + { 0x11, 0x11, 0x11, 0x0A, 0x04, 0x04, 0x04, 0x00 }, // Y + { 0x1F, 0x10, 0x08, 0x04, 0x02, 0x01, 0x1F, 0x00 }, // Z + { 0x0C, 0x12, 0x11, 0x1F, 0x11, 0x09, 0x06, 0x00 }, // [ + { 0x00, 0x01, 0x02, 0x04, 0x08, 0x10, 0x00, 0x00 }, // \d + { 0x06, 0x04, 0x04, 0x04, 0x04, 0x04, 0x06, 0x00 }, // ] + { 0x04, 0x0A, 0x11, 0x00, 0x00, 0x00, 0x00, 0x00 }, // ^ + { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1F, 0x00 }, // _ + { 0x04, 0x04, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00 }, // ` + { 0x00, 0x00, 0x0E, 0x10, 0x1E, 0x11, 0x1E, 0x00 }, // a + { 0x01, 0x01, 0x0D, 0x13, 0x11, 0x11, 0x0F, 0x00 }, // b + { 0x00, 0x00, 0x0E, 0x01, 0x01, 0x11, 0x0E, 0x00 }, // c + { 0x10, 0x10, 0x16, 0x19, 0x11, 0x11, 0x1E, 0x00 }, // d + { 0x00, 0x00, 0x0E, 0x11, 0x1F, 0x01, 0x0E, 0x00 }, // e + { 0x0C, 0x12, 0x02, 0x07, 0x02, 0x02, 0x02, 0x00 }, // f + { 0x00, 0x1E, 0x11, 0x11, 0x1E, 0x10, 0x0E, 0x00 }, // g + { 0x01, 0x01, 0x0D, 0x13, 0x11, 0x11, 0x11, 0x00 }, // h + { 0x04, 0x00, 0x06, 0x04, 0x04, 0x04, 0x0E, 0x00 }, // i + { 0x08, 0x00, 0x0C, 0x08, 0x08, 0x09, 0x06, 0x00 }, // j + { 0x02, 0x02, 0x12, 0x0A, 0x06, 0x0A, 0x12, 0x00 }, // k + { 0x06, 0x04, 0x04, 0x04, 0x04, 0x04, 0x0E, 0x00 }, // l + { 0x00, 0x00, 0x0B, 0x15, 0x15, 0x11, 0x11, 0x00 }, // m + { 0x00, 0x00, 0x0D, 0x13, 0x11, 0x11, 0x11, 0x00 }, // n + { 0x00, 0x00, 0x0E, 0x11, 0x11, 0x11, 0x0E, 0x00 }, // o + { 0x00, 0x00, 0x0F, 0x11, 0x0F, 0x01, 0x01, 0x00 }, // p + { 0x00, 0x00, 0x16, 0x19, 0x1E, 0x10, 0x10, 0x00 }, // q + { 0x00, 0x00, 0x0D, 0x13, 0x01, 0x01, 0x01, 0x00 }, // r + { 0x00, 0x00, 0x0E, 0x01, 0x0E, 0x10, 0x0F, 0x00 }, // s + { 0x02, 0x02, 0x07, 0x02, 0x02, 0x12, 0x0C, 0x00 }, // t + { 0x00, 0x00, 0x11, 0x11, 0x11, 0x19, 0x16, 0x00 }, // u + { 0x00, 0x00, 0x11, 0x11, 0x11, 0x0A, 0x04, 0x00 }, // v + { 0x00, 0x00, 0x11, 0x11, 0x15, 0x15, 0x0A, 0x00 }, // w + { 0x00, 0x00, 0x11, 0x0A, 0x04, 0x0A, 0x11, 0x00 }, // x + { 0x00, 0x00, 0x11, 0x11, 0x1E, 0x10, 0x0E, 0x00 }, // y + { 0x00, 0x00, 0x1F, 0x08, 0x04, 0x02, 0x1F, 0x00 }, // z + { 0x18, 0x04, 0x04, 0x02, 0x04, 0x04, 0x18, 0x00 }, // { + { 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x00 }, // | + { 0x03, 0x04, 0x04, 0x08, 0x04, 0x04, 0x03, 0x00 }, // } + { 0x00, 0x02, 0x15, 0x08, 0x00, 0x00, 0x00, 0x00 }, // ~ + { 0x1F, 0x1F, 0x11, 0x1F, 0x11, 0x1F, 0x1F, 0x00 }, // ? + { 0x00, 0x00, 0x0E, 0x0A, 0x0A, 0x0A, 0x0E, 0x00 }, // ? + { 0x00, 0x00, 0x04, 0x06, 0x04, 0x04, 0x04, 0x00 }, // ? + { 0x00, 0x00, 0x06, 0x08, 0x04, 0x02, 0x0E, 0x00 }, // ? + { 0x00, 0x00, 0x06, 0x08, 0x04, 0x08, 0x06, 0x00 }, // ? + { 0x00, 0x00, 0x02, 0x0A, 0x0E, 0x08, 0x08, 0x00 }, // ? + { 0x00, 0x00, 0x0E, 0x02, 0x06, 0x08, 0x06, 0x00 }, // ? + { 0x00, 0x00, 0x0C, 0x02, 0x0E, 0x0A, 0x0E, 0x00 }, // ? + { 0x00, 0x00, 0x0E, 0x08, 0x04, 0x02, 0x02, 0x00 }, // ? + { 0x00, 0x00, 0x0E, 0x0A, 0x0E, 0x0A, 0x0E, 0x00 }, // ? + { 0x00, 0x00, 0x0E, 0x0A, 0x0E, 0x08, 0x06, 0x00 }, // ? + { 0x08, 0x04, 0x0E, 0x11, 0x11, 0x1F, 0x11, 0x00 }, // ? + { 0x02, 0x04, 0x0E, 0x11, 0x11, 0x1F, 0x11, 0x00 }, // ? + { 0x04, 0x0A, 0x00, 0x0E, 0x11, 0x1F, 0x11, 0x00 }, // ? + { 0x0A, 0x00, 0x0E, 0x11, 0x11, 0x1F, 0x11, 0x00 }, // ? + { 0x08, 0x04, 0x0E, 0x10, 0x1E, 0x11, 0x1E, 0x00 }, // ? + { 0x02, 0x04, 0x0E, 0x10, 0x1E, 0x11, 0x1E, 0x00 }, // ? + { 0x04, 0x0A, 0x0E, 0x10, 0x1E, 0x11, 0x1E, 0x00 }, // ? + { 0x0A, 0x00, 0x0E, 0x10, 0x1E, 0x11, 0x1E, 0x00 }, // ? + { 0x08, 0x04, 0x1F, 0x01, 0x0F, 0x01, 0x1F, 0x00 }, // ? + { 0x02, 0x04, 0x1F, 0x01, 0x0F, 0x01, 0x1F, 0x00 }, // ? + { 0x04, 0x0A, 0x1F, 0x01, 0x0F, 0x01, 0x1F, 0x00 }, // ? + { 0x0A, 0x00, 0x1F, 0x01, 0x0F, 0x01, 0x1F, 0x00 }, // ? + { 0x08, 0x04, 0x0E, 0x11, 0x1F, 0x01, 0x0E, 0x00 }, // ? + { 0x02, 0x04, 0x0E, 0x11, 0x1F, 0x01, 0x0E, 0x00 }, // ? + { 0x04, 0x0A, 0x0E, 0x11, 0x1F, 0x01, 0x0E, 0x00 }, // ? + { 0x0A, 0x00, 0x0E, 0x11, 0x1F, 0x01, 0x0E, 0x00 }, // ? + { 0x08, 0x04, 0x0E, 0x04, 0x04, 0x04, 0x0E, 0x00 }, // ? + { 0x02, 0x04, 0x0E, 0x04, 0x04, 0x04, 0x0E, 0x00 }, // ? + { 0x04, 0x0A, 0x0E, 0x04, 0x04, 0x04, 0x0E, 0x00 }, // ? + { 0x0A, 0x00, 0x0E, 0x04, 0x04, 0x04, 0x0E, 0x00 }, // ? + { 0x08, 0x04, 0x00, 0x06, 0x04, 0x04, 0x0E, 0x00 }, // ? + { 0x02, 0x04, 0x00, 0x06, 0x04, 0x04, 0x0E, 0x00 }, // ? + { 0x04, 0x0A, 0x00, 0x06, 0x04, 0x04, 0x0E, 0x00 }, // + { 0x0A, 0x00, 0x00, 0x06, 0x04, 0x04, 0x0E, 0x00 }, // ¡ + { 0x08, 0x04, 0x0E, 0x11, 0x11, 0x11, 0x0E, 0x00 }, // ¢ + { 0x02, 0x04, 0x0E, 0x11, 0x11, 0x11, 0x0E, 0x00 }, // £ + { 0x04, 0x0A, 0x0E, 0x11, 0x11, 0x11, 0x0E, 0x00 }, // ¤ + { 0x0A, 0x00, 0x0E, 0x11, 0x11, 0x11, 0x0E, 0x00 }, // ¥ + { 0x08, 0x04, 0x00, 0x0E, 0x11, 0x11, 0x0E, 0x00 }, // ¦ + { 0x02, 0x04, 0x00, 0x0E, 0x11, 0x11, 0x0E, 0x00 }, // § + { 0x04, 0x0A, 0x00, 0x0E, 0x11, 0x11, 0x0E, 0x00 }, // ¨ + { 0x0A, 0x00, 0x00, 0x0E, 0x11, 0x11, 0x0E, 0x00 }, // © + { 0x08, 0x04, 0x11, 0x11, 0x11, 0x11, 0x0E, 0x00 }, // ª + { 0x02, 0x04, 0x11, 0x11, 0x11, 0x11, 0x0E, 0x00 }, // « + { 0x04, 0x0A, 0x00, 0x11, 0x11, 0x11, 0x0E, 0x00 }, // ¬ + { 0x0A, 0x00, 0x11, 0x11, 0x11, 0x11, 0x0E, 0x00 }, // ­ + { 0x08, 0x04, 0x11, 0x11, 0x11, 0x19, 0x16, 0x00 }, // ® + { 0x02, 0x04, 0x11, 0x11, 0x11, 0x19, 0x16, 0x00 }, // ¯ + { 0x04, 0x0A, 0x00, 0x11, 0x11, 0x19, 0x16, 0x00 }, // ° + { 0x0A, 0x00, 0x11, 0x11, 0x11, 0x19, 0x16, 0x00 }, // ± + { 0x0E, 0x11, 0x01, 0x11, 0x0E, 0x04, 0x07, 0x00 }, // ² + { 0x00, 0x00, 0x0E, 0x01, 0x11, 0x0E, 0x07, 0x00 }, // ³ + { 0x14, 0x0A, 0x11, 0x13, 0x15, 0x19, 0x11, 0x00 }, // ´ + { 0x14, 0x0A, 0x00, 0x0D, 0x13, 0x11, 0x11, 0x00 }, // µ + { 0x10, 0x08, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00 }, // ¶ + { 0x01, 0x02, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00 }, // · + { 0x00, 0x0A, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }, // ¸ + { 0x04, 0x00, 0x04, 0x02, 0x01, 0x11, 0x0E, 0x00 }, // ¹ + { 0x04, 0x04, 0x00, 0x04, 0x04, 0x04, 0x04, 0x00 }, // º + { 0x00, 0x00, 0x16, 0x09, 0x09, 0x09, 0x16, 0x00 }, // » + { 0x0C, 0x12, 0x12, 0x0E, 0x12, 0x12, 0x0D, 0x00 }, // ¼ + { 0x00, 0x00, 0x12, 0x15, 0x08, 0x08, 0x08, 0x00 }, // ½ + { 0x00, 0x00, 0x00, 0x04, 0x0A, 0x11, 0x1F, 0x00 }, // ¾ + { 0x0C, 0x02, 0x04, 0x08, 0x1E, 0x11, 0x0E, 0x00 }, // ¿ + { 0x00, 0x00, 0x0E, 0x01, 0x0F, 0x01, 0x0E, 0x00 }, // À + { 0x0C, 0x04, 0x04, 0x04, 0x04, 0x04, 0x0C, 0x00 }, // Á + { 0x00, 0x02, 0x04, 0x08, 0x0C, 0x12, 0x11, 0x00 }, // Â + { 0x00, 0x00, 0x09, 0x09, 0x09, 0x17, 0x01, 0x00 }, // Ã + { 0x00, 0x00, 0x1F, 0x0A, 0x0A, 0x0A, 0x19, 0x00 }, // Ä + { 0x00, 0x0C, 0x12, 0x12, 0x0E, 0x02, 0x01, 0x00 }, // Å + { 0x1F, 0x02, 0x04, 0x08, 0x04, 0x02, 0x1F, 0x00 }, // Æ + { 0x00, 0x00, 0x1E, 0x09, 0x09, 0x09, 0x06, 0x00 }, // Ç + { 0x00, 0x00, 0x1E, 0x05, 0x04, 0x14, 0x08, 0x00 }, // È + { 0x04, 0x04, 0x0E, 0x15, 0x0E, 0x04, 0x04, 0x00 }, // É + { 0x0E, 0x11, 0x11, 0x11, 0x0A, 0x0A, 0x1B, 0x00 }, // Ê + { 0x1F, 0x00, 0x11, 0x0A, 0x04, 0x0A, 0x11, 0x00 }, // Ë + { 0x1F, 0x00, 0x11, 0x11, 0x1E, 0x10, 0x0E, 0x00 }, // Ì + { 0x14, 0x08, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00 }, // Í + { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x15, 0x00 }, // Î + { 0x00, 0x08, 0x0C, 0x0E, 0x0C, 0x08, 0x00, 0x00 }, // Ï + { 0x00, 0x00, 0x07, 0x07, 0x07, 0x00, 0x00, 0x00 }, // Ð + { 0x08, 0x08, 0x08, 0x04, 0x02, 0x02, 0x02, 0x00 }, // Ñ + { 0x00, 0x00, 0x00, 0x0E, 0x00, 0x00, 0x00, 0x00 }, // Ò + { 0x0E, 0x08, 0x0E, 0x02, 0x0E, 0x00, 0x00, 0x00 }, // Ó + { 0x0E, 0x0A, 0x0E, 0x00, 0x00, 0x00, 0x00, 0x00 }, // Ô + { 0x06, 0x08, 0x04, 0x08, 0x06, 0x00, 0x00, 0x00 }, // Õ + { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }, // Ö + { 0x02, 0x00, 0x03, 0x02, 0x02, 0x0A, 0x04, 0x00 }, // × + { 0x04, 0x0A, 0x0F, 0x11, 0x0F, 0x01, 0x01, 0x00 }, // Ø + { 0x01, 0x12, 0x0A, 0x04, 0x0A, 0x09, 0x10, 0x00 }, // Ù + { 0x1F, 0x11, 0x05, 0x07, 0x05, 0x01, 0x01, 0x00 }, // Ú + { 0x00, 0x00, 0x0E, 0x11, 0x0F, 0x01, 0x06, 0x00 }, // Û + { 0x00, 0x00, 0x04, 0x04, 0x04, 0x04, 0x1C, 0x00 }, // Ü + { 0x11, 0x13, 0x17, 0x1F, 0x1D, 0x19, 0x11, 0x00 }, // Ý + { 0x05, 0x0A, 0x14, 0x14, 0x14, 0x0A, 0x05, 0x00 }, // Þ + { 0x00, 0x02, 0x07, 0x0F, 0x07, 0x02, 0x00, 0x00 }, // ß + { 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x00 }, // à + { 0x1F, 0x1B, 0x11, 0x0A, 0x1B, 0x1B, 0x1B, 0x00 }, // á + { 0x1F, 0x1B, 0x15, 0x11, 0x15, 0x15, 0x1F, 0x00 }, // â + { 0x1F, 0x1B, 0x17, 0x13, 0x15, 0x13, 0x1F, 0x00 }, // ã + { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1F, 0x00 }, // ä + { 0x04, 0x0E, 0x15, 0x04, 0x04, 0x00, 0x1F, 0x00 }, // å + { 0x04, 0x0A, 0x0E, 0x0A, 0x0A, 0x00, 0x1F, 0x00 }, // æ + { 0x04, 0x08, 0x0C, 0x0A, 0x0C, 0x00, 0x1F, 0x00 }, // ç + { 0x00, 0x00, 0x02, 0x04, 0x08, 0x10, 0x00, 0x00 }, // è + { 0x03, 0x07, 0x0E, 0x1C, 0x18, 0x10, 0x00, 0x00 }, // é + { 0x1F, 0x1E, 0x1C, 0x18, 0x10, 0x00, 0x00, 0x00 }, // ê + { 0x00, 0x00, 0x01, 0x03, 0x07, 0x0F, 0x1F, 0x00 }, // ë + { 0x00, 0x08, 0x14, 0x17, 0x14, 0x08, 0x00, 0x00 }, // ì + { 0x00, 0x04, 0x0A, 0x0A, 0x0A, 0x04, 0x00, 0x00 }, // í + { 0x00, 0x01, 0x00, 0x04, 0x00, 0x10, 0x00, 0x00 }, // î + { 0x04, 0x0E, 0x1F, 0x0E, 0x0E, 0x0E, 0x00, 0x00 }, // ï + { 0x00, 0x0E, 0x0E, 0x0E, 0x1F, 0x0E, 0x04, 0x00 }, // ð + { 0x15, 0x0A, 0x15, 0x0A, 0x15, 0x0A, 0x15, 0x00 }, // ñ + { 0x04, 0x1E, 0x05, 0x0E, 0x14, 0x0F, 0x04, 0x00 }, // ò + { 0x04, 0x0E, 0x1F, 0x0E, 0x0E, 0x00, 0x00, 0x00 }, // ó + { 0x06, 0x09, 0x09, 0x0D, 0x11, 0x11, 0x0D, 0x00 }, // ô + { 0x00, 0x00, 0x00, 0x00, 0x11, 0x11, 0x1F, 0x00 }, // õ + { 0x00, 0x10, 0x18, 0x0C, 0x06, 0x03, 0x01, 0x00 }, // ö + { 0x15, 0x00, 0x11, 0x00, 0x11, 0x00, 0x15, 0x00 }, // ÷ + { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }, // ø + { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }, // ù + { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }, // ú + { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }, // û + { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }, // ü + { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }, // ý + { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }, // þ + { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 } // ÿ +}; diff --git a/kernel/hal/x86/c_include/string.h b/kernel/hal/x86/c_include/string.h index 0cd8e3c..6073285 100644 --- a/kernel/hal/x86/c_include/string.h +++ b/kernel/hal/x86/c_include/string.h @@ -6,6 +6,7 @@ extern "C" { #include void memmove(void* dst, void* src, uint32_t size); uint32_t strlen(const char* str); +int strcmp(const char* str1, const char* str2); #ifdef __cplusplus } #endif diff --git a/kernel/hal/x86/include/base.hpp b/kernel/hal/x86/include/base.hpp index 231f524..ce7305f 100644 --- a/kernel/hal/x86/include/base.hpp +++ b/kernel/hal/x86/include/base.hpp @@ -13,8 +13,8 @@ namespace MTGosHAL { class BlockDevice; class Task; class VMM3; - enum class BG_color: uint16_t; - enum class FG_color: uint16_t; + enum class BG_color: uint32_t; + enum class FG_color: uint32_t; extern Serial debug; extern Screen out; extern Screen err; diff --git a/kernel/hal/x86/include/textDISP.hpp b/kernel/hal/x86/include/textDISP.hpp index e09412c..6aa1e4a 100644 --- a/kernel/hal/x86/include/textDISP.hpp +++ b/kernel/hal/x86/include/textDISP.hpp @@ -1,56 +1,58 @@ #ifndef _TEXTDISP_H #define _TEXTDISP_H +#include #include #include -#define SCREEN_WIDTH 80 -#define SCREEN_HEIGHT 24 +#include +#define SCREEN_WIDTH 128 +#define SCREEN_HEIGHT 96 namespace MTGosHAL { - enum class BG_color : uint16_t { - BLACK=0x0000, - BLUE=0x1000, - GREEN=0x2000, - CYAN=0x3000, - RED=0x4000, - MAGENTA=0x5000, - BROWN=0x6000, - LIGHT_GREY=0x7000, - GREY=0x8000, - LIGHT_BLUE=0x9000, - LIGHT_GREEN=0xA000, - LIGHT_CYAN=0xB000, - LIGHT_RED=0xC000, - LIGHT_MAGENTA=0xD000, - YELLOW=0xE000, - WHITE=0xF000 + enum class BG_color : uint32_t { + BLACK=0x000000, + BLUE=0x0000AA, + GREEN=0x00AA00, + CYAN=0x00AAAA, + RED=0xAA0000, + MAGENTA=0xAA00AA, + BROWN=0xAA5500, + LIGHT_GREY=0xAAAAAA, + GREY=0x555555, + LIGHT_BLUE=0x5555FF, + LIGHT_GREEN=0x55FF55, + LIGHT_CYAN=0x55FFFF, + LIGHT_RED=0xFF5555, + LIGHT_MAGENTA=0xFF55FF, + YELLOW=0xFFFF55, + WHITE=0xFFFFFF }; - enum class FG_color : uint16_t { - BLACK=0x000, - BLUE=0x100, - GREEN=0x200, - CYAN=0x300, - RED=0x400, - MAGENTA=0x500, - BROWN=0x600, - LIGHT_GREY=0x700, - GREY=0x800, - LIGHT_BLUE=0x900, - LIGHT_GREEN=0xA00, - LIGHT_CYAN=0xB00, - LIGHT_RED=0xC00, - LIGHT_MAGENTA=0xD00, - YELLOW=0xE00, - WHITE=0xF00 + enum class FG_color : uint32_t { + BLACK=0x000000, + BLUE=0x0000AA, + GREEN=0x00AA00, + CYAN=0x00AAAA, + RED=0xAA0000, + MAGENTA=0xAA00AA, + BROWN=0xAA5500, + LIGHT_GREY=0xAAAAAA, + GREY=0x555555, + LIGHT_BLUE=0x5555FF, + LIGHT_GREEN=0x55FF55, + LIGHT_CYAN=0x55FFFF, + LIGHT_RED=0xFF5555, + LIGHT_MAGENTA=0xFF55FF, + YELLOW=0xFFFF55, + WHITE=0xFFFFFF }; class Screen: public Output { private: FG_color fg; BG_color bg; - uint16_t* vmem=(uint16_t*)0xB8000; + uint32_t* lfb; auto putChar(char c) -> void; public: Screen(): fg(FG_color::WHITE), bg(BG_color::BLACK) { - clrscr(); } + auto init(struct multiboot_info*) -> void; template auto operator<< (T output) -> Screen & { Output::operator<<(output); diff --git a/kernel/hal/x86/init/init.cpp b/kernel/hal/x86/init/init.cpp index 3fe6a11..5a4c719 100644 --- a/kernel/hal/x86/init/init.cpp +++ b/kernel/hal/x86/init/init.cpp @@ -23,6 +23,8 @@ namespace MTGosHAL { BlockDevice disk; VMM3 mm; void main(int eax, struct multiboot_info* ebx) { + out.init(ebx); + err.init(ebx); out << BG_color::BLACK << FG_color::WHITE << "Loading MTGos...\n"; err << BG_color::BLACK << FG_color::RED; if(eax!=0x2BADB002) diff --git a/kernel/hal/x86/io/serial.cpp b/kernel/hal/x86/io/serial.cpp index b17d41d..4425d06 100644 --- a/kernel/hal/x86/io/serial.cpp +++ b/kernel/hal/x86/io/serial.cpp @@ -5,7 +5,7 @@ namespace MTGosHAL { return inb(port+SERIAL_LSR)&0x20; } auto Serial::putChar(char chr) -> void { - if(!works) +// if(!works) return; int tries=65535; while(!isTransmitEmpty()) { @@ -55,7 +55,7 @@ namespace MTGosHAL { //Set baud divisor outb(port, divisor.b[0]); outb(port+1, divisor.b[1]); - //Set bit count, parity and reset DLAB + //Set bit count, parity and reset DLAB outb(port+SERIAL_LCR, 3); //Finish init outb(port+SERIAL_FCR, 0xC7); diff --git a/kernel/hal/x86/io/textDISP.cpp b/kernel/hal/x86/io/textDISP.cpp index a32f6e8..77af38e 100644 --- a/kernel/hal/x86/io/textDISP.cpp +++ b/kernel/hal/x86/io/textDISP.cpp @@ -1,5 +1,7 @@ #include #include +#include +#include int x=0, y=0; namespace MTGosHAL { auto Screen::putChar(char c) -> void { @@ -9,7 +11,7 @@ namespace MTGosHAL { break; case '\r': x=0; - + break; case '\b': x--; @@ -21,7 +23,16 @@ namespace MTGosHAL { case '\0': break; default: - vmem[y*SCREEN_WIDTH+(x++)]=((uint16_t)fg) | ((uint16_t)bg) | ((uint8_t)c); + for(int lx=0;lx<8;lx++) { + for(int ly=0;ly<8;ly++) { + if(font[(int)((uint8_t)c)][ly]&(1<(fg); + } else { + lfb[(x*8+lx)+(y*8+ly)*1024]=0x000000;//static_cast(bg); + } + } + } + x++; if(x==SCREEN_WIDTH) { x=0; y++; } @@ -29,17 +40,24 @@ namespace MTGosHAL { } if(y>SCREEN_HEIGHT) scroll(); - } + } auto Screen::clrscr() -> void { - for(int p=0; p(bg); + } x=y=0; } auto Screen::scroll() -> void { - for(int p=0; p(bg); + } + } y--; } template <> @@ -63,4 +81,19 @@ namespace MTGosHAL { auto Screen::setColor(FG_color fg, BG_color bg) -> Screen &{ return (*this).setColor(fg).setColor(bg); } + auto Screen::init(struct multiboot_info* mb_info) -> void { + lfb=(uint32_t*)((uint32_t)mb_info->framebuffer_addr); + //clrscr(); + //Render '\001' character + for(int tx=0;tx<16;tx++) { + for(int ty=0;ty<16;ty++) { + for(int x=0;x<8;x++) { + for(int y=0;y<8;y++) { + if(font[tx+ty*16][y]&(1<len2) + return 1; + else if (len1 enum class BGColor : uint32_t { - BLACK=0x0000, - BLUE=0x1000, - GREEN=0x2000, - CYAN=0x3000, - RED=0x4000, - MAGENTA=0x5000, - BROWN=0x6000, - LIGHT_GREY=0x7000, - GREY=0x8000, - LIGHT_BLUE=0x9000, - LIGHT_GREEN=0xA000, - LIGHT_CYAN=0xB000, - LIGHT_RED=0xC000, - LIGHT_MAGENTA=0xD000, - YELLOW=0xE000, - WHITE=0xF000 + BLACK=0x000000, + BLUE=0x0000AA, + GREEN=0x00AA00, + CYAN=0x00AAAA, + RED=0xAA0000, + MAGENTA=0xAA00AA, + BROWN=0xAA5500, + LIGHT_GREY=0xAAAAAA, + GREY=0x555555, + LIGHT_BLUE=0x5555FF, + LIGHT_GREEN=0x55FF55, + LIGHT_CYAN=0x55FFFF, + LIGHT_RED=0xFF5555, + LIGHT_MAGENTA=0xFF55FF, + YELLOW=0xFFFF55, + WHITE=0xFFFFFF }; enum class FGColor : uint32_t { - BLACK=0x000, - BLUE=0x100, - GREEN=0x200, - CYAN=0x300, - RED=0x400, - MAGENTA=0x500, - BROWN=0x600, - LIGHT_GREY=0x700, - GREY=0x800, - LIGHT_BLUE=0x900, - LIGHT_GREEN=0xA00, - LIGHT_CYAN=0xB00, - LIGHT_RED=0xC00, - LIGHT_MAGENTA=0xD00, - YELLOW=0xE00, - WHITE=0xF00 + BLACK=0x000000, + BLUE=0x0000AA, + GREEN=0x00AA00, + CYAN=0x00AAAA, + RED=0xAA0000, + MAGENTA=0xAA00AA, + BROWN=0xAA5500, + LIGHT_GREY=0xAAAAAA, + GREY=0x555555, + LIGHT_BLUE=0x5555FF, + LIGHT_GREEN=0x55FF55, + LIGHT_CYAN=0x55FFFF, + LIGHT_RED=0xFF5555, + LIGHT_MAGENTA=0xFF55FF, + YELLOW=0xFFFF55, + WHITE=0xFFFFFF }; class ScreenOut { private: diff --git a/std.fnt b/std.fnt new file mode 100644 index 0000000000000000000000000000000000000000..984bc96e29d7e5e8b4c634ee576dfae429f9b9d6 GIT binary patch literal 8199 zcmai3y>H{l6(3p)(TC_rZzmtPrvHL~ivu=Xo*-|x)~^+kIhY|gxS^WMC9Uo)hB`@7$t zovA>54$?e(^(xC$6AfRz8VDAG6_VAaOdx+*~q24S2QOI237Hch*96IwrE5QgDk@|~)**465l@A2N)S=kF_ve)#`0`804!Cr#nN#NCD@Ol z6kDaB-WZlrP;Y#CdUiI(4wO1Q9b*UNNAuz1$IS-AA3lBh`0)cKZZ@AjeE=i)LlvNt zE3^3TKTa#1186_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G5A literal 0 HcmV?d00001 diff --git a/test.elf b/test.elf new file mode 100755 index 0000000000000000000000000000000000000000..0d5a60f10e8d2a331a7260e2912665b52a3ecbe0 GIT binary patch literal 18560 zcmeHPYj7LY6~4P#TWd>}WywkGI00qqFo9q>cAOW)5I+kV~?NB=XK^pUD1~LQuXs67y(3wJA;+dw!Q|Qz|{m#9+ z^2$j%{3uL+?47y0=iKw1d+z=2-m|;10V4A>0V4A>0V4A>0V z4A>0V4A>0V4A=~OdJOc8zOy$sQ$2l<-rqm0WNfU*{Xoxb<+DArxf%DK(Wz+ZteR*yrZXP6;n%x`VvVa4&Vtmzz=ZS?===J_3LbJUIL$@VS|d)71oj6!4cr z7s@fm@ndsPMnf|%h0e3_&?~vqSC58f$8Mb+Z_ASqa)14UBNs+rqu4XjYn9Kk2PCsG z2J@Z<9wKBw_5KQavJ zcxZMvZ*q#J^XJDp>y_P2r_ZhFo!Sf8J$7fk3VqADHFw;B7HCjN6AFiP*L!c<{hR~c z6RH3k*ha81rG9Fx8g*Iy6cBc?8L%0!8L%0!8L%0!8L%0!8L%0!8L%1n1QMd{Q^VeJLh|_P0^8?uS0MonxbGHTaDr|QF)3gAS zFfcV}zkoUf%+duI`iX-Z^N#!}pU2dAp|J#THSM@qd8IeQ=fnFNaiS7zy(;@yX~f5F#`*9JkzibTJ!P-+2qgF42KFCKfIFHe3jk+h)iAg#K$+p}189LqN9H-N;lfGfWjyYeY(@7_O zGJ>CeI1kb38RwnUc-lEYr`MbhQRCarCrG=%O2SY@{A%LG8ebCeWf9*Y;wvJ4iHKh+ z;yXorRm3k7@ykVgmx%8c@he1pkBDE%%7}PHzNQPqDAys&t4L%nYL~D3F+}NW5T8PI zZ-=E~7nwcZB=hPL96t+P`UQkD1<0NAkn4YELf(Wx-;WW!tVJix^C*CF!&Nx)UM|Ay zfWjfnGY5zqyxFwYL0D~CE8;L#(2B9j!*G)uPeYV$H0^F4fO(ZFg=m!}7#Q<$rAkRa z!^P7Ki@y(Y^)X0N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KaN^}@eAsfYxQ%e# zbomxEQzk>zCdM|2+f@)XcJfFPK z$%X1~jkAf{zvWV12uEC5hRt5@Wb7@pnZ+Ceoh@Nld<#C=MFaWMJ&pMDqS77J+Fwlv LWAt&eSxoUi(53~C literal 0 HcmV?d00001 diff --git a/user/include/mtgos.hpp b/user/include/mtgos.hpp index 06fe8ba..e8e6ea0 100644 --- a/user/include/mtgos.hpp +++ b/user/include/mtgos.hpp @@ -1,46 +1,47 @@ #include enum class BGColor : uint32_t { - BLACK=0x0000, - BLUE=0x1000, - GREEN=0x2000, - CYAN=0x3000, - RED=0x4000, - MAGENTA=0x5000, - BROWN=0x6000, - LIGHT_GREY=0x7000, - GREY=0x8000, - LIGHT_BLUE=0x9000, - LIGHT_GREEN=0xA000, - LIGHT_CYAN=0xB000, - LIGHT_RED=0xC000, - LIGHT_MAGENTA=0xD000, - YELLOW=0xE000, - WHITE=0xF000 + BLACK=0x000000, + BLUE=0x0000AA, + GREEN=0x00AA00, + CYAN=0x00AAAA, + RED=0xAA0000, + MAGENTA=0xAA00AA, + BROWN=0xAA5500, + LIGHT_GREY=0xAAAAAA, + GREY=0x555555, + LIGHT_BLUE=0x5555FF, + LIGHT_GREEN=0x55FF55, + LIGHT_CYAN=0x55FFFF, + LIGHT_RED=0xFF5555, + LIGHT_MAGENTA=0xFF55FF, + YELLOW=0xFFFF55, + WHITE=0xFFFFFF }; enum class FGColor : uint32_t { - BLACK=0x000, - BLUE=0x100, - GREEN=0x200, - CYAN=0x300, - RED=0x400, - MAGENTA=0x500, - BROWN=0x600, - LIGHT_GREY=0x700, - GREY=0x800, - LIGHT_BLUE=0x900, - LIGHT_GREEN=0xA00, - LIGHT_CYAN=0xB00, - LIGHT_RED=0xC00, - LIGHT_MAGENTA=0xD00, - YELLOW=0xE00, - WHITE=0xF00 + BLACK=0x000000, + BLUE=0x0000AA, + GREEN=0x00AA00, + CYAN=0x00AAAA, + RED=0xAA0000, + MAGENTA=0xAA00AA, + BROWN=0xAA5500, + LIGHT_GREY=0xAAAAAA, + GREY=0x555555, + LIGHT_BLUE=0x5555FF, + LIGHT_GREEN=0x55FF55, + LIGHT_CYAN=0x55FFFF, + LIGHT_RED=0xFF5555, + LIGHT_MAGENTA=0xFF55FF, + YELLOW=0xFFFF55, + WHITE=0xFFFFFF }; class ScreenOut { private: void* handle; public: ScreenOut(bool err); - auto operator <<(char*) -> ScreenOut &; // puts(char *) + auto operator <<(const char*) -> ScreenOut &; // puts(char *) + auto operator <<(int) -> ScreenOut &; auto clrscr() -> ScreenOut &; auto setColor(BGColor, FGColor) -> ScreenOut &; ~ScreenOut(); diff --git a/user/mtgos.cpp b/user/mtgos.cpp index 5d0decb..b17f7f2 100644 --- a/user/mtgos.cpp +++ b/user/mtgos.cpp @@ -1,7 +1,7 @@ #include extern "C" { void * screenout_init(int err); -void * screenout_out(void* handle, char *str); +void * screenout_out(void* handle, const char *str); void * screenout_clear(void* handle); void * screenout_setcolor(void* handle, uint32_t BG, uint32_t FG); void * screenout_destroy(void * handle); @@ -9,10 +9,23 @@ void * screenout_destroy(void * handle); ScreenOut::ScreenOut(bool err) { handle=screenout_init(err); } -auto ScreenOut::operator<<(char * str) -> ScreenOut & { +auto ScreenOut::operator<<(const char * str) -> ScreenOut & { screenout_out(handle, str); return *this; } +auto ScreenOut::operator<<(int output) -> ScreenOut & { + int base=10; + const char* chars="0123456789ABCDEF"; + char buf[33]; + buf[32]='\0'; + char* ptr=buf+31; + do { + *(ptr--)=chars[output%base]; + output/=base; + } while(output && (ptr!=buf)); + *this << ptr+1; + return *this; +} auto ScreenOut::clrscr() -> ScreenOut & { screenout_clear(handle); return *this; diff --git a/user/test.cpp b/user/test.cpp index ec7e56a..186d589 100644 --- a/user/test.cpp +++ b/user/test.cpp @@ -12,6 +12,7 @@ void main() ScreenOut out=ScreenOut(false); int i; out.setColor(BGColor::BLUE, FGColor::YELLOW); - for(;;) + for(;;) { out << arr; + } }