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

CDFS: DVD video support #130

Merged
merged 2 commits into from
Jun 28, 2020
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
61 changes: 47 additions & 14 deletions iop/cdvd/cdfs/src/cdfs_iop.c
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,7 @@ enum PathMatch {
static struct CacheInfoDir cacheInfoDir;
static struct CDVolDesc cdVolDesc;
static sceCdRMode cdReadMode;
static u8 dvdvBuffer[2064];

/***********************************************
* *
Expand Down Expand Up @@ -161,6 +162,7 @@ static int isValidDisc(void) {
case SCECdPS2CD:
case SCECdPS2CDDA:
case SCECdPS2DVD:
case SCECdDVDV:
result = 1;
break;
default:
Expand Down Expand Up @@ -385,7 +387,7 @@ static int cdfs_getVolumeDescriptor(void) {
DPRINTF("cdfs_getVolumeDescriptor called\n\n");

for (volDescSector = 16; volDescSector < 20; volDescSector++) {
cdfs_readSect(volDescSector, 1, &localVolDesc);
cdfs_readSect(volDescSector, 1, (u8*)&localVolDesc);

// If this is still a volume Descriptor
if (strncmp(localVolDesc.volID, "CD001", 5) == 0) {
Expand Down Expand Up @@ -810,7 +812,9 @@ int cdfs_findfile(const char *fname, struct TocEntry *tocEntry) {
* Optimised CD Read *
********************/

int cdfs_readSect(u32 lsn, u32 sectors, void *buf) {
int cdfs_readSect(u32 lsn, u32 sectors, u8 *buf) {
u32 i;
u32 consecutive_sectors = (sectors > 2) ? (sectors * 2048) / 2064 : 0;
int retry;
int result = 0;
cdReadMode.trycount = 32;
Expand All @@ -826,21 +830,50 @@ int cdfs_readSect(u32 lsn, u32 sectors, void *buf) {

sceCdDiskReady(0);

if (!sceCdRead(lsn, sectors, buf, &cdReadMode)) {
// Failed to read
if (retry == 31) {
// Still failed after last retry
memset(buf, 0, (sectors << 11));
// printf("Couldn't Read from file for some reason\n");
return FALSE; // error
if (sceCdGetDiskType() == SCECdDVDV)
{
if (consecutive_sectors > 0)
{
result = !sceCdReadDVDV(lsn, consecutive_sectors, buf, &cdReadMode);
if (result == 0)
{
sceCdSync(0);
result = sceCdGetError();
}
if (result != 0)
{
continue;
}
}
for (i = 0; i < consecutive_sectors; i += 1)
{
memmove(buf + (2048 * i), buf + (2064 * i) + 12, 2048);
}
for (i = consecutive_sectors; i < sectors; i += 1)
{
result = !sceCdReadDVDV(lsn + i, 1, dvdvBuffer, &cdReadMode);
if (result == 0)
{
sceCdSync(0);
result = sceCdGetError();
}
if (result != 0)
{
break;
}
memcpy(buf + (2048 * i), dvdvBuffer + 12, 2048);
}
}
else
{
result = !sceCdRead(lsn, sectors, buf, &cdReadMode);
if (result == 0)
{
sceCdSync(0);
result = sceCdGetError();
}
} else {
// Read okay
sceCdSync(0);
break;
}

result = sceCdGetError();
if (result == 0)
break;
}
Expand Down
2 changes: 1 addition & 1 deletion iop/cdvd/cdfs/src/cdfs_iop.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ int cdfs_prepare(void);
int cdfs_start(void);
int cdfs_finish(void);
int cdfs_findfile(const char *fname, struct TocEntry *tocEntry);
int cdfs_readSect(u32 lsn, u32 sectors, void *buf);
int cdfs_readSect(u32 lsn, u32 sectors, u8 *buf);
int cdfs_getDir(const char *pathname, const char *extensions, enum CDFS_getMode getMode, struct TocEntry tocEntry[], unsigned int req_entries);

#endif // _CDFS_H
2 changes: 2 additions & 0 deletions iop/cdvd/cdfs/src/imports.lst
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ cdvdman_IMPORTS_start
I_sceCdInit
I_sceCdGetError
I_sceCdRead
I_sceCdReadDVDV
I_sceCdStop
I_sceCdSync
I_sceCdDiskReady
Expand All @@ -24,6 +25,7 @@ I_strcat
I_strlen
I_memset
I_memcpy
I_memmove
sysclib_IMPORTS_end

stdio_IMPORTS_start
Expand Down