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 blocks


 List
 Title

Function specifications

 Function

Get current CD status information

 Function Name [SR]

CDC_GetCurStat

 No

1.1

Form
Sint32 CDC_GetCurStat (CdcStat * stat)
input
none
output
stat: CD status information
Function value
Returns an error code.
function
Issue a command to get CD status information for a CD block to get the current CD status information (status and CD report).

 List
 Title

Function specifications

 Function

Get last CD status information

 Function Name [-]

CDC_GetLastStat

 No

1.2

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

 List
 Title

Function specifications

 Function

Get regular CD status information

 Function Name [-]

CDC_GetPeriStat

 No

1.3 1.3

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

 List
 Title

Function specifications

 Function

Get hardware information

 Function Name [S-]

CDC_GetHwInfo

 No

1.4

Form
Sint32 CDC_GetHwInfo (CdcHw * hw)
input
none
output
hw: Hardware information
Function value
Returns an error code.
function
Gets the hardware information for the CD block.

 List
 Title

Function specifications

 Function

Acquisition of TOC information

 Function Name [S-]

CDC_TgetToc

 No

1.5

Form
Sint32 CDC_TgetToc (Uint32 * toc)
input
none
output
toc: TOC information (204 words) …… Refer to data specifications (TOC / SES)
Function value
Returns an error code.
function
Get all TOC information (102 pieces, 408 bytes).
Returns WAIT during TOC read.
In the <OPEN> and <NODISC> states, all the information that can be obtained is FFFFFFFFH.
example
Sint32 ret;
Uint32 toc [102]; / * Securing TOC information storage area * /
ret = CDC_TgetToc (toc); / * Get TOC information * /

 List
 Title

Function specifications

 Function

Get session information

 Function Name [S-]

CDC_GetSes

 No

1.6

Form
Sint32 CDC_GetSes (Sint32 sesno, Uint32 * ses)
input
sesno: Session number (0-99)
output
ses: Session information (2 words) …… Refer to data specifications (TOC / SES)
Function value
Returns an error code.
function
Gets the session information (4 bytes) for the specified session.
Returns WAIT during TOC read.
In the <OPEN> and <NODISC> states, all the information that can be obtained is FFFFFFFFH.

 List
 Title

Function specifications

 Function

CD block initialization

 Function Name [SR]

CDC_CdInit

 No

1.7 1.7

Form
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 : Number of retries (lower 8 bits are valid)
output
none
Function value
Returns an error code.
End flag ESEL flag (Valid only at soft reset, only 0 cleared)
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: Soft reset the CD block 0: No | | | | | + ------- 1: Decode the subcode RW 0: No | | | | + ---------- 1: Recognize Mode2 subheader 0: No | | | + ------------- 1: Perform2 read retry 0: No | +-+ ---------------- CD-ROM data read speed (standard speed cannot be specified)
     | 0 (00B): Maximum speed (currently double speed)
     | 2 (01B): Double speed |
     + ------------------------- 1: Do not change settings 0: Do not

  1. Mode2 subheader recognition is used for correction processing during CD-ROM decoding. The selector always recognizes the Mode2 subheader. (Judgment of aperture and sector length conditions, etc.)

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

  3. The CD-ROM data read speed changes when the <PAUSE> state is reached. When playing the CD-DA area, the standard speed is automatically set. When it enters the CD-ROM area, it returns to the original speed.

(2) Soft reset ... Refer to "5.5 Initializing the CD block".

  1. When soft resetting, wait about 3ms in this function, then ignore the CMOK flag and issue the command. (Can be forcibly issued regardless of normal communication procedure)

  2. Issuing all commands is prohibited during soft reset. Determine the end of soft reset by setting the ESEL flag in the interrupt cause register to 1.

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

  4. It can be executed in the <OPEN> and <NODISC> states, but the CD drive state does not change.

