Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

update cdfs.irx to support browsing FreeDVDBoot disc images #72

Merged
merged 3 commits into from
Jul 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 14 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ MX4SIO ?= 0
SIO2MAN ?= 0
TTY2SIOR ?= 0
DEBUG ?= 0
LCDVD ?= LATEST#or LEGACY
# ----------------------------- #
.SILENT:

Expand All @@ -33,10 +34,10 @@ EE_OBJS = main.o config.o elf.o draw.o loader_elf.o filer.o \
hdd.o hdl_rpc.o hdl_info_irx.o editor.o timer.o jpgviewer.o icon.o lang.o \
font_uLE.o makeicon.o chkesr.o allowdvdv_irx.o

EE_INCS := -I$(PS2DEV)/gsKit/include -I$(PS2SDK)/ports/include -Iiop/oldlibs/libcdvd/ee -Iinclude
EE_INCS := -I$(PS2DEV)/gsKit/include -I$(PS2SDK)/ports/include -Iinclude

EE_LDFLAGS := -L$(PS2DEV)/gsKit/lib -L$(PS2SDK)/ports/lib -Liop/oldlibs/libcdvd/lib -s
EE_LIBS = -lgskit -ldmakit -ljpeg -lmc -lhdd -lcdvdfs -lkbd -lmf \
EE_LIBS = -lgskit -ldmakit -ljpeg -lmc -lhdd -lkbd -lmf \
-lcdvd -lc -lfileXio -lpatches -lpoweroff -ldebug
EE_CFLAGS := -mgpopt -G10240 -G0 -DNEWLIB_PORT_AWARE -D_EE

Expand All @@ -48,6 +49,17 @@ ifeq ($(SMB),1)
EE_CFLAGS += -DSMB
endif

ifeq ($(LCDVD),LEGACY)
$(info -- Building with legacy libcdvd)
EE_CFLAGS += -DLIBCDVD_LEGACY
CDVD_SOURCE = iop/cdvd.irx
else
EE_INCS += -Iiop/oldlibs/libcdvd/ee
EE_LIBS += -lcdvdfs
EE_CFLAGS += -DLIBCDVD_LATEST
CDVD_SOURCE = iop/__precompiled/cdfs.irx
endif

ifeq ($(XFROM),1)
HAS_XFROM = -XFROM
EE_CFLAGS += -DXFROM
Expand Down
5 changes: 4 additions & 1 deletion embed.make
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ else # if we have mx4sio use newer IRX to avoid deadlocks when opening common me
SIO2MAN_SOURCE = iop/__precompiled/sio2man.irx
endif



#---{ MC }---#
$(EE_ASM_DIR)mcman_irx.s: $(MCMAN_SOURCE) | $(EE_ASM_DIR)
$(BIN2S) $< $@ mcman_irx
Expand Down Expand Up @@ -47,8 +49,9 @@ endif
iop/cdvd.irx: iop/oldlibs/libcdvd
$(MAKE) -C $<

$(EE_ASM_DIR)cdvd_irx.s: iop/cdvd.irx | $(EE_ASM_DIR)
$(EE_ASM_DIR)cdvd_irx.s: $(CDVD_SOURCE) | $(EE_ASM_DIR)
$(BIN2S) $< $@ cdvd_irx
$(MAKE) -C iop/oldlibs/libcdvd

$(EE_ASM_DIR)poweroff_irx.s: $(PS2SDK)/iop/irx/poweroff.irx | $(EE_ASM_DIR)
$(BIN2S) $< $@ poweroff_irx
Expand Down
13 changes: 13 additions & 0 deletions include/cdvd_macro.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#ifndef __CDVD_COMPAT_MACRO
#define __CDVD_COMPAT_MACRO

#ifdef LIBCDVD_LEGACY
#define CDVD_INIT() CDVD_Init()
#define CDVD_STOP() CDVD_Stop()
#define CDVD_DISKREADY(x) CDVD_DiskReady(x)
#else
#define CDVD_INIT() // does not exist on sdk libcdvd
#define CDVD_STOP() sceCdStop()
#define CDVD_DISKREADY(x) sceCdDiskReady(x)
#endif
#endif
1 change: 1 addition & 0 deletions include/launchelf.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
#include <floatlib.h>
#include <usbhdfsd-common.h>
#include "hdl_rpc.h"
#include "cdvd_macro.h"
#include "iop/ds34usb/ee/libds34usb.h"
#include "iop/ds34bt/ee/libds34bt.h"

