[Glide64] Change AspectMode to be an enum

This commit is contained in:
zilmar 2017-01-29 17:47:28 +11:00
parent 23e46f85da
commit 8f6107e0bf
6 changed files with 40 additions and 18 deletions

View File

@ -510,11 +510,11 @@ public:
TTSetTxt(IDC_CMB_ASPECT_RATIO, tooltip.c_str());
m_cmbAspect.Attach(GetDlgItem(IDC_CMB_ASPECT_RATIO));
m_cmbAspect.SetItemData(m_cmbAspect.AddString("4:3 (default)"), 0);
m_cmbAspect.SetItemData(m_cmbAspect.AddString("Force 16:9"), 1);
m_cmbAspect.SetItemData(m_cmbAspect.AddString("Stretch"), 2);
m_cmbAspect.SetItemData(m_cmbAspect.AddString("Original"), 3);
SetComboBoxIndex(m_cmbAspect, g_settings->aspectmode);
m_cmbAspect.SetItemData(m_cmbAspect.AddString("4:3 (default)"), CSettings::Aspect_4x3);
m_cmbAspect.SetItemData(m_cmbAspect.AddString("Force 16:9"), CSettings::Aspect_16x9);
m_cmbAspect.SetItemData(m_cmbAspect.AddString("Stretch"), CSettings::Aspect_Stretch);
m_cmbAspect.SetItemData(m_cmbAspect.AddString("Original"), CSettings::Aspect_Original);
SetComboBoxIndex(m_cmbAspect, (uint32_t)g_settings->aspectmode());
tooltip = "Fog enabled:\n\nSets fog emulation on//off.\n\n[Recommended: on]";
TTSetTxt(IDC_CHK_FOG, tooltip.c_str());
@ -561,7 +561,7 @@ public:
CSettings oldsettings = *g_settings;
g_settings->filtering = m_cmbFiltering.GetItemData(m_cmbFiltering.GetCurSel());
g_settings->aspectmode = m_cmbAspect.GetItemData(m_cmbAspect.GetCurSel());
g_settings->SetAspectmode((CSettings::AspectMode_t)m_cmbAspect.GetItemData(m_cmbAspect.GetCurSel()));
g_settings->swapmode = m_cmbBufferSwap.GetItemData(m_cmbBufferSwap.GetCurSel());
g_settings->fog = m_cbxFog.GetCheck() == BST_CHECKED;
g_settings->buff_clear = m_cbxBuffer.GetCheck() == BST_CHECKED;

View File

