openMSX
Classes | Public Types | 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. More...
 

Public Member Functions

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

Additional Inherited Members

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

Detailed Description

Definition at line 18 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 26 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 20 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 160 of file SpriteChecker.hh.

References openmsx::VDP::TICKS_PER_LINE.

Referenced by sync(), updateVRAM(), and openmsx::PixelRenderer::updateWindow().

◆ 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 209 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 199 of file SpriteChecker.hh.

References ranges::fill().

Referenced by reset().

◆ getCollisionX()

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

Get X coordinate of sprite collision.

Definition at line 176 of file SpriteChecker.hh.

References sync().

◆ getCollisionY()

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

Get Y coordinate of sprite collision.

Definition at line 183 of file SpriteChecker.hh.

References sync().

◆ getSprites()

int openmsx::SpriteChecker::getSprites ( int  line,
const SpriteInfo *&  visibleSprites 
) 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.
visibleSpritesOutput parameter in which the pointer to a SpriteInfo array containing the sprites to be displayed is returned. The array's contents are valid until the next time the VDP is scheduled.
Returns
The number of sprites stored in the visibleSprites array.

Definition at line 226 of file SpriteChecker.hh.

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

◆ reset()

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

◆ 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 192 of file SpriteChecker.hh.

◆ resetStatus()

void openmsx::SpriteChecker::resetStatus ( )
inline

Clear status bits triggered by reading of S#0.

Definition at line 86 of file SpriteChecker.hh.

◆ 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 62 of file SpriteChecker.hh.

References checkUntil().

Referenced by frameEnd(), getCollisionX(), getCollisionY(), updateDisplayEnabled(), updateDisplayMode(), updateSpritesEnabled(), updateSpriteSizeMag(), 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 117 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 96 of file SpriteChecker.hh.

References 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 127 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 139 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 149 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 241 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 245 of file SpriteChecker.hh.

References openmsx::DisplayMode::getSpriteMode(), openmsx::DisplayMode::isPlanar(), serialize(), openmsx::SERIALIZE_CLASS_VERSION(), sync(), and UNREACHABLE.


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