Skip to content

Commit

Permalink
Add GB/GBC Sprite Limit toggle
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
saulfabregwiivc committed Jan 4, 2024
1 parent 682c28a commit 21b0e99
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 12 deletions.
29 changes: 18 additions & 11 deletions source/menu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down Expand Up @@ -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;
}
Expand Down Expand Up @@ -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();
}

Expand Down
3 changes: 3 additions & 0 deletions source/preferences.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand Down Expand Up @@ -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");
Expand Down Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion source/vba/gb/gbGfx.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -631,7 +631,7 @@ void gbDrawSprites(bool draw)
}
}
// sprite limit reached!
if(count >= 10)
if(count >= GCSettings.GBMaxSpriteTilesPerLine)
break;
}
}
Expand Down
2 changes: 2 additions & 0 deletions source/vbagx.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions source/vbagx.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 21b0e99

Please sign in to comment.