#include "fsreg.h"
#include "pxipm.h"
#include "srvsys.h"
-#include "lzss.h"
+#include <lzss.c>
#include "internal.h"
#include "logger.h"
+++ /dev/null
-#ifndef __LZSS_H
-#define __LZSS_H
-
-int lzss_decompress(u8 *buffer);
-
-#endif
// 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
-#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;
return ret;
}
+
+#endif
// (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
((void (*)())*arm11Entry)();
}
-static void invokeArm11Function(void (*func)())
-{
+void installArm11Stub(void) {
static int hasCopiedStub = false;
if(!hasCopiedStub)
{
ctr_cache_clean_and_flush_all();
hasCopiedStub = true;
}
+}
+
+void invokeArm11Function(void (*func)())
+{
+ installArm11Stub();
*arm11Entry = (uint32_t)func;
while(*arm11Entry);
//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);
}
// 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)();
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.
}