Skip to content

Commit

Permalink
- Fix it for real, kind of.
Browse files Browse the repository at this point in the history
- Only display DVD game entry in root directory.
  • Loading branch information
Extrems committed Dec 22, 2023
1 parent e06a0de commit acea68a
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 22 deletions.
5 changes: 2 additions & 3 deletions cube/swiss/source/devices/dvd/deviceHandler-DVD.c
Original file line number Diff line number Diff line change
Expand Up @@ -349,14 +349,13 @@ s32 deviceHandler_DVD_readDir(file_handle* ffile, file_handle** dir, u32 type){
concat_path((*dir)[0].name, ffile->name, "..");
(*dir)[0].fileAttrib = IS_SPECIAL;
}

if(dvdDiscTypeInt == ISO9660_GAMECUBE_DISC) {
else if(dvdDiscTypeInt == ISO9660_GAMECUBE_DISC) {
DiskHeader *diskHeader = get_gcm_header(ffile);
if(!diskHeader) return -1;

*dir = reallocarray(*dir, num_entries + 1, sizeof(file_handle));
memset(&(*dir)[num_entries], 0, sizeof(file_handle));
concatf_path((*dir)[num_entries].name, initial_DVD.name, "%.64s.gcm", diskHeader->GameName);
concatf_path((*dir)[num_entries].name, ffile->name, "%.64s.gcm", diskHeader->GameName);
(*dir)[num_entries].fileBase = 0;
(*dir)[num_entries].offset = 0;
(*dir)[num_entries].size = DISC_SIZE;
Expand Down
31 changes: 14 additions & 17 deletions cube/swiss/source/gcm.c
Original file line number Diff line number Diff line change
Expand Up @@ -704,7 +704,7 @@ int read_fst(file_handle *file, file_handle** dir, u64 *usedSpace) {
print_gecko("Read dir for directory: %s\r\n",file->name);
char filename[PATHNAME_MAX];
int numFiles = 1, idx = 0;
int isRoot = !strcmp((const char*)&file->name[0], "dvd:/");
int isRoot = file->fileBase == 0;

DiskHeader *diskHeader = get_gcm_header(file);
if(!diskHeader) return -1;
Expand All @@ -714,16 +714,18 @@ int read_fst(file_handle *file, file_handle** dir, u64 *usedSpace) {

// Get the space taken up by this disc
if(usedSpace) *usedSpace = calc_fst_entries_size(FST);

// Add the disc itself as a "file"
*dir = calloc(numFiles, sizeof(file_handle));
concatf_path((*dir)[idx].name, __device_dvd.initial->name, "%.64s.gcm", diskHeader->GameName);
(*dir)[idx].fileBase = 0;
(*dir)[idx].offset = 0;
(*dir)[idx].size = DISC_SIZE;
(*dir)[idx].fileAttrib = IS_FILE;
(*dir)[idx].meta = 0;
idx++;

if(isRoot) {
// Add the disc itself as a "file"
*dir = calloc(numFiles, sizeof(file_handle));
concatf_path((*dir)[idx].name, file->name, "%.64s.gcm", diskHeader->GameName);
(*dir)[idx].fileBase = 0;
(*dir)[idx].offset = 0;
(*dir)[idx].size = DISC_SIZE;
(*dir)[idx].fileAttrib = IS_FILE;
(*dir)[idx].meta = 0;
idx++;
}

u32 entries=*(unsigned int*)&FST[8];
u32 string_table_offset=FST_ENTRY_SIZE*entries;
Expand All @@ -732,19 +734,14 @@ int read_fst(file_handle *file, file_handle** dir, u64 *usedSpace) {
// Go through the FST and find our DIR (or ROOT)
int parent_dir_offset = (u32)file->fileBase;
int dir_end_offset = isRoot ? *(u32*)&FST[8] : 0;
isRoot = parent_dir_offset==0;

u32 filename_offset=((*(u32*)&FST[parent_dir_offset*0x0C]) & 0x00FFFFFF);
concat_path(filename, file->name, &FST[string_table_offset+filename_offset]);
dir_end_offset = *(u32*)&FST[(parent_dir_offset*0x0C) + 8];

if(!isRoot) {
// Add a special ".." dir which will take us back up a dir
if(idx == numFiles){
++numFiles;
*dir = reallocarray(*dir, numFiles, sizeof(file_handle));
}
memset(&(*dir)[idx], 0, sizeof(file_handle));
*dir = calloc(numFiles, sizeof(file_handle));
concat_path((*dir)[idx].name, file->name, "..");
(*dir)[idx].fileBase = *(u32*)&FST[(parent_dir_offset*0x0C)+4];
(*dir)[idx].offset = 0;
Expand Down
4 changes: 2 additions & 2 deletions cube/swiss/source/swiss.c
Original file line number Diff line number Diff line change
Expand Up @@ -400,7 +400,7 @@ uiDrawObj_t* renderFileBrowser(file_handle** directory, int num_files, uiDrawObj
}
if(padsButtonsHeld() & PAD_BUTTON_X) {
memcpy(&curFile, &curDir, sizeof(file_handle));
curDir.fileBase = (*directory)[curSelection].fileBase;
curDir.fileBase = (*directory)[0].fileBase;
needsDeviceChange = upToParent(&curDir);
needsRefresh=1;
while(padsButtonsHeld() & PAD_BUTTON_X) VIDEO_WaitVSync();
Expand Down Expand Up @@ -619,7 +619,7 @@ uiDrawObj_t* renderFileCarousel(file_handle** directory, int num_files, uiDrawOb
}
if(padsButtonsHeld() & PAD_BUTTON_X) {
memcpy(&curFile, &curDir, sizeof(file_handle));
curDir.fileBase = (*directory)[curSelection].fileBase;
curDir.fileBase = (*directory)[0].fileBase;
needsDeviceChange = upToParent(&curDir);
needsRefresh=1;
while(padsButtonsHeld() & PAD_BUTTON_X) VIDEO_WaitVSync();
Expand Down

0 comments on commit acea68a

Please sign in to comment.