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. | |
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 SpriteInfo > | getSprites (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 | |
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 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().
|
inlinestaticconstexpr |
Definition at line 48 of file SpriteChecker.hh.
Referenced by openmsx::ImGuiSpriteViewer::paint().
|
inline |
Signals the end of the current frame.
time | Moment in emulated time the current frame ends. |
Definition at line 234 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 224 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 201 of file SpriteChecker.hh.
References sync().
|
inline |
Get Y coordinate of sprite collision.
Definition at line 208 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 251 of file SpriteChecker.hh.
References subspan().
Referenced by openmsx::SpriteConverter::drawMode1(), and openmsx::SpriteConverter::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 217 of file SpriteChecker.hh.
|
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().
void openmsx::SpriteChecker::serialize | ( | Archive & | ar, |
unsigned | version | ||
) |
Definition at line 483 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 78 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 133 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 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().
|
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 143 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 155 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 165 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 174 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 265 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 269 of file SpriteChecker.hh.
References sync().