Jazz2::Scripting::Legacy::jjLAYER class

Layer of tiles.

A level normally has eight layers, numbered 1 to 8 from front to back: layers 1 and 2 are drawn in front of everything, layer 3 just in front of the sprites, layer 4 is the sprite layer where the gameplay happens, and layers 5 to 8 form the background, layer 8 being the farthest one. They're reached through jjLayers, which keeps this numbering even after jjLayerOrderSet() changes the order they're drawn in. More layers can be created by the constructors or taken from another level by jjLayersFromLevel().

Properties a script changes are applied to the level once per frame.

Public types

struct TextureStyleParams
Parameters of one texture style of a layer, the object behind jjLAYERWARPHORIZON and the others.
enum TextureSurfaceStyles : std::int32_t { Untextured, Legacy, FullScreen, InnerWindow, InnerLayer }
Where a textured layer is drawn, values of SURFACE::Surface.

Public static functions

static auto CreateFromSize(std::uint32_t width, std::uint32_t height) -> jjLAYER* partially supported
Creates a new empty layer of the given size in tiles.
static auto CreateCopy(jjLAYER* other) -> jjLAYER*
Creates a new layer as a copy of another one.
static auto get_jjLayers(int32_t index) -> jjLAYER*
Returns the layers of the level by their original number, from 1 to 8.
template<float TextureStyleParams::* Member>
static auto GetStyleValue(const TextureStyleParams* params) -> float
Returns a value of the parameters of a texture style.
template<float TextureStyleParams::* Member>
static auto SetStyleValue(TextureStyleParams* params, float value) -> float
Sets a value of the parameters of a texture style, shared by all styles of the layer.
static auto GetStyleFade(const TextureStyleParams* params) -> bool
Returns whether a texture style fades.
static auto SetStyleFade(TextureStyleParams* params, bool value) -> bool
Sets whether a texture style fades, shared by all styles of the layer.
static auto GetStyleTintColor(const TextureStyleParams* params) -> std::uint8_t
Returns the palette entry a reflection is tinted with.
static auto SetStyleTintColor(TextureStyleParams* params, std::uint8_t value) -> std::uint8_t
Sets the palette entry a reflection is tinted with.
template<std::int32_t Index>
static auto GetTextureComponent(const TextureStyleParams* params) -> std::uint8_t
Returns a component of the fade color, or what the style takes it as.
template<std::int32_t Index>
static auto SetTextureComponent(TextureStyleParams* params, std::uint8_t value) -> std::uint8_t
Sets a component of the fade color, or what the style takes it as.
static auto GetWaveSpeed(const TextureStyleParams* params) -> std::int8_t
Returns the speed of a wave, the blue of the fade color as a signed byte.
static auto SetWaveSpeed(TextureStyleParams* params, std::int8_t value) -> std::int8_t
Sets the speed of a wave, the blue of the fade color as a signed byte.
static auto GetTextureStars(const TextureStyleParams* params) -> bool
Returns the stars of a warp horizon, or what the style takes them as.
static auto SetTextureStars(TextureStyleParams* params, bool value) -> bool
Sets the stars of a warp horizon, or what the style takes them as.
static auto GetFadeColor(const TextureStyleParams* params) -> jjPALCOLOR
Returns the fade color of the layer's texture styles.
static void SetFadeColor(TextureStyleParams* params, jjPALCOLOR color)
Sets the fade color of the layer's texture styles.
static auto jjLayerOrderGet() -> CScriptArray*
Returns the layers in the order they're drawn, from the front to the back.
static auto jjLayerOrderSet(const CScriptArray& order) -> bool partially supported
Changes which layers are drawn and in what order.
static auto ToStoredOffset(float value) -> float
Returns a layer offset as it's stored, in 16.16 fixed point.
static auto jjLayersFromLevel(const String& filename, const CScriptArray& layerIDs, int32_t tileIDAdjustmentFactor) -> CScriptArray*
Creates new layers from the layers of another level.
static auto jjTilesFromTileset(const String& filename, std::uint32_t firstTileID, std::uint32_t tileCount, const CScriptArray* paletteColorMapping) -> bool
Appends tiles of another tile set to the end of the level's tile set.
static auto jjTilesFromTileset32(const String& filename, std::uint32_t firstTileID, std::uint32_t tileCount, const jjPAL* palette) -> bool
Appends tiles of another tile set as 32-bit tiles.

