7#include "imgui/imgui.h"
35 uint16_t red = color.
red / 8;
36 uint16_t green = color.
green / 8;
37 uint16_t blue = color.
blue / 8;
50 short color = (uint16_t)((rom[offset + 1]) << 8) | rom[offset];
52 new_color.
red = (color & 0x1F) * 8;
53 new_color.
green = ((color >> 5) & 0x1F) * 8;
54 new_color.
blue = ((color >> 10) & 0x1F) * 8;
59std::vector<snes_color>
Extract(
const char* data,
unsigned int offset,
60 unsigned int palette_size) {
61 std::vector<snes_color> palette(palette_size);
62 for (
unsigned int i = 0; i < palette_size * 2; i += 2) {
63 uint16_t
snes_color = (
static_cast<uint8_t
>(data[offset + i + 1]) << 8) |
64 static_cast<uint8_t
>(data[offset + i]);
70std::vector<char>
Convert(
const std::vector<snes_color>& palette) {
71 std::vector<char> data(palette.size() * 2);
72 for (
unsigned int i = 0; i < palette.size(); i++) {
74 data[i * 2] = snes_data & 0xFF;
75 data[i * 2 + 1] = snes_data >> 8;
82 rgb.x = (color & 0x1F) * 8;
83 rgb.y = ((color & 0x3E0) >> 5) * 8;
84 rgb.z = ((color & 0x7C00) >> 10) * 8;
91 std::vector<SnesColor> colors;
95 for (
int i = 0; i < 512; i += 2) {
96 colors[i / 2] =
GetCgxColor((uint16_t)((data[i + 1] << 8) + data[i]));
void set_rgb(const ImVec4 val)
struct snes_color snes_color
Primitive of 16-bit RGB SNES color.
constexpr uint16_t SNES_GREEN_SHIFT
SnesColor GetCgxColor(uint16_t color)
SnesColor ReadColorFromRom(int offset, const uint8_t *rom)
constexpr uint16_t SNES_RED_MASK
std::vector< SnesColor > GetColFileData(uint8_t *data)
constexpr uint16_t SNES_BLUE_MASK
snes_color ConvertSnesToRgb(uint16_t color_snes)
constexpr uint16_t SNES_GREEN_MASK
std::vector< char > Convert(const std::vector< snes_color > &palette)
uint16_t ConvertRgbToSnes(const snes_color &color)
constexpr uint8_t kColorByteMax
constexpr uint16_t SNES_BLUE_SHIFT
std::vector< snes_color > Extract(const char *data, unsigned int offset, unsigned int palette_size)
Primitive of 16-bit RGB SNES color.