Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add ability to force tv region based on detected ROM #71

Merged
merged 8 commits into from
Dec 17, 2023
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 8 additions & 5 deletions src/menu/settings.c
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,12 @@ static settings_t init = {
.hidden_files_enabled = false,
.default_directory = "/",
.use_saves_folder = true,
.autodetect_rom_region = true,

/* Beta feature flags */
/* Beta feature flags (should always init to off) */
.bgm_enabled = false,
.sound_enabled = false,
.rumble_enabled = true,
.rumble_enabled = false,
};


Expand All @@ -32,6 +33,7 @@ void settings_load (settings_t *settings) {
settings->hidden_files_enabled = mini_get_bool(ini, "menu", "show_hidden_files", init.hidden_files_enabled);
settings->default_directory = strdup(mini_get_string(ini, "menu", "default_directory", init.default_directory));
settings->use_saves_folder = mini_get_bool(ini, "menu", "use_saves_folder", init.use_saves_folder);
settings->autodetect_rom_region = mini_get_bool(ini, "menu", "autodetect_rom_region", init.autodetect_rom_region);

/* Beta feature flags, they might not be in the file */
settings->bgm_enabled = mini_get_bool(ini, "menu_beta_flag", "bgm_enabled", init.bgm_enabled);
Expand All @@ -49,11 +51,12 @@ void settings_save (settings_t *settings) {
mini_set_bool(ini, "menu", "show_hidden_files", settings->hidden_files_enabled);
mini_set_string(ini, "menu", "default_directory", settings->default_directory);
mini_set_bool(ini, "menu", "use_saves_folder", settings->use_saves_folder);
mini_set_bool(ini, "menu", "autodetect_rom_region", settings->autodetect_rom_region);

/* Beta feature flags, they should not save until production ready! */
// mini_set_bool(ini, "menu_beta_flag", "bgm_enabled", init.bgm_enabled);
// mini_set_bool(ini, "menu_beta_flag", "sound_enabled", init.sound_enabled);
// mini_set_bool(ini, "menu_beta_flag", "rumble_enabled", init.rumble_enabled);
// mini_set_bool(ini, "menu_beta_flag", "bgm_enabled", settings->bgm_enabled);
// mini_set_bool(ini, "menu_beta_flag", "sound_enabled", settings->sound_enabled);
// mini_set_bool(ini, "menu_beta_flag", "rumble_enabled", settings->rumble_enabled);

mini_save(ini, MINI_FLAGS_SKIP_EMPTY_GROUPS);

Expand Down
3 changes: 3 additions & 0 deletions src/menu/settings.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@ typedef struct {
/** @brief Put saves into separate directory */
bool use_saves_folder;

/** @brief Enable forcing the (N64 system region) tv type to align with game region when booting the ROM. */
bool autodetect_rom_region;

/** @brief Enable Background music */
bool bgm_enabled;

Expand Down
44 changes: 43 additions & 1 deletion src/menu/views/load_rom.c
Original file line number Diff line number Diff line change
Expand Up @@ -206,8 +206,50 @@ static void load (menu_t *menu) {

menu->next_mode = MENU_MODE_BOOT;
menu->boot_params->device_type = BOOT_DEVICE_TYPE_ROM;
menu->boot_params->tv_type = BOOT_TV_TYPE_PASSTHROUGH;
menu->boot_params->detect_cic_seed = true;

if (menu->settings.autodetect_rom_region) {
// check the market type (menu->load.rom_info.destination_code) and set best guess?!
switch (menu->load.rom_info.destination_code) {
networkfusion marked this conversation as resolved.
Show resolved Hide resolved
case MARKET_NORTH_AMERICA:
case MARKET_JAPANESE:
case MARKET_JAPANESE_MULTI:
case MARKET_GATEWAY64_NTSC:
menu->boot_params->tv_type = BOOT_TV_TYPE_NTSC;
break;
case MARKET_BRAZILIAN:
menu->boot_params->tv_type = BOOT_TV_TYPE_MPAL;
break;
case MARKET_GERMAN:
case MARKET_FRENCH:
case MARKET_DUTCH:
case MARKET_ITALIAN:
case MARKET_SPANISH:
case MARKET_AUSTRALIAN:
case MARKET_SCANDINAVIAN:
case MARKET_GATEWAY64_PAL:
case MARKET_EUROPEAN_BASIC:
// FIXME: There might be some interesting errors with OTHER_X and OTHER_Y (e.g. TGR Asia).
case MARKET_OTHER_X:
case MARKET_OTHER_Y:
menu->boot_params->tv_type = BOOT_TV_TYPE_PAL;
break;
// FIXME: We cannot be sure on these markets, so just return the default!
case MARKET_CHINESE:
case MARKET_CANADIAN:
case MARKET_KOREAN:
case MARKET_OTHER_Z:
default:
menu->boot_params->tv_type = BOOT_TV_TYPE_PASSTHROUGH;
break;
}

}
else {
menu->boot_params->tv_type = BOOT_TV_TYPE_PASSTHROUGH;
}


}

static void deinit (void) {
Expand Down