Browse Source

dun_render: Remove the use of `LightTableIndex`

Replaces the global with an argument.
pull/5535/head
Gleb Mazovetskiy 3 years ago committed by Anders Jenbo
parent
commit
aca4aae3c1
  1. 16
      Source/engine/render/dun_render.cpp
  2. 7
      Source/engine/render/dun_render.hpp
  3. 8
      Source/engine/render/scrollrt.cpp

16
Source/engine/render/dun_render.cpp

@ -1142,8 +1142,10 @@ void RenderBlackTileFull(std::uint8_t *dst, int dstPitch)
} // namespace
void RenderTile(const Surface &out, Point position, LevelCelBlock levelCelBlock,
uint16_t levelPieceId, ArchType archType, bool transparency, bool foliage)
void RenderTile(const Surface &out, Point position,
LevelCelBlock levelCelBlock, uint16_t levelPieceId,
uint8_t lightTableIndex, ArchType archType,
bool transparency, bool foliage)
{
const TileType tile = levelCelBlock.type();
const uint32_t *mask = GetMask(tile, levelPieceId, archType, transparency, foliage);
@ -1164,25 +1166,25 @@ void RenderTile(const Surface &out, Point position, LevelCelBlock levelCelBlock,
if (clip.width <= 0 || clip.height <= 0)
return;
const std::uint8_t *tbl = &LightTables[256 * LightTableIndex];
const std::uint8_t *tbl = &LightTables[256 * lightTableIndex];
const auto *pFrameTable = reinterpret_cast<const std::uint32_t *>(pDungeonCels.get());
const auto *src = reinterpret_cast<const std::uint8_t *>(&pDungeonCels[pFrameTable[levelCelBlock.frame()]]);
std::uint8_t *dst = out.at(static_cast<int>(position.x + clip.left), static_cast<int>(position.y - clip.bottom));
const auto dstPitch = out.pitch();
if (mask == &SolidMask[TILE_HEIGHT - 1]) {
if (LightTableIndex == LightsMax) {
if (lightTableIndex == LightsMax) {
RenderTileType<TransparencyType::Solid, LightType::FullyDark>(tile, dst, dstPitch, src, mask, tbl, clip);
} else if (LightTableIndex == 0) {
} else if (lightTableIndex == 0) {
RenderTileType<TransparencyType::Solid, LightType::FullyLit>(tile, dst, dstPitch, src, mask, tbl, clip);
} else {
RenderTileType<TransparencyType::Solid, LightType::PartiallyLit>(tile, dst, dstPitch, src, mask, tbl, clip);
}
} else {
mask -= clip.bottom;
if (LightTableIndex == LightsMax) {
if (lightTableIndex == LightsMax) {
RenderTileType<TransparencyType::Blended, LightType::FullyDark>(tile, dst, dstPitch, src, mask, tbl, clip);
} else if (LightTableIndex == 0) {
} else if (lightTableIndex == 0) {
RenderTileType<TransparencyType::Blended, LightType::FullyLit>(tile, dst, dstPitch, src, mask, tbl, clip);
} else {
RenderTileType<TransparencyType::Blended, LightType::PartiallyLit>(tile, dst, dstPitch, src, mask, tbl, clip);

7
Source/engine/render/dun_render.hpp

@ -123,12 +123,15 @@ private:
* @param position Target buffer coordinates
* @param levelCelBlock The MIN block of the level CEL file.
* @param levelPieceId The piece ID (index into SOLData and DPieceMicros).
* @param lightTableIndex The light level to use for rendering (index into LightTables / 256).
* @param archType The type of arch to render.
* @param transparency Specifies whether transparency is active for the CEL sprite.
* @param foliage Specifies whether the tile has foliage. Foliage is extra content that overlaps the previous tile.
*/
void RenderTile(const Surface &out, Point position, LevelCelBlock levelCelBlock,
uint16_t levelPieceId, ArchType archType, bool transparency, bool foliage);
void RenderTile(const Surface &out, Point position,
LevelCelBlock levelCelBlock, uint16_t levelPieceId,
uint8_t lightTableIndex, ArchType archType,
bool transparency, bool foliage);
/**
* @brief Render a black 64x31 tile

8
Source/engine/render/scrollrt.cpp

@ -506,7 +506,7 @@ void DrawCell(const Surface &out, Point tilePosition, Point targetBufferPosition
const LevelCelBlock levelCelBlock { pMap->mt[2 * i] };
if (levelCelBlock.hasValue()) {
RenderTile(out, targetBufferPosition,
levelCelBlock, levelPieceId,
levelCelBlock, levelPieceId, LightTableIndex,
i == 0 ? ArchType::Left : ArchType::None,
transparency, foliage);
}
@ -515,7 +515,7 @@ void DrawCell(const Surface &out, Point tilePosition, Point targetBufferPosition
const LevelCelBlock levelCelBlock { pMap->mt[2 * i + 1] };
if (levelCelBlock.hasValue()) {
RenderTile(out, targetBufferPosition + Displacement { TILE_WIDTH / 2, 0 },
levelCelBlock, levelPieceId,
levelCelBlock, levelPieceId, LightTableIndex,
i == 0 ? ArchType::Right : ArchType::None,
transparency, foliage);
}
@ -539,7 +539,7 @@ void DrawFloor(const Surface &out, Point tilePosition, Point targetBufferPositio
const LevelCelBlock levelCelBlock { DPieceMicros[levelPieceId].mt[0] };
if (levelCelBlock.hasValue()) {
RenderTile(out, targetBufferPosition,
levelCelBlock, levelPieceId, ArchType::Left,
levelCelBlock, levelPieceId, LightTableIndex, ArchType::Left,
/*transparency=*/false, /*foliage=*/false);
}
}
@ -547,7 +547,7 @@ void DrawFloor(const Surface &out, Point tilePosition, Point targetBufferPositio
const LevelCelBlock levelCelBlock { DPieceMicros[levelPieceId].mt[1] };
if (levelCelBlock.hasValue()) {
RenderTile(out, targetBufferPosition + Displacement { TILE_WIDTH / 2, 0 },
levelCelBlock, levelPieceId, ArchType::Right,
levelCelBlock, levelPieceId, LightTableIndex, ArchType::Right,
/*transparency=*/false, /*foliage=*/false);
}
}

Loading…
Cancel
Save