Constructors, destructors, conversion operators

jjLAYER()
Creates a new instance.
~jjLAYER()

Public functions

void AddRef()
Increments the reference count.
void Release()
Decrements the reference count.
auto operator=(const jjLAYER& o) -> jjLAYER&
auto get_spriteMode() const -> std::uint32_t
Returns the sprite mode the layer is drawn with.
auto set_spriteMode(std::uint32_t value) const -> std::uint32_t
Sets the sprite mode the layer is drawn with.
auto get_spriteParam() const -> std::uint8_t
Returns the parameter of the layer's sprite mode.
auto set_spriteParam(std::uint8_t value) const -> std::uint8_t
Sets the parameter of the layer's sprite mode.
void setXSpeed(float newspeed, bool newSpeedIsAnAutoSpeed) const
Changes the horizontal speed or automatic speed of the layer.
void setYSpeed(float newspeed, bool newSpeedIsAnAutoSpeed) const
Changes the vertical speed or automatic speed of the layer.
auto getXPosition(const jjPLAYER* play) const -> float
Returns the horizontal position of the layer as last drawn for a player, in pixels.
auto getYPosition(const jjPLAYER* play) const -> float
Returns the vertical position of the layer as last drawn for a player, in pixels.
auto GetTextureMode() const -> std::int32_t
Returns the effect a textured layer is drawn with.
void SetTextureMode(std::int32_t value)
Sets the effect a textured layer is drawn with.
auto GetTexture() const -> std::int32_t
Returns the 256×256 pixel image a textured layer is drawn with.
void SetTexture(std::int32_t value)
Sets the 256×256 pixel image a textured layer is drawn with.
auto GetTextureSurface() const -> std::int32_t
Returns where and whether the layer is drawn textured.
void SetTextureSurface(std::int32_t value)
Sets where and whether the layer is drawn textured.
void ApplyTexture()
Makes the layer of the level drawn as its texture properties say.
auto SetBlend(Tiles::LayerDescription& description) const -> bool
Sets how a textured layer is drawn over what is behind it by the sprite mode a script set.
auto tileGet(int xTile, int yTile) -> std::uint16_t
Returns the tile at the given position in tiles.
auto tileSet(int xTile, int yTile, std::uint16_t newTile) -> std::uint16_t
Changes the tile at the given position in tiles.
void generateSettableTileArea(int xTile, int yTile, int width, int height)
Prepares a rectangular area of the layer for tileSet().
void generateSettableTileAreaAll()
Prepares the whole layer for tileSet().

Public variables

