diff --git a/OVMFbin/OVMF_VARS-pure-efi.fd b/OVMFbin/OVMF_VARS-pure-efi.fd index 9177f63..8525510 100644 Binary files a/OVMFbin/OVMF_VARS-pure-efi.fd and b/OVMFbin/OVMF_VARS-pure-efi.fd differ diff --git a/kernel/bin/CustomOS.img b/kernel/bin/CustomOS.img index 191bfdb..0d347d0 100644 Binary files a/kernel/bin/CustomOS.img and b/kernel/bin/CustomOS.img differ diff --git a/kernel/bin/kernel.elf b/kernel/bin/kernel.elf index a00ad01..dc9fd86 100755 Binary files a/kernel/bin/kernel.elf and b/kernel/bin/kernel.elf differ diff --git a/kernel/lib/BasicRenderer.o b/kernel/lib/BasicRenderer.o index 7ff1ad4..7a71f40 100644 Binary files a/kernel/lib/BasicRenderer.o and b/kernel/lib/BasicRenderer.o differ diff --git a/kernel/lib/kernelUtil.o b/kernel/lib/kernelUtil.o index 7f88e99..3bc73e9 100644 Binary files a/kernel/lib/kernelUtil.o and b/kernel/lib/kernelUtil.o differ diff --git a/kernel/lib/panic.o b/kernel/lib/panic.o index 6e6b2fd..e422991 100644 Binary files a/kernel/lib/panic.o and b/kernel/lib/panic.o differ diff --git a/kernel/lib/userinput/mouse.o b/kernel/lib/userinput/mouse.o index bb5f9b8..3ce3aab 100644 Binary files a/kernel/lib/userinput/mouse.o and b/kernel/lib/userinput/mouse.o differ diff --git a/kernel/src/BasicRenderer.cpp b/kernel/src/BasicRenderer.cpp index 61c5d77..a0ad4fd 100644 --- a/kernel/src/BasicRenderer.cpp +++ b/kernel/src/BasicRenderer.cpp @@ -57,6 +57,31 @@ void BasicRenderer::PutPixel(uint32_t x, uint32_t y, uint32_t colour) { } +uint32_t BasicRenderer::GetPixel(uint32_t x, uint32_t y){ + return *(uint32_t*)((uint64_t)targetFramebuffer->BaseAddress + (x*4) + (y * targetFramebuffer->PixelsPerScanline * 4)); +} + +void BasicRenderer::ClearMouseCursor(uint8_t* mouseCursor, Point position) { + int xMax = 16; + int yMax = 19; + int diffX = targetFramebuffer->Width - position.x; + int diffY = targetFramebuffer->Height - position.y; + + if (diffX < 16) xMax = diffX; + if (diffY < 19) yMax = diffY; + + for (int y = 0; y < yMax; y++) { + for (int x = 0; x < xMax; x++) { + int bit = y * 16 + x; + int byte = bit / 8; + + if (mouseCursor[byte] & (0b10000000 >> (x % 8))) { + PutPixel(position.x + x, position.y + y, mouseCursorBuffer[x + y*16]); + } + } + } +} + void BasicRenderer::DrawOverlayMouseCursor(uint8_t* mouseCursor, Point position, uint32_t colour) { int xMax = 16; int yMax = 19; @@ -72,6 +97,7 @@ void BasicRenderer::DrawOverlayMouseCursor(uint8_t* mouseCursor, Point position, int byte = bit / 8; if (mouseCursor[byte] & (0b10000000 >> (x % 8))) { + mouseCursorBuffer[x + y*16] = GetPixel(position.x + x, position.y + y); PutPixel(position.x + x, position.y + y, colour); } } diff --git a/kernel/src/BasicRenderer.h b/kernel/src/BasicRenderer.h index 58fdbd4..0487456 100644 --- a/kernel/src/BasicRenderer.h +++ b/kernel/src/BasicRenderer.h @@ -10,12 +10,15 @@ class BasicRenderer { Point cursorPosition; Framebuffer* targetFramebuffer; PSF1_FONT* PSF1_Font; + uint32_t mouseCursorBuffer[16*19]; unsigned int Colour; unsigned int ClearColour; void Print(const char* str); void PutChar(char chr, unsigned int xOff, unsigned int yOff); void PutChar(char chr); void PutPixel(uint32_t x, uint32_t y, uint32_t colour); + uint32_t GetPixel(uint32_t x, uint32_t y); + void ClearMouseCursor(uint8_t* mouseCursor, Point position); void ClearChar(); void Clear(); void Next(); diff --git a/kernel/src/userinput/mouse.cpp b/kernel/src/userinput/mouse.cpp index 16729fc..b8d77d9 100644 --- a/kernel/src/userinput/mouse.cpp +++ b/kernel/src/userinput/mouse.cpp @@ -59,6 +59,7 @@ uint8_t mousePacket[4]; bool mousePacketReady = false; Point mousePosition; +Point mousePositionOld; void HandlePS2Mouse(uint8_t data) { switch (mouseCycle) { @@ -137,7 +138,10 @@ void ProcessMousePacket() { if (mousePosition.y < 0) mousePosition.y = 0; if (mousePosition.y > GlobalRenderer->targetFramebuffer->Height-1) mousePosition.y = GlobalRenderer->targetFramebuffer->Height; + GlobalRenderer->ClearMouseCursor(MousePointer, mousePositionOld); GlobalRenderer->DrawOverlayMouseCursor(MousePointer, mousePosition, 0xFFFFFFFF); + + mousePositionOld = mousePosition; } void InitPS2Mouse() {