openMSX
Classes | Public Types | Public Member Functions | Static Public Attributes | List of all members
openmsx::VDP Class Referencefinal

Unified implementation of MSX Video Display Processors (VDPs). More...

#include <VDP.hh>

Inheritance diagram for openmsx::VDP:
Inheritance graph
[legend]
Collaboration diagram for openmsx::VDP:
Collaboration graph
[legend]

Classes

struct  BlinkStateCount
 Calculates what 'blinkState' and 'blinkCount' would be at a specific line. More...
 

Public Types

using VDPClock = Clock< TICKS_PER_SECOND >
 
- Public Types inherited from openmsx::MSXDevice
using Devices = std::vector< MSXDevice * >
 

Public Member Functions

 VDP (const DeviceConfig &config)
 
 ~VDP () override
 
void powerUp (EmuTime::param time) override
 This method is called when MSX is powered up.
 
void reset (EmuTime::param time) override
 This method is called on reset.
 
byte readIO (word port, EmuTime::param time) override
 Read a byte from an IO port at a certain time from this device.
 
byte peekIO (word port, EmuTime::param time) const override
 Read a byte from a given IO port.
 
void writeIO (word port, byte value, EmuTime::param time) override
 Write a byte to a given IO port at a certain time to this device.
 
void getExtraDeviceInfo (TclObject &result) const override
 
std::string_view getVersionString () const
 
byte peekRegister (unsigned address) const
 
byte peekStatusReg (byte reg, EmuTime::param time) const
 
void changeRegister (byte reg, byte val, EmuTime::param time)
 VDP control register has changed, work out the consequences.
 
PostProcessorgetPostProcessor () const
 Used by Video9000 to be able to couple the VDP and V9990 output.
 
bool isMSX1VDP () const
 Is this an MSX1 VDP?
 
bool isVDPwithPALonly () const
 Is this a VDP only capable of PAL?
 
bool vdpLacksMirroring () const
 Is this a VDP that lacks mirroring?
 
bool vdpHasPatColMirroring () const
 Is this a VDP that has pattern/color table mirroring?
 
bool isVDPwithVRAMremapping () const
 Does this VDP have VRAM remapping when switching from 4k to 8/16k mode?
 
bool hasYJK () const
 Does this VDP support YJK display?
 
std::array< std::array< uint8_t, 3 >, 16 > getMSX1Palette () const
 Get the (fixed) palette for this MSX1 VDP.
 
DisplayMode getDisplayMode () const
 Get the display mode the VDP is in.
 
VDPVRAMgetVRAM ()
 Get the VRAM object for this VDP.
 
const RawFrameisSuperimposing () const
 Are we currently superimposing? In case of superimpose, returns a pointer to the to-be-superimposed frame.
 
SpriteCheckergetSpriteChecker ()
 Get the sprite checker for this VDP.
 
bool getTransparency () const
 Gets the current transparency setting.
 
bool canSpriteColor0Collide () const
 Can a sprite which has color=0 collide with some other sprite?
 
int getForegroundColor () const
 Gets the current foreground color.
 
byte getBackgroundColor () const
 Gets the current background color.
 
int getBlinkForegroundColor () const
 Gets the current blinking color for blinking text.
 
int getBlinkBackgroundColor () const
 Gets the current blinking color for blinking text.
 
bool getBlinkState () const
 Gets the current blink state.
 
int getPatternTableBase () const
 Get address of pattern table (only for debugger)
 
int getColorTableBase () const
 Get address of color table (only for debugger)
 
int getNameTableBase () const
 Get address of name table (only for debugger)
 
int getSpritePatternTableBase () const
 Get address of pattern table (only for debugger)
 
int getSpriteAttributeTableBase () const
 Get address of color table (only for debugger)
 
int getVramPointer () const
 Get vram pointer (14-bit) (only for debugger)
 
uint16_t getPalette (unsigned index) const
 Gets a palette entry.
 
std::span< const uint16_t, 16 > getPalette () const
 
void setPalette (unsigned index, word grb, EmuTime::param time)
 Sets a palette entry.
 
bool isDisplayEnabled () const
 Is the display enabled? Both the regular border and forced blanking by clearing the display enable bit are considered disabled display.
 
bool spritesEnabled () const
 Are sprites enabled?
 
bool spritesEnabledFast () const
 Same as spritesEnabled(), but may only be called in sprite mode 1 or 2.
 
bool spritesEnabledRegister () const
 Still faster variant (just looks at the sprite-enabled-bit).
 
byte getVerticalScroll () const
 Gets the current vertical scroll (line displayed at Y=0).
 
byte getHorizontalScrollLow () const
 Gets the current horizontal scroll lower bits.
 
byte getHorizontalScrollHigh () const
 Gets the current horizontal scroll higher bits.
 
bool isBorderMasked () const
 Gets the current border mask setting.
 
bool isMultiPageScrolling () const
 Is multi page scrolling enabled? It is considered enabled if both the multi page scrolling flag is enabled and the current page is odd.
 
int getDisplayPage () const
 Only used by debugger.
 
int getLineZero () const
 Get the absolute line number of display line zero.
 
bool isPalTiming () const
 Is PAL timing active? This setting is fixed at start of frame.
 
bool isInterlaced () const
 Get interlace status.
 
bool isFastBlinkEnabled () const
 Get 'fast-blink' status.
 
bool isEvenOddEnabled () const
 Get even/odd page alternation status.
 