std::int32_t width
Width of the layer in tiles.
std::int32_t widthReal
Width of the layer in tiles, including any widening needed for tiling.
std::int32_t widthRounded
Width of the layer in groups of four tiles, (widthReal + 3) / 4.
std::int32_t height
Height of the layer in tiles.
float xSpeed
Horizontal parallax speed of the layer.
float ySpeed
Vertical parallax speed of the layer, see xSpeed.
float xAutoSpeed
Horizontal automatic scrolling speed of the layer.
float yAutoSpeed
Vertical automatic scrolling speed of the layer, see xAutoSpeed.
float xOffset
Horizontal offset of the layer in pixels.
float yOffset
Vertical offset of the layer in pixels, see xOffset.
float xInnerSpeed
Horizontal speed of the texture inside the layer.
float yInnerSpeed
Vertical speed of the texture inside the layer, see xInnerSpeed.
float xInnerAutoSpeed
Horizontal automatic scrolling speed of the texture inside the layer, see xInnerSpeed.
float yInnerAutoSpeed
Vertical automatic scrolling speed of the texture inside the layer, see xInnerSpeed.
TextureStyleParams warpHorizon
Properties used when textureStyle is TEXTURE::WARPHORIZON.
TextureStyleParams tunnel
Properties used when textureStyle is TEXTURE::TUNNEL.
TextureStyleParams menu partially supported
Properties used when textureStyle is TEXTURE::MENU.
TextureStyleParams tileMenu
Properties used when textureStyle is TEXTURE::TILEMENU.
TextureStyleParams wave
Properties used when textureStyle is TEXTURE::WAVE.
TextureStyleParams cylinder
Properties used when textureStyle is TEXTURE::CYLINDER.
TextureStyleParams reflection
Properties used when textureStyle is TEXTURE::REFLECTION.
std::int32_t rotationAngle partially supported
Angle offset of the layer's swaying while a player is stoned.
std::int32_t rotationRadiusMultiplier partially supported
How far the layer sways while a player is stoned.
bool tileHeight
Whether the layer repeats vertically.
bool tileWidth
Whether the layer repeats horizontally.
bool limitVisibleRegion
Whether the layer is shifted down by an amount that depends on the resolution.
bool hasTileMap
Whether the layer has a tile map.
bool hasTiles
Whether the layer is drawn.
std::int32_t SpeedModeX
Horizontal speed model of the layer.
std::int32_t SpeedModeY
Vertical speed model of the layer.

Enum documentation

enum Jazz2::Scripting::Legacy::jjLAYER::TextureSurfaceStyles : std::int32_t

Where a textured layer is drawn, values of SURFACE::Surface.

Enumerators
Untextured

Drawn as tiles

Legacy

Over the whole view, as layer 8 of the original game

FullScreen

Over the whole view

InnerWindow

Only where the layer is, as a window into one over the whole view

InnerLayer

Only where the layer is, the horizon and the vanishing point a fraction of the layer

Function documentation

static jjLAYER* Jazz2::Scripting::Legacy::jjLAYER::CreateFromSize(std::uint32_t width, std::uint32_t height)

Creates a new empty layer of the given size in tiles.

The new layer has no tiles yet, doesn't move with the camera (both speeds are 0) and isn't drawn until it's included in jjLayerOrderSet().

static jjLAYER* Jazz2::Scripting::Legacy::jjLAYER::CreateCopy(jjLAYER* other)

Creates a new layer as a copy of another one.

The copy takes the tiles, the texture and all other properties of the layer except its sprite mode, which starts as SPRITE::NORMAL. It isn't drawn until it's included in jjLayerOrderSet().

static jjLAYER* Jazz2::Scripting::Legacy::jjLAYER::get_jjLayers(int32_t index)

Returns the layers of the level by their original number, from 1 to 8.

jjLayers[4] is the sprite layer and jjLayers[8] the farthest background layer. The numbers always refer to the layers the level was made with, regardless of jjLayerOrderSet(). An index out of range gives an empty layer that isn't part of the level.

static CScriptArray* Jazz2::Scripting::Legacy::jjLAYER::jjLayerOrderGet()

Returns the layers in the order they're drawn, from the front to the back.

Includes every layer currently drawn, the ones a script added by jjLayerOrderSet() too.

static bool Jazz2::Scripting::Legacy::jjLAYER::jjLayerOrderSet(const CScriptArray& order)

Changes which layers are drawn and in what order.

The first layer of the array is drawn in front, the last one at the back. Layers left out aren't drawn. The array must contain jjLayers[4] and no null handles, otherwise nothing changes and false is returned. A layer that appears more than once is placed by its first appearance.

jjLayers and the global functions that take a layer number keep referring to the original eight layers after the order changes.

static float Jazz2::Scripting::Legacy::jjLAYER::ToStoredOffset(float value)

Returns a layer offset as it's stored, in 16.16 fixed point.

An offset out of the range is 0, and 32768 itself wraps to -32768.

static CScriptArray* Jazz2::Scripting::Legacy::jjLAYER::jjLayersFromLevel(const String& filename, const CScriptArray& layerIDs, int32_t tileIDAdjustmentFactor)

Creates new layers from the layers of another level.

