Skip to content

Commit

Permalink
Config changes and fixes, see description
Browse files Browse the repository at this point in the history
- Remove allow_updown_leftright_dsi (option was unused and useless)
- Hide enable_dsi_external_filter. Do not mention out-of-date wiki,
  fixes #1992
- Limit gamma to a more reasonable value of 8, fixes #1989
  • Loading branch information
TuxSH committed May 1, 2024
1 parent 23e478d commit 64293f8
Show file tree
Hide file tree
Showing 11 changed files with 19 additions and 57 deletions.
Binary file modified arm9/data/config_template.ini
Binary file not shown.
35 changes: 8 additions & 27 deletions arm9/source/config.c
Original file line number Diff line number Diff line change
Expand Up @@ -65,12 +65,11 @@ static const char *singleOptionIniNamesBoot[] = {
"app_syscore_threads_on_core_2",
"show_system_settings_string",
"show_gba_boot_screen",
"enable_dsi_external_filter",
"allow_updown_leftright_dsi",
};

static const char *singleOptionIniNamesMisc[] = {
"use_dev_unitinfo",
"enable_dsi_external_filter",
"disable_arm11_exception_handlers",
"enable_safe_firm_rosalina",
};
Expand Down Expand Up @@ -484,7 +483,7 @@ static int configIniHandler(void* user, const char* section, const char* name, c
return 1;
} else if (strcmp(name, "screen_filters_top_gamma") == 0) {
s64 opt;
CHECK_PARSE_OPTION(parseDecFloatOption(&opt, value, 0, 1411 * FLOAT_CONV_MULT));
CHECK_PARSE_OPTION(parseDecFloatOption(&opt, value, 0, 8 * FLOAT_CONV_MULT));
cfg->topScreenFilter.gammaEnc = opt;
return 1;
} else if (strcmp(name, "screen_filters_top_contrast") == 0) {
Expand All @@ -509,7 +508,7 @@ static int configIniHandler(void* user, const char* section, const char* name, c
return 1;
} else if (strcmp(name, "screen_filters_bot_gamma") == 0) {
s64 opt;
CHECK_PARSE_OPTION(parseDecFloatOption(&opt, value, 0, 1411 * FLOAT_CONV_MULT));
CHECK_PARSE_OPTION(parseDecFloatOption(&opt, value, 0, 8 * FLOAT_CONV_MULT));
cfg->bottomScreenFilter.gammaEnc = opt;
return 1;
} else if (strcmp(name, "screen_filters_bot_contrast") == 0) {
Expand Down Expand Up @@ -657,7 +656,6 @@ static size_t saveLumaIniConfigToStr(char *out)
(int)CONFIG(AUTOBOOTEMU), (int)CONFIG(LOADEXTFIRMSANDMODULES),
(int)CONFIG(PATCHGAMES), (int)CONFIG(REDIRECTAPPTHREADS),
(int)CONFIG(PATCHVERSTRING), (int)CONFIG(SHOWGBABOOT),
(int)CONFIG(ENABLEDSIEXTFILTER), (int)CONFIG(ALLOWUPDOWNLEFTRIGHTDSI),

1 + (int)MULTICONFIG(DEFAULTEMU), 4 - (int)MULTICONFIG(BRIGHTNESS),
splashPosStr, (unsigned int)cfg->splashDurationMsec,
Expand All @@ -678,8 +676,8 @@ static size_t saveLumaIniConfigToStr(char *out)
forceAudioOutputStr,
cfg->volumeSliderOverride,

(int)CONFIG(PATCHUNITINFO), (int)CONFIG(DISABLEARM11EXCHANDLERS),
(int)CONFIG(ENABLESAFEFIRMROSALINA)
(int)CONFIG(PATCHUNITINFO), (int)CONFIG(ENABLEDSIEXTFILTER),
(int)CONFIG(DISABLEARM11EXCHANDLERS), (int)CONFIG(ENABLESAFEFIRMROSALINA)
);

return n < 0 ? 0 : (size_t)n;
Expand Down Expand Up @@ -839,8 +837,6 @@ void configMenu(bool oldPinStatus, u32 oldPinMode)
"( ) Redirect app. syscore threads to core2",
"( ) Show NAND or user string in System Settings",
"( ) Show GBA boot screen in patched AGB_FIRM",
"( ) Enable custom upscaling filters for DSi",
"( ) Allow Left+Right / Up+Down combos for DSi",

// Should always be the last 2 entries
"\nBoot chainloader",
Expand Down Expand Up @@ -930,19 +926,6 @@ void configMenu(bool oldPinStatus, u32 oldPinMode)
"Enable showing the GBA boot screen\n"
"when booting GBA games.",

"Enable replacing the default upscaling\n"
"filter used for DS(i) software by the\n"
"contents of:\n\n"
"/luma/twl_upscaling_filter.bin\n\n"
"Refer to the wiki for further details.",

"Allow Left+Right and Up+Down button\n"
"combos (using DPAD and CPAD\n"
"simultaneously) in DS(i) software.\n\n"
"Commercial software filter these\n"
"combos on their own too, though.",


// Should always be the last 2 entries
"Boot to the Luma3DS chainloader menu.",

Expand Down Expand Up @@ -988,8 +971,6 @@ void configMenu(bool oldPinStatus, u32 oldPinMode)
{ .visible = true },
{ .visible = true },
{ .visible = true },
{ .visible = true },
{ .visible = true },
};

