From 2a177aa9a18e72954522e3e7e9b877ae6bf10c04 Mon Sep 17 00:00:00 2001 From: Ignacio Sanchez Gines Date: Sun, 12 Apr 2020 21:35:55 +0200 Subject: [PATCH] Fix libretro RGB565 rendering --- src/GearsystemCore.cpp | 17 +++++++++++++++++ src/GearsystemCore.h | 1 + src/definitions.h | 8 -------- 3 files changed, 18 insertions(+), 8 deletions(-) diff --git a/src/GearsystemCore.cpp b/src/GearsystemCore.cpp index 21053aaf..bfbab000 100644 --- a/src/GearsystemCore.cpp +++ b/src/GearsystemCore.cpp @@ -790,3 +790,20 @@ void GearsystemCore::Reset() m_pSmsIOPorts->Reset(); m_bPaused = false; } + +void GearsystemCore::Get16BitFrameBuffer(GS_Color* pFrameBuffer, u16* p16BitFrameBuffer) +{ + if (IsValidPointer(pFrameBuffer) && IsValidPointer(p16BitFrameBuffer)) + { + int pixels = GS_RESOLUTION_MAX_WIDTH * GS_RESOLUTION_MAX_HEIGHT; + + + for (int i = 0; i < pixels; i++) + { + GS_Color p = pFrameBuffer[i]; + + p16BitFrameBuffer[i] = 0; + p16BitFrameBuffer[i] = ((p.red >> 3) << 11) | ((p.green >> 2) << 5) | (p.blue >> 3); + } + } +} diff --git a/src/GearsystemCore.h b/src/GearsystemCore.h index 79b408cc..938c58bf 100644 --- a/src/GearsystemCore.h +++ b/src/GearsystemCore.h @@ -76,6 +76,7 @@ class GearsystemCore Memory* GetMemory(); Cartridge* GetCartridge(); void SetSG1000Palette(GS_Color* pSG1000Palette); + void Get16BitFrameBuffer(GS_Color* pFrameBuffer, u16* p16BitFrameBuffer); private: void InitMemoryRules(); diff --git a/src/definitions.h b/src/definitions.h index 3752ccc2..4badc4b3 100644 --- a/src/definitions.h +++ b/src/definitions.h @@ -115,14 +115,6 @@ struct GS_Color u8 blue; }; -enum GS_Color_Format -{ - GS_PIXEL_RGB565, - GS_PIXEL_RGB555, - GS_PIXEL_BGR565, - GS_PIXEL_BGR555 -}; - enum GS_Keys { Key_Up = 0,