openMSX
Public Types | Public Member Functions | Static Public Member Functions | List of all members
openmsx::SpriteConverter Class Reference

Utility class for converting VRAM contents to host pixels. More...

#include <SpriteConverter.hh>

Public Types

using Pixel = uint32_t
 

Public Member Functions

 SpriteConverter (SpriteChecker &spriteChecker_, std::span< const Pixel, 16 > pal)
 Constructor.
 
void setTransparency (bool enabled)
 Update the transparency setting.
 
void setDisplayMode (DisplayMode newMode)
 Notify SpriteConverter of a display mode change.
 
void setPalette (std::span< const Pixel, 16 > newPalette)
 Set palette to use for converting sprites.
 
void drawMode1 (int absLine, int minX, int maxX, std::span< Pixel > pixelPtr) const
 Draw sprites in sprite mode 1.
 
template<unsigned MODE>
void drawMode2 (int absLine, int minX, int maxX, std::span< Pixel > pixelPtr) const
 Draw sprites in sprite mode 2.
 

Static Public Member Functions

static bool clipPattern (int &x, SpriteChecker::SpritePattern &pattern, int minX, int maxX)
 

Detailed Description

Utility class for converting VRAM contents to host pixels.

Definition at line 20 of file SpriteConverter.hh.

Member Typedef Documentation

◆ Pixel

Definition at line 23 of file SpriteConverter.hh.

Constructor & Destructor Documentation

◆ SpriteConverter()

openmsx::SpriteConverter::SpriteConverter ( SpriteChecker spriteChecker_,
std::span< const Pixel, 16 >  pal 
)
inlineexplicit

Constructor.

After construction, also call the various set methods to complete initialisation.

Parameters
spriteChecker_Delivers the sprite data to be rendered.
palThe initial palette. Can later be changed via setPallette().

Definition at line 33 of file SpriteConverter.hh.

Member Function Documentation

◆ clipPattern()

static bool openmsx::SpriteConverter::clipPattern ( int &  x,
SpriteChecker::SpritePattern pattern,
int  minX,
int  maxX 
)
inlinestatic

Definition at line 66 of file SpriteConverter.hh.

Referenced by drawMode1(), drawMode2(), and openmsx::ImGuiSpriteViewer::paint().

◆ drawMode1()

void openmsx::SpriteConverter::drawMode1 ( int  absLine,
int  minX,
int  maxX,
std::span< Pixel pixelPtr 
) const
inline

Draw sprites in sprite mode 1.

Parameters
absLineAbsolute line number. Range is [0..262) for NTSC and [0..313) for PAL.
minXMinimum X coordinate to draw (inclusive).
maxXMaximum X coordinate to draw (exclusive).
pixelPtrPointer to memory to draw to.

Definition at line 96 of file SpriteConverter.hh.

References clipPattern(), openmsx::SpriteChecker::getSprites(), and view::reverse().

Referenced by openmsx::SDLRasterizer::drawSprites().

◆ drawMode2()

template<unsigned MODE>
void openmsx::SpriteConverter::drawMode2 ( int  absLine,
int  minX,
int  maxX,
std::span< Pixel pixelPtr 
) const
inline

Draw sprites in sprite mode 2.

Make sure the pixel pointers point to a large enough memory area: 256 pixels for ZOOM_256 and ZOOM_REAL in 256-pixel wide modes; 512 pixels for ZOOM_REAL in 512-pixel wide modes.

Parameters
absLineAbsolute line number. Range is [0..262) for NTSC and [0..313) for PAL.
minXMinimum X coordinate to draw (inclusive).
maxXMaximum X coordinate to draw (exclusive).
pixelPtrPointer to memory to draw to.

Definition at line 142 of file SpriteConverter.hh.

References clipPattern(), openmsx::SpriteChecker::SpriteInfo::colorAttrib, openmsx::SpriteChecker::getSprites(), openmsx::DisplayMode::GRAPHIC5, openmsx::DisplayMode::GRAPHIC6, openmsx::SpriteChecker::SpriteInfo::pattern, and openmsx::SpriteChecker::SpriteInfo::x.

◆ setDisplayMode()

void openmsx::SpriteConverter::setDisplayMode ( DisplayMode  newMode)
inline

Notify SpriteConverter of a display mode change.

Parameters
newModeThe new display mode.

Definition at line 51 of file SpriteConverter.hh.

Referenced by openmsx::SDLRasterizer::setDisplayMode().

◆ setPalette()

void openmsx::SpriteConverter::setPalette ( std::span< const Pixel, 16 >  newPalette)
inline

Set palette to use for converting sprites.

This palette is stored by reference, so any modifications to it will be used while drawing.

Parameters
newPalette16-entry array containing the sprite palette.

Definition at line 61 of file SpriteConverter.hh.

Referenced by openmsx::SDLRasterizer::setDisplayMode().

◆ setTransparency()

void openmsx::SpriteConverter::setTransparency ( bool  enabled)
inline

Update the transparency setting.

Parameters
enabledThe new value.

Definition at line 43 of file SpriteConverter.hh.

Referenced by openmsx::SDLRasterizer::reset(), and openmsx::SDLRasterizer::setTransparency().


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