1
0
mirror of https://github.com/FunkyFr3sh/cnc-ddraw.git synced 2025-03-26 10:29:23 +01:00

fix vhack for cnc1

This commit is contained in:
FunkyFr3sh 2018-03-23 03:21:16 +01:00
parent 4114b96766
commit e65c03c607
6 changed files with 59 additions and 42 deletions

View File

@ -1,6 +1,6 @@
1 VERSIONINFO 1 VERSIONINFO
FILEVERSION 1,1,6,1 FILEVERSION 1,1,6,2
PRODUCTVERSION 1,1,6,1 PRODUCTVERSION 1,1,6,2
{ {
BLOCK "StringFileInfo" BLOCK "StringFileInfo"
{ {
@ -8,13 +8,13 @@ PRODUCTVERSION 1,1,6,1
{ {
VALUE "CompanyName", "cncnet.org" VALUE "CompanyName", "cncnet.org"
VALUE "FileDescription", "DirectDraw replacement for C&C95 and Red Alert" 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 "InternalName", "ddraw"
VALUE "LegalCopyright", "Copyright (c) 2010-2018" VALUE "LegalCopyright", "Copyright (c) 2010-2018"
VALUE "LegalTrademarks", "" VALUE "LegalTrademarks", ""
VALUE "OriginalFileName", "ddraw.dll" VALUE "OriginalFileName", "ddraw.dll"
VALUE "ProductName", "DirectDraw replacement for C&C95 and Red Alert" 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" VALUE "Comments", "https://cncnet.org"
} }
} }

View File

@ -23,6 +23,9 @@
#include <GL/gl.h> #include <GL/gl.h>
#include <GL/glu.h> #include <GL/glu.h>
#define CUTSCENE_WIDTH 640
#define CUTSCENE_HEIGHT 400
struct IDirectDrawImpl; struct IDirectDrawImpl;
struct IDirectDrawImplVtbl; struct IDirectDrawImplVtbl;
struct IDirectDrawSurfaceImpl; struct IDirectDrawSurfaceImpl;
@ -74,13 +77,14 @@ typedef struct IDirectDrawImpl
HWND hWnd; HWND hWnd;
LRESULT CALLBACK (*WndProc)(HWND, UINT, WPARAM, LPARAM); LRESULT CALLBACK (*WndProc)(HWND, UINT, WPARAM, LPARAM);
struct { float x; float y; } cursor; struct { float x; float y; } cursor;
struct { int width; int height; } cursorclip;
BOOL locked; BOOL locked;
BOOL adjmouse; BOOL adjmouse;
BOOL devmode; BOOL devmode;
BOOL vsync; BOOL vsync;
BOOL vhack; BOOL vhack;
BOOL isredalert; BOOL isredalert;
BOOL iscnc1;
BOOL incutscene;
DWORD WINAPI (*renderer)(void); DWORD WINAPI (*renderer)(void);
char screenshotKey; char screenshotKey;
BOOL opengl_pbo; BOOL opengl_pbo;

View File

@ -256,11 +256,9 @@ HRESULT __stdcall ddraw_SetDisplayMode(IDirectDrawImpl *This, DWORD width, DWORD
This->width = width; This->width = width;
This->height = height; This->height = height;
This->bpp = bpp; This->bpp = bpp;
This->cursorclip.width = width;
This->cursorclip.height = height;
ddraw->cursor.x = ddraw->cursorclip.width / 2; ddraw->cursor.x = width / 2;
ddraw->cursor.y = ddraw->cursorclip.height / 2; ddraw->cursor.y = height / 2;
if(This->fullscreen) if(This->fullscreen)
{ {
@ -766,9 +764,15 @@ 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 (!strcmp(This->title, "Red Alert")) ddraw->isredalert = strcmp(This->title, "Red Alert") == 0;
ddraw->iscnc1 = strcmp(This->title, "Command & Conquer") == 0;
if(This->vhack == 1)
{ {
ddraw->isredalert = 1; if (!ddraw->isredalert && !ddraw->iscnc1)
{
This->vhack = 0;
}
} }
return DD_OK; return DD_OK;

View File

@ -35,11 +35,14 @@ struct hack
BOOL WINAPI fake_GetCursorPos(LPPOINT lpPoint) BOOL WINAPI fake_GetCursorPos(LPPOINT lpPoint)
{ {
POINT pt; POINT pt, realpt;
if (!GetCursorPos(&pt)) if (!GetCursorPos(&pt))
return FALSE; return FALSE;
realpt.x = pt.x;
realpt.y = pt.y;
if(ddraw->locked && (!ddraw->windowed || ScreenToClient(ddraw->hWnd, &pt))) if(ddraw->locked && (!ddraw->windowed || ScreenToClient(ddraw->hWnd, &pt)))
{ {
if(ddraw->adjmouse) if(ddraw->adjmouse)
@ -52,6 +55,26 @@ BOOL WINAPI fake_GetCursorPos(LPPOINT lpPoint)
ddraw->cursor.x = pt.x; ddraw->cursor.x = pt.x;
ddraw->cursor.y = pt.y; 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) if (lpPoint)
@ -63,7 +86,8 @@ BOOL WINAPI fake_GetCursorPos(LPPOINT lpPoint)
} }
else if (ddraw->locked || ddraw->devmode) else if (ddraw->locked || ddraw->devmode)
{ {
return GetCursorPos(lpPoint); lpPoint->x = realpt.x;
lpPoint->y = realpt.y;
} }
else else
return FALSE; return FALSE;

View File

@ -26,8 +26,6 @@
#include "main.h" #include "main.h"
#include "surface.h" #include "surface.h"
#define CUTSCENE_WIDTH 640
#define CUTSCENE_HEIGHT 400
PFNGLGENBUFFERSARBPROC pglGenBuffersARB = 0; // VBO Name Generation Procedure PFNGLGENBUFFERSARBPROC pglGenBuffersARB = 0; // VBO Name Generation Procedure
PFNGLBINDBUFFERARBPROC pglBindBufferARB = 0; // VBO Bind Procedure PFNGLBINDBUFFERARBPROC pglBindBufferARB = 0; // VBO Bind Procedure
@ -194,22 +192,16 @@ DWORD WINAPI render_main(void)
scale_w *= (float)CUTSCENE_WIDTH / ddraw->width; scale_w *= (float)CUTSCENE_WIDTH / ddraw->width;
scale_h *= (float)CUTSCENE_HEIGHT / ddraw->height; 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->incutscene = TRUE;
ddraw->cursorclip.height = CUTSCENE_HEIGHT;
ddraw->cursor.x = CUTSCENE_WIDTH / 2;
ddraw->cursor.y = CUTSCENE_HEIGHT / 2;
} }
} }
else else
{ {
if (ddraw->cursorclip.width != ddraw->width || ddraw->cursorclip.height != ddraw->height) if (ddraw->incutscene)
{ {
ddraw->cursorclip.width = ddraw->width; ddraw->incutscene = FALSE;
ddraw->cursorclip.height = ddraw->height;
ddraw->cursor.x = ddraw->width / 2;
ddraw->cursor.y = ddraw->height / 2;
} }
} }

View File

@ -20,8 +20,6 @@
#include "main.h" #include "main.h"
#include "surface.h" #include "surface.h"
#define CUTSCENE_WIDTH 640
#define CUTSCENE_HEIGHT 400
static unsigned char getPixel(int x, int y) static unsigned char getPixel(int x, int y)
{ {
@ -37,7 +35,10 @@ BOOL detect_cutscene()
if(ddraw->width <= CUTSCENE_WIDTH || ddraw->height <= CUTSCENE_HEIGHT) if(ddraw->width <= CUTSCENE_WIDTH || ddraw->height <= CUTSCENE_HEIGHT)
return FALSE; return FALSE;
if (ddraw->isredalert == TRUE) //if (ddraw->isredalert && *InMovie)
// return !*IsVQA640;
if (ddraw->isredalert)
{ {
if ((*InMovie && !*IsVQA640) || *ShouldStretch) 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, 0, ddraw->height-400, CUTSCENE_WIDTH, CUTSCENE_HEIGHT, ddraw->primary->surface,
bmi, DIB_RGB_COLORS, SRCCOPY); bmi, DIB_RGB_COLORS, SRCCOPY);
if (ddraw->primary->palette && if (ddraw->primary->palette && !ddraw->incutscene)
(ddraw->cursorclip.width != CUTSCENE_WIDTH || ddraw->cursorclip.height != CUTSCENE_HEIGHT))
{ {
ddraw->cursorclip.width = CUTSCENE_WIDTH; ddraw->incutscene = TRUE;
ddraw->cursorclip.height = CUTSCENE_HEIGHT;
ddraw->cursor.x = CUTSCENE_WIDTH / 2;
ddraw->cursor.y = CUTSCENE_HEIGHT / 2;
} }
} }
else if(ddraw->primary && ddraw->primary->palette && else if(ddraw->primary && ddraw->primary->palette && ddraw->incutscene)
(ddraw->cursorclip.width != ddraw->width || ddraw->cursorclip.height != ddraw->height))
{ {
ddraw->cursorclip.width = ddraw->width; ddraw->incutscene = FALSE;
ddraw->cursorclip.height = ddraw->height;
ddraw->cursor.x = ddraw->width / 2;
ddraw->cursor.y = ddraw->height / 2;
} }
LeaveCriticalSection(&ddraw->cs); LeaveCriticalSection(&ddraw->cs);