From 772ef27a551e578eec043a0276527356fb4cbb16 Mon Sep 17 00:00:00 2001 From: Connor McLaughlin Date: Mon, 28 Oct 2019 17:43:34 +1000 Subject: [PATCH] GPU: Implement display disable command GP1(03h) --- src/core/gpu.cpp | 10 +++++++++- src/core/gpu.h | 2 +- src/core/gpu_hw_opengl.cpp | 8 ++++++-- src/core/gpu_sw.cpp | 7 ++++++- 4 files changed, 22 insertions(+), 5 deletions(-) diff --git a/src/core/gpu.cpp b/src/core/gpu.cpp index 91f487f53..5a6ed434c 100644 --- a/src/core/gpu.cpp +++ b/src/core/gpu.cpp @@ -524,6 +524,14 @@ void GPU::WriteGP1(u32 value) } break; + case 0x03: // Display on/off + { + const bool disable = ConvertToBoolUnchecked(value & 0x01); + Log_DebugPrintf("Display %s", disable ? "disabled" : "enabled"); + m_GPUSTAT.display_disable = disable; + } + break; + case 0x04: // DMA Direction { m_GPUSTAT.dma_direction = static_cast(param); @@ -776,7 +784,7 @@ void GPU::DrawDebugStateWindow() ImGui::Text("Dot Clock Divider: %u", cs.dot_clock_divider); ImGui::Text("Vertical Interlace: %s (%s field)", m_GPUSTAT.vertical_interlace ? "Yes" : "No", m_GPUSTAT.interlaced_field ? "odd" : "even"); - ImGui::Text("Display Enable: %s", m_GPUSTAT.display_enable ? "Yes" : "No"); + ImGui::Text("Display Disable: %s", m_GPUSTAT.display_disable ? "Yes" : "No"); ImGui::Text("Drawing Even Line: %s", m_GPUSTAT.drawing_even_line ? "Yes" : "No"); ImGui::NewLine(); diff --git a/src/core/gpu.h b/src/core/gpu.h index b9d35b5dd..0f82133bf 100644 --- a/src/core/gpu.h +++ b/src/core/gpu.h @@ -284,7 +284,7 @@ protected: BitField pal_mode; BitField display_area_color_depth_24; BitField vertical_interlace; - BitField display_enable; + BitField display_disable; BitField interrupt_request; BitField dma_data_request; BitField ready_to_recieve_cmd; diff --git a/src/core/gpu_hw_opengl.cpp b/src/core/gpu_hw_opengl.cpp index bec37b46f..6c675d214 100644 --- a/src/core/gpu_hw_opengl.cpp +++ b/src/core/gpu_hw_opengl.cpp @@ -399,9 +399,13 @@ void GPU_HW_OpenGL::UpdateDisplay() const u32 flipped_vram_offset_y = VRAM_HEIGHT - vram_offset_y - display_height; const u32 scaled_flipped_vram_offset_y = m_vram_texture->GetHeight() - scaled_vram_offset_y - scaled_display_height; - // fast path when both interlacing and 24-bit depth is off - if (!m_GPUSTAT.display_area_color_depth_24 && !m_GPUSTAT.vertical_interlace) + if (m_GPUSTAT.display_disable) { + m_system->GetHostInterface()->SetDisplayTexture(nullptr, 0, 0, 0, 0, m_crtc_state.display_aspect_ratio); + } + else if (!m_GPUSTAT.display_area_color_depth_24 && !m_GPUSTAT.vertical_interlace) + { + // fast path when both interlacing and 24-bit depth is off glCopyImageSubData(m_vram_texture->GetGLId(), GL_TEXTURE_2D, 0, scaled_vram_offset_x, scaled_flipped_vram_offset_y, 0, m_display_texture->GetGLId(), GL_TEXTURE_2D, 0, 0, 0, 0, scaled_display_width, scaled_display_height, 1); diff --git a/src/core/gpu_sw.cpp b/src/core/gpu_sw.cpp index 9894153ac..31e00cd06 100644 --- a/src/core/gpu_sw.cpp +++ b/src/core/gpu_sw.cpp @@ -127,7 +127,12 @@ void GPU_SW::UpdateDisplay() VRAM_HEIGHT - vram_offset_y); display_aspect_ratio = m_crtc_state.display_aspect_ratio; - if (m_GPUSTAT.display_area_color_depth_24) + if (m_GPUSTAT.display_disable) + { + m_system->GetHostInterface()->SetDisplayTexture(nullptr, 0, 0, 0, 0, display_aspect_ratio); + return; + } + else if (m_GPUSTAT.display_area_color_depth_24) { CopyOut24Bit(m_vram.data() + vram_offset_y * VRAM_WIDTH + vram_offset_x, VRAM_WIDTH, m_display_texture_buffer.data(), display_width, display_width, display_height);