Rename SNESPalette, SNESColor to SnesPalette, SnesColor

Create snes_color.h and snes_color.cc to separate concerns
This commit is contained in:
scawful
2024-01-31 21:09:42 -05:00
parent adb7f0666e
commit 693dca1329
34 changed files with 391 additions and 316 deletions

View File

@@ -22,7 +22,7 @@ class DungeonObjectRenderer : public SharedROM {
public:
struct PseudoVram {
std::array<uint8_t, 16> sheets;
std::vector<gfx::SNESPalette> palettes;
std::vector<gfx::SnesPalette> palettes;
};
DungeonObjectRenderer() = default;

View File

@@ -229,16 +229,16 @@ void OverworldMap::LoadAreaGraphics() {
namespace palette_internal {
void SetColorsPalette(ROM& rom, int index, gfx::SNESPalette& current,
gfx::SNESPalette main, gfx::SNESPalette animated,
gfx::SNESPalette aux1, gfx::SNESPalette aux2,
gfx::SNESPalette hud, gfx::SNESColor bgrcolor,
gfx::SNESPalette spr, gfx::SNESPalette spr2) {
void SetColorsPalette(ROM& rom, int index, gfx::SnesPalette& current,
gfx::SnesPalette main, gfx::SnesPalette animated,
gfx::SnesPalette aux1, gfx::SnesPalette aux2,
gfx::SnesPalette hud, gfx::SnesColor bgrcolor,
gfx::SnesPalette spr, gfx::SnesPalette spr2) {
// Palettes infos, color 0 of a palette is always transparent (the arrays
// contains 7 colors width wide) There is 16 color per line so 16*Y
// Left side of the palette - Main, Animated
std::vector<gfx::SNESColor> new_palette(256);
std::vector<gfx::SnesColor> new_palette(256);
// Main Palette, Location 0,2 : 35 colors [7x5]
int k = 0;
@@ -347,7 +347,7 @@ void SetColorsPalette(ROM& rom, int index, gfx::SNESPalette& current,
} // namespace palette_internal
// New helper function to get a palette from the ROM.
gfx::SNESPalette OverworldMap::GetPalette(const std::string& group, int index,
gfx::SnesPalette OverworldMap::GetPalette(const std::string& group, int index,
int previousIndex, int limit) {
if (index == 255) {
index = rom_[rom_.version_constants().overworldMapPaletteGroup +
@@ -382,10 +382,10 @@ void OverworldMap::LoadPalette() {
uchar pal5 = rom_[overworldSpritePaletteGroup +
(sprite_palette_[game_state_] * 2) + 1];
gfx::SNESColor bgr = rom_.palette_group("grass")[0].GetColor(0);
gfx::SnesColor bgr = rom_.palette_group("grass")[0].GetColor(0);
gfx::SNESPalette aux1 = GetPalette("ow_aux", pal1, previousPalId, 20);
gfx::SNESPalette aux2 = GetPalette("ow_aux", pal2, previousPalId, 20);
gfx::SnesPalette aux1 = GetPalette("ow_aux", pal1, previousPalId, 20);
gfx::SnesPalette aux2 = GetPalette("ow_aux", pal2, previousPalId, 20);
// Additional handling of `pal3` and `parent_`
if (pal3 == 255) {
@@ -405,20 +405,22 @@ void OverworldMap::LoadPalette() {
if (parent_ == 0x88) {
pal0 = 4;
}
gfx::SNESPalette main = GetPalette("ow_main", pal0, previousPalId, 255);
gfx::SNESPalette animated =
gfx::SnesPalette main = GetPalette("ow_main", pal0, previousPalId, 255);
gfx::SnesPalette animated =
GetPalette("ow_animated", std::min((int)pal3, 13), previousPalId, 14);
gfx::SNESPalette hud = rom_.palette_group("hud")[0];
gfx::SnesPalette hud = rom_.palette_group("hud")[0];
gfx::SNESPalette spr = GetPalette("sprites_aux3", pal4, previousSprPalId, 24);
gfx::SNESPalette spr2 =
gfx::SnesPalette spr = GetPalette("sprites_aux3", pal4, previousSprPalId, 24);
gfx::SnesPalette spr2 =
GetPalette("sprites_aux3", pal5, previousSprPalId, 24);
palette_internal::SetColorsPalette(rom_, parent_, current_palette_, main,
animated, aux1, aux2, hud, bgr, spr, spr2);
gfx::Paletteset paletteset{main, animated, aux1, aux2, bgr, hud, spr, spr2};
palettesets_[area_graphics_] = paletteset;
if (palettesets_.count(area_palette_) == 0) {
palettesets_[area_palette_] = gfx::Paletteset{
main, animated, aux1, aux2, bgr, hud, spr, spr2, current_palette_};
}
}
// New helper function to process graphics buffer.

View File

@@ -103,7 +103,7 @@ class OverworldMap : public GfxContext {
void LoadDeathMountainGFX();
void ProcessGraphicsBuffer(int index, int static_graphics_offset, int size);
gfx::SNESPalette GetPalette(const std::string& group, int index,
gfx::SnesPalette GetPalette(const std::string& group, int index,
int previousIndex, int limit);
bool built_ = false;
@@ -133,7 +133,7 @@ class OverworldMap : public GfxContext {
Bytes bitmap_data_;
OWMapTiles map_tiles_;
gfx::SNESPalette current_palette_;
gfx::SnesPalette current_palette_;
std::vector<gfx::Tile16> tiles16_;
};

View File

@@ -31,7 +31,7 @@ class Inventory : public SharedROM {
Bytes tilesheets_;
Bytes test_;
gfx::Bitmap tilesheets_bmp_;
gfx::SNESPalette palette_;
gfx::SnesPalette palette_;
gui::Canvas canvas_;
std::vector<gfx::TileInfo> tiles_;