Skip to content

Commit

Permalink
Fix cdvd support
Browse files Browse the repository at this point in the history
  • Loading branch information
infval authored and AKuHAK committed Apr 27, 2018
1 parent 6255334 commit 23395b7
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 10 deletions.
28 changes: 18 additions & 10 deletions src/drivers/ps2/browser.c
Original file line number Diff line number Diff line change
Expand Up @@ -147,15 +147,15 @@ int RomBrowserInput(int files_too, int inside_menu)

#ifdef CDSUPPORT
int listcdvd(const char *path, entries *FileEntry) {
static struct TocEntry TocEntryList[2048];
static struct TocEntry TocEntryList[FILEENTRY_SIZE];
char dir[1025];
int i, n, t;

strcpy(dir, &path[5]);
// Directories first...

CDVD_FlushCache();
n = CDVD_GetDir(dir, NULL, CDVD_GET_DIRS_ONLY, TocEntryList, 2048, dir);
n = CDVD_GetDir(dir, NULL, CDVD_GET_DIRS_ONLY, TocEntryList, FILEENTRY_SIZE, dir);

strcpy(FileEntry[0].filename, "..");
strcpy(FileEntry[0].displayname, "..");
Expand All @@ -173,15 +173,18 @@ int listcdvd(const char *path, entries *FileEntry) {
strzncpy(FileEntry[t].displayname, FileEntry[t].filename, 63);
t++;

if (t >= 2046) {
if (t >= FILEENTRY_SIZE - 2) {
break;
}
}
}

qsort(FileEntry, t, sizeof(entries), comp_entries_by_filename);
first_file_index = t;

// Now files only

CDVD_FlushCache();
n = CDVD_GetDir(dir, NULL, CDVD_GET_FILES_ONLY, TocEntryList, 2048, dir);
n = CDVD_GetDir(dir, NULL, CDVD_GET_FILES_ONLY, TocEntryList, FILEENTRY_SIZE, dir);

for (i = 0; i < n; i++) {
if (TocEntryList[i].fileProperties & 0x02 && (!strcmp(
Expand All @@ -194,11 +197,13 @@ int listcdvd(const char *path, entries *FileEntry) {
strzncpy(FileEntry[t].displayname, FileEntry[t].filename, 63);
t++;

if (t >= 2046) {
if (t >= FILEENTRY_SIZE - 2) {
break;
}
}

qsort(FileEntry + first_file_index, t - first_file_index, sizeof(entries), comp_entries_by_filename);

return t;
}
#endif
Expand All @@ -223,14 +228,15 @@ int listdir(char *path, entries *FileEntry, int files_too)
FileEntry[1].dircheck = 1;
FileEntry[2].dircheck = 1;
FileEntry[3].dircheck = 1;
n = 4;
#ifdef CDSUPPORT
FileEntry[4].dircheck = 1;
n = 5;
}
#ifdef CDSUPPORT
else if (!strncmp(path, "cdfs", 4)) {
n = listcdvd(path, FileEntry);
}
#endif
}
else { // It has a /
dd = fioDopen(path);
if (dd < 0) {
Expand Down Expand Up @@ -310,12 +316,14 @@ int listpfs(char *path, entries *FileEntry, int files_too)
FileEntry[2].dircheck = 1;
FileEntry[3].dircheck = 1;
n = 4;
}
#ifdef CDSUPPORT
FileEntry[4].dircheck = 1;
n = 5;
}
else if (!strncmp(path, "cdfs", 4)) {
n = listcdvd(path, FileEntry);
}
#endif
}
else {
if ((dd = fileXioDopen(path)) < 0) {
printf("Didn't open!\n");
Expand Down
2 changes: 2 additions & 0 deletions src/drivers/ps2/init.c
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,8 @@ void InitPS2()
mcInit(MC_TYPE_XMC);

#ifdef CDSUPPORT
SifExecModuleBuffer(&cdvd_irx, size_cdvd_irx, 0, NULL, NULL);

cdInit(CDVD_INIT_INIT);
printf("Failed to load module: cdInit");
CDVD_Init();
Expand Down

0 comments on commit 23395b7

Please sign in to comment.