layerIDs are the numbers of the layers to take, from 1 to 8. The level is read from the Source directory, or the layers are copied as they are now if it's the current level. tileIDAdjustmentFactor is added to every non-empty, non-animated tile, which helps when the tiles were added by jjTilesFromTileset(); animated tiles refer to the animated tiles of this level. The new layers aren't drawn until they're included in jjLayerOrderSet().

Returns an empty array if the level can't be read or any of the numbers is invalid.

static bool Jazz2::Scripting::Legacy::jjLAYER::jjTilesFromTileset(const String& filename, std::uint32_t firstTileID, std::uint32_t tileCount, const CScriptArray* paletteColorMapping)

Appends tiles of another tile set to the end of the level's tile set.

Takes tileCount tiles starting at firstTileID and increases jjTileCount by that many. If paletteColorMapping has at least 256 entries, every pixel of an 8-bit tile is replaced by the entry at its palette index, to fit the colors into the current palette. Returns false on failure.

static bool Jazz2::Scripting::Legacy::jjLAYER::jjTilesFromTileset32(const String& filename, std::uint32_t firstTileID, std::uint32_t tileCount, const jjPAL* palette)

Appends tiles of another tile set as 32-bit tiles.

The same as jjTilesFromTileset(), but 8-bit tiles are converted to true color, either in the colors of palette or, if it's null, in the tile set's own palette, so they keep their colors whatever the level's palette is.

std::uint32_t Jazz2::Scripting::Legacy::jjLAYER::get_spriteMode() const

Returns the sprite mode the layer is drawn with.

Defaults to SPRITE::NORMAL. A layer drawn as tiles supports NORMAL, TRANSLUCENT, TRANSLUCENTTILE, INVISIBLE, TINTED, PALSHIFT, TRANSLUCENTPALSHIFT, SINGLECOLOR, TRANSLUCENTCOLOR, BRIGHTNESS, CHROMAKEY, ALPHAMAP, MAPPING, TRANSLUCENTMAPPING and all BLEND_* modes, any other mode is ignored. A textured layer supports NORMAL, TRANSLUCENT, TRANSLUCENTTILE, INVISIBLE, CHROMAKEY, MAPPING, TRANSLUCENTMAPPING and the BLEND_* modes, with any other mode it's drawn normally. Layers drawn by special effects, such as a reflection, ignore the mode.

std::uint8_t Jazz2::Scripting::Legacy::jjLAYER::get_spriteParam() const

Returns the parameter of the layer's sprite mode.

Its meaning depends on spriteMode, for example the opacity for SPRITE::BLEND_NORMAL, the palette entry for SPRITE::SINGLECOLOR and SPRITE::CHROMAKEY, or the brightness for SPRITE::BRIGHTNESS (128 leaves it unchanged). It's kept even while the current mode doesn't use it. Defaults to 0.

void Jazz2::Scripting::Legacy::jjLAYER::setXSpeed(float newspeed, bool newSpeedIsAnAutoSpeed) const

Changes the horizontal speed or automatic speed of the layer.

Sets xAutoSpeed if newSpeedIsAnAutoSpeed is true, otherwise xSpeed and sets xAutoSpeed to 0. Unlike assigning the properties, the layer stays where it was in the view of the first player, in every speed model. xOffset doesn't change, the layer is moved by an offset of its own.

void Jazz2::Scripting::Legacy::jjLAYER::setYSpeed(float newspeed, bool newSpeedIsAnAutoSpeed) const

Changes the vertical speed or automatic speed of the layer.

Sets yAutoSpeed if newSpeedIsAnAutoSpeed is true, otherwise ySpeed and sets yAutoSpeed to 0. Unlike assigning the properties, the layer stays where it was in the view of the first player, in every speed model. yOffset doesn't change, the layer is moved by an offset of its own.

float Jazz2::Scripting::Legacy::jjLAYER::getXPosition(const jjPLAYER* play) const

Returns the horizontal position of the layer as last drawn for a player, in pixels.

