mirror of
https://github.com/Fennix-Project/Kernel.git
synced 2025-05-27 23:14:38 +00:00
Color support
This commit is contained in:
parent
f7e316bdcb
commit
9c00c5ec4b
@ -20,4 +20,9 @@ namespace Interrupts
|
||||
#elif defined(__aarch64__)
|
||||
#endif
|
||||
}
|
||||
|
||||
void Enable()
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -4,9 +4,12 @@
|
||||
#include <memory.hpp>
|
||||
#include <string.h>
|
||||
#include <printf.h>
|
||||
#include <lock.hpp>
|
||||
#include <time.hpp>
|
||||
#include <debug.h>
|
||||
|
||||
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();
|
||||
|
@ -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; }
|
||||
|
@ -6,6 +6,7 @@
|
||||
namespace Interrupts
|
||||
{
|
||||
void Initialize();
|
||||
void Enable();
|
||||
}
|
||||
|
||||
#endif // !__FENNIX_KERNEL_INTERRUPTS_H__
|
||||
|
Loading…
x
Reference in New Issue
Block a user