mirror of
https://github.com/FunkyFr3sh/cnc-ddraw.git
synced 2025-03-15 06:04:49 +01:00
fix gdi palette bug + refactoring
This commit is contained in:
parent
084c7b113b
commit
f5698f2d0b
@ -88,7 +88,7 @@ typedef struct IDirectDrawImpl
|
||||
BOOL vhack;
|
||||
BOOL isredalert;
|
||||
BOOL iscnc1;
|
||||
BOOL incutscene;
|
||||
LONG incutscene;
|
||||
DWORD (WINAPI *renderer)(void);
|
||||
char screenshotKey;
|
||||
BOOL fullscreen;
|
||||
|
15
src/main.c
15
src/main.c
@ -842,13 +842,8 @@ HRESULT __stdcall ddraw_SetCooperativeLevel(IDirectDrawImpl *This, HWND hWnd, DW
|
||||
ddraw->isredalert = strcmp(This->title, "Red Alert") == 0;
|
||||
ddraw->iscnc1 = strcmp(This->title, "Command & Conquer") == 0;
|
||||
|
||||
if(This->vhack == 1)
|
||||
{
|
||||
if (!ddraw->isredalert && !ddraw->iscnc1)
|
||||
{
|
||||
This->vhack = 0;
|
||||
}
|
||||
}
|
||||
if (This->vhack && !ddraw->isredalert && !ddraw->iscnc1)
|
||||
This->vhack = 0;
|
||||
|
||||
return DD_OK;
|
||||
}
|
||||
@ -1195,11 +1190,7 @@ HRESULT WINAPI DirectDrawCreate(GUID FAR* lpGUID, LPDIRECTDRAW FAR* lplpDD, IUnk
|
||||
}
|
||||
|
||||
GetPrivateProfileStringA("ddraw", "vhack", "false", tmp, sizeof(tmp), SettingsIniPath);
|
||||
if (tolower(tmp[0]) == 'y' || tolower(tmp[0]) == 't' || tolower(tmp[0]) == 'e' || tmp[0] == '1')
|
||||
{
|
||||
This->vhack = 2;
|
||||
}
|
||||
else if(tolower(tmp[0]) == 'a')
|
||||
if (tolower(tmp[0]) == 'y' || tolower(tmp[0]) == 't' || tolower(tmp[0]) == 'e' || tolower(tmp[0]) == 'a' || tmp[0] == '1')
|
||||
{
|
||||
This->vhack = 1;
|
||||
}
|
||||
|
@ -82,7 +82,7 @@ BOOL WINAPI fake_GetCursorPos(LPPOINT lpPoint)
|
||||
ddraw->cursor.y = pt.y;
|
||||
}
|
||||
|
||||
if (ddraw->vhack && (ddraw->iscnc1 || ddraw->isredalert) && ddraw->incutscene)
|
||||
if (ddraw->vhack && InterlockedExchangeAdd(&ddraw->incutscene, 0))
|
||||
{
|
||||
diffx = 0;
|
||||
diffy = 0;
|
||||
|
24
src/render.c
24
src/render.c
@ -487,24 +487,20 @@ DWORD WINAPI render_main(void)
|
||||
|
||||
if (ddraw->primary && ddraw->primary->palette)
|
||||
{
|
||||
if (ddraw->vhack && detect_cutscene())
|
||||
if (ddraw->vhack)
|
||||
{
|
||||
scale_w *= (float)CUTSCENE_WIDTH / ddraw->width;
|
||||
scale_h *= (float)CUTSCENE_HEIGHT / ddraw->height;
|
||||
|
||||
if (!ddraw->incutscene)
|
||||
if (detect_cutscene())
|
||||
{
|
||||
scaleChanged = TRUE;
|
||||
ddraw->incutscene = TRUE;
|
||||
scale_w *= (float)CUTSCENE_WIDTH / ddraw->width;
|
||||
scale_h *= (float)CUTSCENE_HEIGHT / ddraw->height;
|
||||
|
||||
if (!InterlockedExchange(&ddraw->incutscene, TRUE))
|
||||
scaleChanged = TRUE;
|
||||
}
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
if (ddraw->incutscene)
|
||||
else
|
||||
{
|
||||
scaleChanged = TRUE;
|
||||
ddraw->incutscene = FALSE;
|
||||
if (InterlockedExchange(&ddraw->incutscene, FALSE))
|
||||
scaleChanged = TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -35,9 +35,6 @@ BOOL detect_cutscene()
|
||||
if(ddraw->width <= CUTSCENE_WIDTH || ddraw->height <= CUTSCENE_HEIGHT)
|
||||
return FALSE;
|
||||
|
||||
//if (ddraw->isredalert && *InMovie)
|
||||
// return !*IsVQA640;
|
||||
|
||||
if (ddraw->isredalert)
|
||||
{
|
||||
if ((*InMovie && !*IsVQA640) || *ShouldStretch)
|
||||
@ -120,13 +117,8 @@ DWORD WINAPI render_soft_main(void)
|
||||
|
||||
EnterCriticalSection(&ddraw->cs);
|
||||
|
||||
if (ddraw->primary && (ddraw->primary->palette || ddraw->bpp == 16))
|
||||
if (ddraw->primary && ddraw->primary->palette && ddraw->primary->palette->data_rgb)
|
||||
{
|
||||
if (ddraw->primary->palette && ddraw->primary->palette->data_rgb == NULL)
|
||||
{
|
||||
ddraw->primary->palette->data_rgb = &ddraw->primary->bmi->bmiColors[0];
|
||||
}
|
||||
|
||||
if (warningText[0])
|
||||
{
|
||||
if (timeGetTime() < warningEndTick)
|
||||
@ -138,44 +130,61 @@ DWORD WINAPI render_soft_main(void)
|
||||
warningText[0] = 0;
|
||||
}
|
||||
|
||||
if ((ddraw->render.width != ddraw->width || ddraw->render.height != ddraw->height) &&
|
||||
!(ddraw->vhack && detect_cutscene()) )
|
||||
BOOL scaleCutscene = ddraw->vhack && detect_cutscene();
|
||||
|
||||
if (ddraw->vhack)
|
||||
InterlockedExchange(&ddraw->incutscene, scaleCutscene);
|
||||
|
||||
if (scaleCutscene)
|
||||
{
|
||||
StretchDIBits(
|
||||
ddraw->render.hDC, ddraw->render.viewport.x, ddraw->render.viewport.y,
|
||||
ddraw->render.viewport.width, ddraw->render.viewport.height,
|
||||
0, 0, ddraw->width, ddraw->height, ddraw->primary->surface,
|
||||
ddraw->primary->bmi, DIB_RGB_COLORS, SRCCOPY);
|
||||
ddraw->render.hDC,
|
||||
ddraw->render.viewport.x,
|
||||
ddraw->render.viewport.y,
|
||||
ddraw->render.viewport.width,
|
||||
ddraw->render.viewport.height,
|
||||
0,
|
||||
ddraw->height - 400,
|
||||
CUTSCENE_WIDTH,
|
||||
CUTSCENE_HEIGHT,
|
||||
ddraw->primary->surface,
|
||||
ddraw->primary->bmi,
|
||||
DIB_RGB_COLORS,
|
||||
SRCCOPY);
|
||||
}
|
||||
else if (!(ddraw->vhack && detect_cutscene()))
|
||||
else if (ddraw->render.width != ddraw->width || ddraw->render.height != ddraw->height)
|
||||
{
|
||||
StretchDIBits(
|
||||
ddraw->render.hDC,
|
||||
ddraw->render.viewport.x,
|
||||
ddraw->render.viewport.y,
|
||||
ddraw->render.viewport.width,
|
||||
ddraw->render.viewport.height,
|
||||
0,
|
||||
0,
|
||||
ddraw->width,
|
||||
ddraw->height,
|
||||
ddraw->primary->surface,
|
||||
ddraw->primary->bmi,
|
||||
DIB_RGB_COLORS,
|
||||
SRCCOPY);
|
||||
}
|
||||
else
|
||||
{
|
||||
SetDIBitsToDevice(
|
||||
ddraw->render.hDC, 0, 0, ddraw->width, ddraw->height, 0, 0, 0,
|
||||
ddraw->height, ddraw->primary->surface, ddraw->primary->bmi, DIB_RGB_COLORS);
|
||||
ddraw->render.hDC,
|
||||
0,
|
||||
0,
|
||||
ddraw->width,
|
||||
ddraw->height,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
ddraw->height,
|
||||
ddraw->primary->surface,
|
||||
ddraw->primary->bmi,
|
||||
DIB_RGB_COLORS);
|
||||
}
|
||||
|
||||
}
|
||||
if (ddraw->vhack && ddraw->primary && detect_cutscene()) // for vhack
|
||||
{
|
||||
if (ddraw->primary->palette && ddraw->primary->palette->data_rgb == NULL)
|
||||
{
|
||||
ddraw->primary->palette->data_rgb = &ddraw->primary->bmi->bmiColors[0];
|
||||
}
|
||||
|
||||
StretchDIBits(
|
||||
ddraw->render.hDC, ddraw->render.viewport.x, ddraw->render.viewport.y,
|
||||
ddraw->render.viewport.width, ddraw->render.viewport.height,
|
||||
0, ddraw->height-400, CUTSCENE_WIDTH, CUTSCENE_HEIGHT, ddraw->primary->surface,
|
||||
ddraw->primary->bmi, DIB_RGB_COLORS, SRCCOPY);
|
||||
|
||||
if (ddraw->primary->palette && !ddraw->incutscene)
|
||||
{
|
||||
ddraw->incutscene = TRUE;
|
||||
}
|
||||
}
|
||||
else if(ddraw->primary && ddraw->primary->palette && ddraw->incutscene)
|
||||
{
|
||||
ddraw->incutscene = FALSE;
|
||||
}
|
||||
|
||||
LeaveCriticalSection(&ddraw->cs);
|
||||
|
@ -420,7 +420,12 @@ HRESULT __stdcall ddraw_surface_SetPalette(IDirectDrawSurfaceImpl *This, LPDIREC
|
||||
IDirectDrawPalette_Release(This->palette);
|
||||
}
|
||||
|
||||
EnterCriticalSection(&ddraw->cs);
|
||||
|
||||
This->palette = (IDirectDrawPaletteImpl *)lpDDPalette;
|
||||
This->palette->data_rgb = &This->bmi->bmiColors[0];
|
||||
|
||||
LeaveCriticalSection(&ddraw->cs);
|
||||
|
||||
return DD_OK;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user