(3) Standby time
Specify the time from the transition from <PAUSE> to the <STANDBY> state.
If the standby time elapses in the <PAUSE> state, the state transitions to the <STANDBY> state.

 Set 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 the setting (CDC_PARA_NOCHG)

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

 Set 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 the initialization flag bit2 = 1 (Mode2 subheader is not recognized), Mode2 ECC processing is not performed.

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

 Set value
 explanation
 00H
 Stop data output without retrying (<ERROR>) …… Initial value
 01H ~ 0FH *
 Retry the specified number of times, and if there is an error, stop data output (<ERROR>)
 40H
 Output data without retrying.
 41H-4FH *
 Retry the specified number of times and output data even if an error occurs
 80H
 Retry infinitely
 FFH
 Do not change the setting (CDC_PARA_NOCHG)
* Specify the number of times with the lower 4 bits.

bit [7] [6] [-] [-] [3 2 1 0]
     | | Specified number of times (0 to 15 times) 
     | |
     | + -------------------- 1: Output data 0: Stop at <ERROR> + -------------- --------- 1: Infinite number of retries 0: Specified number of retries

  1. Applies to Mode1 or Form1 sectors.

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

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

(6) Tray opening / closing and drive command
If soft reset is not performed, the following tray opening / closing operation is performed as a drive command. (The same applies to CD playback, seek playback position, and scan playback)

  1. If it is in the <OPEN> state, close the tray.
    -Automatic (front loading): The CD block automatically closes the tray.
    -In the case of manual type (top loading): It will be in the <BUSY> state until it is closed manually.

  2. In the <NODISC> state, open the tray. (See CDC_CdOpen function for details)


 List
 Title

Function specifications

 Function

Open tray

 Function Name [SR]

CDC_CdOpen

 No

1.8 1.8

Form
Sint32 CDC_CdOpen (void)
input
none
output
none
Function value
Returns an error code.
function
Stop the CD drive and open the tray.
-Automatic (front loading): The CD block automatically opens the tray.
-Manual type (top loading): It will be in the <BUSY> state until it is opened manually.
remarks
When the tray is opened, the TOC / session information and file information are initialized, and the DCHG and EFLS flags in the interrupt cause register are set to 1. See 5.5 Block Initialization for more information (even if opened manually).

 List
 Title

Function specifications

 Function

Waiting for data transfer

 Function Name [-]

CDC_DataReady

 No

1.9

Form
Sint32 CDC_DataReady (Sint32 dtype)
input
dtype: Forwarding preparation waiting type
output
none
Function value
Returns an error code.
function
Wait for the data transfer to be ready. After the preparation is complete, you can transfer the data.
After transferring the data, you need to perform End Data Transfer (CDC_DataEnd).

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

(2) Processing content waiting for transfer preparation
Wait until the DRDY flag in the interrupt cause register becomes 1, and clear 0 when it becomes 1.
In the case of writing, if a free sector cannot be secured, the EHST flag of the interrupt cause register becomes 1. In that case, it returns a CDC_ERR_PUT error.

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


 List
 Title

Function specifications

 Function

End of data transfer

 Function Name [S-]

CDC_DataEnd

 No

1.10

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

(1) Number of transfer words in the CD block
Returns the number of words of valid data transferred by the CD block. It does not exceed the number of regular words (the total number of words to be transferred).
In case of an error, the number of transfer words will be as follows.

 Constant name
 explanation
 CDC_DEND_ERR
 An error occurred during data transfer.
The data transfer was terminated even though it was not the time of data transfer.

(2) Relationship between the number of transferred words
You can check the status of data transfer by comparing the number of transfer words on the host (the number of words transferred by the host before the end of data transfer) with the number of transfer words on the CD block.

 Transfer status
 Number of host words transferred (number of host words)
 Number of transfer words in the CD block (cdwnum)
 When ejecting (CD → host)
 When writing (host → CD)
 Forwarding interruption
 Number of host words <Number of regular words
 cdwnum> number of host words
 cdwnum = number of host words
 All transfers
 Number of host words = number of regular words
 cdwnum = number of regular words = number of host words
 Excess transfer
 Number of host words> Number of regular words
 cdwnum = number of regular words <number of host words

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