PROGRAMMER'S GUIDECD communication I / F (MPEG part)
BackForward
CD communication I / F (MPEG part)

3. 3. MPEG device


3.1 Communication with MPEG devices

3.1.1 MPEG device communication register
Table 3.1 shows a list of MPEG-related communication registers and the corresponding access functions.

Table 3.1 List of communication registers
Register name R / W explanation Access function
HIRQREQ R / W Interrupt factor register CDC_GetHirqReq , CDC_ClrHirqReq
HIRQMSK R / W Interrupt mask register CDC_GetHirqMsk , CDC_SetHirqMsk
MPEG RGB R MPEG register (RGB data) CDC_GetMpegPtr
All access widths are 16 bits (1 word)

Details of the MPEG-related communication registers are shown below.

In the figure, the reserved bit is represented by "-". Be sure to specify 0 for the reserved bit.
The bit configuration is 15 for the most significant bit (MSB) and 0 for the least significant bit (LSB).

(1) Interrupt cause register (HIRQREQ)
This register is used to notify the cause of interrupts from the CD block to the host.
(See the CD part for details)

Table 3.2 Interrupt factor register bit configuration
 Register name
 R / W
 15
 14
 13
 12
 11
 Ten
 9
 8
 HIRQREQ
 R / W
 MPST
 MPCM
 MPED 
 7
 6
 Five
 Four
 3
 2
 1
 0 

bit name explanation initial value
bit11 MPED 1: End of MPEG related processing 1
bit12 MPCM 1: End of MPEG operation indefinite section 0
bit13 MPST 1: Notification of MPEG interrupt status (MPEG-related interrupt generation) 0
bit0 to bit10: CD-related interrupt factors

(2) Interrupt mask register (HIRQMSK)
A register for masking interrupts from the CD block to the host.
(See the CD part for details)

Table 3.3 Interrupt mask register bit configuration
 Register name
 R / W
 15
 14
 13
 12
 11
 Ten
 9
 8
 HIRQMSK
 R / W
 MPST
 MPCM
 MPED 
 7
 6
 Five
 Four
 3
 2
 1
 0 

  1. The meaning of the bit is the same as that of the interrupt factor register.
    (1: Interrupt enabled, 0: mask)

(3) MPEG register (MPEGRGB)
A register for transferring the image data of the MPEG frame buffer to the host in RGB format.

Table 3.4 MPEG register bit configuration
 Register name
 R / W
 15
 14
 13
 12
 11
 Ten
 9
 8
 MPEG RGB
 R
 TRP
 B7
 B6
 B5
 B4
 B3
 G7
 G6
 7
 6
 Five
 Four
 3
 2
 1
 0
 G5
 G4
 G3
 R7
 R6
 R5
 R4
 R3

Name explanation
R3 ~ R7 : Upper 5 bits of R (red) data
G3 ~ G7 : Top 5 bits of G (green) data
B3 ~ B7 : Upper 5 bits of B (blue) data
TRP : Transparent bit (Processed by setting the transparent bit mode of the screen special effect)

  1. The initial value of the bit is indefinite.

(4) Command end flag
The MPED flag is an MPEG-related command end flag, and notifies the end of processing of each of the following commands. The CDC function performs exclusive command issuance processing for these commands.
(Refer to the CD part for exclusive processing of command issuance)

Table 3.5 Commands belonging to the command end flag (MPEG part)
flag Command
MPED
-Initialization of MPEG decoder (CDC_MpInit) *
-Reading from the image data window (CDC_MpReadImg)
-Export to the image data window (CDC_MpWriteImg)
-Sector read from MPEG sector buffer (CDC_MpReadSct)
-Sector writing to the MPEG sector buffer (CDC_MpWriteSct)
* For CDC_MpInit , exceptionally, the command end flag is not checked and only 0 is cleared.

3.1.2 Indefinite operation section

(1) MPEG command operation cycle
In the case of VSYNC synchronization, the MPEG command operates in a 2VSYNC cycle or a 1VSYNC cycle starting with VBLANK-IN. This one cycle is called an operation section.
Items set in a certain operation section are reflected in the next operation section.
Table 3.3 shows the interval (operation cycle) of the operation section according to the type of command.

