Japanese
SGL User's ManualPROGRAMMER'S TUTORIAL
BackForward
PROGRAMMER'S TUTORIAL

12.CD-ROM library


This chapter explains how to access CD-ROM using the CD-ROM library. By using the CD-ROM library, you can read data and programs from CD-ROMs and play music. This chapter also includes a list of CD-ROM library function references.


12-1.About CD-ROM library

SGL provides functions for accessing CD-ROMs and virtual CDs. By using these functions, you can achieve the following functionality:

 Note
The CD-ROM library functions are not listed in the separate " Function Reference ", but are listed in the latter half of this chapter .

For information on how to burn a CD-ROM, refer to "Chapter 3 of Data Transfer: How to Burn a CD-ROM."


12-2. CD-ROM access

The flow of reading data from a CD-ROM is as follows.

Figure 12-1 Flow of CD-ROM access

Since accessing a CD-ROM involves mechanical operations, the data is not read into memory the moment a read request is made. Also, the speed at which data is read from a CD-ROM is extremely slow compared to the speed of the CPU. SGL uses a method of accessing the CD-ROM while monitoring the read status so that programs other than CD-ROM access can be executed during this waiting time.

Logical structure of CD-ROM

A CD-ROM is made up of units called sectors. Sectors are generally 2048 bytes (FORM1), but if you really want to secure transfer capacity, such as music data, where there is no problem even if the sector is read slightly incorrectly, you can set it to 2324 bytes (FORM2). can. Each sector within the same file has information called a subheader consisting of channel number, submode, and coding information. A simple representation of the sector structure is as follows.

Figure 12-2 Sector structure

SGL has a function to classify data according to subheaders. In SGL, this information is called a "key." Each bit of submode and coding information has a meaning, and SGL selects and reads only sectors where the specified bit is 1.

Load file

To load files, use the functions “slCdOpen”, “slCdLoadFile”, “slCdGetStatus”.

【CDHN slCdOpen(Sint8 *pathname, CDKEY key[]);】
Specify the file to read.
“key” is the type of sector to read. You can specify multiple types of sectors. After specifying all sector types, specify “CDKEY_TERM” as the last channel number.
If the file can be opened correctly, a non-NULL file handle is returned as the return value.
However, if the total number of keys in the open file exceeds 24, opening will fail. Opened files are automatically closed when reading is interrupted or completed.

[Sint32 slCdLoadFile (CDHN cdhn, CDBUF buf []);]
Specify the area to load.
The order of “buf” corresponds to the order of “key” in the function “slCdOpen”.

To copy data from CD-ROM to work RAM, specify as follows.
buf[ i ]. type = CDBUF_COPY;
buf[ i ]. trans.copy.addr = address of read area;
buf[ i ]. trans.copy.unit = unit of read area size (CDBUF_FORM1/CDBUF_FORM2/CDBUF_BYTE);
buf[ i ]. trans.copy.size = number of read area units;

If “addr” is set to NULL and size is set to 0, it will not be loaded. For "unit", match the unit of the read area size to the sector type of the CD-ROM. This allows you to read data efficiently. The actual read area should be set to "unit" x "size" on a 4-byte boundary.

If you want to read data while processing it, you can register a function as follows.
buf[ i ]. type = CDBUF_FUNC;
buf[ i ]. trans.func.func. = function pointer;
buf[ i ]. trans.func.obj = value passed to the first argument of the function;

The registered function is “Sint32 (*func) (void *obj, Uint32 *addr, Sint32 adinc, Sint32 nsct)”.
“obj” will contain the value of “buf [ i ]. trans.func.obj” as is.
“addr” is the address from which the data will be copied.
“adinc” is the value added to “addr” when 4 bytes are extracted from “addr”, in units of 4 bytes.
“nsct” is the number of sectors that can be read. The return value is the number of sectors actually transferred. After specifying all transfer areas, specify “CDBUF_TERM” in the last “buf[].type”.

[Sint32 slCdGetStatus (CDHN cdhn, Sint32 ndata[]); ]
Please call the function “slCdGetStatus” periodically in the main loop, etc., and monitor the loading status.
When the function value becomes “CDSTAT_COMPLETED”, loading is complete.
The number of bytes read is stored in “ndata” in the order corresponding to the “key” of the function “slCdOpen”.

