1#ifndef SPRITECHECKER_HH
2#define SPRITECHECKER_HH
54 a = (a | (a >> 8)) & 0xFF00FF00;
55 a = (a | (a >> 4)) & 0xF0F0F0F0;
56 a = (a | (a >> 2)) & 0xCCCCCCCC;
57 a = (a | (a >> 1)) & 0xAAAAAAAA;
72 void reset(EmuTime::param time);
78 inline void sync(EmuTime::param time) {
79 if (!updateSpritesMethod) {
89 static bool syncInProgress =
false;
90 assert(!syncInProgress);
91 syncInProgress =
true;
96 syncInProgress =
false;
114 setDisplayMode(mode);
193 if (currentLine < limit) {
195 (this->*updateSpritesMethod)(limit);
218 collisionX = collisionY = 0;
225 frameStartTime.
reset(time);
251 [[nodiscard]]
inline std::span<const SpriteInfo>
getSprites(
int line)
const {
258 if (line < 0)
return {};
260 return subspan(spriteBuffer[line], 0, spriteCount[line]);
273 template<
typename Archive>
274 void serialize(Archive& ar,
unsigned version);
282 updateSpritesMethod =
nullptr;
285 updateSpritesMethod = &SpriteChecker::updateSprites1;
288 updateSpritesMethod = &SpriteChecker::updateSprites2;
300 void updateSprites1(
int limit);
304 void updateSprites2(
int limit);
314 [[nodiscard]]
inline SpritePattern calculatePatternNP(
unsigned patternNr,
unsigned y)
const;
315 [[nodiscard]]
inline SpritePattern calculatePatternPlanar(
unsigned patternNr,
unsigned y)
const;
327 inline void checkSprites1(
int minLine,
int maxLine);
339 inline void checkSprites2(
int minLine,
int maxLine);
342 using UpdateSpritesMethod = void (SpriteChecker::*)(int limit);
343 UpdateSpritesMethod updateSpritesMethod;
359 BooleanSetting& limitSpritesSetting;
363 Clock<VDP::TICKS_PER_SECOND> frameStartTime;
384 std::array<std::array<SpriteInfo, 32 + 1>, 313> spriteBuffer;
391 std::array<uint8_t, 313> spriteCount;
constexpr void reset(EmuTime::param e)
Reset the clock to start ticking at the given time.
constexpr unsigned getTicksTill_fast(EmuTime::param e) const
Same as above, only faster, Though the time interval may not be too large.
Represents a VDP display mode.
constexpr bool isPlanar() const
Is VRAM "planar" in the current display mode? Graphic 6 and 7 spread their bytes over two VRAM ICs,...
constexpr int getSpriteMode(bool isMSX1) const
Get the sprite mode of this display mode.
Class containing all settings for renderers.
void frameStart(EmuTime::param time)
Signals the start of a new frame.
void sync(EmuTime::param time)
Update sprite checking to specified time.
void reset(EmuTime::param time)
Puts the sprite checker in its initial state.
void serialize(Archive &ar, unsigned version)
void frameEnd(EmuTime::param time)
Signals the end of the current frame.
uint32_t SpritePattern
Bitmap of length 32 describing a sprite pattern.
void updateTransparency(bool tp, EmuTime::param time)
Informs the sprite checker of a change in the TP bit (R#8 bit 5)
int getCollisionX(EmuTime::param time)
Get X coordinate of sprite collision.
void updateVerticalScroll(int scroll, EmuTime::param time)
Informs the sprite checker of a vertical scroll change.
void updateWindow(bool, EmuTime::param time) override
Informs the observer that the entire VRAM window will change.
void updateDisplayMode(DisplayMode mode, EmuTime::param time)
Informs the sprite checker of a VDP display mode change.
void resetStatus()
Clear status bits triggered by reading of S#0.
static constexpr SpritePattern doublePattern(SpritePattern a)
void updateDisplayEnabled(bool enabled, EmuTime::param time)
Informs the sprite checker of a VDP display enabled change.
void checkUntil(EmuTime::param time)
Update sprite checking until specified line.
void updateSpriteSizeMag(byte sizeMag, EmuTime::param time)
Informs the sprite checker of sprite size or magnification changes.
std::span< const SpriteInfo > getSprites(int line) const
Get sprites for a display line.
int getCollisionY(EmuTime::param time)
Get Y coordinate of sprite collision.
void resetCollision()
Reset sprite collision coordinates.
void updateVRAM(unsigned, EmuTime::param time) override
Informs the observer of a change in VRAM contents.
void updateSpritesEnabled(bool enabled, EmuTime::param time)
Informs the sprite checker of sprite enable changes.
void sync(EmuTime::param time)
Update VRAM state to specified moment in time.
Unified implementation of MSX Video Display Processors (VDPs).
byte getStatusReg0() const
Should only be used by SpriteChecker.
static constexpr int TICKS_PER_LINE
Number of VDP clock ticks per line.
void setSpriteStatus(byte value)
Should only be used by SpriteChecker.
bool isMSX1VDP() const
Is this an MSX1 VDP?
Interface that can be registered at VRAMWindow, to be called when the contents of the VRAM inside tha...
This file implemented 3 utility functions:
constexpr void fill(ForwardRange &&range, const T &value)
constexpr auto subspan(Range &&range, size_t offset, size_t count=std::dynamic_extent)
Contains all the information to draw a line of a sprite.
SpritePattern pattern
Pattern of this sprite line, corrected for magnification.
byte colorAttrib
Bit 3..0 are index in palette.
int16_t x
X-coordinate of sprite, corrected for early clock.