This repository has been archived on 2022-05-31. You can view files and clone it, but cannot push or open issues or pull requests.
Luma3DS-3GX/loader/source/main.c
Aurora 0f64fd73ec Fix bug when quitting AGB_FIRM
The wrong config.bin section was used to remember the last-used FIRM
2016-04-16 20:27:52 +02:00

45 lines
1.2 KiB
C

#include "types.h"
#include "buttons.h"
#include "fatfs/ff.h"
#define PAYLOAD_ADDRESS 0x23F00000
#define PAYLOADS_FOLDER "/aurei/payloads/"
#define PAYLOAD_PATH(a) PAYLOADS_FOLDER a ".bin"
static u32 loadPayload(const char *path)
{
FIL payload;
unsigned int br;
if(f_open(&payload, path, FA_READ) == FR_OK)
{
f_read(&payload, (void *)PAYLOAD_ADDRESS, f_size(&payload), &br);
f_close(&payload);
return 1;
}
return 0;
}
void main(void)
{
FATFS fs;
f_mount(&fs, "0:", 1);
//Get pressed buttons
u32 pressed = HID_PAD;
if(((pressed & BUTTON_RIGHT) && loadPayload(PAYLOAD_PATH("right"))) ||
((pressed & BUTTON_LEFT) && loadPayload(PAYLOAD_PATH("left"))) ||
((pressed & BUTTON_UP) && loadPayload(PAYLOAD_PATH("up"))) ||
((pressed & BUTTON_DOWN) && loadPayload(PAYLOAD_PATH("down"))) ||
((pressed & BUTTON_X) && loadPayload(PAYLOAD_PATH("x"))) ||
((pressed & BUTTON_Y) && loadPayload(PAYLOAD_PATH("y"))) ||
((pressed & BUTTON_SELECT) && loadPayload(PAYLOAD_PATH("select"))) ||
((pressed & BUTTON_R1) && loadPayload(PAYLOAD_PATH("r"))) ||
loadPayload(PAYLOAD_PATH("default")))
((void (*)())PAYLOAD_ADDRESS)();
}