Japanese
PROGRAMMER'S GUIDECD communication I/F (CD part)
BackForward
CD communication interface user's manual (CD part)

Function details-1


8.2.1 Common to CD block


 one
View
table
 Title

function specification

 Function

Get current CD status information

 Function Name[SR]

CDC_GetCurStat

 No

1.1

Format
Sint32 CDC_GetCurStat(CdcStat *stat)
input
none
output
stat: CD status information
function value
Returns an error code.
function
Issue the CD status information acquisition command to the CD block to acquire the current CD status information (status and CD report).

 one
View
table
 Title

function specification

 Function

Get the previous CD status information

 Function Name[--]

CDC_GetLastStat

 No

1.2

Format
Sint32 CDC_GetLastStat(CdcStat *stat)
input
none
output
stat: CD status information
function value
Returns an error code.
function
Gets CD status information for the previous CD block command.
remarks
When the CD communication interface issues a CD block command, it holds the response status and CD report. This function returns the value it holds.

 one
View
table
 Title

function specification

 Function

Obtain periodic CD status information

 Function Name[--]

CDC_GetPeriStat

 No

1.3

Format
Sint32 CDC_GetPeriStat(CdcStat *stat)
input
none
output
stat: CD status information
function value
Returns an error code.
function
Obtains CD status information through periodic responses.
remarks
Since no commands are issued to CD blocks, the load is small and polling processing is also possible. However, immediately after a command/response, a regular response cannot be obtained and a CDC_ERR_PERI error is returned. To get the correct value, keep calling the function until it returns CDC_ERR_OK.

 one
View
table
 Title

function specification

 Function

Get hardware information

 Function Name[S-]

CDC_GetHwInfo

 No

1.4

Format
Sint32 CDC_GetHwInfo(CdcHw *hw)
input
none
output
hw: Hardware information
function value
Returns an error code.
function
Get the hardware information of CD block.

 one
View
table
 Title

function specification

 Function

Acquisition of TOC information

 Function Name[S-]

CDC_TgetToc

 No

1.5

Format
Sint32 CDC_TgetToc(Uint32 *toc)
input
none
output
toc: TOC information (204 words)...See data specifications (TOC/SES)
function value
Returns an error code.
function
Get all TOC information (102 pieces, 408 bytes).
Returns WAIT while reading TOC.
〈 OPEN〉 ,〈 NODISC〉 All information obtained in the state will be FFFFFFFFH.
example
Sint32 ret;
Uint32 toc[102]; /* Secure TOC information storage area */
ret = CDC_TgetToc(toc); /* Get TOC information */

 one
View
table
 Title

function specification

 Function

Get session information

 Function Name[S-]

CDC_GetSes

 No

1.6

Format
Sint32 CDC_GetSes(Sint32 sesno, Uint32 *ses)
input
sesno: Session number (0 to 99)
output
ses: Session information (2 words)...See data specifications (TOC/SES)
function value
Returns an error code.
function
Gets session information (4 bytes) for the specified session.
Returns WAIT while reading TOC.
〈 OPEN〉 ,〈 NODISC〉 In the state, all the information you get will be FFFFFFFFH.

 one
View
table
 Title

function specification

 Function

CD block initialization

 Function Name[SR]

CDC_CdInit

 No

1.7

Format
Sint32 CDC_CdInit(Sint32 iflag, Sint32 stnby, Sint32 ecc, Sint32 retry)
input
iflag : Initialization flag (lower 8 bits are valid)
stnby :Standby time (lower 16 bits are valid)
ecc :ECC count (lower 8 bits are valid)
retry :Retry count (lower 8 bits are valid)
output
none
function value
Returns an error code.
End flag ESEL flag (valid only at software reset, only cleared to 0)
function
Initializes the CD block and pauses the CD drive at its current position.