Sample program 1 shows an example program for reading files.

This sample program is a process for reading files on a CD-ROM, and is an example of how to use a basic library for reading files from a CD-ROM. The steps will be explained according to Flow 12-1.

  1. Initializes the system such as graphics.

  2. Initialize the CD-ROM system.

  3. Open the file.
    There is key information for classifying data in the input parameter of the function that opens the file, so please set this information as necessary.

  4. Reads the file using the file handle and read area information returned by the file open function as parameters.

  5. Executes the graphics library (function “slSynch()”).
    The file specified in File Load is actually read piecemeal at this time.

  6. Get the status information and check if the file has finished loading.
    If the file has not finished reading, it will loop until the status shows that it has finished reading.
    Inside this loop, call the function “slSynch()”.

Flow 12-1 Sample program 1 (load file sample_cd1/main.c)

Listing 12-1 Sample program 1 (loading file sample_cd1/main.c)
/************************************************* ****************************
 *
 * Copyright (c) 1994 SEGA
 *
 *File:main.c
 *Date :1995-02-20
 * Version:0.00
 *Author:
 ************************************************** **********************************/
#include "sgl.h"
#include "sgl_cd.h"

/************************************************* ***************************/
#define MAX_FILE 128
#define READSECT 50
/************************************************* ***************************/
Sint32 dirwork[SLCD_WORK_SIZE(MAX_FILE)];
Sint32 readbuf[ READSECT * CDBUF_FORM1 / sizeof(Sint32)];
    
/************************************************* ***************************/
void ss_main(void)
{
    Sint32ndir;
    CDHN cdhn;
    CDKEY key[2];
    CDBUF buf[2];
    Sint32 stat;
    Sint32 len[2];
    Sint32 ypos = 1;

    slInitSystem(TV_320x224, NULL, 1);		
    ndir = slCdInit(MAX_FILE, dirwork);	
    slPrint("slCdInit:", slLocate(1,ypos));
    slPrintFX(toFIXED(ndir), slLocate(11, ypos));
    ypos++;

    key[0].cn = key[0].sm = key[0].ci = CDKEY_NONE;
    key[1].cn = CDKEY_TERM;	
    cdhn = slCdOpen("S2100D0_.M", key);	
    slPrint("slCdOpen:", slLocate(1, ypos));
    slDispHex((Uint32)cdhn, slLocate(11, ypos));

    buf[0].type = CDBUF_COPY;	
    buf[0].trans.copy.addr = readbuf;	
    buf[0].trans.copy.unit = CDBUF_FORM1;
    buf[0].trans.copy.size = READSECT;	
    buf[1].type = CDBUF_TERM;
    slCdLoadFile(cdhn, buf);		
    ypos++;

    while (1) {
	slSynch();     			
	stat = slCdGetStatus(cdhn, len);
	slPrint("stat:", slLocate(1, ypos));
	slDispHex((Uint32)stat, slLocate(7, ypos));
	ypos++;
	if (ypos >= 27) ypos = 1;
	if (stat == CDSTAT_COMPLETED) break;
    }
    while (1);
}

Separate file loading

Please use the function “slCdResetBuf” to load a large amount of data in pieces, such as videos.

[Bool slCdResetBuf (CDHN cdhn, CDKEY *key);]
Returns the loading destination of the data corresponding to the file handle "key" to the beginning of the area specified by the function "slCdLoadFile".
Use the function “slCdGetStatus” to obtain the number of valid data in the read area, process the data when the read area is full, and call the function “slCdResetBuf”.

Sample program 2 shows an example of a program that divides and reads data.

