1
0
mirror of https://github.com/FunkyFr3sh/cnc-ddraw.git synced 2025-03-24 17:49:52 +01:00

support upscale hack for KKND Xtreme high resolution patch (vhack=true)

This commit is contained in:
FunkyFr3sh 2021-05-15 00:41:50 +02:00
parent d1d9b1f972
commit 39c62d6e7d
10 changed files with 47 additions and 22 deletions

View File

@ -89,8 +89,11 @@ typedef struct cnc_ddraw
BOOL devmode; BOOL devmode;
BOOL vsync; BOOL vsync;
BOOL vhack; BOOL vhack;
int upscale_hack_width;
int upscale_hack_height;
BOOL isredalert; BOOL isredalert;
BOOL iscnc1; BOOL iscnc1;
BOOL iskkndx;
LONG incutscene; LONG incutscene;
DWORD (WINAPI *renderer)(void); DWORD (WINAPI *renderer)(void);
BOOL fullscreen; BOOL fullscreen;

View File

@ -4,9 +4,6 @@
#define WIN32_LEAN_AND_MEAN #define WIN32_LEAN_AND_MEAN
#include <windows.h> #include <windows.h>
#define CUTSCENE_WIDTH 640
#define CUTSCENE_HEIGHT 400
void util_limit_game_ticks(); void util_limit_game_ticks();
void util_update_bnet_pos(int newX, int newY); void util_update_bnet_pos(int newX, int newY);

View File

@ -282,12 +282,12 @@ static void cfg_create_ini()
"; Should the window be resizeable by the user in windowed mode?\n" "; Should the window be resizeable by the user in windowed mode?\n"
"resizeable=true\n" "resizeable=true\n"
"\n" "\n"
"; Enable C&C video resize hack - Stretches C&C cutscenes to fullscreen\n"
"vhack=false\n"
"\n"
"; Enable linear (D3DTEXF_LINEAR) upscaling filter for the direct3d9 renderer (16 bit color depth games only)\n" "; Enable linear (D3DTEXF_LINEAR) upscaling filter for the direct3d9 renderer (16 bit color depth games only)\n"
"d3d9linear=true\n" "d3d9linear=true\n"
"\n" "\n"
"; Enable upscale hack for high resolution patches (Supports C&C1, Red Alert 1 and KKND Xtreme)\n"
"vhack=false\n"
"\n"
"\n" "\n"
"\n" "\n"
"; ### Compatibility settings ###\n" "; ### Compatibility settings ###\n"
@ -565,6 +565,10 @@ static void cfg_create_ini()
"[Moorhuhn2]\n" "[Moorhuhn2]\n"
"hook=3\n" "hook=3\n"
"\n" "\n"
"; KKND Xtreme (With high resolution patch)\n"
"[KKNDgame]\n"
"vhack=true\n"
"\n"
, fh); , fh);
fclose(fh); fclose(fh);

View File

@ -690,8 +690,20 @@ HRESULT dd_SetCooperativeLevel(HWND hwnd, DWORD dwFlags)
g_ddraw->isredalert = strcmp(g_ddraw->title, "Red Alert") == 0; g_ddraw->isredalert = strcmp(g_ddraw->title, "Red Alert") == 0;
g_ddraw->iscnc1 = strcmp(g_ddraw->title, "Command & Conquer") == 0; g_ddraw->iscnc1 = strcmp(g_ddraw->title, "Command & Conquer") == 0;
g_ddraw->iskkndx = strcmp(g_ddraw->title, "KKND Xtreme") == 0;
if (g_ddraw->vhack && !g_ddraw->isredalert && !g_ddraw->iscnc1) if (g_ddraw->iskkndx)
{
g_ddraw->upscale_hack_width = 640;
g_ddraw->upscale_hack_height = 480;
}
else if (g_ddraw->isredalert || g_ddraw->iscnc1)
{
g_ddraw->upscale_hack_width = 640;
g_ddraw->upscale_hack_height = 400;
}
if (g_ddraw->vhack && !g_ddraw->isredalert && !g_ddraw->iscnc1 && !g_ddraw->iskkndx)
{ {
g_ddraw->vhack = 0; g_ddraw->vhack = 0;
} }

View File

