1
0
mirror of https://github.com/DxWnd/DxWnd.reloaded synced 2024-12-30 09:25:35 +01:00

v2_02_06_src

Former-commit-id: d4efddb04484dd2edfc4dfcea2129763baf1ca88
This commit is contained in:
gho tik 2013-01-22 11:17:01 -05:00 committed by Refael ACkermann
parent e418999410
commit 8f3bc994d0
24 changed files with 4028 additions and 52 deletions

View File

@ -1,3 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:d748f1b239ec33cab73c3a6b40b6900a093f28c33c42e1b430f2e08f499e36fd
size 262144
oid sha256:19d29414d50135080a863b7865dfe2c8685150e1df359c9a5e528a65d5f9a46d
size 263168

View File

@ -1,3 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:b9e5a9b8b7cadb640fa36491af117b34e6979ac7eb3cee8fa4b55b06e1a3ab9f
oid sha256:fcaebaa1f5eaffeb624d13fdb6f6058db5383fcaeadf22df4a641a766127c8d5
size 488448

View File

@ -18,3 +18,8 @@ v2.02.05:
hooked winmm timeGetTime() API: makes time stretching work for Age of Empires series
changed time stretching grain: now it's not the coarse grained 2x, 4x,... series in 9 possible values but the fine grained series 1.5x, 2x, 3x,.... in 17 possible values
added status and time stretching view panels to tray icon menu
v2.02.06:
preliminary FPS counter overlapped on game screen, Alt-F7 to toggle display on/off.
fixed buf on time stretch logging (and possible game crash).
revised GetDC handling with 8BPP paletized surfaces: avoided need to emulate reverse-blitting and got an impressive speed improvement for games such as Age of Empires I & II and Hyperblade.

3881
debug/dxwnd.ini Normal file

File diff suppressed because it is too large Load Diff

View File

@ -504,7 +504,7 @@ static void dx_TogglePositionLock(HWND hwnd)
}
}
void dx_ToggleDC()
static void dx_ToggleDC()
{
if(dxw.dwFlags1 & HANDLEDC){
dxw.dwFlags1 &= ~HANDLEDC;
@ -516,6 +516,18 @@ void dx_ToggleDC()
}
}
static void dx_ToggleFPS()
{
if(dxw.dwFlags2 & SHOWFPS){
dxw.dwFlags2 &= ~SHOWFPS;
OutTrace("ToggleFPS: SHOWFPS mode OFF\n");
}
else {
dxw.dwFlags2 |= SHOWFPS;
OutTrace("ToggleFPS: SHOWFPS mode ON\n");
}
}
LRESULT LastCursorPos;
LRESULT CALLBACK extWindowProc(HWND hwnd, UINT message, WPARAM wparam, LPARAM lparam)
@ -684,23 +696,26 @@ LRESULT CALLBACK extWindowProc(HWND hwnd, UINT message, WPARAM wparam, LPARAM lp
case VK_F8:
dx_ToggleDC();
break;
case VK_F7:
dx_ToggleFPS();
break;
case VK_F6:
case VK_F5:
if (dxw.dwFlags2 & TIMESTRETCH) {
char *sTSCaption[17]={"x16","x8","x4","x2","x1",":2",":4",":8",":16"};
if (wparam == VK_F5 && (dxw.TimeShift < 8)) dxw.TimeShift++;
if (wparam == VK_F6 && (dxw.TimeShift > -8)) dxw.TimeShift--;
OutTrace("Time Stretch: shift=%d speed=%s\n", dxw.TimeShift, dxw.GetTSCaption());
DxWndStatus.iTimeShift=dxw.TimeShift;
SetHookStatus(&DxWndStatus);
}
break;
case VK_F4:
if (dxw.dwFlags1 & HANDLEALTF4) {
OutTraceD("WindowProc: WM_SYSKEYDOWN(ALT-F4) - terminating process\n");
TerminateProcess(GetCurrentProcess(),0);
}
break;
case VK_F5:
case VK_F6:
if (dxw.dwFlags2 & TIMESTRETCH) {
char *sTSCaption[9]={"x16","x8","x4","x2","x1",":2",":4",":8",":16"};
if (wparam == VK_F5 && (dxw.TimeShift < 8)) dxw.TimeShift++;
if (wparam == VK_F6 && (dxw.TimeShift > -8)) dxw.TimeShift--;
OutTrace("Time Stretch: shift=%d speed=%s\n", dxw.TimeShift, sTSCaption[dxw.TimeShift+4]);
DxWndStatus.iTimeShift=dxw.TimeShift;
SetHookStatus(&DxWndStatus);
}
break;
default:
break;
}