This sample program is a process for reading files on a CD-ROM into parts, and is an example of how to use a basic library for reading files from a CD-ROM. I will explain the steps according to Flow 12-2.

  1. Initializes the system such as graphics.

  2. Initialize the CD-ROM system.

  3. Open the file.
    There is key information for classifying data in the input parameter of the function that opens the file, so please set this information as necessary.

  4. Reads the file using the file handle and read area information returned by the file open function as parameters.

  5. Executes the graphics library (function “slSynch()”).
    The file specified in File Load is actually read piecemeal at this time.

  6. Get the status information and check if the file has finished loading.
    Also, check if the loading area is full. If it is full, process the data as needed and then reset the loading area.
    If the file has not finished reading, it will loop until the status shows that it has finished reading.
    Inside this loop, call the function “slSynch()”.

Flow 12-2 Sample program 2 (divided file reading sample_cd2/main.c)

Listing 12-2 Sample program 2 (divided file reading sample_cd2/main.c)
/************************************************* ****************************
 *
 * Copyright (c) 1994 SEGA
 *
 *File:main.c
 *Date :1995-02-20
 * Version:0.00
 *Author:
 ************************************************** **********************************/
#include "sgl.h"
#include "sgl_cd.h"

/************************************************* ***************************/
#define MAX_OPEN 128	
#define FNAME "S2100D0_.M"
#define slsize 2	

/************************************************* ***************************/
Sint32 lib_work[SLCD_WORK_SIZE(MAX_OPEN)];
Sint32 readbuf[ (CDBUF_FORM1 * slsize) / sizeof(Sint32) ];

/************************************************* ***************************/
void ss_main(void)
{
    Sint32 ndir;			
    Sint32 ypos = 1 ;	
    Sint32 ret ;		
    Sint32 ndata[2] ;	
    CDHN cdhn;		
    CDKEY key[2];
    CDBUF buf[2];

    slInitSystem(TV_320x224, NULL, 1);	
    ndir = slCdInit(MAX_OPEN, lib_work);
    slPrint("slCdInit:", slLocate(1,ypos));
    slPrintFX(toFIXED(ndir), slLocate(11, ypos));
    ypos++;

    key[0].cn = key[0].sm = key[0].ci = CDKEY_NONE;
    key[1].cn = CDKEY_TERM ;	
    cdhn = slCdOpen(FNAME, key);	
    slPrint("slCdOpen:", slLocate(1, ypos));
    slDispHex((Uint32)cdhn, slLocate(11, ypos));

    buf[0].type = CDBUF_COPY ;
    buf[0].trans.copy.addr = readbuf;
    buf[0].trans.copy.unit = CDBUF_FORM1 ;
    buf[0].trans.copy.size = slsize;	
    buf[1].type = CDBUF_TERM ;
    ypos++;

    slCdLoadFile(cdhn, buf);	 
    while( 1 ){

	slSynch();			
	ret = slCdGetStatus( cdhn, ndata );
	slPrint("stat:", slLocate(1, ypos));
	slDispHex( (Uint32)ret, slLocate(7, ypos));
	ypos++;
	if (ypos >= 27) ypos = 3;
	if ( ret == CDSTAT_COMPLETED ) break;
	if ( ndata[0] == CDBUF_FORM1 * slsize ){
		slCdResetBuf(cdhn, &(key[0]));
	} 
   }
    while( 1 );          
}

About the read-ahead function

When reading data from a CD-ROM, the mechanical movement of the CD drive is involved, so the data is not actually read the moment the reading starts. The look-ahead function is a function that minimizes this waiting time. The Sega Saturn has an area that temporarily stores data read from CD-ROM. This area is called the CD buffer. Once the next file to read is determined, it starts reading data into the CD buffer, and when the data is needed it is transferred to memory.

Figure 12-3 CD buffer

Set the address of the read area of the previously explained function “slCdLoadFile” to NULL and the size of the read area to 0, and when the return value of the function “slCdGetStatus” becomes “CDSTAT_WAIT”, the read ahead is complete. After this, set the address and size of the read area using the function “slCdLoadFile” and transfer will begin immediately. You can also set the address and size of the read area before the read-ahead into the CD buffer is complete.

[Sint32 slCdLoadFile (CDHN cdhn, CDBUF buf[]);]
Specify the following in the CD buffer to read ahead:
buf[ i ]. type = CDBUF_COPY;
buf[ i ]. trans.copy.addr = NULL;
buf[ i ]. trans.copy.unit = CDBUF_FORM1;
buf[ i ]. trans.copy.size = 0;