@ -190,7 +190,7 @@ void ChangeSize()
g_settings->res_x += (uint32_t)rdp.offset_x;
g_settings->res_y += (uint32_t)offset_y;
rdp.offset_y += offset_y;
if (g_settings->aspectmode == 3) // original
if (g_settings->aspectmode() == CSettings::Aspect_Original)
{
rdp.scale_x = rdp.scale_y = 1.0f;
rdp.offset_x = (g_settings->scr_res_x - rdp.vi_width) / 2.0f;

View File

@ -27,7 +27,7 @@ fog(0),
buff_clear(0),
swapmode(0),
lodmode(0),
aspectmode(0),
m_aspectmode(Aspect_4x3),
m_frame_buffer(0),
//Texture filtering options
texture_dir(""),
@ -153,7 +153,7 @@ void CSettings::RegisterSettings(void)
general_setting(Set_fog_default, "fog", 1);
general_setting(Set_buff_clear_default, "buff_clear", 1);
general_setting(Set_swapmode_default, "swapmode", 1);
general_setting(Set_aspect_default, "aspect", 0);
general_setting(Set_aspect_default, "aspect", Aspect_4x3);
general_setting(Set_fb_smart_default, "fb_smart", true);
general_setting(Set_fb_hires_default, "fb_hires", true);
@ -205,6 +205,16 @@ void CSettings::RegisterSettings(void)
game_setting_default(Set_fb_render, "fb_render", Set_fb_render_default);
}
void CSettings::SetAspectmode(AspectMode_t value)
{
if (value != m_aspectmode)
{
m_aspectmode = value;
UpdateAspectRatio();
m_dirty = true;
}
}
void CSettings::UpdateFrameBufferBits(uint32_t BitsToAdd, uint32_t BitsToRemove)
{
uint32_t frame_buffer_original = m_frame_buffer;
@ -218,9 +228,9 @@ void CSettings::UpdateFrameBufferBits(uint32_t BitsToAdd, uint32_t BitsToRemove)
void CSettings::UpdateAspectRatio(void)
{
switch (aspectmode)
switch (m_aspectmode)
{
case 0: //4:3
case Aspect_4x3:
if (scr_res_x >= scr_res_y * 4.0f / 3.0f) {
res_y = scr_res_y;
res_x = (uint32_t)(res_y * 4.0f / 3.0f);
@ -231,7 +241,7 @@ void CSettings::UpdateAspectRatio(void)
res_y = (uint32_t)(res_x / 4.0f * 3.0f);
}
break;
case 1: //16:9
case Aspect_16x9:
if (scr_res_x >= scr_res_y * 16.0f / 9.0f)
{
res_y = scr_res_y;
@ -477,7 +487,6 @@ void CSettings::ReadGameSettings(const char * name)
g_settings->fog = GetSetting(g_romopen ? Set_fog : Set_fog_default);
g_settings->buff_clear = GetSetting(g_romopen ? Set_buff_clear : Set_buff_clear_default);
g_settings->swapmode = GetSetting(g_romopen ? Set_swapmode : Set_swapmode_default);
g_settings->aspectmode = GetSetting(g_romopen ? Set_aspect : Set_aspect_default);
g_settings->lodmode = GetSetting(g_romopen ? Set_lodmode : Set_lodmode_default);
#ifdef _WIN32
g_settings->res_data = GetSetting(Set_Resolution);
@ -535,6 +544,7 @@ void CSettings::ReadGameSettings(const char * name)
else if (read_back_to_screen == 0) { fb_remove_bits |= fb_read_back_to_screen | fb_read_back_to_screen2; }
g_settings->UpdateFrameBufferBits(fb_add_bits, fb_remove_bits);
SetAspectmode((AspectMode_t)GetSetting(g_romopen ? Set_aspect : Set_aspect_default));
g_settings->flame_corona = g_settings->hacks(hack_Zelda) && !fb_depth_render_enabled();
}
@ -586,7 +596,7 @@ void CSettings::WriteSettings(void)
SetSetting(g_romopen ? Set_buff_clear : Set_buff_clear_default, g_settings->buff_clear);
SetSetting(g_romopen ? Set_swapmode : Set_swapmode_default, g_settings->swapmode);
SetSetting(g_romopen ? Set_lodmode : Set_lodmode_default, g_settings->lodmode);
SetSetting(g_romopen ? Set_aspect : Set_aspect_default, g_settings->aspectmode);
SetSetting(g_romopen ? Set_aspect : Set_aspect_default, m_aspectmode);
SetSetting(g_romopen ? Set_fb_read_always : Set_fb_read_always_default, g_settings->fb_ref_enabled() ? true : false);
SetSetting(g_romopen ? Set_fb_smart : Set_fb_smart_default, g_settings->fb_emulation_enabled() ? true : false);

View File

@ -60,6 +60,14 @@ public:
hack_OoT = (1<<30), //zelda OoT hacks
};
enum AspectMode_t
{
Aspect_4x3 = 0,
Aspect_16x9 = 1,
Aspect_Stretch = 2,
Aspect_Original = 3,
};
uint32_t res_x, scr_res_x;
uint32_t res_y, scr_res_y;
#ifndef ANDROID
@ -77,7 +85,6 @@ public:
int buff_clear;
int swapmode;
int lodmode;
int aspectmode;
enum FBCRCMODE
@ -106,6 +113,7 @@ public:
inline const char * log_dir(void) const { return m_log_dir; }
inline bool FlushLogs(void) const { return m_FlushLogs; }
inline AspectMode_t aspectmode(void) const { return m_aspectmode; }
//Texture filtering options
std::string texture_dir;
int ghq_fltr;
@ -169,6 +177,7 @@ public:
int wrpVRAM;
int wrpFBO;
int wrpAnisotropic;
void SetAspectmode(AspectMode_t value);
void UpdateFrameBufferBits(uint32_t BitsToAdd, uint32_t BitsToRemove);
void ReadGameSettings(const char * name);
@ -182,6 +191,7 @@ private:
bool m_dirty;
bool m_FlushLogs;
char m_log_dir[260];
AspectMode_t m_aspectmode;
uint32_t m_frame_buffer;
hacks_t m_hacks;
};

View File

@ -803,9 +803,13 @@ void do_triangle_stuff(uint16_t linew, int old_interpolate) // what else?? do th
else
{
if (!g_settings->clip_zmin)
{
rdp.clip &= ~CLIP_ZMIN;
}
if (!g_settings->clip_zmax)
{
rdp.clip &= ~CLIP_ZMAX;
}
}
render_tri(linew, old_interpolate);
}

View File

@ -62,7 +62,7 @@ static void fb_bg_copy()
if (rdp.main_ci == 0)
return;
CI_STATUS status = rdp.frame_buffers[rdp.ci_count - 1].status;
if ((status == ci_copy))
if (status == ci_copy)
return;
uint32_t addr = segoffset(rdp.cmd1) >> 1;
@ -238,7 +238,6 @@ static void fb_settextureimage()
}
WriteTrace(TraceRDP, TraceDebug, "Detect FB usage. texture addr is inside framebuffer: %08lx - %08lx ", addr, rdp.main_ci);
}
///*
else if ((cur_fb.status != ci_main) && (addr >= rdp.zimg && addr < rdp.zimg_end))
{
cur_fb.status = ci_zcopy;
@ -246,7 +245,6 @@ static void fb_settextureimage()
rdp.copy_zi_index = rdp.ci_count - 1;
WriteTrace(TraceRDP, TraceDebug, "fb_settextureimage. rdp.frame_buffers[%d].status = ci_zcopy", rdp.ci_count - 1);
}
//*/
else if ((rdp.maincimg[0].width > 64) && (addr >= rdp.maincimg[0].addr) && (addr < (rdp.maincimg[0].addr + rdp.maincimg[0].width*rdp.maincimg[0].height * 2)))
{
if (cur_fb.status != ci_main)