big cleanup, replace Bytes alias with std::vector<uint8_t> to reduce ambiguity
This commit is contained in:
@@ -226,15 +226,15 @@ void Bitmap::SaveSurfaceToFile(std::string_view filename) {
|
||||
}
|
||||
|
||||
Bitmap::Bitmap(int width, int height, int depth, int data_size) {
|
||||
Create(width, height, depth, Bytes(data_size, 0));
|
||||
Create(width, height, depth, std::vector<uint8_t>(data_size, 0));
|
||||
}
|
||||
|
||||
void Bitmap::Create(int width, int height, int depth, const Bytes &data) {
|
||||
void Bitmap::Create(int width, int height, int depth, const std::vector<uint8_t> &data) {
|
||||
Create(width, height, depth, kIndexed, data);
|
||||
}
|
||||
|
||||
void Bitmap::Create(int width, int height, int depth, int format,
|
||||
const Bytes &data) {
|
||||
const std::vector<uint8_t> &data) {
|
||||
if (data.empty()) {
|
||||
SDL_Log("Bitmap data is empty\n");
|
||||
active_ = false;
|
||||
|
||||
@@ -72,11 +72,11 @@ class Bitmap {
|
||||
Bitmap() = default;
|
||||
|
||||
Bitmap(int width, int height, int depth, int data_size);
|
||||
Bitmap(int width, int height, int depth, const Bytes &data)
|
||||
Bitmap(int width, int height, int depth, const std::vector<uint8_t> &data)
|
||||
: width_(width), height_(height), depth_(depth), data_(data) {
|
||||
Create(width, height, depth, data);
|
||||
}
|
||||
Bitmap(int width, int height, int depth, const Bytes &data,
|
||||
Bitmap(int width, int height, int depth, const std::vector<uint8_t> &data,
|
||||
const SnesPalette &palette)
|
||||
: width_(width),
|
||||
height_(height),
|
||||
@@ -98,8 +98,8 @@ class Bitmap {
|
||||
/**
|
||||
* @brief Creates a bitmap object with the provided graphical data.
|
||||
*/
|
||||
void Create(int width, int height, int depth, const Bytes &data);
|
||||
void Create(int width, int height, int depth, int format, const Bytes &data);
|
||||
void Create(int width, int height, int depth, const std::vector<uint8_t> &data);
|
||||
void Create(int width, int height, int depth, int format, const std::vector<uint8_t> &data);
|
||||
|
||||
void Reformat(int format);
|
||||
|
||||
@@ -192,7 +192,7 @@ class Bitmap {
|
||||
auto modified() const { return modified_; }
|
||||
auto is_active() const { return active_; }
|
||||
void set_active(bool active) { active_ = active; }
|
||||
void set_data(const Bytes &data) { data_ = data; }
|
||||
void set_data(const std::vector<uint8_t> &data) { data_ = data; }
|
||||
void set_modified(bool modified) { modified_ = modified; }
|
||||
|
||||
private:
|
||||
@@ -207,7 +207,7 @@ class Bitmap {
|
||||
void *texture_pixels = nullptr;
|
||||
|
||||
uint8_t *pixel_data_ = nullptr;
|
||||
Bytes data_;
|
||||
std::vector<uint8_t> data_;
|
||||
|
||||
std::vector<uint8_t> png_data_;
|
||||
|
||||
|
||||
@@ -413,10 +413,11 @@ absl::StatusOr<CompressionPiecePointer> SplitCompressionPiece(
|
||||
return new_piece;
|
||||
}
|
||||
|
||||
Bytes CreateCompressionString(CompressionPiecePointer& start, int mode) {
|
||||
std::vector<uint8_t> CreateCompressionString(CompressionPiecePointer& start,
|
||||
int mode) {
|
||||
uint pos = 0;
|
||||
auto piece = start;
|
||||
Bytes output;
|
||||
std::vector<uint8_t> output;
|
||||
|
||||
while (piece != nullptr) {
|
||||
if (piece->length <= kMaxLengthNormalHeader) { // Normal header
|
||||
@@ -515,12 +516,13 @@ CompressionPiecePointer MergeCopy(CompressionPiecePointer& start) {
|
||||
return start;
|
||||
}
|
||||
|
||||
// TODO TEST compressed data border for each cmd
|
||||
absl::StatusOr<Bytes> CompressV2(const uchar* data, const int start,
|
||||
const int length, int mode, bool check) {
|
||||
absl::StatusOr<std::vector<uint8_t>> CompressV2(const uchar* data,
|
||||
const int start,
|
||||
const int length, int mode,
|
||||
bool check) {
|
||||
// Surely there's no need to compress zero...
|
||||
if (length == 0) {
|
||||
return Bytes();
|
||||
return std::vector<uint8_t>();
|
||||
}
|
||||
|
||||
// Worst case should be a copy of the string with extended header
|
||||
@@ -868,18 +870,20 @@ uint8_t* Uncompress(uint8_t const* src, int* const size,
|
||||
return b2;
|
||||
}
|
||||
|
||||
absl::StatusOr<Bytes> CompressGraphics(const uchar* data, const int pos,
|
||||
const int length) {
|
||||
absl::StatusOr<std::vector<uint8_t>> CompressGraphics(const uchar* data,
|
||||
const int pos,
|
||||
const int length) {
|
||||
return CompressV2(data, pos, length, kNintendoMode2);
|
||||
}
|
||||
|
||||
absl::StatusOr<Bytes> CompressOverworld(const uchar* data, const int pos,
|
||||
const int length) {
|
||||
absl::StatusOr<std::vector<uint8_t>> CompressOverworld(const uchar* data,
|
||||
const int pos,
|
||||
const int length) {
|
||||
return CompressV2(data, pos, length, kNintendoMode1);
|
||||
}
|
||||
|
||||
absl::StatusOr<Bytes> CompressOverworld(const std::vector<uint8_t> data,
|
||||
const int pos, const int length) {
|
||||
absl::StatusOr<std::vector<uint8_t>> CompressOverworld(
|
||||
const std::vector<uint8_t> data, const int pos, const int length) {
|
||||
return CompressV3(data, pos, length, kNintendoMode1);
|
||||
}
|
||||
|
||||
@@ -1304,11 +1308,11 @@ void FinalizeCompression(CompressionContext& context) {
|
||||
<< context.compressed_data.size());
|
||||
}
|
||||
|
||||
absl::StatusOr<Bytes> CompressV3(const std::vector<uint8_t>& data,
|
||||
const int start, const int length, int mode,
|
||||
bool check) {
|
||||
absl::StatusOr<std::vector<uint8_t>> CompressV3(
|
||||
const std::vector<uint8_t>& data, const int start, const int length,
|
||||
int mode, bool check) {
|
||||
if (length == 0) {
|
||||
return Bytes();
|
||||
return std::vector<uint8_t>();
|
||||
}
|
||||
|
||||
CompressionContext context(data, start, length, mode);
|
||||
@@ -1332,7 +1336,8 @@ absl::StatusOr<Bytes> CompressV3(const std::vector<uint8_t>& data,
|
||||
}
|
||||
|
||||
FinalizeCompression(context);
|
||||
return Bytes(context.compressed_data.begin(), context.compressed_data.end());
|
||||
return std::vector<uint8_t>(context.compressed_data.begin(),
|
||||
context.compressed_data.end());
|
||||
}
|
||||
|
||||
// Decompression
|
||||
@@ -1354,8 +1359,8 @@ std::string SetBuffer(const std::vector<uint8_t>& data, int src_pos,
|
||||
return buffer;
|
||||
}
|
||||
|
||||
void memfill(const uchar* data, Bytes& buffer, int buffer_pos, int offset,
|
||||
int length) {
|
||||
void memfill(const uchar* data, std::vector<uint8_t>& buffer, int buffer_pos,
|
||||
int offset, int length) {
|
||||
auto a = data[offset];
|
||||
auto b = data[offset + 1];
|
||||
for (int i = 0; i < length; i = i + 2) {
|
||||
@@ -1364,13 +1369,13 @@ void memfill(const uchar* data, Bytes& buffer, int buffer_pos, int offset,
|
||||
}
|
||||
}
|
||||
|
||||
absl::StatusOr<Bytes> DecompressV2(const uchar* data, int offset, int size,
|
||||
int mode) {
|
||||
absl::StatusOr<std::vector<uint8_t>> DecompressV2(const uchar* data, int offset,
|
||||
int size, int mode) {
|
||||
if (size == 0) {
|
||||
return Bytes();
|
||||
return std::vector<uint8_t>();
|
||||
}
|
||||
|
||||
Bytes buffer(size, 0);
|
||||
std::vector<uint8_t> buffer(size, 0);
|
||||
uint length = 0;
|
||||
uint buffer_pos = 0;
|
||||
uchar command = 0;
|
||||
@@ -1451,17 +1456,18 @@ absl::StatusOr<Bytes> DecompressV2(const uchar* data, int offset, int size,
|
||||
return buffer;
|
||||
}
|
||||
|
||||
absl::StatusOr<Bytes> DecompressGraphics(const uchar* data, int pos, int size) {
|
||||
absl::StatusOr<std::vector<uint8_t>> DecompressGraphics(const uchar* data,
|
||||
int pos, int size) {
|
||||
return DecompressV2(data, pos, size, kNintendoMode2);
|
||||
}
|
||||
|
||||
absl::StatusOr<Bytes> DecompressOverworld(const uchar* data, int pos,
|
||||
int size) {
|
||||
absl::StatusOr<std::vector<uint8_t>> DecompressOverworld(const uchar* data,
|
||||
int pos, int size) {
|
||||
return DecompressV2(data, pos, size, kNintendoMode1);
|
||||
}
|
||||
|
||||
absl::StatusOr<Bytes> DecompressOverworld(const std::vector<uint8_t> data,
|
||||
int pos, int size) {
|
||||
absl::StatusOr<std::vector<uint8_t>> DecompressOverworld(
|
||||
const std::vector<uint8_t> data, int pos, int size) {
|
||||
return DecompressV2(data.data(), pos, size, kNintendoMode1);
|
||||
}
|
||||
|
||||
|
||||
@@ -142,21 +142,21 @@ void CompressionCommandAlternativeV2(const uchar* data,
|
||||
* @brief Compresses a buffer of data using the LC_LZ2 algorithm.
|
||||
* \deprecated Use Compress and Uncompress instead.
|
||||
*/
|
||||
absl::StatusOr<Bytes> CompressV2(const uchar* data, const int start,
|
||||
absl::StatusOr<std::vector<uint8_t>> CompressV2(const uchar* data, const int start,
|
||||
const int length, int mode = 1,
|
||||
bool check = false);
|
||||
|
||||
absl::StatusOr<Bytes> CompressGraphics(const uchar* data, const int pos,
|
||||
absl::StatusOr<std::vector<uint8_t>> CompressGraphics(const uchar* data, const int pos,
|
||||
const int length);
|
||||
absl::StatusOr<Bytes> CompressOverworld(const uchar* data, const int pos,
|
||||
absl::StatusOr<std::vector<uint8_t>> CompressOverworld(const uchar* data, const int pos,
|
||||
const int length);
|
||||
absl::StatusOr<Bytes> CompressOverworld(const std::vector<uint8_t> data,
|
||||
absl::StatusOr<std::vector<uint8_t>> CompressOverworld(const std::vector<uint8_t> data,
|
||||
const int pos, const int length);
|
||||
|
||||
absl::StatusOr<CompressionPiecePointer> SplitCompressionPiece(
|
||||
CompressionPiecePointer& piece, int mode);
|
||||
|
||||
Bytes CreateCompressionString(CompressionPiecePointer& start, int mode);
|
||||
std::vector<uint8_t> CreateCompressionString(CompressionPiecePointer& start, int mode);
|
||||
|
||||
absl::Status ValidateCompressionResult(CompressionPiecePointer& chain_head,
|
||||
int mode, int start, int src_data_pos);
|
||||
@@ -213,7 +213,7 @@ void FinalizeCompression(CompressionContext& context);
|
||||
* @brief Compresses a buffer of data using the LC_LZ2 algorithm.
|
||||
* \deprecated Use Compress and Uncompress instead.
|
||||
*/
|
||||
absl::StatusOr<Bytes> CompressV3(const std::vector<uint8_t>& data,
|
||||
absl::StatusOr<std::vector<uint8_t>> CompressV3(const std::vector<uint8_t>& data,
|
||||
const int start, const int length,
|
||||
int mode = 1, bool check = false);
|
||||
|
||||
@@ -229,18 +229,18 @@ uint8_t* Uncompress(uint8_t const* src, int* const size,
|
||||
std::string SetBuffer(const std::vector<uint8_t>& data, int src_pos,
|
||||
int comp_accumulator);
|
||||
std::string SetBuffer(const uchar* data, int src_pos, int comp_accumulator);
|
||||
void memfill(const uchar* data, Bytes& buffer, int buffer_pos, int offset,
|
||||
void memfill(const uchar* data, std::vector<uint8_t>& buffer, int buffer_pos, int offset,
|
||||
int length);
|
||||
|
||||
/**
|
||||
* @brief Decompresses a buffer of data using the LC_LZ2 algorithm.
|
||||
* \deprecated Use Compress and Uncompress instead.
|
||||
*/
|
||||
absl::StatusOr<Bytes> DecompressV2(const uchar* data, int offset,
|
||||
absl::StatusOr<std::vector<uint8_t>> DecompressV2(const uchar* data, int offset,
|
||||
int size = 0x800, int mode = 1);
|
||||
absl::StatusOr<Bytes> DecompressGraphics(const uchar* data, int pos, int size);
|
||||
absl::StatusOr<Bytes> DecompressOverworld(const uchar* data, int pos, int size);
|
||||
absl::StatusOr<Bytes> DecompressOverworld(const std::vector<uint8_t> data,
|
||||
absl::StatusOr<std::vector<uint8_t>> DecompressGraphics(const uchar* data, int pos, int size);
|
||||
absl::StatusOr<std::vector<uint8_t>> DecompressOverworld(const uchar* data, int pos, int size);
|
||||
absl::StatusOr<std::vector<uint8_t>> DecompressOverworld(const std::vector<uint8_t> data,
|
||||
int pos, int size);
|
||||
|
||||
} // namespace lc_lz2
|
||||
|
||||
@@ -20,8 +20,8 @@ namespace scad_format {
|
||||
void FindMetastamp() {
|
||||
int matching_position = -1;
|
||||
bool matched = false;
|
||||
Bytes cgx_rom;
|
||||
Bytes raw_data_;
|
||||
std::vector<uint8_t> cgx_rom;
|
||||
std::vector<uint8_t> raw_data_;
|
||||
for (int i = 0;
|
||||
i < cgx_rom.size() - sizeof(kMatchedBytes) - kOffsetFromMatchedBytesEnd;
|
||||
i++) {
|
||||
|
||||
@@ -25,7 +25,7 @@ namespace gfx {
|
||||
* @brief Internal functions for loading palettes by group.
|
||||
*/
|
||||
namespace palette_group_internal {
|
||||
absl::Status LoadOverworldMainPalettes(const Bytes& rom_data,
|
||||
absl::Status LoadOverworldMainPalettes(const std::vector<uint8_t>& rom_data,
|
||||
gfx::PaletteGroupMap& palette_groups) {
|
||||
auto data = rom_data.data();
|
||||
for (int i = 0; i < 6; i++) {
|
||||
@@ -37,7 +37,7 @@ absl::Status LoadOverworldMainPalettes(const Bytes& rom_data,
|
||||
}
|
||||
|
||||
absl::Status LoadOverworldAuxiliaryPalettes(
|
||||
const Bytes& rom_data, gfx::PaletteGroupMap& palette_groups) {
|
||||
const std::vector<uint8_t>& rom_data, gfx::PaletteGroupMap& palette_groups) {
|
||||
auto data = rom_data.data();
|
||||
for (int i = 0; i < 20; i++) {
|
||||
palette_groups.overworld_aux.AddPalette(
|
||||
@@ -48,7 +48,7 @@ absl::Status LoadOverworldAuxiliaryPalettes(
|
||||
}
|
||||
|
||||
absl::Status LoadOverworldAnimatedPalettes(
|
||||
const Bytes& rom_data, gfx::PaletteGroupMap& palette_groups) {
|
||||
const std::vector<uint8_t>& rom_data, gfx::PaletteGroupMap& palette_groups) {
|
||||
auto data = rom_data.data();
|
||||
for (int i = 0; i < 14; i++) {
|
||||
palette_groups.overworld_animated.AddPalette(gfx::ReadPaletteFromRom(
|
||||
@@ -57,7 +57,7 @@ absl::Status LoadOverworldAnimatedPalettes(
|
||||
return absl::OkStatus();
|
||||
}
|
||||
|
||||
absl::Status LoadHUDPalettes(const Bytes& rom_data,
|
||||
absl::Status LoadHUDPalettes(const std::vector<uint8_t>& rom_data,
|
||||
gfx::PaletteGroupMap& palette_groups) {
|
||||
auto data = rom_data.data();
|
||||
for (int i = 0; i < 2; i++) {
|
||||
@@ -67,7 +67,7 @@ absl::Status LoadHUDPalettes(const Bytes& rom_data,
|
||||
return absl::OkStatus();
|
||||
}
|
||||
|
||||
absl::Status LoadGlobalSpritePalettes(const Bytes& rom_data,
|
||||
absl::Status LoadGlobalSpritePalettes(const std::vector<uint8_t>& rom_data,
|
||||
gfx::PaletteGroupMap& palette_groups) {
|
||||
auto data = rom_data.data();
|
||||
palette_groups.global_sprites.AddPalette(
|
||||
@@ -77,7 +77,7 @@ absl::Status LoadGlobalSpritePalettes(const Bytes& rom_data,
|
||||
return absl::OkStatus();
|
||||
}
|
||||
|
||||
absl::Status LoadArmorPalettes(const Bytes& rom_data,
|
||||
absl::Status LoadArmorPalettes(const std::vector<uint8_t>& rom_data,
|
||||
gfx::PaletteGroupMap& palette_groups) {
|
||||
auto data = rom_data.data();
|
||||
for (int i = 0; i < 5; i++) {
|
||||
@@ -87,7 +87,7 @@ absl::Status LoadArmorPalettes(const Bytes& rom_data,
|
||||
return absl::OkStatus();
|
||||
}
|
||||
|
||||
absl::Status LoadSwordPalettes(const Bytes& rom_data,
|
||||
absl::Status LoadSwordPalettes(const std::vector<uint8_t>& rom_data,
|
||||
gfx::PaletteGroupMap& palette_groups) {
|
||||
auto data = rom_data.data();
|
||||
for (int i = 0; i < 4; i++) {
|
||||
@@ -97,7 +97,7 @@ absl::Status LoadSwordPalettes(const Bytes& rom_data,
|
||||
return absl::OkStatus();
|
||||
}
|
||||
|
||||
absl::Status LoadShieldPalettes(const Bytes& rom_data,
|
||||
absl::Status LoadShieldPalettes(const std::vector<uint8_t>& rom_data,
|
||||
gfx::PaletteGroupMap& palette_groups) {
|
||||
auto data = rom_data.data();
|
||||
for (int i = 0; i < 3; i++) {
|
||||
@@ -107,7 +107,7 @@ absl::Status LoadShieldPalettes(const Bytes& rom_data,
|
||||
return absl::OkStatus();
|
||||
}
|
||||
|
||||
absl::Status LoadSpriteAux1Palettes(const Bytes& rom_data,
|
||||
absl::Status LoadSpriteAux1Palettes(const std::vector<uint8_t>& rom_data,
|
||||
gfx::PaletteGroupMap& palette_groups) {
|
||||
auto data = rom_data.data();
|
||||
for (int i = 0; i < 12; i++) {
|
||||
@@ -117,7 +117,7 @@ absl::Status LoadSpriteAux1Palettes(const Bytes& rom_data,
|
||||
return absl::OkStatus();
|
||||
}
|
||||
|
||||
absl::Status LoadSpriteAux2Palettes(const Bytes& rom_data,
|
||||
absl::Status LoadSpriteAux2Palettes(const std::vector<uint8_t>& rom_data,
|
||||
gfx::PaletteGroupMap& palette_groups) {
|
||||
auto data = rom_data.data();
|
||||
for (int i = 0; i < 11; i++) {
|
||||
@@ -127,7 +127,7 @@ absl::Status LoadSpriteAux2Palettes(const Bytes& rom_data,
|
||||
return absl::OkStatus();
|
||||
}
|
||||
|
||||
absl::Status LoadSpriteAux3Palettes(const Bytes& rom_data,
|
||||
absl::Status LoadSpriteAux3Palettes(const std::vector<uint8_t>& rom_data,
|
||||
gfx::PaletteGroupMap& palette_groups) {
|
||||
auto data = rom_data.data();
|
||||
for (int i = 0; i < 24; i++) {
|
||||
@@ -137,7 +137,7 @@ absl::Status LoadSpriteAux3Palettes(const Bytes& rom_data,
|
||||
return absl::OkStatus();
|
||||
}
|
||||
|
||||
absl::Status LoadDungeonMainPalettes(const Bytes& rom_data,
|
||||
absl::Status LoadDungeonMainPalettes(const std::vector<uint8_t>& rom_data,
|
||||
gfx::PaletteGroupMap& palette_groups) {
|
||||
auto data = rom_data.data();
|
||||
for (int i = 0; i < 20; i++) {
|
||||
@@ -147,7 +147,7 @@ absl::Status LoadDungeonMainPalettes(const Bytes& rom_data,
|
||||
return absl::OkStatus();
|
||||
}
|
||||
|
||||
absl::Status LoadGrassColors(const Bytes& rom_data,
|
||||
absl::Status LoadGrassColors(const std::vector<uint8_t>& rom_data,
|
||||
gfx::PaletteGroupMap& palette_groups) {
|
||||
palette_groups.grass.AddColor(
|
||||
gfx::ReadColorFromRom(kHardcodedGrassLW, rom_data.data()));
|
||||
@@ -158,7 +158,7 @@ absl::Status LoadGrassColors(const Bytes& rom_data,
|
||||
return absl::OkStatus();
|
||||
}
|
||||
|
||||
absl::Status Load3DObjectPalettes(const Bytes& rom_data,
|
||||
absl::Status Load3DObjectPalettes(const std::vector<uint8_t>& rom_data,
|
||||
gfx::PaletteGroupMap& palette_groups) {
|
||||
auto data = rom_data.data();
|
||||
palette_groups.object_3d.AddPalette(
|
||||
@@ -169,7 +169,7 @@ absl::Status Load3DObjectPalettes(const Bytes& rom_data,
|
||||
}
|
||||
|
||||
absl::Status LoadOverworldMiniMapPalettes(
|
||||
const Bytes& rom_data, gfx::PaletteGroupMap& palette_groups) {
|
||||
const std::vector<uint8_t>& rom_data, gfx::PaletteGroupMap& palette_groups) {
|
||||
auto data = rom_data.data();
|
||||
for (int i = 0; i < 2; i++) {
|
||||
palette_groups.overworld_mini_map.AddPalette(gfx::ReadPaletteFromRom(
|
||||
@@ -327,7 +327,7 @@ absl::StatusOr<PaletteGroup> CreatePaletteGroupFromLargePalette(
|
||||
using namespace palette_group_internal;
|
||||
|
||||
// TODO: Refactor LoadAllPalettes to use group names, move to zelda3 namespace
|
||||
absl::Status LoadAllPalettes(const Bytes& rom_data, PaletteGroupMap& groups) {
|
||||
absl::Status LoadAllPalettes(const std::vector<uint8_t>& rom_data, PaletteGroupMap& groups) {
|
||||
RETURN_IF_ERROR(LoadOverworldMainPalettes(rom_data, groups))
|
||||
RETURN_IF_ERROR(LoadOverworldAuxiliaryPalettes(rom_data, groups))
|
||||
RETURN_IF_ERROR(LoadOverworldAnimatedPalettes(rom_data, groups))
|
||||
|
||||
@@ -352,7 +352,7 @@ absl::StatusOr<PaletteGroup> CreatePaletteGroupFromLargePalette(
|
||||
* groups.
|
||||
*
|
||||
*/
|
||||
absl::Status LoadAllPalettes(const Bytes& rom_data, PaletteGroupMap& groups);
|
||||
absl::Status LoadAllPalettes(const std::vector<uint8_t>& rom_data, PaletteGroupMap& groups);
|
||||
|
||||
/**
|
||||
* @brief Represents a set of palettes used in a SNES graphics system.
|
||||
|
||||
@@ -22,7 +22,7 @@ constexpr ushort TileVFlipBit = 0x8000;
|
||||
// Bits used for tile name
|
||||
constexpr ushort TileNameMask = 0x03FF;
|
||||
|
||||
tile8 UnpackBppTile(const Bytes& data, const uint32_t offset,
|
||||
tile8 UnpackBppTile(const std::vector<uint8_t>& data, const uint32_t offset,
|
||||
const uint32_t bpp) {
|
||||
tile8 tile;
|
||||
assert(bpp >= 1 && bpp <= 8);
|
||||
@@ -79,7 +79,7 @@ tile8 UnpackBppTile(const Bytes& data, const uint32_t offset,
|
||||
return tile;
|
||||
}
|
||||
|
||||
Bytes PackBppTile(const tile8& tile, const uint32_t bpp) {
|
||||
std::vector<uint8_t> PackBppTile(const tile8& tile, const uint32_t bpp) {
|
||||
// Allocate memory for output data
|
||||
std::vector<uint8_t> output(bpp * 8, 0); // initialized with 0
|
||||
unsigned maxcolor = 2 << bpp;
|
||||
@@ -148,7 +148,7 @@ std::vector<uint8_t> Convert4bppTo3bpp(const std::vector<uint8_t>& tiles) {
|
||||
return ConvertBpp(tiles, 4, 3);
|
||||
}
|
||||
|
||||
Bytes SnesTo8bppSheet(const Bytes& sheet, int bpp) {
|
||||
std::vector<uint8_t> SnesTo8bppSheet(const std::vector<uint8_t>& sheet, int bpp) {
|
||||
int xx = 0; // positions where we are at on the sheet
|
||||
int yy = 0;
|
||||
int pos = 0;
|
||||
@@ -167,7 +167,7 @@ Bytes SnesTo8bppSheet(const Bytes& sheet, int bpp) {
|
||||
} else if (bpp == 8) {
|
||||
bpp = 64;
|
||||
}
|
||||
Bytes sheet_buffer_out(buffer_size);
|
||||
std::vector<uint8_t> sheet_buffer_out(buffer_size);
|
||||
|
||||
for (int i = 0; i < num_tiles; i++) { // for each tiles, 16 per line
|
||||
for (int y = 0; y < 8; y++) { // for each line
|
||||
@@ -200,7 +200,7 @@ Bytes SnesTo8bppSheet(const Bytes& sheet, int bpp) {
|
||||
return sheet_buffer_out;
|
||||
}
|
||||
|
||||
Bytes Bpp8SnesToIndexed(Bytes data, uint64_t bpp) {
|
||||
std::vector<uint8_t> Bpp8SnesToIndexed(std::vector<uint8_t> data, uint64_t bpp) {
|
||||
// 3BPP
|
||||
// [r0,bp1],[r0,bp2],[r1,bp1],[r1,bp2],[r2,bp1],[r2,bp2],[r3,bp1],[r3,bp2]
|
||||
// [r4,bp1],[r4,bp2],[r5,bp1],[r5,bp2],[r6,bp1],[r6,bp2],[r7,bp1],[r7,bp2]
|
||||
@@ -212,7 +212,7 @@ Bytes Bpp8SnesToIndexed(Bytes data, uint64_t bpp) {
|
||||
// [r4,bp7],[r4,bp8],[r5,bp7],[r5,bp8],[r6,bp7],[r6,bp8],[r7,bp7],[r7,bp8]
|
||||
|
||||
// 16 tiles = 1024 bytes
|
||||
auto buffer = Bytes(data.size());
|
||||
auto buffer = std::vector<uint8_t>(data.size());
|
||||
std::vector<std::vector<uint8_t>> bitmap_data;
|
||||
bitmap_data.resize(0x80);
|
||||
for (auto& each : bitmap_data) {
|
||||
|
||||
@@ -14,8 +14,8 @@ namespace gfx {
|
||||
constexpr uint8_t kGraphicsBitmap[8] = {0x80, 0x40, 0x20, 0x10,
|
||||
0x08, 0x04, 0x02, 0x01};
|
||||
|
||||
Bytes SnesTo8bppSheet(const Bytes& sheet, int bpp);
|
||||
Bytes Bpp8SnesToIndexed(Bytes data, uint64_t bpp = 0);
|
||||
std::vector<uint8_t> SnesTo8bppSheet(const std::vector<uint8_t>& sheet, int bpp);
|
||||
std::vector<uint8_t> Bpp8SnesToIndexed(std::vector<uint8_t> data, uint64_t bpp = 0);
|
||||
|
||||
struct tile8 {
|
||||
uint32_t id;
|
||||
@@ -24,10 +24,10 @@ struct tile8 {
|
||||
};
|
||||
using tile8 = struct tile8;
|
||||
|
||||
tile8 UnpackBppTile(const Bytes& data, const uint32_t offset,
|
||||
tile8 UnpackBppTile(const std::vector<uint8_t>& data, const uint32_t offset,
|
||||
const uint32_t bpp);
|
||||
|
||||
Bytes PackBppTile(const tile8& tile, const uint32_t bpp);
|
||||
std::vector<uint8_t> PackBppTile(const tile8& tile, const uint32_t bpp);
|
||||
|
||||
std::vector<uint8_t> ConvertBpp(const std::vector<uint8_t>& tiles,
|
||||
uint32_t from_bpp, uint32_t to_bpp);
|
||||
|
||||
Reference in New Issue
Block a user