From: chaoskagami Date: Sat, 30 Jul 2016 03:35:39 +0000 (-0400) Subject: WIP - change brightness in menu. Requested by someone on IRC. X-Git-Tag: v0.3.0~72^2~2 X-Git-Url: https://chaos.moe/g/?a=commitdiff_plain;h=241b0f9c7b5f1fb139dd1153eef06f349cc27bae;p=corbenik%2Fcorbenik.git WIP - change brightness in menu. Requested by someone on IRC. Currently requires rebooting to fully apply; largely waiting on libctr11, since refactoring will be largely made pointless when it is released. --- diff --git a/include/option.h b/include/option.h index ba5f154..ddcd8af 100644 --- a/include/option.h +++ b/include/option.h @@ -73,15 +73,15 @@ struct options_s // Pause for A key on each step. #define OPTION_TRACE 7 -// Freed up options due to code changes. -// 9, 10 - // Dim background for readability. #define OPTION_DIM_MODE 8 // Accent color in menus. #define OPTION_ACCENT_COLOR 9 +// Screeninit brightness +#define OPTION_BRIGHTNESS 10 + // Enable L2 cache. #define OPTION_LOADER_CPU_L2 11 diff --git a/source/main.c b/source/main.c index c3a2da5..9a728e1 100644 --- a/source/main.c +++ b/source/main.c @@ -21,6 +21,22 @@ main(int argc, char** argv) int c = fmount(); + if (c) { + // Failed to mount SD. Bomb out. + // TODO - What the hell does one even do in this situation? + // Spin until the card is available to mount, maybe? + abort("Failed to mount SD card.\n"); + } + + if (argc >= 1 && argc < 2) { + // Valid argc passed. + fprintf(stderr, "Chainloaded. Path: %s\n", argv[0]); + } + + set_font(PATH_TERMFONT); // Read the font before all else. + + load_config(); // Load configuration. + screen_mode(0); // Use RGBA8 mode. clear_bg(); @@ -33,22 +49,8 @@ main(int argc, char** argv) ctr_screen_enable_backlight(CTR_SCREEN_BOTH); - set_font(PATH_TERMFONT); - install_interrupts(); // Get some free debug info. - if (c) { - // Failed to mount SD. Bomb out. - abort("Failed to mount SD card.\n"); - } - - if (argc >= 1 && argc < 2) { - // Valid argc passed. - fprintf(stderr, "Chainloaded. Path: %s\n", argv[0]); - } - - load_config(); // Load configuration. - if (CFG_BOOTENV == 7) { fprintf(stderr, "Rebooted from AGB, disabling EmuNAND.\n"); config.options[OPTION_EMUNAND] = 0; diff --git a/source/menu.c b/source/menu.c index d06b09c..36adf09 100644 --- a/source/menu.c +++ b/source/menu.c @@ -23,6 +23,8 @@ static struct options_s options[] = { { OPTION_ACCENT_COLOR, "Accent color", "Changes the accent color in menus.", ranged_val, 1, 7}, + { OPTION_BRIGHTNESS, "Brightness", "Changes the screeninit brightness in menu. WIP, only takes effect on reboot (this will change.)", ranged_val, 0, 3}, + // space { 0, "", "", not_option, 0, 0 }, // Patches. diff --git a/source/option.c b/source/option.c index 0125d49..2abcb06 100644 --- a/source/option.c +++ b/source/option.c @@ -13,6 +13,7 @@ regenerate_config() memcpy(&(config.magic), CONFIG_MAGIC, 4); config.config_ver = config_version; config.options[OPTION_ACCENT_COLOR] = 2; + config.options[OPTION_BRIGHTNESS] = 3; if (!(conf_handle = fopen(PATH_CONFIG, "w"))) abort("Failed to open config for write?\n"); diff --git a/source/screeninit.c b/source/screeninit.c index 2348aaf..72dc48e 100644 --- a/source/screeninit.c +++ b/source/screeninit.c @@ -30,7 +30,9 @@ screen_mode(uint32_t mode) if (PDN_GPU_CNT == 1) screenInitAddress[2] = 0; // Do a full init. - screenInitAddress[3] = 0xFF; // Brightness + // FIXME - God awful syntactical hack. + screenInitAddress[3] = ("\x40\x8F\xC0\xFF")[config.options[OPTION_BRIGHTNESS]]; + screenInitAddress[4] = mode; // Mode *a11_entry = (uint32_t)screenInitAddress;