After specifying all transfer areas, specify “CDBUF_TERM” for the last “type”.

Sample program 3 shows an example of a read-ahead program.

This sample program is a process for reading files on a CD-ROM, and is a basic usage example of library processing that pre-reads files from a CD-ROM. I will explain the steps according to Flow 12-3.

  1. Initializes the system such as graphics.

  2. Initialize the CD-ROM system.

  3. Open the file.
    There is key information for classifying data in the input parameter of the function that opens the file, so please set this information as necessary.

  4. Reads the file using the file handle and read area information returned by the file open function as parameters.
    At this time, set NULL to the read area address of the read area information, set 0 to the size, and pre-read the file.

  5. Executes the graphics library (function “slSynch()”).

  6. Get the status information and check whether it is waiting for transfer.
    If it is in the transfer waiting state, the loop ends.
    Call the function “slSynch()” in this loop.

  7. Load the file again.
    At this time, set the address in the read area address of the read area information and read the file.

  8. Executes the graphics library (function “slSynch()”).
    The file specified in Load File is actually loaded at this time.

  9. Get the status information and check if the file has finished loading.
    If the file has not finished reading, it will loop until the status shows that it has finished reading.
    Inside this loop, call the function “slSynch()”.

Flow 12-3 Sample program 3 (read ahead sample_cd3/main.c)

Listing 12-3 Sample program 3 (read ahead sample_cd3/main.c)
/************************************************* ****************************
 * Copyright (c) 1994 SEGA
 *
 *File:main.c
 *Date :1995-02-20
 * Version:0.00
 *Author:
 *
 ************************************************** **********************************/
#include "sgl.h"
#include "sgl_cd.h"

/************************************************* ***************************/
#define MAX_OPEN 128	
#define FNAME "S2100D0_.M"
#define slsize 2

/************************************************* ***************************/
Sint32 lib_work[SLCD_WORK_SIZE(MAX_OPEN)];	
Sint32 readbuf[ (CDBUF_FORM1 * slsize) / sizeof(Sint32)];
	
/************************************************* ***************************/
void ss_main(void)
{
    Sint32 ndir;		
    Sint32 ypos = 1 ;	
    Sint32 ret ;		
    Sint32 ndata[2] ;	
    CDHN cdhn;			
    CDKEY key[2];	
    CDBUF buf[2];		

    slInitSystem(TV_320x224, NULL, 1);		
    ndir = slCdInit(MAX_OPEN, lib_work);
    slPrint("slCdInit:", slLocate(1,ypos));
    slPrintFX(toFIXED(ndir), slLocate(11, ypos));
    ypos++;
 					
    key[0].cn = key[0].sm = key[0].ci = CDKEY_NONE;
    key[1].cn = CDKEY_TERM ;	
    cdhn = slCdOpen(FNAME, key);	
    slPrint("slCdOpen:", slLocate(1, ypos));
    slDispHex((Uint32)cdhn, slLocate(11, ypos));

    buf[0].type = CDBUF_COPY ;	
    buf[0].trans.copy.addr = NULL ;
    buf[0].trans.copy.unit = CDBUF_FORM1 ;
    buf[0].trans.copy.size = 0;	
    buf[1].type = CDBUF_TERM ;	
    slCdLoadFile( cdhn, buf );
    ypos++;

    while( 1 ){
	slSynch();			
	ret = slCdGetStatus( cdhn, NULL );	
	slPrint("stat1:", slLocate(1, ypos));
	slDispHex( (Uint32)ret, slLocate(7, ypos));
	ypos++;
	if (ypos >= 27) ypos = 3;
	if ( ret == CDSTAT_WAIT ) {	
		buf[0].trans.copy.addr = readbuf; 
    		buf[0].trans.copy.size = slsize; 
		break ;
	}
    }

    slCdLoadFile( cdhn, buf );	

    while( 1 ){

	slSynch();				
	ret = slCdGetStatus( cdhn, ndata );
	slPrint("stat2:", slLocate(1, ypos));
	slDispHex( ret, slLocate(7, ypos));
	ypos++;
	slPrint("ndata:", slLocate(1, ypos));
	slDispHex( ndata[0], slLocate(7, ypos));
	ypos++;
	if (ypos >= 27) ypos = 3;
 	if ( ret == CDSTAT_COMPLETED ) break;
	if ( ndata[0] == CDBUF_FORM1 * slsize ){
		slCdLoadFile(cdhn, buf);
	}
    }
    while( 1 );          
}

