diff --git a/MakefileVC b/MakefileVC index 82fcf5c2b..d11f97a46 100644 --- a/MakefileVC +++ b/MakefileVC @@ -49,6 +49,9 @@ endif all: Diablo.exe +debug: CFLAGS += /D "_DEBUG" +debug: Diablo.exe + # fix compilation order to match the VC6 workspace files DIABLO_SRC=$(sort $(filter-out Source/render.cpp, $(wildcard Source/*.cpp))) DIABLO_SRC += Source/render.cpp diff --git a/Source/dx.cpp b/Source/dx.cpp index d48e2d199..cf23fa27f 100644 --- a/Source/dx.cpp +++ b/Source/dx.cpp @@ -10,6 +10,9 @@ int sgdwLockCount; Screen *gpBuffer; IDirectDrawSurface *lpDDSBackBuf; IDirectDrawSurface *lpDDSPrimary; +#ifdef _DEBUG +int locktbl[256]; +#endif static CRITICAL_SECTION sgMemCrit; char gbBackBuf; // weak char gbEmulate; // weak @@ -184,7 +187,10 @@ HRESULT __fastcall dx_DirectDrawCreate(GUID *guid, IDirectDraw **DD, void *unkno return ((int (__stdcall *)(GUID *, IDirectDraw **, void *))v5)(v8, v3, unknown); } -void __fastcall j_lock_buf_priv(char a1) { +void __fastcall j_lock_buf_priv(BYTE idx) { +#ifdef _DEBUG + ++locktbl[idx]; +#endif lock_buf_priv(); } @@ -219,7 +225,12 @@ LABEL_9: } // 69CF0C: using guessed type int gpBufEnd; -void __fastcall j_unlock_buf_priv(char a1) { +void __fastcall j_unlock_buf_priv(BYTE idx) { +#ifdef _DEBUG + if ( !locktbl[idx] ) + TermMsg("Draw lock underflow: 0x%x", idx); + --locktbl[idx]; +#endif unlock_buf_priv(); } diff --git a/Source/dx.h b/Source/dx.h index 8b94a1fde..7afb6a161 100644 --- a/Source/dx.h +++ b/Source/dx.h @@ -23,9 +23,9 @@ void __fastcall dx_init(HWND hWnd); void __cdecl dx_create_back_buffer(); void __cdecl dx_create_primary_surface(); HRESULT __fastcall dx_DirectDrawCreate(GUID *guid, IDirectDraw **DD, void *unknown); -void __fastcall j_lock_buf_priv(char a1); +void __fastcall j_lock_buf_priv(BYTE idx); void __cdecl lock_buf_priv(); -void __fastcall j_unlock_buf_priv(char a1); +void __fastcall j_unlock_buf_priv(BYTE idx); void __cdecl unlock_buf_priv(); void __cdecl dx_cleanup(); void __cdecl dx_reinit();