File management improvements

This commit is contained in:
wiidev 2023-02-16 23:40:02 +00:00
parent 7d13d45861
commit 2d6c458083
3 changed files with 31 additions and 20 deletions

View File

@ -32,6 +32,7 @@ u32 appIos = 0;
#define MEM2PROT 0x0D8B420A #define MEM2PROT 0x0D8B420A
#define ESMODULESTART (u16*)0x939F0000 #define ESMODULESTART (u16*)0x939F0000
#define MB_SIZE 1048576.0
static const u16 ticket[] = { static const u16 ticket[] = {
0x685B, // ldr r3,[r3,#4] ; get TMD pointer 0x685B, // ldr r3,[r3,#4] ; get TMD pointer
@ -64,7 +65,7 @@ static bool patchahbprot(void)
} }
} }
bool LoadApp(const char* path) bool LoadApp(const char* path, const char* filename)
{ {
Con_Clear(); Con_Clear();
@ -88,6 +89,8 @@ bool LoadApp(const char* path)
*(vu32*)0x91000000 = 0; *(vu32*)0x91000000 = 0;
} }
/*
// This causes crashes when XML nodes are empty
struct MetaData* appData = LoadMetaData(currentPath); struct MetaData* appData = LoadMetaData(currentPath);
if (appData) if (appData)
@ -100,19 +103,14 @@ bool LoadApp(const char* path)
printf("\n"); printf("\n");
} }
*/
snprintf(currentPath, sizeof(currentPath), "%s/boot.dol", path); snprintf(currentPath, sizeof(currentPath), "%s/%s", path, filename);
FILE* f = fopen(currentPath, "rb"); FILE* f = fopen(currentPath, "rb");
if (f == NULL) if (f == NULL)
{ return false;
snprintf(currentPath, sizeof(currentPath), "%s/boot.elf", path);
f = fopen(currentPath, "rb");
if (f == NULL)
return false;
}
printf("-> Load: %s\n", currentPath); printf("-> Load: %s\n", currentPath);
@ -135,7 +133,8 @@ bool LoadApp(const char* path)
} }
else else
{ {
printf("-> App size: 0x%X\n\n", appSize); f32 filesize = (appSize / MB_SIZE);
printf("-> App size: %.2f MB\n\n", filesize);
} }
DCFlushRange(appBuffer, appSize); DCFlushRange(appBuffer, appSize);

View File

@ -16,7 +16,7 @@ typedef struct _dolhdr
u32 entrypoint; u32 entrypoint;
} dolhdr; } dolhdr;
bool LoadApp(const char* path); bool LoadApp(const char* path, const char* filename);
u8* GetApp(u32* size); u8* GetApp(u32* size);
void LaunchApp(void); void LaunchApp(void);
void SetIos(int ios); void SetIos(int ios);

View File

@ -664,11 +664,23 @@ int Menu_FileOperations(fatFile *file, char *inFilePath)
{ {
Con_Clear(); Con_Clear();
printf("[+] WAD Filename : %s\n", file->filename); if(file->iswad) {
printf(" WAD Filesize : %.2f MB\n\n\n", filesize); printf("[+] WAD Filename : %s\n", file->filename);
printf(" WAD Filesize : %.2f MB\n\n\n", filesize);
printf("[+] Select action: < %s WAD >\n\n", "Delete"); //There's yet nothing else than delete
printf("[+] Select action: < %s WAD >\n\n", "Delete"); //There's yet nothing else than delete }
else if(file->isdol) {
printf("[+] DOL Filename : %s\n", file->filename);
printf(" DOL Filesize : %.2f MB\n\n\n", filesize);
printf("[+] Select action: < %s DOL >\n\n", "Delete");
}
else if(file->iself) {
printf("[+] ELF Filename : %s\n", file->filename);
printf(" ELF Filesize : %.2f MB\n\n\n", filesize);
printf("[+] Select action: < %s ELF >\n\n", "Delete");
}
else
return 0;
printf(" Press LEFT/RIGHT to change selected action.\n\n"); printf(" Press LEFT/RIGHT to change selected action.\n\n");
@ -721,7 +733,7 @@ void Menu_WadManage(fatFile *file, char *inFilePath)
/* Clear console */ /* Clear console */
Con_Clear(); Con_Clear();
if(file->iswad) { if(file->iswad) {
printf("[+] WAD Filename : %s\n", file->filename); printf("[+] WAD Filename : %s\n", file->filename);
printf(" WAD Filesize : %.2f MB\n\n\n", filesize); printf(" WAD Filesize : %.2f MB\n\n\n", filesize);
@ -732,12 +744,12 @@ void Menu_WadManage(fatFile *file, char *inFilePath)
} }
else { else {
if(file->isdol) { if(file->isdol) {
printf("[+] DOL Filename : %s\n", file->filename); printf("[+] DOL Filename : %s\n", file->filename);
printf(" DOL Filesize : %.2f MB\n\n\n", filesize); printf(" DOL Filesize : %.2f MB\n\n\n", filesize);
printf(" Press A to launch DOL.\n"); printf(" Press A to launch DOL.\n");
} }
if(file->iself) { if(file->iself) {
printf("[+] ELF Filename : %s\n", file->filename); printf("[+] ELF Filename : %s\n", file->filename);
printf(" ELF Filesize : %.2f MB\n\n\n", filesize); printf(" ELF Filesize : %.2f MB\n\n\n", filesize);
printf(" Press A to launch ELF.\n"); printf(" Press A to launch ELF.\n");
} }
@ -790,7 +802,7 @@ void Menu_WadManage(fatFile *file, char *inFilePath)
else { else {
printf("launch dol/elf here \n"); printf("launch dol/elf here \n");
if(LoadApp(inFilePath)) { if(LoadApp(inFilePath, file->filename)) {
LaunchApp(); LaunchApp();
} }
return; return;