Ddraw tweaks

Lock/Unlock Pitch Fix

FIXPITCH

Some programs ignore the pitch value returned by the DirectDrawSurface::Lock method and fill the graphics buffer according to an incorrect predetermined pitch value. This discrepancy is caused when DxWnd creates virtual surfaces with varying pitch values that may not correspond to the original values when creating the surface on a different memory type (system memory and video memory). When this is happening to a hooked program, some elements may appear diagonally skewed. Note how the left border of the text widget in the figure below goes down and to the right rather than straight down, distorting the contained text as well. This flag resolves the issue by copying the graphic scan lines to the proper memory offset. For additional examples, see Examples > SnowBoard: Racer.

Width not power of 2 fix

POWER2WIDTH

Some programs produce texture surfaces of odd sizes, which are generally not supported but can be detected when the textures have an incorrect aspect ratio. This flag resolves the issue by copying the graphic scan lines to the proper memory offset. The most notable example of this issue is in "Midtown Madness".

Fix ddraw refcount

FIXREFCOUNTER

Decrements the reference counter of some objects to properly track all of DxWnd's service objects.

Set ZBufferBitDepths capability

SETZBUFFERBITDEPTHS

The dwZBufferBitDepths is an obsolete field in the DirectDraw surface descriptor. It is no longer set and should be ignored, but some old programs rely on the value of this field and may crash if the field is empty (contains the NULL value). This flag copies the value returned by the GetCaps method and places it into the dwZBufferBitDepths field. The most notable example of this issue is in "MechCommander 2".

Limit ddraw interface

LIMITDDRAW

Instead of using a specific version of DirectDraw, some programs simply request the most recent version available on the machine. Using a version of DirectDraw that is significantly newer than what was available when the game was developed may yield poor results. This option hides newer versions of DirectDraw from the hooked program, basically allowing you to manually specify which version of DirectDraw the program should use. Choose a maximum DirectDraw version from the drop-down menu located near this option.

Set 16BPP RGB565 encoding

USERGB565

By default, DxWnd emulates 16bpp color with RGB555 encoding. This option forces RGB565. This option only impacts the video in emulation mode and with 16bpp color depth.

No EXCLUSIVE coop level

NODDEXCLUSIVEMODE

When running a program in windowed mode, DxWnd suppresses the DirectDraw DDSCL_EXCLUSIVE mode in the SetCooperativeLevel wrapper, since this mode is not allowed in windowed mode. However, if windowed mode is not requested, DxWnd leaves the cooperative level flags as they are, allowing DDSCL_EXCLUSIVE cooperative mode if requested. This flag also suppresses the DDSCL_EXCLUSIVE mode in fullscreen mode (that is, when DDSCL_FULLSCREEN is set). This flag is required when running "Warhammer 40,000: Rites of War" in non-windowed fullscreen mode.

Lock FULLSCREEN coop level

LOCKFULLSCREENCOOP

Prevents the return to the normal cooperative level in non-windowed mode, used in running "Speedboat Attack" in fullscreen mode.

Create a Desktop Win

CREATEDESKTOP

This flag creates a window if a game doesn't bother building it and blits directly on top of the desktop. Fixes "Manx TT Super Bike"

Safe palette usage

SAFEPALETTEUSAGE

Option to fix DirectDrawPalette use and abuse. As the name suggests, "Safe palette usage" inhibits some part of the palette handling that may cause problems in some circumstances (fixes "Speedboat Attack").

Enable gamma ramp emulation

LOADGAMMARAMP

Enables gamma ramp correction in DirectDraw. See Gamma control.

Full RECT Blit

FULLRECTBLIT

In some situations it can be difficult to calculate the exact position and size of the scaled blit operations. It is then possible to force a blit on the whole window surface and check if the result is preferrable. It is used with "Ashes to Ashes" to make the HUD visible during gameplay.

Fix DC palette

FIXDCPALETTE

The flag fixes the impossibility to apply a palette to a DC that is supposed to emulate a 8-bit video device but in reality has a different color depth. Particularly, it fixes the game "Legal Crime" .



VSync

This panel contains a set of different options meant to fine tune the vertical sync feature. Here, by VSync we mean the wait operation performed by the WaitForVerticalBlank() DirectDraw method. It should be noted that the VSync is always referred to operations toward the real primary surface on the video memory, so in direct modes, it changes the Flip/Blt to primary surface operations, while in emulated modes, it applies only to blit operations from the virtual primary surface to the real primary surface. The panel contains two selectors, one to specify whether to perform the VSync operation or not, the other to determine the method to be used. It should be noted that the former flag "Optimize CPU" is equivalent to the combination of VSync "ON" + "WaitForFrequency".

Default

Set by default. DxWnd closely follows the program's indications about VSync.

ON

FORCEVSYNC

When not present, DxWnd inserts a WaitForVerticalBlank operation before each Blt/Flip to the primary surface.

OFF

FORCENOVSYNC

Any WaitForVerticalBlank() invocation is bypassed.

WaitForVerticalBlank

Set by default. When performed, the VSync operation invokes the DirectDraw native WaitForVerticalBlank method.

WaitForScanline

VSYNCSCANLINE