Playing CDDA files

To play a CDDA file, initialize the sound and use the functions “slCdOpen”, “slCdLoadFile” and “slCdGetStatus”.

[Sint32 slCdLoadFile (CDHN cdhn, CDBUF buf[]);]
To play a CDDA file, specify:

buf[ 0 ]. type = CDBUF_COPY;
buf[ 0 ]. trans.copy.addr = NULL;
buf[ 0 ]. trans.copy.unit = CDBUF_FORM1;
buf[ 0 ]. trans.copy.size = 0;
buf[ 1 ]. type = CDBUF_TERM;

Sample program 4 shows an example program for playing CDDA files.

This sample program is a process for reading CDDA files on a CD-ROM, and is an example of how to use a basic library to play CDDA files on a CD-ROM.
I will explain the steps according to flow 12-4.

  1. Initializes the system such as graphics.

  2. Initialize the sound.

  3. Initialize the CD-ROM system.

  4. Open the file.
    There is key information for classifying data in the input parameter of the function that opens the file, but this information is not necessary, so please set it so that it is not selected here.

  5. Plays CDDA files.
    Plays the CDDA file using the file handle and read area information as the return value of the file open function as parameters.

  6. Executes the graphics library (function “slSynch()”).

  7. Get the status information and check whether the CDDA file has finished playing.
    When the playback is finished, end the loop.
    Call the function “slSynch()” in this loop.

Flow 12-4 Sample program 4 (CDDA file playback sample_cd4/main.c)

Listing 12-4 Sample program 4 (CDDA file playback sample_cd4/main.c)
/************************************************* ****************************
 *
 * Copyright (c) 1994 SEGA
 *
 *File:main.c
 *Date :1995-02-20
 * Version:0.00
 *Author:
 *
 ************************************************** **********************************/
#include "sgl.h"
#include "sgl_cd.h"
#include "sddrvs.dat"

/************************************************* ***************************/
#define WIN_ORG_X 0		
#define WIN_ORG_Y 0		
#define WIN_SIZE_X 320		
#define WIN_SIZE_Y 240	
#define MAX_FILE 128
Sint32 dirwork[SLCD_WORK_SIZE(MAX_FILE)];

Uint8 sdmap[] = {
	0x00, 0x00, 0xB0, 0x00, 0x00, 0x00, 0x80, 0x00,
	0x10, 0x01, 0x30, 0x00, 0x00, 0x00, 0x10, 0x00,
	0x11, 0x01, 0x40, 0x00, 0x00, 0x00, 0x20, 0x00,
	0x20, 0x01, 0x60, 0x00, 0x00, 0x00, 0x06, 0x00,
	0x21, 0x01, 0x68, 0x00, 0x00, 0x00, 0x06, 0x00,
	0x22, 0x01, 0x70, 0x00, 0x00, 0x00, 0x06, 0x00,
	0x23, 0x01, 0x78, 0x00, 0x00, 0x00, 0x06, 0x00,
	0x24, 0x01, 0x80, 0x00, 0x00, 0x00, 0x06, 0x00,
	0x01, 0x01, 0x86, 0x00, 0x00, 0x04, 0x00, 0x00,
	0x30, 0x05, 0xA0, 0x00, 0x00, 0x02, 0x00, 0x00,
	0xFF, 0xFF
    };
    
/************************************************* ***************************/

