Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WIP: Native res stuff #221

Open
wants to merge 6 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 10 additions & 4 deletions GLideN64/src/DisplayWindow.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
#pragma once
#include "Types.h"
#include "GraphicsDrawer.h"
#include "VI.h"

extern uint32_t retro_screen_width;
extern uint32_t retro_screen_height;
extern uint32_t max_retro_screen_width;
extern uint32_t max_retro_screen_height;

class DisplayWindow
{
Expand Down Expand Up @@ -28,10 +34,10 @@ class DisplayWindow
f32 getScaleY() const { return m_scaleY; }
f32 getAdjustScale() const { return m_adjustScale; }
u32 getBuffersSwapCount() const { return m_buffersSwapCount; }
u32 getWidth() const { return m_width; }
u32 getHeight() const { return m_height; }
u32 getScreenWidth() const { return m_screenWidth; }
u32 getScreenHeight() const { return m_screenHeight; }
u32 getWidth() const { return retro_screen_width; }
u32 getHeight() const { return retro_screen_height; }
u32 getScreenWidth() const { return max_retro_screen_width; }
u32 getScreenHeight() const { return max_retro_screen_height; }
u32 getHeightOffset() const { return m_heightOffset; }
bool isFullscreen() const { return m_bFullscreen; }
bool isAdjustScreen() const { return m_bAdjustScreen; }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,8 +103,8 @@ bool DisplayWindowMupen64plus::_resizeWindow()
{
_setAttributes();
m_bFullscreen = true;
m_width = m_screenWidth = m_resizeWidth;
m_height = m_screenHeight = m_resizeHeight;
m_width = m_resizeWidth;
m_height = m_resizeHeight;
opengl::Utils::isGLError(); // reset GL error.

return true;
Expand Down
19 changes: 18 additions & 1 deletion GLideN64/src/VI.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,13 @@ void VI_UpdateSize()
VI.rheight = VI.height != 0 ? 1.0f / VI.height : 0.0f;
}

extern uint32_t retro_screen_width;
extern uint32_t retro_screen_height;
extern "C" {
uint32_t last_vi_width = retro_screen_width;
uint32_t last_vi_height = retro_screen_height;
}

void VI_UpdateScreen()
{
if (VI.lastOrigin == -1) // Workaround for Mupen64Plus issue with initialization
Expand All @@ -108,8 +115,18 @@ void VI_UpdateScreen()
if (ConfigOpen)
return;

perf.increaseVICount();
DisplayWindow & wnd = dwnd();

uint32_t width = VI.width;
uint32_t height = VI.height;
if(VI.lastOrigin != -1 && (height != last_vi_height || width != last_vi_width))
{
printf("VI_UpdateScreen Origin: %08x, Old origin: %08x, width: %d, height: %d\n", *REG.VI_ORIGIN, VI.lastOrigin, VI.width, VI.height);
last_vi_width = retro_screen_width = width;
last_vi_height = retro_screen_height = height;
}

perf.increaseVICount();
if (wnd.changeWindow())
return;
if (wnd.resizeWindow())
Expand Down
32 changes: 29 additions & 3 deletions libretro/libretro.c
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,13 @@ uint32_t *blitter_buf = NULL;
uint32_t *blitter_buf_lock = NULL;
uint32_t retro_screen_width = 640;
uint32_t retro_screen_height = 480;
uint32_t max_retro_screen_width = 640;
uint32_t max_retro_screen_height = 480;
uint32_t last_retro_screen_width = 640;
uint32_t last_retro_screen_height = 480;
struct retro_game_geometry active_geometry;
extern uint32_t last_vi_width;
extern uint32_t last_vi_height;
uint32_t screen_pitch = 0;

float retro_screen_aspect = 4.0 / 3.0;
Expand Down Expand Up @@ -443,15 +450,24 @@ void retro_get_system_av_info(struct retro_system_av_info *info)
{
info->geometry.base_width = retro_screen_width;
info->geometry.base_height = retro_screen_height;
info->geometry.max_width = retro_screen_width;
info->geometry.max_height = retro_screen_height;
info->geometry.aspect_ratio = retro_screen_aspect;
info->geometry.max_width = max_retro_screen_width;
info->geometry.max_height = max_retro_screen_height;
info->geometry.aspect_ratio = ((float)retro_screen_width) / ((float)retro_screen_height);
#ifdef HAVE_PARALLEL_RDP
if (current_rdp_type == RDP_PLUGIN_PARALLEL)
parallel_get_geometry(&info->geometry);
#endif
info->timing.fps = vi_expected_refresh_rate_from_tv_standard(ROM_PARAMS.systemtype);
info->timing.sample_rate = 44100.0;
memcpy(&active_geometry, &info->geometry, sizeof(struct retro_game_geometry));
}

void retro_set_geometry_runtime(uint32_t width, uint32_t height)
{
active_geometry.base_height = height;
active_geometry.base_width = width;
active_geometry.aspect_ratio = ((float)retro_screen_width) / ((float)retro_screen_height);
environ_cb(RETRO_ENVIRONMENT_SET_GEOMETRY, &active_geometry);
}

unsigned retro_get_region (void)
Expand Down Expand Up @@ -1048,6 +1064,9 @@ static void update_variables(bool startup)
// Force factor to 1 for low resolutions, unless set manually
EnableNativeResFactor = !EnableNativeResFactor ? 1 : EnableNativeResFactor;
}
// Save active configuration as max value
max_retro_screen_width = retro_screen_width;
max_retro_screen_height = retro_screen_height;
}

// If we use Angrylion, we force 640x480
Expand Down Expand Up @@ -1644,6 +1663,13 @@ void retro_run (void)
glsm_ctl(GLSM_CTL_STATE_UNBIND, NULL);
}

if(last_vi_height != last_retro_screen_height || last_vi_width != last_retro_screen_width)
{
last_retro_screen_height = last_vi_height;
last_retro_screen_width = last_vi_width;
retro_set_geometry_runtime(last_retro_screen_width, last_retro_screen_height);
}

if (libretro_swap_buffer)
{
if(current_rdp_type == RDP_PLUGIN_GLIDEN64)
Expand Down