Skip to content

Commit

Permalink
use sce libcdvd only
Browse files Browse the repository at this point in the history
israpps committed Jul 11, 2024
1 parent c608306 commit 41ca9d4
Showing 9 changed files with 119 additions and 41 deletions.
15 changes: 13 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
@@ -33,10 +33,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

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

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

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

CDVD_SOURCE = iop/__precompiled/cdfs.irx
#iop/cdvd.irx


#---{ MC }---#
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
@@ -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"

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;
}
2 changes: 1 addition & 1 deletion src/draw.c
Original file line number Diff line number Diff line change
@@ -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))
62 changes: 34 additions & 28 deletions src/filer.c
Original file line number Diff line number Diff line change
@@ -693,11 +693,11 @@ int readMC(const char *path, FILEINFO *info, int max)
//------------------------------
//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) {
@@ -713,32 +713,38 @@ int readCD(const char *path, FILEINFO *info, int max)
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
//--------------------------------------------------------------
@@ -884,8 +890,8 @@ int genFixPath(const char *inp_path, char *gen_path)
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
2 changes: 1 addition & 1 deletion src/jpgviewer.c
Original file line number Diff line number Diff line change
@@ -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;
14 changes: 7 additions & 7 deletions src/main.c
Original file line number Diff line number Diff line change
@@ -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;
}
}
@@ -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;
@@ -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);
}
@@ -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)) {

0 comments on commit 41ca9d4

Please sign in to comment.