Skip to content

Commit

Permalink
Implement config functions
Browse files Browse the repository at this point in the history
  • Loading branch information
Lectem committed Dec 15, 2024
1 parent 94e7d14 commit d8357d0
Show file tree
Hide file tree
Showing 13 changed files with 307 additions and 24 deletions.
3 changes: 1 addition & 2 deletions D2.Detours.patches/1.10f/D2Client.patch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -105,8 +105,7 @@ static ExtraPatchAction extraPatchActions[] = {
{ 0x6FAADD00 - D2ClientImageBase, &APPMODE_JoinGame, PatchAction::FunctionReplaceOriginalByPatch},
{ 0x6FAAA4E0 - D2ClientImageBase, &APPMODE_Startup, PatchAction::FunctionReplaceOriginalByPatch},

{ 0x6FAABBF0 - D2ClientImageBase, &CONFIG_ApplyGameInformation, PatchAction::FunctionReplaceOriginalByPatch},
{ 0x6FAABC50 - D2ClientImageBase, &CONFIG_Apply_BattleNetIP, PatchAction::FunctionReplaceOriginalByPatch},
{ 0x6FAABEE0 - D2ClientImageBase, &ApplyConfiguration, PatchAction::FunctionReplaceOriginalByPatch},

{ 0x6FAA2050 - D2ClientImageBase, &D2ClientEntrypoint, PatchAction::FunctionReplaceOriginalByPatch},

Expand Down
2 changes: 1 addition & 1 deletion D2.Detours.patches/1.10f/D2Common.patch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1143,7 +1143,7 @@ static PatchAction patchActions[GetOrdinalCount()] = {
PatchAction::FunctionReplacePatchByOriginal, // D2Common_11099 @11099
PatchAction::FunctionReplaceOriginalByPatch, /*C*/ // LOG_11100 @11100
PatchAction::FunctionReplaceOriginalByPatch, /*C*/ // LOG_11101 @11101
PatchAction::FunctionReplaceOriginalByPatch, /*C*/ // LOG_11102 @11102
PatchAction::FunctionReplaceOriginalByPatch, /*C*/ // LOG_SetEnabled @11102
PatchAction::FunctionReplaceOriginalByPatch, /*C*/ // LOG_11103 @11103
PatchAction::FunctionReplaceOriginalByPatch, /*C*/ // LOG_11104 @11104
PatchAction::FunctionReplaceOriginalByPatch, /*C*/ // LOG_11105 @11105
Expand Down
2 changes: 2 additions & 0 deletions source/D2Client/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,12 @@ target_sources(${D2ClientImplName}
)
target_sources(${D2ClientImplName}
PRIVATE
src/Draw/Draw.cpp
src/Draw/dFloor.cpp
src/Draw/dLightMap.cpp
src/Draw/dWall.cpp

include/Draw/Draw.h
include/Draw/dFloor.h
include/Draw/dLightMap.h
include/Draw/dWall.h
Expand Down
7 changes: 1 addition & 6 deletions source/D2Client/include/CGAME/Game.h
Original file line number Diff line number Diff line change
Expand Up @@ -67,12 +67,6 @@ void __fastcall D2CLIENT_DrawGameScene(DWORD a1);
//1.13c: D2Client.0x6FAF4B50
signed int __stdcall ClientGameLoop(int nIteration);

//1.10f: D2Client.0x6FAABBF0
void __fastcall CONFIG_ApplyGameInformation(D2ConfigStrc* pConfig);

//1.10f: D2Client.0x6FAABC50
void __fastcall CONFIG_Apply_BattleNetIP(D2ConfigStrc* pConfig);

//1.10f: D2Client.0x6FAABEE0
BOOL __fastcall ApplyConfiguration(D2ConfigStrc* pConfig);

Expand Down Expand Up @@ -112,3 +106,4 @@ BOOL __fastcall sub_6FAAB290();
BOOL __fastcall sub_6FAAB2E0();
//1.10f: D2Client.0x6FAAB320
BOOL __fastcall sub_6FAAB320();

36 changes: 36 additions & 0 deletions source/D2Client/include/Draw/Draw.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
#pragma once

#include <D2BasicTypes.h>
#include <D2Config.h>
#include <DisplayType.h>

//1.10f: 0x6FB6B7F6 (thunk for D2GFX_SetGamma)
void __fastcall DRAW_SetGamma(uint32_t nGamma);


//1.10f: D2Client.0x6FAABD30
void __fastcall CONFIG_Apply_GDI(D2ConfigStrc* pConfig);

//1.10f: D2Client.0x6FAABD40
void __fastcall CONFIG_Apply_Glide(D2ConfigStrc* pConfig);

//1.10f: D2Client.0x6FAABD50
void __fastcall CONFIG_Apply_OpenGL(D2ConfigStrc* pConfig);

//1.10f: D2Client.0x6FAABD60
void __fastcall CONFIG_Apply_D3D(D2ConfigStrc* pConfig);

//1.10f: D2Client.0x6FAABD70
void __fastcall CONFIG_Apply_Rave(D2ConfigStrc* pConfig);

//1.10f: D2Client.0x6FAA28C0
DisplayType __fastcall CLIENT_GetDisplayType();

//1.10f: D2Client.0x6FAA28D0
BOOL __fastcall CLIENT_IsDisplayType3D();

//1.10f: D2Client.0x6FAABD80
void __fastcall CONFIG_Apply_Gamma(D2ConfigStrc* pConfig);

//1.10f: D2Client.0x6FAABD90
void __fastcall CONFIG_Apply_VSync(D2ConfigStrc* pConfig);
74 changes: 74 additions & 0 deletions source/D2Client/src/Draw/Draw.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
#include <Draw/Draw.h>
#include <D2Client.h>
#include <D2Gfx.h>

#ifdef D2_VERSION_110F

D2VAR(D2CLIENT, pgDisplayType, DisplayType, 0x6FB74970 - D2ClientImageBase);

//1.10f: D2Client.0x6FB9A968
static BOOL gbAskedForGDI = FALSE; // Unused ?
//1.10f: D2Client.0x6FAABD30
void __fastcall CONFIG_Apply_GDI(D2ConfigStrc* pConfig)
{
if (pConfig->bWindow)
{
*D2CLIENT_pgDisplayType = DISPLAYTYPE_GDI;
gbAskedForGDI = TRUE;
}
}


//1.10f: D2Client.0x6FAABD40
void __fastcall CONFIG_Apply_Glide(D2ConfigStrc* pConfig)
{
if (pConfig->b3DFX) *D2CLIENT_pgDisplayType = DISPLAYTYPE_GLIDE;
}
//1.10f: D2Client.0x6FAABD50
void __fastcall CONFIG_Apply_OpenGL(D2ConfigStrc* pConfig)
{
if (pConfig->bOpenGL) *D2CLIENT_pgDisplayType = DISPLAYTYPE_OPENGL;
}
//1.10f: D2Client.0x6FAABD60
void __fastcall CONFIG_Apply_D3D(D2ConfigStrc* pConfig)
{
if (pConfig->bD3D) *D2CLIENT_pgDisplayType = DISPLAYTYPE_DIRECT3D;
}

//1.10f: D2Client.0x6FAABD70
void __fastcall CONFIG_Apply_Rave(D2ConfigStrc* pConfig)
{
if (pConfig->bRave) *D2CLIENT_pgDisplayType = DISPLAYTYPE_RAVE;
}

//1.10f: D2Client.0x6FAA28C0
DisplayType __fastcall CLIENT_GetDisplayType()
{
return *D2CLIENT_pgDisplayType;
}

//1.10f: D2Client.0x6FAA28D0
BOOL __fastcall CLIENT_IsDisplayType3D()
{
return *D2CLIENT_pgDisplayType >= DISPLAYTYPE_GLIDE;
}

//1.10f: D2Client.0x6FAABD80
void __fastcall CONFIG_Apply_Gamma(D2ConfigStrc* pConfig)
{
if (pConfig->dwGamma != 0) DRAW_SetGamma(pConfig->dwGamma);
}

//1.10f: D2Client.0x6FAABD90
void __fastcall CONFIG_Apply_VSync(D2ConfigStrc* pConfig)
{
if (pConfig->bVSync) D2GFX_EnableVSync();
}

void __fastcall DRAW_SetGamma(uint32_t nGamma)
{
D2GFX_SetGamma(nGamma);
}


#endif
Loading

0 comments on commit d8357d0

Please sign in to comment.