View File

@ -1,3 +1,4 @@
#include <stdio.h>
#include "dxwnd.h"
#include "dxwcore.hpp"
#include "syslibs.h"
@ -323,7 +324,7 @@ void dxwCore::ScreenRefresh(void)
}
static void ShowFPS()
static void CountFPS()
{
static DWORD time = 0xFFFFFFFF;
static DWORD FPSCount = 0;
@ -333,6 +334,7 @@ static void ShowFPS()
// log fps count
OutTrace("FPSCount=%d\n", FPSCount);
// show fps count on status win
GetHookStatus(&DxWndStatus);
DxWndStatus.FPSCount = FPSCount;
SetHookStatus(&DxWndStatus);
// reset
@ -372,7 +374,7 @@ static BOOL SkipFrameCount(int delay)
BOOL dxwCore::HandleFPS()
{
if(dwFlags2 & SHOWFPS) ShowFPS();
if(dwFlags2 & SHOWFPS) CountFPS();
if(dwFlags2 & LIMITFPS) LimitFrameCount(dxw.MaxFPS);
if(dwFlags2 & SKIPFPS) if(SkipFrameCount(dxw.MaxFPS)) return TRUE;
return FALSE;
@ -453,3 +455,57 @@ void dxwCore::GetSystemTime(LPSYSTEMTIME lpSystemTime)
dwStartTick = dwCurrentTick;
}
}
void dxwCore::ShowFPS(LPDIRECTDRAWSURFACE lpdds)
{
HDC xdc; // the working dc
char sBuf[81];
static DWORD dwTimer = 0;
static int corner = 0;
static int x, y;
static DWORD color;
if((*pGetTickCount)()-dwTimer > 4000){
if(!dwTimer) srand ((*pGetTickCount)());
dwTimer = (*pGetTickCount)();
//corner = rand() % 4;
corner = dwTimer % 4;
//color = ((0x80 + (rand() % 0x80))) +
// ((0x80 + (rand() % 0x80))<<8) +
// ((0x80 + (rand() % 0x80))<<16);
// color = rand() % 0x1000000;
//color = RGB(rand()%0x100, rand()%0x100, rand()%0x100);
//color = RGB(dwTimer%0x100, dwTimer%0x100, dwTimer%0x100);
color=0xFF0000; // blue
switch (corner) {
case 0: x=10; y=10; break;
case 1: x=dwScreenWidth-60; y=10; break;
case 2: x=dwScreenWidth-60; y=dwScreenHeight-20; break;
case 3: x=10; y=dwScreenHeight-20; break;
}
}
if (FAILED(lpdds->GetDC(&xdc))) return;
SetTextColor(xdc,color);
//SetBkMode(xdc, TRANSPARENT);
SetBkMode(xdc, OPAQUE);
sprintf(sBuf, "FPS: %d", DxWndStatus.FPSCount);
TextOut(xdc, x, y, sBuf, strlen(sBuf));
lpdds->ReleaseDC(xdc);
}
char *dxwCore::GetTSCaption(int shift)
{
static char *sTSCaption[17]={
"x16","x12","x8","x6",
"x4","x3","x2","x1.5",
"x1",
":1.5",":2",":3",":4",
":6",":8",":12",":16"};
if (shift<0 || shift>16) return "???";
return sTSCaption[shift+8];
}
char *dxwCore::GetTSCaption(void)
{
return GetTSCaption(TimeShift);
}

View File

@ -42,7 +42,9 @@ public: // methods
void ResetPrimarySurface(void);
void GetSystemTime(LPSYSTEMTIME lpSystemTime);
DWORD StretchTime(DWORD);
void ShowFPS(LPDIRECTDRAWSURFACE);
char *GetTSCaption(int);
char *GetTSCaption(void);
public: // simple data variables
DDPIXELFORMAT ActualPixelFormat;

View File

@ -23,7 +23,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#include <stdio.h>
#include "dxwnd.h"
#define VERSION "2.02.05"
#define VERSION "2.02.06"
LRESULT CALLBACK HookProc(int ncode, WPARAM wparam, LPARAM lparam);

