Discuss the development of software, tools, libraries and anything else that helps make ps2dev happen.
Moderators: cheriff , Herben
misfire
Posts: 110 Joined: Mon Sep 06, 2004 7:53 am
Location: Germany
Post
by misfire » Sat Nov 26, 2005 12:47 am
I've encountered a problem with cdRead(). When I try to read a non-existing sector, cdRead() returns 1 (OK) instead of 0 (error).
Example:
Code: Select all
void readtest()
{
int ret;
u8 buf[2048];
CdvdReadMode_t mode;
memset(buf, 0, sizeof(buf));
mode.retries = 10;
mode.sectorType = CDVD_SECTOR_2048;
mode.readSpeed = CDVD_SPIN_NORMAL;
cdInit(0);
printf("Reading data from disc... ");
ret = cdRead(-1, 1, buf, &mode); // read the sector at LBA (-1)
cdSync(0); // blocking
if (!ret) printf("Failed.\n");
else printf("OK.\n");
}
And the output is: "Reading data from disc... OK."
I don't know why it acts like that.
Also, does anybody know how to get the total number of sectors on a disc? I guess this information is stored in the TOC, but where?
evilo
Posts: 230 Joined: Thu Apr 22, 2004 8:40 pm
Contact:
Post
by evilo » Sat Nov 26, 2005 1:21 am
the TOC is a special area that cannot be read with the CdRead() function.
However, you can use the CdGetToc() function (seeing the function name, I don't think you need further information on it).
if you want some examples of usage, just check the sdk sources (audsrv for i.e.).
misfire
Posts: 110 Joined: Mon Sep 06, 2004 7:53 am
Location: Germany
Post
by misfire » Tue Dec 06, 2005 7:35 pm
I know how to read the TOC, I just can't find any information on how it is organized?
Also, what is its exact size? In libcdvd.h it says:
Code: Select all
// get toc from inserted disc
//
// args: buffer to hold toc (1024 or 2064 bytes?)
// returns: 1 if successful
// 0 otherwise
s32 cdGetToc(u8 *toc);
Any help would be appreciated.