@ -36,6 +36,9 @@ HRESULT dds_Blt(IDirectDrawSurfaceImpl *This, LPRECT lpDestRect, LPDIRECTDRAWSUR
dbg_dump_dds_blt_flags(dwFlags); dbg_dump_dds_blt_flags(dwFlags);
if (g_ddraw->iskkndx && (dwFlags & DDBLT_COLORFILL) && lpDestRect && lpDestRect->right == 640 && lpDestRect->bottom == 480)
lpDestRect = NULL;
RECT src_rect = { 0, 0, src_surface ? src_surface->width : 0, src_surface ? src_surface->height : 0 }; RECT src_rect = { 0, 0, src_surface ? src_surface->width : 0, src_surface ? src_surface->height : 0 };
RECT dst_rect = { 0, 0, This->width, This->height }; RECT dst_rect = { 0, 0, This->width, This->height };

View File

@ -284,8 +284,8 @@ static BOOL d3d9_update_vertices(BOOL in_cutscene, BOOL stretch)
float vp_w = stretch ? (float)(g_ddraw->render.viewport.width + g_ddraw->render.viewport.x) : (float)g_ddraw->width; float vp_w = stretch ? (float)(g_ddraw->render.viewport.width + g_ddraw->render.viewport.x) : (float)g_ddraw->width;
float vp_h = stretch ? (float)(g_ddraw->render.viewport.height + g_ddraw->render.viewport.y) : (float)g_ddraw->height; float vp_h = stretch ? (float)(g_ddraw->render.viewport.height + g_ddraw->render.viewport.y) : (float)g_ddraw->height;
float s_h = in_cutscene ? g_d3d9.scale_h * ((float)CUTSCENE_HEIGHT / g_ddraw->height) : g_d3d9.scale_h; float s_h = in_cutscene ? g_d3d9.scale_h * ((float)g_ddraw->upscale_hack_height / g_ddraw->height) : g_d3d9.scale_h;
float s_w = in_cutscene ? g_d3d9.scale_w * ((float)CUTSCENE_WIDTH / g_ddraw->width) : g_d3d9.scale_w; float s_w = in_cutscene ? g_d3d9.scale_w * ((float)g_ddraw->upscale_hack_width / g_ddraw->width) : g_d3d9.scale_w;
CUSTOMVERTEX vertices[] = CUSTOMVERTEX vertices[] =
{ {

View File

@ -86,9 +86,9 @@ DWORD WINAPI gdi_render_main(void)
g_ddraw->render.viewport.width, g_ddraw->render.viewport.width,
g_ddraw->render.viewport.height, g_ddraw->render.viewport.height,
0, 0,
g_ddraw->height - CUTSCENE_HEIGHT, g_ddraw->height - g_ddraw->upscale_hack_height,
CUTSCENE_WIDTH, g_ddraw->upscale_hack_width,
CUTSCENE_HEIGHT, g_ddraw->upscale_hack_height,
g_ddraw->primary->surface, g_ddraw->primary->surface,
g_ddraw->primary->bmi, g_ddraw->primary->bmi,
DIB_RGB_COLORS, DIB_RGB_COLORS,

View File

@ -567,8 +567,8 @@ static void ogl_render()
{ {
if (util_detect_cutscene()) if (util_detect_cutscene())
{ {
g_ogl.scale_w *= (float)CUTSCENE_WIDTH / g_ddraw->width; g_ogl.scale_w *= (float)g_ddraw->upscale_hack_width / g_ddraw->width;
g_ogl.scale_h *= (float)CUTSCENE_HEIGHT / g_ddraw->height; g_ogl.scale_h *= (float)g_ddraw->upscale_hack_height / g_ddraw->height;
if (!InterlockedExchange(&g_ddraw->incutscene, TRUE)) if (!InterlockedExchange(&g_ddraw->incutscene, TRUE))
scale_changed = TRUE; scale_changed = TRUE;

View File

@ -341,7 +341,7 @@ BOOL util_detect_cutscene()
static int* is_vqa_640 = (int*)0x0065D7BC; static int* is_vqa_640 = (int*)0x0065D7BC;
static BYTE* should_stretch = (BYTE*)0x00607D78; static BYTE* should_stretch = (BYTE*)0x00607D78;
if (g_ddraw->width <= CUTSCENE_WIDTH || g_ddraw->height <= CUTSCENE_HEIGHT) if (g_ddraw->width <= g_ddraw->upscale_hack_width || g_ddraw->height <= g_ddraw->upscale_hack_height)
{ {
return FALSE; return FALSE;
} }
@ -357,7 +357,13 @@ BOOL util_detect_cutscene()
} }
else if (g_ddraw->iscnc1) else if (g_ddraw->iscnc1)
{ {
return util_get_pixel(CUTSCENE_WIDTH + 1, 0) == 0 || util_get_pixel(CUTSCENE_WIDTH + 5, 1) == 0 ? TRUE : FALSE; return
util_get_pixel(g_ddraw->upscale_hack_width + 1, 0) == 0 ||
util_get_pixel(g_ddraw->upscale_hack_width + 5, 1) == 0;
}
else if (g_ddraw->iskkndx)
{
return util_get_pixel(g_ddraw->width - 3, 3) == 0;
} }
return FALSE; return FALSE;

View File

@ -70,16 +70,16 @@ BOOL WINAPI fake_GetCursorPos(LPPOINT lpPoint)
diffx = 0; diffx = 0;
diffy = 0; diffy = 0;
if (g_ddraw->cursor.x > CUTSCENE_WIDTH) if (g_ddraw->cursor.x > g_ddraw->upscale_hack_width)
{ {
diffx = g_ddraw->cursor.x - CUTSCENE_WIDTH; diffx = g_ddraw->cursor.x - g_ddraw->upscale_hack_width;
g_ddraw->cursor.x = CUTSCENE_WIDTH; g_ddraw->cursor.x = g_ddraw->upscale_hack_width;
} }
if (g_ddraw->cursor.y > CUTSCENE_HEIGHT) if (g_ddraw->cursor.y > g_ddraw->upscale_hack_height)
{ {
diffy = g_ddraw->cursor.y - CUTSCENE_HEIGHT; diffy = g_ddraw->cursor.y - g_ddraw->upscale_hack_height;
g_ddraw->cursor.y = CUTSCENE_HEIGHT; g_ddraw->cursor.y = g_ddraw->upscale_hack_height;
} }
if (diffx || diffy) if (diffx || diffy)