From 7936e0206657d796810a496fc516abc9ea3337f5 Mon Sep 17 00:00:00 2001 From: Sergey Lipskiy Date: Fri, 26 Jun 2015 19:20:44 +0600 Subject: [PATCH] Enable hack_subscreen for GLES2. --- src/FrameBuffer.cpp | 64 +++++++++++++++++++++++++-------------------- 1 file changed, 36 insertions(+), 28 deletions(-) diff --git a/src/FrameBuffer.cpp b/src/FrameBuffer.cpp index 04b8d6b2..daeb40fd 100644 --- a/src/FrameBuffer.cpp +++ b/src/FrameBuffer.cpp @@ -32,8 +32,6 @@ public: void CopyToRDRAM(u32 _address); private: - void _copyWhite(FrameBuffer * _pBuffer); - union RGBA { struct { u8 r, g, b, a; @@ -847,6 +845,32 @@ void FrameBuffer_ActivateBufferTextureBG(s16 t, FrameBuffer *pBuffer ) gDP.changed |= CHANGED_FB_TEXTURE; } +static +void copyWhiteToRDRAM(FrameBuffer * _pBuffer) +{ + if (_pBuffer->m_size == G_IM_SIZ_32b) { + u32 *ptr_dst = (u32*)(RDRAM + _pBuffer->m_startAddress); + + for (u32 y = 0; y < VI.height; ++y) { + for (u32 x = 0; x < VI.width; ++x) + ptr_dst[x + y*VI.width] = 0xFFFFFFFF; + } + } + else { + u16 *ptr_dst = (u16*)(RDRAM + _pBuffer->m_startAddress); + + for (u32 y = 0; y < VI.height; ++y) { + for (u32 x = 0; x < VI.width; ++x) { + ptr_dst[(x + y*VI.width) ^ 1] = 0xFFFF; + } + } + } + _pBuffer->m_copiedToRdram = true; + _pBuffer->copyRdram(); + + _pBuffer->m_cleared = false; +} + #ifndef GLES2 void FrameBufferToRDRAM::Init() { @@ -902,31 +926,6 @@ void FrameBufferToRDRAM::Destroy() { } } -void FrameBufferToRDRAM::_copyWhite(FrameBuffer * _pBuffer) -{ - if (_pBuffer->m_size == G_IM_SIZ_32b) { - u32 *ptr_dst = (u32*)(RDRAM + _pBuffer->m_startAddress); - - for (u32 y = 0; y < VI.height; ++y) { - for (u32 x = 0; x < VI.width; ++x) - ptr_dst[x + y*VI.width] = 0xFFFFFFFF; - } - } - else { - u16 *ptr_dst = (u16*)(RDRAM + _pBuffer->m_startAddress); - - for (u32 y = 0; y < VI.height; ++y) { - for (u32 x = 0; x < VI.width; ++x) { - ptr_dst[(x + y*VI.width) ^ 1] = 0xFFFF; - } - } - } - _pBuffer->m_copiedToRdram = true; - _pBuffer->copyRdram(); - - _pBuffer->m_cleared = false; -} - void FrameBufferToRDRAM::CopyToRDRAM(u32 _address) { if (VI.width == 0 || frameBufferList().getCurrent() == NULL) // H width is zero or no current buffer. Don't copy @@ -936,7 +935,7 @@ void FrameBufferToRDRAM::CopyToRDRAM(u32 _address) return; if ((config.generalEmulation.hacks & hack_subscreen) != 0) { - _copyWhite(pBuffer); + copyWhiteToRDRAM(pBuffer); return; } @@ -1013,6 +1012,15 @@ void FrameBuffer_CopyToRDRAM(u32 _address) { #ifndef GLES2 g_fbToRDRAM.CopyToRDRAM(_address); +#else + if ((config.generalEmulation.hacks & hack_subscreen) == 0) + return; + if (VI.width == 0 || frameBufferList().getCurrent() == NULL) + return; + FrameBuffer *pBuffer = frameBufferList().findBuffer(_address); + if (pBuffer == NULL || pBuffer->m_width < VI.width || pBuffer->m_isOBScreen) + return; + copyWhiteToRDRAM(pBuffer); #endif }