void ss_main(void)
{
    Sint32ndir;
    CDHN cdhn;
    CDBUF buf[2];
    CDKEY key[2];
    Sint32 stat;

    slInitSystem(TV_320x224, NULL, 1);
    slInitSound(sddrvstsk, sizeof(sddrvstsk), sdmap, sizeof(sdmap));
    slCDDAOn(127, 127, 0, 0);
    ndir = slCdInit(MAX_FILE, dirwork);

    key[0].cn = CDKEY_NONE;
    key[0].sm = CDKEY_NONE;
    key[0].ci = CDKEY_NONE;
    key[1].cn = CDKEY_TERM;
    cdhn = slCdOpen("cdda1", key);

    buf[0].type = CDBUF_COPY;
    buf[0].trans.copy.addr = NULL;
    buf[0].trans.copy.unit = CDBUF_FORM1;
    buf[0].trans.copy.size = 0;
    buf[1].type = CDBUF_TERM;
    slCdLoadFile(cdhn, buf);

    while (1) {
	slSynch();
	stat = slCdGetStatus(cdhn, NULL);
	if (stat == CDSTAT_COMPLETED) break;
    }
    while (1)
	;
}

Other general matters

●About read errors
If a read error occurs during reading, the CD block is first recovered by hardware. If recovery is still not possible, the library will perform the recovery process a certain number of times. If recovery is ultimately not possible, the status acquisition function interrupts reading and returns a read error error code.

●About path names
Specify the directory as \ or /. Also, directory names and file names can be in both uppercase and lowercase letters.

●Advanced usage of CD-ROM library
SGL allows you to use functions from the file system library and stream system library. Use these functions, for example when using Cinepak or MPEG. For details, refer to each library's manual.
If you call the function “slCdInit”, there is no need to initialize the file system and stream system.
When using the file system or stream system while reading a file with SGL, call the function "slCdPause" and check that the status becomes "CDSTAT_PAUSE", or call the function "slCdAbort".
It is also necessary to stop reading when you finish reading by the file system or stream system and return to SGL.

Figure 12-4 Internal structure of CD-ROM library


12-3. CD library functions


CDHN file handle
Explanation
A file handle to read the file.

CDKEY Key for classifying sector data

structure
typedef struct {
    Sint16 cn;
    Sint16 sm;
    Sint16 ci;
}CDKEY;

member
 cn
 channel number
 sm
 submode
 ci
 Coding information

Explanation
Specifies the key for classifying sector data using subheaders.

remarks
If not selected, specify CDKEY_NONE.
Set CDKEY_TERM to the terminal cn.

CDBUF read area information

structure
typedef struct {
         void *addr;
         Sint32 unit;
         Sint32 size;
         } TRANS_COPY;

typedef struct {
         Sint32 (*func) (void *obj, Uint32 *addr,
                          Sint32 adinc, Sint32 nsct);
         void *obj;
         } TRANS_FUNC;

typedef struct {
     Sint32 type;
         union {
                 TRANS_COPY copy;
                 TRANS_FUNC fucn;
         }trans;
}CDBUF;

member
type  CDBUF_COPY     Copy to work RAM
      CDBUF_FUNC     Transfer function
      CDBUF_TERM     Termination

-------------------------------------------------------
If type = CDBUF_COPY : copy
-------------------------------------------------------
addr                 Address of read area (NULL if not read)
unit  CDBUF_FORM1    The size of the read area is 2048 bytes.
      CDBUF_FORM2    The size of the read area is 2324 bytes.
      CDBUF_BYTE     The size of the read area is in bytes.
size                 Number of units for reading area (0 if not reading)

-------------------------------------------------------
If type = CDBUF_FUNC : func
-------------------------------------------------------
func                Transfer function
obj                 object

Explanation
Set the read area or transfer function.

remarks
The read area must be on a 4-byte boundary.

Sint32 slCdInit (Sint32 nfile, void *work) initialization

parameters
 nfile
 Maximum number of files in one directory
 work
 work area

function
Perform the initial settings for using the CD.

Return value
Number of files in root directory (error code if negative)

remarks
The size of the area is determined by SLCD_WORK_SIZE(nfile).
nfile Maximum number of files in each directory
The work area must be on a 4-byte boundary.

Sint32 slCdChgDir (Sint8 *pathname) directory change

parameters
 pathname
 Path name (relative path/absolute path can be specified)

function
Move directory.

Return value
Number of files in directory (error code if negative)

CDHN slCdOpen (Sint8 *pathname, CDKEY key[]) File open

