Color support

This commit is contained in:
Alex 2022-10-11 00:46:51 +03:00
parent f7e316bdcb
commit 9c00c5ec4b
Signed by untrusted user who does not match committer: enderice2
GPG Key ID: EACC3AD603BAB4DD
5 changed files with 43 additions and 4 deletions

View File

@ -20,4 +20,9 @@ namespace Interrupts
#elif defined(__aarch64__) #elif defined(__aarch64__)
#endif #endif
} }
void Enable()
{
}
} }

View File

@ -13,8 +13,35 @@ namespace Video
char Display::Print(char Char, int Index) char Display::Print(char Char, int Index)
{ {
SMARTLOCK(PrintLock); 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) switch (Char)
{ {
case '\e':
{
this->ColorIteration = true;
return Char;
}
case '\b': case '\b':
{ {
if (this->Buffers[Index]->CursorX > 0) 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++) for (uint64_t X = this->Buffers[Index]->CursorX; X < this->Buffers[Index]->CursorX + fonthdrWidth; X++)
if ((*FontPtr & (0b10000000 >> (X - this->Buffers[Index]->CursorX))) > 0) if ((*FontPtr & (0b10000000 >> (X - this->Buffers[Index]->CursorX))) > 0)
*(uint32_t *)((uint64_t)this->Buffers[Index]->Buffer + *(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; FontPtr += BytesPerLine;
} }

View File

@ -4,9 +4,12 @@
#include <memory.hpp> #include <memory.hpp>
#include <string.h> #include <string.h>
#include <printf.h> #include <printf.h>
#include <lock.hpp>
#include <time.hpp> #include <time.hpp>
#include <debug.h> #include <debug.h>
NEWLOCK(KernelLock);
BootInfo *bInfo = nullptr; BootInfo *bInfo = nullptr;
Video::Display *Display = nullptr; Video::Display *Display = nullptr;
SymbolResolver::Symbols *KernelSymbolTable = nullptr; SymbolResolver::Symbols *KernelSymbolTable = nullptr;
@ -23,8 +26,9 @@ extern "C" int vprintf_(const char *format, va_list arg);
void KPrint(const char *format, ...) void KPrint(const char *format, ...)
{ {
SMARTLOCK(KernelLock);
Time tm = ReadClock(); 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_list args;
va_start(args, format); va_start(args, format);
vprintf_(format, args); vprintf_(format, args);
@ -48,7 +52,7 @@ EXTERNC void Entry(BootInfo *Info)
memcpy(bInfo, Info, sizeof(BootInfo)); memcpy(bInfo, Info, sizeof(BootInfo));
debug("BootInfo structure is at %p", bInfo); debug("BootInfo structure is at %p", bInfo);
Display = new Video::Display(bInfo->Framebuffer[0]); 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"); KPrint("Initializing GDT and IDT");
Interrupts::Initialize(); Interrupts::Initialize();

View File

@ -77,7 +77,7 @@ namespace Video
struct ScreenBuffer struct ScreenBuffer
{ {
void *Buffer; void *Buffer = nullptr;
uint32_t Width, Height; uint32_t Width, Height;
uint64_t Size; uint64_t Size;
uint32_t Color; uint32_t Color;
@ -90,6 +90,8 @@ namespace Video
BootInfo::FramebufferInfo framebuffer; BootInfo::FramebufferInfo framebuffer;
Font *CurrentFont; Font *CurrentFont;
ScreenBuffer *Buffers[16]; ScreenBuffer *Buffers[16];
bool ColorIteration = false;
int ColorPickerIteration = 0;
public: public:
Font *GetCurrentFont() { return CurrentFont; } Font *GetCurrentFont() { return CurrentFont; }

View File

@ -6,6 +6,7 @@
namespace Interrupts namespace Interrupts
{ {
void Initialize(); void Initialize();
void Enable();
} }
#endif // !__FENNIX_KERNEL_INTERRUPTS_H__ #endif // !__FENNIX_KERNEL_INTERRUPTS_H__