Allocate framebuffer before screeninit, and only initialize screen before entering menu (or showing splash)
*/
void installArm11Stub(void);
+/* Sets up framebuffer offsets independent of screeninit.
+ */
+void set_fb_struct();
+
#endif
/* Loads top background image from a path.
*
* \param fname_top filename to load from.
+ * \return 1 if background loaded
*/
-void load_bg_top(const char* fname_top);
+int load_bg_top(const char* fname_top);
/* Loads bottom background image from a path.
*
* \param fname_bottom filename to load from.
+ * \return 1 if background loaded
*/
-void load_bg_bottom(const char* fname_bottom);
+int load_bg_bottom(const char* fname_bottom);
/* Clears the displays either to black or the background image.
*/
invokeArm11Function(ARM11);
}
+void set_fb_struct() {
+ if (!framebuffers) {
+ // Look ma, dynamically allocating the CakeHax struct! (joking)
+ // We literally just discard the previous state - for sanity's sake.
+ // On chainload, it is needed to copy the framebuffer struct.
+ framebuffers = memalign(16, sizeof(struct framebuffers));
+
+ // Set not-actually cakebrah framebuffers. Meh.
+ framebuffers->top_left = (uint8_t *)0x18300000;
+ framebuffers->top_right = (uint8_t *)0x18300000;
+ framebuffers->bottom = (uint8_t *)0x1835dc00;
+ }
+}
+
void screen_mode(uint32_t mode) {
static uint32_t stride, init_top, init_bottom, bright;
init_top = MAKE_FRAMEBUFFER_PIXFMT(mode, 0, 1);
init_bottom = MAKE_FRAMEBUFFER_PIXFMT(mode, 0, 0);
- if (!framebuffers) {
- // Look ma, dynamically allocating the CakeHax struct! (joking)
- // We literally just discard the previous state - for sanity's sake.
- // On chainload, it is needed to copy the framebuffer struct.
- framebuffers = memalign(16, sizeof(struct framebuffers));
- }
-
void __attribute__((naked)) ARM11(void) {
//Disable interrupts
__asm(".word 0xF10C01C0");
PDC1_FRAMEBUFFER_SETUP_FBA_ADDR_1 = 0x1835dc00;
PDC1_FRAMEBUFFER_SETUP_FBA_ADDR_2 = 0x1835dc00;
- // Set not-actually cakebrah framebuffers. Meh.
- framebuffers->top_left = (uint8_t *)0x18300000;
- framebuffers->top_right = (uint8_t *)0x18300000;
- framebuffers->bottom = (uint8_t *)0x1835dc00;
-
WAIT_FOR_ARM9();
}
int
main(int argc, char** argv)
{
+ int have_bg = 0;
+ int si = 0;
+
int r_held = (ctr_hid_get_buttons() & CTR_HID_RT);
if (PDN_MPCORE_CFG == 7)
set_font(PATH_TERMFONT); // Read the font before all else.
// Check key down for autoboot
- screen_mode(RGBA8); // Use RGBA8 mode.
+ set_fb_struct();
clear_bg();
- load_bg_top (PATH_TOP_BG);
- load_bg_bottom(PATH_BOTTOM_BG); // This is a menuhax splash (90deg rotated BGR8 pixel data)
+ // This is a menuhax splash (90deg rotated BGR8 pixel data)
+ if (load_bg_top(PATH_TOP_BG) || load_bg_bottom(PATH_BOTTOM_BG))
+ have_bg = 1;
clear_disp(TOP_SCREEN);
clear_disp(BOTTOM_SCREEN);
if (get_opt_u32(OPTION_SILENCE))
shut_up(); // This does exactly what it sounds like.
+
+ if (have_bg && !si) {
+ screen_mode(RGBA8); // Use RGBA8 mode.
+ si = 1;
+ }
} else {
+ if (!si) {
+ screen_mode(RGBA8); // Use RGBA8 mode.
+ si = 1;
+ }
menu_handler();
}
memset(bottom_bg, 0, BOTTOM_SIZE);
}
-void load_bg_top(const char* fname_top) {
+int load_bg_top(const char* fname_top) {
FILE* f = cropen(fname_top, "r");
- if (!f) return;
+ if (!f) return 0;
for (int i=1; i < TOP_SIZE; i += 4) {
crread(&top_bg[i], 1, 3, f);
}
crclose(f);
+
+ return 1;
}
-void load_bg_bottom(const char* fname_bottom) {
+int load_bg_bottom(const char* fname_bottom) {
FILE* f = cropen(fname_bottom, "r");
if (!f)
- return;
+ return 0;
for (int i=1; i < BOTTOM_SIZE; i += 4) {
crread(&bottom_bg[i], 1, 3, f);
}
crclose(f);
+
+ return 1;
}
void set_font(const char* filename) {