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

45 lines
1.2 KiB
C
Raw Normal View History

#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)
{
2016-03-24 16:02:00 +01:00
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
2016-04-02 22:02:08 +02:00
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)();
}