From 9c00c5ec4b00b1b63bfcbb125bb1631931f9aff5 Mon Sep 17 00:00:00 2001 From: Alex Date: Tue, 11 Oct 2022 00:46:51 +0300 Subject: [PATCH] Color support --- Core/Interrupts/IntManager.cpp | 5 +++++ Core/Video/Display.cpp | 29 ++++++++++++++++++++++++++++- Kernel.cpp | 8 ++++++-- include/display.hpp | 4 +++- include/interrupts.hpp | 1 + 5 files changed, 43 insertions(+), 4 deletions(-) diff --git a/Core/Interrupts/IntManager.cpp b/Core/Interrupts/IntManager.cpp index edaf471..7b25b39 100644 --- a/Core/Interrupts/IntManager.cpp +++ b/Core/Interrupts/IntManager.cpp @@ -20,4 +20,9 @@ namespace Interrupts #elif defined(__aarch64__) #endif } + + void Enable() + { + + } } diff --git a/Core/Video/Display.cpp b/Core/Video/Display.cpp index 34e465f..06ecd9e 100644 --- a/Core/Video/Display.cpp +++ b/Core/Video/Display.cpp @@ -13,8 +13,35 @@ namespace Video char Display::Print(char Char, int Index) { SMARTLOCK(PrintLock); + + if (this->ColorIteration) + { + // RRGGBB + if (Char >= '0' && Char <= '9') + this->Buffers[Index]->Color = (this->Buffers[Index]->Color << 4) | (Char - '0'); + else if (Char >= 'a' && Char <= 'f') + this->Buffers[Index]->Color = (this->Buffers[Index]->Color << 4) | (Char - 'a' + 10); + else if (Char >= 'A' && Char <= 'F') + this->Buffers[Index]->Color = (this->Buffers[Index]->Color << 4) | (Char - 'A' + 10); + else + this->Buffers[Index]->Color = 0; + + this->ColorPickerIteration++; + if (this->ColorPickerIteration == 6) + { + this->ColorPickerIteration = 0; + this->ColorIteration = false; + } + return Char; + } + switch (Char) { + case '\e': + { + this->ColorIteration = true; + return Char; + } case '\b': { if (this->Buffers[Index]->CursorX > 0) @@ -86,7 +113,7 @@ namespace Video for (uint64_t X = this->Buffers[Index]->CursorX; X < this->Buffers[Index]->CursorX + fonthdrWidth; X++) if ((*FontPtr & (0b10000000 >> (X - this->Buffers[Index]->CursorX))) > 0) *(uint32_t *)((uint64_t)this->Buffers[Index]->Buffer + - (Y * this->Buffers[Index]->Width + X) * (this->framebuffer.BitsPerPixel / 8)) = 0xFFFFFF; + (Y * this->Buffers[Index]->Width + X) * (this->framebuffer.BitsPerPixel / 8)) = this->Buffers[Index]->Color; FontPtr += BytesPerLine; } diff --git a/Kernel.cpp b/Kernel.cpp index f3caa2e..30ef45a 100644 --- a/Kernel.cpp +++ b/Kernel.cpp @@ -4,9 +4,12 @@ #include #include #include +#include #include #include +NEWLOCK(KernelLock); + BootInfo *bInfo = nullptr; Video::Display *Display = nullptr; SymbolResolver::Symbols *KernelSymbolTable = nullptr; @@ -23,8 +26,9 @@ extern "C" int vprintf_(const char *format, va_list arg); void KPrint(const char *format, ...) { + SMARTLOCK(KernelLock); Time tm = ReadClock(); - printf_("[%02ld:%02ld:%02ld] ", tm.Hour, tm.Minute, tm.Second); + printf_("\eCCCCCC[\e00AEFF%02ld:%02ld:%02ld\eCCCCCC] ", tm.Hour, tm.Minute, tm.Second); va_list args; va_start(args, format); vprintf_(format, args); @@ -48,7 +52,7 @@ EXTERNC void Entry(BootInfo *Info) memcpy(bInfo, Info, sizeof(BootInfo)); debug("BootInfo structure is at %p", bInfo); Display = new Video::Display(bInfo->Framebuffer[0]); - printf_("%s - %s(%s)\n", KERNEL_NAME, KERNEL_VERSION, GIT_COMMIT_SHORT); + printf_("\eFFFFFF%s - %s [\e058C19%s\eFFFFFF]\n", KERNEL_NAME, KERNEL_VERSION, GIT_COMMIT_SHORT); /**************************************************************************************/ KPrint("Initializing GDT and IDT"); Interrupts::Initialize(); diff --git a/include/display.hpp b/include/display.hpp index d2412ad..e3ad631 100644 --- a/include/display.hpp +++ b/include/display.hpp @@ -77,7 +77,7 @@ namespace Video struct ScreenBuffer { - void *Buffer; + void *Buffer = nullptr; uint32_t Width, Height; uint64_t Size; uint32_t Color; @@ -90,6 +90,8 @@ namespace Video BootInfo::FramebufferInfo framebuffer; Font *CurrentFont; ScreenBuffer *Buffers[16]; + bool ColorIteration = false; + int ColorPickerIteration = 0; public: Font *GetCurrentFont() { return CurrentFont; } diff --git a/include/interrupts.hpp b/include/interrupts.hpp index a8736f8..e6201f8 100644 --- a/include/interrupts.hpp +++ b/include/interrupts.hpp @@ -6,6 +6,7 @@ namespace Interrupts { void Initialize(); + void Enable(); } #endif // !__FENNIX_KERNEL_INTERRUPTS_H__