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

#include <SpriteChecker.hh>

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

Classes

struct  SpriteInfo
 Contains all the information to draw a line of a sprite. More...
 

Public Types

using SpritePattern = uint32_t
 Bitmap of length 32 describing a sprite pattern.
 

Public Member Functions

 SpriteChecker (VDP &vdp, RenderSettings &renderSettings, EmuTime::param time)
 Create a sprite checker.
 
void reset (EmuTime::param time)
 Puts the sprite checker in its initial state.
 
void sync (EmuTime::param time)
 Update sprite checking to specified time.
 
void resetStatus ()
 Clear status bits triggered by reading of S#0.
 
void updateDisplayMode (DisplayMode mode, EmuTime::param time)
 Informs the sprite checker of a VDP display mode change.
 
void updateDisplayEnabled (bool enabled, EmuTime::param time)
 Informs the sprite checker of a VDP display enabled change.
 
void updateSpritesEnabled (bool enabled, EmuTime::param time)
 Informs the sprite checker of sprite enable changes.
 
void updateSpriteSizeMag (byte sizeMag, EmuTime::param time)
 Informs the sprite checker of sprite size or magnification changes.
 
void updateTransparency (bool tp, EmuTime::param time)
 Informs the sprite checker of a change in the TP bit (R#8 bit 5)
 
void updateVerticalScroll (int scroll, EmuTime::param time)
 Informs the sprite checker of a vertical scroll change.
 
void checkUntil (EmuTime::param time)
 Update sprite checking until specified line.
 
int getCollisionX (EmuTime::param time)
 Get X coordinate of sprite collision.
 
int getCollisionY (EmuTime::param time)
 Get Y coordinate of sprite collision.
 
void resetCollision ()
 Reset sprite collision coordinates.
 
void frameStart (EmuTime::param time)
 Signals the start of a new frame.
 
void frameEnd (EmuTime::param time)
 Signals the end of the current frame.
 
std::span< const SpriteInfogetSprites (int line) const
 Get sprites for a display line.
 
void updateVRAM (unsigned, EmuTime::param time) override
 Informs the observer of a change in VRAM contents.
 
void updateWindow (bool, EmuTime::param time) override
 Informs the observer that the entire VRAM window will change.
 
template<typename Archive >
void serialize (Archive &ar, unsigned version)
 

Static Public Member Functions

static constexpr SpritePattern doublePattern (SpritePattern a)
 

Additional Inherited Members

- Protected Member Functions inherited from openmsx::VRAMObserver
 ~VRAMObserver ()=default
 

Detailed Description

Definition at line 21 of file SpriteChecker.hh.

Member Typedef Documentation

◆ SpritePattern

Bitmap of length 32 describing a sprite pattern.

Visible pixels are 1, transparent pixels are 0. If the sprite is less than 32 pixels wide, the lower bits are unused.

Definition at line 29 of file SpriteChecker.hh.

Constructor & Destructor Documentation

◆ SpriteChecker()

openmsx::SpriteChecker::SpriteChecker ( VDP vdp,
RenderSettings renderSettings,
EmuTime::param  time 
)

Create a sprite checker.

Parameters
vdpThe VDP this sprite checker is part of.
renderSettingsTODO
timeTODO

Definition at line 21 of file SpriteChecker.cc.

References openmsx::VRAMWindow::setObserver(), openmsx::VDPVRAM::spriteAttribTable, and openmsx::VDPVRAM::spritePatternTable.

Member Function Documentation

◆ checkUntil()

void openmsx::SpriteChecker::checkUntil ( EmuTime::param  time)
inline

Update sprite checking until specified line.

VRAM must be up-to-date before this method is called. It is not allowed to call this method in a spriteless display mode.

Parameters
timeThe moment in emulated time to update to.

Definition at line 185 of file SpriteChecker.hh.

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

Referenced by sync(), and updateVRAM().

◆ doublePattern()

static constexpr SpritePattern openmsx::SpriteChecker::doublePattern ( SpritePattern  a)
inlinestaticconstexpr

Definition at line 48 of file SpriteChecker.hh.

Referenced by openmsx::ImGuiSpriteViewer::paint().

◆ frameEnd()

void openmsx::SpriteChecker::frameEnd ( EmuTime::param  time)
inline

Signals the end of the current frame.

Parameters
timeMoment in emulated time the current frame ends.

Definition at line 234 of file SpriteChecker.hh.

References sync().

◆ frameStart()

void openmsx::SpriteChecker::frameStart ( EmuTime::param  time)
inline

Signals the start of a new frame.

Parameters
timeMoment in emulated time the new frame starts.

Definition at line 224 of file SpriteChecker.hh.

References ranges::fill(), and openmsx::Clock< FREQ_NUM, FREQ_DENOM >::reset().

Referenced by reset().

◆ getCollisionX()

int openmsx::SpriteChecker::getCollisionX ( EmuTime::param  time)
inline

Get X coordinate of sprite collision.

Definition at line 201 of file SpriteChecker.hh.

References sync().

◆ getCollisionY()

int openmsx::SpriteChecker::getCollisionY ( EmuTime::param  time)
inline

Get Y coordinate of sprite collision.

Definition at line 208 of file SpriteChecker.hh.

References sync().

◆ getSprites()

std::span< const SpriteInfo > openmsx::SpriteChecker::getSprites ( int  line) const
inline

Get sprites for a display line.

Returns the contents of the line the last time it was sprite checked; before getting the sprites, you should sync to a moment in time after the sprites are checked, or you'll get last frame's sprites.

Parameters
lineThe absolute line number for which sprites should be returned. Range is [0..313) for PAL and [0..262) for NTSC.
Returns
The to-be-displayed sprites. The buffers content remains valid until the next time the VDP is scheduled. This buffer is followed by a sentinel, this sentinel is NOT included in the returned span (IOW the span can be extended with one extra element which is the sentinel).

Definition at line 251 of file SpriteChecker.hh.

References subspan().

Referenced by openmsx::SpriteConverter::drawMode1(), and openmsx::SpriteConverter::drawMode2().

◆ reset()

void openmsx::SpriteChecker::reset ( EmuTime::param  time)

Puts the sprite checker in its initial state.

Parameters
timeThe moment in time this reset occurs.

Definition at line 31 of file SpriteChecker.cc.

References frameStart(), and openmsx::VDP::setSpriteStatus().

◆ resetCollision()

void openmsx::SpriteChecker::resetCollision ( )
inline

Reset sprite collision coordinates.

This happens directly after a read, so a timestamp for syncing is not necessary.

Definition at line 217 of file SpriteChecker.hh.

◆ resetStatus()

void openmsx::SpriteChecker::resetStatus ( )
inline

Clear status bits triggered by reading of S#0.

Definition at line 102 of file SpriteChecker.hh.

References openmsx::VDP::getStatusReg0(), and openmsx::VDP::setSpriteStatus().

◆ serialize()

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

◆ sync()

void openmsx::SpriteChecker::sync ( EmuTime::param  time)
inline

Update sprite checking to specified time.

This includes a VRAM sync.

Parameters
timeThe moment in emulated time to update to.

Definition at line 78 of file SpriteChecker.hh.

References checkUntil(), and openmsx::VDPVRAM::sync().

Referenced by frameEnd(), getCollisionX(), getCollisionY(), updateDisplayEnabled(), updateDisplayMode(), updateSpritesEnabled(), updateSpriteSizeMag(), updateTransparency(), updateVerticalScroll(), and updateWindow().

◆ updateDisplayEnabled()

void openmsx::SpriteChecker::updateDisplayEnabled ( bool  enabled,
EmuTime::param  time 
)
inline

Informs the sprite checker of a VDP display enabled change.

Parameters
enabledThe new display enabled state.
timeThe moment in emulated time this change occurs.

Definition at line 133 of file SpriteChecker.hh.

References sync().

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

◆ updateDisplayMode()

void openmsx::SpriteChecker::updateDisplayMode ( DisplayMode  mode,
EmuTime::param  time 
)
inline

Informs the sprite checker of a VDP display mode change.

Parameters
modeThe new display mode.
timeThe moment in emulated time this change occurs.

Definition at line 112 of file SpriteChecker.hh.

References openmsx::Clock< FREQ_NUM, FREQ_DENOM >::getTicksTill_fast(), sync(), and openmsx::VDP::TICKS_PER_LINE.

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

◆ updateSpritesEnabled()

void openmsx::SpriteChecker::updateSpritesEnabled ( bool  enabled,
EmuTime::param  time 
)
inline

Informs the sprite checker of sprite enable changes.

Parameters
enabledThe new sprite enabled state.
timeThe moment in emulated time this change occurs.

Definition at line 143 of file SpriteChecker.hh.

References sync().

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

◆ updateSpriteSizeMag()

void openmsx::SpriteChecker::updateSpriteSizeMag ( byte  sizeMag,
EmuTime::param  time 
)
inline

Informs the sprite checker of sprite size or magnification changes.

Parameters
sizeMagThe new size and magnification state. Bit 0 is magnification: 0 = normal, 1 = doubled. Bit 1 is size: 0 = 8x8, 1 = 16x16.
timeThe moment in emulated time this change occurs.

Definition at line 155 of file SpriteChecker.hh.

References sync().

◆ updateTransparency()

void openmsx::SpriteChecker::updateTransparency ( bool  tp,
EmuTime::param  time 
)
inline

Informs the sprite checker of a change in the TP bit (R#8 bit 5)

Parameters
tpThe new transparency value.
timeThe moment in emulated time this change occurs.

Definition at line 165 of file SpriteChecker.hh.

References sync().

◆ updateVerticalScroll()

void openmsx::SpriteChecker::updateVerticalScroll ( int  scroll,
EmuTime::param  time 
)
inline

Informs the sprite checker of a vertical scroll change.

Parameters
scrollThe new scroll value.
timeThe moment in emulated time this change occurs.

Definition at line 174 of file SpriteChecker.hh.

References sync().

◆ updateVRAM()

void openmsx::SpriteChecker::updateVRAM ( unsigned  offset,
EmuTime::param  time 
)
inlineoverridevirtual

Informs the observer of a change in VRAM contents.

This update is sent just before the change, so the subcomponent can update itself to the given time based on the old contents.

Parameters
offsetOffset of byte that will change, relative to window base address.
timeThe moment in emulated time this change occurs.

Implements openmsx::VRAMObserver.

Definition at line 265 of file SpriteChecker.hh.

References checkUntil().

◆ updateWindow()

void openmsx::SpriteChecker::updateWindow ( bool  enabled,
EmuTime::param  time 
)
inlineoverridevirtual

Informs the observer that the entire VRAM window will change.

This update is sent just before the change, so the subcomponent can update itself to the given time based on the old contents. This happens if the base/index masks are changed, or if the window becomes disabled. TODO: Separate enable/disable from window move?

Parameters
enabledWill the window be enabled after the change? If the observer keeps a cache which is based on VRAM contents, it is only necessary to flush the cache if the new window is enabled, because no reads are allowed from disabled windows.
timeThe moment in emulated time this change occurs.

Implements openmsx::VRAMObserver.

Definition at line 269 of file SpriteChecker.hh.

References sync().


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