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

CD block structure


The characteristics and logical structure of the CD block from the host's perspective are shown below.

(1)Data format
The CD buffer manages streams in sectors of fixed length (2352 bytes) regardless of device.
However, when inputting and outputting data to and from a device, the effective data length within one sector does not necessarily match 2352 bytes. For hosts, variable length settings from 2048 to 2352 bytes are possible.

(2) Stream selection circuit
The function of separating and storing streams is achieved using a mechanism called aperture and buffer partitions. Consider these functions as logical elements (selectors). By combining selectors, construct a circuit that selects the required stream.

(3) Device
Consider CDs, MPEGs, etc. as logical devices that generate and absorb streams. Control the stream flow by connecting devices to the stream selection circuit.

5.1 Data flow

The overall data flow for the CD block is shown in Figure 5.1.

Figure 5.1 Data flow across CD block

5.2 Stream processing mechanism

Figure 5.2 shows the overall configuration of the CD block, focusing on the stream flow.

Figure 5.2 Overall configuration diagram of CD block

[Explanation of each part]
  1. Device: Generates and absorbs streams. (Stream outflow/inflow device)
  2. Selector: Consists of an aperture and buffer section and selects a stream.
  3. Aperture: Separates streams according to set conditions. (matches the condition/does not match)
  4. Buffer partition: stores streams and releases and erases data upon external requests.

Each device and selector has a connector to connect to. The device and selector input/output connectors are connected one-to-one. You can also connect between selectors.

Connections between connectors that do not pass through compartments have a constant flow of streams. It will stop when you enter the area. Sectors output from unconnected output connectors will be erased.

Always connect devices through the selector. Device output connectors can only be connected to aperture input connectors, and device input connectors can only be connected to compartment output connectors.

5.3 Selector structure

A selector's processing capabilities are independent of the selector or device to which it is connected. It simply separates and stores the input stream, and outputs it on demand.
Figure 5.3 shows the structure of the selector.

Figure 5.3 Selector structure (initial state)

The initial state of the selector is that the aperture and compartment with the same number are connected through the true output connector and compartment input connector. Other connectors are not connected.

5.3.1 Aperture

For the aperture, set the conditions for the sector (FAD range, subheader) that should be passed. Sectors that match the conditions are output to the true output connector and stored in the connected buffer section. Other sectors are output to the false output connector.
The false output connector can be connected to other aperture input connectors, and the same selection process will occur one after the other.
Sectors output from unconnected output connectors will be erased.

Figure 5.4 Schematic diagram of stream selection processing

5.3.2 Buffer compartment

(1) Structure of buffer section
The CD buffer is divided into multiple buffer compartments. The structure of the buffer compartment is shown in Figure 5.5.

Figure 5.5 Structure of buffer compartment

(2) Storing sectors in buffer partitions
Sectors that enter a partition are stored at the end of the partition. The last sector position of the partition is equal to the buffer partition size - 1. After storing, the buffer partition size increases by 1.

(3) Release and erase sectors from the buffer partition
When releasing sectors from a partition, there are two ways to do so: leave the sector in the source partition or delete it. (You can also instruct only deletion.)
For example, retrieval to the host corresponds to "retrieval" and "retrieval/erase", and inflow/output between selectors corresponds to "copy" and "move".

(4) CD 1-sector interrupt and storage location
A 1-sector interrupt (CSCT flag in the interrupt factor register) during CD reading occurs for each sector when the sector is stored (or erased) in a partition. The CD block remembers the storage partition number of the last sector read, and the host can retrieve that value.
If the ECC count is set to multiple times, 1 sector interrupts may not occur at equal intervals. Multiple sectors may be stored at once for error correction.

5.3.3 Connector

(1) Connection from buffer section to aperture (copying/moving sector data)
Copying/moving sector data is possible by connecting the partition output connector to the aperture input connector and flowing sector data. The process of connection/inflow/output is executed by issuing a single command.

Figure 5.6 Copying/moving sector data

(2) Connecting selectors using OR conditions (many-to-one connection)
You can connect the true output connectors of multiple apertures to the same compartment input connector. This allows sectors that match any of multiple conditions to be stored. (OR condition: logical sum condition)

Figure 5.7 Connecting selectors using OR conditions

(3) Type of connector and connection destination
Table 5.1 Connector types and connection destinations
      input
