[Glide64] Get swap mode to use an enum

This commit is contained in:
zilmar 2017-01-30 05:05:06 +11:00
parent fbdc95c30a
commit 88e5009afa
6 changed files with 55 additions and 25 deletions

View File

@ -491,10 +491,10 @@ public:
TTSetTxt(IDC_TXT_BUFFER_SWAPPING, tooltip.c_str());
TTSetTxt(IDC_CMB_BUFFER_SWAPPING, tooltip.c_str());
m_cmbBufferSwap.Attach(GetDlgItem(IDC_CMB_BUFFER_SWAPPING));
m_cmbBufferSwap.SetItemData(m_cmbBufferSwap.AddString("Old"), 0);
m_cmbBufferSwap.SetItemData(m_cmbBufferSwap.AddString("New"), 1);
m_cmbBufferSwap.SetItemData(m_cmbBufferSwap.AddString("Hybrid"), 2);
SetComboBoxIndex(m_cmbBufferSwap, g_settings->swapmode);
m_cmbBufferSwap.SetItemData(m_cmbBufferSwap.AddString("Old"), CSettings::SwapMode_Old);
m_cmbBufferSwap.SetItemData(m_cmbBufferSwap.AddString("New"), CSettings::SwapMode_New);
m_cmbBufferSwap.SetItemData(m_cmbBufferSwap.AddString("Hybrid"), CSettings::SwapMode_Hybrid);
SetComboBoxIndex(m_cmbBufferSwap, g_settings->swapmode());
tooltip = "Per-pixel level-of-detail calculation:\n\nN64 uses special mechanism for mip-mapping, which nearly impossible to reproduce correctly on PC hardware.\nThis option enables approximate emulation of this feature.\nFor example, it is required for the Peach/Bowser portrait's transition in Super Mario 64.\nThere are 3 modes:\n\n* off - LOD is not calculated\n* fast - fast imprecise LOD calculation.\n* precise - most precise LOD calculation possible, but more slow.\n\n[Recommended: your preference]";
TTSetTxt(IDC_TXT_LOD_CALC, tooltip.c_str());
@ -562,7 +562,7 @@ public:
g_settings->SetFiltering((CSettings::Filtering_t)m_cmbFiltering.GetItemData(m_cmbFiltering.GetCurSel()));
g_settings->SetAspectmode((CSettings::AspectMode_t)m_cmbAspect.GetItemData(m_cmbAspect.GetCurSel()));
g_settings->swapmode = m_cmbBufferSwap.GetItemData(m_cmbBufferSwap.GetCurSel());
g_settings->SetSwapMode((CSettings::SwapMode_t)m_cmbBufferSwap.GetItemData(m_cmbBufferSwap.GetCurSel()));
g_settings->fog = m_cbxFog.GetCheck() == BST_CHECKED;
g_settings->buff_clear = m_cbxBuffer.GetCheck() == BST_CHECKED;
g_settings->lodmode = m_cmbLOD.GetItemData(m_cmbLOD.GetCurSel());

View File

