fixes and optimizations to mouse drawing
This commit is contained in:
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -51,13 +51,13 @@ void BasicRenderer::Print(const char* str) {
|
||||
}
|
||||
}
|
||||
|
||||
void BasicRenderer::PutPixel(uint32_t x, uint32_t y, uint32_t colour) {
|
||||
inline void BasicRenderer::PutPixel(uint32_t x, uint32_t y, uint32_t colour) {
|
||||
|
||||
*(uint32_t*)((uint64_t)targetFramebuffer->BaseAddress + (x*4) + (y * targetFramebuffer->PixelsPerScanline * 4)) = colour;
|
||||
|
||||
}
|
||||
|
||||
uint32_t BasicRenderer::GetPixel(uint32_t x, uint32_t y){
|
||||
inline uint32_t BasicRenderer::GetPixel(uint32_t x, uint32_t y){
|
||||
return *(uint32_t*)((uint64_t)targetFramebuffer->BaseAddress + (x*4) + (y * targetFramebuffer->PixelsPerScanline * 4));
|
||||
}
|
||||
|
||||
@@ -78,7 +78,9 @@ void BasicRenderer::ClearMouseCursor(uint8_t* mouseCursor, Point position) {
|
||||
int byte = bit / 8;
|
||||
|
||||
if (mouseCursor[byte] & (0b10000000 >> (x % 8))) {
|
||||
PutPixel(position.x + x, position.y + y, mouseCursorBuffer[x + y*16]);
|
||||
if (GetPixel(position.x + x, position.y + y) == mouseCursorBufferAfter[x + y * 16]) {
|
||||
PutPixel(position.x + x, position.y + y, mouseCursorBuffer[x + y*16]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -101,6 +103,8 @@ void BasicRenderer::DrawOverlayMouseCursor(uint8_t* mouseCursor, Point position,
|
||||
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);
|
||||
mouseCursorBufferAfter[x + y*16] = GetPixel(position.x + x, position.y + y);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -11,13 +11,14 @@ class BasicRenderer {
|
||||
Framebuffer* targetFramebuffer;
|
||||
PSF1_FONT* PSF1_Font;
|
||||
uint32_t mouseCursorBuffer[16*19];
|
||||
uint32_t mouseCursorBufferAfter[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);
|
||||
inline void PutPixel(uint32_t x, uint32_t y, uint32_t colour);
|
||||
inline uint32_t GetPixel(uint32_t x, uint32_t y);
|
||||
void ClearMouseCursor(uint8_t* mouseCursor, Point position);
|
||||
void ClearChar();
|
||||
void Clear();
|
||||
|
||||
@@ -58,6 +58,12 @@ uint8_t mouseCycle = 0;
|
||||
uint8_t mousePacket[4];
|
||||
bool mousePacketReady = false;
|
||||
|
||||
bool mouseButtons[] = {
|
||||
false, // left
|
||||
false, // right
|
||||
false // middle
|
||||
};
|
||||
|
||||
Point mousePosition;
|
||||
Point mousePositionOld;
|
||||
|
||||
@@ -138,6 +144,10 @@ void ProcessMousePacket() {
|
||||
if (mousePosition.y < 0) mousePosition.y = 0;
|
||||
if (mousePosition.y > GlobalRenderer->targetFramebuffer->Height-1) mousePosition.y = GlobalRenderer->targetFramebuffer->Height;
|
||||
|
||||
mouseButtons[0] = mousePacket[0] & PS2LeftButton;
|
||||
mouseButtons[1] = mousePacket[1] & PS2RightButton;
|
||||
mouseButtons[2] = mousePacket[2] & PS2MiddleButton;
|
||||
|
||||
GlobalRenderer->ClearMouseCursor(MousePointer, mousePositionOld);
|
||||
GlobalRenderer->DrawOverlayMouseCursor(MousePointer, mousePosition, 0xFFFFFFFF);
|
||||
|
||||
|
||||
@@ -5,8 +5,8 @@
|
||||
|
||||
extern uint8_t MousePointer[];
|
||||
#define PS2LeftButton 0b00000001
|
||||
#define PS2MiddleButton 0b00000010
|
||||
#define PS2RightButton 0b00000100
|
||||
#define PS2MiddleButton 0b00000100
|
||||
#define PS2RightButton 0b00000010
|
||||
|
||||
#define PS2XSign 0b00010000
|
||||
#define PS2YSign 0b00100000
|
||||
@@ -14,6 +14,7 @@ extern uint8_t MousePointer[];
|
||||
#define PS2YOverflow 0b10000000
|
||||
|
||||
extern Point mousePosition;
|
||||
extern bool mouseButtons[];
|
||||
|
||||
void InitPS2Mouse();
|
||||
void HandlePS2Mouse(uint8_t data);
|
||||
|
||||
Reference in New Issue
Block a user