Skip to content

Commit

Permalink
Honor -c with rgbgfx -r
Browse files Browse the repository at this point in the history
  • Loading branch information
ISSOtm committed Nov 24, 2023
1 parent aa5b163 commit f1eac5e
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
2 changes: 1 addition & 1 deletion include/gfx/rgba.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ struct Rgba {
auto shl = [](uint8_t val, unsigned shift) { return static_cast<uint32_t>(val) << shift; };
return shl(red, 24) | shl(green, 16) | shl(blue, 8) | shl(alpha, 0);
}
friend bool operator!=(Rgba const &lhs, Rgba const &rhs) { return lhs.toCSS() != rhs.toCSS(); }
friend bool operator==(Rgba const &lhs, Rgba const &rhs) { return lhs.toCSS() == rhs.toCSS(); }

/*
* CGB colors are RGB555, so we use bit 15 to signify that the color is transparent instead
Expand Down
9 changes: 9 additions & 0 deletions src/gfx/reverse.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,7 @@ void reverse() {
std::vector<std::array<Rgba, 4>> palettes{
{Rgba(0xFFFFFFFF), Rgba(0xAAAAAAFF), Rgba(0x555555FF), Rgba(0x000000FF)}
};
// If a palette file is used as input, it overrides the default colours.
if (options.palettes.has_value()) {
File file;
if (!file.open(*options.palettes, std::ios::in | std::ios::binary)) {
Expand Down Expand Up @@ -171,6 +172,14 @@ void reverse() {
warning("Read %zu palettes, more than the specified limit of %zu", palettes.size(),
options.nbPalettes);
}

if (options.palSpecType == Options::EXPLICIT && palettes != options.palSpec) {
warning("Colors in the palette file do not match those specified with `-c`!\n");
}
} else if (options.palSpecType == Options::EMBEDDED) {
warning("An embedded palette was requested, but no palette file was specified; ignoring request.\n");
} else if (options.palSpecType == Options::EXPLICIT) {
palettes = std::move(options.palSpec); // We won't be using it again.
}

std::optional<DefaultInitVec<uint8_t>> attrmap;
Expand Down

0 comments on commit f1eac5e

Please sign in to comment.