@ -1422,17 +1422,23 @@ void CALL UpdateScreen(void)
}
return;
}
if (g_settings->swapmode == 0)
if (g_settings->swapmode() == CSettings::SwapMode_Old)
{
newSwapBuffers();
}
}
static void DrawWholeFrameBufferToScreen()
{
static uint32_t toScreenCI = 0;
if (rdp.ci_width < 200)
{
return;
}
if (rdp.cimg == toScreenCI)
{
return;
}
toScreenCI = rdp.cimg;
FB_TO_SCREEN_INFO fb_info;
fb_info.addr = rdp.cimg;
@ -1440,7 +1446,9 @@ static void DrawWholeFrameBufferToScreen()
fb_info.width = rdp.ci_width;
fb_info.height = rdp.ci_height;
if (fb_info.height == 0)
{
return;
}
fb_info.ul_x = 0;
fb_info.lr_x = rdp.ci_width - 1;
fb_info.ul_y = 0;

View File

@ -25,7 +25,7 @@ vsync(0),
fog(0),
buff_clear(0),
swapmode(0),
m_swapmode(SwapMode_Old),
lodmode(0),
m_aspectmode(Aspect_4x3),
m_frame_buffer(0),
@ -152,7 +152,7 @@ void CSettings::RegisterSettings(void)
general_setting(Set_lodmode_default, "lodmode", 0);
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_swapmode_default, "swapmode", SwapMode_New);
general_setting(Set_aspect_default, "aspect", Aspect_4x3);
general_setting(Set_fb_smart_default, "fb_smart", true);
@ -224,6 +224,15 @@ void CSettings::SetFiltering(Filtering_t value)
}
}
void CSettings::SetSwapMode(SwapMode_t value)
{
if (value != m_swapmode)
{
m_swapmode = value;
m_dirty = true;
}
}
void CSettings::UpdateFrameBufferBits(uint32_t BitsToAdd, uint32_t BitsToRemove)
{
uint32_t frame_buffer_original = m_frame_buffer;
@ -494,7 +503,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->lodmode = GetSetting(g_romopen ? Set_lodmode : Set_lodmode_default);
#ifdef _WIN32
g_settings->res_data = GetSetting(Set_Resolution);
@ -554,6 +562,7 @@ void CSettings::ReadGameSettings(const char * name)
g_settings->UpdateFrameBufferBits(fb_add_bits, fb_remove_bits);
SetFiltering((Filtering_t)GetSetting(g_romopen ? Set_filtering : Set_filtering_default));
SetSwapMode((SwapMode_t)GetSetting(g_romopen ? Set_swapmode : Set_swapmode_default));
SetAspectmode((AspectMode_t)GetSetting(g_romopen ? Set_aspect : Set_aspect_default));
g_settings->flame_corona = g_settings->hacks(hack_Zelda) && !fb_depth_render_enabled();
}
@ -603,7 +612,7 @@ void CSettings::WriteSettings(void)
SetSetting(g_romopen ? Set_filtering : Set_filtering_default, filtering());
SetSetting(g_romopen ? Set_fog : Set_fog_default, g_settings->fog);
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_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, m_aspectmode);

View File

@ -83,6 +83,13 @@ public:
Filter_ForcePointSampled = 2,
};
enum SwapMode_t
{
SwapMode_Old = 0,
SwapMode_New = 1,
SwapMode_Hybrid = 2,
};
uint32_t res_x, scr_res_x;
uint32_t res_y, scr_res_y;
#ifndef ANDROID
@ -96,7 +103,6 @@ public:
int fog;
int buff_clear;
int swapmode;
int lodmode;
@ -128,6 +134,7 @@ public:
inline ScreenRotate_t rotate(void) const { return m_rotate; }
inline Filtering_t filtering(void) const { return m_filtering; }
inline SwapMode_t swapmode(void) const { return m_swapmode; }
inline AspectMode_t aspectmode(void) const { return m_aspectmode; }
//Texture filtering options
std::string texture_dir;
@ -194,6 +201,7 @@ public:
int wrpAnisotropic;
void SetAspectmode(AspectMode_t value);
void SetFiltering(Filtering_t value);
void SetSwapMode(SwapMode_t value);
void UpdateFrameBufferBits(uint32_t BitsToAdd, uint32_t BitsToRemove);
void ReadGameSettings(const char * name);
@ -211,6 +219,7 @@ private:
uint32_t m_frame_buffer;
ScreenRotate_t m_rotate;
Filtering_t m_filtering;
SwapMode_t m_swapmode;
hacks_t m_hacks;
};

View File

