Format of the status register:
The VDP status register is a 10-bit register. When you do a 16-bit read from the status register, the lower 10 bits correspond with the contents of the 10-bit status register. The upper 6 bits are undefined (See section below for how to define them). Here's the format of the 10-bit status register, according to my understanding:
Code: Select all
//-------------------------------------------------------------
//| 9 | 8 | 7 | 6 | 5 | 4 | 3 | 2 | 1 | 0 |
//|-----------------------------------------------------------|
//|EMPT |FULL | F |SOVR | COL | ODD | VB | HB | DMA | PAL |
//-------------------------------------------------------------
FULL - FIFO full flag. When there are 4 pending writes held in the 4-word FIFO, this bit is set, otherwise it is clear.
F - Vint occurrance flag. This bit is set when a VINT is being asserted to the M68000. It represents the real-time state of VINT. When the status register is read, this bit is cleared immediately after, at which time, the VINT is no longer asserted. You need to do a status register read in a VINT handler in order to clear this bit to stop the VINT being asserted, otherwise the interrupt handler will
enter again as soon as it exits.
SOVR - Sprite overflow flag. This bit is set when a sprite overflow occurs. I don't have enough information on this flag, and I can't find any good notes right now. Does a dot overflow set this flag as well as too many sprites on a line? Exactly when is this flag set? Does it get set for too many sprites on a line before the line begins? Does a dot overflow get set during the line? What about a dot overflow off the edge of the screen? I do know this flag remains set until the status register is read, after which it is cleared.
COL - Sprite collision flag. This bit is set when two (non-transparent?) pixels in two sprites are found to overlap. Presumably this is set during active scan, at the time the pixel is being drawn, and is never set for any sprites, or any parts of sprites, which are off the edge of the screen, but I don't know this for certain. I do know this flag remains set until the status register is read, after which it is cleared.
ODD - Odd frame in interlace mode. This bit is set if interlacing is currently enabled, and the VDP is rendering the odd frame. I don't know exactly when this bit is set or cleared.
VB - Vertical blank flag. Set if the VDP is currently in vblank. IIRC, there's some good notes on this forum about the timing of when this is set and cleared.
HB - Horizontal blank flag. Set if the VDP is currently in hblank. IIRC, there's some good notes on this forum about the timing of when this is set and cleared.
DMA - Set if a DMA operation is currently in progress. Most likely is NOT set if a write which is supposed to start a DMA operation is currently held in the FIFO, and hasn't been processed yet, so code should look for this flag being clear, and the FIFO empty flag being set, in order to determine when a DMA operation is completed.
PAL - PAL/NTSC mode flag. Asserted if bit 3 of register 1 is set, to enable PAL mode. I assume this represents the real-time state of that bit, and this bit in the status register changes immediately after the register changes.
The upper 6 bits:
When you do a 16-bit read of the status register, the upper 6 bits are not set by the VDP. The value assigned to these bits will be whatever value these bits were set to from the last read the M68000 performed. Writes from the M68000 don't affect these bits, only reads.
Internally, the M68000 has a 16-bit data register it uses to read data from the bus (8-bit and 32-bit reads are both performed as 16-bit reads, see M68000 Users Manual). When performing a read, as the data lines are asserted by an external device, the M68000 latches the bits from the state the data lines are set to, and writes those bits into this internal register. The data is then moved from this internal register into the actual destination for the read.
When the M68000 is attempting to do a read from the bus, the input data lines are tri-state, meaning that the device which is being read must either pull the data lines high or low. If the device fails to pull a data line either high or low, but just leaves it floating, the M68000 never latches a value for the bit corresponding to that line, so the previously latched value is used.
Can anyone expand on this? I'm particularly interested in more information on the sprite overflow/collision flags, and in general, when and how sprite data is processed.