]> Chaos Git - corbenik/corbenik.git/commitdiff
Minor tweaks
authorchaoskagami <chaos.kagami@gmail.com>
Wed, 17 Aug 2016 14:44:02 +0000 (10:44 -0400)
committerchaoskagami <chaos.kagami@gmail.com>
Wed, 17 Aug 2016 14:44:02 +0000 (10:44 -0400)
external/loader/source/loader.c
external/loader/source/lzss.h [deleted file]
include/arm11.h
include/lzss.c [moved from external/loader/source/lzss.c with 88% similarity]
include/option.h
source/arm11.c
source/firm/firm.c
source/main.c

index 535307368cce632750c64d90288379221c59d108..609aa9f4036e33211fadedb65f0422b403be545c 100644 (file)
@@ -5,7 +5,7 @@
 #include "fsreg.h"
 #include "pxipm.h"
 #include "srvsys.h"
-#include "lzss.h"
+#include <lzss.c>
 #include "internal.h"
 #include "logger.h"
 
diff --git a/external/loader/source/lzss.h b/external/loader/source/lzss.h
deleted file mode 100644 (file)
index 5ab8b82..0000000
+++ /dev/null
@@ -1,6 +0,0 @@
-#ifndef __LZSS_H
-#define __LZSS_H
-
-int lzss_decompress(u8 *buffer);
-
-#endif
index 4dfeac41aa17af53295bec9b9f7fa8f10b33b050..f7c2a21d9569c76fa52f381db25bedb8696c9e50 100644 (file)
 
 // Inits the screen if needed.
 void screen_mode(uint32_t mode);
+void invokeArm11Function(void (*func)());
+void deinitScreens(void);
+void updateBrightness(uint32_t brightnessIndex);
+void clearScreens(void);
+void installArm11Stub(void);
 
 #endif
similarity index 88%
rename from external/loader/source/lzss.c
rename to include/lzss.c
index 7ca6e0bce1c4514a60605bf62212463398cf731c..c2f02ded9da5f6d63350b8277b3fae56af23f238 100644 (file)
@@ -1,14 +1,11 @@
-#include <3ds.h>
+#ifndef __LZSS_H
+#define __LZSS_H
 
-// TODO - In the future, why not ADD code compression modes? Like, zlib, for example. Or lzss+zlib.
-
-int
+static int
 lzss_decompress(u8 *buffer)
 {
     // This WAS originally a decompilation in @yifan_lu's repo; it was rewritten
     // for readability following ctrtool's namings.
-    // You can thank me for making it more readable if you'd like; I don't
-    // really care. Did it for myself.
     unsigned int decompSize, v15;
     u8 *compressEndOff, *index, *stopIndex;
     char control;
@@ -55,3 +52,5 @@ lzss_decompress(u8 *buffer)
 
     return ret;
 }
+
+#endif
index fb864d7db11d18a38eba786308e619cbece670f5..30d86bb09c16ed0bed10238dca1bec1b0312eeca 100644 (file)
@@ -121,6 +121,9 @@ struct options_s
 // (e.g. SaltySD)
 #define OPTION_LOADER_LOADCODE 21
 
+// Silenced autoboot will not init the screen.
+#define OPTION_SILENT_NOSCREEN 22
+
 // Calculate EmuNAND at the back of the disk, rather than the front.
 // There's many good reasons for this to be supported:
 //   - Resizable FAT partition
index 2115a2c6774c2cd5d9841804e7d72f8f8daf3e05..f8566aa3683ca759220f3597cd1f4733fe3eb040 100644 (file)
@@ -53,8 +53,7 @@ void  __attribute__((naked)) arm11Stub(void)
     ((void (*)())*arm11Entry)();
 }
 
-static void invokeArm11Function(void (*func)())
-{
+void installArm11Stub(void) {
     static int hasCopiedStub = false;
     if(!hasCopiedStub)
     {
@@ -62,6 +61,11 @@ static void invokeArm11Function(void (*func)())
                ctr_cache_clean_and_flush_all();
         hasCopiedStub = true;
     }
+}
+
+void invokeArm11Function(void (*func)())
+{
+    installArm11Stub();
 
     *arm11Entry = (uint32_t)func;
     while(*arm11Entry);
@@ -78,11 +82,13 @@ void deinitScreens(void)
         //Shutdown LCDs
         *(volatile uint32_t *)0x10202A44 = 0;
         *(volatile uint32_t *)0x10202244 = 0;
+        *(volatile uint32_t *)0x1020200C = 0;
         *(volatile uint32_t *)0x10202014 = 0;
 
         WAIT_FOR_ARM9();
     }
 
+    // If screen is initialized, invoke.
     if(PDN_GPU_CNT != 1) invokeArm11Function(ARM11);
 }
 
index 1be1a4d05689808cc7537c88e3e68eca52b10bfe..171dc3648f4fae540d6de9d03229a24cd3bf57ff 100644 (file)
@@ -473,9 +473,8 @@ boot_firm()
 
     // No fprintf will work from here on out.
 
-    *a11_entry = (uint32_t)arm11_preboot_halt;
-    while (*a11_entry)
-        ; // Make sure it jumped there correctly before changing it.
+    deinitScreens();
+
     *a11_entry = (uint32_t)firm_loc->a11Entry;
 
     ((void (*)())firm_loc->a9Entry)();
index c0fd59e2d3f429c89752589748bb34f2c93fcdde..d33d13174fd243d095f15e793bf9e3b7efd61015 100644 (file)
@@ -22,38 +22,41 @@ main(int argc, char** argv)
     if (fmount())
         poweroff(); // Failed to mount SD. Bomb out.
 
-    set_font(PATH_TERMFONT); // Read the font before all else.
-
     load_config(); // Load configuration.
 
+    install_interrupts(); // Get some free debug info.
+
+    installArm11Stub();
+
+    if (CFG_BOOTENV == 7)
+        config->options[OPTION_EMUNAND] = 0; // Disable EmuNAND on AGB reboot.
+
+    if (config->options[OPTION_AUTOBOOT] && !(ctr_hid_get_buttons() & CTR_HID_RT)) {
+        doing_autoboot = 1;
+
+        if (config->options[OPTION_SILENCE] || config->options[OPTION_SILENT_NOSCREEN])
+            shut_up(); // This does exactly what it sounds like.
+
+        if (config->options[OPTION_SILENT_NOSCREEN])
+            boot_cfw(); // Skip all other checks and just boot.
+    }
+
+    set_font(PATH_TERMFONT); // Read the font before all else.
+
+    // Check key down for autoboot
     screen_mode(RGBA8); // Use RGBA8 mode.
 
     clear_bg();
 
     load_bg_top   (PATH_TOP_BG);
-    load_bg_bottom(PATH_BOTTOM_BG); // This is basically a menuhax splash (90deg rotated BGR8 pixel data)
+    load_bg_bottom(PATH_BOTTOM_BG); // This is a menuhax splash (90deg rotated BGR8 pixel data)
 
     clear_disp(TOP_SCREEN);
     clear_disp(BOTTOM_SCREEN);
 
-//    ctr_screen_enable_backlight(CTR_SCREEN_BOTH);
-
-//    install_interrupts(); // Get some free debug info.
-
-    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_SILENCE])
-            shut_up(); // This does exactly what it sounds like.
-        doing_autoboot = 1;
-    } else {
+    if (!doing_autoboot)
         menu_handler();
-    }
 
     boot_cfw();
-    // Under ideal conditions, we never get here.
 }