diff --git a/Source/Core/Core/Src/HW/VideoInterface.cpp b/Source/Core/Core/Src/HW/VideoInterface.cpp index aab48bb466..43e4057e78 100644 --- a/Source/Core/Core/Src/HW/VideoInterface.cpp +++ b/Source/Core/Core/Src/HW/VideoInterface.cpp @@ -1159,14 +1159,9 @@ void Update() // TODO: What's the correct behavior for progressive mode? - for (int i = 0; i < 4; ++i) - { - if (m_InterruptRegister[i].VCT == m_VBeamPos) - { - m_InterruptRegister[i].IR_INT = 1; - UpdateInterrupts(); - } - } + m_VBeamPos++; + if (m_VBeamPos > s_lineCount) + m_VBeamPos = 1; if (m_VBeamPos == s_upperFieldBegin) BeginField(m_DisplayControlRegister.NIN ? FIELD_PROGRESSIVE : FIELD_UPPER); @@ -1180,9 +1175,14 @@ void Update() if (m_VBeamPos == s_lowerFieldEnd) EndField(); - m_VBeamPos++; - if (m_VBeamPos > s_lineCount) - m_VBeamPos = 1; + for (int i = 0; i < 4; ++i) + { + if (m_InterruptRegister[i].VCT == m_VBeamPos) + { + m_InterruptRegister[i].IR_INT = 1; + UpdateInterrupts(); + } + } } } // namespace diff --git a/Source/Plugins/Plugin_VideoOGL/Src/Render.cpp b/Source/Plugins/Plugin_VideoOGL/Src/Render.cpp index 925c3698a8..7188ac94bf 100644 --- a/Source/Plugins/Plugin_VideoOGL/Src/Render.cpp +++ b/Source/Plugins/Plugin_VideoOGL/Src/Render.cpp @@ -580,6 +580,9 @@ u32 Renderer::AccessEFB(EFBAccessType type, int x, int y) case PEEK_COLOR: { + // TODO: Find some way to test PEEK_COLOR. Wind Waker may be using it + // for pictograph quests. + if (s_MSAASamples > 1) { // Resolve our rectangle. @@ -591,12 +594,13 @@ u32 Renderer::AccessEFB(EFBAccessType type, int x, int y) int srcX = (targetPixelRc.left + targetPixelRc.right) / 2; int srcY = (targetPixelRc.top + targetPixelRc.bottom) / 2; + // Read back pixel in BGRA format, then byteswap to get GameCube's + // ARGB format. u32 color = 0; - glReadPixels(srcX, srcY, 1, 1, GL_RGBA, GL_UNSIGNED_INT, &color); + glReadPixels(srcX, srcY, 1, 1, GL_BGRA, GL_UNSIGNED_BYTE, &color); GL_REPORT_ERRORD(); - // TODO: Find some way to test PEEK_COLOR. - return color; + return Common::swap32(color); } case POKE_COLOR: diff --git a/Source/Plugins/Plugin_VideoOGL/Src/main.cpp b/Source/Plugins/Plugin_VideoOGL/Src/main.cpp index 1072eac2cc..e4549af63a 100644 --- a/Source/Plugins/Plugin_VideoOGL/Src/main.cpp +++ b/Source/Plugins/Plugin_VideoOGL/Src/main.cpp @@ -376,11 +376,11 @@ void Video_Prepare(void) VertexLoaderManager::Init(); TextureConverter::Init(); - s_swapRequested = false; + s_swapRequested = FALSE; s_swapResponseEvent.Init(); s_swapResponseEvent.Set(); - s_efbAccessRequested = false; + s_efbAccessRequested = FALSE; s_efbResponseEvent.Init(); s_PluginInitialized = true; @@ -455,13 +455,12 @@ void VideoFifo_CheckSwapRequest() { if (Common::AtomicLoadAcquire(s_swapRequested)) { - s_swapRequested = FALSE; - Renderer::Swap(s_beginFieldArgs.xfbAddr, s_beginFieldArgs.field, s_beginFieldArgs.fbWidth, s_beginFieldArgs.fbHeight); // TODO: Find better name for this because I don't know if it means what it says. g_VideoInitialize.pCopiedToXFB(); + s_swapRequested = FALSE; s_swapResponseEvent.Set(); } } @@ -514,7 +513,10 @@ void Video_BeginField(u32 xfbAddr, FieldType field, u32 fbWidth, u32 fbHeight) // Run from the CPU thread (from VideoInterface.cpp) void Video_EndField() { - Common::AtomicStoreRelease(s_swapRequested, TRUE); + if (s_PluginInitialized) + { + Common::AtomicStoreRelease(s_swapRequested, TRUE); + } } static volatile struct @@ -530,10 +532,9 @@ void VideoFifo_CheckEFBAccess() { if (Common::AtomicLoadAcquire(s_efbAccessRequested)) { - s_efbAccessRequested = FALSE; - s_AccessEFBResult = Renderer::AccessEFB(s_accessEFBArgs.type, s_accessEFBArgs.x, s_accessEFBArgs.y); + s_efbAccessRequested = FALSE; s_efbResponseEvent.Set(); } }