bool getEvenOdd () const
 Is the even or odd field being displayed?
 
unsigned getEvenOddMask () const
 Expresses the state of even/odd page interchange in a mask on the line number.
 
unsigned getEvenOddMask (int line) const
 Similar to the above getEvenOddMask() method, but can also be called when 'isFastBlinkEnabled() == true'.
 
BlinkStateCount calculateLineBlinkState (unsigned line) const
 
int getTicksThisFrame (EmuTime::param time) const
 Gets the number of VDP clock ticks (21MHz) elapsed between a given time and the start of this frame.
 
EmuTime::param getFrameStartTime () const
 
int getSpriteSize () const
 Gets the sprite size in pixels (8/16).
 
bool isSpriteMag () const
 Are sprites magnified?
 
bool getCmdBit () const
 Are commands possible in non Graphic modes? (V9958 only)
 
int getLinesPerFrame () const
 Gets the number of lines per frame.
 
int getNumberOfLines () const
 Gets the number of display lines per screen.
 
int getTicksPerFrame () const
 Gets the number of VDP clock ticks (21MHz) per frame.
 
bool isInsideFrame (EmuTime::param time) const
 Is the given timestamp inside the current frame? Mainly useful for debugging, because relevant timestamps should always be inside the current frame.
 
int getHorizontalAdjust () const
 This is a combination of the (horizontal) set adjust register and the YJK-mode bit.
 
int getLeftSprites () const
 Gets the number of VDP clock ticks between start of line and the start of the sprite plane.
 
int getLeftBorder () const
 Gets the number of VDP clock ticks between start of line and the end of the left border.
 
int getRightBorder () const
 Gets the number of VDP clock ticks between start of line and the start of the right border.
 
int getLeftBackground () const
 Gets the number of VDP clock ticks between start of line and the time when the background pixel with X coordinate 0 would be drawn.
 
byte getStatusReg0 () const
 Should only be used by SpriteChecker.
 
void setSpriteStatus (byte value)
 Should only be used by SpriteChecker.
 
bool getVRMode () const
 Returns current VR mode.
 
void setExternalVideoSource (const RawFrame *externalSource)
 Enable superimposing.
 
bool getBrokenCmdTiming () const
 Value of the cmdTiming setting, true means commands have infinite speed.
 
EmuTime getAccessSlot (EmuTime::param time, VDPAccessSlots::Delta delta) const
 Get the earliest access slot that is at least 'delta' cycles in the future.
 
VDPAccessSlots::Calculator getAccessSlotCalculator (EmuTime::param time, EmuTime::param limit) const
 Same as getAccessSlot(), but it can be much faster for repeated calls, e.g.
 
void scheduleCmdSync (EmuTime t)
 Only used when there are commandExecuting-probe listeners.
 
gl::ivec2 getMSXPos (EmuTime::param time) const
 Returns the position of the raster beam expressed in 'narrow' MSX screen coordinates (like 'screen 7').
 
VDPCmdEnginegetCmdEngine ()
 
template<typename Archive >
void serialize (Archive &ar, unsigned version)
 
- Public Member Functions inherited from openmsx::MSXDevice
 MSXDevice (const MSXDevice &)=delete
 
 MSXDevice (MSXDevice &&)=delete
 
MSXDeviceoperator= (const MSXDevice &)=delete
 
MSXDeviceoperator= (MSXDevice &&)=delete
 
virtual ~MSXDevice ()=0
 
const HardwareConfiggetHardwareConfig () const
 Returns the hardwareconfig this device belongs to.
 
void testRemove (std::span< const std::unique_ptr< MSXDevice > > removed) const
 Checks whether this device can be removed (no other device has a reference to it).
 
virtual byte readIRQVector ()
 Gets IRQ vector used in IM2.
 
virtual void powerDown (EmuTime::param time)
 This method is called when MSX is powered down.
 
virtual const std::string & getName () const
 Returns a human-readable name for this device.
 
virtual void getNameList (TclObject &result) const
 Returns list of name(s) of this device.
 
void getDeviceInfo (TclObject &result) const
 Get device info.
 
void getVisibleMemRegion (unsigned &base, unsigned &size) const
 Returns the range where this device is visible in memory.
 
virtual byte readMem (word address, EmuTime::param time)
 Read a byte from a location at a certain time from this device.
 
virtual void writeMem (word address, byte value, EmuTime::param time)
 Write a given byte to a given location at a certain time to this device.
 
virtual const bytegetReadCacheLine (word start) const
 Test that the memory in the interval [start, start + CacheLine::SIZE) is cacheable for reading.
 
virtual bytegetWriteCacheLine (word start)
 Test that the memory in the interval [start, start + CacheLine::SIZE) is cacheable for writing.
 
virtual byte peekMem (word address, EmuTime::param time) const
 Read a byte from a given memory location.
 
virtual void globalWrite (word address, byte value, EmuTime::param time)
 Global writes.
 
virtual void globalRead (word address, EmuTime::param time)
 Global reads.
 
void invalidateDeviceRWCache ()
 Calls MSXCPUInterface::invalidateXXCache() for the specific (part of) the slot that this device is located in.
 
void invalidateDeviceRCache ()
 
void invalidateDeviceWCache ()
 
void invalidateDeviceRWCache (unsigned start, unsigned size)
 
void invalidateDeviceRCache (unsigned start, unsigned size)
 
