Merge pull request #7 from Tatsuya79/master

Custom Palette support, add Composite wip.
This commit is contained in:
Autechre 2020-07-12 16:07:54 +02:00 committed by GitHub
commit 77eda41d34
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 554 additions and 4 deletions

View File

@ -41,6 +41,7 @@
static bool old_cdimagecache = false;
static bool show_advanced_input_settings = true;
static bool use_palette = false;
extern MDFNGI EmulatedPCE;
MDFNGI *MDFNGameInfo = &EmulatedPCE;
@ -49,6 +50,523 @@ static int hires_blend = 0;
static int blur_passes = 1;
static int aspect_ratio = 0;
/* Composite palette WIP 2020/06/30
* made by dshadoff and turboxray from The PC Engine Software Bible Forum
*/
static uint8_t composite_palette[] = {
0, 0, 0,
0, 0, 22,
0, 0, 52,
0, 0, 72,
0, 0, 103,
0, 0, 128,
0, 0, 167,
0, 0, 207,
27, 0, 3,
31, 3, 31,
27, 0, 53,
31, 1, 82,
27, 0, 105,
31, 0, 136,
25, 0, 163,
27, 0, 207,
62, 8, 11,
57, 3, 34,
61, 6, 64,
57, 1, 85,
61, 4, 114,
57, 0, 136,
60, 2, 170,
54, 0, 201,
87, 8, 13,
83, 3, 36,
87, 6, 64,
83, 1, 87,
87, 5, 115,
83, 0, 138,
86, 3, 170,
81, 0, 197,
114, 7, 15,
118, 11, 44,
114, 6, 67,
118, 9, 98,
114, 4, 119,
118, 7, 147,
114, 2, 169,
117, 5, 203,
152, 13, 27,
148, 8, 48,
152, 11, 78,
148, 7, 99,
152, 10, 129,
148, 5, 150,
151, 8, 181,
147, 3, 204,
185, 8, 31,
181, 3, 51,
185, 7, 81,
181, 2, 103,
185, 5, 134,
180, 0, 155,
185, 4, 183,
180, 0, 206,
225, 0, 35,
229, 2, 66,
225, 0, 87,
229, 0, 117,
225, 0, 138,
229, 0, 168,
225, 0, 189,
229, 0, 220,
10, 38, 10,
6, 34, 30,
10, 37, 61,
6, 32, 81,
10, 35, 112,
5, 30, 135,
8, 32, 171,
1, 24, 206,
37, 38, 10,
33, 33, 33,
37, 36, 64,
33, 31, 84,
37, 35, 113,
33, 30, 135,
36, 32, 169,
30, 25, 200,
64, 37, 13,
68, 40, 44,
64, 35, 64,
68, 39, 95,
64, 34, 115,
68, 37, 146,
64, 32, 169,
67, 34, 205,
99, 45, 23,
95, 41, 44,
98, 44, 75,
94, 39, 97,
98, 42, 126,
94, 37, 147,
98, 40, 177,
93, 35, 203,
124, 45, 26,
120, 41, 46,
124, 44, 77,
120, 39, 97,
124, 42, 128,
120, 38, 148,
124, 41, 179,
119, 35, 202,
151, 45, 28,
155, 48, 56,
151, 44, 77,
155, 47, 108,
151, 41, 130,
155, 45, 160,
151, 40, 180,
155, 43, 211,
189, 51, 37,
185, 46, 60,
189, 49, 89,
185, 44, 111,
189, 48, 140,
185, 43, 162,
189, 46, 191,
184, 41, 214,
222, 46, 42,
218, 41, 64,
222, 44, 93,
218, 40, 113,
222, 43, 144,
218, 38, 167,
222, 41, 196,
218, 36, 216,
13, 68, 10,
17, 71, 40,
13, 66, 63,
17, 69, 92,
13, 65, 113,
17, 68, 143,
12, 62, 169,
14, 63, 207,
47, 76, 20,
43, 71, 43,
47, 75, 71,
43, 70, 94,
47, 73, 122,
43, 68, 145,
38, 63, 168,
41, 65, 204,
74, 75, 22,
70, 71, 43,
74, 74, 74,
70, 69, 96,
74, 72, 126,
70, 67, 146,
74, 71, 176,
69, 65, 202,
101, 74, 25,
106, 78, 54,
101, 73, 76,
106, 76, 105,
101, 71, 127,
106, 75, 156,
101, 70, 179,
105, 73, 210,
136, 83, 35,
132, 78, 56,
136, 82, 85,
131, 76, 107,
135, 79, 138,
131, 75, 159,
127, 70, 180,
131, 73, 210,
162, 83, 36,
157, 78, 59,
161, 82, 87,
157, 77, 110,
161, 80, 138,
157, 75, 161,
161, 79, 189,
157, 73, 212,
188, 83, 38,
192, 86, 69,
188, 81, 89,
193, 84, 118,
188, 79, 141,
192, 82, 172,
188, 78, 192,
192, 81, 221,
227, 89, 47,
222, 84, 70,
226, 87, 101,
222, 82, 122,
218, 77, 144,
222, 80, 173,
218, 75, 195,
222, 79, 224,
25, 105, 20,
20, 100, 42,
24, 104, 71,
20, 99, 93,
24, 102, 122,
20, 97, 145,
24, 100, 176,
18, 94, 203,
50, 106, 22,
54, 109, 51,
50, 104, 73,
54, 107, 104,
50, 102, 125,
54, 106, 154,
50, 101, 176,
53, 103, 210,
76, 105, 25,
80, 109, 53,
76, 104, 75,
80, 107, 104,
76, 102, 126,
80, 106, 155,
76, 101, 178,
79, 104, 209,
111, 113, 35,
107, 108, 55,
112, 112, 84,
107, 107, 107,
111, 110, 137,
107, 105, 158,
111, 108, 187,
107, 103, 209,
139, 112, 36,
143, 115, 67,
139, 111, 87,
143, 114, 118,
139, 109, 138,
143, 112, 168,
139, 108, 189,
142, 111, 220,
165, 112, 38,
169, 116, 68,
165, 111, 89,
169, 114, 118,
164, 109, 140,
168, 112, 171,
164, 108, 192,
168, 111, 221,
199, 121, 46,
195, 116, 69,
198, 119, 100,
194, 114, 120,
198, 117, 151,
194, 113, 171,
198, 116, 202,
194, 111, 222,
226, 121, 45,
230, 124, 79,
225, 118, 102,
230, 122, 130,
226, 117, 151,
229, 120, 182,
225, 115, 204,
229, 119, 233,
27, 135, 21,
31, 139, 50,
26, 134, 73,
30, 137, 103,
26, 132, 124,
30, 136, 153,
26, 130, 175,
29, 133, 209,
62, 143, 32,
58, 138, 53,
61, 141, 83,
57, 137, 104,
61, 140, 134,
57, 135, 155,
61, 138, 186,
57, 133, 209,
87, 143, 34,
92, 147, 63,
87, 142, 84,
91, 145, 114,
87, 140, 137,
91, 143, 166,
87, 139, 186,
91, 142, 217,
113, 143, 35,
117, 146, 66,
113, 142, 86,
117, 145, 117,
113, 140, 137,
117, 143, 167,
113, 139, 188,
117, 142, 219,
149, 151, 45,
144, 146, 67,
149, 149, 96,
145, 144, 117,
149, 147, 148,
144, 142, 170,
148, 146, 199,
144, 141, 220,
176, 150, 45,
180, 153, 77,
176, 148, 99,
180, 152, 128,
176, 147, 150,
180, 150, 179,
176, 145, 201,
180, 149, 230,
203, 151, 45,
206, 153, 79,
202, 148, 101,
206, 152, 130,
202, 147, 151,
206, 150, 181,
201, 145, 204,
206, 148, 233,
237, 160, 51,
232, 154, 78,
236, 157, 110,
231, 152, 133,
236, 155, 161,
231, 150, 184,
236, 154, 212,
231, 149, 234,
34, 175, 31,
38, 179, 60,
34, 174, 82,
38, 177, 111,
34, 172, 133,
38, 176, 162,
34, 170, 184,
29, 165, 208,
64, 173, 33,
68, 176, 62,
64, 172, 83,
68, 175, 114,
63, 170, 136,
67, 173, 165,
63, 168, 186,
67, 171, 216,
99, 181, 42,
95, 175, 65,
99, 179, 94,
94, 174, 116,
99, 177, 145,
94, 172, 167,
99, 176, 196,
94, 171, 219,
125, 181, 45,
129, 184, 75,
125, 179, 96,
129, 183, 125,
124, 178, 147,
120, 173, 170,
124, 176, 199,
120, 171, 219,
151, 181, 44,
155, 184, 76,
150, 179, 98,
155, 183, 127,
150, 178, 149,
154, 181, 178,
150, 176, 200,
154, 180, 229,
187, 189, 52,
182, 183, 78,
186, 187, 109,
182, 182, 129,
186, 185, 158,
182, 180, 181,
185, 183, 211,
181, 179, 232,
215, 189, 51,
218, 191, 86,
213, 186, 109,
217, 189, 140,
213, 184, 161,
209, 179, 183,
213, 183, 212,
209, 178, 234,
242, 191, 47,
244, 192, 86,
239, 186, 112,
243, 189, 142,
239, 185, 163,
243, 188, 192,
239, 183, 214,
243, 186, 245,
38, 218, 38,
34, 213, 59,
38, 216, 88,
34, 211, 110,
38, 214, 141,
34, 210, 162,
38, 213, 191,
34, 208, 213,
71, 213, 41,
67, 208, 64,
71, 211, 92,
67, 206, 115,
71, 210, 143,
67, 205, 166,
71, 208, 194,
67, 203, 217,
101, 211, 44,
105, 214, 74,
101, 209, 95,
105, 213, 124,
101, 207, 147,
105, 211, 177,
100, 206, 198,
105, 209, 227,
136, 219, 52,
132, 213, 75,
136, 216, 106,
132, 212, 127,
136, 215, 157,
132, 210, 178,
136, 213, 208,
132, 209, 229,
163, 219, 52,
158, 214, 77,
162, 217, 108,
158, 212, 128,
162, 216, 158,
157, 210, 180,
161, 213, 211,
157, 209, 232,
189, 220, 50,
192, 222, 85,
188, 217, 108,
192, 220, 139,
188, 215, 160,
191, 219, 190,
187, 214, 211,
191, 217, 241,
226, 229, 55,
220, 222, 85,
223, 224, 119,
219, 219, 141,
223, 223, 170,
219, 218, 191,
223, 221, 222,
218, 216, 244,
255, 230, 49,
248, 222, 84,
251, 224, 119,
246, 219, 142,
250, 222, 173,
246, 217, 194,
250, 220, 224,
246, 216, 245,
27, 255, 35,
31, 255, 66,
27, 255, 86,
31, 255, 117,
27, 254, 137,
31, 255, 168,
27, 252, 188,
30, 255, 219,
75, 255, 49,
71, 250, 71,
75, 254, 100,
71, 249, 121,
75, 252, 152,
71, 247, 174,
75, 251, 203,
71, 246, 224,
109, 251, 51,
104, 246, 74,
108, 249, 105,
104, 244, 125,
108, 247, 156,
104, 243, 176,
108, 246, 207,
104, 241, 227,
139, 249, 51,
142, 252, 85,
138, 247, 107,
142, 250, 136,
138, 245, 157,
142, 248, 188,
138, 243, 210,
142, 247, 239,
175, 255, 58,
170, 251, 85,
173, 254, 116,
169, 249, 139,
173, 253, 168,
169, 248, 190,
173, 251, 219,
169, 246, 241,
202, 255, 54,
196, 252, 85,
199, 255, 119,
195, 250, 141,
199, 253, 169,
195, 248, 190,
199, 251, 221,
194, 246, 244,
229, 255, 48,
231, 255, 91,
225, 255, 118,
229, 255, 150,
225, 253, 172,
229, 255, 201,
224, 251, 223,
229, 255, 252,
255, 255, 47,
255, 255, 88,
255, 255, 126,
255, 255, 152,
255, 255, 182,
255, 255, 203,
255, 255, 232,
255, 254, 255
};
static bool ReadM3U(std::vector<std::string> &file_list, std::string path, unsigned depth = 0)
{
@ -512,6 +1030,16 @@ static void check_variables(bool loaded)
setting_pce_overclocked = atoi(var.value);
}
var.key = "pce_palette";
if (environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE, &var) && var.value)
{
if (strcmp(var.value, "Composite") == 0)
use_palette = true;
else
use_palette = false;
}
var.key = "pce_aspect_ratio";
if (environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE, &var) && var.value)
@ -1150,7 +1678,9 @@ void retro_run(void)
spec.SoundVolume = 1.0;
spec.soundmultiplier = 1.0;
spec.SoundBufSize = 0;
spec.VideoFormatChanged = false;
spec.CustomPalette = use_palette ? composite_palette : NULL;
spec.CustomPaletteNumEntries = use_palette ? 512 : 0;
spec.VideoFormatChanged = true;
spec.SoundFormatChanged = false;
spec.skip = false;

View File

@ -98,6 +98,17 @@ struct retro_core_option_definition option_defs_us[] = {
},
"1"
},
{
"pce_palette",
"Colour Palette",
"Composite tries to recreate the original console output and can show more details in some games.",
{
{ "RGB", NULL },
{ "Composite", NULL },
{ NULL, NULL},
},
"RGB"
},
{
"pce_aspect_ratio",
"Aspect Ratio",

View File

@ -206,6 +206,17 @@ typedef struct
// you can ignore this. If you do wish to use this, you must set all elements every frame.
int32_t *LineWidths;
// Pointer to an array of uint8, 3 * CustomPaletteEntries.
// CustomPalette must be NULL and CustomPaletteEntries mujst be 0 if no custom palette is specified/available;
// otherwise, CustomPalette must be non-NULL and CustomPaletteEntries must be equal to a non-zero "num_entries" member of a CustomPalette_Spec
// entry of MDFNGI::CPInfo.
//
// Set and used internally if driver-side code hasn't specified a non-NULL value for CustomPalette. If driver side uses it, driver side should
// set VideoFormatChanged to true whenever the custom palette changes.
//
uint8 *CustomPalette = nullptr;
uint32 CustomPaletteNumEntries = 0;
// TODO
bool *IsFMV;

View File

@ -598,7 +598,7 @@ void Emulate(EmulateSpecStruct *espec)
MDFNMP_ApplyPeriodicCheats();
if(espec->VideoFormatChanged)
vce->SetPixelFormat(NULL, 0); //espec->CustomPalette, espec->CustomPaletteNumEntries
vce->SetPixelFormat(espec->CustomPalette, espec->CustomPaletteNumEntries);
if(espec->SoundFormatChanged)
SetSoundRate(espec->SoundRate);

View File

@ -207,8 +207,6 @@ VCE::VCE(const bool want_sgfx, const uint32 vram_size)
memset(surf_clut, 0, sizeof(surf_clut));
SetShowHorizOS(false);
SetPixelFormat(NULL, 0);
}
void VCE::SetVDCUnlimitedSprites(const bool nospritelimit)