(1) Initialization flag
bit [7][-][5--4][3][2][1][0]
     |     |  |  |  |  |  |
     |     |  |  |  |  |  +---- 1:Perform soft reset of CD block   0:Do not perform
     |     |  |  |  |  +------- 1:Perform decoding of subcode RW   0:Do not perform
     |     |  |  |  +---------- 1:Recognize Mode 2 subheader       0:Do not perform
     |     |  |  +------------- 1:Perform Form 2 read retry        0:Do not perform
     |     +--+---------------- CD-ROM data read speed (standard speed cannot be specified)
     |                          0(00B):Maximum speed (currently double speed)
     |                          2(01B):2x speed
     |
     +------------------------- 1:Do not change settings           0:Do not perform

  1. Mode 2 subheader recognition is used for correction processing during CD-ROM decoding. Selectors always recognize Mode2 subheaders. (judging conditions such as aperture and sector length)

  2. If you do not retry Form2 read, data will be output even if there is an error.

  3. The CD-ROM data read speed is〈 PAUSE〉 It will switch when the condition is reached. When playing the CD-DA area, the speed is automatically set to standard speed. When entering the CD-ROM area, the original speed will be restored.

(2) Soft reset…Please refer to “ 5.5 CD block initialization

  1. When performing a soft reset, the command is issued after waiting approximately 3ms within this function, ignoring the CMOK flag. (Can be issued forcibly, regardless of normal communication procedures)

  2. During soft reset, issuing all commands is prohibited. Determine the end of soft reset by checking that the ESEL flag in the interrupt factor register becomes 1.

  3. Other input parameters (bits 1 to 6 of iflag, stnby, etc.) are ignored and become the initial values.

  4. 〈 OPEN〉 ,〈 NODISC〉 It can also be executed in the state, but the CD drive state does not transition.

(3)Standby time
〈 PAUSE〉 from〈 STANDBY〉 Specify the time to transition to the state.
〈 PAUSE〉 If the standby time elapses in this state,〈 STANDBY〉 transition to the state.

 Setting value
 explanation
 0000H
 180 seconds (3 minutes)……Initial value
 003CH~0384H
(60~900)
 Transition time (in seconds)... Can be specified from 60 to 900 seconds (1 to 15 minutes)
(Minimum value: CDC_STNBY_MIN, maximum value: CDC_STNBY_MAX)
 FFFFH
 Do not change settings (CDC_PARA_NOCHG)

(4)ECC number
Specifies the number of times ECC processing (PQ correction once each) is repeated during CD-ROM decoding.

 Setting value
 explanation
 00H
 Process ECC only once in real time...Initial value
 01H~05H
 Maximum number of repetitions when there is an error after ECC processing (2 to 6 times in total)
 80H
 No ECC processing
 FFH
 Do not change settings

  1. Applies to Mode1 or Form1 sectors.

  2. When bit2 of the initialization flag is 1 (Mode2 subheader is not recognized), Mode2 ECC processing is not performed.

(5) Number of retries
Specify the number of read retries for the same sector if an error occurs during CD-ROM decoding.

 Setting value
 explanation
 00H
 Stop data output without retrying (〈 ERROR〉 )...Initial value
 01H~0FH *
 Retries the specified number of times, and if there is an error, stops data output (〈 ERROR〉 become)
 40H
 Output data without retrying.
 41H~4FH *
 Retry specified number of times and output data even if there is an error
 80H
 retry infinite times
 FFH
 Do not change settings (CDC_PARA_NOCHG)
* The number of times is specified using the lower 4 bits.

bit [7][6][-][-][3  2  1  0]
     |  |        Specified number of times (0 to 15 times) 
     |  |
     |  +-------------------- 1: Output data             0:〈ERROR〉
     +----------------------- 1: Retry infinite times    0:Retry specified number of times

  1. Applies to Mode1 or Form1 sectors.

  2. When bit3 of the initialization flag is 1 (Form2 read retry), it is also applied to Form2.

  3. When bit2 of the initialization flag is 1 (Mode2 subheader is not recognized), it is also applied to Mode2.

