all repos — mgba @ aa8f77c18f33515af4b90b1dd9ab20c66846bf49

mGBA Game Boy Advance Emulator

GB Video: Increase palette entry width to 24 bits
Vicki Pfau vi@endrift.com
Tue, 13 Jun 2017 22:15:48 -0700
commit

aa8f77c18f33515af4b90b1dd9ab20c66846bf49

parent

0cc49ac4fbb00e5d44021a262fa872b04b17b94c

3 files changed, 6 insertions(+), 3 deletions(-)

jump to
M include/mgba/core/interface.hinclude/mgba/core/interface.h

@@ -31,6 +31,9 @@ #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) +#define M_RGB5_TO_RGB8(X) ((M_R5(X) << 3) | (M_G5(X) << 11) | (M_B5(X) << 19)) +#define M_RGB8_TO_RGB5(X) ((((X) & 0xF8) >> 3) | (((X) & 0xF800) >> 6) | (((X) & 0xF80000) >> 9)) + struct blip_t; struct mCoreCallbacks {
M include/mgba/internal/gb/video.hinclude/mgba/internal/gb/video.h

@@ -144,7 +144,7 @@ void GBVideoWriteLYC(struct GBVideo* video, uint8_t value);

void GBVideoWritePalette(struct GBVideo* video, uint16_t address, uint8_t value); void GBVideoSwitchBank(struct GBVideo* video, uint8_t value); -void GBVideoSetPalette(struct GBVideo* video, unsigned index, uint16_t color); +void GBVideoSetPalette(struct GBVideo* video, unsigned index, uint32_t color); struct GBSerializedState; void GBVideoSerialize(const struct GBVideo* video, struct GBSerializedState* state);
M src/gb/video.csrc/gb/video.c

@@ -471,11 +471,11 @@ video->vramBank = &video->vram[value * GB_SIZE_VRAM_BANK0];

video->vramCurrentBank = value; } -void GBVideoSetPalette(struct GBVideo* video, unsigned index, uint16_t color) { +void GBVideoSetPalette(struct GBVideo* video, unsigned index, uint32_t color) { if (index >= 4) { return; } - video->dmgPalette[index] = color; + video->dmgPalette[index] = M_RGB8_TO_RGB5(color); } static void GBVideoDummyRendererInit(struct GBVideoRenderer* renderer, enum GBModel model) {