Page 1 of 1

War Gods - direct3d1

Posted: January 21st, 2015, 8:13 pm
by bclarte
Hi,

This game from 1996-1997 Midway uses D3D1, which isn't correctly supported by dxgl yet.

FindDevice needs to use these smaller structs:

Code: Select all

typedef struct _D3DDEVICEDESC1 {
        DWORD           dwSize;
        DWORD           dwFlags;
        D3DCOLORMODEL   dcmColorModel;
        DWORD           dwDevCaps;
        D3DTRANSFORMCAPS dtcTransformCaps;
        BOOL            bClipping;
        D3DLIGHTINGCAPS dlcLightingCaps;
        D3DPRIMCAPS     dpcLineCaps;
        D3DPRIMCAPS     dpcTriCaps;
        DWORD           dwDeviceRenderBitDepth;
        DWORD           dwDeviceZBufferBitDepth;
        DWORD           dwMaxBufferSize;
        DWORD           dwMaxVertexCount;
} D3DDEVICEDESC1,*LPD3DDEVICEDESC1;


typedef struct _D3DFINDDEVICERESULT1 {
    DWORD               dwSize;
    GUID                guid;
    D3DDEVICEDESC1       ddHwDesc;
    D3DDEVICEDESC1       ddSwDesc;
} D3DFINDDEVICERESULT1,*LPD3DFINDDEVICERESULT1;



HRESULT WINAPI glDirect3D7::FindDevice(LPD3DFINDDEVICESEARCH lpD3DFDS, LPD3DFINDDEVICERESULT lpD3DFDR)
..
..
	// war gods - d3d1
	if(lpD3DFDR->dwSize == sizeof(D3DFINDDEVICERESULT1)) d3d1 = true;
	else if(lpD3DFDR->dwSize < sizeof(D3DFINDDEVICERESULT)) TRACE_RET(HRESULT,23,DDERR_INVALIDPARAMS);

Game doesn't care what's returned in the FDR struct other than GUID. There is another bug that's not fixed and is only pseudo-hacked around. I have no idea what causes the drawwindow_? to overscan / overdraw.

Code: Select all

HRESULT WINAPI glDirectDraw1::SetDisplayMode(DWORD dwWidth, DWORD dwHeight, DWORD dwBPP)
{
	TRACE_ENTER(4,14,this,8,dwWidth,8,dwHeight,8,dwBPP);
	if(!this) TRACE_RET(HRESULT,23,DDERR_INVALIDOBJECT);
	//TRACE_RET(HRESULT,23,glDD7->SetDisplayMode(dwWidth,dwHeight,dwBPP,0,0));
	return 0;
}
Game sets 640x480x16. But the viewport?? drawing is very off - it only shows top-left quadrant of picture and crops the rest offscreen. This workaround keeps desktop resolution and shows the remaining "cropped" screen plus extra black area.

Code: Select all

xxxxx======
xxxxx======
xxxxx======
===========
===========
===========
Sorry it's hard to describe. But the game runs / looks great - back in the day, it only worked on Voodoo1 or s3virge. Most 3d cards like Matrox or voodoo2 failed to go.


Extra note: to get 3d acceleration working on NT or higher, you have to hack the wargods.exe

Goto exe offset 0x1fca0: 0xeb to skip the os check.


Thanks for your great emulation work! Exciting to see this running once again. :)

Re: War Gods - direct3d1

Posted: January 22nd, 2015, 7:48 pm
by bclarte
I found some more info on why the screen is behaving wonky. Game keeps switching windowed (320x200) -> fullscreen (640x480) -> windowed (320x200) -> etc.


GetClientRect starts to get stuck in some warped state, returning weird results like:

Code: Select all

(windowed)
    glDirectDraw7::SetCooperativeLevel: left set to 0
    glDirectDraw7::SetCooperativeLevel: right set to 524
    glDirectDraw7::SetCooperativeLevel: top set to 0
    glDirectDraw7::SetCooperativeLevel: bottom set to 431
    glDirectDraw7::SetCooperativeLevel: width set to 1366
    glDirectDraw7::SetCooperativeLevel: height set to 768
        InitGL(524, 431, 32, false, 0x00110192, PTR);



(later fullscreen switch again)
glDirectDraw1::SetCooperativeLevel(PTR, 0x00110192, 0x00000055);
    glDirectDraw7::SetCooperativeLevel(PTR, 0x00110192, 0x00000055);
    glDirectDraw7::SetCooperativeLevel: fullscreen @@  left set to 0
    glDirectDraw7::SetCooperativeLevel: fullscreen @@  right set to 524
    glDirectDraw7::SetCooperativeLevel: fullscreen @@  top set to 0
    glDirectDraw7::SetCooperativeLevel: fullscreen @@  bottom set to 431
    glDirectDraw7::SetCooperativeLevel: width set to 1366
    glDirectDraw7::SetCooperativeLevel: height set to 768
        InitGL(1366, 768, 32, true, 0x00110192, PTR);
I don't know how to fix this, but that's roughly what the game does.

Re: War Gods - direct3d1

Posted: January 22nd, 2015, 8:22 pm
by bclarte
Sorry about this - wanted to PM you but don't have permission yet and can't edit post #2 either. :)


Found out that replacing:

Code: Select all

		//ShowWindow(This->hWnd,SW_MAXIMIZE);
		ShowWindow(This->hWnd,SW_NORMAL);

Code: Select all

		//ShowWindow(newwnd,SW_MAXIMIZE);
		ShowWindow(newwnd,SW_NORMAL);
fixes most of the weird clientrect problems. It now correctly shows a centered 320x200 window + correct 640x480 fullscreen mode (using 640x480 compatibility mode).


Thanks again for everything!

Re: War Gods - direct3d1

Posted: January 25th, 2015, 7:11 pm
by William
Hello. I will take a look at these issues soon. And regarding PM's, that is because the system still considers you a "Newly registered user."

Re: War Gods - direct3d1

Posted: March 30th, 2024, 12:11 pm
by William
Hello. If you still have an issue with this game, please file an issue at https://github.com/dxgldotorg/dxgl