Skip to content

Commit

Permalink
pce, add alternate palette
Browse files Browse the repository at this point in the history
  • Loading branch information
dinkc64 committed Sep 14, 2024
1 parent 24c3945 commit bd1a2db
Show file tree
Hide file tree
Showing 4 changed files with 54 additions and 5 deletions.
8 changes: 7 additions & 1 deletion src/burn/devices/vdc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,7 @@ void vce_write(UINT8 offset, UINT8 data)
}
}

void vce_palette_init(UINT32 *Palette)
void vce_palette_init(UINT32 *Palette, UINT32 *Alt_Palette)
{
#if defined FBNEO_DEBUG
if (!DebugDev_VDCInitted) bprintf(PRINT_ERROR, _T("vce_palette_init called without init\n"));
Expand All @@ -276,6 +276,12 @@ void vce_palette_init(UINT32 *Palette)
INT32 g = ((i >> 6) & 7) << 5;
INT32 b = ((i >> 0) & 7) << 5;

if (Alt_Palette != NULL) {
r = (Alt_Palette[i] >> 16) & 0xff;
g = (Alt_Palette[i] >> 8) & 0xff;
b = (Alt_Palette[i] >> 0) & 0xff;
}

INT32 y = ((66 * r + 129 * g + 25 * b + 128) >> 8) + 16;

Palette[0x000 + i] = BurnHighCol(r, g, b, 0);
Expand Down
2 changes: 1 addition & 1 deletion src/burn/devices/vdc.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ UINT8 vpc_read(UINT8 offset);
UINT16 *vdc_get_line(UINT32 y);
INT32 vce_linecount();
void vce_reset();
void vce_palette_init(UINT32 *Palette);
void vce_palette_init(UINT32 *Palette, UINT32 *Alt_Palette);
void vce_write(UINT8 offset, UINT8 data);
UINT8 vce_read(UINT8 offset);
extern UINT16 *vce_data;
Expand Down
4 changes: 4 additions & 0 deletions src/burn/drv/pce/d_pce.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,10 @@ static struct BurnDIPInfo pceDIPList[] =
{0x02, 0x01, 0x10, 0x10, "Disabled (hack)" },
{0x02, 0x01, 0x10, 0x00, "Enabled" },

{0 , 0xfe, 0 , 2, "Alt Palette" },
{0x02, 0x01, 0x20, 0x00, "Disabled" },
{0x02, 0x01, 0x20, 0x20, "Enabled" },

{0 , 0xfe, 0 , 2, "Sound Synthesis" },
{0x02, 0x01, 0x80, 0x00, "LQ (Low CPU Usage)" },
{0x02, 0x01, 0x80, 0x80, "HQ (High CPU Usage)" },
Expand Down
45 changes: 42 additions & 3 deletions src/burn/drv/pce/pce.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -523,7 +523,7 @@ static INT32 CommonInit(int type)
bram_locked = 1;

vdc_init();
vce_palette_init(DrvPalette);
vce_palette_init(DrvPalette, NULL);

c6280_init(3579545, 0, (strcmp(BurnDrvGetTextA(DRV_NAME), "pce_lostsunh") == 0) ? 1 : 0);
c6280_set_renderer(PCEDips[2] & 0x80);
Expand Down Expand Up @@ -588,10 +588,45 @@ INT32 PCEExit()
return 0;
}

