diff --git a/core/hw/maple/maple_devs.cpp b/core/hw/maple/maple_devs.cpp index beaa97517..255f7e0f9 100755 --- a/core/hw/maple/maple_devs.cpp +++ b/core/hw/maple/maple_devs.cpp @@ -1384,7 +1384,7 @@ maple_device* maple_Create(MapleDeviceType type) static void screenToNative(int& x, int& y, int width, int height) { float fx, fy; - if ((float)width / height >= 640.f / 480.f) + if (!config::Rotate90) { float scale = 480.f / height; fy = y * scale; @@ -1416,7 +1416,7 @@ void SetMousePosition(int x, int y, int width, int height, u32 mouseId) { int t = y; y = x; - x = height - t; + x = height - 1 - t; std::swap(width, height); } screenToNative(x, y, width, height); diff --git a/core/nullDC.cpp b/core/nullDC.cpp index 8edd92e5a..3456f9cc2 100644 --- a/core/nullDC.cpp +++ b/core/nullDC.cpp @@ -728,11 +728,21 @@ void dc_resume() SetMemoryHandlers(); settings.aica.NoBatch = config::ForceWindowsCE || config::DSPEnabled; int hres; - if ((config::Widescreen || cheatManager.isActive()) && !config::Rotate90) + int vres = config::RenderResolution; + if (config::Widescreen && !config::Rotate90) + { hres = config::RenderResolution * 16 / 9; - else + } + else if (config::Rotate90) + { + vres = vres * config::ScreenStretching / 100; hres = config::RenderResolution * 4 / 3; - renderer->Resize(hres, config::RenderResolution); + } + else + { + hres = config::RenderResolution * 4 * config::ScreenStretching / 3 / 100; + } + renderer->Resize(hres, vres); EventManager::event(Event::Resume); if (!emu_thread.thread.joinable()) diff --git a/core/rend/gles/gldraw.cpp b/core/rend/gles/gldraw.cpp index e1a454d68..3346bb4a9 100644 --- a/core/rend/gles/gldraw.cpp +++ b/core/rend/gles/gldraw.cpp @@ -637,7 +637,12 @@ void DrawStrips() void DrawFramebuffer() { - int sx = (int)roundf((gl.ofbo.width - 4.f / 3.f * gl.ofbo.height) / 2.f); + float aspectRatio = 4.f / 3.f; + if (config::Rotate90) + aspectRatio /= config::ScreenStretching / 100.f; + else + aspectRatio *= config::ScreenStretching / 100.f; + int sx = (int)roundf((gl.ofbo.width - aspectRatio * gl.ofbo.height) / 2.f); glViewport(sx, 0, gl.ofbo.width - sx * 2, gl.ofbo.height); drawQuad(fbTextureId, false, true); glcache.DeleteTextures(1, &fbTextureId); diff --git a/core/rend/gui.cpp b/core/rend/gui.cpp index c4c4349a9..ec4bcc87b 100644 --- a/core/rend/gui.cpp +++ b/core/rend/gui.cpp @@ -2187,29 +2187,21 @@ std::pair getCrosshairPosition(int playerNum) { float fx = mo_x_abs[playerNum]; float fy = mo_y_abs[playerNum]; - int width = screen_width; - int height = screen_height; + float width = 640.f; + float height = 480.f; + if (config::Rotate90) { float t = fy; - fy = width - fx; + fy = 639.f - fx; fx = t; std::swap(width, height); } - if ((float)width / height >= 640.f / 480.f) - { - float scale = 480.f / height; - fy /= scale; - scale *= config::ScreenStretching / 100.f; - fx = fx / scale + (width - 640.f / scale) / 2.f; - } - else - { - float scale = 640.f / width; - fx /= scale; - scale *= config::ScreenStretching / 100.f; - fy = fy / scale + (height - 480.f / scale) / 2.f; - } + float scale = height / screen_height; + fy /= scale; + scale /= config::ScreenStretching / 100.f; + fx = fx / scale + (screen_width - width / scale) / 2.f; + return std::make_pair(fx, fy); } diff --git a/core/rend/transform_matrix.h b/core/rend/transform_matrix.h index 0dcc50e24..676403d15 100644 --- a/core/rend/transform_matrix.h +++ b/core/rend/transform_matrix.h @@ -137,11 +137,22 @@ public: float y_coef; glm::mat4 trans_rot; - float dc2s_scale_h = renderViewport.y / 480.0f; + if (config::Rotate90) + { + float dc2s_scale_h = renderViewport.x / 640.0f; - sidebarWidth = (renderViewport.x - dc2s_scale_h * 640.0f * screen_stretching) / 2; - x_coef = 2.0f / (renderViewport.x / dc2s_scale_h * scale_x) * screen_stretching; - y_coef = 2.0f / dcViewport.y * (invertY ? -1 : 1); + sidebarWidth = 0; + y_coef = 2.0f / (renderViewport.y / dc2s_scale_h * scale_y) * screen_stretching * (invertY ? -1 : 1); + x_coef = 2.0f / dcViewport.x; + } + else + { + float dc2s_scale_h = renderViewport.y / 480.0f; + + sidebarWidth = (renderViewport.x - dc2s_scale_h * 640.0f * screen_stretching) / 2; + x_coef = 2.0f / (renderViewport.x / dc2s_scale_h * scale_x) * screen_stretching; + y_coef = 2.0f / dcViewport.y * (invertY ? -1 : 1); + } trans_rot = glm::translate(glm::vec3(-1 + 2 * sidebarWidth / renderViewport.x, invertY ? 1 : -1, 0)); normalMatrix = trans_rot diff --git a/core/rend/vulkan/overlay.cpp b/core/rend/vulkan/overlay.cpp index 94209263e..3ba3a02f9 100644 --- a/core/rend/vulkan/overlay.cpp +++ b/core/rend/vulkan/overlay.cpp @@ -69,7 +69,6 @@ const std::vector* VulkanOverlay::Prepare(vk::CommandPo { const u32* texData = getCrosshairTextureData(); xhairTexture = createTexture(commandPool, 16, 16, (u8*)texData); -// delete [] texData; } return &commandBuffers[context->GetCurrentImageIndex()]; @@ -141,7 +140,8 @@ void VulkanOverlay::Draw(vk::Extent2D viewport, float scaling, bool vmu, bool cr y -= XHAIR_HEIGHT / 2; vk::Viewport viewport(x, y, XHAIR_WIDTH, XHAIR_HEIGHT); commandBuffer.setViewport(0, 1, &viewport); - commandBuffer.setScissor(0, vk::Rect2D(vk::Offset2D(x, y), vk::Extent2D(XHAIR_WIDTH, XHAIR_HEIGHT))); + commandBuffer.setScissor(0, vk::Rect2D(vk::Offset2D(std::max(0.f, x), std::max(0.f, y)), + vk::Extent2D(XHAIR_WIDTH, XHAIR_HEIGHT))); u32 color = config::CrosshairColor[i]; float xhairColor[4] { (color & 0xff) / 255.f,