void invalidateDeviceWCache (unsigned start, unsigned size)
 
void fillDeviceRWCache (unsigned start, unsigned size, byte *rwData)
 Calls MSXCPUInterface::fillXXCache() for the specific (part of) the slot that this device is located in.
 
void fillDeviceRWCache (unsigned start, unsigned size, const byte *rData, byte *wData)
 
void fillDeviceRCache (unsigned start, unsigned size, const byte *rData)
 
void fillDeviceWCache (unsigned start, unsigned size, byte *wData)
 
MSXMotherBoardgetMotherBoard () const
 Get the mother board this device belongs to.
 
const XMLElementgetDeviceConfig () const
 Get the configuration section for this device.
 
const DeviceConfiggetDeviceConfig2 () const
 
const DevicesgetReferences () const
 Get the device references that are specified for this device.
 
EmuTime::param getCurrentTime () const
 
MSXCPUgetCPU () const
 
MSXCPUInterfacegetCPUInterface () const
 
SchedulergetScheduler () const
 
MSXCliCommgetCliComm () const
 
ReactorgetReactor () const
 
CommandControllergetCommandController () const
 
PluggingControllergetPluggingController () const
 
LedStatusgetLedStatus () const
 
template<typename Archive >
void serialize (Archive &ar, unsigned version)
 

Static Public Attributes

static constexpr int TICKS_PER_SECOND = 3579545 * 6
 Number of VDP clock ticks per second.
 
static constexpr int TICKS_PER_LINE = 1368
 Number of VDP clock ticks per line.
 
- Static Public Attributes inherited from openmsx::MSXDevice
static std::array< byte, 0x10000 > unmappedRead
 
static std::array< byte, 0x10000 > unmappedWrite
 

Additional Inherited Members

- Protected Member Functions inherited from openmsx::MSXDevice
 MSXDevice (const DeviceConfig &config, std::string_view name)
 Every MSXDevice has a config entry; this constructor gets some device properties from that config entry.
 
 MSXDevice (const DeviceConfig &config)
 
virtual void init ()
 
virtual unsigned getBaseSizeAlignment () const
 The 'base' and 'size' attribute values need to be at least aligned to CacheLine::SIZE.
 
virtual bool allowUnaligned () const
 By default we don't allow unaligned <mem> specifications in the config file.
 
byte getPrimarySlot () const
 
- Protected Attributes inherited from openmsx::MSXDevice
std::string deviceName
 

Detailed Description

Unified implementation of MSX Video Display Processors (VDPs).

MSX1 VDP is Texas Instruments TMS9918A or TMS9928A. MSX2 VDP is Yamaha V9938. MSX2+ and turbo R VDP is Yamaha V9958.

Current implementation is written by Maarten ter Huurne, with some contributions from other openMSX developers. The first implementation was based on Sean Young's code from MESS, which was in turn based on code by Mike Balfour. Integration of MESS code into openMSX was done by David Heremans.

All undocumented features as described in the following file should be emulated: http://www.msxnet.org/tech/tms9918a.txt

This class is the VDP core, it uses a separate Renderer to convert the VRAM contents into pixels on the host machine. Communicates with the Renderer through a pull variant of the Observer pattern: a VDP object fires events when its state changes, the Renderer can retrieve the new state if necessary by calling methods on the VDP object.

A note about timing: the start of a frame or line is defined as the starting time of the corresponding sync (vsync, hsync).

Definition at line 65 of file VDP.hh.

Member Typedef Documentation

◆ VDPClock

Definition at line 72 of file VDP.hh.

Constructor & Destructor Documentation

◆ VDP()

openmsx::VDP::VDP ( const DeviceConfig config)
explicit

◆ ~VDP()

openmsx::VDP::~VDP ( )
override

Definition at line 221 of file VDP.cc.

References openmsx::Subject< T >::detach(), and openmsx::Display::detach().

Member Function Documentation

◆ calculateLineBlinkState()

BlinkStateCount openmsx::VDP::calculateLineBlinkState ( unsigned  line) const
inline

Definition at line 485 of file VDP.hh.

References isFastBlinkEnabled().

Referenced by getEvenOddMask().

◆ canSpriteColor0Collide()

bool openmsx::VDP::canSpriteColor0Collide ( ) const
inline

Can a sprite which has color=0 collide with some other sprite?

Definition at line 195 of file VDP.hh.

References getTransparency(), and isMSX1VDP().

◆ changeRegister()

void openmsx::VDP::changeRegister ( byte  reg,
byte  val,
EmuTime::param  time 
)

◆ getAccessSlot()

EmuTime openmsx::VDP::getAccessSlot ( EmuTime::param  time,
VDPAccessSlots::Delta  delta 
) const

Get the earliest access slot that is at least 'delta' cycles in the future.

Definition at line 890 of file VDP.cc.

References openmsx::VDPAccessSlots::getAccessSlot(), and getFrameStartTime().

◆ getAccessSlotCalculator()

VDPAccessSlots::Calculator openmsx::VDP::getAccessSlotCalculator ( EmuTime::param  time,
EmuTime::param  limit 
) const

Same as getAccessSlot(), but it can be much faster for repeated calls, e.g.

in the implementation of VDP commands. However it does have some limitations:

  • The returned calculator only remains valid for as long as the VDP access timing remains the same (display/sprite enable).
  • The calculator needs to see all time changes. (So this means that in every VDPCmd::execute() method you need to construct a new calculator).