static UINT32 alt_palette[0x200] = {
0x00020101, 0x0002011a, 0x0003033e, 0x0002015b, 0x00030580, 0x0002019c, 0x000004c5, 0x000203e0, 0x001e0105, 0x00220526, 0x001f0042, 0x00230769, 0x001f0384, 0x002006ab, 0x001c05c9, 0x002208ee,
0x00420711, 0x003e022a, 0x00450951, 0x0041046d, 0x00420b90, 0x003e07af, 0x00440ad5, 0x004009f2, 0x005e0415, 0x005c032e, 0x00610655, 0x005d0571, 0x00600894, 0x005c04b4, 0x00620bd8, 0x005e06f6,
0x007c0518, 0x0081083a, 0x007f0759, 0x00830a7c, 0x007e0998, 0x00820cc1, 0x007f08dd, 0x00850fff, 0x00a00a24, 0x009f093e, 0x00a30c65, 0x00a10b80, 0x00a30ea9, 0x00a00dc5, 0x00a610ea, 0x00a30cff,
0x00bc0b28, 0x00bb0645, 0x00c10d69, 0x00bd0884, 0x00c00fad, 0x00be0bc9, 0x00c40eee, 0x00c10dff, 0x00da082c, 0x00e10f53, 0x00dd0a6d, 0x00e01191, 0x00de0cb1, 0x00e413d5, 0x00e10ff2, 0x00e812ff,
0x000b2403, 0x0007231c, 0x000b2643, 0x0004255d, 0x00082a82, 0x000426a1, 0x00092dc7, 0x000528e3, 0x00272507, 0x00232020, 0x00272747, 0x00202263, 0x00242b86, 0x002027a5, 0x00272acb, 0x002329e7,
0x0043220b, 0x0047292c, 0x0045244b, 0x00462b6e, 0x0042268a, 0x00472fb2, 0x00452bcf, 0x00492ef4, 0x00692b16, 0x00652630, 0x00662d57, 0x00642872, 0x00683196, 0x00642cb7, 0x006b33da, 0x00672ff8,
0x0085281a, 0x00812734, 0x00842a5b, 0x00802976, 0x00862e9d, 0x00822dbb, 0x008930df, 0x00852cfc, 0x00a1291e, 0x00a72c43, 0x00a02b5f, 0x00a62e82, 0x00a32fa1, 0x00a932c7, 0x00a72ee4, 0x00ac35ff,
0x00c52e2a, 0x00c32d47, 0x00c6306a, 0x00c43186, 0x00c834af, 0x00c733cb, 0x00cd36f0, 0x00ca32ff, 0x00e32f2e, 0x00e12a4d, 0x00e2316e, 0x00e02c8a, 0x00e635b3, 0x00e530ce, 0x00eb37f4, 0x00e833ff,
0x000b4301, 0x000c461e, 0x0008473d, 0x000c4a60, 0x0008497b, 0x000d4ea3, 0x00094ac0, 0x001251e5, 0x002f4808, 0x00284722, 0x002c4c49, 0x00284b64, 0x002f4e88, 0x002b4fa7, 0x00274bc5, 0x00304ee9,
0x004b490c, 0x00444426, 0x004a4d4d, 0x00464868, 0x004b4f8c, 0x00494cab, 0x004d53d0, 0x004e4fee, 0x00694610, 0x006a4f35, 0x00664a51, 0x006c5174, 0x00694c90, 0x006f55b9, 0x006b50d4, 0x007659fd,
0x008a4f1c, 0x00864c39, 0x008c535d, 0x00884e78, 0x008f579f, 0x008b52bd, 0x00894ed8, 0x009456ff, 0x00a64c20, 0x00a44d3d, 0x00a85060, 0x00a64f7c, 0x00ad54a4, 0x00a953c1, 0x00b456e6, 0x00b252ff,
0x00c24d24, 0x00c8524b, 0x00c65164, 0x00cd5488, 0x00c955a9, 0x00cf58cc, 0x00d257ea, 0x00d85cff, 0x00e85533, 0x00e6534f, 0x00ec5670, 0x00e9558c, 0x00e750ad, 0x00ed59d0, 0x00f054ee, 0x00f65dff,
0x00106801, 0x000c6718, 0x00106a3f, 0x000d6b59, 0x00116e7e, 0x000d6f9d, 0x001672c1, 0x00126ede, 0x002c6902, 0x00306c24, 0x002c6b43, 0x00337066, 0x002f6f82, 0x003874a9, 0x003473c6, 0x003978ec,
0x00486606, 0x004e6d2b, 0x004a6847, 0x004f716a, 0x004b6c86, 0x005675ad, 0x005270ca, 0x005879f3, 0x006e6f12, 0x006a6a2f, 0x006f7153, 0x006d6e6e, 0x00717595, 0x007472b2, 0x007879d6, 0x007677f7,
0x008a6c16, 0x008e733b, 0x008d6e57, 0x0093777a, 0x008f7299, 0x009a7bbe, 0x009676da, 0x009c7fff, 0x00a66d1a, 0x00ac703f, 0x00a96f5a, 0x00af747e, 0x00ad739d, 0x00b878c2, 0x00b477df, 0x00ba7cff,
0x00cc7529, 0x00c87143, 0x00cf7666, 0x00cd7582, 0x00d878ab, 0x00d579c6, 0x00da7cef, 0x00d87dff, 0x00e8732d, 0x00ef7651, 0x00ed776a, 0x00f27a93, 0x00f579af, 0x00fb7ed2, 0x00f87ef3, 0x00ff82ff,
0x00108701, 0x00158a1a, 0x00118b37, 0x00158e5a, 0x00168f76, 0x001a949f, 0x001693ba, 0x001b98e0, 0x00358c04, 0x00318b1e, 0x00359045, 0x0033905e, 0x003c9487, 0x003895a3, 0x003d98c8, 0x003b96e5,
0x00518d08, 0x0057902d, 0x00539149, 0x005c966c, 0x005a958b, 0x005e9aaf, 0x005b99cc, 0x00619ef5, 0x006f8a0c, 0x00739131, 0x006f8e4d, 0x007a9770, 0x0076928f, 0x007c9bb3, 0x007996d0, 0x007f9ff9,
0x00939218, 0x008f8e35, 0x00959758, 0x00989474, 0x009c9b9b, 0x009a98b8, 0x00a0a0dd, 0x009d9cfd, 0x00af901c, 0x00b59941, 0x00b3945c, 0x00bc9d83, 0x00ba989f, 0x00c1a1c4, 0x00be9ce1, 0x00c3a5ff,
0x00cd9123, 0x00d19645, 0x00cf9560, 0x00da9a87, 0x00d899a4, 0x00df9ec8, 0x00db9ee9, 0x00e1a2ff, 0x00f1992f, 0x00ef974b, 0x00fa9a6c, 0x00f89b8b, 0x00fe9eb0, 0x00fc9fcc, 0x00ffa4f5, 0x00ffa3ff,
0x0019aa01, 0x001db31f, 0x001eaf3b, 0x0022b75c, 0x001eb47c, 0x0025bda1, 0x0021b8bd, 0x001bb6da, 0x0035ab01, 0x0039b023, 0x003cb13f, 0x0040b462, 0x003cb581, 0x0041baa5, 0x003db9c1, 0x0043beeb,
0x0059b30a, 0x0057b127, 0x0060b64a, 0x005cb566, 0x0063ba8d, 0x005fbba9, 0x0065bfce, 0x0061bfef, 0x0077b00e, 0x0080b933, 0x007eb74e, 0x0082ba72, 0x0081bb91, 0x007db8ac, 0x0083c0d2, 0x007fbcf3,
0x0093ae12, 0x009eb737, 0x009ab452, 0x00a0bb79, 0x009db895, 0x00a3c1ba, 0x00a0bdd6, 0x00a2c5ff, 0x00b7b621, 0x00bab43b, 0x00c0bd5e, 0x00bcb87d, 0x00c3c1a1, 0x00c1bebe, 0x00c7c7e7, 0x00c0c2ff,
0x00d5b725, 0x00e0bc46, 0x00dcba62, 0x00e3c389, 0x00e1bea7, 0x00dfbfc2, 0x00e5c4eb, 0x00dec3ff, 0x00f1b429, 0x00fcbd4c, 0x00fabb66, 0x00ffbf8d, 0x00ffbfaa, 0x00ffc4ce, 0x00ffc5ef, 0x00ffc9ff,
0x0026d201, 0x0022ce19, 0x0026d73d, 0x0023d456, 0x0027dd7f, 0x0025d99b, 0x0026e2bf, 0x0022dedf, 0x0042d300, 0x003ecf1d, 0x0044d440, 0x0041d55a, 0x0045da83, 0x0041db9f, 0x0044dfc4, 0x0040dfe4,
0x005ed004, 0x0064d729, 0x0060d544, 0x0067da68, 0x0063db87, 0x0067e0aa, 0x0062e0c8, 0x0066e5f1, 0x0084d913, 0x0080d52d, 0x0087da50, 0x0083db6c, 0x0089e093, 0x0085e1ae, 0x0088e6d7, 0x0084e6f5,
0x00a0d617, 0x009ed231, 0x00a3db54, 0x00a1d873, 0x00a7e197, 0x00a3deb3, 0x00a6e7db, 0x00a2e3f9, 0x00bcd71b, 0x00c2da3c, 0x00c1d858, 0x00c7e17f, 0x00c3de9b, 0x00c6e7c0, 0x00c4e4e0, 0x00c9edff,
0x00e2dc27, 0x00e0db40, 0x00e5e064, 0x00e3de83, 0x00e9e7a8, 0x00e4e4c4, 0x00eaeded, 0x00e7e9ff, 0x00fedd2b, 0x00fcd844, 0x00ffe168, 0x00ffdf87, 0x00ffe4ac, 0x00ffe5c8, 0x00ffeaf1, 0x00ffebff,
0x0026f101, 0x002bf61b, 0x0027f435, 0x002bfd58, 0x0027f977, 0x002aff9c, 0x0026ffb8, 0x002bffe1, 0x004af602, 0x0047f71f, 0x004dfc42, 0x0049fa5c, 0x004aff85, 0x0047ffa0, 0x004cffc6, 0x0049ffe6,
0x0068f709, 0x0065f523, 0x0069fa46, 0x0067fb62, 0x0068ff89, 0x0064ffa4, 0x006affcd, 0x0067ffeb, 0x0084f40d, 0x0089fd2f, 0x0087fb4a, 0x008bff71, 0x0086ff8d, 0x008affb0, 0x0088ffd1, 0x008efff7,
0x00a9fd19, 0x00a7fa33, 0x00abff56, 0x00a9ff75, 0x00acff98, 0x00a8ffb5, 0x00afffde, 0x00acfffa, 0x00c5fa1d, 0x00c3fb36, 0x00c9ff5a, 0x00c7fe79, 0x00c8ff9c, 0x00c6ffba, 0x00cdffe2, 0x00caffff,
0x00e3fb21, 0x00e9ff42, 0x00e5ff5e, 0x00e8ff85, 0x00e6ffa0, 0x00ecffc9, 0x00ebffe7, 0x00f1ffff, 0x00ffff2d, 0x00ffff46, 0x00ffff6d, 0x00ffff89, 0x00ffffae, 0x00ffffcd, 0x00fffff3, 0x00ffffff
};

INT32 PCEDraw()
{
if (PCEPaletteRecalc) {
vce_palette_init(DrvPalette);
vce_palette_init(DrvPalette, (PCEDips[2] & 0x20) ? &alt_palette[0] : NULL);
PCEPaletteRecalc = 0;
}

Expand Down Expand Up @@ -622,10 +657,14 @@ static void PCECompileInputs()
PCEInputs[4] ^= (PCEJoy5[i] & 1) << i;
}

if ((last_dip ^ PCEDips[2]) == 0x80) {
if ((last_dip ^ PCEDips[2]) & 0x80) {
bprintf(0, _T("Sound core switched to: %s\n"), (PCEDips[2] & 0x80) ? _T("HQ") : _T("LQ"));
c6280_set_renderer(PCEDips[2] & 0x80);
}
if ((last_dip ^ PCEDips[2]) & 0x20) {
bprintf(0, _T("Palette switched to: %s\n"), (PCEDips[2] & 0x20) ? _T("Alternate") : _T("Normal"));
PCEPaletteRecalc = 1;
}
last_dip = PCEDips[2];
}

Expand Down

0 comments on commit bd1a2db

Please sign in to comment.