Show cart ID and type on cart drive

Fixes #435
This commit is contained in:
d0k3 2018-11-05 00:19:41 +01:00
parent f13a5c6e4f
commit 75a23a15c3
3 changed files with 17 additions and 0 deletions

View File

@ -2,6 +2,7 @@
#include "fsgame.h"
#include "fsinit.h"
#include "virtual.h"
#include "vcart.h"
#include "sddata.h"
#include "image.h"
#include "ui.h"
@ -85,6 +86,9 @@ bool GetRootDirContentsWorker(DirStruct* contents) {
char sdlabel[16];
if (!GetFATVolumeLabel("0:", sdlabel))
snprintf(sdlabel, 16, "NOLABEL");
char carttype[16];
GetVCartTypeString(carttype);
// virtual root objects hacked in
for (u32 i = 0; (i < NORM_FS+VIRT_FS) && (n_entries < MAX_DIR_ENTRIES); i++) {
@ -109,6 +113,8 @@ bool GetRootDirContentsWorker(DirStruct* contents) {
(GetMountState() & GAME_NDS ) ? "NDS" :
(GetMountState() & SYS_FIRM ) ? "FIRM" :
(GetMountState() & GAME_TAD ) ? "DSIWARE" : "UNK", drvname[i]);
else if (*(drvnum[i]) == 'C') // Game cart handling
snprintf(entry->name, 32, "[%s] %s (%s)", drvnum[i], drvname[i], carttype);
else if (*(drvnum[i]) == '0') // SD card handling
snprintf(entry->name, 32, "[%s] %s (%s)", drvnum[i], drvname[i], sdlabel);
else snprintf(entry->name, 32, "[%s] %s", drvnum[i], drvname[i]);

View File

@ -70,3 +70,13 @@ int ReadVCartFile(const VirtualFile* vfile, void* buffer, u64 offset, u64 count)
u64 GetVCartDriveSize(void) {
return cart_init ? cdata->cart_size : 0;
}
void GetVCartTypeString(char* typestr) {
// typestr needs to be at least 11 + 1 chars big
if (!cart_init || !cdata) sprintf(typestr, "EMPTY");
else sprintf(typestr, "%s%08lX",
(cdata->cart_type & CART_CTR) ? "CTR" :
(cdata->cart_type & CART_TWL) ? "TWL" :
(cdata->cart_type & CART_NTR) ? "NTR" : "???",
cdata->cart_id);
}

View File

@ -8,3 +8,4 @@ bool ReadVCartDir(VirtualFile* vfile, VirtualDir* vdir);
int ReadVCartFile(const VirtualFile* vfile, void* buffer, u64 offset, u64 count);
// int WriteVCartFile(const VirtualFile* vfile, const void* buffer, u64 offset, u64 count); // no writes
u64 GetVCartDriveSize(void);
void GetVCartTypeString(char* typestr);