Expand Down
49 changes: 49 additions & 0 deletions include/snippets/readCD.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
#ifndef LIBCDVD_LEGACY
#error LIBCDVD_LEGACY not defined, but legacy readCD() included
#endif
int readCD(const char *path, FILEINFO *info, int max)
{
static struct TocEntry TocEntryList[MAX_ENTRY];
char dir[MAX_PATH];
int i, j, n;
u64 wait_start;

if (sceCdGetDiskType() <= SCECdUNKNOWN) {
wait_start = Timer();
while ((Timer() < wait_start + 500) && !uLE_cdDiscValid()) {
if (cdmode == SCECdNODISC)
return 0;
}
if (cdmode == SCECdNODISC)
return 0;
if ((cdmode < SCECdPSCD) || (cdmode > SCECdPS2DVD)) {
uLE_cdStop();
return 0;
}
}

strcpy(dir, &path[5]);
CDVD_FlushCache();
n = CDVD_GetDir(dir, NULL, CDVD_GET_FILES_AND_DIRS, TocEntryList, MAX_ENTRY, dir);

for (i = j = 0; i < n; i++) {
if (TocEntryList[i].fileProperties & 0x02 &&
(!strcmp(TocEntryList[i].filename, ".") ||
!strcmp(TocEntryList[i].filename, "..")))
continue; //Skip pseudopaths "." and ".."
strcpy(info[j].name, TocEntryList[i].filename);
clear_mcTable(&info[j].stats);
if (TocEntryList[i].fileProperties & 0x02) {
info[j].stats.AttrFile = MC_ATTR_norm_folder;
} else {
info[j].stats.AttrFile = MC_ATTR_norm_file;
info[j].stats.FileSizeByte = TocEntryList[i].fileSize;
info[j].stats.Reserve2 = 0; //Assuming a CD can't have a single 4GB file
}
j++;
}

size_valid = 1;

return j;
}
Binary file added iop/__precompiled/cdfs.irx
Binary file not shown.
2 changes: 1 addition & 1 deletion src/draw.c
Original file line number Diff line number Diff line change
Expand Up @@ -809,7 +809,7 @@ void loadSkin(int Picture, char *Path, int ThumbNum)
fclose(File);
} /* end if( File != NULL ) */
if (!strncmp(tmpPath, "cdfs", 4)) {
CDVD_Stop();
CDVD_STOP();
sceCdSync(0);
}
if (!strncmp(tmpPath, "hdd0:/", 6))
Expand Down
62 changes: 34 additions & 28 deletions src/filer.c
Original file line number Diff line number Diff line change
Expand Up @@ -693,55 +693,61 @@
//------------------------------
//endfunc readMC
//--------------------------------------------------------------
#ifndef LIBCDVD_LEGACY
int readCD(const char *path, FILEINFO *info, int max)
{
static struct TocEntry TocEntryList[MAX_ENTRY];
char dir[MAX_PATH];
int i, j, n;
iox_dirent_t record;
int n = 0, dd = -1;
u64 wait_start;

if (sceCdGetDiskType() <= SCECdUNKNOWN) {
wait_start = Timer();
while ((Timer() < wait_start + 500) && !uLE_cdDiscValid()) {
if (cdmode == SCECdNODISC)
return 0;
}
if (cdmode == SCECdNODISC)
return 0;
if ((cdmode < SCECdPSCD) || (cdmode > SCECdPS2DVD)) {
uLE_cdStop();
return 0;
}
}

strcpy(dir, &path[5]);
CDVD_FlushCache();
n = CDVD_GetDir(dir, NULL, CDVD_GET_FILES_AND_DIRS, TocEntryList, MAX_ENTRY, dir);

for (i = j = 0; i < n; i++) {
if (TocEntryList[i].fileProperties & 0x02 &&
(!strcmp(TocEntryList[i].filename, ".") ||
!strcmp(TocEntryList[i].filename, "..")))
continue; //Skip pseudopaths "." and ".."
strcpy(info[j].name, TocEntryList[i].filename);
clear_mcTable(&info[j].stats);
if (TocEntryList[i].fileProperties & 0x02) {
info[j].stats.AttrFile = MC_ATTR_norm_folder;
} else {
info[j].stats.AttrFile = MC_ATTR_norm_file;
info[j].stats.FileSizeByte = TocEntryList[i].fileSize;
info[j].stats.Reserve2 = 0; //Assuming a CD can't have a single 4GB file
}
j++;
}

if ((dd = fileXioDopen(path)) < 0)
goto exit; //exit if error opening directory
while (fileXioDread(dd, &record) > 0) {
if ((FIO_S_ISDIR(record.stat.mode)) && (!strcmp(record.name, ".") || !strcmp(record.name, "..")))
continue; //Skip entry if pseudo-folder "." or ".."
strcpy(info[n].name, record.name);
clear_mcTable(&info[n].stats);
if (FIO_S_ISDIR(record.stat.mode)) {
info[n].stats.AttrFile = MC_ATTR_norm_folder;
} else if (FIO_S_ISREG(record.stat.mode)) {
info[n].stats.AttrFile = MC_ATTR_norm_file;
info[n].stats.FileSizeByte = record.stat.size;
info[n].stats.Reserve2 = 0;
} else
continue; //Skip entry which is neither a file nor a folder
strncpy((char *)info[n].stats.EntryName, info[n].name, 32);
memcpy((void *)&info[n].stats._Create, record.stat.ctime, 8);
memcpy((void *)&info[n].stats._Modify, record.stat.mtime, 8);
n++;
if (n == max)
break;
} //ends while
size_valid = 1;

return j;
exit:
if (dd >= 0)
fileXioDclose(dd); //Close directory if opened above
return n;
}
#else
#include "snippets/readCD.h"
#endif
//------------------------------
//endfunc readCD
//--------------------------------------------------------------

