openMSX
Public Member Functions | Friends | List of all members
openmsx::VRAMWindow Class Reference

Specifies an address range in the VRAM. More...

#include <VDPVRAM.hh>

Public Member Functions

 VRAMWindow (const VRAMWindow &)=delete
 
 VRAMWindow (VRAMWindow &&)=delete
 
VRAMWindowoperator= (const VRAMWindow &)=delete
 
VRAMWindowoperator= (VRAMWindow &&)=delete
 
unsigned getMask () const
 Gets the mask for this window.
 
void setMask (unsigned newBaseMask, unsigned newIndexMask, unsigned newSizeMask, EmuTime::param time)
 Sets the mask and enables this window.
 
void setMask (unsigned newBaseMask, unsigned newIndexMask, EmuTime::param time)
 Same as above, but 'sizeMask' doesn't change.
 
void disable (EmuTime::param time)
 Disable this window: no address will be considered inside.
 
bool isContinuous (unsigned index, unsigned size) const
 Is the given index range continuous in VRAM (iow there's no mirroring) Only if the range is continuous it's allowed to call getReadArea().
 
bool isContinuous (unsigned mask) const
 Alternative version to check whether a region is continuous in VRAM.
 
template<size_t size>
std::span< const byte, size > getReadArea (unsigned index) const
 Gets a span of a contiguous part of the VRAM.
 
template<size_t size>
std::pair< std::span< const byte, size/2 >, std::span< const byte, size/2 > > getReadAreaPlanar (unsigned index) const
 Similar to getReadArea(), but now with planar addressing mode.
 
byte readNP (unsigned index) const
 Reads a byte from VRAM in its current state.
 
byte readPlanar (unsigned index) const
 Similar to readNP, but now with planar addressing.
 
bool hasObserver () const
 Is there an observer registered for this window?
 
void setObserver (VRAMObserver *newObserver)
 Register an observer on this VRAM window.
 
void resetObserver ()
 Unregister the observer of this VRAM window.
 
bool isInside (unsigned address) const
 Test whether an address is inside this window.
 
void notify (unsigned address, EmuTime::param time)
 Notifies the observer of this window of a VRAM change, if the changes address is inside this window.
 
void setSizeMask (unsigned newSizeMask, EmuTime::param time)
 Inform VRAMWindow of changed sizeMask.
 
template<typename Archive >
void serialize (Archive &ar, unsigned version)
 

Friends

class VDPVRAM
 Only VDPVRAM may construct VRAMWindow objects.
 

Detailed Description

Specifies an address range in the VRAM.

A VDP subsystem can use this to put a claim on a certain area. For example, the owner of a read window will be notified before writes to the corresponding area are commited. The address range is specified by a mask and is not necessarily continuous. See "doc/vram-addressing.txt" for details. TODO: Rename to "Table"? That's the term the VDP data book uses. Maybe have two classes: "Table" for tables, using a mask, and "Window" for the command engine, using an interval.

Definition at line 134 of file VDPVRAM.hh.

Constructor & Destructor Documentation

◆ VRAMWindow() [1/2]

openmsx::VRAMWindow::VRAMWindow ( const VRAMWindow )
delete

◆ VRAMWindow() [2/2]

openmsx::VRAMWindow::VRAMWindow ( VRAMWindow &&  )
delete

Member Function Documentation

◆ disable()

void openmsx::VRAMWindow::disable ( EmuTime::param  time)
inline

Disable this window: no address will be considered inside.

Parameters
timeThe moment in emulated time this change occurs.

Definition at line 192 of file VDPVRAM.hh.

References openmsx::VRAMObserver::updateWindow().

◆ getMask()

unsigned openmsx::VRAMWindow::getMask ( ) const
inline

Gets the mask for this window.

Should only be called if the window is enabled. TODO: Only used by dirty checking. Maybe a new dirty checking approach can obsolete this method?

Definition at line 147 of file VDPVRAM.hh.

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

◆ getReadArea()

template<size_t size>
std::span< const byte, size > openmsx::VRAMWindow::getReadArea ( unsigned  index) const
inline

Gets a span of a contiguous part of the VRAM.

The region is [index, index + size) inside the current window.

Parameters
indexIndex in window

Definition at line 228 of file VDPVRAM.hh.

References isContinuous().

◆ getReadAreaPlanar()

template<size_t size>
std::pair< std::span< const byte, size/2 >, std::span< const byte, size/2 > > openmsx::VRAMWindow::getReadAreaPlanar ( unsigned  index) const
inline

Similar to getReadArea(), but now with planar addressing mode.

This means the region is split in two: one region for the even bytes (span0) and another for the odd bytes (span1).

Parameters
indexIndex in window
Returns
pair{span0, span1} span0: The block of even numbered bytes. span1: The block of odd numbered bytes.

Definition at line 245 of file VDPVRAM.hh.

References Math::floodRight().

◆ hasObserver()

bool openmsx::VRAMWindow::hasObserver ( ) const
inline

Is there an observer registered for this window?

Definition at line 282 of file VDPVRAM.hh.

◆ isContinuous() [1/2]

bool openmsx::VRAMWindow::isContinuous ( unsigned  index,
unsigned  size 
) const
inline

Is the given index range continuous in VRAM (iow there's no mirroring) Only if the range is continuous it's allowed to call getReadArea().

Definition at line 200 of file VDPVRAM.hh.

References Math::floodRight().

Referenced by getReadArea().

◆ isContinuous() [2/2]

bool openmsx::VRAMWindow::isContinuous ( unsigned  mask) const
inline

Alternative version to check whether a region is continuous in VRAM.

This tests whether all addresses in the range 0bCCCCCCCCCCXXXXXXXX (with C constant and X varying) are continuous. The input must be a value 1-less-than-a-power-of-2 (so a binary value containing zeros on the left ones on the right) 1-bits in the parameter correspond with 'X' in the pattern above. Or IOW it tests an aligned-power-of-2-sized region.

Definition at line 217 of file VDPVRAM.hh.

◆ isInside()

bool openmsx::VRAMWindow::isInside ( unsigned  address) const
inline

Test whether an address is inside this window.

"Inside" is defined as: there is at least one index in this window, which is mapped to the given address. TODO: Might be replaced by notify().

Parameters
addressThe address to test.
Returns
true iff the address is inside this window.

Definition at line 308 of file VDPVRAM.hh.

Referenced by openmsx::VDPVRAM::cpuRead(), openmsx::VDPVRAM::cpuWrite(), and notify().

◆ notify()

void openmsx::VRAMWindow::notify ( unsigned  address,
EmuTime::param  time 
)
inline

Notifies the observer of this window of a VRAM change, if the changes address is inside this window.

Parameters
addressThe address to test.
timeThe moment in emulated time the change occurs.

Definition at line 317 of file VDPVRAM.hh.

References isInside(), and openmsx::VRAMObserver::updateVRAM().

◆ operator=() [1/2]

VRAMWindow & openmsx::VRAMWindow::operator= ( const VRAMWindow )
delete

◆ operator=() [2/2]

VRAMWindow & openmsx::VRAMWindow::operator= ( VRAMWindow &&  )
delete

◆ readNP()

byte openmsx::VRAMWindow::readNP ( unsigned  index) const
inline

Reads a byte from VRAM in its current state.

Parameters
indexIndex in table, with unused bits set to 1.

Definition at line 265 of file VDPVRAM.hh.

Referenced by openmsx::Graphic4Mode::point(), openmsx::Graphic5Mode::point(), openmsx::Graphic6Mode::point(), openmsx::Graphic7Mode::point(), and openmsx::NonBitmapMode::point().

◆ readPlanar()

byte openmsx::VRAMWindow::readPlanar ( unsigned  index) const
inline

Similar to readNP, but now with planar addressing.

Parameters
indexIndex in table, with unused bits set to 1.

Definition at line 273 of file VDPVRAM.hh.

◆ resetObserver()

void openmsx::VRAMWindow::resetObserver ( )
inline

Unregister the observer of this VRAM window.

Definition at line 297 of file VDPVRAM.hh.

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

◆ serialize()

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

Definition at line 301 of file VDPVRAM.cc.

◆ setMask() [1/2]

void openmsx::VRAMWindow::setMask ( unsigned  newBaseMask,
unsigned  newIndexMask,
EmuTime::param  time 
)
inline

Same as above, but 'sizeMask' doesn't change.

This is a useful shortcut, because 'sizeMask' rarely changes.

Definition at line 184 of file VDPVRAM.hh.

References setMask().

◆ setMask() [2/2]

void openmsx::VRAMWindow::setMask ( unsigned  newBaseMask,
unsigned  newIndexMask,
unsigned  newSizeMask,
EmuTime::param  time 
)
inline

Sets the mask and enables this window.

Parameters
newBaseMaskThe table base register, with the unused bits all ones.
newIndexMaskThe table index mask, with the unused bits all ones.
newSizeMask
timeThe moment in emulated time this change occurs. TODO: In planar mode, the index bits are rotated one to the right. Solution: have the caller pass index mask instead of the number of bits. For many tables the number of index bits depends on the display mode anyway.

Definition at line 165 of file VDPVRAM.hh.

References openmsx::VRAMObserver::updateWindow().

Referenced by setMask(), openmsx::VDPVRAM::setRenderer(), setSizeMask(), and openmsx::VDPVRAM::VDPVRAM().

◆ setObserver()

void openmsx::VRAMWindow::setObserver ( VRAMObserver newObserver)
inline

Register an observer on this VRAM window.

It will be called when changes occur within the window. There can be only one observer per window at any given time.

Parameters
newObserverThe observer to register.

Definition at line 291 of file VDPVRAM.hh.

Referenced by openmsx::VDPVRAM::setRenderer(), and openmsx::SpriteChecker::SpriteChecker().

◆ setSizeMask()

void openmsx::VRAMWindow::setSizeMask ( unsigned  newSizeMask,
EmuTime::param  time 
)
inline

Inform VRAMWindow of changed sizeMask.

For the moment this only happens when switching the VR bit in VDP register 8 (in VR=0 mode only 32kB VRAM is addressable).

Definition at line 327 of file VDPVRAM.hh.

References setMask().

Friends And Related Symbol Documentation

◆ VDPVRAM

friend class VDPVRAM
friend

Only VDPVRAM may construct VRAMWindow objects.

Definition at line 346 of file VDPVRAM.hh.


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