all repos — mgba @ ba65740b159a2ce3bceecf1088f859f326d69b34

mGBA Game Boy Advance Emulator

GB: Allow setting DMG palette
Vicki Pfau vi@endrift.com
Mon, 03 Apr 2017 14:32:21 -0700
commit

ba65740b159a2ce3bceecf1088f859f326d69b34

parent

f73fd7f3da3e36b6a11fe5e15cafaca8c0fd733f

3 files changed, 24 insertions(+), 0 deletions(-)

jump to
M include/mgba/internal/gb/video.hinclude/mgba/internal/gb/video.h

@@ -139,6 +139,8 @@ 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); + struct GBSerializedState; void GBVideoSerialize(const struct GBVideo* video, struct GBSerializedState* state); void GBVideoDeserialize(struct GBVideo* video, const struct GBSerializedState* state);
M src/gb/core.csrc/gb/core.c

@@ -105,6 +105,21 @@ } else {

gb->audio.masterVolume = core->opts.volume; } gb->video.frameskip = core->opts.frameskip; + + int color; + if (mCoreConfigGetIntValue(&core->config, "gb.pal[0]", &color)) { + GBVideoSetPalette(&gb->video, 0, color); + } + if (mCoreConfigGetIntValue(&core->config, "gb.pal[1]", &color)) { + GBVideoSetPalette(&gb->video, 1, color); + } + if (mCoreConfigGetIntValue(&core->config, "gb.pal[2]", &color)) { + GBVideoSetPalette(&gb->video, 2, color); + } + if (mCoreConfigGetIntValue(&core->config, "gb.pal[3]", &color)) { + GBVideoSetPalette(&gb->video, 3, color); + } + mCoreConfigCopyValue(&core->config, config, "gb.bios"); mCoreConfigCopyValue(&core->config, config, "gbc.bios");
M src/gb/video.csrc/gb/video.c

@@ -439,6 +439,13 @@ video->vramBank = &video->vram[value * GB_SIZE_VRAM_BANK0];

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