Skip to content

Commit

Permalink
cdvdman: detect cd/dvd in cdvdman (instead of loader)
Browse files Browse the repository at this point in the history
  • Loading branch information
rickgaiser committed Mar 7, 2024
1 parent 4fe9625 commit 3caaf54
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
4 changes: 1 addition & 3 deletions ee/loader/src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -1152,11 +1152,9 @@ int main(int argc, char *argv[])
return -1;
}

if (eMediaType == SCECdNODISC)
eMediaType = iso_size <= (333000 * 2048) ? SCECdPS2CD : SCECdPS2DVD;

const char *sMT;
switch (eMediaType) {
case SCECdNODISC: sMT = "ps2 cd/dvd auto detect"; break;
case SCECdPS2CDDA: sMT = "ps2 cdda"; break;
case SCECdPS2CD: sMT = "ps2 cd"; break;
case SCECdDVDV: sMT = "dvd video"; break;
Expand Down
8 changes: 6 additions & 2 deletions iop/cdvdman_emu/src/searchfile.c
Original file line number Diff line number Diff line change
Expand Up @@ -233,12 +233,16 @@ void cdvdman_searchfile_init(void)
// Number of sectors on first layer
u32 lsn0 = *(u32 *)&cdvdman_buf[0x50];

// Auto detect CD/DVD based on number of sectors
if (cdvdman_settings.media == SCECdNODISC)
cdvdman_settings.media = lsn0 <= 333000 ? SCECdPS2CD : SCECdPS2DVD;

// Read the volume descriptor of second layer
sceCdRead_internal(lsn0, 1, cdvdman_buf, NULL, ECS_SEARCHFILE);
sceCdSync(0);

if ((sceCdGetError() == SCECdErNO) && (cdvdman_buf[0x00] == 1) && (!strncmp(&((char*)cdvdman_buf)[0x01], "CD001", 5))) {
printf("%s Dual Layer DVD detected @ lsn = %d\n", __FUNCTION__, lsn0 - 16);
M_DEBUG("%s: Dual Layer DVD detected @ lsn = %d\n", __FUNCTION__, lsn0 - 16);

cdvdman_settings.layer1_start = lsn0 - 16;

Expand All @@ -247,6 +251,6 @@ void cdvdman_searchfile_init(void)
layer_info[1].rootDirtocLength = tocEntryPointer->fileSize;
}
else {
printf("%s Single Layer CD/DVD detected\n", __FUNCTION__);
M_DEBUG("%s: Single Layer %s detected\n", __FUNCTION__, cdvdman_settings.media == SCECdPS2CD ? "CD" : "DVD");
}
}

0 comments on commit 3caaf54

Please sign in to comment.