View File

@ -1,7 +1,7 @@

Microsoft Visual Studio Solution File, Format Version 10.00
# Visual Studio 2008
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "dxwnd", "dxwnd.ws2008.vcproj", "{579E7FE7-2745-4100-A802-23511711FCDE}"
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "dxwnd", "dxwnd.vs2008.vcproj", "{579E7FE7-2745-4100-A802-23511711FCDE}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution

BIN
dll/dxwnd.vs2008.suo Normal file

Binary file not shown.

View File

@ -1,20 +0,0 @@

Microsoft Visual Studio Solution File, Format Version 9.00
# Visual Studio 2005
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "dxwnd", "dxwnd.ws2005.vcproj", "{579E7FE7-2745-4100-A802-23511711FCDE}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Win32 = Debug|Win32
Release|Win32 = Release|Win32
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{579E7FE7-2745-4100-A802-23511711FCDE}.Debug|Win32.ActiveCfg = Debug|Win32
{579E7FE7-2745-4100-A802-23511711FCDE}.Debug|Win32.Build.0 = Debug|Win32
{579E7FE7-2745-4100-A802-23511711FCDE}.Release|Win32.ActiveCfg = Release|Win32
{579E7FE7-2745-4100-A802-23511711FCDE}.Release|Win32.Build.0 = Release|Win32
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
EndGlobal

Binary file not shown.

Binary file not shown.

View File