Definition at line 896 of file VDP.cc.

References openmsx::VDPAccessSlots::getCalculator(), and getFrameStartTime().

◆ getBackgroundColor()

byte openmsx::VDP::getBackgroundColor ( ) const
inline

Gets the current background color.

Returns
Color index. In Graphic5 mode, the range is [0..15]; bits 3-2 contains the color for even pixels, bits 1-0 contains the color for odd pixels. In Graphic7 mode with YJK off, the range is [0..255]. In other modes, the range is [0..15].

Definition at line 219 of file VDP.hh.

References openmsx::DisplayMode::getByte(), and openmsx::DisplayMode::GRAPHIC7.

Referenced by openmsx::SDLRasterizer::setDisplayMode(), openmsx::SDLRasterizer::setPalette(), openmsx::SDLRasterizer::setSuperimposeVideoFrame(), openmsx::SDLRasterizer::setTransparency(), and openmsx::PixelRenderer::updatePalette().

◆ getBlinkBackgroundColor()

int openmsx::VDP::getBlinkBackgroundColor ( ) const
inline

Gets the current blinking color for blinking text.

Returns
Color index [0..15].

Definition at line 238 of file VDP.hh.

◆ getBlinkForegroundColor()

int openmsx::VDP::getBlinkForegroundColor ( ) const
inline

Gets the current blinking color for blinking text.

Returns
Color index [0..15].

Definition at line 231 of file VDP.hh.

◆ getBlinkState()

bool openmsx::VDP::getBlinkState ( ) const
inline

Gets the current blink state.

Returns
True iff alternate colors / page should be displayed.

Definition at line 245 of file VDP.hh.

◆ getBrokenCmdTiming()

bool openmsx::VDP::getBrokenCmdTiming ( ) const
inline

Value of the cmdTiming setting, true means commands have infinite speed.

Definition at line 663 of file VDP.hh.

◆ getCmdBit()

bool openmsx::VDP::getCmdBit ( ) const
inline

Are commands possible in non Graphic modes? (V9958 only)

Returns
True iff CMD bit set.

Definition at line 547 of file VDP.hh.

Referenced by openmsx::VDPCmdEngine::reset().

◆ getCmdEngine()

VDPCmdEngine & openmsx::VDP::getCmdEngine ( )
inline

Definition at line 736 of file VDP.hh.

◆ getColorTableBase()

int openmsx::VDP::getColorTableBase ( ) const
inline

Get address of color table (only for debugger)

Definition at line 254 of file VDP.hh.

◆ getDisplayMode()

DisplayMode openmsx::VDP::getDisplayMode ( ) const
inline

◆ getDisplayPage()

int openmsx::VDP::getDisplayPage ( ) const
inline

Only used by debugger.

Returns
page 0-3

Definition at line 375 of file VDP.hh.

◆ getEvenOdd()

bool openmsx::VDP::getEvenOdd ( ) const
inline

Is the even or odd field being displayed?

Returns
True iff this field should be displayed half a line lower.

Definition at line 439 of file VDP.hh.

Referenced by openmsx::PixelRenderer::frameStart(), and openmsx::SDLRasterizer::frameStart().

◆ getEvenOddMask() [1/2]

unsigned openmsx::VDP::getEvenOddMask ( ) const
inline

Expresses the state of even/odd page interchange in a mask on the line number.

If even/odd interchange is active, for some frames lines 256..511 (page 1) are replaced by 0..255 (page 0) and 768..1023 (page 3, if applicable) by 512..767 (page 2). Together with the interlace setting this can be used to create an interlaced display. Even/odd interchange can also happen because of the 'blink' feature in bitmap modes.

Precondition
!isFastBlinkEnabled()
Returns
Line number mask that expressed even/odd state.

Definition at line 454 of file VDP.hh.

References isFastBlinkEnabled().

Referenced by openmsx::SDLRasterizer::drawDisplay(), and getEvenOddMask().

◆ getEvenOddMask() [2/2]

unsigned openmsx::VDP::getEvenOddMask ( int  line) const
inline

Similar to the above getEvenOddMask() method, but can also be called when 'isFastBlinkEnabled() == true'.

In the latter case the timing is based on lines instead of frames. This means the result is no longer fixed per frame, and thus this method takes an additional line parameter.

Definition at line 467 of file VDP.hh.

References calculateLineBlinkState(), getEvenOddMask(), and isFastBlinkEnabled().

◆ getExtraDeviceInfo()

void openmsx::VDP::getExtraDeviceInfo ( TclObject result) const
overridevirtual
See also
getDeviceInfo() Default implementation does nothing. Subclasses can override this method to add extra info (like subtypes).

Reimplemented from openmsx::MSXDevice.

Definition at line 746 of file VDP.cc.

References openmsx::TclObject::addDictKeyValues(), and getVersionString().

◆ getForegroundColor()

int openmsx::VDP::getForegroundColor ( ) const
inline

Gets the current foreground color.

Returns
Color index [0..15].

Definition at line 207 of file VDP.hh.

◆ getFrameStartTime()

EmuTime::param openmsx::VDP::getFrameStartTime ( ) const
inline

◆ getHorizontalAdjust()

int openmsx::VDP::getHorizontalAdjust ( ) const
inline

This is a combination of the (horizontal) set adjust register and the YJK-mode bit.

Definition at line 587 of file VDP.hh.

◆ getHorizontalScrollHigh()

