add base snes_color for clib

This commit is contained in:
scawful
2024-08-06 22:46:05 -04:00
parent 38cbba79e2
commit 34ee6c9945
3 changed files with 29 additions and 14 deletions

View File

@@ -1,25 +1,16 @@
#ifndef YAZE_APP_GFX_SNES_COLOR_H_
#define YAZE_APP_GFX_SNES_COLOR_H_
#include "imgui/imgui.h"
#include <cstdint>
#include <vector>
#include "base/snes_color.h"
#include "imgui/imgui.h"
namespace yaze {
namespace app {
namespace gfx {
/**
* @brief Primitive of 16-bit RGB SNES color.
*/
struct snes_color {
uint16_t red; /**< Red component of the color. */
uint16_t blue; /**< Blue component of the color. */
uint16_t green; /**< Green component of the color. */
};
typedef struct snes_color snes_color;
snes_color ConvertSNEStoRGB(uint16_t snes_color);
uint16_t ConvertRGBtoSNES(const snes_color& color);
uint16_t ConvertRGBtoSNES(const ImVec4& color);

View File

@@ -1,7 +1,6 @@
#include "snes_palette.h"
#include <SDL.h>
#include "imgui/imgui.h"
#include <cstdint>
#include <cstdlib>
@@ -15,6 +14,7 @@
#include "absl/status/statusor.h"
#include "app/core/constants.h"
#include "app/gfx/snes_color.h"
#include "imgui/imgui.h"
namespace yaze {
namespace app {
@@ -307,7 +307,7 @@ SnesPalette ReadPaletteFromRom(int offset, int num_colors, const uchar* rom) {
while (color_offset < num_colors) {
short color = (ushort)((rom[offset + 1]) << 8) | rom[offset];
gfx::snes_color new_color;
snes_color new_color;
new_color.red = (color & 0x1F) * 8;
new_color.green = ((color >> 5) & 0x1F) * 8;
new_color.blue = ((color >> 10) & 0x1F) * 8;

24
src/base/snes_color.h Normal file
View File

@@ -0,0 +1,24 @@
#ifndef YAZE_BASE_SNES_COLOR_H_
#define YAZE_BASE_SNES_COLOR_H_
#include <cstdint>
#ifdef __cplusplus
extern "C" {
#endif
/**
* @brief Primitive of 16-bit RGB SNES color.
*/
struct snes_color {
uint16_t red; /**< Red component of the color. */
uint16_t blue; /**< Blue component of the color. */
uint16_t green; /**< Green component of the color. */
};
typedef struct snes_color snes_color;
#ifdef __cplusplus
}
#endif
#endif // YAZE_BASE_SNES_COLOR_H_