@ -210,7 +210,7 @@ SetEntries_Type pSetEntries;
LPDIRECTDRAWSURFACE lpDDSEmu_Prim=NULL, lpDDSEmu_Back=NULL;
LPDIRECTDRAWSURFACE lpDDSBack=NULL;
LPDIRECTDRAWCLIPPER lpDDC=NULL;
LPDIRECTDRAWPALETTE lpDDP = 0;
LPDIRECTDRAWPALETTE lpDDP=NULL;
LPDIRECTDRAW lpDD=NULL;
// v2.1.87: lpServiceDD is the DIRECTDRAW object to which the primary surface and all
// the service objects (emulated backbuffer, emulater primary, ....) are attached.
@ -1688,14 +1688,12 @@ HRESULT WINAPI extCreateSurfaceEmu(int dxversion, CreateSurface_Type pCreateSurf
// beware of the different behaviour between older and newer directdraw releases...
if(dxversion >= 4){
//if (lpDDSHDC) while(lpDDSHDC->Release());
if (lpDDC) while(lpDDC->Release());
if (lpDDSEmu_Back) while(lpDDSEmu_Back->Release());
if (lpDDSEmu_Prim) while(lpDDSEmu_Prim->Release());
if (ddsd.dwFlags & DDSD_BACKBUFFERCOUNT)
if (lpDDSBack) while(lpDDSBack->Release());
}
//lpDDSHDC=NULL;
lpDDC=NULL;
lpDDSEmu_Back=NULL;
lpDDSEmu_Prim=NULL;
@ -1873,6 +1871,26 @@ HRESULT WINAPI extCreateSurfaceEmu(int dxversion, CreateSurface_Type pCreateSurf
return res;
}
// for 8BPP palettized surfaces, connect them to either the ddraw emulated palette or the GDI emulated palette
if(ddsd.ddpfPixelFormat.dwRGBBitCount==8){ // use a better condition here....
if(lpDDP==NULL){
// should link here to the GDI palette? See Hyperblade....
//static PALETTEENTRY Palette[256];
extern PALETTEENTRY *GDIPalette;
//res=(*pCreatePalette)(lpdd, DDPCAPS_ALLOW256|DDPCAPS_8BIT|DDPCAPS_INITIALIZE, Palette, &lpDDP, NULL);
res=(*pCreatePalette)(lpdd, DDPCAPS_ALLOW256|DDPCAPS_8BIT|DDPCAPS_INITIALIZE, GDIPalette, &lpDDP, NULL);
if (res) {
OutTraceE("CreateSurface: CreatePalette ERROR res=%x(%s) at %d\n", res, ExplainDDError(res), __LINE__);
return res;
}
}
res=(*pSetPalette)(*lplpdds, lpDDP);
if (res) {
OutTraceE("CreateSurface: SetPalette ERROR res=%x(%s) at %d\n", res, ExplainDDError(res), __LINE__);
return res;
}
}
// diagnostic hooks ....
HookDDSurfaceGeneric(lplpdds, dxversion);
// unmark this as possible primary
@ -2428,6 +2446,7 @@ HRESULT WINAPI sBlt(char *api, LPDIRECTDRAWSURFACE lpdds, LPRECT lpdestrect,
work on my PC.
*/
if(res==DDERR_UNSUPPORTED){
if (dxw.dwFlags2 & SHOWFPS) dxw.ShowFPS(lpddssrc);
res=(*pBlt)(lpDDSEmu_Prim, &destrect, lpddssrc, lpsrcrect, dwflags, lpddbltfx);
if (res) BlitError(res, lpsrcrect, &destrect, __LINE__);
}
@ -2462,6 +2481,7 @@ HRESULT WINAPI sBlt(char *api, LPDIRECTDRAWSURFACE lpdds, LPRECT lpdestrect,
lpDDSSource = lpdds;
}
if (dxw.dwFlags2 & SHOWFPS) dxw.ShowFPS(lpDDSSource);
res=(*pBlt)(lpDDSEmu_Prim, &destrect, lpDDSSource, &emurect, DDBLT_WAIT, 0);
if (res==DDERR_NOCLIPLIST){
RenewClipper(lpDD, lpDDSEmu_Prim);
@ -2880,6 +2900,7 @@ HRESULT WINAPI extUnlock(int dxversion, Unlock4_Type pUnlock, LPDIRECTDRAWSURFAC
lpDDSSource=lpdds;
}
if (dxw.dwFlags2 & SHOWFPS) dxw.ShowFPS(lpDDSSource);
res=(*pBlt)(lpDDSEmu_Prim, &screen, lpDDSSource, &rect, DDBLT_WAIT, 0);
if (res==DDERR_NOCLIPLIST) {
RenewClipper(lpDD, lpDDSEmu_Prim);
@ -2921,7 +2942,7 @@ HRESULT WINAPI extGetDC(LPDIRECTDRAWSURFACE lpdds, HDC FAR *pHDC)
// Should the surface have a RGB color setting to allow for DC creation?
// log an error just when not intercepted by EMULATESURFACE|HANDLEDC handling below
if ((dxw.dwFlags1 & (EMULATESURFACE|HANDLEDC))!=(EMULATESURFACE|HANDLEDC))
if ((dxw.dwFlags1 & (EMULATESURFACE|HANDLEDC))!=(EMULATESURFACE|HANDLEDC))
OutTraceE("GetDC ERROR: lpdss=%x%s, hdc=%x, res=%x(%s) at %d\n",
lpdds, IsPrim?"(PRIM)":"", *pHDC, res, ExplainDDError(res), __LINE__);

View File

@ -2265,6 +2265,7 @@ typedef struct tagDxWndLOGPALETTE
} DxWndLOGPALETTE;
DxWndLOGPALETTE MyPal;
PALETTEENTRY *GDIPalette = MyPal.palPalEntry;
//BOOL G_bForceBackground;
HPALETTE WINAPI extGDICreatePalette(CONST LOGPALETTE *plpal)

View File

@ -44,6 +44,7 @@ void CStatusDialog::OnTimer(UINT_PTR nIDEvent)
extern PRIVATEMAP *pTitles;
extern TARGETMAP *pTargets;
TARGETMAP *Target;
extern char *GetTSCaption(int);
CDialog::OnTimer(nIDEvent);
DxStatus=GetHookStatus(NULL);
@ -56,7 +57,6 @@ void CStatusDialog::OnTimer(UINT_PTR nIDEvent)
GetDllVersion(DllVersion);
DxWndStatus.Status=DxStatus;
if(DxStatus==DXW_RUNNING){
char *sTSCaption[17]={"x16","x12","x8","x6","x4","x3","x2","x1.5","x1",":1.5",":2",":3",":4",":6",":8",":12",":16"};
GetHookStatus(&DxWndStatus);
Target=&pTargets[DxWndStatus.TaskIdx];
@ -76,7 +76,7 @@ void CStatusDialog::OnTimer(UINT_PTR nIDEvent)
}
if(Target->flags2 & TIMESTRETCH){
if(DxWndStatus.iTimeShift>=-8 && DxWndStatus.iTimeShift<=8){
sprintf(sMsgBuf, "\nTime speed: %s", sTSCaption[DxWndStatus.iTimeShift+8]);
sprintf(sMsgBuf, "\nTime speed: %s", GetTSCaption(DxWndStatus.iTimeShift));
strcat(sMsg, sMsgBuf);
}
}

View File

@ -10,6 +10,7 @@ class CTimeSliderDialog : public CDialog
public:
CTimeSliderDialog(CWnd* pParent = NULL); // standard constructor
virtual ~CTimeSliderDialog();
//~CTimeSliderDialog();
// Dialog Data
enum { IDD = IDD_TIMESLIDER };

View File

@ -16,6 +16,8 @@ CTimeSliderDialog::CTimeSliderDialog(CWnd* pParent /*=NULL*/)
CTimeSliderDialog::~CTimeSliderDialog()
{
MessageBoxEx(0, "Time Slider destructor", "Warning", MB_OK | MB_ICONEXCLAMATION, NULL);
//CTimeSliderDialog::OnOK(); // kill timer....
}
void CTimeSliderDialog::DoDataExchange(CDataExchange* pDX)
@ -40,9 +42,9 @@ void CTimeSliderDialog::OnTimer(UINT_PTR nIDEvent)
DXWNDSTATUS Status;
CSliderCtrl *Slider;
CStatic *Text;
char *sTSCaption[17]={"x16","x12","x8","x6","x4","x3","x2","x1.5","x1",":1.5",":2",":3",":4",":6",":8",":12",":16"};
char sMsg[81];
static int iLastPos=-1;
extern char *GetTSCaption(int);
Slider=(CSliderCtrl *)this->GetDlgItem(IDC_TIMESLIDER);
Text=(CStatic *)this->GetDlgItem(IDC_TIMESPEED);
@ -67,7 +69,7 @@ void CTimeSliderDialog::OnTimer(UINT_PTR nIDEvent)
SetHookStatus(&Status);
}
iLastPos = i_TimeSlider;
sprintf(sMsg, "Time speed: %s", sTSCaption[i_TimeSlider+8]);
sprintf(sMsg, "Time speed %s", GetTSCaption(i_TimeSlider));
Text->SetWindowTextA(sMsg);
}
@ -93,8 +95,9 @@ void CTimeSliderDialog::OnOK()
{
// TODO: Add your specialized code here and/or call the base class
KillTimer(IDTIMER);
// stop timer
// MessageBoxEx(0, "Stopping Time Slider dialog", "Warning", MB_OK | MB_ICONEXCLAMATION, NULL);
KillTimer(IDTIMER);
DXWNDSTATUS Status;
GetHookStatus(&Status);

Binary file not shown.

View File

@ -200,3 +200,14 @@ void CDxwndhostApp::OnAppAbout()
/////////////////////////////////////////////////////////////////////////////
// CDxwndhostApp Message Handler
char *GetTSCaption(int shift)
{
static char *sTSCaption[17]={
"x16","x12","x8","x6",
"x4","x3","x2","x1.5",
"x1",
":1.5",":2",":3",":4",
":6",":8",":12",":16"};
if (shift<-8 || shift>8) return "???";
return sTSCaption[shift+8];
}

View File

@ -328,13 +328,13 @@ BEGIN
END
IDD_TIMESLIDER DIALOGEX 0, 0, 168, 65
STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | WS_POPUP | WS_CAPTION | WS_SYSMENU
STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | WS_POPUP | WS_CAPTION
CAPTION "Time Slider"
FONT 8, "MS Shell Dlg", 400, 0, 0x1
BEGIN
DEFPUSHBUTTON "OK",IDOK,111,44,50,14
CONTROL "",IDC_TIMESLIDER,"msctls_trackbar32",TBS_AUTOTICKS | TBS_TRANSPARENTBKGND | WS_TABSTOP,7,7,154,18,WS_EX_TRANSPARENT
LTEXT "Time shift:",IDC_TIMESPEED,7,43,64,15
LTEXT "Time speed",IDC_TIMESPEED,7,43,86,15
LTEXT "x16",IDC_STATIC,7,31,15,9
LTEXT "x8",IDC_STATIC,30,30,15,9
LTEXT "x4",IDC_STATIC,47,30,15,9

Binary file not shown.