Add COL file indexing for palettes
This commit is contained in:
@@ -170,6 +170,18 @@ absl::Status GraphicsEditor::DrawPaletteControls() {
|
|||||||
status_ = temp_rom_.LoadFromFile(col_file_path_,
|
status_ = temp_rom_.LoadFromFile(col_file_path_,
|
||||||
/*z3_load=*/false);
|
/*z3_load=*/false);
|
||||||
auto col_data_ = gfx::GetColFileData(temp_rom_.data());
|
auto col_data_ = gfx::GetColFileData(temp_rom_.data());
|
||||||
|
if (col_file_palette_group_.size() != 0) {
|
||||||
|
col_file_palette_group_.Clear();
|
||||||
|
}
|
||||||
|
for (int i = 0; i < col_data_.size(); i += 8) {
|
||||||
|
// Extract 8 colors from the col_data_ and make them into a palette
|
||||||
|
gfx::SNESPalette palette;
|
||||||
|
for (int j = 0; j < 8; j++) {
|
||||||
|
palette.AddColor(col_data_[i + j]);
|
||||||
|
}
|
||||||
|
// color.AddColor()
|
||||||
|
col_file_palette_group_.AddPalette(palette);
|
||||||
|
}
|
||||||
col_file_palette_ = gfx::SNESPalette(col_data_);
|
col_file_palette_ = gfx::SNESPalette(col_data_);
|
||||||
col_file_ = true;
|
col_file_ = true;
|
||||||
is_open_ = true;
|
is_open_ = true;
|
||||||
@@ -282,12 +294,6 @@ absl::Status GraphicsEditor::DecompressImportData(int size) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
absl::Status GraphicsEditor::DecompressSuperDonkey() {
|
absl::Status GraphicsEditor::DecompressSuperDonkey() {
|
||||||
if (rom_.isLoaded()) {
|
|
||||||
auto palette_group =
|
|
||||||
rom_.GetPaletteGroup(kPaletteGroupAddressesKeys[current_palette_]);
|
|
||||||
palette_ = palette_group.palettes[current_palette_index_];
|
|
||||||
}
|
|
||||||
|
|
||||||
int i = 0;
|
int i = 0;
|
||||||
for (const auto& offset : kSuperDonkeyTiles) {
|
for (const auto& offset : kSuperDonkeyTiles) {
|
||||||
int offset_value =
|
int offset_value =
|
||||||
@@ -300,9 +306,13 @@ absl::Status GraphicsEditor::DecompressSuperDonkey() {
|
|||||||
gfx::Bitmap(core::kTilesheetWidth, core::kTilesheetHeight,
|
gfx::Bitmap(core::kTilesheetWidth, core::kTilesheetHeight,
|
||||||
core::kTilesheetDepth, converted_sheet.data(), 0x1000);
|
core::kTilesheetDepth, converted_sheet.data(), 0x1000);
|
||||||
if (col_file_) {
|
if (col_file_) {
|
||||||
graphics_bin_[i].ApplyPalette(col_file_palette_);
|
graphics_bin_[i].ApplyPalette(
|
||||||
|
col_file_palette_group_[current_palette_index_]);
|
||||||
} else {
|
} else {
|
||||||
// ROM palette
|
// ROM palette
|
||||||
|
auto palette_group =
|
||||||
|
rom_.GetPaletteGroup(kPaletteGroupAddressesKeys[current_palette_]);
|
||||||
|
palette_ = palette_group.palettes[current_palette_index_];
|
||||||
graphics_bin_[i].ApplyPalette(palette_);
|
graphics_bin_[i].ApplyPalette(palette_);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -321,9 +331,13 @@ absl::Status GraphicsEditor::DecompressSuperDonkey() {
|
|||||||
gfx::Bitmap(core::kTilesheetWidth, core::kTilesheetHeight,
|
gfx::Bitmap(core::kTilesheetWidth, core::kTilesheetHeight,
|
||||||
core::kTilesheetDepth, converted_sheet.data(), 0x1000);
|
core::kTilesheetDepth, converted_sheet.data(), 0x1000);
|
||||||
if (col_file_) {
|
if (col_file_) {
|
||||||
graphics_bin_[i].ApplyPalette(col_file_palette_);
|
graphics_bin_[i].ApplyPalette(
|
||||||
|
col_file_palette_group_[current_palette_index_]);
|
||||||
} else {
|
} else {
|
||||||
// ROM palette
|
// ROM palette
|
||||||
|
auto palette_group =
|
||||||
|
rom_.GetPaletteGroup(kPaletteGroupAddressesKeys[current_palette_]);
|
||||||
|
palette_ = palette_group.palettes[current_palette_index_];
|
||||||
graphics_bin_[i].ApplyPalette(palette_);
|
graphics_bin_[i].ApplyPalette(palette_);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -126,6 +126,8 @@ class GraphicsEditor {
|
|||||||
|
|
||||||
gfx::BitmapTable clipboard_graphics_bin_;
|
gfx::BitmapTable clipboard_graphics_bin_;
|
||||||
|
|
||||||
|
gfx::PaletteGroup col_file_palette_group_;
|
||||||
|
|
||||||
gfx::SNESPalette palette_;
|
gfx::SNESPalette palette_;
|
||||||
gfx::SNESPalette col_file_palette_;
|
gfx::SNESPalette col_file_palette_;
|
||||||
|
|
||||||
|
|||||||
@@ -81,8 +81,15 @@ class SNESPalette {
|
|||||||
explicit SNESPalette(const std::vector<SNESColor>&);
|
explicit SNESPalette(const std::vector<SNESColor>&);
|
||||||
|
|
||||||
void Create(const std::vector<SNESColor>&);
|
void Create(const std::vector<SNESColor>&);
|
||||||
void AddColor(SNESColor color) { colors.push_back(color); }
|
void AddColor(SNESColor color) {
|
||||||
|
colors.push_back(color);
|
||||||
|
size_++;
|
||||||
|
}
|
||||||
auto GetColor(int i) const { return colors[i]; }
|
auto GetColor(int i) const { return colors[i]; }
|
||||||
|
void Clear() {
|
||||||
|
colors.clear();
|
||||||
|
size_ = 0;
|
||||||
|
}
|
||||||
|
|
||||||
SNESColor operator[](int i) {
|
SNESColor operator[](int i) {
|
||||||
if (i > size_) {
|
if (i > size_) {
|
||||||
@@ -133,6 +140,10 @@ struct PaletteGroup {
|
|||||||
}
|
}
|
||||||
palettes[0].AddColor(color);
|
palettes[0].AddColor(color);
|
||||||
}
|
}
|
||||||
|
void Clear() {
|
||||||
|
palettes.clear();
|
||||||
|
size_ = 0;
|
||||||
|
}
|
||||||
SNESPalette operator[](int i) {
|
SNESPalette operator[](int i) {
|
||||||
if (i > size_) {
|
if (i > size_) {
|
||||||
std::cout << "PaletteGroup: Index out of bounds" << std::endl;
|
std::cout << "PaletteGroup: Index out of bounds" << std::endl;
|
||||||
|
|||||||
Reference in New Issue
Block a user