mouse cleans up after itself now

This commit is contained in:
2026-01-29 14:34:19 +11:00
parent df3f9478e8
commit 46e806795c
10 changed files with 33 additions and 0 deletions

View File

@@ -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);
}
}