Go to the documentation of this file.
7 #include <stdint-gcc.h>
25 return static_cast<uint8_t
>((color << 3) + (color >> 2));
58 template <std::
size_t DEST_SIZE_Y, std::
size_t DEST_SIZE_X, std::
size_t SRC_SIZE_Y, std::
size_t SRC_SIZE_X>
59 void merge2DArray(std::array<std::array<uint32_t, DEST_SIZE_X>, DEST_SIZE_Y> &bufferDest,
60 const std::array<std::array<uint32_t, SRC_SIZE_X>, SRC_SIZE_Y> &bufferSrc,
63 int offsetY = offset.
y;
64 for (
auto &row : bufferSrc) {
65 std::copy(row.begin(), row.end(), bufferDest[offsetY++].begin() + offset.
x);
69 template <std::
size_t SRC_SIZE_Y, std::
size_t SRC_SIZE_X>
70 void VFlipArray(std::array<std::array<uint32_t, SRC_SIZE_X>, SRC_SIZE_Y> &array,
74 for (
int i = offset.y; i < offset.y + size.
y; i++) {
75 std::reverse(array[i].begin() + offset.x, array[i].begin() + offset.x + size.
x);
79 template <std::
size_t SRC_SIZE_Y, std::
size_t SRC_SIZE_X>
80 void HFlipArray(std::array<std::array<uint32_t, SRC_SIZE_X>, SRC_SIZE_Y> &array,
84 std::reverse(array.begin() + offset.x, array.begin() + offset.x + size.
x);
88 template <std::
size_t DEST_SIZE_X, std::
size_t DEST_SIZE_Y, std::
size_t SRC_SIZE_X, std::
size_t SRC_SIZE_Y>
89 static void addBuffer(std::array<std::array<uint32_t, DEST_SIZE_Y>, DEST_SIZE_X> &bufferDest,
90 const std::array<std::array<uint32_t, SRC_SIZE_Y>, SRC_SIZE_X> &bufferSrc)
94 for (
const auto &sourceRow : bufferSrc) {
95 for (
const auto &pixel : sourceRow) {
97 bufferDest[i][j] = pixel;
void HFlipArray(std::array< std::array< uint32_t, SRC_SIZE_X >, SRC_SIZE_Y > &array, const Vector2< int > &size, const Vector2< int > &offset={0, 0})
Definition: PPUUtils.hpp:80
uint16_t posX
Tile X offset.
Definition: PPUUtils.hpp:35
Used to parse easily VRAM Tile information.
Definition: PPUUtils.hpp:32
uint16_t tilePriority
True if the Tile has priority.
Definition: PPUUtils.hpp:41
Definition: Background.cpp:11
Struct to save all specific variables needed for the registers (prev values for example)
Definition: PPUUtils.hpp:51
uint16_t palette
Palette number used by the Tile.
Definition: PPUUtils.hpp:39
uint16_t horizontalFlip
True if the Tile need to be horizontally flipped.
Definition: PPUUtils.hpp:43
uint16_t posY
Tile Y offset.
Definition: PPUUtils.hpp:37
uint8_t to8Bit(int color)
Transform CGRAM color data to 8bits.
Definition: PPUUtils.hpp:23
void merge2DArray(std::array< std::array< uint32_t, DEST_SIZE_X >, DEST_SIZE_Y > &bufferDest, const std::array< std::array< uint32_t, SRC_SIZE_X >, SRC_SIZE_Y > &bufferSrc, const Vector2< int > &offset)
Definition: PPUUtils.hpp:59
uint16_t raw
Definition: PPUUtils.hpp:47
T x
Definition: Vector2.hpp:16
uint8_t hScrollPrevValue
Shared by the four BGnHOFS registers.
Definition: PPUUtils.hpp:55
void VFlipArray(std::array< std::array< uint32_t, SRC_SIZE_X >, SRC_SIZE_Y > &array, const Vector2< int > &size, const Vector2< int > &offset={0, 0})
Definition: PPUUtils.hpp:70
uint16_t verticalFlip
True if the Tile need to be vertically flipped.
Definition: PPUUtils.hpp:45
static void addBuffer(std::array< std::array< uint32_t, DEST_SIZE_Y >, DEST_SIZE_X > &bufferDest, const std::array< std::array< uint32_t, SRC_SIZE_Y >, SRC_SIZE_X > &bufferSrc)
Add a bg buffer to another buffer.
Definition: PPUUtils.hpp:89
uint8_t hvSharedScrollPrevValue
Used by by all eight BGnxOFS registers (0x210D - 0x2114)
Definition: PPUUtils.hpp:53
T y
Definition: Vector2.hpp:17
uint32_t CGRAMColorToRGBA(uint16_t CGRAMColor)
Transform SNES color code BGR to uint32_t RGBA.
Definition: PPUUtils.cpp:10