Add CGB revision selection to the SDL frontend

This commit is contained in:
Lior Halphon 2022-07-02 18:11:55 +03:00
parent 63a858d767
commit a773297b3a
3 changed files with 43 additions and 3 deletions

View File

@ -113,6 +113,7 @@ configuration_t configuration =
.rumble_mode = GB_RUMBLE_ALL_GAMES,
.default_scale = 2,
.color_temperature = 10,
.cgb_revision = GB_MODEL_CGB_E - GB_MODEL_CGB_0,
};
@ -397,6 +398,38 @@ const char *current_model_string(unsigned index)
[configuration.model];
}
static void cycle_cgb_revision(unsigned index)
{
configuration.cgb_revision++;
if (configuration.cgb_revision == GB_MODEL_CGB_E - GB_MODEL_CGB_0) {
configuration.cgb_revision = 0;
}
pending_command = GB_SDL_RESET_COMMAND;
}
static void cycle_cgb_revision_backwards(unsigned index)
{
if (configuration.cgb_revision == 0) {
configuration.cgb_revision = GB_MODEL_CGB_E - GB_MODEL_CGB_0;
}
configuration.cgb_revision--;
pending_command = GB_SDL_RESET_COMMAND;
}
const char *current_cgb_revision_string(unsigned index)
{
return (const char *[]){
"CPU CGB 0 (Exp.)",
"CPU CGB A (Exp.)",
"CPU CGB B (Exp.)",
"CPU CGB C (Exp.)",
"CPU CGB D",
"CPU CGB E",
}
[configuration.cgb_revision];
}
static void cycle_sgb_revision(unsigned index)
{
@ -524,6 +557,7 @@ const char *current_rtc_mode_string(unsigned index)
static const struct menu_item emulation_menu[] = {
{"Emulated Model:", cycle_model, current_model_string, cycle_model_backwards},
{"GBC Revision:", cycle_cgb_revision, current_cgb_revision_string, cycle_cgb_revision_backwards},
{"SGB Revision:", cycle_sgb_revision, current_sgb_revision_string, cycle_sgb_revision_backwards},
{"Boot ROMs Folder:", toggle_bootrom, current_bootrom_string, toggle_bootrom},
{"Rewind Length:", cycle_rewind, current_rewind_string, cycle_rewind_backwards},

View File

@ -124,8 +124,13 @@ typedef struct {
/* v0.14.4 */
bool osd;
struct __attribute__((packed, aligned(4))) {
/* v0.15 */
bool allow_mouse_controls;
uint8_t cgb_revision;
};
} configuration_t;
extern configuration_t configuration;

View File

@ -649,7 +649,7 @@ restart:
model = (GB_model_t [])
{
[MODEL_DMG] = GB_MODEL_DMG_B,
[MODEL_CGB] = GB_MODEL_CGB_E,
[MODEL_CGB] = GB_MODEL_CGB_0 + configuration.cgb_revision,
[MODEL_AGB] = GB_MODEL_AGB_A,
[MODEL_MGB] = GB_MODEL_MGB,
[MODEL_SGB] = (GB_model_t [])
@ -869,6 +869,7 @@ int main(int argc, char **argv)
configuration.rumble_mode %= GB_RUMBLE_ALL_GAMES + 1;
configuration.color_temperature %= 21;
configuration.bootrom_path[sizeof(configuration.bootrom_path) - 1] = 0;
configuration.cgb_revision %= GB_MODEL_CGB_E - GB_MODEL_CGB_0 + 1;
}
if (configuration.model >= MODEL_MAX) {