byte openmsx::VDP::getHorizontalScrollHigh ( ) const
inline

Gets the current horizontal scroll higher bits.

This value determines how many 8-pixel steps the background is rotated to the left.

Returns
Horizontal scroll high register value.

Definition at line 349 of file VDP.hh.

Referenced by openmsx::SDLRasterizer::drawDisplay().

◆ getHorizontalScrollLow()

byte openmsx::VDP::getHorizontalScrollLow ( ) const
inline

Gets the current horizontal scroll lower bits.

Rather than actually scrolling the screen, this setting shifts the screen 0..7 bytes to the right.

Returns
Horizontal scroll low register value.

Definition at line 340 of file VDP.hh.

Referenced by getLeftBackground().

◆ getLeftBackground()

int openmsx::VDP::getLeftBackground ( ) const
inline

Gets the number of VDP clock ticks between start of line and the time when the background pixel with X coordinate 0 would be drawn.

This includes extra pixels of horizontal scroll low, but disregards border mask.

Definition at line 626 of file VDP.hh.

References getHorizontalScrollLow(), and getLeftSprites().

Referenced by openmsx::SDLRasterizer::drawDisplay().

◆ getLeftBorder()

int openmsx::VDP::getLeftBorder ( ) const
inline

Gets the number of VDP clock ticks between start of line and the end of the left border.

Does not include extra pixels of horizontal scroll low, since those are not actually border pixels (sprites appear in front of them).

Definition at line 609 of file VDP.hh.

References getLeftSprites(), and isBorderMasked().

◆ getLeftSprites()

int openmsx::VDP::getLeftSprites ( ) const
inline

Gets the number of VDP clock ticks between start of line and the start of the sprite plane.

The location of the sprite plane is not influenced by horizontal scroll or border mask. TODO: Leave out the text mode case, since there are no sprites in text mode?

Definition at line 598 of file VDP.hh.

References openmsx::DisplayMode::isTextMode().

Referenced by openmsx::SDLRasterizer::drawSprites(), getLeftBackground(), getLeftBorder(), getMSXPos(), and getRightBorder().

◆ getLinesPerFrame()

int openmsx::VDP::getLinesPerFrame ( ) const
inline

Gets the number of lines per frame.

Definition at line 553 of file VDP.hh.

Referenced by getTicksPerFrame().

◆ getLineZero()

int openmsx::VDP::getLineZero ( ) const
inline

Get the absolute line number of display line zero.

Usually this is equal to the height of the top border, but not so during overscan.

Definition at line 383 of file VDP.hh.

References TICKS_PER_LINE.

Referenced by getMSXPos().

◆ getMSX1Palette()

std::array< std::array< uint8_t, 3 >, 16 > openmsx::VDP::getMSX1Palette ( ) const

Get the (fixed) palette for this MSX1 VDP.

Don't use this if it's not an MSX1 VDP!

Returns
an array of 16 RGB triplets

Definition at line 1544 of file VDP.cc.

References openmsx::B, Math::clipIntToByte(), openmsx::MSXDevice::getDeviceConfig(), isMSX1VDP(), and xrange().

◆ getMSXPos()

gl::ivec2 openmsx::VDP::getMSXPos ( EmuTime::param  time) const
inline

Returns the position of the raster beam expressed in 'narrow' MSX screen coordinates (like 'screen 7').

Horizontally: pixels in the left border have a negative coordinate, pixels in the right border have a coordinate bigger than or equal to 512. For MSX screen modes that are 256 pixels wide (e.g. 'screen 5') divide the x-coordinate by 2. For text modes (aka screen 0, width 40/80) subtract 16 from the x-coordinate (= (512-480)/2), and divide by 2 (for width 40).

Vertically: lines in the top border have negative coordinates, lines in the bottom border have coordinates bigger or equal to 192 or 212.

Definition at line 729 of file VDP.hh.

References getLeftSprites(), getLineZero(), getTicksThisFrame(), and TICKS_PER_LINE.

◆ getNameTableBase()

int openmsx::VDP::getNameTableBase ( ) const
inline

Get address of name table (only for debugger)

Definition at line 258 of file VDP.hh.

◆ getNumberOfLines()

int openmsx::VDP::getNumberOfLines ( ) const
inline

Gets the number of display lines per screen.

Returns
192 or 212.

Definition at line 560 of file VDP.hh.

Referenced by peekStatusReg().

◆ getPalette() [1/2]

std::span< const uint16_t, 16 > openmsx::VDP::getPalette ( ) const
inline

Definition at line 282 of file VDP.hh.

◆ getPalette() [2/2]

uint16_t openmsx::VDP::getPalette ( unsigned  index) const
inline

Gets a palette entry.

Parameters
indexThe index [0..15] in the palette.
Returns
Color value in the format of the palette registers: bit 10..8 is green, bit 6..4 is red and bit 2..0 is blue.

Definition at line 279 of file VDP.hh.

Referenced by openmsx::ImGuiPalette::getPalette(), and openmsx::ImGuiPalette::paint().

◆ getPatternTableBase()

int openmsx::VDP::getPatternTableBase ( ) const
inline

Get address of pattern table (only for debugger)

Definition at line 250 of file VDP.hh.

◆ getPostProcessor()

PostProcessor * openmsx::VDP::getPostProcessor ( ) const

Used by Video9000 to be able to couple the VDP and V9990 output.

Can return nullptr in case of renderer=none. This value can change over the lifetime of the VDP object (on renderer switch).

