mirror of
https://github.com/FunkyFr3sh/cnc-ddraw.git
synced 2025-03-26 02:19:24 +01:00
Add support for C&C video scaling
This commit is contained in:
parent
a803c12995
commit
c073805db3
24
main.c
24
main.c
@ -405,6 +405,14 @@ HRESULT __stdcall ddraw_SetCooperativeLevel(IDirectDrawImpl *This, HWND hWnd, DW
|
|||||||
|
|
||||||
GetWindowText(This->hWnd, (LPTSTR)&This->title, sizeof(This->title));
|
GetWindowText(This->hWnd, (LPTSTR)&This->title, sizeof(This->title));
|
||||||
|
|
||||||
|
if(This->vhack == 1)
|
||||||
|
{
|
||||||
|
if (strcmp(This->title, "Command & Conquer"))
|
||||||
|
{
|
||||||
|
This->vhack = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return DD_OK;
|
return DD_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -589,6 +597,8 @@ HRESULT WINAPI DirectDrawCreate(GUID FAR* lpGUID, LPDIRECTDRAW FAR* lplpDD, IUnk
|
|||||||
"sensitivity=0.0\n"
|
"sensitivity=0.0\n"
|
||||||
"; enable C&C/RA mouse hack\n"
|
"; enable C&C/RA mouse hack\n"
|
||||||
"mhack=true\n"
|
"mhack=true\n"
|
||||||
|
"; enable C&C video resize hack, auto = auto-detect game, true = forced, false = disabled\n"
|
||||||
|
"vhack=auto\n"
|
||||||
, fh);
|
, fh);
|
||||||
fclose(fh);
|
fclose(fh);
|
||||||
}
|
}
|
||||||
@ -675,5 +685,19 @@ HRESULT WINAPI DirectDrawCreate(GUID FAR* lpGUID, LPDIRECTDRAW FAR* lplpDD, IUnk
|
|||||||
GetPrivateProfileStringA("ddraw", "sensitivity", "0", tmp, sizeof(tmp), ini_path);
|
GetPrivateProfileStringA("ddraw", "sensitivity", "0", tmp, sizeof(tmp), ini_path);
|
||||||
This->sensitivity = strtof(tmp, NULL);
|
This->sensitivity = strtof(tmp, NULL);
|
||||||
|
|
||||||
|
GetPrivateProfileStringA("ddraw", "vhack", "auto", tmp, sizeof(tmp), ini_path);
|
||||||
|
if(tolower(tmp[0]) == 'y' || tolower(tmp[0]) == 't' || tmp[0] == '1')
|
||||||
|
{
|
||||||
|
This->vhack = 2;
|
||||||
|
}
|
||||||
|
else if(tolower(tmp[0]) == 'a')
|
||||||
|
{
|
||||||
|
This->vhack = 1;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
This->vhack = 0;
|
||||||
|
}
|
||||||
|
|
||||||
return DD_OK;
|
return DD_OK;
|
||||||
}
|
}
|
||||||
|
1
main.h
1
main.h
@ -77,6 +77,7 @@ typedef struct IDirectDrawImpl
|
|||||||
BOOL devmode;
|
BOOL devmode;
|
||||||
BOOL vsync;
|
BOOL vsync;
|
||||||
float sensitivity;
|
float sensitivity;
|
||||||
|
BOOL vhack;
|
||||||
|
|
||||||
} IDirectDrawImpl;
|
} IDirectDrawImpl;
|
||||||
|
|
||||||
|
21
render.c
21
render.c
@ -20,6 +20,8 @@
|
|||||||
#include "main.h"
|
#include "main.h"
|
||||||
#include "surface.h"
|
#include "surface.h"
|
||||||
|
|
||||||
|
BOOL detect_cutscene();
|
||||||
|
|
||||||
DWORD WINAPI render_main(void)
|
DWORD WINAPI render_main(void)
|
||||||
{
|
{
|
||||||
int i,j;
|
int i,j;
|
||||||
@ -96,6 +98,12 @@ DWORD WINAPI render_main(void)
|
|||||||
EnterCriticalSection(&ddraw->cs);
|
EnterCriticalSection(&ddraw->cs);
|
||||||
if(ddraw->primary && ddraw->primary->palette)
|
if(ddraw->primary && ddraw->primary->palette)
|
||||||
{
|
{
|
||||||
|
if(ddraw->vhack && detect_cutscene())
|
||||||
|
{
|
||||||
|
scale_w *= 640.0f / ddraw->width;
|
||||||
|
scale_h *= 400.0f / ddraw->height;
|
||||||
|
}
|
||||||
|
|
||||||
for(i=0; i<ddraw->height; i++)
|
for(i=0; i<ddraw->height; i++)
|
||||||
{
|
{
|
||||||
for(j=0; j<ddraw->width; j++)
|
for(j=0; j<ddraw->width; j++)
|
||||||
@ -137,3 +145,16 @@ DWORD WINAPI render_main(void)
|
|||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static unsigned char getPixel(int x, int y)
|
||||||
|
{
|
||||||
|
return ((unsigned char *)ddraw->primary->surface)[y*ddraw->primary->lPitch + x*ddraw->primary->lXPitch];
|
||||||
|
}
|
||||||
|
|
||||||
|
BOOL detect_cutscene()
|
||||||
|
{
|
||||||
|
if(ddraw->width <= 640 || ddraw->height <= 480)
|
||||||
|
return FALSE;
|
||||||
|
|
||||||
|
return getPixel(641, 0) == 0 || getPixel(645, 1) == 0 ? TRUE : FALSE;
|
||||||
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user