Check notice on line 750 in src/filer.c

View check run for this annotation

codefactor.io / CodeFactor

src/filer.c#L697-L750

Complex Method
void setPartyList(void)
{
iox_dirent_t dirEnt;
Expand Down Expand Up @@ -884,8 +890,8 @@
pathSep = strchr(uLE_path, '/');

if (!strncmp(uLE_path, "cdfs", 4)) { //if using CD or DVD disc path
CDVD_FlushCache();
CDVD_DiskReady(0);
// TODO: Flush CDFS cache
CDVD_DISKREADY(0);
//end of clause for using a CD or DVD path

} else if (!strncmp(uLE_path, "mass", 4)) { //if using USB mass: path
Expand Down
2 changes: 1 addition & 1 deletion src/jpgviewer.c
Original file line number Diff line number Diff line change
Expand Up @@ -604,7 +604,7 @@ void JpgViewer(char *file)
jpg_browser_up = FALSE;
} //ends if(jpg_browser_cd)
if (!strncmp(path, "cdfs", 4)) {
CDVD_Stop();
CDVD_STOP();
}
if (top > jpg_browser_nfiles - rows)
top = jpg_browser_nfiles - rows;
Expand Down
14 changes: 7 additions & 7 deletions src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -1174,10 +1174,10 @@ static void loadCdModules(void)
int ret, id;

if (!have_cdvd) {
sceCdInit(SCECdINoD); // SCECdINoD init without check for a disc. Reduces risk of a lockup if the drive is in a erroneous state.
id = SifExecModuleBuffer(cdvd_irx, size_cdvd_irx, 0, NULL, &ret);
CDVD_INIT();
DPRINTF(" [CDVD]: id=%d, ret=%d\n", id, ret);
sceCdInit(SCECdINoD); // SCECdINoD init without check for a disc. Reduces risk of a lockup if the drive is in a erroneous state.
CDVD_Init();
have_cdvd = 1;
}
}
Expand Down Expand Up @@ -1229,7 +1229,7 @@ int uLE_cdStop(void)
uLE_cdmode = (cdmode == SCECdPS2DVD) ? SCECdESRDVD_1 : SCECdESRDVD_0;
}
}
CDVD_Stop();
CDVD_STOP();
sceCdSync(0);
}
return uLE_cdmode;
Expand Down Expand Up @@ -1277,8 +1277,8 @@ static void getExternalFilePath(const char *argPath, char *filePath)
#endif
} else if (!strncmp(argPath, "cdfs", 4)) {
strcpy(filePath, argPath);
CDVD_FlushCache();
CDVD_DiskReady(0);
// TODO: Flush CDFS cache
CDVD_DISKREADY(0);
} else {
genFixPath(argPath, filePath);
}
Expand Down Expand Up @@ -2348,8 +2348,8 @@ static void Execute(char *pathin)
Show_build_info();
return;
} else if (!strncmp(path, "cdfs", 4)) {
CDVD_FlushCache();
CDVD_DiskReady(0);
// TODO: Flush CDFS cache
CDVD_DISKREADY(0);
party[0] = 0;
goto CheckELF_path;
} else if (!strncmp(path, "rom", 3)) {
Expand Down
Loading