(6) Opening/closing the tray and drive commands
If you do not perform a soft reset, use the following tray opening/closing operations as drive commands. (The same applies to CD playback, seek to playback position, and scan playback)

  1. 〈 OPEN〉 If so, close the tray.
    ・ For automatic type (front loading): CD block automatically closes the tray.
    ・ For manual type (top loading): Until closed manually〈 BUSY〉 state.

  2. 〈 NODISC〉 If so, open the tray. (See CDC_CdOpen function for details)


 one
View
table
 Title

function specification

 Function

opening the tray

 Function Name[SR]

CDC_CdOpen

 No

1.8

Format
Sint32 CDC_CdOpen(void)
input
none
output
none
function value
Returns an error code.
function
Stop the CD drive and open the tray.
・ For automatic type (front loading): CD block automatically opens the tray.
・ For manual type (top loading): until opened manually〈 BUSY〉 state.
remarks
When the tray is opened, the TOC/session information and file information are initialized, and the DCHG and EFLS flags in the interrupt factor register become 1. (The same applies if it is opened manually) For details, see " 5.5 Block Initialization ".

 one
View
table
 Title

function specification

 Function

Waiting for data transfer preparation

 Function Name[--]

CDC_DataReady

 No

1.9

Format
Sint32 CDC_DataReady(Sint32 dtype)
input
dtype: Transfer preparation waiting type
output
none
function value
Returns an error code.
function
Wait until data transfer is ready. After preparation is complete, data can be transferred.
After transferring the data, you must perform End Data Transfer (CDC_DataEnd).

(1) Transfer preparation waiting type
 constant name
 explanation
 CDC_DRDY_GET
 Specify when extracting data. (CD block → host)
 CDC_DRDY_PUT
 Specify when writing data. (Host → CD block)

(2) Processing details waiting for transfer preparation
Wait until the DRDY flag in the interrupt factor register becomes 1, then clear it to 0.
For writing, if a free sector cannot be secured, the EHST flag in the interrupt factor register becomes 1. In that case, it returns CDC_ERR_PUT error.

remarks
If an error occurs while waiting for preparation, there is no need to terminate data transfer. It is automatically executed inside this function.


 one
View
table
 Title

function specification

 Function

End of data transfer

 Function Name[S-]

CDC_DataEnd

 No

1.10

Format
Sint32 CDC_DataEnd(Sint32 *cdwnum)
input
none
output
cdwnum: Number of words transferred in CD block
function value
Returns an error code.
function
Instructs the CD block to end data transfer. It is also possible to cancel data transfer midway.

(1) Number of transferred words in CD block
Returns the number of valid words of data transferred by the CD block. The normal number of words (total number of words to be transferred) will not be exceeded.
In the case of an error, etc., the number of transferred words will be as follows.

 constant name
 explanation
 CDC_DEND_ERR
 An error occurred during data transfer.
Ending data transfer was executed even though data transfer was not in progress.

(2) Relationship between the number of transferred words
You can check the data transfer status by comparing the number of words transferred by the host (the number of words transferred by the host before completing the data transfer) and the number of words transferred in the CD block.

 Transfer status
 Host transfer word count
(Number of host words)
 Number of CD block transfer words (cdwnum)
 When ejecting (CD → host)
 When writing (host → CD)
 Transfer interruption
 host word count< Regular word count
 cdwnum> host word count
 cdwnum = number of host words
 All transfer
 Number of host words = regular number of words
 cdwnum=normal number of words=number of host words
 Excess transfer
 host word count> Regular word count
 cdwnum=normal number of words< host word count

remarks
After issuing the command, the DRDY flag is cleared inside the function.


BackForward
PROGRAMMER'S GUIDECD communication I/F (CD part)
Copyright SEGA ENTERPRISES, LTD., 1997