output
 Aperture input
 Parcel input
 device input
 device output
 ×
 ×
 true output
 ×
 ×
 false output
 ×
 ×
 Partition output
 ×
○: Connection possible (1 to 1)...Only one output connector can be connected to one input connector
△: Connectable (many to 1)...Multiple output connectors can be connected to the same input connector (OR condition)
×: Unable to connect

It depends on each device whether to perform a single connection (disconnection) process with one command or a complex process that combines the connection and inflow/output processes.
CD-ROM and MPEG decoders are processed independently, while others (host, copy/move, etc.) are processed in combination.

5.3.4 Notes on selectors

(1) Error in stream processing
Errors in stream processing generally occur when the following operations are performed: (However, this does not result in an error for CD-ROM devices.)

(2) Selector setting valid timing
The selector setting becomes effective when the selector setting command is issued and the ESEL flag in the interrupt factor register becomes 1.
If the selector setting command is issued during CD playback, the FAD for which the setting is valid is within +1 frame (FAD to FAD+1) of the FAD returned in the CD report. The host should consider the margin and issue the configuration command at least 10 sectors before the target FAD.

(3) Sector data when switching connections
Even if you switch the connection to another selector while sector data is flowing, such as while reading a CD, data will not be dropped. This means that data flow is guaranteed during temporary disconnections due to connection switching.
If it is completely disconnected, the leaked data will be deleted.

(4) General access to buffer partitions (general commands that specify sector positions and sector ranges)
If you make an invalid specification, such as a position or range that exceeds the number of data in the partition, the command will return WAIT.
Always returns WAIT if:

Before accessing a partition, be sure to get the number of sectors in the buffer partition (CDC_GetSctNum) and make sure that the number of sectors is not 0.

(5) Elimination release from buffer compartment
In the case of processing to erase and release sectors from a partition, all data in the initially specified sector range will be erased even if the processing is canceled due to an error etc. (Retrieving and erasing sector data, moving, etc.)

5.4 Sector data format

(1) Basic format
The sector data format basically conforms to the CD-ROM XA sector format.

Figure 5.8 CD-ROM XA sector format

(2) Handling of subheader and user data (2048 bytes)

  1. Subheaders other than mode 2 (header mode part is 02H) are treated as 0.

  2. Only in mode 1 (header mode part is 01H), there is user data immediately after the header. Otherwise, it is assumed that the user data is located in the same location as Mode 2 Form 1.

  3. When storing user data in a partition from a source other than a CD-ROM device, treat it the same as Mode 2 Form 1. The first 24 bytes are 0, and the rest of the user data is undefined.

(3) Conversion of absolute time from BCD to FAD
Convert the header absolute time BCD (minutes: seconds: frames) to FAD using the following formula.

FAD = {(M1×10+M2)×60+(S1×10+S2)}×75+(F1×10+F2)
[M1 M2 S1 S2 F1 F2]: Absolute time BCD (6 digits, 3 bytes)

Absolute time is always converted using the above formula without checking the validity of the value.

5.5 CD Block Initialization

The information content inside the CD block is initialized by each operation as shown in Table 5.2.

Table 5.2 CD block initialization contents
 operation
Information content
 tray opens
 tray closes
 soft reset
 TOC/Session information
 initialized
 TOC lead
 File information
 initialized
 initialized
 host information
 initialized
 CD block register
 initialized
" - " means no change

If you execute CD block initialization (CDC_CdInit) without specifying a soft reset, none of the above information will be initialized.

(1)TOC/Session information
This information is unique to the disc and is initialized only when the tray is opened.
Once initialized, no information will be entered.
When the tray is closed, the TOC is automatically read and the information is retained.

(2)File information
Information about ISO9660 files held by the CD block file system.
Once initialized, no information will be entered.
Reading of file information is instructed by the host using a command.

(3)Host information
Mainly host configuration information and buffer data.
When initialized, the initial value (as a general rule, equal to the default value) is set.

(4) CD block register
Information about CD block hardware.

(5) Opening and closing the tray
When the tray is opened, the DCHG and EFLS flags in the interrupt factor register become 1. The timing is<OPEN> before the state.
The tray opening/closing operation is the same whether using command or manual operation. When opening a tray (CDC_CdOpen), the tray is initialized even if it is not actually opened.


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