Core: Rename GBA color macros to M color macros
Jeffrey Pfau jeffrey@endrift.com
Fri, 21 Oct 2016 14:05:45 -0700
6 files changed,
25 insertions(+),
26 deletions(-)
M
src/core/interface.h
→
src/core/interface.h
@@ -18,6 +18,14 @@ typedef uint32_t color_t;
#define BYTES_PER_PIXEL 4 #endif +#define M_R5(X) ((X) & 0x1F) +#define M_G5(X) (((X) >> 5) & 0x1F) +#define M_B5(X) (((X) >> 10) & 0x1F) + +#define M_R8(X) (((((X) << 3) & 0xF8) * 0x21) >> 5) +#define M_G8(X) (((((X) >> 2) & 0xF8) * 0x21) >> 5) +#define M_B8(X) (((((X) >> 7) & 0xF8) * 0x21) >> 5) + struct blip_t; struct mCoreCallbacks {
M
src/gba/video.h
→
src/gba/video.h
@@ -11,14 +11,6 @@
#include "core/core.h" #include "gba/memory.h" -#define GBA_R5(X) ((X) & 0x1F) -#define GBA_G5(X) (((X) >> 5) & 0x1F) -#define GBA_B5(X) (((X) >> 10) & 0x1F) - -#define GBA_R8(X) (((((X) << 3) & 0xF8) * 0x21) >> 5) -#define GBA_G8(X) (((((X) >> 2) & 0xF8) * 0x21) >> 5) -#define GBA_B8(X) (((((X) >> 7) & 0xF8) * 0x21) >> 5) - mLOG_DECLARE_CATEGORY(GBA_VIDEO); enum {
M
src/platform/qt/AssetTile.cpp
→
src/platform/qt/AssetTile.cpp
@@ -10,8 +10,7 @@
#include <QFontDatabase> extern "C" { -// TODO: Move color macros elsewhere -#include "gba/video.h" +#include "core/interface.h" #ifdef M_CORE_GBA #include "gba/memory.h" #endif@@ -133,9 +132,9 @@ uint16_t color = data[index];
m_ui.color->setColor(0, color); m_ui.color->update(); - uint32_t r = GBA_R5(color); - uint32_t g = GBA_G5(color); - uint32_t b = GBA_B5(color); + uint32_t r = M_R5(color); + uint32_t g = M_G5(color); + uint32_t b = M_B5(color); m_ui.r->setText(tr("0x%0 (%1)").arg(r, 2, 16, QChar('0')).arg(r, 2, 10, QChar('0'))); m_ui.g->setText(tr("0x%0 (%1)").arg(g, 2, 16, QChar('0')).arg(g, 2, 10, QChar('0'))); m_ui.b->setText(tr("0x%0 (%1)").arg(b, 2, 16, QChar('0')).arg(b, 2, 10, QChar('0')));
M
src/platform/qt/PaletteView.cpp
→
src/platform/qt/PaletteView.cpp
@@ -114,9 +114,9 @@ return;
} uint16_t color = palette[index]; m_ui.selected->setColor(0, color); - uint32_t r = GBA_R5(color); - uint32_t g = GBA_G5(color); - uint32_t b = GBA_B5(color); + uint32_t r = M_R5(color); + uint32_t g = M_G5(color); + uint32_t b = M_B5(color); uint32_t hexcode = (r << 19) | (g << 11) | (b << 3); hexcode |= (hexcode >> 5) & 0x070707; m_ui.hexcode->setText(tr("#%0").arg(hexcode, 6, 16, QChar('0')));
M
src/platform/qt/Swatch.cpp
→
src/platform/qt/Swatch.cpp
@@ -9,7 +9,7 @@ #include <QMouseEvent>
#include <QPainter> extern "C" { -#include "gba/video.h" +#include "core/interface.h" } using namespace QGBA;@@ -39,9 +39,9 @@ }
void Swatch::setColor(int index, uint16_t color) { m_colors[index].setRgb( - GBA_R8(color), - GBA_G8(color), - GBA_B8(color)); + M_R8(color), + M_G8(color), + M_B8(color)); updateFill(index); }
M
src/util/export.c
→
src/util/export.c
@@ -43,9 +43,9 @@
size_t i; for (i = 0; i < entries; ++i) { uint8_t block[4] = { - GBA_R8(colors[i]), - GBA_G8(colors[i]), - GBA_B8(colors[i]), + M_R8(colors[i]), + M_G8(colors[i]), + M_B8(colors[i]), 0 }; if (vf->write(vf, block, 4) < 4) {@@ -63,9 +63,9 @@ }
size_t i; for (i = 0; i < entries; ++i) { uint8_t block[3] = { - GBA_R8(colors[i]), - GBA_G8(colors[i]), - GBA_B8(colors[i]), + M_R8(colors[i]), + M_G8(colors[i]), + M_B8(colors[i]), }; if (vf->write(vf, block, 3) < 3) { return false;