This flag is for experimental usage, mainly to try to cause bad wait conditions on the vertical blank condition. The DirectDraw WaitForVerticalBlank method only allows for two operation modes, DDWAITVB_BLOCKBEGIN and DDWAITVB_BLOCKEND. Setting this flag, the operation is replaced by a series of Sleep(1) waits until the vertical line reaches a given threshold set in the numeric field to the right. The number in there, ranging from 1 to some value above 100, indicates the percentage of vertical line that triggers the end of wait condition.

WaitForFrequency

SAVELOAD

On some specific hardware and conditions, the WaitForVerticalBlank method could be either unimplemented or implemented in such a way that causes heavy CPU consumption. The WaitForFrequency flag replaces the WaitForVerticalBlank() implementation with an equivalent Sleep(n) operation, where 'n' is calculated to match the exact video vertical frequency. This way, CPU consumption is lowered to the minimum, though the operation is performed regardless of the actual vertical line position. On modern computers and video hardware though, this aspect is usually irrelevant and the risk of getting video tearing is absent.



Flip/Blt Wait

This panel contains a set of different options meant to fine tune the wait options for Blt or Flip operations. It should be noted that when using emulated modes, a Flip operation may be easily mapped to a sequence of one or more Blt and Flip operations, so that the original wait indication may have to be remapped to the corresponding indication for another method. It should be noted that the wait is always referred to the operations toward the real primary surface on the video memory, so in direct modes, it changes the Flip/Blt to primary surface operations, while in emulated modes, it applies only to blit operations from the virtual primary surface to the real primary surface.

The following are the wait flags affected by the "Blt/Flip Wait" panel:

NOTE: In DirectDraw, you can specify none of the flags above but in that case, the behaviour is mapped to either a WAIT or a DONOTWAIT condition depending on the DirectDraw interface version.

default

The Blt/Flip wait related flags are left unchanged.

ON

FORCEWAIT

Blt/Flip operations are forced to be performed with DDBLT_WAIT/DDFLIP_WAIT flags respectively.

OFF

FORCENOWAIT

Blt/Flip operations are forced to be performed with DDBLT_DONOTWAIT/DDFLIP_DONOTWAIT flags respectively.



Clipper

This panel contains a set of different options meant to fine tune the clipper creation options for DirectDraw operations. It should be noted that the lack of a clipper is a frequent consequence of the AERO, despite the emulation flags being properly set, the program breaks AERO at startup, a clipper creation should be attempted.

MSDN quote: One common use for a clipper is to define the boundaries of the screen or window. With a clipper that has the screen rectangle as its clip list, DirectDraw knows how to trim the sprite as it performs the blit so that only the visible portion is copied. Without a clipper object, DirectDraw does not allow you to blit the entire sprite, because part of it would fall outside the destination surface. A straight copy of the pixel values in the sprite to the destination surface buffer would result in an incorrect display and even memory access violations.

Default

The clipper object is created or not according to program specifications.

ON

FORCECLIPPER

Whenever the program omits the creation of a clipper object (in fullscreen programs, this is not mandatory), DxWnd forces its creation. For example, this fixes the MechWarrior 3 targeting crash when the resolution is set higher than 800x600.

OFF

SUPPRESSCLIPPING

In some rare cases, the clipper creation may lead to screen blinks, slow operations or errors. In these cases, it is better to sacrifice AERO support and turn clipping off to let the program run.

MAX

MAXCLIPPER

Forces the DirectDraw clip region to be the whole virtual desktop. This is necessary when the program uses the clipper area size to perform further calculations. In case of virtualized desktop, the actual clipper area does not match the scaled values, since the primary surface is as big as the whole actual desktop. Used (so far) only by "Full Pipe".



FourCC processing

No



HW

HWFOURCC

Hardware processing.

SW

SWFOURCC

Software processing.



Capabilities

Suppress overlay capability

SUPPRESSOVERLAY

Prevents the game from detecting any hardware overlay capability. Hardware overlay is very efficient, but not very flexible. If you run a program with hardware overlay in a window, you may be able to reposition and resize the window, but the blitted surface (the content of the window) doesn't move or change. This flag makes programs ignore the hardware overlay capability so that you can move or stretch the window with expected results. The most notable example of this issue is in "Moto Racer 2".

Set minimal caps

MINIMALCAPS

Simulates the minimal hardware capabilities similar to what's available on the VirtualPC or VMware emulators. Some older games may not support advanced features, a case where this flag can easily improve the rendering process and eliminate some artifacts.

Clear texture FourCC

CLEARTEXTUREFOURCC

DxWnd lets you dump, edit, and replace all the uncompressed game textures. Textures compressed with a FourCC codec can't be processed this way. This flag forces the FourCC capabilities OFF in the capability query and in texture surface creation. This forces the game to use plain, uncompressed bitmap textures that can be easily tweaked. To avoid texture errors, you may need to adjust the texture flags. This flag was introduced to allow uncompressed textures for the game "The Sting!".

It also trims the list to eliminate the DDPF_FOURCC entires. This fixes the rendering and text issues in Star Wars: Rogue Squardon 3D.

Suppress FOURCC blit capability

SUPPRESSFOURCCBLT

When a game queries the device capabilities, this flag pretends that the device has no capabilities to perform flip or blit operations when the surfaces have FourCC encoded data. This is useful because FourCC codec usually works in fullscreen mode, but fails in windowed mode.