From 21b0e998a42591774209310972cfa0130fbed629 Mon Sep 17 00:00:00 2001 From: saulfabreg Wii VC Project Date: Thu, 4 Jan 2024 16:14:32 -0500 Subject: [PATCH] Add GB/GBC Sprite Limit toggle Both Game Boy and Game Boy Color have a limit of 10 sprites per line, and a total limit of 40 sprites on the screen. Add a toggle for disable/enable sprite limit. It is set to "On" by default. --- source/menu.cpp | 29 ++++++++++++++++++----------- source/preferences.cpp | 3 +++ source/vba/gb/gbGfx.cpp | 2 +- source/vbagx.cpp | 2 ++ source/vbagx.h | 1 + 5 files changed, 25 insertions(+), 12 deletions(-) diff --git a/source/menu.cpp b/source/menu.cpp index 9e124b71..89331da8 100644 --- a/source/menu.cpp +++ b/source/menu.cpp @@ -3095,6 +3095,7 @@ static int MenuSettingsVideo() } sprintf(options.name[i++], "Screen Position"); sprintf(options.name[i++], "Video Mode"); + sprintf(options.name[i++], "GB Sprite Limit"); sprintf(options.name[i++], "GB Mono Colorization"); sprintf(options.name[i++], "GB Palette"); sprintf(options.name[i++], "GBA Frameskip"); @@ -3197,19 +3198,23 @@ static int MenuSettingsVideo() if(GCSettings.videomode > 6) GCSettings.videomode = 0; break; - + case 6: - GCSettings.colorize ^= 1; + GCSettings.gbSpriteLimit ^= 1; break; case 7: - menu = MENU_GAMESETTINGS_PALETTE; + GCSettings.colorize ^= 1; break; case 8: - GCSettings.gbaFrameskip ^= 1; + menu = MENU_GAMESETTINGS_PALETTE; break; + case 9: + GCSettings.gbaFrameskip ^= 1; + break; + case 10: GCSettings.TurboModeEnabled ^= 1; break; } @@ -3278,22 +3283,24 @@ static int MenuSettingsVideo() case 6: sprintf (options.value[5], "European RGB (240p)"); break; } + + sprintf (options.value[6], "%s", GCSettings.gbSpriteLimit == 1 ? "On" : "Off"); if (GCSettings.colorize) - sprintf (options.value[6], "On"); + sprintf (options.value[7], "On"); else - sprintf (options.value[6], "Off"); + sprintf (options.value[7], "Off"); if(strcmp(CurrentPalette.gameName, "default")) - sprintf(options.value[7], "Custom"); + sprintf(options.value[8], "Custom"); else - sprintf(options.value[7], "Default"); + sprintf(options.value[8], "Default"); if (GCSettings.gbaFrameskip) - sprintf (options.value[8], "On"); + sprintf (options.value[9], "On"); else - sprintf (options.value[8], "Off"); - sprintf (options.value[9], "%s", GCSettings.TurboModeEnabled == 1 ? "On" : "Off"); + sprintf (options.value[9], "Off"); + sprintf (options.value[10], "%s", GCSettings.TurboModeEnabled == 1 ? "On" : "Off"); optionBrowser.TriggerUpdate(); } diff --git a/source/preferences.cpp b/source/preferences.cpp index 24da5eb3..fa036587 100644 --- a/source/preferences.cpp +++ b/source/preferences.cpp @@ -191,6 +191,7 @@ preparePrefsData () createXMLSetting("gbZoomVert", "GB Vertical Zoom Level", FtoStr(GCSettings.gbZoomVert)); createXMLSetting("gbFixed", "GB Fixed Pixel Ratio", toStr(GCSettings.gbFixed)); createXMLSetting("gbaFixed", "GBA Fixed Pixel Ratio", toStr(GCSettings.gbaFixed)); + createXMLSetting("gbSpriteLimit", "GB Sprite Limit", toStr(GCSettings.gbSpriteLimit)); createXMLSetting("render", "Video Filtering", toStr(GCSettings.render)); createXMLSetting("scaling", "Aspect Ratio Correction", toStr(GCSettings.scaling)); createXMLSetting("xshift", "Horizontal Video Shift", toStr(GCSettings.xshift)); @@ -506,6 +507,7 @@ decodePrefsData () loadXMLSetting(&GCSettings.gbZoomHor, "gbZoomHor"); loadXMLSetting(&GCSettings.gbZoomVert, "gbZoomVert"); loadXMLSetting(&GCSettings.gbaFixed, "gbaFixed"); + loadXMLSetting(&GCSettings.gbSpriteLimit, "gbSpriteLimit"); loadXMLSetting(&GCSettings.gbFixed, "gbFixed"); loadXMLSetting(&GCSettings.render, "render"); loadXMLSetting(&GCSettings.scaling, "scaling"); @@ -659,6 +661,7 @@ DefaultSettings () GCSettings.xshift = 0; // horizontal video shift GCSettings.yshift = 0; // vertical video shift GCSettings.colorize = 0; // Colorize mono gameboy games + GCSettings.gbSpriteLimit = 1; // Turn GB sprite limit on by default GCSettings.gbaFrameskip = 1; // Turn auto-frameskip on for GBA games GCSettings.TurboModeEnabled = 1; // Enabled by default diff --git a/source/vba/gb/gbGfx.cpp b/source/vba/gb/gbGfx.cpp index 85c9d0ac..82356f4b 100644 --- a/source/vba/gb/gbGfx.cpp +++ b/source/vba/gb/gbGfx.cpp @@ -631,7 +631,7 @@ void gbDrawSprites(bool draw) } } // sprite limit reached! - if(count >= 10) + if(count >= GCSettings.GBMaxSpriteTilesPerLine) break; } } diff --git a/source/vbagx.cpp b/source/vbagx.cpp index add5b9d5..cab7df80 100644 --- a/source/vbagx.cpp +++ b/source/vbagx.cpp @@ -432,6 +432,8 @@ int main(int argc, char *argv[]) ScreenshotRequested = 0; SwitchAudioMode(0); + + GCSettings.GBMaxSpriteTilesPerLine = (GCSettings.gbSpriteLimit ? 10 : 40); // stop checking if devices were removed/inserted // since we're starting emulation again diff --git a/source/vbagx.h b/source/vbagx.h index 11d44153..902697d9 100644 --- a/source/vbagx.h +++ b/source/vbagx.h @@ -85,6 +85,7 @@ struct SGCSettings int render; // 0 - original, 1 - filtered, 2 - unfiltered int xshift; // video output shift int yshift; + int gbSpriteLimit; int colorize; // colorize Mono Gameboy games int gbaFrameskip; // turn on auto-frameskip for GBA games int WiiControls; // Match Wii Game