From 1d4b86d61cc8d85792cd077b3caa013987e71a5a Mon Sep 17 00:00:00 2001 From: scawful Date: Wed, 7 Aug 2024 01:29:16 -0400 Subject: [PATCH] add get_color_from_paletteset --- src/yaze.cc | 25 +++++++++++++++++++++++++ src/yaze.h | 3 +++ 2 files changed, 28 insertions(+) diff --git a/src/yaze.cc b/src/yaze.cc index e48221b4..7eed4cb0 100644 --- a/src/yaze.cc +++ b/src/yaze.cc @@ -33,4 +33,29 @@ void unload_rom(Rom rom) { if (rom.impl) { delete static_cast(rom.impl); } +} + +snes_color get_color_from_paletteset(const Rom* rom, int palette_set, + int palette, int color) { + snes_color color_struct; + color_struct.red = 0; + color_struct.green = 0; + color_struct.blue = 0; + + if (rom->impl) { + yaze::app::Rom* internal_rom = static_cast(rom->impl); + auto get_color = + internal_rom->palette_group() + .get_group(yaze::app::gfx::kPaletteGroupAddressesKeys[palette_set]) + ->palette(palette) + .GetColor(color); + if (!get_color.ok()) { + return color_struct; + } + color_struct = get_color.value().rom_color(); + + return color_struct; + } + + return color_struct; } \ No newline at end of file diff --git a/src/yaze.h b/src/yaze.h index 95abc69b..d74c0d45 100644 --- a/src/yaze.h +++ b/src/yaze.h @@ -26,6 +26,9 @@ struct Rom { Rom load_rom(const char* filename); void unload_rom(Rom rom); +snes_color get_color_from_paletteset(const Rom* rom, int palette_set, + int palette, int color); + #ifdef __cplusplus } #endif