8#include "imgui/imgui.h"
27 uint16_t red = color.
red / 8;
28 uint16_t green = color.
green / 8;
29 uint16_t blue = color.
blue / 8;
44 const uint16_t color =
45 (
static_cast<uint16_t
>(rom[offset + 1]) << 8) | rom[offset];
49std::vector<snes_color>
Extract(
const char* data,
unsigned int offset,
50 unsigned int palette_size) {
51 std::vector<snes_color> palette(palette_size);
52 for (
unsigned int i = 0; i < palette_size * 2; i += 2) {
53 uint16_t
snes_color = (
static_cast<uint8_t
>(data[offset + i + 1]) << 8) |
54 static_cast<uint8_t
>(data[offset + i]);
60std::vector<char>
Convert(
const std::vector<snes_color>& palette) {
61 std::vector<char> data(palette.size() * 2);
62 for (
unsigned int i = 0; i < palette.size(); i++) {
64 data[i * 2] = snes_data & 0xFF;
65 data[i * 2 + 1] = snes_data >> 8;
75 std::vector<SnesColor> colors;
79 for (
int i = 0; i < 512; i += 2) {
80 colors[i / 2] =
GetCgxColor((uint16_t)((data[i + 1] << 8) + data[i]));
96 color.
red =
static_cast<uint16_t
>(
rgb_.x);
97 color.
green =
static_cast<uint16_t
>(
rgb_.y);
98 color.
blue =
static_cast<uint16_t
>(
rgb_.z);
113 rgb_ = ImVec4(
static_cast<float>(col.
red),
static_cast<float>(col.
green),
void set_snes(uint16_t val)
Set color from SNES 15-bit format.
void set_rgb(const ImVec4 val)
Set color from ImVec4 (0.0-1.0 range)
snes_color ConvertSnesToRgb(uint16_t color_snes)
Convert SNES 15-bit color to RGB (0-255 range)
std::vector< snes_color > Extract(const char *data, unsigned int offset, unsigned int palette_size)
constexpr uint16_t SNES_GREEN_MASK
uint16_t ConvertRgbToSnes(const snes_color &color)
Convert RGB (0-255) to SNES 15-bit color.
std::vector< char > Convert(const std::vector< snes_color > &palette)
SnesColor ReadColorFromRom(int offset, const uint8_t *rom)
constexpr uint16_t SNES_BLUE_SHIFT
constexpr uint16_t SNES_GREEN_SHIFT
constexpr uint8_t ExpandSnesChannel(uint8_t value)
constexpr uint16_t SNES_RED_MASK
constexpr uint16_t SNES_BLUE_MASK
constexpr float kColorByteMaxF
constexpr uint8_t kColorByteMax
SnesColor GetCgxColor(uint16_t color)
std::vector< SnesColor > GetColFileData(uint8_t *data)
SNES color in 15-bit RGB format (BGR555)