openMSX
|
#include <SpriteChecker.hh>
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 | updateTransparency (bool tp, EmuTime::param time) |
Informs the sprite checker of a change in the TP bit (R#8 bit 5) 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... | |
std::span< const SpriteInfo > | getSprites (int line) 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) |
virtual void | updateVRAM (unsigned offset, EmuTime::param time)=0 |
Informs the observer of a change in VRAM contents. More... | |
virtual void | updateWindow (bool enabled, EmuTime::param time)=0 |
Informs the observer that the entire VRAM window will change. More... | |
Additional Inherited Members | |
![]() | |
~VRAMObserver ()=default | |
Definition at line 21 of file SpriteChecker.hh.
using openmsx::SpriteChecker::SpritePattern = uint32_t |
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.
openmsx::SpriteChecker::SpriteChecker | ( | VDP & | vdp, |
RenderSettings & | renderSettings, | ||
EmuTime::param | time | ||
) |
Create a sprite checker.
vdp | The VDP this sprite checker is part of. |
renderSettings | TODO |
time | TODO |
Definition at line 21 of file SpriteChecker.cc.
References openmsx::VRAMWindow::setObserver(), openmsx::VDPVRAM::spriteAttribTable, and openmsx::VDPVRAM::spritePatternTable.
|
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.
time | The moment in emulated time to update to. |
Definition at line 172 of file SpriteChecker.hh.
References openmsx::Clock< FREQ_NUM, FREQ_DENOM >::getTicksTill_fast(), and openmsx::VDP::TICKS_PER_LINE.
Referenced by sync(), and updateVRAM().
|
inline |
Signals the end of the current frame.
time | Moment in emulated time the current frame ends. |
Definition at line 221 of file SpriteChecker.hh.
References sync().
|
inline |
Signals the start of a new frame.
time | Moment in emulated time the new frame starts. |
Definition at line 211 of file SpriteChecker.hh.
References ranges::fill(), and openmsx::Clock< FREQ_NUM, FREQ_DENOM >::reset().
Referenced by reset().
|
inline |
Get X coordinate of sprite collision.
Definition at line 188 of file SpriteChecker.hh.
References sync().
|
inline |
Get Y coordinate of sprite collision.
Definition at line 195 of file SpriteChecker.hh.
References sync().
|
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.
line | The absolute line number for which sprites should be returned. Range is [0..313) for PAL and [0..262) for NTSC. |
Definition at line 238 of file SpriteChecker.hh.
References subspan().
Referenced by openmsx::SpriteConverter< Pixel >::drawMode1(), and openmsx::SpriteConverter< Pixel >::drawMode2().
void openmsx::SpriteChecker::reset | ( | EmuTime::param | time | ) |
Puts the sprite checker in its initial state.
time | The moment in time this reset occurs. |
Definition at line 31 of file SpriteChecker.cc.
References frameStart(), and openmsx::VDP::setSpriteStatus().
|
inline |
Reset sprite collision coordinates.
This happens directly after a read, so a timestamp for syncing is not necessary.
Definition at line 204 of file SpriteChecker.hh.
|
inline |
Clear status bits triggered by reading of S#0.
Definition at line 89 of file SpriteChecker.hh.
References openmsx::VDP::getStatusReg0(), and openmsx::VDP::setSpriteStatus().
void openmsx::SpriteChecker::serialize | ( | Archive & | ar, |
unsigned | version | ||
) |
Definition at line 496 of file SpriteChecker.cc.
References ranges::fill(), openmsx::VDP::getDisplayMode(), openmsx::VDP::getFrameStartTime(), and openmsx::Clock< FREQ_NUM, FREQ_DENOM >::reset().
|
inline |
Update sprite checking to specified time.
This includes a VRAM sync.
time | The moment in emulated time to update to. |
Definition at line 65 of file SpriteChecker.hh.
References checkUntil(), and openmsx::VDPVRAM::sync().
Referenced by frameEnd(), getCollisionX(), getCollisionY(), updateDisplayEnabled(), updateDisplayMode(), updateSpritesEnabled(), updateSpriteSizeMag(), updateTransparency(), updateVerticalScroll(), and updateWindow().
|
inline |
Informs the sprite checker of a VDP display enabled change.
enabled | The new display enabled state. |
time | The moment in emulated time this change occurs. |
Definition at line 120 of file SpriteChecker.hh.
References sync().
Referenced by openmsx::VDPVRAM::updateDisplayEnabled().
|
inline |
Informs the sprite checker of a VDP display mode change.
mode | The new display mode. |
time | The moment in emulated time this change occurs. |
Definition at line 99 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().
|
inline |
Informs the sprite checker of sprite enable changes.
enabled | The new sprite enabled state. |
time | The moment in emulated time this change occurs. |
Definition at line 130 of file SpriteChecker.hh.
References sync().
Referenced by openmsx::VDPVRAM::updateSpritesEnabled().
|
inline |
Informs the sprite checker of sprite size or magnification changes.
sizeMag | The new size and magnification state. Bit 0 is magnification: 0 = normal, 1 = doubled. Bit 1 is size: 0 = 8x8, 1 = 16x16. |
time | The moment in emulated time this change occurs. |
Definition at line 142 of file SpriteChecker.hh.
References sync().
|
inline |
Informs the sprite checker of a change in the TP bit (R#8 bit 5)
tp | The new transparency value. |
time | The moment in emulated time this change occurs. |
Definition at line 152 of file SpriteChecker.hh.
References sync().
|
inline |
Informs the sprite checker of a vertical scroll change.
scroll | The new scroll value. |
time | The moment in emulated time this change occurs. |
Definition at line 161 of file SpriteChecker.hh.
References sync().
|
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.
offset | Offset of byte that will change, relative to window base address. |
time | The moment in emulated time this change occurs. |
Implements openmsx::VRAMObserver.
Definition at line 252 of file SpriteChecker.hh.
References checkUntil().
|
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?
enabled | Will 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. |
time | The moment in emulated time this change occurs. |
Implements openmsx::VRAMObserver.
Definition at line 256 of file SpriteChecker.hh.
References sync().