//Calculate the amount of the various kinds of options and pre-select the first single one
Expand Down Expand Up @@ -1060,21 +1041,21 @@ void configMenu(bool oldPinStatus, u32 oldPinMode)
}

drawString(false, 10, 10, COLOR_WHITE, optionsDescription[selectedOption]);

bool startPressed = false;
//Boring configuration menu
while(true)
{
u32 pressed = 0;
if (!startPressed)
if (!startPressed)
do
{
pressed = waitInput(true) & MENU_BUTTONS;
}
while(!pressed);

// Force the selection of "save and exit" and trigger it.
if(pressed & BUTTON_START)
if(pressed & BUTTON_START)
{
startPressed = true;
// This moves the cursor to the last entry
Expand Down
5 changes: 2 additions & 3 deletions arm9/source/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@

#define CONFIG_FILE "config.ini"
#define CONFIG_VERSIONMAJOR 3
#define CONFIG_VERSIONMINOR 11
#define CONFIG_VERSIONMINOR 12

#define BOOTCFG_NAND BOOTCONFIG(0, 1)
#define BOOTCFG_EMUINDEX BOOTCONFIG(1, 3)
Expand All @@ -62,9 +62,8 @@ enum singleOptions
REDIRECTAPPTHREADS,
PATCHVERSTRING,
SHOWGBABOOT,
ENABLEDSIEXTFILTER,
ALLOWUPDOWNLEFTRIGHTDSI,
PATCHUNITINFO,
ENABLEDSIEXTFILTER,
DISABLEARM11EXCHANDLERS,
ENABLESAFEFIRMROSALINA,

Expand Down
13 changes: 0 additions & 13 deletions arm9/source/patches.c
Original file line number Diff line number Diff line change
Expand Up @@ -797,19 +797,6 @@ void patchTwlBg(u8 *pos, u32 size)
// else error("Failed to apply enable_dsi_external_filter.");
}
}

if (CONFIG(ALLOWUPDOWNLEFTRIGHTDSI))
{
u16 *off2;
for (off2 = (u16 *)pos; (u8 *)off2 < pos + size && (off2[0] != 0x2040 || off2[1] != 0x4020); off2++);

if ((u8 *)off2 < pos + size)
{
// else error("Failed to apply allow_updown_leftright_dsi.");
for (u32 i = 0; i < 8; i++)
off2[i] = 0x46C0;
}
}
}

