Skip to content

Commit

Permalink
Merge pull request #1052 from AKuHAK/kr_fix
Browse files Browse the repository at this point in the history
Some fixes for semaphore PR
  • Loading branch information
rickgaiser authored Aug 11, 2023
2 parents 2123e3e + a7519fb commit ea72571
Show file tree
Hide file tree
Showing 6 changed files with 26 additions and 18 deletions.
13 changes: 7 additions & 6 deletions modules/iopcore/cdvdfsv/ncmd.c
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,8 @@ static inline void cdvd_readee(void *buf)
{ // Read Disc data to EE mem buffer
u8 curlsn_buf[16];
u32 nbytes, nsectors, sectors_to_read, size_64b, size_64bb, bytesent, temp;
int sector_size, flag_64b, fsverror;
u16 sector_size;
int flag_64b, fsverror;
void *fsvRbuf = (void *)cdvdfsv_buf;
void *eeaddr_64b, *eeaddr2_64b;
cdvdfsv_readee_t readee;
Expand All @@ -114,13 +115,13 @@ static inline void cdvd_readee(void *buf)
return;
}

sector_size = 2328;
sector_size = 2048;

if ((r->mode.datapattern & 0xff) != 1) {
if (r->mode.datapattern == SCECdSecS2328)
sector_size = 2328;
if (r->mode.datapattern == SCECdSecS2340)
sector_size = 2340;
if ((r->mode.datapattern & 0xff) != 2)
sector_size = 2048;
}


r->eeaddr1 = (void *)((u32)r->eeaddr1 & 0x1fffffff);
r->eeaddr2 = (void *)((u32)r->eeaddr2 & 0x1fffffff);
Expand Down
1 change: 1 addition & 0 deletions modules/iopcore/cdvdman/cdvdman.c
Original file line number Diff line number Diff line change
Expand Up @@ -600,6 +600,7 @@ int sceCdSC(int code, int *param)
result = 1;
break;
default:
DPRINTF("sceCdSC unknown, code=0x%X param=0x%X \n", code, *param);
result = 1; // dummy result
}

Expand Down
4 changes: 2 additions & 2 deletions modules/iopcore/cdvdman/internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -71,10 +71,10 @@ struct SteamingData
typedef struct
{
int err;
int status;
u8 status; // SCECdvdDriveState
struct SteamingData StreamingData;
int intr_ef;
int disc_type_reg;
int disc_type_reg; // SCECdvdMediaType
u32 cdread_lba;
u32 cdread_sectors;
u16 sector_size;
Expand Down
8 changes: 7 additions & 1 deletion modules/iopcore/cdvdman/ioops.c
Original file line number Diff line number Diff line change
Expand Up @@ -398,7 +398,7 @@ static int cdrom_dread(iop_file_t *f, iox_dirent_t *dirent)
DPRINTF("cdrom_dread fh->lsn=%lu\n", fh->lsn);

if ((r = sceCdRead(fh->lsn, 1, cdvdman_fs_buf, NULL)) == 1) {
// sceCdSync(0); // TODO: need to verify
sceCdSync(0);

do {
r = 0;
Expand Down Expand Up @@ -433,6 +433,8 @@ static int cdrom_ioctl(iop_file_t *f, u32 cmd, void *args)
{
register int r = 0;

DPRINTF("cdrom_ioctl 0x%X\n", cmd);

WaitSema(cdrom_io_sema);

if (cmd != 0x10000) // Spin Ctrl op
Expand All @@ -449,6 +451,7 @@ static int cdrom_devctl(iop_file_t *f, const char *name, int cmd, void *args, u3
int result;

WaitSema(cdrom_io_sema);
WaitEventFlag(cdvdman_stat.intr_ef, 1, WEF_AND, NULL);

result = 0;
switch (cmd) {
Expand Down Expand Up @@ -536,6 +539,7 @@ static int cdrom_devctl(iop_file_t *f, const char *name, int cmd, void *args, u3
result = cdvdman_stat.intr_ef;
break;
default:
DPRINTF("cdrom_devctl unknown, cmd=0x%X\n", cmd);
result = -EIO;
break;
}
Expand All @@ -553,6 +557,7 @@ static int cdrom_ioctl2(iop_file_t *f, int cmd, void *args, unsigned int arglen,
// There was a check here on whether the file was opened with mode 8.

WaitSema(cdrom_io_sema);
WaitEventFlag(cdvdman_stat.intr_ef, 1, WEF_AND, NULL);

switch (cmd) {
case CIOCSTREAMPAUSE:
Expand All @@ -565,6 +570,7 @@ static int cdrom_ioctl2(iop_file_t *f, int cmd, void *args, unsigned int arglen,
r = sceCdStStat();
break;
default:
DPRINTF("cdrom_ioctl2 unknown, cmd=0x%X\n", cmd);
r = -EINVAL;
}

Expand Down
10 changes: 5 additions & 5 deletions modules/iopcore/cdvdman/ncmd.c
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,8 @@ int cdvdman_fill_toc(u8 *tocBuff)
}

switch (discType) {
case 0x12: // SCECdPS2CD
case 0x13: // SCECdPS2CDDA
case SCECdPS2CD:
case SCECdPS2CDDA:
u8 min;
u8 sec;
u8 frm;
Expand Down Expand Up @@ -109,8 +109,8 @@ int cdvdman_fill_toc(u8 *tocBuff)
// Later if PS2CCDA is added the tracks need to get filled in toc too.
break;

case 0x14: // SCECdPS2DVD
case 0xFE: // SCECdDVDV
case SCECdPS2DVD:
case SCECdDVDV:
// Toc for single layer DVD.
memset(tocBuff, 0, 2048);

Expand Down Expand Up @@ -168,7 +168,7 @@ int cdvdman_fill_toc(u8 *tocBuff)
}

// Not known type.
DPRINTF("cdvdman_fill_toc unimplemented for discType=%02X\n", discType);
DPRINTF("cdvdman_fill_toc unimplemented for discType=%02X\n", discType);
return 0;
}

Expand Down
8 changes: 4 additions & 4 deletions modules/iopcore/cdvdman/scmd.c
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ int sceCdTrayReq(int mode, u32 *traycnt)
}

cdvdman_stat.status = SCECdStatShellOpen;
cdvdman_stat.disc_type_reg = 0;
cdvdman_stat.disc_type_reg = SCECdNODISC;

DelayThread(11000);

Expand All @@ -93,7 +93,7 @@ int sceCdTrayReq(int mode, u32 *traycnt)
If the day comes that OPL implements disc swapping, this will be place to reupdate all disc type, LBA start offsets, mediaLsn count and everything else.
Until then it will the same disc.
*/
cdvdman_stat.disc_type_reg = cdvdman_settings.common.media & 0xFF;
cdvdman_stat.disc_type_reg = cdvdman_settings.common.media;

cdvdman_media_changed = 1;

Expand All @@ -114,9 +114,9 @@ int sceCdApplySCmd(u8 cmd, const void *in, u16 in_size, void *out)
//-------------------------------------------------------------------------
int sceCdStatus(void)
{
DPRINTF("sceCdStatus %d\n", cdvdman_stat.status);
DPRINTF("sceCdStatus %d\n", (int)cdvdman_stat.status);

return cdvdman_stat.status;
return (int)cdvdman_stat.status;
}

//-------------------------------------------------------------------------
Expand Down

0 comments on commit ea72571

Please sign in to comment.