@ -606,8 +606,10 @@ EXPORT void CALL ProcessDList(void)
GoToFullScreen();
//* Set states *//
if (g_settings->swapmode > 0)
if (g_settings->swapmode() != CSettings::SwapMode_Old)
{
SwapOK = TRUE;
}
rdp.updatescreen = 1;
rdp.tri_n = 0; // 0 triangles so far this frame
@ -697,11 +699,7 @@ EXPORT void CALL ProcessDList(void)
// cmd2 and cmd3 are filled only when needed, by the function that needs them
// Output the address before the command
#ifdef LOG_COMMANDS
WriteTrace(TraceRDP, TraceDebug, "%08lx (c0:%08lx, c1:%08lx): ", a, rdp.cmd0, rdp.cmd1);
#else
WriteTrace(TraceRDP, TraceDebug, "%08lx: ", a);
#endif
// Go to the next instruction
rdp.pc[rdp.pc_i] = (a + 8) & BMASK;
@ -2766,7 +2764,7 @@ static void rdp_setcolorimage()
rdp.skip_drawing = TRUE;
break;
case ci_copy_self:
if (g_settings->fb_hwfbe_enabled() && (rdp.ci_count <= rdp.copy_ci_index) && (!SwapOK || g_settings->swapmode == 2))
if (g_settings->fb_hwfbe_enabled() && (rdp.ci_count <= rdp.copy_ci_index) && (!SwapOK || g_settings->swapmode() == CSettings::SwapMode_Hybrid))
{
OpenTextureBuffer(cur_fb);
}
@ -2896,12 +2894,14 @@ static void rdp_setcolorimage()
}
CI_SET = TRUE;
if (g_settings->swapmode > 0)
if (g_settings->swapmode() != CSettings::SwapMode_Old)
{
if (rdp.zimg == rdp.cimg)
{
rdp.updatescreen = 1;
}
int viSwapOK = ((g_settings->swapmode == 2) && (rdp.vi_org_reg == *gfx.VI_ORIGIN_REG)) ? FALSE : TRUE;
int viSwapOK = ((g_settings->swapmode() == CSettings::SwapMode_Hybrid) && (rdp.vi_org_reg == *gfx.VI_ORIGIN_REG)) ? FALSE : TRUE;
if ((rdp.zimg != rdp.cimg) && (rdp.ocimg != rdp.cimg) && SwapOK && viSwapOK && !rdp.cur_image)
{
if (g_settings->fb_emulation_enabled())
@ -2912,7 +2912,7 @@ static void rdp_setcolorimage()
{
rdp.maincimg[0].addr = rdp.cimg;
}
rdp.last_drawn_ci_addr = (g_settings->swapmode == 2) ? swapped_addr : rdp.maincimg[0].addr;
rdp.last_drawn_ci_addr = (g_settings->swapmode() == CSettings::SwapMode_Hybrid) ? swapped_addr : rdp.maincimg[0].addr;
swapped_addr = rdp.cimg;
newSwapBuffers();
rdp.vi_org_reg = *gfx.VI_ORIGIN_REG;
@ -3366,7 +3366,7 @@ void DetectFrameBufferUsage()
{
if (g_settings->fb_hwfbe_enabled())
{
if (rdp.read_previous_ci && !previous_ci_was_read && (g_settings->swapmode != 2) && (g_settings->ucode != ucode_PerfectDark))
if (rdp.read_previous_ci && !previous_ci_was_read && (g_settings->swapmode() != CSettings::SwapMode_Hybrid) && (g_settings->ucode != ucode_PerfectDark))
{
int ind = (rdp.ci_count > 0) ? rdp.ci_count - 1 : 0;
uint32_t height = rdp.frame_buffers[ind].height;
@ -4054,8 +4054,10 @@ void CALL ProcessRDPList(void)
GoToFullScreen();
//* Set states *//
if (g_settings->swapmode > 0)
if (g_settings->swapmode() != CSettings::SwapMode_Old)
{
SwapOK = TRUE;
}
rdp.updatescreen = 1;
rdp.tri_n = 0; // 0 triangles so far this frame
@ -4109,7 +4111,8 @@ void CALL ProcessRDPList(void)
bool setZero = true;
while (rdp_cmd_cur != rdp_cmd_ptr) {
while (rdp_cmd_cur != rdp_cmd_ptr)
{
uint32_t cmd = (rdp_cmd_data[rdp_cmd_cur] >> 24) & 0x3f;
if ((((rdp_cmd_ptr - rdp_cmd_cur)&maxCMDMask) * 4) < rdp_command_length[cmd]) {
@ -4131,7 +4134,8 @@ void CALL ProcessRDPList(void)
rdp_cmd_cur = (rdp_cmd_cur + rdp_command_length[cmd] / 4) & maxCMDMask;
}
if (setZero) {
if (setZero)
{
rdp_cmd_ptr = 0;
rdp_cmd_cur = 0;
}

View File

@ -430,7 +430,7 @@ static void fb_setcolorimage()
}
if (cur_fb.status == ci_main)
{
int viSwapOK = ((g_settings->swapmode == 2) && (rdp.vi_org_reg == *gfx.VI_ORIGIN_REG)) ? FALSE : TRUE;
int viSwapOK = ((g_settings->swapmode() == CSettings::SwapMode_Hybrid) && (rdp.vi_org_reg == *gfx.VI_ORIGIN_REG)) ? FALSE : TRUE;
if ((rdp.maincimg[0].addr != cur_fb.addr) && SwapOK && viSwapOK)
{
SwapOK = FALSE;