Accounts for everything that moves the layer, such as its speeds, offsets and the player's camera, so it can be used to keep something aligned to a layer. The player should be a local one. For a layer that isn't part of the level, the position is estimated from the camera, xSpeed and xOffset.

float Jazz2::Scripting::Legacy::jjLAYER::getYPosition(const jjPLAYER* play) const

Returns the vertical position of the layer as last drawn for a player, in pixels.

See getXPosition().

std::int32_t Jazz2::Scripting::Legacy::jjLAYER::GetTextureMode() const

Returns the effect a textured layer is drawn with.

Used only when textureSurface isn't SURFACE::UNTEXTURED. Each style has its own properties, for example warpHorizon for TEXTURE::WARPHORIZON. TEXTURE::MENU is drawn as a warp horizon.

std::int32_t Jazz2::Scripting::Legacy::jjLAYER::GetTexture() const

Returns the 256×256 pixel image a textured layer is drawn with.

TEXTURE::FROMTILES (the default) takes the 8×8 tiles at the top left corner of the layer. Reads as TEXTURE::CUSTOM after jjPIXELMAP::makeTexture() gave the layer an image. The other textures are read from a data file in the game's Source directory, if it's missing, the image of the layer doesn't change.

std::int32_t Jazz2::Scripting::Legacy::jjLAYER::GetTextureSurface() const

Returns where and whether the layer is drawn textured.

SURFACE::UNTEXTURED draws the layer as tiles. Otherwise it's drawn with the effect of textureStyle, see SURFACE::Surface for the options.

void Jazz2::Scripting::Legacy::jjLAYER::ApplyTexture()

Makes the layer of the level drawn as its texture properties say.

A style the game can't draw (TEXTURE::MENU) is drawn as a warp horizon, a wave is drawn over the whole view whatever its surface.

bool Jazz2::Scripting::Legacy::jjLAYER::SetBlend(Tiles::LayerDescription& description) const

Sets how a textured layer is drawn over what is behind it by the sprite mode a script set.

Returns false if the mode isn't one a textured layer can be drawn with, it's drawn as it is then.

std::uint16_t Jazz2::Scripting::Legacy::jjLAYER::tileGet(int xTile, int yTile)

Returns the tile at the given position in tiles.

An animated tile is returned as its animated tile ID, not its current frame. Returns 0 for a position outside the layer or a layer that isn't part of the level.

std::uint16_t Jazz2::Scripting::Legacy::jjLAYER::tileSet(int xTile, int yTile, std::uint16_t newTile)

Changes the tile at the given position in tiles.

Only that tile changes, other places using the same tiles aren't affected. Returns newTile, or 0 if the layer isn't part of the level.

void Jazz2::Scripting::Legacy::jjLAYER::generateSettableTileArea(int xTile, int yTile, int width, int height)

Prepares a rectangular area of the layer for tileSet().

Has no effect, every tile can already be changed on its own.

void Jazz2::Scripting::Legacy::jjLAYER::generateSettableTileAreaAll()

Prepares the whole layer for tileSet().

Has no effect, every tile can already be changed on its own.

Variable documentation

std::int32_t Jazz2::Scripting::Legacy::jjLAYER::widthReal

Width of the layer in tiles, including any widening needed for tiling.

Always equal to width, layers are never stored widened.

float Jazz2::Scripting::Legacy::jjLAYER::xSpeed

Horizontal parallax speed of the layer.

How fast the layer moves relative to the camera: 1 moves it together with the sprite layer, 0 keeps it fixed on screen. How it combines with xAutoSpeed depends on xSpeedModel.

float Jazz2::Scripting::Legacy::jjLAYER::xAutoSpeed

Horizontal automatic scrolling speed of the layer.

Scrolls the layer constantly, regardless of the camera. How it combines with xSpeed depends on xSpeedModel.

float Jazz2::Scripting::Legacy::jjLAYER::xOffset

Horizontal offset of the layer in pixels.

Added to the position of the layer regardless of its speeds. The automatic speed scrolls the layer without changing it. Stored in 16.16 fixed point, so a value out of the range of roughly -32768 to 32767 becomes 0.

