VDP Status Registers
This page was last modified 21:52, 13 November 2016 by Mars2000you.

The MSX1 VDP has only one status register (register 0) while the MSX2/2+ VDP has 10 status registers (0 to 9).

Contents

The status registers

Status Register 0

This status register is common to all MSX generations and can be read with the MSX-BASIC instruction VDP(), using the value 8.

It may be read at any time but asynchronous reads will cause the F flag to be reset and therefore missed. Consequently, the status register should be read only when the VDP interrupt is pending (flag value 1).

Bit Code Meaning Values
7 F Vertical scan interrupt flag * Set to 1 at the end of the raster scan of the last line of the active display
* Reset to 0 when the register is read or the VDP is externally reset
6 5S Flag for 5th sprite (SCREEN 1 and 2)
or 9th sprite (SCREEN 4 to 8 and 10 to 12)
* Set to 1 when the F flag is equal to 0 and there are more than 4 or 8 sprites aligned on the same horizontal line
* Reset to 0 after the register is read or when the VDP is externally reset
5 C Collision flag * Set to 1 when two sprites have collided
* Reset to 0 after the register is read or when the VDP is externally reset
4 to 0 5SN Number of the 5th sprite (SCREEN 1 and 2)
or 9th sprite (SCREEN 4 to 8 and 10 to 12)


Status Register 1

This status register is available on the MSX2/2+ VDP and can be read with the MSX-BASIC instruction VDP(), using the value -1.

Bit Code Meaning Values
7 FL Light Pen / Mouse 2 * Set to 1 when light pen detects light or second button of mouse is pressed
* Light pen interrupt generated only if enabled in IE2 (bit 5 of Control Register 0)
* Reset to 0 when this register is read after light detection by light pen
* Always value 0 on MSX2+ VDP
6 LPS Light Pen / Mouse 1 * Set to 1 when light pen button or first button of mouse is pressed
* Never reset when this register is read
* Always value 0 on MSX2+ VDP
5 to 1 ID # Identification number of the VDP chip * 00000 for V9938
* 00010 for V9958
0 FH Horizontal scan interrupt flag * Set to 1 if VDP scans line specified in Control Register 19
* Interrupt generated only if enabled in IE1 (bit 4 of Control Register 0)
* Reset to 0 when this register is read


Status Register 2

This status register is available on the MSX2/2+ VDP and can be read with the MSX-BASIC instruction VDP(), using the value -2.

Bit Code Meaning Values
7 TR Transfer ready flag * Set to 1 when VDP is ready for next transfer from CPU
* Set to 0 when VDP is not ready
6 VR Vertical retrace flag Set to 1 during scanning of VBLANK area of the screen, i.e. during vertical retrace plus while lower and upper borders of the screen are drawn
5 HR Horizontal retrace flag Set to 1 during scanning of HBLANK area of the screen, i.e. when right and left borders of the screen are drawn
4 BD Color detect flag Set to 1 during execution of the SEARCH command when specified color is detected
3-2 Always value 1
1 EO Display field flag * Value 1 to indicate the second field
* Value 0 to indicate the first field
0 CE Command execution flag Value 1 to indicate that VDP is busy executing a command


Status Registers 3 to 6

These status registers are available on the MSX2/2+ VDP and can be read with the MSX-BASIC instruction VDP(), using the values -3 to -6. They contain coordinate information about collision location of the sprites, or location of light pen, or relative movement of the mouse.

The status register 3 is associated as low register with status register 4 as high register for the column info. Bits 7 to 1 of status register 4 have always the value 1.

The status register 5 is associated as low register with status register 6 as high register for the row info. Bits 7 to 2 of status register 6 have always the value 1.

Status Register 7

This status register is available on the MSX2/2+ VDP and can be read with the MSX-BASIC instruction VDP(), using the value -7. It's a color register that is used when executing commands 'POINT' and 'VRAM to CPU' and contains VRAM data.

Status Registers 8 and 9

These status registers are available on the MSX2/2+ VDP and can be read with the MSX-BASIC instruction VDP(), using the values -8 and -9.

The status register 8 is associated as low register with status register 9 as high register. Bits 7 to 1 of status register 9 have always the value 1.

When the SEARCH command is executed and a coded color had been detected (see bit 4 of status register 2), these registers contain the X coordinate of the coded color.

How to read a VDP status register

Direct access

As indicated for each status register, direct access in reading mode is possible with the VDP() instruction. Value needs to be 0 for status register 0, -1 to -9 for the other status registers.

Example

Direct reading of status register 1

PRINT VDP(-1)

The result will be different according the VDP: 0 with MSX2 VDP, 4 with MSX2+ VDP (by default without any other change).

Indirect access

Indirect access to a status register is possible via Control Register 15. The procedure is as following:

1 - Set the number of the status register in Control Register 15 (not required on MSX1)
2 - Read the data of the status register from VDP port #1 (99 in hexadecimal)
3 - Put back 0 in the Control Register 15 (not required on MSX1)

Step 3 is required on MSX2 and higher because after each interrupt, the BIOS reads the status register 0 and ignores the control register 15.

In MSX-BASIC, it can be made by combining the VDP() instruction with value 16 and the INP() instruction to read port &H99.

Example

Indirect reading of status register 1

VDP(16)=1 : A=INP(&H99) : VDP(16)=0 : PRINT A

The result will be different according the VDP: 0 with MSX2 VDP, 4 with MSX2+ VDP (by default without any other change).