Skip to content

Commit

Permalink
Add HDMI mod PAL60 compatibility
Browse files Browse the repository at this point in the history
  • Loading branch information
networkfusion committed Nov 24, 2024
1 parent 058c41b commit 0d3c79c
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 2 deletions.
15 changes: 14 additions & 1 deletion src/menu/menu.c
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,9 @@

static menu_t *menu;

static tv_type_t tv_type;
extern tv_type_t __boot_tvtype;


static void menu_init (boot_params_t *boot_params) {
menu = calloc(1, sizeof(menu_t));
Expand Down Expand Up @@ -74,8 +77,17 @@ static void menu_init (boot_params_t *boot_params) {
.width = 640,
.height = 480,
.interlaced = INTERLACED ? INTERLACE_HALF : INTERLACE_OFF,
.pal60 = menu->settings.pal60_enabled,
.pal60 = (!menu->settings.hdmi_pal60_compatibility_mode && menu->settings.pal60_enabled),
};

if (menu->settings.hdmi_pal60_compatibility_mode) {
tv_type = get_tv_type();
if (tv_type == TV_PAL && menu->settings.pal60_enabled) {
// HACK: Set TV type to NTSC, so PAL console would output 60 Hz signal instead.
__boot_tvtype = TV_NTSC;
}
}

display_init(resolution, DEPTH_16_BPP, 2, GAMMA_NONE, INTERLACED ? FILTERS_DISABLED : FILTERS_RESAMPLE);
display_set_fps_limit(FPS_LIMIT);

Expand All @@ -101,6 +113,7 @@ static void menu_init (boot_params_t *boot_params) {
}

static void menu_deinit (menu_t *menu) {
__boot_tvtype = tv_type;
hdmi_send_game_id(menu->boot_params);

ui_components_background_free();
Expand Down
3 changes: 3 additions & 0 deletions src/menu/settings.c
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ static char *settings_path = NULL;

static settings_t init = {
.pal60_enabled = false,
.hdmi_pal60_compatibility_mode = false,
.show_protected_entries = false,
.default_directory = "/",
.use_saves_folder = true,
Expand Down Expand Up @@ -39,6 +40,7 @@ void settings_load (settings_t *settings) {
mini_t *ini = mini_try_load(settings_path);

settings->pal60_enabled = mini_get_bool(ini, "menu", "pal60", init.pal60_enabled); // TODO: consider changing file setting name
settings->hdmi_pal60_compatibility_mode = mini_get_bool(ini, "menu", "hdmi_pal60_compatibility_mode", init.hdmi_pal60_compatibility_mode);
settings->show_protected_entries = mini_get_bool(ini, "menu", "show_protected_entries", init.show_protected_entries);
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);
Expand All @@ -59,6 +61,7 @@ void settings_save (settings_t *settings) {
mini_t *ini = mini_create(settings_path);

mini_set_bool(ini, "menu", "pal60", settings->pal60_enabled);
mini_set_bool(ini, "menu", "hdmi_pal60_compatibility_mode", settings->hdmi_pal60_compatibility_mode);
mini_set_bool(ini, "menu", "show_protected_entries", settings->show_protected_entries);
mini_set_string(ini, "menu", "default_directory", settings->default_directory);
mini_set_bool(ini, "menu", "use_saves_folder", settings->use_saves_folder);
Expand Down
3 changes: 3 additions & 0 deletions src/menu/settings.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@
typedef struct {
/** @brief Use 60 Hz refresh rate on a PAL console */
bool pal60_enabled;

/** @brief Use 60 Hz refresh rate on a PAL console with certain HDMI mods that do not properly support it */
bool hdmi_pal60_compatibility_mode;

/** @brief Show files/directories that are filtered in the browser */
bool show_protected_entries;
Expand Down
16 changes: 15 additions & 1 deletion src/menu/views/settings_editor.c
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,11 @@ static void set_pal60_type (menu_t *menu, void *arg) {
settings_save(&menu->settings);
}

static void set_hdmi_pal60_compatibility_type (menu_t *menu, void *arg) {
menu->settings.hdmi_pal60_compatibility = (bool)(uintptr_t)(arg);
settings_save(&menu->settings);
}

static void set_protected_entries_type (menu_t *menu, void *arg) {
menu->settings.show_protected_entries = (bool)(uintptr_t)(arg);
settings_save(&menu->settings);
Expand Down Expand Up @@ -54,7 +59,13 @@ static void set_rumble_enabled_type (menu_t *menu, void *arg) {

static component_context_menu_t set_pal60_type_context_menu = { .list = {
{.text = "On", .action = set_pal60_type, .arg = (void *)(uintptr_t)(true) },
{.text = "Off", .action = set_pal60_type, .arg = (void *) (false) },
{.text = "Off", .action = set_pal60_type, .arg = (void *)(uintptr_t)(false) },
COMPONENT_CONTEXT_MENU_LIST_END,
}};

static component_context_menu_t set_pal60_hdmi_compatibility_type_context_menu = { .list = {
{.text = "On", .action = set_hdmi_pal60_compatibility_type, .arg = (void *)(uintptr_t)(true) },
{.text = "Off", .action = set_hdmi_pal60_compatibility_type, .arg = (void *)(uintptr_t)(false) },
COMPONENT_CONTEXT_MENU_LIST_END,
}};

Expand Down Expand Up @@ -92,6 +103,7 @@ static component_context_menu_t set_rumble_enabled_type_context_menu = { .list =

static component_context_menu_t options_context_menu = { .list = {
{ .text = "PAL60 Mode", .submenu = &set_pal60_type_context_menu },
{ .text = "PAL60 HDMI Compat", .submenu = &set_pal60_hdmi_compatibility_type_context_menu },
{ .text = "Show Hidden Files", .submenu = &set_protected_entries_type_context_menu },
{ .text = "Sound Effects", .submenu = &set_sound_enabled_type_context_menu },
{ .text = "Use Saves Folder", .submenu = &set_use_saves_folder_type_context_menu },
Expand Down Expand Up @@ -139,6 +151,7 @@ static void draw (menu_t *menu, surface_t *d) {
" Autoload ROM : %s\n"
"To change the following menu settings, press 'A':\n"
"* PAL60 Mode : %s\n"
"* PAL60 HDMI Compat : %s\n"
" Show Hidden Files : %s\n"
" Use Saves folder : %s\n"
" Sound Effects : %s\n"
Expand All @@ -152,6 +165,7 @@ static void draw (menu_t *menu, surface_t *d) {
menu->settings.default_directory,
format_switch(menu->settings.rom_autoload_enabled),
format_switch(menu->settings.pal60_enabled),
format_switch(menu->settings.hdmi_pal60_compatibility),
format_switch(menu->settings.show_protected_entries),
format_switch(menu->settings.use_saves_folder),
format_switch(menu->settings.sound_enabled)
Expand Down

0 comments on commit 0d3c79c

Please sign in to comment.