parameters
 pathname
 Path name (relative path/absolute path can be specified)
 key
 Key information for classifying stream data

function
Open the file.

Return value
File handle (NULL if cannot be opened)

remarks
It will be automatically closed when loading is interrupted or completed.

Sint32 slCdLoadFile (CDHN cdhn,CDBUF buf[]) Load file

parameters
 cdhn
 file handle
 buf
 Reading area information (corresponds to the key when opening)

function
Start playback and read data from the CD.

Return value
Error code

remarks
If you specify NULL for the read area and 0 for the number of units, read ahead will be executed.
If a read area is specified, transfer using CPUDMA.

Sint32 slCdTrans (CDHN cdhn, CDBUF buf[], Sint32 ndata[]) Stream transfer

parameters
 cdhn
 file handle
 buf
 Reading area information
 data
 Number of valid data in transfer area (NULL if unnecessary)

function
Only data transfer is performed while file loading is paused.

Return value
Error code

remarks
You can use “slCdLoadFile()” to transfer only to the key specified by NULL in the transfer area.
This function does not end until the transfer is completed.

Bool slCdResetBuf (CDHN cdhn, CDKEY *key) Reset transfer area

parameters
 cdhn
 file handle
 key
 Key information for classifying data

function
Initialize the destination pointer.

Return value
 TRUE
 normal termination
 FLASE
 A key that is not open was specified. 

Sint32 slCdAbort (CDHN cdhn) Loading abort

parameters
 cdhn
 file handle

function
Interrupt file loading

Return value
Error code

Sint32 slCdPause (CDHN cdhn) Pause reading

parameters
 cdhn
 file handle

function
Pause file loading.

Return value
Error code

Sint32 slCdGetStatus (CDHN cdhn, Sint32 ndata[]) Get status

parameters
 cdhn
 file handle
However, you can obtain the status of the CD block by specifying the following constant.
 CDREQ_FREECD
 Get the number of free sectors in a block
 CDREQ_FAD
 Current pickup position
 CDREQ_DRVCD
 Drive status
 data
 If a file handle is specified, the number of valid data in the transfer area
(NULL if not needed)

function
Get the status of the issued request.

Return value
Status when specifying a file handle (if negative, error code)
 CDSTAT_PAUSE
 Loading stopped
 CDSTAT_DOING
 Loading
 CDSTAT_WAIT
 Transfer waiting state
 CDSTAT_COMPLETED
 Loading completed
 If CDREQ_FREE is specified
 Number of free sectors in CD block
 When specifying CDREQ_FAD
 pickup position
 If CDREQ_DRV is specified
 CD drive status
 CDDRV-BUSY
 State transition in progress
 CDDRV_PAUSE
 Pausing
 CDDRV_STDBY
 stand-by
 CDDRV_PLAY
 CD playing
 CDDRV_SEEK
 Seeking in progress
 CDDRV_SCAN
 Scan playback in progress
 CDDRV_OPEN
 tray is open
 CDDRV_NODISC
 no disc
 CDDRV_RETRY
 Read retry processing in progress
 CDDRV_ERROR
 Read error occurred
 CDDRV_FATAL
 Fatal error occurred


Error code

Table 12-1 Error codes
constant name meaning constant value
CDERR_OK normal termination (0)
CDERR_RDERR Read error (-1)
CDERR_NODISC Disc is not set (-2)
CDERR_CDROM Disk is not CR-ROM (-3)
CDERR_IPARA Invalid initialization parameter (-Four)
CDERR_DIR Move outside the directory (-6)
CDERR_NEXIST File does not exist (-9)
CDERR_NUM Negative number of bytes etc. (-14)
CDERR_PUINUSE Pickup in operation (-20)
CDERR_ALIGN The work area is not on a 4-byte boundary (-twenty one)
CDERR_TMOUT timeout (-twenty two)
CDERR_OPEN tray open (-twenty three)
CDERR_FATAL CD drive< FATAL> (-twenty five)
CDERR_BUSY State transition in progress (-50)


BackForward
SGL User's ManualPROGRAMMER'S TUTORIAL
Copyright SEGA ENTERPRISES, LTD., 1997