Definition at line 247 of file VDP.cc.

◆ getRightBorder()

int openmsx::VDP::getRightBorder ( ) const
inline

Gets the number of VDP clock ticks between start of line and the start of the right border.

Definition at line 616 of file VDP.hh.

References getLeftSprites(), and openmsx::DisplayMode::isTextMode().

◆ getSpriteAttributeTableBase()

int openmsx::VDP::getSpriteAttributeTableBase ( ) const
inline

Get address of color table (only for debugger)

Definition at line 266 of file VDP.hh.

◆ getSpriteChecker()

SpriteChecker & openmsx::VDP::getSpriteChecker ( )
inline

Get the sprite checker for this VDP.

Definition at line 182 of file VDP.hh.

◆ getSpritePatternTableBase()

int openmsx::VDP::getSpritePatternTableBase ( ) const
inline

Get address of pattern table (only for debugger)

Definition at line 262 of file VDP.hh.

◆ getSpriteSize()

int openmsx::VDP::getSpriteSize ( ) const
inline

Gets the sprite size in pixels (8/16).

Definition at line 534 of file VDP.hh.

◆ getStatusReg0()

byte openmsx::VDP::getStatusReg0 ( ) const
inline

Should only be used by SpriteChecker.

Returns the current value of status register 0 (both the F-flag and the sprite related bits).

Definition at line 633 of file VDP.hh.

Referenced by openmsx::SpriteChecker::resetStatus().

◆ getTicksPerFrame()

int openmsx::VDP::getTicksPerFrame ( ) const
inline

Gets the number of VDP clock ticks (21MHz) per frame.

Definition at line 566 of file VDP.hh.

References getLinesPerFrame(), and TICKS_PER_LINE.

Referenced by isInsideFrame(), and peekStatusReg().

◆ getTicksThisFrame()

int openmsx::VDP::getTicksThisFrame ( EmuTime::param  time) const
inline

Gets the number of VDP clock ticks (21MHz) elapsed between a given time and the start of this frame.

Definition at line 524 of file VDP.hh.

References openmsx::Clock< FREQ_NUM, FREQ_DENOM >::getTicksTill_fast().

Referenced by getMSXPos(), isInsideFrame(), and peekStatusReg().

◆ getTransparency()

bool openmsx::VDP::getTransparency ( ) const
inline

◆ getVersionString()

std::string_view openmsx::VDP::getVersionString ( ) const

Definition at line 735 of file VDP.cc.

References openmsx::XMLElement::findChild(), and openmsx::MSXDevice::getDeviceConfig().

Referenced by getExtraDeviceInfo().

◆ getVerticalScroll()

byte openmsx::VDP::getVerticalScroll ( ) const
inline

Gets the current vertical scroll (line displayed at Y=0).

Returns
Vertical scroll register value.

Definition at line 331 of file VDP.hh.

◆ getVRAM()

VDPVRAM & openmsx::VDP::getVRAM ( )
inline

Get the VRAM object for this VDP.

Definition at line 162 of file VDP.hh.

◆ getVramPointer()

int openmsx::VDP::getVramPointer ( ) const
inline

Get vram pointer (14-bit) (only for debugger)

Definition at line 270 of file VDP.hh.

◆ getVRMode()

bool openmsx::VDP::getVRMode ( ) const
inline

Returns current VR mode.

false -> VR=0, true -> VR=1

Definition at line 651 of file VDP.hh.

Referenced by openmsx::VDPVRAM::serialize().

◆ hasYJK()

bool openmsx::VDP::hasYJK ( ) const
inline

Does this VDP support YJK display?

Returns
True for V9958, false otherwise.

Definition at line 143 of file VDP.hh.

◆ isBorderMasked()

bool openmsx::VDP::isBorderMasked ( ) const
inline

Gets the current border mask setting.

Border mask extends the left border by 8 pixels if enabled. This is a V9958 feature, on older VDPs it always returns false.

Returns
true iff enabled.

Definition at line 358 of file VDP.hh.

Referenced by getLeftBorder().

◆ isDisplayEnabled()

bool openmsx::VDP::isDisplayEnabled ( ) const
inline

Is the display enabled? Both the regular border and forced blanking by clearing the display enable bit are considered disabled display.

Returns
true iff enabled.

Definition at line 299 of file VDP.hh.

Referenced by openmsx::PixelRenderer::reInit().

◆ isEvenOddEnabled()

bool openmsx::VDP::isEvenOddEnabled ( ) const
inline

Get even/odd page alternation status.

Interlace means the odd fields are displayed half a line lower than the even fields. Together with even/odd page alternation this can be used to create an interlaced display. This setting is NOT fixed at start of frame. TODO: Find out how real VDP does it. If it fixes it at start of frame, so should we. If it handles it dynamically (my guess), then an update method should be added on the Renderer interface.

Returns
True iff even/odd page alternation is enabled.

Definition at line 431 of file VDP.hh.

References isFastBlinkEnabled().

Referenced by openmsx::PixelRenderer::frameEnd(), and openmsx::PixelRenderer::frameStart().

◆ isFastBlinkEnabled()

bool openmsx::VDP::isFastBlinkEnabled ( ) const
inline

Get 'fast-blink' status.

Normally blinking timing (alternating between pages) is based on frames. Though the V99x8 has an undocumented feature which changes this timing to lines. Sometimes this is called the "Cadari" feature after Luciano Cadari who discovered it.

