From 23e46f85da023125cd2f107e5ceb6443cba66c5a Mon Sep 17 00:00:00 2001 From: zilmar Date: Sun, 29 Jan 2017 17:26:41 +1100 Subject: [PATCH] [Glide64] Change game hack value to enum --- Source/Glide64/3dmath.cpp | 2 +- Source/Glide64/Combine.cpp | 26 +++---- Source/Glide64/FBtoScreen.cpp | 4 +- Source/Glide64/Main.cpp | 17 ++--- Source/Glide64/Settings.cpp | 136 +++++++++++++++++++++++++--------- Source/Glide64/Settings.h | 74 +++++++++--------- Source/Glide64/TexBuffer.cpp | 4 +- Source/Glide64/TexCache.cpp | 17 +---- Source/Glide64/Util.cpp | 6 +- Source/Glide64/rdp.cpp | 110 ++++++++++++++------------- Source/Glide64/ucode00.h | 11 ++- Source/Glide64/ucode02.h | 4 +- Source/Glide64/ucode05.h | 2 +- Source/Glide64/ucode06.h | 18 +++-- 14 files changed, 250 insertions(+), 181 deletions(-) diff --git a/Source/Glide64/3dmath.cpp b/Source/Glide64/3dmath.cpp index 6100d4f42..ec0fc13c8 100644 --- a/Source/Glide64/3dmath.cpp +++ b/Source/Glide64/3dmath.cpp @@ -122,7 +122,7 @@ void calc_sphere(VERTEX *v) WriteTrace(TraceRDP, TraceDebug, "calc_sphere"); DECLAREALIGN16VAR(vec[3]); int s_scale, t_scale; - if (g_settings->hacks&hack_Chopper) + if (g_settings->hacks(CSettings::hack_Chopper)) { s_scale = minval(rdp.tiles[rdp.cur_tile].org_s_scale >> 6, rdp.tiles[rdp.cur_tile].lr_s); t_scale = minval(rdp.tiles[rdp.cur_tile].org_t_scale >> 6, rdp.tiles[rdp.cur_tile].lr_t); diff --git a/Source/Glide64/Combine.cpp b/Source/Glide64/Combine.cpp index b3ca4b031..0d3dbde3a 100644 --- a/Source/Glide64/Combine.cpp +++ b/Source/Glide64/Combine.cpp @@ -997,7 +997,7 @@ static void cc_shade() static void cc_one_mul_shade() { - if ((g_settings->hacks&hack_Knockout) && (rdp.aTBuffTex[0] || rdp.aTBuffTex[1] || rdp.cur_image)) //hack for boxer shadow + if (g_settings->hacks(CSettings::hack_Knockout) && (rdp.aTBuffTex[0] || rdp.aTBuffTex[1] || rdp.cur_image)) //hack for boxer shadow { CCMB(GR_COMBINE_FUNCTION_SCALE_OTHER, GR_COMBINE_FACTOR_LOCAL, @@ -5976,7 +5976,7 @@ static void cc_prim_sub_env_mul_t1_add_env() GR_COMBINE_OTHER_CONSTANT); CC_PRIM(); SETSHADE_ENV(); - if (rdp.cycle_mode == 0 || ((g_settings->hacks&hack_KI) && (rdp.cycle2 & 0x0FFFFFFF) == 0x01FF1FFF)) + if (rdp.cycle_mode == 0 || (g_settings->hacks(CSettings::hack_KI) && (rdp.cycle2 & 0x0FFFFFFF) == 0x01FF1FFF)) { USE_T0(); } @@ -8130,7 +8130,7 @@ static void cc__t1_inter_t0_using_prim__mul_shade() static void cc__t0_inter_t1_using_primlod__mul_shade() { //* - if (rdp.LOD_en && (rdp.mipmap_level == 0) && !(g_settings->hacks&hack_Fifa98)) + if (rdp.LOD_en && (rdp.mipmap_level == 0) && !g_settings->hacks(CSettings::hack_Fifa98)) { cc_t0_mul_shade(); return; @@ -8412,7 +8412,7 @@ static void cc__one_inter_prim_using_t1__mul_shade() { if (cmb.combine_ext) { - if ((g_settings->hacks&hack_BAR) && rdp.cur_tile == 1) + if (g_settings->hacks(CSettings::hack_BAR) && rdp.cur_tile == 1) { T0CCMBEXT(GR_CMBX_TMU_CCOLOR, GR_FUNC_MODE_X, GR_CMBX_TMU_CALPHA, GR_FUNC_MODE_NEGATIVE_X, @@ -8444,7 +8444,7 @@ static void cc__one_inter_prim_using_t1__mul_shade() GR_COMBINE_FACTOR_LOCAL, GR_COMBINE_LOCAL_ITERATED, GR_COMBINE_OTHER_TEXTURE); - if ((g_settings->hacks&hack_BAR) && rdp.cur_tile == 1) + if (g_settings->hacks(CSettings::hack_BAR) && rdp.cur_tile == 1) { MOD_0(TMOD_COL_INTER_COL1_USING_TEX); MOD_0_COL(0xFFFFFF00); @@ -8813,7 +8813,7 @@ static void ac_t1() GR_COMBINE_FACTOR_ONE, GR_COMBINE_LOCAL_NONE, GR_COMBINE_OTHER_TEXTURE); - if ((g_settings->hacks&hack_BAR) && rdp.tiles[rdp.cur_tile].format == 3) + if (g_settings->hacks(CSettings::hack_BAR) && rdp.tiles[rdp.cur_tile].format == 3) A_USE_T0(); else A_USE_T1(); @@ -11202,7 +11202,7 @@ static void ac__t1_mul_primlod_add_t0__mul_env() static void ac__t0_inter_t1_using_primlod__mul_shade() { - if (g_settings->hacks & hack_Makers) + if (g_settings->hacks(CSettings::hack_Makers)) { //rolling rock issue - it has zero shade alpha and thus rejected by alpha compare ac_t0_inter_t1_using_primlod(); @@ -15679,7 +15679,7 @@ void Combine() cc_t0(); ac_t1(); } - else if (color_combine == 0x613522f0 && (g_settings->hacks&hack_PMario)) //Paper Mario fortune teller spheres + else if (color_combine == 0x613522f0 && g_settings->hacks(CSettings::hack_PMario)) //Paper Mario fortune teller spheres { ac_t0(); } @@ -15709,7 +15709,7 @@ void Combine() { if (aTBuff[0] && g_settings->fb_read_alpha_enabled()) { - if ((g_settings->hacks&hack_PMario) && aTBuff[0]->width == rdp.ci_width) + if (g_settings->hacks(CSettings::hack_PMario) && aTBuff[0]->width == rdp.ci_width) ; else { @@ -15903,7 +15903,7 @@ void CombineBlender() */ else if (blendmode == 0x0040) // Mia Soccer Lights A_BLEND(GR_BLEND_SRC_ALPHA, GR_BLEND_ONE_MINUS_SRC_ALPHA); - else if ((g_settings->hacks&hack_Pilotwings) && (rdp.othermode_l & 0x80)) //CLR_ON_CVG without FORCE_BL + else if (g_settings->hacks(CSettings::hack_Pilotwings) && (rdp.othermode_l & 0x80)) //CLR_ON_CVG without FORCE_BL A_BLEND(GR_BLEND_ZERO, GR_BLEND_ONE); else A_BLEND(GR_BLEND_ONE, GR_BLEND_ZERO); @@ -15913,7 +15913,7 @@ void CombineBlender() // if (rdp.othermode_l & 0x2000) if ((rdp.othermode_l & 0x2000) && ((rdp.othermode_l & 0x7000) != 0x7000)) { - if ((g_settings->hacks&hack_PMario) && (blendmode == 0x5055)) + if (g_settings->hacks(CSettings::hack_PMario) && (blendmode == 0x5055)) { A_BLEND(GR_BLEND_ZERO, GR_BLEND_ONE); } @@ -15929,7 +15929,7 @@ void CombineBlender() //hack //* - if (g_settings->hacks&hack_ISS64) + if (g_settings->hacks(CSettings::hack_ISS64)) { if (rdp.othermode_l == 0xff5a6379) { @@ -15940,7 +15940,7 @@ void CombineBlender() A_BLEND(GR_BLEND_ZERO, GR_BLEND_ONE); } } - else if (g_settings->hacks&hack_TGR) + else if (g_settings->hacks(CSettings::hack_TGR)) { if (rdp.othermode_l == 0x0f0a0235) { diff --git a/Source/Glide64/FBtoScreen.cpp b/Source/Glide64/FBtoScreen.cpp index 63fa43569..d67176132 100644 --- a/Source/Glide64/FBtoScreen.cpp +++ b/Source/Glide64/FBtoScreen.cpp @@ -191,7 +191,7 @@ static void DrawRE2Video256(FB_TO_SCREEN_INFO & fb_info) static void DrawFrameBufferToScreen256(FB_TO_SCREEN_INFO & fb_info) { - if (g_settings->hacks&hack_RE2) + if (g_settings->hacks(CSettings::hack_RE2)) { DrawRE2Video256(fb_info); return; @@ -403,7 +403,7 @@ bool DrawFrameBufferToScreen(FB_TO_SCREEN_INFO & fb_info) voodoo.tex_min_addr[tmu] + voodoo.tmem_ptr[tmu], GR_MIPMAPLEVELMASK_BOTH, &t_info); - if (g_settings->hacks&hack_RE2) + if (g_settings->hacks(CSettings::hack_RE2)) { DrawRE2Video(fb_info, scale); } diff --git a/Source/Glide64/Main.cpp b/Source/Glide64/Main.cpp index f912b320a..7158f5f18 100644 --- a/Source/Glide64/Main.cpp +++ b/Source/Glide64/Main.cpp @@ -691,7 +691,7 @@ int InitGfx() grGet(GR_NUM_TMU, 4, (FxI32*)&voodoo.num_tmu); // get maximal texture size grGet(GR_MAX_TEXTURE_SIZE, 4, (FxI32*)&voodoo.max_tex_size); - voodoo.sup_large_tex = (voodoo.max_tex_size > 256 && !(g_settings->hacks & hack_PPL)); + voodoo.sup_large_tex = (voodoo.max_tex_size > 256 && !g_settings->hacks(CSettings::hack_PPL)); //num_tmu = 1; if (voodoo.tex_UMA) @@ -709,7 +709,7 @@ int InitGfx() voodoo.tex_max_addr[1] = grTexMaxAddress(GR_TMU1); } - if (strstr(extensions, "TEXMIRROR") && !(g_settings->hacks&hack_Zelda)) //zelda's trees suffer from hardware mirroring + if (strstr(extensions, "TEXMIRROR") && !g_settings->hacks(CSettings::hack_Zelda)) //zelda's trees suffer from hardware mirroring voodoo.sup_mirroring = 1; else voodoo.sup_mirroring = 0; @@ -1361,7 +1361,7 @@ void drawViRegBG() rdp.last_bg = fb_info.addr; bool drawn = DrawFrameBufferToScreen(fb_info); - if (g_settings->hacks&hack_Lego && drawn) + if (g_settings->hacks(CSettings::hack_Lego) && drawn) { rdp.updatescreen = 1; newSwapBuffers(); @@ -1399,7 +1399,7 @@ void CALL UpdateScreen(void) { update_screen_count++; } - uint32_t limit = (g_settings->hacks&hack_Lego) ? 15 : 30; + uint32_t limit = g_settings->hacks(CSettings::hack_Lego) ? 15 : 30; if (g_settings->fb_cpu_write_hack_enabled() && (update_screen_count > limit) && (rdp.last_bg == 0)) { WriteTrace(TraceRDP, TraceDebug, "DirectCPUWrite hack!"); @@ -1661,7 +1661,7 @@ void newSwapBuffers() DrawWholeFrameBufferToScreen(); } - if (g_settings->fb_hwfbe_enabled() && !(g_settings->hacks&hack_RE2) && !evoodoo) + if (g_settings->fb_hwfbe_enabled() && !g_settings->hacks(CSettings::hack_RE2) && !evoodoo) { grAuxBufferExt(GR_BUFFER_AUXBUFFER); } @@ -1689,12 +1689,9 @@ void newSwapBuffers() } } - if (g_settings->wireframe || g_settings->buff_clear || (g_settings->hacks&hack_PPL && g_settings->ucode == 6)) + if (g_settings->wireframe || g_settings->buff_clear || (g_settings->hacks(CSettings::hack_PPL) && g_settings->ucode == 6)) { - if (g_settings->hacks&hack_RE2 && g_settings->fb_depth_render_enabled()) - grDepthMask(FXFALSE); - else - grDepthMask(FXTRUE); + grDepthMask((g_settings->hacks(CSettings::hack_RE2) && g_settings->fb_depth_render_enabled()) ? FXFALSE : FXTRUE); grBufferClear(0, 0, 0xFFFF); } diff --git a/Source/Glide64/Settings.cpp b/Source/Glide64/Settings.cpp index e671989b2..608f7867a 100644 --- a/Source/Glide64/Settings.cpp +++ b/Source/Glide64/Settings.cpp @@ -83,7 +83,7 @@ zmode_compare_less(0), //force GR_CMP_LESS for zmode=0 (opaque)and zmode=1 (inte old_style_adither(0), //apply alpha dither regardless of alpha_dither_mode n64_z_scale(0), //scale vertex z value before writing to depth buffer, as N64 does. -hacks(0), + m_hacks((hacks_t)0), //wrapper settings #ifndef ANDROID @@ -317,73 +317,137 @@ void CSettings::ReadSettings() void CSettings::ReadGameSettings(const char * name) { - g_settings->hacks = 0; + m_hacks = (hacks_t)0; //detect games which require special hacks if (strstr(name, (const char *)"ZELDA")) - g_settings->hacks |= (hack_Zelda | hack_OoT); + { + m_hacks = (hacks_t)(m_hacks | (CSettings::hack_Zelda | CSettings::hack_OoT)); + } else if (strstr(name, (const char *)"MASK")) - g_settings->hacks |= hack_Zelda; + { + m_hacks = (hacks_t)(m_hacks | CSettings::hack_Zelda); + } else if (strstr(name, (const char *)"ROADSTERS TROPHY")) - g_settings->hacks |= hack_Zelda; + { + m_hacks = (hacks_t)(m_hacks | CSettings::hack_Zelda); + } else if (strstr(name, (const char *)"Diddy Kong Racing")) - g_settings->hacks |= hack_Diddy; + { + m_hacks = (hacks_t)(m_hacks | CSettings::hack_Diddy); + } else if (strstr(name, (const char *)"Tonic Trouble")) - g_settings->hacks |= hack_Tonic; + { + m_hacks = (hacks_t)(m_hacks | CSettings::hack_Tonic); + } else if (strstr(name, (const char *)"All") && strstr(name, (const char *)"Star") && strstr(name, (const char *)"Baseball")) - g_settings->hacks |= hack_ASB; + { + m_hacks = (hacks_t)(m_hacks | CSettings::hack_ASB); + } else if (strstr(name, (const char *)"Beetle") || strstr(name, (const char *)"BEETLE") || strstr(name, (const char *)"HSV")) - g_settings->hacks |= hack_BAR; + { + m_hacks = (hacks_t)(m_hacks | CSettings::hack_BAR); + } else if (strstr(name, (const char *)"I S S 64") || strstr(name, (const char *)"J WORLD SOCCER3") || strstr(name, (const char *)"PERFECT STRIKER") || strstr(name, (const char *)"RONALDINHO SOCCER")) - g_settings->hacks |= hack_ISS64; + { + m_hacks = (hacks_t)(m_hacks | CSettings::hack_ISS64); + } else if (strstr(name, (const char *)"MARIOKART64")) - g_settings->hacks |= hack_MK64; + { + m_hacks = (hacks_t)(m_hacks | CSettings::hack_MK64); + } else if (strstr(name, (const char *)"NITRO64")) - g_settings->hacks |= hack_WCWnitro; + { + m_hacks = (hacks_t)(m_hacks | CSettings::hack_WCWnitro); + } else if (strstr(name, (const char *)"CHOPPER_ATTACK") || strstr(name, (const char *)"WILD CHOPPERS")) - g_settings->hacks |= hack_Chopper; + { + m_hacks = (hacks_t)(m_hacks | CSettings::hack_Chopper); + } else if (strstr(name, (const char *)"Resident Evil II") || strstr(name, (const char *)"BioHazard II")) - g_settings->hacks |= hack_RE2; + { + m_hacks = (hacks_t)(m_hacks | CSettings::hack_RE2); + } else if (strstr(name, (const char *)"YOSHI STORY")) - g_settings->hacks |= hack_Yoshi; + { + m_hacks = (hacks_t)(m_hacks | CSettings::hack_Yoshi); + } else if (strstr(name, (const char *)"F-Zero X") || strstr(name, (const char *)"F-ZERO X")) - g_settings->hacks |= hack_Fzero; + { + m_hacks = (hacks_t)(m_hacks | CSettings::hack_Fzero); + } else if (strstr(name, (const char *)"PAPER MARIO") || strstr(name, (const char *)"MARIO STORY")) - g_settings->hacks |= hack_PMario; + { + m_hacks = (hacks_t)(m_hacks | CSettings::hack_PMario); + } else if (strstr(name, (const char *)"TOP GEAR RALLY 2")) - g_settings->hacks |= hack_TGR2; + { + m_hacks = (hacks_t)(m_hacks | CSettings::hack_TGR2); + } else if (strstr(name, (const char *)"TOP GEAR RALLY")) - g_settings->hacks |= hack_TGR; + { + m_hacks = (hacks_t)(m_hacks | CSettings::hack_TGR); + } else if (strstr(name, (const char *)"Top Gear Hyper Bike")) - g_settings->hacks |= hack_Hyperbike; + { + m_hacks = (hacks_t)(m_hacks | CSettings::hack_Hyperbike); + } else if (strstr(name, (const char *)"Killer Instinct Gold") || strstr(name, (const char *)"KILLER INSTINCT GOLD")) - g_settings->hacks |= hack_KI; + { + m_hacks = (hacks_t)(m_hacks | CSettings::hack_KI); + } else if (strstr(name, (const char *)"Knockout Kings 2000")) - g_settings->hacks |= hack_Knockout; + { + m_hacks = (hacks_t)(m_hacks | CSettings::hack_Knockout); + } else if (strstr(name, (const char *)"LEGORacers")) - g_settings->hacks |= hack_Lego; + { + m_hacks = (hacks_t)(m_hacks | CSettings::hack_Lego); + } else if (strstr(name, (const char *)"OgreBattle64")) - g_settings->hacks |= hack_Ogre64; + { + m_hacks = (hacks_t)(m_hacks | CSettings::hack_Ogre64); + } else if (strstr(name, (const char *)"Pilot Wings64")) - g_settings->hacks |= hack_Pilotwings; + { + m_hacks = (hacks_t)(m_hacks | CSettings::hack_Pilotwings); + } else if (strstr(name, (const char *)"Supercross")) - g_settings->hacks |= hack_Supercross; + { + m_hacks = (hacks_t)(m_hacks | CSettings::hack_Supercross); + } else if (strstr(name, (const char *)"STARCRAFT 64")) - g_settings->hacks |= hack_Starcraft; + { + m_hacks = (hacks_t)(m_hacks | CSettings::hack_Starcraft); + } else if (strstr(name, (const char *)"BANJO KAZOOIE 2") || strstr(name, (const char *)"BANJO TOOIE")) - g_settings->hacks |= hack_Banjo2; + { + m_hacks = (hacks_t)(m_hacks | CSettings::hack_Banjo2); + } else if (strstr(name, (const char *)"FIFA: RTWC 98") || strstr(name, (const char *)"RoadToWorldCup98")) - g_settings->hacks |= hack_Fifa98; + { + m_hacks = (hacks_t)(m_hacks | CSettings::hack_Fifa98); + } else if (strstr(name, (const char *)"Mega Man 64") || strstr(name, (const char *)"RockMan Dash")) - g_settings->hacks |= hack_Megaman; + { + m_hacks = (hacks_t)(m_hacks | CSettings::hack_Megaman); + } else if (strstr(name, (const char *)"MISCHIEF MAKERS") || strstr(name, (const char *)"TROUBLE MAKERS")) - g_settings->hacks |= hack_Makers; + { + m_hacks = (hacks_t)(m_hacks | CSettings::hack_Makers); + } else if (strstr(name, (const char *)"GOLDENEYE")) - g_settings->hacks |= hack_GoldenEye; + { + m_hacks = (hacks_t)(m_hacks | CSettings::hack_GoldenEye); + } else if (strstr(name, (const char *)"PUZZLE LEAGUE")) - g_settings->hacks |= hack_PPL; - else if (strstr(name, (const char *)"WIN BACK") || strstr(name, (const char *)"OPERATION WINBACK")) - g_settings->hacks |= hack_Winback; + { + m_hacks = (hacks_t)(m_hacks | CSettings::hack_PPL); + } + else if (strstr(name, (const char *)"WIN BACK") || strstr(name, (const char *)"OPERATION WINBACK")) + { + m_hacks = (hacks_t)(m_hacks | CSettings::hack_Winback); + } g_settings->alt_tex_size = GetSetting(Set_alt_tex_size); g_settings->use_sts1_only = GetSetting(Set_use_sts1_only); @@ -471,7 +535,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); - g_settings->flame_corona = (g_settings->hacks & hack_Zelda) && !fb_depth_render_enabled(); + g_settings->flame_corona = g_settings->hacks(hack_Zelda) && !fb_depth_render_enabled(); } void CSettings::WriteSettings(void) diff --git a/Source/Glide64/Settings.h b/Source/Glide64/Settings.h index 4a8163af1..b5b9bfdc0 100644 --- a/Source/Glide64/Settings.h +++ b/Source/Glide64/Settings.h @@ -25,6 +25,41 @@ public: fb_cpu_write_hack = (1 << 14), //show images writed directly by CPU }; + enum hacks_t + { + hack_ASB = (1<<0), //All-Star Baseball games + hack_Banjo2 = (1<<1), //Banjo Tooie + hack_BAR = (1<<2), //Beetle Adventure Racing + hack_Chopper = (1<<3), //Chopper Attack + hack_Diddy = (1<<4), //diddy kong racing + hack_Fifa98 = (1<<5), //FIFA - Road to World Cup 98 + hack_Fzero = (1<<6), //F-Zero + hack_GoldenEye = (1<<7), //Golden Eye + hack_Hyperbike = (1<<8), //Top Gear Hyper Bike + hack_ISS64 = (1<<9), //International Superstar Soccer 64 + hack_KI = (1<<10), //Killer Instinct + hack_Knockout = (1<<11), //Knockout Kings 2000 + hack_Lego = (1<<12), //LEGO Racers + hack_MK64 = (1<<13), //Mario Kart + hack_Megaman = (1<<14), //Megaman64 + hack_Makers = (1<<15), //Mischief-makers + hack_WCWnitro = (1<<16), //WCW Nitro + hack_Ogre64 = (1<<17), //Ogre Battle 64 + hack_Pilotwings = (1<<18), //Pilotwings + hack_PMario = (1<<19), //Paper Mario + hack_PPL = (1<<20), //pokemon puzzle league requires many special fixes + hack_RE2 = (1<<21), //Resident Evil 2 + hack_Starcraft = (1<<22), //StarCraft64 + hack_Supercross = (1<<23), //Supercross 2000 + hack_TGR = (1<<24), //Top Gear Rally + hack_TGR2 = (1<<25), //Top Gear Rally 2 + hack_Tonic = (1<<26), //tonic trouble + hack_Winback = (1<<27), //WinBack - Covert Operations + hack_Yoshi = (1<<28), //Yoshi Story + hack_Zelda = (1<<29), //zeldas hacks + hack_OoT = (1<<30), //zelda OoT hacks + }; + uint32_t res_x, scr_res_x; uint32_t res_y, scr_res_y; #ifndef ANDROID @@ -124,41 +159,9 @@ public: int zmode_compare_less; //force GR_CMP_LESS for zmode=0 (opaque)and zmode=1 (interpenetrating) int old_style_adither; //apply alpha dither regardless of alpha_dither_mode int n64_z_scale; //scale vertex z value before writing to depth buffer, as N64 does. - - //Special game hacks -#define hack_ASB (1<<0) //All-Star Baseball games -#define hack_Banjo2 (1<<1) //Banjo Tooie -#define hack_BAR (1<<2) //Beetle Adventure Racing -#define hack_Chopper (1<<3) //Chopper Attack -#define hack_Diddy (1<<4) //diddy kong racing -#define hack_Fifa98 (1<<5) //FIFA - Road to World Cup 98 -#define hack_Fzero (1<<6) //F-Zero -#define hack_GoldenEye (1<<7) //Golden Eye -#define hack_Hyperbike (1<<8) //Top Gear Hyper Bike -#define hack_ISS64 (1<<9) //International Superstar Soccer 64 -#define hack_KI (1<<10) //Killer Instinct -#define hack_Knockout (1<<11) //Knockout Kings 2000 -#define hack_Lego (1<<12) //LEGO Racers -#define hack_MK64 (1<<13) //Mario Kart -#define hack_Megaman (1<<14) //Megaman64 -#define hack_Makers (1<<15) //Mischief-makers -#define hack_WCWnitro (1<<16) //WCW Nitro -#define hack_Ogre64 (1<<17) //Ogre Battle 64 -#define hack_Pilotwings (1<<18) //Pilotwings -#define hack_PMario (1<<19) //Paper Mario -#define hack_PPL (1<<20) //pokemon puzzle league requires many special fixes -#define hack_RE2 (1<<21) //Resident Evil 2 -#define hack_Starcraft (1<<22) //StarCraft64 -#define hack_Supercross (1<<23) //Supercross 2000 -#define hack_TGR (1<<24) //Top Gear Rally -#define hack_TGR2 (1<<25) //Top Gear Rally 2 -#define hack_Tonic (1<<26) //tonic trouble -#define hack_Winback (1<<27) //WinBack - Covert Operations -#define hack_Yoshi (1<<28) //Yoshi Story -#define hack_Zelda (1<<29) //zeldas hacks -#define hack_OoT (1<<30) //zelda OoT hacks - uint32_t hacks; - + + inline bool hacks(hacks_t hack) const { return (m_hacks & hack) == hack; } //Special game hacks + //wrapper settings #ifndef ANDROID int wrpResolution; @@ -180,6 +183,7 @@ private: bool m_FlushLogs; char m_log_dir[260]; uint32_t m_frame_buffer; + hacks_t m_hacks; }; extern CSettings * g_settings; diff --git a/Source/Glide64/TexBuffer.cpp b/Source/Glide64/TexBuffer.cpp index b6204b91b..7d2d96a88 100644 --- a/Source/Glide64/TexBuffer.cpp +++ b/Source/Glide64/TexBuffer.cpp @@ -216,7 +216,7 @@ int OpenTextureBuffer(COLOR_IMAGE & cimage) int found = FALSE, search = TRUE; TBUFF_COLOR_IMAGE *texbuf = 0; uint32_t addr = cimage.addr; - if ((g_settings->hacks&hack_Banjo2) && cimage.status == ci_copy_self) + if (g_settings->hacks(CSettings::hack_Banjo2) && cimage.status == ci_copy_self) addr = rdp.frame_buffers[rdp.copy_ci_index].addr; uint32_t end_addr = addr + ((cimage.width*cimage.height) << cimage.size >> 1); if (rdp.motionblur) @@ -227,7 +227,7 @@ int OpenTextureBuffer(COLOR_IMAGE & cimage) } if (rdp.read_whole_frame) { - if (g_settings->hacks&hack_PMario) //motion blur effects in Paper Mario + if (g_settings->hacks(CSettings::hack_PMario)) //motion blur effects in Paper Mario { rdp.cur_tex_buf = rdp.acc_tex_buf; WriteTrace(TraceRDP, TraceDebug, "\nread_whole_frame. last allocated bank: %d", rdp.acc_tex_buf); diff --git a/Source/Glide64/TexCache.cpp b/Source/Glide64/TexCache.cpp index 0934735b5..52be3d904 100644 --- a/Source/Glide64/TexCache.cpp +++ b/Source/Glide64/TexCache.cpp @@ -76,7 +76,8 @@ typedef struct TEXINFO_t TEXINFO texinfo[2]; int tex_found[2][MAX_TMU]; -typedef struct HIRESTEX_t { +typedef struct HIRESTEX_t +{ int width, height; uint16_t format; uint8_t *data; @@ -999,7 +1000,7 @@ void LoadTex(int id, int tmu) //!Hackalert //GoldenEye water texture. It has CI format in fact, but the game set it to RGBA - if ((g_settings->hacks&hack_GoldenEye) && rdp.tiles[td].format == 0 && rdp.tlut_mode == 2 && rdp.tiles[td].size == 2) + if (g_settings->hacks(CSettings::hack_GoldenEye) && rdp.tiles[td].format == 0 && rdp.tlut_mode == 2 && rdp.tiles[td].size == 2) { rdp.tiles[td].format = 2; rdp.tiles[td].size = 1; @@ -1639,17 +1640,6 @@ void LoadTex(int id, int tmu) cache->c_scl_y *= mscale; cache->c_scl_x *= mscale; } - /* - else - { - if (rdp.tiles[td].mirror_s && sup_mirroring) - cache->f_mirror_s = TRUE; - if (rdp.tiles[td].mirror_t && sup_mirroring) - cache->f_mirror_t = TRUE; - //cache->c_scl_y /= mscale; - //cache->c_scl_x /= mscale; - } - */ if (ghqTexInfo.aspectRatioLog2 >= 0) { cache->scale_x = 1.0f; @@ -1689,7 +1679,6 @@ void LoadTex(int id, int tmu) } else { - //cache->scale = 256.0f / float(1<c_off = 128.0f / float(1 << lod); } real_x = ghqTexInfo.width; diff --git a/Source/Glide64/Util.cpp b/Source/Glide64/Util.cpp index e968ee2af..60e31101d 100644 --- a/Source/Glide64/Util.cpp +++ b/Source/Glide64/Util.cpp @@ -313,7 +313,7 @@ void draw_tri(VERTEX **vtx, uint16_t linew) // Calculate deltaZ per polygon for Decal z-mode double fdzdy = (diffz_02 * diffx_12 - diffz_12 * diffx_02) / denom; double fdz = fabs(fdzdx) + fabs(fdzdy); - if ((g_settings->hacks & hack_Zelda) && (rdp.rm & 0x800)) + if (g_settings->hacks(CSettings::hack_Zelda) && (rdp.rm & 0x800)) { fdz *= 4.0; // Decal mode in Zelda sometimes needs mutiplied deltaZ to work correct, e.g. roads } @@ -401,7 +401,7 @@ void draw_tri(VERTEX **vtx, uint16_t linew) { if (rdp.aTBuffTex[0]->tile_uls != (int)rdp.tiles[rdp.cur_tile].f_ul_s) v->u0 -= rdp.tiles[rdp.cur_tile].f_ul_s; - if (rdp.aTBuffTex[0]->tile_ult != (int)rdp.tiles[rdp.cur_tile].f_ul_t || (g_settings->hacks&hack_Megaman)) + if (rdp.aTBuffTex[0]->tile_ult != (int)rdp.tiles[rdp.cur_tile].f_ul_t || g_settings->hacks(CSettings::hack_Megaman)) v->v0 -= rdp.tiles[rdp.cur_tile].f_ul_t; //required for megaman (boss special attack) v->u0 *= rdp.aTBuffTex[0]->u_scale; v->v0 *= rdp.aTBuffTex[0]->v_scale; @@ -1036,7 +1036,7 @@ float ScaleZ(float z) static void DepthBuffer(VERTEX * vtx, int n) { - if (g_settings->fb_depth_render_enabled() && !(g_settings->hacks&hack_RE2) && dzdx && (rdp.flags & ZBUF_UPDATE)) + if (g_settings->fb_depth_render_enabled() && !g_settings->hacks(CSettings::hack_RE2) && dzdx && (rdp.flags & ZBUF_UPDATE)) { vertexi v[12]; if (u_cull_mode == 1) //cull front diff --git a/Source/Glide64/rdp.cpp b/Source/Glide64/rdp.cpp index 1ab65f64f..457b93f8e 100644 --- a/Source/Glide64/rdp.cpp +++ b/Source/Glide64/rdp.cpp @@ -415,7 +415,7 @@ static void CopyFrameBuffer(GrBuffer_t buffer = GR_BUFFER_BACKBUFFER) uint32_t width = rdp.ci_width;//*gfx.VI_WIDTH_REG; uint32_t height; - if (g_settings->fb_emulation_enabled() && !(g_settings->hacks&hack_PPL)) + if (g_settings->fb_emulation_enabled() && !g_settings->hacks(CSettings::hack_PPL)) { int ind = (rdp.ci_count > 0) ? rdp.ci_count - 1 : 0; height = rdp.frame_buffers[ind].height; @@ -423,8 +423,10 @@ static void CopyFrameBuffer(GrBuffer_t buffer = GR_BUFFER_BACKBUFFER) else { height = rdp.ci_lower_bound; - if (g_settings->hacks&hack_PPL) + if (g_settings->hacks(CSettings::hack_PPL)) + { height -= rdp.ci_upper_bound; + } } WriteTrace(TraceRDP, TraceDebug, "width: %d, height: %d... ", width, height); @@ -500,10 +502,12 @@ static void CopyFrameBuffer(GrBuffer_t buffer = GR_BUFFER_BACKBUFFER) uint32_t stride = info.strideInBytes >> 1; int read_alpha = g_settings->fb_read_alpha_enabled(); - if ((g_settings->hacks&hack_PMario) && rdp.frame_buffers[rdp.ci_count - 1].status != ci_aux) + if (g_settings->hacks(CSettings::hack_PMario) && rdp.frame_buffers[rdp.ci_count - 1].status != ci_aux) + { read_alpha = FALSE; + } int x_start = 0, y_start = 0, x_end = width, y_end = height; - if (g_settings->hacks&hack_BAR) + if (g_settings->hacks(CSettings::hack_BAR)) { x_start = 80, y_start = 24, x_end = 240, y_end = 86; } @@ -643,7 +647,7 @@ EXPORT void CALL ProcessDList(void) //analize possible frame buffer usage if (g_settings->fb_emulation_enabled()) DetectFrameBufferUsage(); - if (!(g_settings->hacks&hack_Lego) || rdp.num_of_ci > 1) + if (!g_settings->hacks(CSettings::hack_Lego) || rdp.num_of_ci > 1) rdp.last_bg = 0; //* End of set states *// @@ -658,7 +662,7 @@ EXPORT void CALL ProcessDList(void) if (cpu_fb_write == TRUE) DrawPartFrameBufferToScreen(); - if ((g_settings->hacks&hack_Tonic) && dlist_length < 16) + if (g_settings->hacks(CSettings::hack_Tonic) && dlist_length < 16) { rdp_fullsync(); WriteTrace(TraceRDP, TraceWarning, "DLIST is too short!"); @@ -759,7 +763,7 @@ EXPORT void CALL ProcessDList(void) rdp.scale_y = rdp.scale_y_bak; } - if (g_settings->hacks & hack_OoT) + if (g_settings->hacks(CSettings::hack_OoT)) { copyWhiteToRDRAM(); //Subscreen delay fix } @@ -770,10 +774,10 @@ EXPORT void CALL ProcessDList(void) if (rdp.cur_image) { - CloseTextureBuffer(rdp.read_whole_frame && ((g_settings->hacks&hack_PMario) || rdp.swap_ci_index >= 0)); + CloseTextureBuffer(rdp.read_whole_frame && (g_settings->hacks(CSettings::hack_PMario) || rdp.swap_ci_index >= 0)); } - if ((g_settings->hacks&hack_TGR2) && rdp.vi_org_reg != *gfx.VI_ORIGIN_REG && CI_SET) + if (g_settings->hacks(CSettings::hack_TGR2) && rdp.vi_org_reg != *gfx.VI_ORIGIN_REG && CI_SET) { newSwapBuffers(); CI_SET = FALSE; @@ -907,21 +911,26 @@ static void rdp_texrect() else { //gDPTextureRectangle - if (g_settings->hacks&hack_Winback) { + if (g_settings->hacks(CSettings::hack_Winback)) + { rdp.pc[rdp.pc_i] += 8; return; } - if (g_settings->hacks&hack_ASB) + if (g_settings->hacks(CSettings::hack_ASB)) + { rdp.cmd2 = 0; + } else + { rdp.cmd2 = ((uint32_t*)gfx.RDRAM)[a + 0]; + } rdp.cmd3 = ((uint32_t*)gfx.RDRAM)[a + 1]; rdp.pc[rdp.pc_i] += 8; } } - if ((g_settings->hacks&hack_Yoshi) && g_settings->ucode == ucode_S2DEX) + if (g_settings->hacks(CSettings::hack_Yoshi) && g_settings->ucode == ucode_S2DEX) { ys_memrect(); return; @@ -929,7 +938,7 @@ static void rdp_texrect() if (rdp.skip_drawing || (!g_settings->fb_emulation_enabled() && (rdp.cimg == rdp.zimg))) { - if ((g_settings->hacks&hack_PMario) && rdp.ci_status == ci_useless) + if (g_settings->hacks(CSettings::hack_PMario) && rdp.ci_status == ci_useless) { pm_palette_mod(); } @@ -1036,7 +1045,7 @@ static void rdp_texrect() /*Gonetz*/ //hack for Zelda MM. it removes black texrects which cover all geometry in "Link meets Zelda" cut scene - if ((g_settings->hacks&hack_Zelda) && rdp.timg.addr >= rdp.cimg && rdp.timg.addr < rdp.ci_end) + if (g_settings->hacks(CSettings::hack_Zelda) && rdp.timg.addr >= rdp.cimg && rdp.timg.addr < rdp.ci_end) { WriteTrace(TraceRDP, TraceDebug, "Wrong Texrect. texaddr: %08lx, cimg: %08lx, cimg_end: %08lx", rdp.cur_cache[0]->addr, rdp.cimg, rdp.cimg + rdp.ci_width*rdp.ci_height * 2); rdp.tri_n += 2; @@ -1054,16 +1063,14 @@ static void rdp_texrect() //remove motion blur in night vision if ((g_settings->ucode == ucode_PerfectDark) && (rdp.maincimg[1].addr != rdp.maincimg[0].addr) && (rdp.timg.addr >= rdp.maincimg[1].addr) && (rdp.timg.addr < (rdp.maincimg[1].addr + rdp.ci_width*rdp.ci_height*rdp.ci_size))) { - if (g_settings->fb_emulation_enabled()) - if (rdp.ci_count > 0 && rdp.frame_buffers[rdp.ci_count - 1].status == ci_copy_self) - { - //WriteTrace(TraceRDP, TraceDebug, "Wrong Texrect. texaddr: %08lx, cimg: %08lx, cimg_end: %08lx", rdp.timg.addr, rdp.maincimg[1], rdp.maincimg[1]+rdp.ci_width*rdp.ci_height*rdp.ci_size); - WriteTrace(TraceRDP, TraceDebug, "Wrong Texrect."); - rdp.tri_n += 2; - return; - } + if (g_settings->fb_emulation_enabled() && rdp.ci_count > 0 && rdp.frame_buffers[rdp.ci_count - 1].status == ci_copy_self) + { + //WriteTrace(TraceRDP, TraceDebug, "Wrong Texrect. texaddr: %08lx, cimg: %08lx, cimg_end: %08lx", rdp.timg.addr, rdp.maincimg[1], rdp.maincimg[1]+rdp.ci_width*rdp.ci_height*rdp.ci_size); + WriteTrace(TraceRDP, TraceDebug, "Wrong Texrect."); + rdp.tri_n += 2; + return; + } } - //*/ int i; @@ -2081,7 +2088,7 @@ static void rdp_loadtile() rdp.tbuff_tex->tile_ult = ul_t; } - if ((g_settings->hacks&hack_Tonic) && tile == 7) + if (g_settings->hacks(CSettings::hack_Tonic) && tile == 7) { rdp.tiles[0].ul_s = ul_s; rdp.tiles[0].ul_t = ul_t; @@ -2097,7 +2104,7 @@ static void rdp_loadtile() info.tile_ul_t = ul_t; info.tile_width = (rdp.tiles[tile].mask_s ? minval((uint16_t)width, 1 << rdp.tiles[tile].mask_s) : (uint16_t)width); info.tile_height = (rdp.tiles[tile].mask_t ? minval((uint16_t)height, 1 << rdp.tiles[tile].mask_t) : (uint16_t)height); - if (g_settings->hacks&hack_MK64) + if (g_settings->hacks(CSettings::hack_MK64)) { if (info.tile_width % 2) { @@ -2220,7 +2227,7 @@ static void rdp_fillrect() if ((rdp.cimg == rdp.zimg) || (g_settings->fb_emulation_enabled() && rdp.ci_count > 0 && rdp.frame_buffers[rdp.ci_count - 1].status == ci_zimg) || pd_multiplayer) { WriteTrace(TraceRDP, TraceDebug, "Fillrect - cleared the depth buffer"); - if (!(g_settings->hacks&hack_Hyperbike) || rdp.ci_width > 64) //do not clear main depth buffer for aux depth buffers + if (!g_settings->hacks(CSettings::hack_Hyperbike) || rdp.ci_width > 64) //do not clear main depth buffer for aux depth buffers { update_scissor(); grDepthMask(FXTRUE); @@ -2229,25 +2236,22 @@ static void rdp_fillrect() grColorMask(FXTRUE, FXTRUE); rdp.update |= UPDATE_ZBUF_ENABLED; } - //if (g_settings->frame_buffer&fb_depth_clear) + ul_x = minval(maxval(ul_x, rdp.scissor_o.ul_x), rdp.scissor_o.lr_x); + lr_x = minval(maxval(lr_x, rdp.scissor_o.ul_x), rdp.scissor_o.lr_x); + ul_y = minval(maxval(ul_y, rdp.scissor_o.ul_y), rdp.scissor_o.lr_y); + lr_y = minval(maxval(lr_y, rdp.scissor_o.ul_y), rdp.scissor_o.lr_y); + uint32_t zi_width_in_dwords = rdp.ci_width >> 1; + ul_x >>= 1; + lr_x >>= 1; + uint32_t * dst = (uint32_t*)(gfx.RDRAM + rdp.cimg); + dst += ul_y * zi_width_in_dwords; + for (uint32_t y = ul_y; y < lr_y; y++) { - ul_x = minval(maxval(ul_x, rdp.scissor_o.ul_x), rdp.scissor_o.lr_x); - lr_x = minval(maxval(lr_x, rdp.scissor_o.ul_x), rdp.scissor_o.lr_x); - ul_y = minval(maxval(ul_y, rdp.scissor_o.ul_y), rdp.scissor_o.lr_y); - lr_y = minval(maxval(lr_y, rdp.scissor_o.ul_y), rdp.scissor_o.lr_y); - uint32_t zi_width_in_dwords = rdp.ci_width >> 1; - ul_x >>= 1; - lr_x >>= 1; - uint32_t * dst = (uint32_t*)(gfx.RDRAM + rdp.cimg); - dst += ul_y * zi_width_in_dwords; - for (uint32_t y = ul_y; y < lr_y; y++) + for (uint32_t x = ul_x; x < lr_x; x++) { - for (uint32_t x = ul_x; x < lr_x; x++) - { - dst[x] = rdp.fill_color; - } - dst += zi_width_in_dwords; + dst[x] = rdp.fill_color; } + dst += zi_width_in_dwords; } return; } @@ -2317,7 +2321,7 @@ static void rdp_fillrect() { uint32_t color = rdp.fill_color; - if ((g_settings->hacks&hack_PMario) && rdp.ci_count > 0 && rdp.frame_buffers[rdp.ci_count - 1].status == ci_aux) + if (g_settings->hacks(CSettings::hack_PMario) && rdp.ci_count > 0 && rdp.frame_buffers[rdp.ci_count - 1].status == ci_aux) { //background of auxiliary frame buffers must have zero alpha. //make it black, set 0 alpha to plack pixels on frame buffer read @@ -2596,7 +2600,7 @@ static void rdp_setcolorimage() rdp.scale_y = 1.0f; } } - else if (rdp.copy_ci_index && (g_settings->hacks&hack_PMario)) //tidal wave + else if (rdp.copy_ci_index && g_settings->hacks(CSettings::hack_PMario)) //tidal wave OpenTextureBuffer(rdp.frame_buffers[rdp.main_ci_index]); } else if (!rdp.motionblur && g_settings->fb_hwfbe_enabled() && !SwapOK && (rdp.ci_count <= rdp.copy_ci_index)) @@ -2636,7 +2640,7 @@ static void rdp_setcolorimage() { // if (CloseTextureBuffer(TRUE)) //* - if ((g_settings->hacks&hack_Zelda) && (rdp.frame_buffers[rdp.ci_count + 2].status == ci_aux) && !rdp.fb_drawn) //hack for photo camera in Zelda MM + if (g_settings->hacks(CSettings::hack_Zelda) && (rdp.frame_buffers[rdp.ci_count + 2].status == ci_aux) && !rdp.fb_drawn) //hack for photo camera in Zelda MM { CopyFrameBuffer(GR_BUFFER_TEXTUREBUFFER_EXT); rdp.fb_drawn = TRUE; @@ -2737,11 +2741,9 @@ static void rdp_setcolorimage() case ci_zimg: if (g_settings->ucode != ucode_PerfectDark) { - if (g_settings->fb_hwfbe_enabled() && !rdp.copy_ci_index && (rdp.copy_zi_index || (g_settings->hacks&hack_BAR))) + if (g_settings->fb_hwfbe_enabled() && !rdp.copy_ci_index && (rdp.copy_zi_index || g_settings->hacks(CSettings::hack_BAR))) { - GrLOD_t LOD = GR_LOD_LOG2_1024; - if (g_settings->scr_res_x > 1024) - LOD = GR_LOD_LOG2_2048; + GrLOD_t LOD = g_settings->scr_res_x > 1024 ? GR_LOD_LOG2_1024 : GR_LOD_LOG2_2048; grTextureAuxBufferExt(rdp.texbufs[0].tmu, rdp.texbufs[0].begin, LOD, LOD, GR_ASPECT_LOG2_1x1, GR_TEXFMT_RGB_565, GR_MIPMAPLEVELMASK_BOTH); grAuxBufferExt(GR_BUFFER_TEXTUREAUXBUFFER_EXT); @@ -2778,7 +2780,7 @@ static void rdp_setcolorimage() { if (!g_settings->fb_hwfbe_enabled() && prev_fb.format == 0) CopyFrameBuffer(); - else if ((g_settings->hacks&hack_Knockout) && prev_fb.width < 100) + else if (g_settings->hacks(CSettings::hack_Knockout) && prev_fb.width < 100) CopyFrameBuffer(GR_BUFFER_TEXTUREBUFFER_EXT); } if (!g_settings->fb_hwfbe_enabled() && cur_fb.status == ci_copy) @@ -2792,7 +2794,7 @@ static void rdp_setcolorimage() { if (cur_fb.format == 0) { - if ((g_settings->hacks&hack_PPL) && (rdp.scale_x < 1.1f)) //need to put current image back to frame buffer + if (g_settings->hacks(CSettings::hack_PPL) && (rdp.scale_x < 1.1f)) //need to put current image back to frame buffer { int width = cur_fb.width; int height = cur_fb.height; @@ -3231,7 +3233,7 @@ void DetectFrameBufferUsage() uint32_t a; int tidal = FALSE; - if ((g_settings->hacks&hack_PMario) && (rdp.copy_ci_index || rdp.frame_buffers[rdp.copy_ci_index].status == ci_copy_self)) + if (g_settings->hacks(CSettings::hack_PMario) && (rdp.copy_ci_index || rdp.frame_buffers[rdp.copy_ci_index].status == ci_copy_self)) tidal = TRUE; uint32_t ci = rdp.cimg, zi = rdp.zimg; uint32_t ci_height = rdp.frame_buffers[(rdp.ci_count > 0) ? rdp.ci_count - 1 : 0].height; @@ -3429,8 +3431,10 @@ void DetectFrameBufferUsage() } } rdp.ci_count = 0; - if (g_settings->hacks&hack_Banjo2) + if (g_settings->hacks(CSettings::hack_Banjo2)) + { rdp.cur_tex_buf = 0; + } rdp.maincimg[0] = rdp.frame_buffers[rdp.main_ci_index]; // rdp.scale_x = rdp.scale_x_bak; // rdp.scale_y = rdp.scale_y_bak; diff --git a/Source/Glide64/ucode00.h b/Source/Glide64/ucode00.h index 780e51660..a8c60b84d 100644 --- a/Source/Glide64/ucode00.h +++ b/Source/Glide64/ucode00.h @@ -535,7 +535,7 @@ static void uc0_tri1() &rdp.vtx[((rdp.cmd1 >> 8) & 0xFF) / 10], &rdp.vtx[(rdp.cmd1 & 0xFF) / 10] }; - if (g_settings->hacks & hack_Makers) + if (g_settings->hacks(CSettings::hack_Makers)) { rdp.force_wrap = FALSE; for (int i = 0; i < 3; i++) @@ -775,7 +775,10 @@ static void uc0_moveword() static void uc0_texture() { int tile = (rdp.cmd0 >> 8) & 0x07; - if (tile == 7 && (g_settings->hacks&hack_Supercross)) tile = 0; //fix for supercross 2000 + if (tile == 7 && g_settings->hacks(CSettings::hack_Supercross)) + { + tile = 0; //fix for supercross 2000 + } rdp.mipmap_level = (rdp.cmd0 >> 11) & 0x07; uint32_t on = (rdp.cmd0 & 0xFF); rdp.cur_tile = tile; @@ -932,7 +935,9 @@ static void uc0_setothermode_l() rdp.render_mode_changed |= rdp.rm ^ rdp.othermode_l; rdp.rm = rdp.othermode_l; if (g_settings->flame_corona && (rdp.rm == 0x00504341)) //hack for flame's corona - rdp.othermode_l |= /*0x00000020 |*/ 0x00000010; + { + rdp.othermode_l |= 0x00000010; + } WriteTrace(TraceRDP, TraceDebug, "rendermode: %08lx", rdp.othermode_l); // just output whole othermode_l } diff --git a/Source/Glide64/ucode02.h b/Source/Glide64/ucode02.h index bf099dba8..c17b6f076 100644 --- a/Source/Glide64/ucode02.h +++ b/Source/Glide64/ucode02.h @@ -123,7 +123,7 @@ static void uc2_vertex() } uint32_t geom_mode = rdp.geom_mode; - if ((g_settings->hacks&hack_Fzero) && (rdp.geom_mode & 0x40000)) + if (g_settings->hacks(CSettings::hack_Fzero) && (rdp.geom_mode & 0x40000)) { if (((short*)gfx.RDRAM)[(((addr) >> 1) + 4) ^ 1] || ((short*)gfx.RDRAM)[(((addr) >> 1) + 5) ^ 1]) rdp.geom_mode ^= 0x40000; @@ -414,7 +414,9 @@ static void uc2_geom_mode() if ((rdp.flags & ZBUF_ENABLED)) { if (!g_settings->flame_corona || (rdp.rm != 0x00504341)) //hack for flame's corona + { rdp.flags ^= ZBUF_ENABLED; + } rdp.update |= UPDATE_ZBUF_ENABLED; } } diff --git a/Source/Glide64/ucode05.h b/Source/Glide64/ucode05.h index f9852c8d9..f7c6903d2 100644 --- a/Source/Glide64/ucode05.h +++ b/Source/Glide64/ucode05.h @@ -114,7 +114,7 @@ static void uc5_vertex() // 0 = unused int n = ((rdp.cmd0 >> 19) & 0x1F);// + 1; - if (g_settings->hacks&hack_Diddy) + if (g_settings->hacks(CSettings::hack_Diddy)) n++; if (rdp.cmd0 & 0x00010000) diff --git a/Source/Glide64/ucode06.h b/Source/Glide64/ucode06.h index 1c1439fd8..34b4a6f52 100644 --- a/Source/Glide64/ucode06.h +++ b/Source/Glide64/ucode06.h @@ -356,15 +356,19 @@ void DrawImage(DRAWIMAGE & d) } } - if ((g_settings->hacks&hack_PPL) > 0) + if (g_settings->hacks(CSettings::hack_PPL)) { if (d.imageY > d.imageH) + { d.imageY = (d.imageY%d.imageH); + } } - else if ((g_settings->hacks&hack_Starcraft) > 0) + else if (g_settings->hacks(CSettings::hack_Starcraft)) { if (d.imageH % 2 == 1) + { d.imageH -= 1; + } } else { @@ -602,7 +606,7 @@ void DrawHiresImage(DRAWIMAGE & d, int screensize = FALSE) if (d.imageH % 2 == 1) d.imageH -= 1; if (d.imageY > d.imageH) d.imageY = (d.imageY%d.imageH); - if (!(g_settings->hacks&hack_PPL)) + if (!g_settings->hacks(CSettings::hack_PPL)) { if ((d.frameX > 0) && (d.frameW == rdp.ci_width)) d.frameW -= (uint16_t)(2.0f*d.frameX); @@ -734,7 +738,7 @@ static void uc6_bg(bool bg_1cyc) return; } - if (g_settings->ucode == ucode_F3DEX2 || (g_settings->hacks&hack_PPL)) + if (g_settings->ucode == ucode_F3DEX2 || g_settings->hacks(CSettings::hack_PPL)) { if ((d.imagePtr != rdp.cimg) && (d.imagePtr != rdp.ocimg) && d.imagePtr) //can't draw from framebuffer DrawImage(d); @@ -1246,7 +1250,7 @@ static void uc6_obj_rectangle_r() DRAWOBJECT d; uc6_read_object_data(d); - if (d.imageFmt == 1 && (g_settings->hacks&hack_Ogre64)) //Ogre Battle needs to copy YUV texture to frame buffer + if (d.imageFmt == 1 && g_settings->hacks(CSettings::hack_Ogre64)) //Ogre Battle needs to copy YUV texture to frame buffer { float ul_x = d.objX / mat_2d.BaseScaleX + mat_2d.X; float lr_x = (d.objX + d.imageW / d.scaleW) / mat_2d.BaseScaleX + mat_2d.X; @@ -1354,7 +1358,7 @@ static void uc6_obj_loadtxtr() WriteTrace(TraceRDP, TraceDebug, "tile addr: %08lx, tmem: %08lx, twidth: %d, theight: %d", image, tmem, twidth, theight); - int line = (twidth + 1) >> 2; + uint16_t line = (twidth + 1) >> 2; rdp.timg.addr = image; rdp.timg.width = line << 3; @@ -1489,7 +1493,7 @@ void uc6_sprite2d() d.frameY = ((short)(cmd1 & 0xFFFF)) / 4.0f; d.frameW = (uint16_t)(d.imageW / d.scaleX); d.frameH = (uint16_t)(d.imageH / d.scaleY); - if (g_settings->hacks&hack_WCWnitro) + if (g_settings->hacks(CSettings::hack_WCWnitro)) { int scaleY = (int)d.scaleY; d.imageH /= scaleY;