diff --git a/main.c b/main.c index 6e74259..7a1b6a9 100644 --- a/main.c +++ b/main.c @@ -405,6 +405,14 @@ HRESULT __stdcall ddraw_SetCooperativeLevel(IDirectDrawImpl *This, HWND hWnd, DW 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; } @@ -589,6 +597,8 @@ HRESULT WINAPI DirectDrawCreate(GUID FAR* lpGUID, LPDIRECTDRAW FAR* lplpDD, IUnk "sensitivity=0.0\n" "; enable C&C/RA mouse hack\n" "mhack=true\n" + "; enable C&C video resize hack, auto = auto-detect game, true = forced, false = disabled\n" + "vhack=auto\n" , 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); 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; } diff --git a/main.h b/main.h index 3c5de93..7420f57 100644 --- a/main.h +++ b/main.h @@ -77,6 +77,7 @@ typedef struct IDirectDrawImpl BOOL devmode; BOOL vsync; float sensitivity; + BOOL vhack; } IDirectDrawImpl; diff --git a/render.c b/render.c index 6634832..733538f 100644 --- a/render.c +++ b/render.c @@ -20,6 +20,8 @@ #include "main.h" #include "surface.h" +BOOL detect_cutscene(); + DWORD WINAPI render_main(void) { int i,j; @@ -96,6 +98,12 @@ DWORD WINAPI render_main(void) EnterCriticalSection(&ddraw->cs); 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; iheight; i++) { for(j=0; jwidth; j++) @@ -137,3 +145,16 @@ DWORD WINAPI render_main(void) 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; +}