Remade the chainloader to only try to load the right payload for the pressed button, got rid of the default payload (start now boots "start_NAME.bin"), sel_NAME is now select_NAME as there is no more SFN limitations anymore

This commit is contained in:
Aurora
2016-04-29 14:28:37 +02:00
parent e651c3d9cc
commit c6d3158b56
10 changed files with 55 additions and 85 deletions

View File

@@ -1,39 +1,6 @@
#include "types.h"
#include "buttons.h"
#include "fatfs/ff.h"
#define PAYLOAD_ADDRESS 0x23F00000
#define LOAD_PAYLOAD(a) loadPayload(a "_*.bin")
static u32 loadPayload(const char *pattern)
{
char path[29] = "/luma/payloads";
DIR dir;
FILINFO info;
FRESULT result = f_findfirst(&dir, &info, path, pattern);
f_closedir(&dir);
if(result != FR_OK || !info.fname[0])
return 0;
path[14] = '/';
u32 i;
for(i = 0; info.fname[i]; i++)
path[15 + i] = info.fname[i];
path[15 + i] = '\0';
FIL payload;
unsigned int read;
f_open(&payload, path, FA_READ);
f_read(&payload, (void *)PAYLOAD_ADDRESS, f_size(&payload), &read);
f_close(&payload);
return 1;
}
void main(void)
{
@@ -41,18 +8,12 @@ void main(void)
f_mount(&fs, "0:", 1);
//Get pressed buttons
u32 pressed = HID_PAD;
FIL payload;
unsigned int read;
if(((pressed & BUTTON_RIGHT) && LOAD_PAYLOAD("right")) ||
((pressed & BUTTON_LEFT) && LOAD_PAYLOAD("left")) ||
((pressed & BUTTON_UP) && LOAD_PAYLOAD("up")) ||
((pressed & BUTTON_DOWN) && LOAD_PAYLOAD("down")) ||
((pressed & BUTTON_X) && LOAD_PAYLOAD("x")) ||
((pressed & BUTTON_Y) && LOAD_PAYLOAD("y")) ||
((pressed & BUTTON_R1) && LOAD_PAYLOAD("r")) ||
((pressed & BUTTON_A) && LOAD_PAYLOAD("a")) ||
((pressed & BUTTON_SELECT) && LOAD_PAYLOAD("sel")) ||
LOAD_PAYLOAD("def"))
((void (*)())PAYLOAD_ADDRESS)();
f_open(&payload, (char *)0x24F02000, FA_READ);
f_read(&payload, (void *)PAYLOAD_ADDRESS, f_size(&payload), &read);
f_close(&payload);
((void (*)())PAYLOAD_ADDRESS)();
}