See ticket#1091: "Support for undocumented V99x8 register 1 bit 2" https://github.com/openMSX/openMSX/issues/1091 for test cases and links to more information.

Definition at line 416 of file VDP.hh.

Referenced by calculateLineBlinkState(), getEvenOddMask(), getEvenOddMask(), and isEvenOddEnabled().

◆ isInsideFrame()

bool openmsx::VDP::isInsideFrame ( EmuTime::param  time) const
inline

Is the given timestamp inside the current frame? Mainly useful for debugging, because relevant timestamps should always be inside the current frame.

The end time of a frame is still considered inside, to support the case when the given timestamp is exclusive itself: a typically "limit" variable.

Parameters
timeTimestamp to check.
Returns
True iff the timestamp is inside the current frame.

Definition at line 579 of file VDP.hh.

References getTicksPerFrame(), getTicksThisFrame(), and openmsx::Clock< FREQ_NUM, FREQ_DENOM >::getTime().

Referenced by openmsx::VDPVRAM::cmdWrite(), openmsx::VDPVRAM::cpuRead(), openmsx::VDPVRAM::cpuWrite(), readIO(), openmsx::VDPVRAM::sync(), openmsx::VDPVRAM::updateDisplayEnabled(), openmsx::VDPVRAM::updateDisplayMode(), openmsx::VDPVRAM::updateSpritesEnabled(), and writeIO().

◆ isInterlaced()

bool openmsx::VDP::isInterlaced ( ) const
inline

Get interlace status.

Interlace means the odd fields are displayed half a line lower than the even fields. Together with even/odd page alternation this can be used to create an interlaced display. This setting is fixed at start of frame.

Returns
True iff interlace is enabled.

Definition at line 402 of file VDP.hh.

Referenced by openmsx::PixelRenderer::frameEnd(), openmsx::PixelRenderer::frameStart(), and openmsx::SDLRasterizer::frameStart().

◆ isMSX1VDP()

bool openmsx::VDP::isMSX1VDP ( ) const
inline

◆ isMultiPageScrolling()

bool openmsx::VDP::isMultiPageScrolling ( ) const
inline

Is multi page scrolling enabled? It is considered enabled if both the multi page scrolling flag is enabled and the current page is odd.

Scrolling wraps into the lower even page.

Returns
true iff enabled.

Definition at line 368 of file VDP.hh.

Referenced by openmsx::SDLRasterizer::drawDisplay().

◆ isPalTiming()

bool openmsx::VDP::isPalTiming ( ) const
inline

Is PAL timing active? This setting is fixed at start of frame.

Returns
True if PAL timing, false if NTSC timing.

Definition at line 391 of file VDP.hh.

Referenced by openmsx::SDLRasterizer::frameStart().

◆ isSpriteMag()

bool openmsx::VDP::isSpriteMag ( ) const
inline

Are sprites magnified?

Definition at line 540 of file VDP.hh.

◆ isSuperimposing()

const RawFrame * openmsx::VDP::isSuperimposing ( ) const
inline

Are we currently superimposing? In case of superimpose, returns a pointer to the to-be-superimposed frame.

Returns nullptr if superimpose is not active.

Definition at line 170 of file VDP.hh.

Referenced by openmsx::SDLRasterizer::setBackgroundColor(), openmsx::SDLRasterizer::setDisplayMode(), openmsx::SDLRasterizer::setPalette(), and openmsx::SDLRasterizer::setTransparency().

◆ isVDPwithPALonly()

bool openmsx::VDP::isVDPwithPALonly ( ) const
inline

Is this a VDP only capable of PAL?

Returns
True iff this is a PAL only VDP

Definition at line 115 of file VDP.hh.

◆ isVDPwithVRAMremapping()

bool openmsx::VDP::isVDPwithVRAMremapping ( ) const
inline

Does this VDP have VRAM remapping when switching from 4k to 8/16k mode?

Returns
True iff this is a VDP with VRAM remapping

Definition at line 136 of file VDP.hh.

Referenced by changeRegister().

◆ peekIO()

byte openmsx::VDP::peekIO ( word  port,
EmuTime::param  time 
) const
overridevirtual

Read a byte from a given IO port.

