diff --git a/ddraw.rc b/ddraw.rc index 9e82315..198e3bb 100644 --- a/ddraw.rc +++ b/ddraw.rc @@ -1,6 +1,6 @@ 1 VERSIONINFO -FILEVERSION 1,1,6,1 -PRODUCTVERSION 1,1,6,1 +FILEVERSION 1,1,6,2 +PRODUCTVERSION 1,1,6,2 { BLOCK "StringFileInfo" { @@ -8,13 +8,13 @@ PRODUCTVERSION 1,1,6,1 { VALUE "CompanyName", "cncnet.org" VALUE "FileDescription", "DirectDraw replacement for C&C95 and Red Alert" - VALUE "FileVersion", "1.1.6.1" + VALUE "FileVersion", "1.1.6.2" VALUE "InternalName", "ddraw" VALUE "LegalCopyright", "Copyright (c) 2010-2018" VALUE "LegalTrademarks", "" VALUE "OriginalFileName", "ddraw.dll" VALUE "ProductName", "DirectDraw replacement for C&C95 and Red Alert" - VALUE "ProductVersion", "1.1.6.1" + VALUE "ProductVersion", "1.1.6.2" VALUE "Comments", "https://cncnet.org" } } diff --git a/inc/main.h b/inc/main.h index 6192389..5c027f8 100644 --- a/inc/main.h +++ b/inc/main.h @@ -23,6 +23,9 @@ #include #include +#define CUTSCENE_WIDTH 640 +#define CUTSCENE_HEIGHT 400 + struct IDirectDrawImpl; struct IDirectDrawImplVtbl; struct IDirectDrawSurfaceImpl; @@ -74,13 +77,14 @@ typedef struct IDirectDrawImpl HWND hWnd; LRESULT CALLBACK (*WndProc)(HWND, UINT, WPARAM, LPARAM); struct { float x; float y; } cursor; - struct { int width; int height; } cursorclip; BOOL locked; BOOL adjmouse; BOOL devmode; BOOL vsync; BOOL vhack; BOOL isredalert; + BOOL iscnc1; + BOOL incutscene; DWORD WINAPI (*renderer)(void); char screenshotKey; BOOL opengl_pbo; diff --git a/src/main.c b/src/main.c index 4ed57a4..eccf7d4 100644 --- a/src/main.c +++ b/src/main.c @@ -256,11 +256,9 @@ HRESULT __stdcall ddraw_SetDisplayMode(IDirectDrawImpl *This, DWORD width, DWORD This->width = width; This->height = height; This->bpp = bpp; - This->cursorclip.width = width; - This->cursorclip.height = height; - ddraw->cursor.x = ddraw->cursorclip.width / 2; - ddraw->cursor.y = ddraw->cursorclip.height / 2; + ddraw->cursor.x = width / 2; + ddraw->cursor.y = height / 2; if(This->fullscreen) { @@ -766,10 +764,16 @@ HRESULT __stdcall ddraw_SetCooperativeLevel(IDirectDrawImpl *This, HWND hWnd, DW GetWindowText(This->hWnd, (LPTSTR)&This->title, sizeof(This->title)); - if (!strcmp(This->title, "Red Alert")) - { - ddraw->isredalert = 1; - } + 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; + } + } return DD_OK; } diff --git a/src/mouse.c b/src/mouse.c index 858ca48..5264e45 100644 --- a/src/mouse.c +++ b/src/mouse.c @@ -35,11 +35,14 @@ struct hack BOOL WINAPI fake_GetCursorPos(LPPOINT lpPoint) { - POINT pt; + POINT pt, realpt; if (!GetCursorPos(&pt)) return FALSE; + realpt.x = pt.x; + realpt.y = pt.y; + if(ddraw->locked && (!ddraw->windowed || ScreenToClient(ddraw->hWnd, &pt))) { if(ddraw->adjmouse) @@ -52,6 +55,26 @@ BOOL WINAPI fake_GetCursorPos(LPPOINT lpPoint) ddraw->cursor.x = pt.x; ddraw->cursor.y = pt.y; } + + if (ddraw->vhack && ddraw->iscnc1 && ddraw->incutscene) + { + int diffx = 0, diffy = 0; + + if (ddraw->cursor.x > CUTSCENE_WIDTH) + { + diffx = ddraw->cursor.x - CUTSCENE_WIDTH; + ddraw->cursor.x = CUTSCENE_WIDTH; + } + + if (ddraw->cursor.y > CUTSCENE_HEIGHT) + { + diffy = ddraw->cursor.y - CUTSCENE_HEIGHT; + ddraw->cursor.y = CUTSCENE_HEIGHT; + } + + if (diffx || diffy) + SetCursorPos(realpt.x - diffx, realpt.y - diffy); + } } if (lpPoint) @@ -63,7 +86,8 @@ BOOL WINAPI fake_GetCursorPos(LPPOINT lpPoint) } else if (ddraw->locked || ddraw->devmode) { - return GetCursorPos(lpPoint); + lpPoint->x = realpt.x; + lpPoint->y = realpt.y; } else return FALSE; diff --git a/src/render.c b/src/render.c index 6130fae..9137eab 100644 --- a/src/render.c +++ b/src/render.c @@ -26,8 +26,6 @@ #include "main.h" #include "surface.h" -#define CUTSCENE_WIDTH 640 -#define CUTSCENE_HEIGHT 400 PFNGLGENBUFFERSARBPROC pglGenBuffersARB = 0; // VBO Name Generation Procedure PFNGLBINDBUFFERARBPROC pglBindBufferARB = 0; // VBO Bind Procedure @@ -194,22 +192,16 @@ DWORD WINAPI render_main(void) scale_w *= (float)CUTSCENE_WIDTH / ddraw->width; scale_h *= (float)CUTSCENE_HEIGHT / ddraw->height; - if (ddraw->cursorclip.width != CUTSCENE_WIDTH || ddraw->cursorclip.height != CUTSCENE_HEIGHT) + if (!ddraw->incutscene) { - ddraw->cursorclip.width = CUTSCENE_WIDTH; - ddraw->cursorclip.height = CUTSCENE_HEIGHT; - ddraw->cursor.x = CUTSCENE_WIDTH / 2; - ddraw->cursor.y = CUTSCENE_HEIGHT / 2; + ddraw->incutscene = TRUE; } } else { - if (ddraw->cursorclip.width != ddraw->width || ddraw->cursorclip.height != ddraw->height) + if (ddraw->incutscene) { - ddraw->cursorclip.width = ddraw->width; - ddraw->cursorclip.height = ddraw->height; - ddraw->cursor.x = ddraw->width / 2; - ddraw->cursor.y = ddraw->height / 2; + ddraw->incutscene = FALSE; } } diff --git a/src/render_soft.c b/src/render_soft.c index 6130889..bb5a92c 100644 --- a/src/render_soft.c +++ b/src/render_soft.c @@ -20,8 +20,6 @@ #include "main.h" #include "surface.h" -#define CUTSCENE_WIDTH 640 -#define CUTSCENE_HEIGHT 400 static unsigned char getPixel(int x, int y) { @@ -37,7 +35,10 @@ BOOL detect_cutscene() if(ddraw->width <= CUTSCENE_WIDTH || ddraw->height <= CUTSCENE_HEIGHT) return FALSE; - if (ddraw->isredalert == TRUE) + //if (ddraw->isredalert && *InMovie) + // return !*IsVQA640; + + if (ddraw->isredalert) { if ((*InMovie && !*IsVQA640) || *ShouldStretch) { @@ -133,22 +134,14 @@ DWORD WINAPI render_soft_main(void) 0, ddraw->height-400, CUTSCENE_WIDTH, CUTSCENE_HEIGHT, ddraw->primary->surface, bmi, DIB_RGB_COLORS, SRCCOPY); - if (ddraw->primary->palette && - (ddraw->cursorclip.width != CUTSCENE_WIDTH || ddraw->cursorclip.height != CUTSCENE_HEIGHT)) + if (ddraw->primary->palette && !ddraw->incutscene) { - ddraw->cursorclip.width = CUTSCENE_WIDTH; - ddraw->cursorclip.height = CUTSCENE_HEIGHT; - ddraw->cursor.x = CUTSCENE_WIDTH / 2; - ddraw->cursor.y = CUTSCENE_HEIGHT / 2; + ddraw->incutscene = TRUE; } } - else if(ddraw->primary && ddraw->primary->palette && - (ddraw->cursorclip.width != ddraw->width || ddraw->cursorclip.height != ddraw->height)) + else if(ddraw->primary && ddraw->primary->palette && ddraw->incutscene) { - ddraw->cursorclip.width = ddraw->width; - ddraw->cursorclip.height = ddraw->height; - ddraw->cursor.x = ddraw->width / 2; - ddraw->cursor.y = ddraw->height / 2; + ddraw->incutscene = FALSE; } LeaveCriticalSection(&ddraw->cs);