Skip to content

Commit 4d65410

Browse files
committed
Fix RGB PPU default palette emphasis behavior
1 parent 352e426 commit 4d65410

File tree

2 files changed

+33
-19
lines changed

2 files changed

+33
-19
lines changed

Core/NES/NesDefaultVideoFilter.cpp

+32-18
Original file line numberDiff line numberDiff line change
@@ -42,31 +42,45 @@ NesDefaultVideoFilter::NesDefaultVideoFilter(Emulator* emu) : BaseVideoFilter(em
4242
InitLookupTable();
4343
}
4444

45-
void NesDefaultVideoFilter::GenerateFullColorPalette(uint32_t paletteBuffer[512])
45+
void NesDefaultVideoFilter::GenerateFullColorPalette(uint32_t paletteBuffer[512], PpuModel model)
4646
{
4747
for(int i = 0; i < 64; i++) {
4848
for(int j = 1; j < 8; j++) {
4949
double redColor = (uint8_t)(paletteBuffer[i] >> 16);
5050
double greenColor = (uint8_t)(paletteBuffer[i] >> 8);
5151
double blueColor = (uint8_t)paletteBuffer[i];
52-
if((i & 0x0F) <= 0x0D) {
53-
//Emphasis doesn't affect columns $xE and $xF
54-
if(j & 0x01) {
55-
//Intensify red
56-
greenColor *= 0.84;
57-
blueColor *= 0.84;
58-
}
59-
if(j & 0x02) {
60-
//Intensify green
61-
redColor *= 0.84;
62-
blueColor *= 0.84;
63-
}
64-
if(j & 0x04) {
65-
//Intensify blue
66-
redColor *= 0.84;
67-
greenColor *= 0.84;
52+
if(model == PpuModel::Ppu2C02) {
53+
if((i & 0x0F) <= 0x0D) {
54+
//Emphasis doesn't affect columns $xE and $xF
55+
if(j & 0x01) {
56+
//Intensify red
57+
greenColor *= 0.84;
58+
blueColor *= 0.84;
59+
}
60+
if(j & 0x02) {
61+
//Intensify green
62+
redColor *= 0.84;
63+
blueColor *= 0.84;
64+
}
65+
if(j & 0x04) {
66+
//Intensify blue
67+
redColor *= 0.84;
68+
greenColor *= 0.84;
69+
}
6870
}
6971
}
72+
else {
73+
// RGB PPUs do emphasis in a different way
74+
//Intensify red
75+
if(j & 0x01)
76+
redColor = 0xFF;
77+
//Intensify green
78+
if(j & 0x02)
79+
greenColor = 0xFF;
80+
//Intensify blue
81+
if(j & 0x04)
82+
blueColor = 0xFF;
83+
}
7084

7185
uint8_t r = (uint8_t)(redColor > 255 ? 255 : redColor);
7286
uint8_t g = (uint8_t)(greenColor > 255 ? 255 : greenColor);
@@ -98,7 +112,7 @@ void NesDefaultVideoFilter::GetFullPalette(uint32_t palette[512], NesConfig& nes
98112
}
99113
} else {
100114
memcpy(palette, _ppuPaletteArgb[(int)model], sizeof(_ppuPaletteArgb[(int)_ppuModel]));
101-
GenerateFullColorPalette(palette);
115+
GenerateFullColorPalette(palette, model);
102116
}
103117
}
104118
}

Core/NES/NesDefaultVideoFilter.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ class NesDefaultVideoFilter : public BaseVideoFilter
2525

2626
static void ApplyPalBorder(uint16_t* ppuOutputBuffer);
2727

28-
static void GenerateFullColorPalette(uint32_t paletteBuffer[512]);
28+
static void GenerateFullColorPalette(uint32_t paletteBuffer[512], PpuModel model = PpuModel::Ppu2C02);
2929
static void GetFullPalette(uint32_t palette[512], NesConfig& nesCfg, PpuModel model);
3030

3131
static uint32_t GetDefaultPixelBrightness(uint16_t colorIndex, PpuModel model);

0 commit comments

Comments
 (0)