Reading via this method has no side effects (doesn't change the device status). If safe reading is not possible this method returns 0xFF. This method is not used by the emulation. It can however be used by a debugger. The default implementation just returns 0xFF.

Reimplemented from openmsx::MSXDevice.

Definition at line 1005 of file VDP.cc.

Referenced by openmsx::MSXMatsushita::peekIO().

◆ peekRegister()

byte openmsx::VDP::peekRegister ( unsigned  address) const

Definition at line 751 of file VDP.cc.

◆ peekStatusReg()

byte openmsx::VDP::peekStatusReg ( byte  reg,
EmuTime::param  time 
) const

◆ powerUp()

void openmsx::VDP::powerUp ( EmuTime::param  time)
overridevirtual

This method is called when MSX is powered up.

The default implementation calls reset(), this is usually ok.

Parameters
timeThe moment in time the power up occurs.

Reimplemented from openmsx::MSXDevice.

Definition at line 319 of file VDP.cc.

References reset().

Referenced by VDP().

◆ readIO()

byte openmsx::VDP::readIO ( word  port,
EmuTime::param  time 
)
overridevirtual

Read a byte from an IO port at a certain time from this device.

The default implementation returns 255.

Reimplemented from openmsx::MSXDevice.

Definition at line 985 of file VDP.cc.

References isInsideFrame(), isMSX1VDP(), and UNREACHABLE.

Referenced by openmsx::MSXMatsushita::readIO().

◆ reset()

void openmsx::VDP::reset ( EmuTime::param  time)
overridevirtual

This method is called on reset.

Default implementation does nothing.

Reimplemented from openmsx::MSXDevice.

Definition at line 325 of file VDP.cc.

Referenced by powerUp().

◆ scheduleCmdSync()

void openmsx::VDP::scheduleCmdSync ( EmuTime  t)
inline

Only used when there are commandExecuting-probe listeners.

Call to announce a (lower-bound) estimate for when the VDP command will finish executing. In response the VDP will schedule a synchronization point to sync with VDPCmdEngine emulation.

Normally it's not required to pro-actively sync with the end of a VDP command. Instead these sync happen reactively on VDP status reads (e.g. polling the CE bit) or on VRAM reads (rendering or CPU VRAM read). This is in contrast with the V9990 where we DO need an active sync because the V9990 can generate an IRQ on command end.

Though when the VDP.commandExecuting probe is in use we do want a reasonably timing accurate reaction of that probe. So (only) then we do add the extra syncs (thus with extra emulation overhead when you use that probe).

Definition at line 700 of file VDP.hh.

References openmsx::Clock< TICKS_PER_SECOND >::duration(), openmsx::MSXDevice::getCurrentTime(), and t.

◆ serialize()

template<typename Archive >
void openmsx::VDP::serialize ( Archive &  ar,
unsigned  version 
)

◆ setExternalVideoSource()

void openmsx::VDP::setExternalVideoSource ( const RawFrame externalSource)
inline

Enable superimposing.

Definition at line 657 of file VDP.hh.

◆ setPalette()

void openmsx::VDP::setPalette ( unsigned  index,
word  grb,
EmuTime::param  time 
)

Sets a palette entry.

Parameters
indexThe index [0..15] in the palette.
grbvalue in the format of the palette registers: bit 10..8 is green, bit 6..4 is red and bit 2..0 is blue.
timeMoment in time palette change occurs.

Definition at line 762 of file VDP.cc.

Referenced by openmsx::ImGuiPalette::paint(), and writeIO().

◆ setSpriteStatus()

void openmsx::VDP::setSpriteStatus ( byte  value)
inline

Should only be used by SpriteChecker.

Change the sprite related bits of status register 0 (leaves the F-flag unchanged). Bit 6 (5S) is set when more than 4 (sprite mode 1) or 8 (sprite mode 2) sprites occur on the same line. Bit 5 (C) is set when sprites collide. Bit 4..0 (5th sprite number) contains the number of the first sprite to exceed the limit per line.

Definition at line 643 of file VDP.hh.

Referenced by openmsx::SpriteChecker::reset(), and openmsx::SpriteChecker::resetStatus().

◆ spritesEnabled()

bool openmsx::VDP::spritesEnabled ( ) const
inline

Are sprites enabled?

Returns
True iff blanking is off, the current mode supports sprites and sprites are not disabled.

Definition at line 307 of file VDP.hh.

References openmsx::DisplayMode::getSpriteMode(), and isMSX1VDP().

◆ spritesEnabledFast()

bool openmsx::VDP::spritesEnabledFast ( ) const
inline

Same as spritesEnabled(), but may only be called in sprite mode 1 or 2.

Is a tiny bit faster.

Definition at line 316 of file VDP.hh.

References openmsx::DisplayMode::getSpriteMode(), and isMSX1VDP().

◆ spritesEnabledRegister()

bool openmsx::VDP::spritesEnabledRegister ( ) const
inline

Still faster variant (just looks at the sprite-enabled-bit).

But only valid in sprite mode 1/2 with screen enabled.

Definition at line 324 of file VDP.hh.

◆ vdpHasPatColMirroring()

bool openmsx::VDP::vdpHasPatColMirroring ( ) const
inline

Is this a VDP that has pattern/color table mirroring?

Returns
True iff this VDP has pattern/color table mirroring

Definition at line 129 of file VDP.hh.

Referenced by changeRegister().

◆ vdpLacksMirroring()

bool openmsx::VDP::vdpLacksMirroring ( ) const
inline

Is this a VDP that lacks mirroring?

Returns
True iff this VDP lacks the screen 2 mirrored mode

Definition at line 122 of file VDP.hh.

◆ writeIO()

void openmsx::VDP::writeIO ( word  port,
byte  value,
EmuTime::param  time 
)
overridevirtual

Write a byte to a given IO port at a certain time to this device.

The default implementation ignores the write (does nothing)

Reimplemented from openmsx::MSXDevice.

Definition at line 645 of file VDP.cc.

References changeRegister(), isInsideFrame(), isMSX1VDP(), setPalette(), and openmsx::MSXCPU::waitCyclesZ80().

Referenced by openmsx::MSXMatsushita::writeIO().

Member Data Documentation

◆ TICKS_PER_LINE

constexpr int openmsx::VDP::TICKS_PER_LINE = 1368
staticconstexpr

◆ TICKS_PER_SECOND

constexpr int openmsx::VDP::TICKS_PER_SECOND = 3579545 * 6
staticconstexpr

Number of VDP clock ticks per second.

Definition at line 71 of file VDP.hh.


The documentation for this class was generated from the following files: