Index: ddraw/ShaderGen2D.cpp |
— | — | @@ -1,5 +1,5 @@ |
2 | 2 | // DXGL
|
3 | | -// Copyright (C) 2013-2018 William Feely
|
| 3 | +// Copyright (C) 2013-2019 William Feely
|
4 | 4 |
|
5 | 5 | // This library is free software; you can redistribute it and/or
|
6 | 6 | // modify it under the terms of the GNU Lesser General Public
|
— | — | @@ -66,12 +66,12 @@ |
67 | 67 | 0x11: 4-bit palette
|
68 | 68 | 0x12: 2-bit palette
|
69 | 69 | 0x13: 1-bit palette
|
70 | | -0x14: 4-bit palette index
|
71 | | -0x15: 2-bit palette index
|
72 | | -0x16: 1-bit palette index
|
73 | | -0x20: (first entry for specific RGB formats)
|
74 | | -0x80: (first entry for specific YUV formats)
|
75 | | -0xC0: (first entry for compressed)
|
| 70 | +0x14: 4-bit palette index (future)
|
| 71 | +0x15: 2-bit palette index (future)
|
| 72 | +0x16: 1-bit palette index (future)
|
| 73 | +0x20: (first entry for specific RGB formats) (future)
|
| 74 | +0x80: (first entry for specific YUV formats) (future)
|
| 75 | +0xC0: (first entry for compressed) (future)
|
76 | 76 | */
|
77 | 77 |
|
78 | 78 | static const char revheader[] =
|
— | — | @@ -99,6 +99,8 @@ |
100 | 100 | static const char unif_desttex[] = "uniform sampler2D desttex;\n";
|
101 | 101 | static const char unif_patterntex[] = "uniform sampler2D patterntex;\n";
|
102 | 102 | static const char unif_stenciltex[] = "uniform sampler2D stenciltex;\n";
|
| 103 | +static const char unif_srcpal[] = "uniform sampler2D srcpal;\n";
|
| 104 | +static const char unif_destpal[] = "uniform sampler2D destpal;\n";
|
103 | 105 | static const char unif_ckeysrc[] = "uniform ivec3 ckeysrc;\n";
|
104 | 106 | static const char unif_ckeydest[] = "uniform ivec3 ckeydest;\n";
|
105 | 107 | static const char unif_ckeysrchigh[] = "uniform ivec3 ckeysrchigh;\n";
|
— | — | @@ -118,6 +120,9 @@ |
119 | 121 | // Operations
|
120 | 122 | static const char op_src[] = "src = ivec4(texture2D(srctex,gl_TexCoord[0].st)*vec4(colorsizesrc)+.5);\n";
|
121 | 123 | static const char op_pixel[] = "pixel = ivec4(texture2D(srctex,gl_TexCoord[0].st)*vec4(colorsizedest)+.5);\n";
|
| 124 | +static const char op_palpixel[] = "vec4 myindex = texture2D(srctex, gl_TexCoord[0].xy);\n\
|
| 125 | +vec2 index = vec2(((myindex.x*(255.0/256.0))+(0.5/256.0)),0.5);\n\
|
| 126 | +pixel = ivec4(texture2D(srcpal, index)*vec4(colorsizedest)+.5);\n";
|
122 | 127 | static const char op_color[] = "pixel = fillcolor;\n";
|
123 | 128 | static const char op_dest[] = "dest = ivec4(texture2D(desttex,gl_TexCoord[1].st)*vec4(colorsizedest)+.5);\n";
|
124 | 129 | static const char op_pattern[] = "patternst = vec2(mod(gl_FragCoord.x,float(patternsize.x))/float(patternsize.x),\n\
|
— | — | @@ -730,11 +735,14 @@ |
731 | 736 | tmp.ptr = NULL;
|
732 | 737 | BOOL intproc = FALSE;
|
733 | 738 | BOOL usedest = FALSE;
|
| 739 | + unsigned char srctype = (id >> 32) & 0xFF;
|
| 740 | + unsigned char srctype2;
|
| 741 | + unsigned char desttype = (id >> 40) & 0xFF;
|
734 | 742 | gen->genshaders2D[index].shader.vsrc.ptr = NULL;
|
735 | 743 | gen->genshaders2D[index].shader.fsrc.ptr = NULL;
|
736 | | - char idstring[22];
|
737 | | - _snprintf(idstring, 21, "%0.8I32X\n", id);
|
738 | | - idstring[21] = 0;
|
| 744 | + char idstring[30];
|
| 745 | + _snprintf(idstring, 29, "%0.16I64X\n", id);
|
| 746 | + idstring[29] = 0;
|
739 | 747 | // Create vertex shader
|
740 | 748 | // Header
|
741 | 749 | STRING *vsrc = &gen->genshaders2D[index].shader.vsrc;
|
— | — | @@ -859,6 +867,19 @@ |
860 | 868 | String_Append(fsrc, unif_ckeydest);
|
861 | 869 | if (id & 0x40000000) String_Append(fsrc, unif_ckeydesthigh);
|
862 | 870 | }
|
| 871 | + if (srctype == desttype) srctype2 = 0;
|
| 872 | + else srctype2 = srctype;
|
| 873 | + switch (srctype2)
|
| 874 | + {
|
| 875 | + default:
|
| 876 | + break;
|
| 877 | + case 0x10:
|
| 878 | + case 0x11:
|
| 879 | + case 0x12:
|
| 880 | + case 0x13:
|
| 881 | + String_Append(fsrc, unif_srcpal);
|
| 882 | + break;
|
| 883 | + }
|
863 | 884 |
|
864 | 885 | // Variables
|
865 | 886 | String_Append(fsrc, var_pixel);
|
— | — | @@ -877,7 +898,22 @@ |
878 | 899 | String_Append(fsrc, mainstart);
|
879 | 900 | if (id & 0x10000000) String_Append(fsrc, op_clip);
|
880 | 901 | if (id & DDBLT_COLORFILL) String_Append(fsrc, op_color);
|
881 | | - else String_Append(fsrc, op_pixel);
|
| 902 | + else
|
| 903 | + {
|
| 904 | + switch (srctype2)
|
| 905 | + {
|
| 906 | + case 0:
|
| 907 | + default:
|
| 908 | + String_Append(fsrc, op_pixel);
|
| 909 | + break;
|
| 910 | + case 0x10:
|
| 911 | + case 0x11:
|
| 912 | + case 0x12:
|
| 913 | + case 0x13:
|
| 914 | + String_Append(fsrc, op_palpixel);
|
| 915 | + break;
|
| 916 | + }
|
| 917 | + }
|
882 | 918 | if (id & DDBLT_KEYSRC) String_Append(fsrc, op_src);
|
883 | 919 | if (usedest) String_Append(fsrc, op_dest);
|
884 | 920 | if (id & DDBLT_KEYSRC)
|
— | — | @@ -966,6 +1002,8 @@ |
967 | 1003 | gen->genshaders2D[index].shader.uniforms[10] = gen->ext->glGetUniformLocation(gen->genshaders2D[index].shader.prog, "colorsizesrc");
|
968 | 1004 | gen->genshaders2D[index].shader.uniforms[11] = gen->ext->glGetUniformLocation(gen->genshaders2D[index].shader.prog, "colorsizedest");
|
969 | 1005 | gen->genshaders2D[index].shader.uniforms[12] = gen->ext->glGetUniformLocation(gen->genshaders2D[index].shader.prog, "fillcolor");
|
970 | | -
|
| 1006 | + gen->genshaders2D[index].shader.uniforms[13] = gen->ext->glGetUniformLocation(gen->genshaders2D[index].shader.prog, "srcpal");
|
| 1007 | + gen->genshaders2D[index].shader.uniforms[14] = gen->ext->glGetUniformLocation(gen->genshaders2D[index].shader.prog, "destpal");
|
| 1008 | +
|
971 | 1009 | gen->genshaders2D[index].id = id;
|
972 | 1010 | } |
\ No newline at end of file |
Index: ddraw/ShaderGen3D.cpp |
— | — | @@ -1,5 +1,5 @@ |
2 | 2 | // DXGL
|
3 | | -// Copyright (C) 2012-2016 William Feely
|
| 3 | +// Copyright (C) 2012-2019 William Feely
|
4 | 4 |
|
5 | 5 | // This library is free software; you can redistribute it and/or
|
6 | 6 | // modify it under the terms of the GNU Lesser General Public
|
— | — | @@ -149,7 +149,7 @@ |
150 | 150 | */
|
151 | 151 | int __cdecl compshader2D(const GenShader2D *elem1, const GenShader2D *elem2)
|
152 | 152 | {
|
153 | | - return elem1->id - elem2->id;
|
| 153 | + return memcmp(&elem1->id, &elem2->id, sizeof(__int64));
|
154 | 154 | }
|
155 | 155 |
|
156 | 156 | /**
|
— | — | @@ -200,7 +200,7 @@ |
201 | 201 | This->current_shadertype = 1;
|
202 | 202 | GenShader2D key2d;
|
203 | 203 | GenShader2D *shader2d;
|
204 | | - key2d.id = id & 0xFFFFFFFF;
|
| 204 | + key2d.id = id;
|
205 | 205 | shader2d = (GenShader2D*)bsearch(&key2d, gen2d->genshaders2D, gen2d->genindex, sizeof(GenShader2D),
|
206 | 206 | (int(__cdecl *) (const void *, const void *))compshader2D);
|
207 | 207 | if (!shader2d)
|
— | — | @@ -216,7 +216,7 @@ |
217 | 217 | String_Free(&gen2d->genshaders2D[gen2d->genindex].shader.fsrc);
|
218 | 218 | ZeroMemory(&gen2d->genshaders2D[gen2d->genindex], sizeof(GenShader2D));
|
219 | 219 | }
|
220 | | - ShaderGen2D_CreateShader2D(gen2d, gen2d->genindex, id & 0xFFFFFFFF);
|
| 220 | + ShaderGen2D_CreateShader2D(gen2d, gen2d->genindex, id);
|
221 | 221 | gen2d->genindex++;
|
222 | 222 | if (gen2d->genindex >= gen2d->maxshaders)
|
223 | 223 | {
|
Index: ddraw/glDirectDrawPalette.c |
— | — | @@ -1,5 +1,5 @@ |
2 | 2 | // DXGL
|
3 | | -// Copyright (C) 2011-2016 William Feely
|
| 3 | +// Copyright (C) 2011-2019 William Feely
|
4 | 4 |
|
5 | 5 | // This library is free software; you can redistribute it and/or
|
6 | 6 | // modify it under the terms of the GNU Lesser General Public
|
— | — | @@ -235,13 +235,16 @@ |
236 | 236 | memcpy(((char *)This->palette)+(dwStartingEntry*entrysize),lpEntries,dwCount*entrysize);
|
237 | 237 | if (!(This->flags & DDPCAPS_ALLOW256))
|
238 | 238 | {
|
239 | | - memcpy(&This->palette[0], DefaultPalette, 4);
|
240 | | - memcpy(&This->palette[255], DefaultPalette + 1020, 4);
|
| 239 | + if (This->flags & DDPCAPS_8BIT)
|
| 240 | + {
|
| 241 | + memcpy(&This->palette[0], DefaultPalette, 4);
|
| 242 | + memcpy(&This->palette[255], DefaultPalette + 1020, 4);
|
| 243 | + }
|
241 | 244 | }
|
242 | 245 | if (This->texture)
|
243 | 246 | {
|
244 | 247 | glTexture_Lock(This->texture, 0, NULL, &ddsd, 0, FALSE);
|
245 | | - memcpy(ddsd.lpSurface, This->palette, 1024);
|
| 248 | + memcpy(ddsd.lpSurface, This->palette, 4 * This->palsize);
|
246 | 249 | glTexture_Unlock(This->texture, 0, NULL, FALSE);
|
247 | 250 | }
|
248 | 251 | if ((This->flags & DDPCAPS_PRIMARYSURFACE) && (This->surface))
|
— | — | @@ -287,7 +290,25 @@ |
288 | 291 | glDirectDrawPalette *newpal;
|
289 | 292 | TRACE_ENTER(3,9,dwFlags,14,lpDDColorArray,14,lplpDDPalette);
|
290 | 293 | if (!IsWritablePointer(lplpDDPalette, sizeof(LPDIRECTDRAWPALETTE), FALSE)) TRACE_RET(HRESULT, 23, DDERR_INVALIDPARAMS);
|
291 | | - if (lpDDColorArray && !IsReadablePointer(lpDDColorArray,256*sizeof(PALETTEENTRY))) TRACE_RET(HRESULT, 23, DDERR_INVALIDPARAMS);
|
| 294 | + if (lpDDColorArray)
|
| 295 | + {
|
| 296 | + if (dwFlags & DDPCAPS_8BIT)
|
| 297 | + {
|
| 298 | + if (!IsReadablePointer(lpDDColorArray, 256 * sizeof(PALETTEENTRY))) TRACE_RET(HRESULT, 23, DDERR_INVALIDPARAMS);
|
| 299 | + }
|
| 300 | + if (dwFlags & DDPCAPS_4BIT)
|
| 301 | + {
|
| 302 | + if (!IsReadablePointer(lpDDColorArray, 16 * sizeof(PALETTEENTRY))) TRACE_RET(HRESULT, 23, DDERR_INVALIDPARAMS);
|
| 303 | + }
|
| 304 | + if (dwFlags & DDPCAPS_2BIT)
|
| 305 | + {
|
| 306 | + if (!IsReadablePointer(lpDDColorArray, 4 * sizeof(PALETTEENTRY))) TRACE_RET(HRESULT, 23, DDERR_INVALIDPARAMS);
|
| 307 | + }
|
| 308 | + if (dwFlags & DDPCAPS_1BIT)
|
| 309 | + {
|
| 310 | + if (!IsReadablePointer(lpDDColorArray, 2 * sizeof(PALETTEENTRY))) TRACE_RET(HRESULT, 23, DDERR_INVALIDPARAMS);
|
| 311 | + }
|
| 312 | + }
|
292 | 313 | if (dwFlags & 0xFFFFF000) TRACE_RET(HRESULT, 23, DDERR_INVALIDPARAMS);
|
293 | 314 | if ((dwFlags & DDPCAPS_8BIT) && (dwFlags & DDPCAPS_8BITENTRIES)) TRACE_RET(HRESULT, 23, DDERR_INVALIDPARAMS);
|
294 | 315 | if (((dwFlags & DDPCAPS_1BIT) || (dwFlags & DDPCAPS_2BIT) || (dwFlags & DDPCAPS_4BIT)) && (dwFlags & DDPCAPS_ALLOW256))
|
— | — | @@ -309,15 +330,24 @@ |
310 | 331 | }
|
311 | 332 | else
|
312 | 333 | {
|
313 | | - if(newpal->flags & DDPCAPS_1BIT)
|
314 | | - if(newpal->flags & DDPCAPS_8BITENTRIES) memcpy(newpal->palette,lpDDColorArray,2);
|
315 | | - else memcpy(newpal->palette,lpDDColorArray,2*sizeof(PALETTEENTRY));
|
316 | | - else if(newpal->flags & DDPCAPS_2BIT)
|
317 | | - if(newpal->flags & DDPCAPS_8BITENTRIES) memcpy(newpal->palette,lpDDColorArray,4);
|
318 | | - else memcpy(newpal->palette,lpDDColorArray,4*sizeof(PALETTEENTRY));
|
319 | | - else if(newpal->flags & DDPCAPS_4BIT)
|
320 | | - if(newpal->flags & DDPCAPS_8BITENTRIES) memcpy(newpal->palette,lpDDColorArray,16);
|
321 | | - else memcpy(newpal->palette,lpDDColorArray,16*sizeof(PALETTEENTRY));
|
| 334 | + if (newpal->flags & DDPCAPS_1BIT)
|
| 335 | + {
|
| 336 | + if (newpal->flags & DDPCAPS_8BITENTRIES) memcpy(newpal->palette, lpDDColorArray, 2);
|
| 337 | + else memcpy(newpal->palette, lpDDColorArray, 2 * sizeof(PALETTEENTRY));
|
| 338 | + newpal->palsize = 2;
|
| 339 | + }
|
| 340 | + else if (newpal->flags & DDPCAPS_2BIT)
|
| 341 | + {
|
| 342 | + if (newpal->flags & DDPCAPS_8BITENTRIES) memcpy(newpal->palette, lpDDColorArray, 4);
|
| 343 | + else memcpy(newpal->palette, lpDDColorArray, 4 * sizeof(PALETTEENTRY));
|
| 344 | + newpal->palsize = 4;
|
| 345 | + }
|
| 346 | + else if (newpal->flags & DDPCAPS_4BIT)
|
| 347 | + {
|
| 348 | + if (newpal->flags & DDPCAPS_8BITENTRIES) memcpy(newpal->palette, lpDDColorArray, 16);
|
| 349 | + else memcpy(newpal->palette, lpDDColorArray, 16 * sizeof(PALETTEENTRY));
|
| 350 | + newpal->palsize = 16;
|
| 351 | + }
|
322 | 352 | else
|
323 | 353 | {
|
324 | 354 | memcpy(newpal->palette, lpDDColorArray, 256 * sizeof(PALETTEENTRY));
|
— | — | @@ -326,6 +356,7 @@ |
327 | 357 | memcpy(&newpal->palette[0], DefaultPalette, 4);
|
328 | 358 | memcpy(&newpal->palette[255], DefaultPalette + 1020, 4);
|
329 | 359 | }
|
| 360 | + newpal->palsize = 256;
|
330 | 361 | }
|
331 | 362 | }
|
332 | 363 | if(lplpDDPalette) *lplpDDPalette = (LPDIRECTDRAWPALETTE)newpal;
|
— | — | @@ -338,8 +369,10 @@ |
339 | 370 | DDSURFACEDESC2 ddsd;
|
340 | 371 | ZeroMemory(&ddsd, sizeof(DDSURFACEDESC2));
|
341 | 372 | memcpy(&ddsd, &ddsd256pal, sizeof(DDSURFACEDESC2));
|
342 | | - glTexture_Create(&ddsd256pal, &This->texture, renderer, 256, 1, FALSE, FALSE);
|
| 373 | + ddsd.dwWidth = This->palsize;
|
| 374 | + ddsd.lPitch = This->palsize * 4;
|
| 375 | + glTexture_Create(&ddsd, &This->texture, renderer, This->palsize, 1, FALSE, FALSE);
|
343 | 376 | glTexture_Lock(This->texture, 0, NULL, &ddsd, 0, FALSE);
|
344 | | - memcpy(ddsd.lpSurface, This->palette, 1024);
|
| 377 | + memcpy(ddsd.lpSurface, This->palette, (This->palsize * 4));
|
345 | 378 | glTexture_Unlock(This->texture, 0, NULL, FALSE);
|
346 | 379 | } |
\ No newline at end of file |
Index: ddraw/glRenderer.cpp |
— | — | @@ -1,5 +1,5 @@ |
2 | 2 | // DXGL
|
3 | | -// Copyright (C) 2012-2018 William Feely
|
| 3 | +// Copyright (C) 2012-2019 William Feely
|
4 | 4 |
|
5 | 5 | // This library is free software; you can redistribute it and/or
|
6 | 6 | // modify it under the terms of the GNU Lesser General Public
|
— | — | @@ -3379,6 +3379,7 @@ |
3380 | 3380 | if (rop_texture_usage[(cmd->bltfx.dwROP >> 16) & 0xFF] & 4) usepattern = TRUE;
|
3381 | 3381 | }
|
3382 | 3382 | else shaderid = cmd->flags & 0xF2FAADFF;
|
| 3383 | + if (cmd->src) shaderid |= ((long long)cmd->src->blttype << 32);
|
3383 | 3384 | //TODO: Add src/dest texture types
|
3384 | 3385 | if (cmd->flags & DDBLT_KEYDEST) usedest = TRUE;
|
3385 | 3386 | if (IsAlphaCKey())
|
— | — | @@ -3516,6 +3517,22 @@ |
3517 | 3518 | glUtil_EnableArray(This->util, shader->shader.attribs[5], TRUE);
|
3518 | 3519 | This->ext->glVertexAttribPointer(shader->shader.attribs[5], 2, GL_FLOAT, GL_FALSE, sizeof(BltVertex), &This->bltvertices[0].stencils);
|
3519 | 3520 | }
|
| 3521 | + switch ((shaderid >> 32) & 0xFF)
|
| 3522 | + {
|
| 3523 | + case 0x10:
|
| 3524 | + case 0x11:
|
| 3525 | + case 0x12:
|
| 3526 | + case 0x13: // Use palette
|
| 3527 | + if (cmd->src->palette)
|
| 3528 | + {
|
| 3529 | + if (cmd->src->palette->levels[0].dirty & 1) glTexture__Upload(cmd->src->palette, 0);
|
| 3530 | + glUtil_SetTexture(This->util, 12, cmd->src->palette);
|
| 3531 | + This->ext->glUniform1i(shader->shader.uniforms[13], 12);
|
| 3532 | + }
|
| 3533 | + break;
|
| 3534 | + default:
|
| 3535 | + break;
|
| 3536 | + }
|
3520 | 3537 | if (cmd->src)
|
3521 | 3538 | {
|
3522 | 3539 | glUtil_SetTexture(This->util, 8, cmd->src);
|
Index: ddraw/glTexture.cpp |
— | — | @@ -814,6 +814,7 @@ |
815 | 815 | This->convfunctionupload = 11;
|
816 | 816 | This->convfunctiondownload = 14;
|
817 | 817 | This->internalsize = 1; // Store in R8/LUMINANCE8 texture
|
| 818 | + This->blttype = 0x13;
|
818 | 819 | if (This->renderer->ext->glver_major >= 3)
|
819 | 820 | {
|
820 | 821 | This->internalformats[0] = GL_R8;
|
— | — | @@ -840,6 +841,7 @@ |
841 | 842 | This->convfunctionupload = 12;
|
842 | 843 | This->convfunctiondownload = 15;
|
843 | 844 | This->internalsize = 1; // Store in R8/LUMINANCE8 texture
|
| 845 | + This->blttype = 0x12;
|
844 | 846 | if (This->renderer->ext->glver_major >= 3)
|
845 | 847 | {
|
846 | 848 | This->internalformats[0] = GL_R8;
|
— | — | @@ -866,6 +868,7 @@ |
867 | 869 | This->convfunctionupload = 13;
|
868 | 870 | This->convfunctiondownload = 16;
|
869 | 871 | This->internalsize = 1; // Store in R8/LUMINANCE8 texture
|
| 872 | + This->blttype = 0x11;
|
870 | 873 | if (This->renderer->ext->glver_major >= 3)
|
871 | 874 | {
|
872 | 875 | This->internalformats[0] = GL_R8;
|
— | — | @@ -888,6 +891,7 @@ |
889 | 892 | This->colorbits[3] = 0;
|
890 | 893 | break;
|
891 | 894 | case 3: // 8-bit palette
|
| 895 | + This->blttype = 0x10;
|
892 | 896 | if (This->renderer->ext->glver_major >= 3)
|
893 | 897 | {
|
894 | 898 | This->internalformats[0] = GL_R8;
|
Index: ddraw/struct.h |
— | — | @@ -1,5 +1,5 @@ |
2 | 2 | // DXGL
|
3 | | -// Copyright (C) 2015-2016 William Feely
|
| 3 | +// Copyright (C) 2015-2019 William Feely
|
4 | 4 |
|
5 | 5 | // This library is free software; you can redistribute it and/or
|
6 | 6 | // modify it under the terms of the GNU Lesser General Public
|
— | — | @@ -315,6 +315,7 @@ |
316 | 316 | int convfunctionupload;
|
317 | 317 | int convfunctiondownload;
|
318 | 318 | int internalsize;
|
| 319 | + unsigned char blttype;
|
319 | 320 | struct glTexture *palette;
|
320 | 321 | struct glTexture *stencil;
|
321 | 322 | struct glTexture *dummycolor;
|
— | — | @@ -426,6 +427,7 @@ |
427 | 428 | IUnknown *creator;
|
428 | 429 | LPDIRECTDRAWSURFACE7 surface;
|
429 | 430 | DXGLTimer *timer;
|
| 431 | + DWORD palsize;
|
430 | 432 | } glDirectDrawPalette;
|
431 | 433 |
|
432 | 434 | // Function pointer table for glDirectDrawPalette
|
Index: dxglcfg/palette.cpp |
— | — | @@ -23,19 +23,19 @@ |
24 | 24 | }; // Just black and white
|
25 | 25 |
|
26 | 26 | const unsigned char DefaultPalette2[16] = {
|
27 | | - 0x00,0x00,0x00,0x00,0xff,0xff,0x55,0x00,
|
| 27 | + 0x00,0x00,0x00,0x00,0x55,0xff,0xff,0x00,
|
28 | 28 | 0xff,0x55,0xff,0x00,0xff,0xff,0xff,0x00
|
29 | 29 | }; // Based on IBM PC CGA Palette 1 with intensity bit set
|
30 | 30 |
|
31 | 31 | const unsigned char DefaultPalette4[64] = {
|
32 | | - 0x00,0x00,0x00,0x00,0xaa,0x00,0x00,0x00,
|
33 | | - 0x00,0xaa,0x00,0x00,0xaa,0xaa,0x00,0x00,
|
34 | | - 0x00,0x00,0xaa,0x00,0xaa,0x00,0xaa,0x00,
|
35 | | - 0x00,0x55,0xaa,0x00,0xaa,0xaa,0xaa,0x00,
|
36 | | - 0x55,0x55,0x55,0x00,0xff,0x55,0x55,0x00,
|
37 | | - 0x55,0xff,0x55,0x00,0xff,0xff,0x55,0x00,
|
38 | | - 0x55,0x55,0xff,0x00,0x55,0xff,0x55,0x00,
|
39 | | - 0x55,0xff,0xff,0x00,0xff,0xff,0xff,0x00
|
| 32 | + 0x00,0x00,0x00,0x00,0x00,0x00,0xaa,0x00,
|
| 33 | + 0x00,0xaa,0x00,0x00,0x00,0xaa,0xaa,0x00,
|
| 34 | + 0xaa,0x00,0x00,0x00,0xaa,0x00,0xaa,0x00,
|
| 35 | + 0xaa,0x55,0x00,0x00,0xaa,0xaa,0xaa,0x00,
|
| 36 | + 0x55,0x55,0x55,0x00,0x55,0x55,0xff,0x00,
|
| 37 | + 0x55,0xff,0x55,0x00,0x55,0xff,0xff,0x00,
|
| 38 | + 0xff,0x55,0x55,0x00,0xff,0x55,0xff,0x00,
|
| 39 | + 0xff,0xff,0x55,0x00,0xff,0xff,0xff,0x00
|
40 | 40 | }; // Based on IBM PC CGA/EGA/VGA default 16 color palette
|
41 | 41 |
|
42 | 42 | const unsigned char DefaultPalette8[1024] = {
|
Index: dxglcfg/tests.cpp |
— | — | @@ -2477,6 +2477,27 @@ |
2478 | 2478 | }
|
2479 | 2479 | else
|
2480 | 2480 | {
|
| 2481 | + switch (PaletteType(ddsd.ddpfPixelFormat.dwFlags))
|
| 2482 | + {
|
| 2483 | + case 0:
|
| 2484 | + break;
|
| 2485 | + case 1:
|
| 2486 | + ddinterface->CreatePalette(DDPCAPS_1BIT, (LPPALETTEENTRY)&DefaultPalette1, &sprites[1].palette, NULL);
|
| 2487 | + sprites[1].surface->SetPalette(sprites[1].palette);
|
| 2488 | + break;
|
| 2489 | + case 2:
|
| 2490 | + ddinterface->CreatePalette(DDPCAPS_2BIT, (LPPALETTEENTRY)&DefaultPalette2, &sprites[1].palette, NULL);
|
| 2491 | + sprites[1].surface->SetPalette(sprites[1].palette);
|
| 2492 | + break;
|
| 2493 | + case 4:
|
| 2494 | + ddinterface->CreatePalette(DDPCAPS_4BIT, (LPPALETTEENTRY)&DefaultPalette4, &sprites[1].palette, NULL);
|
| 2495 | + sprites[1].surface->SetPalette(sprites[1].palette);
|
| 2496 | + break;
|
| 2497 | + case 8:
|
| 2498 | + ddinterface->CreatePalette(DDPCAPS_8BIT, (LPPALETTEENTRY)&DefaultPalette8, &sprites[1].palette, NULL);
|
| 2499 | + sprites[1].surface->SetPalette(sprites[1].palette);
|
| 2500 | + break;
|
| 2501 | + }
|
2481 | 2502 | error = sprites[1].surface->Blt(NULL, sprites[0].surface, NULL, DDBLT_WAIT, NULL);
|
2482 | 2503 | if (error)
|
2483 | 2504 | {
|