]> Chaos Git - corbenik/corbenik.git/commitdiff
Bugfixes all over the damn place, and yet another useless feature (tm)
authorchaoskagami <chaos.kagami@gmail.com>
Fri, 15 Jul 2016 10:24:43 +0000 (06:24 -0400)
committerchaoskagami <chaos.kagami@gmail.com>
Fri, 15 Jul 2016 10:24:43 +0000 (06:24 -0400)
More specifically:
 * Fixed an issue in handling R on boot when ctr9_io adaptation was done
 * Don't force logging on (introduced again in the ctr9_io branch)
 * Printing of colored text was incorrect - B and R were swapped
 * Accent color is now customizable.

source/chain.c
source/config.c
source/config.h
source/display.c
source/main.c
source/menu.c
source/std/draw.c

index 9421771a7c26621c8d4a6db663ff7d8231d05c7b..4efa5175e734532cdb9f2943cc80e319b8fbfbca 100644 (file)
@@ -130,11 +130,11 @@ list_chain_build(char *name)
 {
     current_chain_index = 0;
 
-    strncpy(chains[0].name, "\x1b[40;32mChainloader Payloads\x1b[0m", 64);
+    strncpy(chains[0].name, "Chainloader Payloads", 64);
     strncpy(chains[0].desc, "", 255);
     chains[0].index = 0;
     chains[0].allowed = not_option;
-    chains[0].a = 0;
+    chains[0].a = 1;
     chains[0].b = 0;
 
     current_chain_index += 1;
index d6bbc3a32da3f7a58a06e87be702e14ca412b309..b0bf8f10152d26c13e1afa92140562af2e14cddd 100644 (file)
@@ -12,6 +12,7 @@ regenerate_config()
     memset(&config, 0, sizeof(config));
     memcpy(&(config.magic), CONFIG_MAGIC, 4);
     config.config_ver = config_version;
+    config.options[OPTION_ACCENT_COLOR] = 0x2;
 
     if (!(conf_handle = fopen(PATH_CONFIG, "w")))
         abort("Failed to open config for write?\n");
index 54b692827a3622ee7d04a40a8a880636940c7fca..ba5f154ac71438e784123fb3ddca607748228fd6 100644 (file)
@@ -79,6 +79,9 @@ struct options_s
 // Dim background for readability.
 #define OPTION_DIM_MODE 8
 
+// Accent color in menus.
+#define OPTION_ACCENT_COLOR 9
+
 // Enable L2 cache.
 #define OPTION_LOADER_CPU_L2 11
 
index dba94815962033ff731dfa80d770cfad054543e5..6197b64fb558b51ed8168614713225332dfec94f 100644 (file)
@@ -16,6 +16,13 @@ void show_help(char* help) {
     wait_key(1);
 }
 
+void accent_color(void* screen, int fg) {
+    char color[] = "\x1b[30m";
+    if (!fg) color[2] = '4';
+    color[3] = ("01234567")[config.options[OPTION_ACCENT_COLOR]];
+    fprintf(screen, "%s", color);
+}
+
 int
 show_menu(struct options_s *options, uint8_t *toggles)
 {
@@ -85,28 +92,35 @@ show_menu(struct options_s *options, uint8_t *toggles)
             set_cursor(TOP_SCREEN, 0, i-window_top+2);
 
             if (options[i].allowed == boolean_val || (is_n3ds && options[i].allowed == boolean_val_n3ds)) {
-                if (cursor_y == i)
-                    fprintf(TOP_SCREEN, "\x1b[32m>>\x1b[0m ");
-                else
+                if (cursor_y == i) {
+                    accent_color(TOP_SCREEN, 1);
+                    fprintf(TOP_SCREEN, ">>\x1b[0m ");
+                } else {
                     fprintf(TOP_SCREEN, "   ");
+                }
 
                 fprintf(TOP_SCREEN, "[%c]  %s", (toggles[options[i].index] ? '*' : ' '), options[i].name);
             } else if (options[i].allowed == call_fun || options[i].allowed == break_menu) {
-                if (cursor_y == i)
-                    fprintf(TOP_SCREEN, "\x1b[32m>>\x1b[0m ");
-                else
+                if (cursor_y == i) {
+                    accent_color(TOP_SCREEN, 1);
+                    fprintf(TOP_SCREEN, ">>\x1b[0m ");
+                } else {
                     fprintf(TOP_SCREEN, "   ");
+                }
 
                 fprintf(TOP_SCREEN, "%s", options[i].name);
             } else if (options[i].allowed == ranged_val) {
-                if (cursor_y == i)
-                    fprintf(TOP_SCREEN, "\x1b[32m>>\x1b[0m ");
-                else
+                if (cursor_y == i) {
+                    accent_color(TOP_SCREEN, 1);
+                    fprintf(TOP_SCREEN, ">>\x1b[0m ");
+                } else {
                     fprintf(TOP_SCREEN, "   ");
-
+                }
                 fprintf(TOP_SCREEN, "[%u]  %s  ", toggles[options[i].index], options[i].name);
             } else if (options[i].allowed == not_option) {
-                fprintf(TOP_SCREEN, "%s", options[i].name);
+                if (options[i].a == 1)
+                    accent_color(TOP_SCREEN, 1);
+                fprintf(TOP_SCREEN, "%s\x1b[0m", options[i].name);
             }
             ++i;
         }
index 994ab2db236fab7ceb7b3a76c2169c9d0898385a..8a5316e7104c1247dfeb2b9c59aaf57b15e88ad9 100644 (file)
@@ -46,15 +46,13 @@ main(int argc, char** argv)
 
     load_config(); // Load configuration.
 
-    config.options[OPTION_SAVE_LOGS] = 1;
-
     if (CFG_BOOTENV == 7) {
         fprintf(stderr, "Rebooted from AGB, disabling EmuNAND.\n");
         config.options[OPTION_EMUNAND] = 0;
     }
 
     // Autoboot. Non-standard code path.
-    if (config.options[OPTION_AUTOBOOT] && (ctr_hid_get_buttons() & CTR_HID_RT)) {
+    if (config.options[OPTION_AUTOBOOT] && !(ctr_hid_get_buttons() & CTR_HID_RT)) {
         if (config.options[OPTION_SILENCE])
             shut_up(); // This does exactly what it sounds like.
         doing_autoboot = 1;
index 1392b595fb290991428c69ca7e0ceb73a48834e6..6e8adc5c8bba1cb3daf58dd9b5b3d5bde95c16a1 100644 (file)
@@ -11,7 +11,7 @@ uint8_t *enable_list = (uint8_t *)FCRAM_PATCHLIST_LOC;
 
 static struct options_s options[] = {
     // Patches.
-    { 0, "\x1b[32;40mGeneral Options\x1b[0m", "", not_option, 0, 0 },
+    { 0, "General Options", "", not_option, 1, 0 },
 
     { OPTION_SVCS, "svcBackdoor Fixup", "Reinserts svcBackdoor on 11.0 NATIVE_FIRM. svcBackdoor allows executing arbitrary functions with ARM11 kernel permissions, and is required by some (poorly coded) applications.", boolean_val, 0, 0 },
 
@@ -25,10 +25,12 @@ static struct options_s options[] = {
     { OPTION_SILENCE, "  Silent mode", "Suppress all debug output during autoboot. You'll see the screen turn on and then off once.", boolean_val, 0, 0 },
     { OPTION_DIM_MODE, "Dim Background", "Experimental! Dims colors on lighter backgrounds to improve readability with text. You won't notice the change until scrolling or exiting the current menu due to the way rendering works.", boolean_val, 0, 0 },
 
+    { OPTION_ACCENT_COLOR, "Accent color", "Changes the accent color in menus.", ranged_val, 1, 7},
+
     // space
     { 0, "", "", not_option, 0, 0 },
     // Patches.
-    { 0, "\x1b[32;40mLoader Options\x1b[0m", "", not_option, 0, 0 },
+    { 0, "Loader Options", "", not_option, 1, 0 },
 
     { OPTION_LOADER, "Use Loader Replacement", "Replaces loader with one capable of extra features. You should enable this even if you don't plan to use loader-based patches to kill ASLR and the Ninjhax/OOThax checks.", boolean_val, 0, 0 },
     { OPTION_LOADER_CPU_L2, "  CPU - L2 cache", "Forces the system to use the L2 cache on all applications. If you have issues with crashes, try turning this off.", boolean_val_n3ds, 0, 0 },
@@ -45,7 +47,7 @@ static struct options_s options[] = {
     // space
     { 0, "", "", not_option, 0, 0 },
     // Patches.
-    { 0, "\x1b[32;40mDeveloper Options\x1b[0m", "", not_option, 0, 0 },
+    { 0, "Developer Options", "", not_option, 1, 0 },
 
     { OPTION_TRACE, "Step Through", "After each important step, [WAIT] will be shown and you'll need to press a key. Debug feature.", boolean_val, 0, 0 },
     { OPTION_OVERLY_VERBOSE, "Verbose", "Output more debug information than the average user needs.", boolean_val, 0, 0 },
@@ -61,12 +63,15 @@ static struct options_s options[] = {
 
 extern unsigned int font_w;
 
+void accent_color(void* screen, int fg);
+
 void
 header(char *append)
 {
     set_cursor(TOP_SCREEN, 0, 0);
-    fill_line(stdout, 0, 0x2);
-    fprintf(stdout, "\x1b[30;42m ." FW_NAME " // %s\x1b[0m\n\n", append);
+    fill_line(stdout, 0, config.options[OPTION_ACCENT_COLOR]);
+    accent_color(TOP_SCREEN, 0);
+    fprintf(stdout, "\x1b[30m ." FW_NAME " // %s\x1b[0m\n\n", append);
 }
 
 static int current_menu_index_patches = 0;
@@ -140,11 +145,11 @@ list_patches_build(char *name, int desc_is_fname)
     memset(enable_list, 0, FCRAM_SPACING / 2);
 
     if (!desc_is_fname) {
-        strncpy(patches[0].name, "\x1b[40;32mPatches\x1b[0m", 64);
+        strncpy(patches[0].name, "Patches", 64);
         strncpy(patches[0].desc, "", 255);
         patches[0].index = 0;
         patches[0].allowed = not_option;
-        patches[0].a = 0;
+        patches[0].a = 1;
         patches[0].b = 0;
 
         current_menu_index_patches += 1;
index 89b169344ddfda715727c20d54244020880c7684..d2c7ae5fc26abfce33578ef99d78d69669b83e01 100644 (file)
@@ -356,9 +356,9 @@ draw_character(uint8_t *screen, const uint32_t character, int ch_x, int ch_y, co
                         screen[pos + 2] = buffer_bg[pos + 2] - dim_factor;
                 }
             } else {
-                screen[pos]     = color_bg >> 16;
+                screen[pos]     = color_bg;
                 screen[pos + 1] = color_bg >> 8;
-                screen[pos + 2] = color_bg;
+                screen[pos + 2] = color_bg >> 16;
             }
 
             if (char_dat & 0x80) {
@@ -379,9 +379,9 @@ draw_character(uint8_t *screen, const uint32_t character, int ch_x, int ch_y, co
                             screen[pos + 2] = buffer_bg[pos + 2] - dim_factor;
                     }
                 } else {
-                    screen[pos]     = color_fg >> 16;
+                    screen[pos]     = color_fg;
                     screen[pos + 1] = color_fg >> 8;
-                    screen[pos + 2] = color_fg;
+                    screen[pos + 2] = color_fg >> 16;
                 }
             }