Table 3.6 Command operation cycle
Command Operation cycle
Decoding system (MPEG decoder, MPEG stream) 2VSYNC
Display system (MPEG display screen) Non-interlaced 1VSYNC
Interlace 2VSYNC

(2) Indefinite operation section
In the CD block, the setting for the MPEG decoder is performed at the timing of VSYNC. On the other hand, it is difficult for the user program on the host side to obtain the timing of VSYNC. Therefore, there is a section in which it is uncertain whether the issued MPEG command is reflected in the current section or in the next section.

(3) Judgment of indefinite operation section
There are the following two methods to avoid the operation indefinite section.

  1. VBLANK-OUT
    VBLANK-OUT guarantees that the indefinite operation interval has ended.
    It is recommended to perform MPEG related processing from the VBLANK-OUT timing.

  2. MPCM flag in interrupt factor register
    The MPCM flag is a flag that indicates that the status of the MPEG decoder has been confirmed.
    Commands issued between MPCM = 1 and VBLANK-IN will be reflected in the next section.
    Clear the MPCM flag to 0 on the host side and wait for it to become 1 again.

Figure 3.1 Judgment of indefinite operation section

In the case of host synchronization, the MPCM flag is set to 1 due to the transmission of the decode synchronization signal (DSYNC) in addition to VSYNC. The indefinite interval ends in either VSYNC or DSYNC.

(4) Checking the MPCM flag when issuing a command
The MPEG communication function checks the MPCM flag when issuing a command, and if it is 0, returns the error code CDC_ERR_MP_COMU without issuing the command.
When determining the end of the operation indefinite interval with the MPCM flag, the user program clears the MPCM flag to 0 at the timing of VBLANK-IN, and confirm that the MPEG communication function returns CDC_ERR_OK.

However, the following functions do not check the MPCM flag.

Table 3.7 MPEG communication functions that do not check the MPCM flag
 -Acquisition of the previous MPEG status information
 ( CDC_MpGetLastStat )
 -Initialization of MPEG decoder
( CDC_MpInit )
 -Image data window position setting
( CDC_MpSetImgPos )
 -Image data window size setting
( CDC_MpSetImgSiz )
 -Reading from the image data window
( CDC_MpReadImg )
 -Export to the image data window
( CDC_MpWriteImg )
 -Reading sectors from the MPEG sector buffer
( CDC_MpReadSct )
 -Sector writing to the MPEG sector buffer
( CDC_MpWriteSct )

3.2 Operation mode and data flow

(1) Video playback mode

Figure 3.2 Data flow in video playback mode

(2) Still image playback mode
The still image is reproduced by sequentially decoding an MPEG stream in which all the pictures are composed of I pictures.
In the still image playback mode, the frame bank for storing the image data is specified and decoded. The frame bank to be displayed / output can be specified independently.
(If the same frame bank is specified, the status during decoding is also displayed on the screen.)

Figure 3.3 Data flow in still image playback mode

(3) MPEG sector buffer mode

Figure 3.4 Data flow in MPEG sector buffer mode

3.3 Procedure for using the MPEG function

(1) Routine "MPEG check" in BOOT ROM
To use the MPEG function, it is necessary to execute the MPEG check routine (SYS_CHKMPEG function macro) in the BOOT ROM. This routine performs the processing necessary to use the MPEG function.
If this routine is not executed and completed normally, all MPEG communication functions will be REJECT and cannot be used at all.
The SYS_CHKMPEG function macro is defined in the SYS library (sega_sys.h). Please refer to the library explanation file (mansys.txt) for the specific execution method and sample program.

(2) Execution procedure
The procedure for executing the MPEG check routine required to use the MPEG function is shown below.

  1. Perform a soft reset of the CD block with the CDC_CdInit function.

  2. Execute the CDC_GetHwInfo function to check if the MPEG cartridge is installed.

  3. If installed, execute the SYS_CHKMPEG function macro.
    (Even if it fails, it will be executed up to 2 times)

  4. If successful, execute the CDC_MpInit function with the switch ON to boot the MPEG system.

  5. If successful, all MPEG communication functions will be available.


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