u32 patchLgyK11(u8 *section1, u32 section1Size, u8 *section2, u32 section2Size)
Expand Down
3 changes: 1 addition & 2 deletions k11_extension/include/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,8 @@ enum singleOptions
REDIRECTAPPTHREADS,
PATCHVERSTRING,
SHOWGBABOOT,
ENABLEDSIEXTFILTER,
ALLOWUPDOWNLEFTRIGHTDSI,
PATCHUNITINFO,
ENABLEDSIEXTFILTER,
DISABLEARM11EXCHANDLERS,
ENABLESAFEFIRMROSALINA,
};
3 changes: 1 addition & 2 deletions sysmodules/loader/source/patcher.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,8 @@ enum singleOptions
REDIRECTAPPTHREADS,
PATCHVERSTRING,
SHOWGBABOOT,
ENABLEDSIEXTFILTER,
ALLOWUPDOWNLEFTRIGHTDSI,
PATCHUNITINFO,
ENABLEDSIEXTFILTER,
DISABLEARM11EXCHANDLERS,
ENABLESAFEFIRMROSALINA,
};
Expand Down
3 changes: 1 addition & 2 deletions sysmodules/pm/source/luma.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,8 @@ enum singleOptions
REDIRECTAPPTHREADS,
PATCHVERSTRING,
SHOWGBABOOT,
ENABLEDSIEXTFILTER,
ALLOWUPDOWNLEFTRIGHTDSI,
PATCHUNITINFO,
ENABLEDSIEXTFILTER,
DISABLEARM11EXCHANDLERS,
ENABLESAFEFIRMROSALINA,
};
Expand Down
Binary file modified sysmodules/rosalina/data/config_template.ini
Binary file not shown.
3 changes: 1 addition & 2 deletions sysmodules/rosalina/include/luma_config.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,8 @@ enum singleOptions
REDIRECTAPPTHREADS,
PATCHVERSTRING,
SHOWGBABOOT,
ENABLEDSIEXTFILTER,
ALLOWUPDOWNLEFTRIGHTDSI,
PATCHUNITINFO,
ENABLEDSIEXTFILTER,
DISABLEARM11EXCHANDLERS,
ENABLESAFEFIRMROSALINA,
};
Expand Down
5 changes: 2 additions & 3 deletions sysmodules/rosalina/source/luma_config.c
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,6 @@ static size_t LumaConfig_SaveLumaIniConfigToStr(char *out, const CfgData *cfg)
(int)CONFIG(AUTOBOOTEMU), (int)CONFIG(LOADEXTFIRMSANDMODULES),
(int)CONFIG(PATCHGAMES), (int)CONFIG(REDIRECTAPPTHREADS),
(int)CONFIG(PATCHVERSTRING), (int)CONFIG(SHOWGBABOOT),
(int)CONFIG(ENABLEDSIEXTFILTER), (int)CONFIG(ALLOWUPDOWNLEFTRIGHTDSI),

1 + (int)MULTICONFIG(DEFAULTEMU), 4 - (int)MULTICONFIG(BRIGHTNESS),
splashPosStr, (unsigned int)cfg->splashDurationMsec,
Expand All @@ -191,8 +190,8 @@ static size_t LumaConfig_SaveLumaIniConfigToStr(char *out, const CfgData *cfg)
forceAudioOutputStr,
cfg->volumeSliderOverride,

(int)CONFIG(PATCHUNITINFO), (int)CONFIG(DISABLEARM11EXCHANDLERS),
(int)CONFIG(ENABLESAFEFIRMROSALINA)
(int)CONFIG(PATCHUNITINFO), (int)CONFIG(ENABLEDSIEXTFILTER),
(int)CONFIG(DISABLEARM11EXCHANDLERS), (int)CONFIG(ENABLESAFEFIRMROSALINA)
);

return n < 0 ? 0 : (size_t)n;
Expand Down
6 changes: 3 additions & 3 deletions sysmodules/rosalina/source/menus/screen_filters.c
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ void ScreenFiltersMenu_LoadConfig(void)

svcGetSystemInfo(&out, 0x10000, 0x104);
topScreenFilter.gamma = (float)(out / FLOAT_CONV_MULT);
if (topScreenFilter.gamma < 0.0f || topScreenFilter.gamma > 1411.0f)
if (topScreenFilter.gamma < 0.0f || topScreenFilter.gamma > 8.0f)
topScreenFilter.gamma = 1.0f;

svcGetSystemInfo(&out, 0x10000, 0x105);
Expand All @@ -221,7 +221,7 @@ void ScreenFiltersMenu_LoadConfig(void)

svcGetSystemInfo(&out, 0x10000, 0x109);
bottomScreenFilter.gamma = (float)(out / FLOAT_CONV_MULT);
if (bottomScreenFilter.gamma < 0.0f || bottomScreenFilter.gamma > 1411.0f)
if (bottomScreenFilter.gamma < 0.0f || bottomScreenFilter.gamma > 8.0f)
bottomScreenFilter.gamma = 1.0f;

svcGetSystemInfo(&out, 0x10000, 0x10A);
Expand Down Expand Up @@ -253,7 +253,7 @@ DEF_CCT_SETTER(1200, Ember)
static void ScreenFiltersMenu_ClampFilter(ScreenFilter *filter)
{
filter->cct = CLAMP(filter->cct, 1000, 25100);
filter->gamma = CLAMP(filter->gamma, 0.0f, 1411.0f); // ln(255) / ln(254/255): (254/255)^1411 <= 1/255
filter->gamma = CLAMP(filter->gamma, 0.0f, 8.0f);
filter->contrast = CLAMP(filter->contrast, 0.0f, 255.0f);
filter->brightness = CLAMP(filter->brightness, -1.0f, 1.0f);
}
Expand Down

0 comments on commit 64293f8

Please sign in to comment.