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
 
VRAMWindowoperator= (const VRAMWindow &)=delete
 
int getMask () const
 Gets the mask for this window. More...
 
void setMask (int newBaseMask, int newIndexMask, EmuTime::param time)
 Sets the mask and enables this window. More...
 
void disable (EmuTime::param time)
 Disable this window: no address will be considered inside. More...
 
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(). More...
 
bool isContinuous (unsigned mask) const
 Alternative version to check whether a region is continuous in VRAM. More...
 
const bytegetReadArea (unsigned index, unsigned size) const
 Gets a pointer to a contiguous part of the VRAM. More...
 
void getReadAreaPlanar (unsigned index, unsigned size, const byte *&ptr0, const byte *&ptr1) const
 Similar to getReadArea(), but now with planar addressing mode. More...
 
byte readNP (unsigned index) const
 Reads a byte from VRAM in its current state. More...
 
byte readPlanar (unsigned index) const
 Similar to readNP, but now with planar addressing. More...
 
bool hasObserver () const
 Is there an observer registered for this window? More...
 
void setObserver (VRAMObserver *newObserver)
 Register an observer on this VRAM window. More...
 
void resetObserver ()
 Unregister the observer of this VRAM window. More...
 
bool isInside (unsigned address) const
 Test whether an address is inside this window. More...
 
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. More...
 
void setSizeMask (unsigned newSizeMask, EmuTime::param time)
 Inform VRAMWindow of changed sizeMask. More...
 
template<typename Archive >
void serialize (Archive &ar, unsigned version)
 

Friends

class VDPVRAM
 Only VDPVRAM may construct VRAMWindow objects. More...
 

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 135 of file VDPVRAM.hh.

Constructor & Destructor Documentation

◆ VRAMWindow()

openmsx::VRAMWindow::VRAMWindow ( const 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 182 of file VDPVRAM.hh.

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

◆ getMask()

int 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 146 of file VDPVRAM.hh.

Referenced by openmsx::SDLRasterizer< Pixel >::drawDisplay(), and openmsx::PixelRenderer::updateSpritesEnabled().

◆ getReadArea()

const byte* openmsx::VRAMWindow::getReadArea ( unsigned  index,
unsigned  size 
) const
inline

Gets a pointer to a contiguous part of the VRAM.

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

Parameters
indexIndex in table
sizeSize of the block. This is only used to assert that requested block is not too large.

Definition at line 219 of file VDPVRAM.hh.

References detail::data().

Referenced by openmsx::CharacterConverter< Pixel >::convertLine(), and openmsx::SpriteChecker::reset().

◆ getReadAreaPlanar()

void openmsx::VRAMWindow::getReadAreaPlanar ( unsigned  index,
unsigned  size,
const byte *&  ptr0,
const byte *&  ptr1 
) 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 (ptr0) and another for the odd bytes (ptr1).

Parameters
indexIndex in table
sizeSize of the block. This is only used to assert that requested block is not too large.
ptr0out Pointer to the block of even numbered bytes.
ptr1out Pointer to the block of odd numbered bytes.

Definition at line 233 of file VDPVRAM.hh.

References detail::data(), and Math::floodRight().

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

◆ hasObserver()

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

Is there an observer registered for this window?

Definition at line 270 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 190 of file VDPVRAM.hh.

References Math::floodRight().

Referenced by openmsx::CharacterConverter< Pixel >::convertLine().

◆ 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 207 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 296 of file VDPVRAM.hh.

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

◆ 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 305 of file VDPVRAM.hh.

◆ operator=()

VRAMWindow& openmsx::VRAMWindow::operator= ( const 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 253 of file VDPVRAM.hh.

References detail::data().

Referenced by openmsx::CharacterConverter< Pixel >::convertLine(), openmsx::Graphic4Mode::point(), openmsx::Graphic5Mode::point(), openmsx::Graphic6Mode::point(), openmsx::Graphic7Mode::point(), openmsx::NonBitmapMode::point(), and openmsx::SpriteChecker::reset().

◆ 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 261 of file VDPVRAM.hh.

References detail::data().

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

◆ resetObserver()

void openmsx::VRAMWindow::resetObserver ( )
inline

Unregister the observer of this VRAM window.

Definition at line 285 of file VDPVRAM.hh.

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

◆ serialize()

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

Definition at line 312 of file VDPVRAM.cc.

◆ setMask()

void openmsx::VRAMWindow::setMask ( int  newBaseMask,
int  newIndexMask,
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.
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 163 of file VDPVRAM.hh.

Referenced by openmsx::VDPVRAM::setRenderer(), 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 279 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 315 of file VDPVRAM.hh.

References openmsx::serialize().

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

Friends And Related Function Documentation

◆ VDPVRAM

friend class VDPVRAM
friend

Only VDPVRAM may construct VRAMWindow objects.

Definition at line 332 of file VDPVRAM.hh.


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