diff --git a/core/video/display.cpp b/core/video/display.cpp index 38e042db..9e88566a 100644 --- a/core/video/display.cpp +++ b/core/video/display.cpp @@ -50,6 +50,39 @@ namespace Video // MarkRegionDirty(Y / RegionHeight, X / RegionWidth); } + __no_sanitize("undefined") uint32_t Display::GetPixel(uint32_t X, + uint32_t Y) + { + if (unlikely(X >= this->Width)) + X = this->Width - 1; + + if (unlikely(Y >= this->Height)) + Y = this->Height - 1; + + uint32_t *Pixel = (uint32_t *)((uintptr_t)this->Buffer + (Y * this->Width + X) * (this->framebuffer.BitsPerPixel / 8)); + return *Pixel; + } + + __no_sanitize("undefined") void Display::DrawRectangle(uint32_t X, + uint32_t Y, + uint32_t Width, + uint32_t Height, + uint32_t Color) + { + for (uint32_t i = 0; i < Width; i++) + { + for (uint32_t j = 0; j < Height; j++) + { + uint32_t *Pixel = + (uint32_t *)((uintptr_t)this->Buffer + ((Y + j) * + this->Width + + (X + i)) * + (this->framebuffer.BitsPerPixel / 8)); + *Pixel = Color; + } + } + } + void Display::Scroll(int Lines) { if (this->DoNotScroll) diff --git a/include/display.hpp b/include/display.hpp index bad842d0..5a93fae4 100644 --- a/include/display.hpp +++ b/include/display.hpp @@ -214,6 +214,10 @@ namespace Video void ClearBuffer(); void SetPixel(uint32_t X, uint32_t Y, uint32_t Color); + uint32_t GetPixel(uint32_t X, uint32_t Y); + void DrawRectangle(uint32_t X, uint32_t Y, + uint32_t Width, uint32_t Height, + uint32_t Color); void Scroll(int Lines); void SetDoNotScroll(bool Value)