Skip to content

Commit

Permalink
- Recognize .fdi files on FlippyDrive.
Browse files Browse the repository at this point in the history
  • Loading branch information
Extrems committed Dec 9, 2024
1 parent 6eb1211 commit edcb2f7
Show file tree
Hide file tree
Showing 9 changed files with 32 additions and 17 deletions.
4 changes: 2 additions & 2 deletions cube/swiss/include/util.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@
#define RECENT_ERR_DEV_MISSING 2

char *endsWith(char *str, char *end);
bool canLoadFileType(char *filename);
bool checkExtension(char *filename);
bool canLoadFileType(char *filename, char **extraExtensions);
bool checkExtension(char *filename, char **extraExtensions);
char *getRelativeName(char *path);
char *getRelativePath(char *path, char *parentPath);
bool getParentPath(char *path, char *parentPath);
Expand Down
1 change: 1 addition & 0 deletions cube/swiss/source/devices/deviceHandler.h
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,7 @@ struct DEVICEHANDLER_STRUCT {
const char* deviceName;
const char* deviceDescription;
textureImage deviceTexture;
char** extraExtensions;
u32 features;
u32 quirks;
u32 emulable;
Expand Down
2 changes: 1 addition & 1 deletion cube/swiss/source/devices/filemeta.c
Original file line number Diff line number Diff line change
Expand Up @@ -277,7 +277,7 @@ void populate_meta(file_handle *f) {
}
}
}
else if(endsWith(f->name,".gcm") || endsWith(f->name,".iso")) {
else if(endsWith(f->name,".fdi") || endsWith(f->name,".gcm") || endsWith(f->name,".iso")) {
DiskHeader *diskHeader = get_gcm_header(f);
if(diskHeader) {
u32 bannerOffset = 0, bannerSize = f->size;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ s64 deviceHandler_Flippy_seekFile(file_handle* file, s64 where, u32 type) {
}

static u32 defaultFlags(file_handle* file) {
if(endsWith(file->name,".gcm") || endsWith(file->name,".iso") || endsWith(file->name,".tgc"))
if(endsWith(file->name,".fdi") || endsWith(file->name,".gcm") || endsWith(file->name,".iso") || endsWith(file->name,".tgc"))
return FLIPPY_FLAG_DISABLE_DVDSPEED;
return FLIPPY_FLAG_DEFAULT;
}
Expand Down Expand Up @@ -322,6 +322,11 @@ bool deviceHandler_Flippy_test() {
}
}
case 0x20220426:
flippyversion *version = (flippyversion *)driveInfo.pad;

if (FLIPPY_VERSION(version->major, version->minor, version->build) < FLIPPY_VERSION(1,3,1))
__device_flippy.extraExtensions = NULL;

swissSettings.hasFlippyDrive = 1;
return true;
}
Expand Down Expand Up @@ -355,6 +360,7 @@ DEVICEHANDLER_INTERFACE __device_flippy = {
.deviceName = "FlippyDrive",
.deviceDescription = "Supported File System(s): FAT16, FAT32, exFAT",
.deviceTexture = {TEX_FLIPPY, 102, 56, 104, 58},
.extraExtensions = (char*[]){".fdi", NULL},
.features = FEAT_READ|FEAT_WRITE|FEAT_BOOT_GCM|FEAT_BOOT_DEVICE|FEAT_CONFIG_DEVICE|FEAT_AUTOLOAD_DOL|FEAT_THREAD_SAFE|FEAT_HYPERVISOR|FEAT_PATCHES|FEAT_AUDIO_STREAMING,
.quirks = QUIRK_NO_DEINIT,
.emulable = EMU_READ|EMU_READ_SPEED|EMU_MEMCARD,
Expand Down
2 changes: 1 addition & 1 deletion cube/swiss/source/files.c
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ int sortFiles(file_handle* dir, int numFiles, file_handle*** sortedDir)
if((dir[j].fileAttrib & ATTRIB_HIDDEN) && !swissSettings.showHiddenFiles) {
continue;
}
if(dir[j].fileType == IS_FILE && !checkExtension(dir[j].name)) {
if(dir[j].fileType == IS_FILE && !checkExtension(dir[j].name, devices[DEVICE_CUR]->extraExtensions)) {
continue;
}
(*sortedDir)[i++] = &dir[j];
Expand Down
1 change: 1 addition & 0 deletions cube/swiss/source/gui/FrameBufferMagic.c
Original file line number Diff line number Diff line change
Expand Up @@ -1335,6 +1335,7 @@ uiDrawObj_t* DrawFileBrowserButton(int x1, int y1, int x2, int y2, const char *m
if((end = endsWith(start,".dol"))
|| (end = endsWith(start,".dol+cli"))
|| (end = endsWith(start,".elf"))
|| (end = endsWith(start,".fdi"))
|| (end = endsWith(start,".gci"))
|| (end = endsWith(start,".gcm.gcm"))
|| (end = endsWith(start,".gcm"))
Expand Down
2 changes: 1 addition & 1 deletion cube/swiss/source/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,7 @@ int main(int argc, char *argv[])
wait_press_A();
DrawDispose(msgBox);
}
else if(FLIPPY_VERSION(version->major, version->minor, version->build) < FLIPPY_VERSION(1,3,0)) {
else if(FLIPPY_VERSION(version->major, version->minor, version->build) < FLIPPY_VERSION(1,3,2)) {
uiDrawObj_t *msgBox = DrawPublish(DrawMessageBox(D_INFO, "A firmware update is available.\nflippydrive.com/updates"));
wait_press_A();
DrawDispose(msgBox);
Expand Down
8 changes: 4 additions & 4 deletions cube/swiss/source/swiss.c
Original file line number Diff line number Diff line change
Expand Up @@ -359,7 +359,7 @@ uiDrawObj_t* renderFileBrowser(file_handle** directory, int num_files, uiDrawObj
}
else if(directory[curSelection]->fileType==IS_FILE) {
memcpy(&curFile, directory[curSelection], sizeof(file_handle));
if(canLoadFileType(&curFile.name[0])) {
if(canLoadFileType(curFile.name, devices[DEVICE_CUR]->extraExtensions)) {
meta_thread_stop();
load_file();
}
Expand Down Expand Up @@ -595,7 +595,7 @@ uiDrawObj_t* renderFileCarousel(file_handle** directory, int num_files, uiDrawOb
}
else if(directory[curSelection]->fileType==IS_FILE){
memcpy(&curFile, directory[curSelection], sizeof(file_handle));
if(canLoadFileType(&curFile.name[0])) {
if(canLoadFileType(curFile.name, devices[DEVICE_CUR]->extraExtensions)) {
meta_thread_stop();
load_file();
}
Expand Down Expand Up @@ -769,7 +769,7 @@ uiDrawObj_t* renderFileFullwidth(file_handle** directory, int num_files, uiDrawO
}
else if(directory[curSelection]->fileType==IS_FILE) {
memcpy(&curFile, directory[curSelection], sizeof(file_handle));
if(canLoadFileType(&curFile.name[0])) {
if(canLoadFileType(curFile.name, devices[DEVICE_CUR]->extraExtensions)) {
meta_thread_stop();
load_file();
}
Expand Down Expand Up @@ -2265,7 +2265,7 @@ void load_file()
DrawDispose(msgBox);
return;
}
else if(endsWith(fileName,".gcm") || endsWith(fileName,".iso") || endsWith(fileName,".tgc")) {
else if(endsWith(fileName,".fdi") || endsWith(fileName,".gcm") || endsWith(fileName,".iso") || endsWith(fileName,".tgc")) {
if(devices[DEVICE_CUR]->features & FEAT_BOOT_GCM) {
load_game();
memset(&GCMDisk, 0, sizeof(DiskHeader));
Expand Down
21 changes: 14 additions & 7 deletions cube/swiss/source/util.c
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@


/* File name helper functions */
char *knownExtensions[] = {".bin", ".dol", ".dol+cli", ".elf", ".fpkg", ".fzn", ".gcm", ".gcz", ".iso", ".mp3", ".rvz", ".tgc"};
char *knownExtensions[] = {".bin", ".dol", ".dol+cli", ".elf", ".fpkg", ".fzn", ".gcm", ".gcz", ".iso", ".mp3", ".rvz", ".tgc", NULL};

char *endsWith(char *str, char *end) {
size_t len_str = strlen(str);
Expand All @@ -22,20 +22,27 @@ char *endsWith(char *str, char *end) {
return !strcasecmp(str, end) ? str : NULL;
}

bool canLoadFileType(char *filename) {
int i;
for(i = 0; i < sizeof(knownExtensions)/sizeof(char*); i++) {
if(endsWith(filename, knownExtensions[i])) {
bool canLoadFileType(char *filename, char **extraExtensions) {
char *ext;
if(extraExtensions) {
for(ext = *extraExtensions; ext; ext++) {
if(endsWith(filename, ext)) {
return !is_rom_name(filename);
}
}
}
for(ext = *knownExtensions; ext; ext++) {
if(endsWith(filename, ext)) {
return !is_rom_name(filename);
}
}
return false;
}

bool checkExtension(char *filename) {
bool checkExtension(char *filename, char **extraExtensions) {
if(!swissSettings.hideUnknownFileTypes)
return true;
return canLoadFileType(filename);
return canLoadFileType(filename, extraExtensions);
}

char *getRelativeName(char *path)
Expand Down

0 comments on commit edcb2f7

Please sign in to comment.