]> Chaos Git - corbenik/corbenik.git/commitdiff
WIP - change brightness in menu. Requested by someone on IRC.
authorchaoskagami <chaos.kagami@gmail.com>
Sat, 30 Jul 2016 03:35:39 +0000 (23:35 -0400)
committerchaoskagami <chaos.kagami@gmail.com>
Sat, 30 Jul 2016 03:35:39 +0000 (23:35 -0400)
Currently requires rebooting to fully apply; largely waiting on libctr11, since refactoring will be largely made pointless when it is released.

include/option.h
source/main.c
source/menu.c
source/option.c
source/screeninit.c

index ba5f154ac71438e784123fb3ddca607748228fd6..ddcd8af51a5b80f7a7cda31b128d28252ba26a64 100644 (file)
@@ -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
 
index c3a2da5854aa1158c1a6c64633b4c62c9da455fe..9a728e1fa7366d4fe628d087099335ac8bb5dec2 100644 (file)
@@ -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;
index d06b09cbbeb781c9ca46f92ab07260db56d40ab6..36adf095a31dc48c04fe16ea9159a1c3e6773dfc 100644 (file)
@@ -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.
index 0125d49910e0b25763947e4c8d3a8cefee2a1e8b..2abcb06c4e27da18567b6b0ba27c9965eef72bb5 100644 (file)
@@ -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");
index 2348aafcdda8cbc2b6a40330ac46a138d14ed979..72dc48e14273ff05e93ca280c6512925da98fd7f 100644 (file)
@@ -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;