GBA-Exploader/arm9/source/ret_menu9_Gen.c
ApacheThunder 11ea610150 Fix fifo ...
* FIFO on arm7 appears to now work as intended.
* GBA mode switch funcition remains broken.
* Default GBA_Exploader.ini file now created if one is not present.
* Moved GBA_File struct to ctrl_tble and removed duplicate from main.c.
This was causing issues where I would forget to update both when I
removed the now unused Alias char array. All code now shares the single
instance which will prevent this issue should this struct need to be
updated in the future.
2024-05-08 15:24:51 -05:00

99 lines
2.1 KiB
C
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

/***********************************************************
Arm9 Soft rest for General purpose
by Rudolph (<28>cé)
***************************************************************/
#include <nds.h>
//#include <nds/registers_alt.h> // devkitPror20
#include <nds/arm9/dldi.h>
#include <fat.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
// extern u32 _io_dldi;
static char *menu_nam;
static char name[32];
bool ret_menu_chk() {
FILE *fp;
char buf[5];
buf[0] = io_dldi_data->ioInterface.ioType & 0xFF;
buf[1] = (io_dldi_data->ioInterface.ioType >> 8) & 0xFF;
buf[2] = (io_dldi_data->ioInterface.ioType >> 16) & 0xFF;
buf[3] = (io_dldi_data->ioInterface.ioType >> 24) & 0xFF;
buf[4] = 0;
sprintf(name, "/SoftReset.%s", buf);
fp = fopen(name, "rb");
if(fp != NULL) {
fclose(fp);
menu_nam = name;
return true;
}
menu_nam = NULL;
switch (io_dldi_data->ioInterface.ioType) {
case 0x53444353: menu_nam = "/MSFORSC.NDS"; break; // SCDS
// case 0x4F49524E: menu_nam = "/udisk.nds"; break; // N-Card and Clones
case 0x4E475052: menu_nam = "/akmenu4.nds"; break; // AK.R.P.G NAND
case 0x53475052: menu_nam = "/akmenu4.nds"; break; // AK.R.P.G SD
case 0x44533958: menu_nam = "/loader.nds"; break; // X9 SD
case 0x4F495454: menu_nam = "/TTMENU.DAT"; break; // DSTT
}
// if(_io_dldi == 0x58585858) { // AK+(XXXX)
// menu_nam = "/system/akmenu2_fat.nds";
// }
if(menu_nam != NULL) {
fp = fopen(menu_nam, "rb");
if(fp != NULL) {
fclose(fp);
return true;
}
}
return false;
}
bool ret_menu9_Gen() {
u32 hed[16];
u8 *ldrBuf;
FILE *ldr;
u32 siz;
ldr = fopen(menu_nam, "rb");
if(ldr == NULL) return false;
fread((u8*)hed, 1, 16*4, ldr);
siz = 512 + hed[11] + hed[15];
ldrBuf = (u8*)malloc(siz);
if(ldrBuf == NULL) {
fclose(ldr);
return false;
}
fseek(ldr, 0, SEEK_SET);
fread(ldrBuf, 1, 512, ldr);
fseek(ldr, hed[8], SEEK_SET);
fread(ldrBuf + 512, 1, hed[11], ldr);
fseek(ldr, hed[12], SEEK_SET);
fread(ldrBuf + 512 + hed[11], 1, hed[15], ldr);
fclose(ldr);
(*(vu32*)0x027FFDF4) = (u32)ldrBuf;
return true;
}