float Jazz2::Scripting::Legacy::jjLAYER::xInnerSpeed

Horizontal speed of the texture inside the layer.

Used only when textureSurface is SURFACE::INNERLAYER or SURFACE::INNERWINDOW: the regular speeds then place the layer in the level, while the inner speeds move the texture within it. Defaults to 0.

TextureStyleParams Jazz2::Scripting::Legacy::jjLAYER::warpHorizon

Properties used when textureStyle is TEXTURE::WARPHORIZON.

The texture is drawn as a floor and a ceiling stretching to a horizon in the distance. The horizon can fade into the fade color and show stars.

TextureStyleParams Jazz2::Scripting::Legacy::jjLAYER::tunnel

Properties used when textureStyle is TEXTURE::TUNNEL.

The texture is drawn as rings shrinking towards a center in the distance, which can fade into the fade color. spiral makes the rings twist inwards.

TextureStyleParams Jazz2::Scripting::Legacy::jjLAYER::menu

Properties used when textureStyle is TEXTURE::MENU.

Meant for the rotating background of the main menu, built from three 16-color palette rows.

TextureStyleParams Jazz2::Scripting::Legacy::jjLAYER::tileMenu

Properties used when textureStyle is TEXTURE::TILEMENU.

The rotating background of the main menu: three parts repeated over the view, each turning and zooming at its own pace around a pivot. The front part is the layer's texture, the middle one the 2×2 tiles at the top left corner of layer 4, and the back one the tile at 0,2 of layer 4.

TextureStyleParams Jazz2::Scripting::Legacy::jjLAYER::wave

Properties used when textureStyle is TEXTURE::WAVE.

The texture is drawn flat and repeated, with its rows and columns shifted by sine waves.

TextureStyleParams Jazz2::Scripting::Legacy::jjLAYER::cylinder

Properties used when textureStyle is TEXTURE::CYLINDER.

The texture is drawn as the inside of a horizontal tube receding a short way into the distance, which can fade into the fade color near its horizon.

TextureStyleParams Jazz2::Scripting::Legacy::jjLAYER::reflection

Properties used when textureStyle is TEXTURE::REFLECTION.

The part of the view below the horizon is drawn as a plane stretching into the distance that mirrors everything drawn above the horizon before this layer, rippled by the texture. Nothing is drawn above the horizon. The layer ignores its sprite mode.

std::int32_t Jazz2::Scripting::Legacy::jjLAYER::rotationAngle

Angle offset of the layer's swaying while a player is stoned.

Uses the range of 0 to 1023 of jjSin() and jjCos().

std::int32_t Jazz2::Scripting::Legacy::jjLAYER::rotationRadiusMultiplier

How far the layer sways while a player is stoned.

0 keeps the layer still.

bool Jazz2::Scripting::Legacy::jjLAYER::limitVisibleRegion

Whether the layer is shifted down by an amount that depends on the resolution.

Applies to a layer that doesn't repeat vertically and uses LAYERSPEEDMODEL::NORMAL or LAYERSPEEDMODEL::BOTHSPEEDS vertically.

bool Jazz2::Scripting::Legacy::jjLAYER::hasTileMap

Whether the layer has a tile map.

false for a layer of the level that contains no tiles at all, nothing can ever be drawn of it. Always true for a layer created from a size or by jjLayersFromLevel().

bool Jazz2::Scripting::Legacy::jjLAYER::hasTiles

Whether the layer is drawn.

Setting it to false hides the layer. A layer left out by jjLayerOrderSet() isn't drawn either way.

std::int32_t Jazz2::Scripting::Legacy::jjLAYER::SpeedModeX

Horizontal speed model of the layer.

Decides how the speed properties position the layer horizontally, see LAYERSPEEDMODEL::LayerSpeedModel.

std::int32_t Jazz2::Scripting::Legacy::jjLAYER::SpeedModeY

Vertical speed model of the layer.

Decides how the speed properties position the layer vertically, see LAYERSPEEDMODEL::LayerSpeedModel.