cleanup rom, gfx, overworld and add comments
This commit is contained in:
@@ -59,10 +59,10 @@ absl::Status LoadCgx(uint8_t bpp, std::string_view filename,
|
||||
file.close();
|
||||
|
||||
if (bpp > 8) {
|
||||
cgx_loaded = gfx::BPP8SNESToIndexed(cgx_data, 40);
|
||||
cgx_loaded = gfx::Bpp8SnesToIndexed(cgx_data, 40);
|
||||
return absl::OkStatus();
|
||||
}
|
||||
cgx_loaded = gfx::BPP8SNESToIndexed(cgx_data, bpp);
|
||||
cgx_loaded = gfx::Bpp8SnesToIndexed(cgx_data, bpp);
|
||||
return absl::OkStatus();
|
||||
}
|
||||
|
||||
|
||||
@@ -146,15 +146,6 @@ SNESPalette::SNESPalette(const std::vector<SNESColor>& cols) {
|
||||
size_ = cols.size();
|
||||
}
|
||||
|
||||
char* SNESPalette::encode() {
|
||||
auto data = new char[size_ * 2];
|
||||
for (unsigned int i = 0; i < size_; i++) {
|
||||
data[i * 2] = (char)(colors[i].GetSNES() & 0xFF);
|
||||
data[i * 2 + 1] = (char)(colors[i].GetSNES() >> 8);
|
||||
}
|
||||
return data;
|
||||
}
|
||||
|
||||
SDL_Palette* SNESPalette::GetSDL_Palette() {
|
||||
auto sdl_palette = std::make_shared<SDL_Palette>();
|
||||
sdl_palette->ncolors = size_;
|
||||
|
||||
@@ -114,11 +114,10 @@ class SNESPalette {
|
||||
explicit SNESPalette(const std::vector<snes_color>&);
|
||||
explicit SNESPalette(const std::vector<SNESColor>&);
|
||||
|
||||
char* encode();
|
||||
SDL_Palette* GetSDL_Palette();
|
||||
|
||||
void Create(const std::vector<SNESColor>& cols) {
|
||||
for (const auto each : cols) {
|
||||
for (const auto& each : cols) {
|
||||
colors.push_back(each);
|
||||
}
|
||||
size_ = cols.size();
|
||||
|
||||
@@ -75,7 +75,9 @@ Bytes PackBppTile(const tile8& tile, const uint32_t bpp) {
|
||||
for (unsigned int col = 0; col < 8; col++) {
|
||||
for (unsigned int row = 0; row < 8; row++) {
|
||||
uchar color = tile.data[col * 8 + row];
|
||||
if (color > maxcolor) throw std::runtime_error("Invalid color value.");
|
||||
if (color > maxcolor) {
|
||||
throw std::invalid_argument("Invalid color value.");
|
||||
}
|
||||
|
||||
// 1bpp format
|
||||
if (bpp == 1) output[col] += (uchar)((color & 1) << (7 - row));
|
||||
@@ -178,7 +180,7 @@ Bytes SnesTo8bppSheet(Bytes sheet, int bpp) {
|
||||
return sheet_buffer_out;
|
||||
}
|
||||
|
||||
Bytes BPP8SNESToIndexed(Bytes data, uint64_t bpp) {
|
||||
Bytes Bpp8SnesToIndexed(Bytes 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]
|
||||
|
||||
@@ -15,7 +15,7 @@ constexpr uchar kGraphicsBitmap[8] = {0x80, 0x40, 0x20, 0x10,
|
||||
0x08, 0x04, 0x02, 0x01};
|
||||
|
||||
Bytes SnesTo8bppSheet(Bytes sheet, int bpp);
|
||||
Bytes BPP8SNESToIndexed(Bytes data, uint64_t bpp = 0);
|
||||
Bytes Bpp8SnesToIndexed(Bytes data, uint64_t bpp = 0);
|
||||
|
||||
struct tile8 {
|
||||
uint32_t id;
|
||||
|
||||
Reference in New Issue
Block a user