RSX: simplify recale native resolution

This commit is contained in:
raven02 2014-07-08 23:18:29 +08:00
parent cd8f286791
commit 52112006d4
3 changed files with 40 additions and 109 deletions

View File

@ -9,6 +9,37 @@
u32 methodRegisters[0xffff];
void RSXThread::nativeRescale(float width, float height)
{
switch (Ini.GSResolution.GetValue())
{
case 1: // 1920x1080 window size
m_width_scale = 1920 / width * 2.0f;
m_height_scale = 1080 / height * 2.0f;
m_width = 1920;
m_height = 1080;
break;
case 2: // 1280x720 window size
m_width_scale = 1280 / width * 2.0f;
m_height_scale = 720 / height * 2.0f;
m_width = 1280;
m_height = 720;
break;
case 4: // 720x480 window size
m_width_scale = 720 / width * 2.0f;
m_height_scale = 480 / height * 2.0f;
m_width = 720;
m_height = 480;
break;
case 5: // 720x576 window size
m_width_scale = 720 / width * 2.0f;
m_height_scale = 576 / height * 2.0f;
m_width = 720;
m_height = 576;
break;
}
}
u32 GetAddress(u32 offset, u8 location)
{
switch(location)
@ -1337,112 +1368,8 @@ void RSXThread::DoCmd(const u32 fcmd, const u32 cmd, mem32_ptr_t& args, const u3
m_width = m_buffer_width = re(buffers[m_gcm_current_buffer].width);
m_height = m_buffer_height = re(buffers[m_gcm_current_buffer].height);
// Rescale native 1080p to fit 720p/480p window size
if (m_buffer_width == 1920 && m_buffer_height == 1080)
{
switch (Ini.GSResolution.GetValue())
{
case 2: // 1280x720 window size
m_width_scale = m_height_scale = 1.33f;
m_width = 1280;
m_height = 720;
break;
case 4: // 720x480 window size
m_width_scale = 0.75f;
m_height_scale = 0.88f;
m_width = 720;
m_height = 480;
break;
}
}
// Rescale native 720p to fit 480p window size
if (m_buffer_width == 1280 && m_buffer_height == 720)
{
if (Ini.GSResolution.GetValue() == 4) // 720x480 window size
{
m_width_scale = 1.125f;
m_height_scale = 1.33f;
m_width = 720;
m_height = 480;
}
}
// Rescale native 960x540 to fit 1080p/720p/480p window size
if (m_buffer_width == 960 && m_buffer_height == 540)
{
switch (Ini.GSResolution.GetValue())
{
case 1: // 1920x1080 window size
m_width_scale = m_height_scale = 4.0f;
m_width = 1980;
m_height = 1080;
break;
case 2: // 1280x720 window size
m_width_scale = m_height_scale = 2.66f;
m_width = 1280;
m_height = 720;
break;
case 4: // 720x480 window size
m_width_scale = 1.5f;
m_height_scale = 1.77f;
m_width = 720;
m_height = 480;
break;
}
}
// Rescale native 960x1080 to fit 1080p/720p/480p window size
if (m_buffer_width == 960 && m_buffer_height == 1080)
{
switch (Ini.GSResolution.GetValue())
{
case 1: // 1920x1080 window size
m_width_scale = 4.0f;
m_height_scale = 2.0f;
m_width = 1980;
m_height = 1080;
break;
case 2: // 1280x720 window size
m_width_scale = 2.66f;
m_height_scale = 1.33f;
m_width = 1280;
m_height = 720;
break;
case 4: // 720x480 window size
m_width_scale = 1.5f;
m_height_scale = 0.88f;
m_width = 720;
m_height = 480;
break;
}
}
// Rescale native 1024x768 to fit 1080p/720p/480p window size
if (m_buffer_width == 1024 && m_buffer_height == 768)
{
switch (Ini.GSResolution.GetValue())
{
case 1: // 1920x1080 window size
m_width_scale = 3.75f;
m_height_scale = 2.81f;
m_width = 1980;
m_height = 1080;
break;
case 2: // 1280x720 window size
m_width_scale = 2.5f;
m_height_scale = 1.87f;
m_width = 1280;
m_height = 720;
break;
case 4: // 720x480 window size
m_width_scale = 1.4f;
m_height_scale = 1.25f;
m_width = 720;
m_height = 480;
break;
}
}
// Rescale native resolution to fit 1080p/720p/480p/576p window size
nativeRescale((float)m_buffer_width, (float)m_buffer_height);
}
break;

View File

@ -595,7 +595,8 @@ protected:
u32 OutOfArgsCount(const uint x, const u32 cmd, const u32 count);
void DoCmd(const u32 fcmd, const u32 cmd, mem32_ptr_t& args, const u32 count);
void nativeRescale(float width, float height);
virtual void OnInit() = 0;
virtual void OnInitThread() = 0;
virtual void OnExitThread() = 0;

View File

@ -231,6 +231,7 @@ static const CellVideoOutResolution ResolutionTable[] =
{1600, 1080}, //10 - 5
{1440, 1080}, //11 - 6
{1280, 1080}, //12 - 7
{960, 1080}, //13 - 8
};
inline static u32 ResolutionIdToNum(u32 id)
@ -250,9 +251,10 @@ inline static u32 ResolutionIdToNum(u32 id)
5, //10
6, //11
7, //12
8, //13
};
return id <= 12 ? res[id] : 0;
return id <= 13 ? res[id] : 0;
}
inline static u32 ResolutionNumToId(u32 num)
@ -267,7 +269,8 @@ inline static u32 ResolutionNumToId(u32 num)
10, //5
11, //6
12, //7
13, //8
};
return num <= 7 ? res[num] : 0;
return num <= 8 ? res[num] : 0;
}