[develop] PAL60Hz mode on hardware mods (#165)

<!--- Provide a general summary of your changes in the Title above -->

## Description
<!--- Describe your changes in detail -->
Most hardware mods have issues with PAL60 when outputing on displays
when using libDragon Preview branch (e.g. PixelFX and UltraHDMI).
This is a workaround until libDragon can deal with them.

The settings are not exposed through the menu (by default) as can lead
to no video output.

## Motivation and Context
<!--- What does this sample do? What problem does it solve? -->
<!--- If it fixes/closes/resolves an open issue, please link to the
issue here -->
#163
https://discordapp.com/channels/205520502922543113/1310357756091437086

## How Has This Been Tested?
<!-- (if applicable) -->
<!--- Please describe in detail how you tested your sample/changes. -->
<!--- Include details of your testing environment, and the tests you ran
to -->
<!--- see how your change affects other areas of the code, etc. -->
* Ultra HDMI modded PAL console using both HDMI and its analogue output
[pal60 + pal60 compat].
* ----- HDMI output ....
* ----- analog output only when compat mode off = out of screen
vertical.

## Screenshots
<!-- (if appropriate): -->

## Types of changes
<!--- What types of changes does your code introduce? Put an `x` in all
the boxes that apply: -->
- [ ] Improvement (non-breaking change that adds a new feature)
- [ ] Bug fix (fixes an issue)
- [ ] Breaking change (breaking change)
- [ ] Documentation Improvement
- [ ] Config and build (change in the configuration and build system,
has no impact on code or features)

## Checklist:
<!--- Go over all the following points, and put an `x` in all the boxes
that apply. -->
<!--- If you're unsure about any of these, don't hesitate to ask. We're
here to help! -->
- [ ] My code follows the code style of this project.
- [ ] My change requires a change to the documentation.
- [ ] I have updated the documentation accordingly.
- [ ] I have added tests to cover my changes.
- [ ] All new and existing tests passed.

<!--- It would be nice if you could sign off your contribution by
replacing the name with your GitHub user name and GitHub email contact.
-->
Signed-off-by: GITHUB_USER <GITHUB_USER_EMAIL>
This commit is contained in:
Robin Jones 2025-03-04 00:28:06 +00:00 committed by GitHub
parent a0ea3972d2
commit 39e4e91454
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 39 additions and 3 deletions

View File

@ -38,6 +38,14 @@
static menu_t *menu;
/** FIXME: These are used for overriding libdragon's global variables for TV type to allow PAL60 compatibility
* with hardware mods that don't really understand the VI output.
**/
static tv_type_t tv_type;
extern int __boot_tvtype;
/* -- */
/**
* @brief Initialize the menu system.
*
@ -85,13 +93,22 @@ static void menu_init (boot_params_t *boot_params) {
menu->load.load_history = -1;
menu->load.load_favorite = -1;
path_pop(path);
if (menu->settings.pal60_compatibility_mode) { // hardware VI mods that dont really understand the output
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 = (int)TV_NTSC;
}
}
resolution_t resolution = {
.width = 640,
.height = 480,
.interlaced = INTERLACED ? INTERLACE_HALF : INTERLACE_OFF,
.pal60 = menu->settings.pal60_enabled
.pal60 = menu->settings.pal60_enabled, // this may be overridden by the PAL60 compatibility mode.
};
display_init(resolution, DEPTH_16_BPP, 2, GAMMA_NONE, INTERLACED ? FILTERS_DISABLED : FILTERS_RESAMPLE);
display_set_fps_limit(FPS_LIMIT);

View File

@ -12,6 +12,7 @@ static settings_t init = {
.schema_revision = 1,
.first_run = true,
.pal60_enabled = false,
.pal60_compatibility_mode = true,
.show_protected_entries = false,
.default_directory = "/",
.use_saves_folder = true,
@ -45,6 +46,7 @@ void settings_load (settings_t *settings) {
settings->schema_revision = mini_get_int(ini, "menu", "schema_revision", init.schema_revision);
settings->first_run = mini_get_bool(ini, "menu", "first_run", init.first_run);
settings->pal60_enabled = mini_get_bool(ini, "menu", "pal60", init.pal60_enabled); // TODO: consider changing file setting name
settings->pal60_compatibility_mode = mini_get_bool(ini, "menu", "pal60_compatibility_mode", init.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);
@ -69,6 +71,7 @@ void settings_save (settings_t *settings) {
mini_set_int(ini, "menu", "schema_revision", settings->schema_revision);
mini_set_bool(ini, "menu", "first_run", settings->first_run);
mini_set_bool(ini, "menu", "pal60", settings->pal60_enabled);
mini_set_bool(ini, "menu", "pal60_compatibility_mode", settings->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);

View File

@ -18,6 +18,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 mods that do not properly the video output */
bool pal60_compatibility_mode;
/** @brief Show files/directories that are filtered in the browser */
bool show_protected_entries;

View File

@ -35,6 +35,11 @@ static void set_pal60_type (menu_t *menu, void *arg) {
settings_save(&menu->settings);
}
static void set_mod_pal60_compatibility_type (menu_t *menu, void *arg) {
menu->settings.pal60_compatibility_mode = (bool)(uintptr_t)(arg);
settings_save(&menu->settings);
}
static void set_bgm_enabled_type (menu_t *menu, void *arg) {
menu->settings.bgm_enabled = (bool)(uintptr_t)(arg);
settings_save(&menu->settings);
@ -51,7 +56,6 @@ static void set_rumble_enabled_type (menu_t *menu, void *arg) {
// }
#endif
static component_context_menu_t set_protected_entries_type_context_menu = { .list = {
{.text = "On", .action = set_protected_entries_type, .arg = (void *)(uintptr_t)(true) },
{.text = "Off", .action = set_protected_entries_type, .arg = (void *)(uintptr_t)(false) },
@ -73,7 +77,13 @@ static component_context_menu_t set_use_saves_folder_type_context_menu = { .list
#ifdef BETA_SETTINGS
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_mod_compatibility_type_context_menu = { .list = {
{.text = "On", .action = set_mod_pal60_compatibility_type, .arg = (void *)(uintptr_t)(true) },
{.text = "Off", .action = set_mod_pal60_compatibility_type, .arg = (void *)(uintptr_t)(false) },
COMPONENT_CONTEXT_MENU_LIST_END,
}};
@ -96,6 +106,7 @@ static component_context_menu_t options_context_menu = { .list = {
{ .text = "Use Saves Folder", .submenu = &set_use_saves_folder_type_context_menu },
#ifdef BETA_SETTINGS
{ .text = "PAL60 Mode", .submenu = &set_pal60_type_context_menu },
{ .text = "PAL60 Compatibility", .submenu = &set_pal60_mod_compatibility_type_context_menu },
{ .text = "Background Music", .submenu = &set_bgm_enabled_type_context_menu },
{ .text = "Rumble Feedback", .submenu = &set_rumble_enabled_type_context_menu },
// { .text = "Restore Defaults", .action = set_use_default_settings },
@ -145,6 +156,7 @@ static void draw (menu_t *menu, surface_t *d) {
" Sound Effects : %s\n"
#ifdef BETA_SETTINGS
"* PAL60 Mode : %s\n"
"* PAL60 Mod Compat : %s\n"
" Background Music : %s\n"
" Rumble Feedback : %s\n"
"\n\n"
@ -162,6 +174,7 @@ static void draw (menu_t *menu, surface_t *d) {
#ifdef BETA_SETTINGS
,
format_switch(menu->settings.pal60_enabled),
format_switch(menu->settings.pal60_compatibility_mode),
format_switch(menu->settings.bgm_enabled),
format_switch(menu->settings.rumble_enabled)
#endif