GB: Allow setting DMG palette

This commit is contained in:
Vicki Pfau 2017-04-03 14:32:21 -07:00
parent f73fd7f3da
commit ba65740b15
3 changed files with 24 additions and 0 deletions

View File

@ -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);

View File

@ -105,6 +105,21 @@ static void _GBCoreLoadConfig(struct mCore* core, const struct mCoreConfig* conf
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");

View File

@ -439,6 +439,13 @@ void GBVideoSwitchBank(struct GBVideo* video, uint8_t value) {
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);