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

3. MPEG device


3.1 Communication with MPEG devices

3.1.1 MPEG device communication registers
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 GGB R MPEG register (RGB data) CDC_GetMpegPtr
All access widths are 16 bits (1 word)

Details of MPEG-related communication registers are shown below.

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

(1) Interrupt factor register (HIRQREQ)
This register is used to notify the host of interrupt factors from the CD block.
(Please refer to the CD part for details)

Table 3.2 Bit configuration of interrupt factor register
 register name
 R/W
 15
 14
 13
 12
 11
 10
 9
 8
 HIRQREQ
 R/W
 MPST
 MPCM
 MPED 
 7
 6
 5
 4
 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 undefined section 0
bit13 MPST 1: MPEG interrupt status notification (MPEG-related interrupt occurrence) 0
bit0 to bit10: CD-related interrupt factors

(2) Interrupt mask register (HIRQMSK)
This register is used to mask interrupts from the CD block to the host.
(Please refer to the CD part for details)

Table 3.3 Bit configuration of interrupt mask register
 register name
 R/W
 15
 14
 13
 12
 11
 10
 9
 8
 HIRQMSK
 R/W
 MPST
 MPCM
 MPED 
 7
 6
 5
 4
 3
 2
 1
 0 

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

(3) MPEG register (MPEGRGB)
This register is used to transfer MPEG frame buffer image data to the host in RGB format.

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

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

  1. The initial value of the bit is undefined.

(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 issuing processing for these commands.
(Refer to the CD part for exclusive processing of command issuance)

Table 3.5 Commands belonging to command end flag (MPEG part)
flag Command
MPED
・Initialize MPEG decoder ( CDC_MpInit ) *
・ Reading from an image data window ( CDC_MpReadImg )
・ Write to image data window ( CDC_MpWriteImg )
・ Reading sectors from MPEG sector buffer ( CDC_MpReadSct )
・ Write sector to MPEG sector buffer ( CDC_MpWriteSct )
* As an exception, CDC_MpInit does not check the command end flag and only clears it to 0.

3.1.2 Operation undefined section

(1) MPEG command operation cycle
In the case of VSYNC synchronization, the MPEG command operates in 2VSYNC cycles or 1VSYNC cycle with VBLANK-IN at the beginning. This one cycle is called an operation section.
Items set during a certain operation section are reflected in the next operation section.
Table 3.3 shows the intervals of operation sections (operation cycles) depending on the type of command.

Table 3.6 Command operation cycle
Command Operating cycle
Decoding system (MPEG decoder, MPEG stream) 2VSYNC
Display system (MPEG display screen) non-interlaced 1VSYNC
interlace 2VSYNC

(2) Operation undefined section
Within the CD block, settings for the MPEG decoder are performed at VSYNC timing. On the other hand, it is difficult for the user program on the host side to obtain VSYNC timing. Therefore, there are sections where it is unclear whether the issued MPEG command will be reflected in the current section or the next section.

(3) Determination of unstable operation section
There are two methods to avoid unstable operation sections:

  1. VBLANK-OUT

  2. VBLANK-OUT guarantees that the undefined operation period has ended.
    It is recommended to perform MPEG-related processing from the timing of VBLANK-OUT.

  3. MPCM flag of interrupt factor register

  4. The MPCM flag is a flag that indicates that the MPEG decoder status has been determined.
    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 Determination of unstable operation section

In the case of host synchronization, the MPCM flag becomes 1 due to the sending of a decode synchronization signal (DSYNC) in addition to VSYNC. The indefinite interval ends regardless of whether it is 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 undefined operation section using the MPCM flag, the user program should clear the MPCM flag to 0 at the VBLANK-IN timing, and make sure 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 previous MPEG status information
 ( CDC_MpGetLastStat )
・Initialize MPEG decoder
( CDC_MpInit )
・Setting the image data window position
( CDC_MpSetImgPos )
・Setting the image data window size
( CDC_MpSetImgSiz )
・Reading from the image data window
( CDC_MpReadImg )
・Export to image data window
( CDC_MpWriteImg )
・Reading sectors from MPEG sector buffer
( CDC_MpReadSct )
・Write sectors to MPEG sector buffer
( CDC_MpWriteSct )

3.2 Operating modes and data flow

(1) Video playback mode

Figure 3.2 Data flow in video playback mode

(2) Still image playback mode
Still images are reproduced by sequentially decoding an MPEG stream in which all pictures are I pictures.
In still image playback mode, a frame bank in which image data is stored is specified and decoded. Frame banks to be displayed and output can be specified independently.
(If you specify the same frame bank, the state in the middle of decoding will also be displayed on the screen.)

Figure 3.3 Data flow in still image playback mode

(3) MPEG sector buffer mode

Figure 3.4 MPEG sector buffer mode data flow

3.3 Procedures for using MPEG functions

(1) BOOT ROM routine “MPEG check”
To use the MPEG function, you need to run 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 terminated normally, all MPEG communication functions will become REJECT and cannot be used at all.
The SYS_CHKMPEG function macro is defined in the SYS library (sega_sys.h). For specific execution methods and sample programs, please refer to the library description file (mansys.txt).

(2) Execution procedure
The steps for executing the MPEG check routine necessary to use the MPEG function are shown below.

  1. Execute a soft reset of the CD block using the CDC_CdInit function .

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

  3. If it is 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 and start the MPEG system.

  5. If the process completes normally, all MPEG communication functions will be available.


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