Skip to content

Commit

Permalink
Add Game.exe
Browse files Browse the repository at this point in the history
  • Loading branch information
Lectem committed Oct 26, 2023
1 parent 06840dd commit f34e6db
Show file tree
Hide file tree
Showing 12 changed files with 1,099 additions and 5 deletions.
1 change: 1 addition & 0 deletions source/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,5 @@ add_subdirectory(D2Win)
add_subdirectory(D2Sound)
add_subdirectory(D2MCPClient)
add_subdirectory(D2Debugger)
add_subdirectory(Game)

2 changes: 1 addition & 1 deletion source/Fog/definitions/Fog.1.10f.def
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ EXPORTS
FOG_csprintf @10018 NONAME
FOG_InitErrorMgr @10019 NONAME
; FOG_10020 @10020 NONAME
FOG_10021 @10021 NONAME
FOG_SetLogPrefix @10021 NONAME
FOG_GetSystemInfo @10022 NONAME
FOG_DisplayAssert @10023 NONAME
FOG_DisplayHalt @10024 NONAME
Expand Down
5 changes: 4 additions & 1 deletion source/Fog/include/Fog.h
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ typedef int (*D2ExceptionCallback)();

D2FUNC_DLL(FOG, csprintf, const char*, __cdecl, (char* szDest, const char* szFormat, ...), 0xDD90) //Fog.#10018
D2FUNC_DLL(FOG, InitErrorMgr, void, __fastcall, (const char* szProgramName, D2ExceptionCallback pExceptionCallback, const char* szVersion, BOOL bLogToFile), 0xE1B0) //Fog.#10019
D2FUNC_DLL(FOG, 10021, int, __fastcall, (const char* szLogName), 0xE1A0) //Fog.#10021
D2FUNC_DLL(FOG, SetLogPrefix, int, __fastcall, (const char* szLogPrefix), 0xE1A0) //Fog.#10021
D2FUNC_DLL(FOG, GetSystemInfo, void*, __cdecl, (), 0xDF20) //Fog.#10022
D2FUNC_DLL(FOG, DisplayAssert, void, __cdecl, (const char* szMsg, const char* szFile, int nLine), 0xED30) //Fog.#10023
D2FUNC_DLL(FOG, DisplayHalt, void, __cdecl, (const char* szMsg, const char* szFile, int nLine), 0xED60) //Fog.#10024
Expand All @@ -169,6 +169,8 @@ D2FUNC_DLL(FOG, FreePool, void, __fastcall, (void* pMemPool, void* pFree, const
D2FUNC_DLL(FOG, ReallocPool, void*, __fastcall, (void* pMemPool, void* pMemory, int nSize, const char* szFile, int nLine, int n0), 0x9060) //Fog.#10047
D2FUNC_DLL(FOG, 10050_EnterCriticalSection, void, __fastcall, (CRITICAL_SECTION* pCriticalSection, int nLine), 0xDC20) //Fog.#10050
D2FUNC_DLL(FOG, 10055_GetSyncTime, int32_t, __fastcall, (), 0xA690) //Fog.#10055
// Noop, same as 10048, 10049, 10053, 10054, 10146, 10194, 10195, 10196, 10197, 10220, 10221, 10225, 10232, 10240, 10241, 10242
D2FUNC_DLL(FOG, 10082_Noop, void, __fastcall, (), 0x1DE0) //Fog.#10082
D2FUNC_DLL(FOG, 10083_Cos_LUT, float, __stdcall, (int16_t index), 0x1DF0) //Fog.#10083
D2FUNC_DLL(FOG, 10084_Sin_LUT, float, __stdcall, (int16_t index), 0x1E10) //Fog.#10084
D2FUNC_DLL(FOG, Decode14BitsFromString, unsigned, __stdcall, (uint16_t* p2Characters), 0x1B20) //Fog.#10085
Expand All @@ -193,6 +195,7 @@ D2FUNC_DLL(FOG, MPQFileClose, void, __fastcall, (HSFILE pFile), 0x11610)
D2FUNC_DLL(FOG, MPQFileRead, BOOL, __fastcall, (HSFILE pFile, void* pBuffer, size_t nSize, int* nBytesRead, uint32_t, uint32_t, uint32_t), 0x11620) //Fog.#10104
D2FUNC_DLL(FOG, MPQFileGetSize, size_t, __fastcall, (HSFILE pFileHandle, uint32_t* lpFileSizeHigh), 0x11650) //Fog.#10105
D2FUNC_DLL(FOG, GetSavePath, size_t, __fastcall, (char* pPathBuffer, size_t nBufferSize), 0x1900) //Fog.#10115
D2FUNC_DLL(FOG, GetInstallPath, BOOL, __fastcall, (char* pPathBuffer, size_t nBufferSize), 0x1900) //Fog.#10116
D2FUNC_DLL(FOG, ComputeStringCRC16, uint16_t, __stdcall, (const char* szString), 0x3DB0) //Fog.#10137
D2FUNC_DLL(FOG, CreateNewPoolSystem, void, __cdecl, (void** pMemPoolSystem, const char* szName, uint32_t nPools, uint32_t nUnused), 0xA280) //Fog.#10142
D2FUNC_DLL(FOG, DestroyMemoryPoolSystem, void, __cdecl, (void* pMemoryPoolSystem), 0xA100) //Fog.#10143
Expand Down
18 changes: 18 additions & 0 deletions source/Game/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@

add_executable(Game WIN32
src/Main.cpp
include/Main.h

resources/Game.rc
resources/Game.${D2MOO_ORDINALS_VERSION}.rc
)
target_include_directories(Game PRIVATE include)
target_link_libraries(Game
PRIVATE
Fog
Storm
D2Win
D2Gfx
D2Sound
D2MCPClient
)
210 changes: 210 additions & 0 deletions source/Game/include/Main.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,210 @@
#pragma once
#include <Windows.h>

//TODO
#define D2_VERSION_EXPANSION true
#define D2_VERSION_MAJOR 1
#define D2_VERSION_MINOR 10
#define D2_HAS_OPENGL false

#define D2_HAS_MULTILAN defined(D2_VERSION_100) // TODO: figure out when this was removed

/*
* Project definitions
*/
#define GAMEAPI __fastcall
#define KEYHOOKAPI __stdcall
#define QUERYINTAPI __fastcall

#define MAX_REG_KEY 1024
#define NUM_GAME_MOD 7

/*
* String definitions
*/
#define GAME_FILE_INI "D2.ini"
#define GAME_OK "DIABLO_II_OK"

#define SYS_NAME "Diablo II"
#define SYS_LOG_PREFIX "D2"

#define SVC_NAME "DIABLO2SRV"
#define SVC_DISPLAYNAME "Diablo II Server"

#define INIT_NAME "d2server"

#define REG_KEY_HOME "Diablo II"
#define REG_VAL_RENDER "Render"
#define REG_PATH_HOME "SOFTWARE\\Blizzard Entertainment\\Diablo II"
#define REG_PATH_BETA "SOFTWARE\\Blizzard Entertainment\\Diablo II Beta"
#define REG_PATH_VIDEO "SOFTWARE\\Blizzard Entertainment\\Diablo II\\VideoConfig"

#define HMOD_KEYHOOK "Keyhook.dll"
#define PROC_QUERYINT "QueryInterface"
#define PROC_KEYHOOK "InstallKeyboardHook"
#define PROC_UNKEYHOOK "UninstallKeyboardHook"

#define ERRMSG_TITLE "Diablo 2"
#define ERRMSG_LOADMOD "Cannot load %s: Error %d"
#define ERRMSG_INSTALLSVC "Unable to install or run service. Verify that you have administrator access and that the program is located on a local drive."

#define CMDLINE_TOKEN "-"
#define CMDLINE_SVC "SvcCmdLine"
#define CMDLINE_USE "UseCmdLine"
#define CMDLINE_BNET "-skiptobnet"
#define CMDLINE_ADD_BNET "%s -skiptobnet"
#define CMDLINE_INSTALL "-install"
#define CMDLINE_SZ "CmdLine"

/*
* Define module types
*/
enum D2_MODULES
{
MODULE_NONE,
MODULE_CLIENT,
MODULE_SERVER,
MODULE_MULTIPLAYER,
MODULE_LAUNCHER,
#if D2_HAS_MULTILAN
MODULE_MULTILAN,
#endif
MODULE_EXPAND,
D2_MODULES_COUNT
};

/*
* Define graphic render modes
*/
enum
{
DISPLAYTYPE_NONE,
DISPLAYTYPE_GDI,
DISPLAYTYPE_UNUSED,
DISPLAYTYPE_RAVE,
DISPLAYTYPE_GLIDE,
DISPLAYTYPE_OPENGL,
DISPLAYTYPE_DIRECT3D
};

/*
* Define command line types
*/
enum
{
CMD_BOOLEAN,
CMD_INTEGER,
CMD_STRING
};

/*
* Create structure for game configuration parameters
* 888 bytes in size
*/
#pragma pack(push, 1)
struct D2GameCfgStrc
{
#if D2_VERSION_EXPANSION // Not present in old versions of the game such as 1.00
BOOL bIsExpansion;
#endif
BYTE bWindow;
BYTE b3DFX;
BYTE bOpenGL;
BYTE bRave;
BYTE bD3D;
BYTE bPerspective;
BYTE bQuality;
DWORD dwGamma;
BYTE bVSync;
DWORD dwFramerate;
DWORD dwGameType;
WORD wJoinID; // Dangerous ! We may be overwriting szGameName since code expects a DWORD
char szGameName[24];
char szServerIP[24];
char szBattleNetIP[24];
char szMCPIP[24];
BYTE _0076[4];
BYTE bNoPK;
BYTE bOpenC;
BYTE bAmazon;
BYTE bPaladin;
BYTE bSorceress;
BYTE bNecromancer;
BYTE bBarbarian;
#if D2_VERSION_EXPANSION
BYTE bDruid;
BYTE bAssassin;
#endif
BYTE bInvincible;
BYTE _0082[48];
char szName[24];
BYTE szRealm[256];
BYTE _01D0[0x18];
DWORD dwCTemp;
BYTE bNoMonsters;
DWORD dwMonsterClass;
BYTE bMonsterInfo;
DWORD dwMonsterDebug;
BYTE bRare;
BYTE bUnique;
BYTE _01DA[2]; // Possibly Set/Magic
DWORD dwAct;
BYTE bNoPreload;
BYTE bDirect;
BYTE bLowEnd;
BYTE bNoCompress;
DWORD dwArena;
BYTE _01E8[6]; // Related to Arena
#ifndef VERSION_100 // TODO: figure out when this was added. Probably in 1.10
void* pSomeCallback;
BYTE bTxt;
#endif
BYTE bLog;
BYTE bMsgLog;
BYTE bSafeMode;
BYTE bNoSave;
DWORD dwSeed;
BYTE bCheats;
#ifndef VERSION_100 // TODO: figure out when this was added
BYTE bTeen;
#endif
BYTE bNoSound;
BYTE bQuests;
BYTE _01F9;

#ifndef VERSION_100 // TODO: figure out when this was added. Probably in 1.10
BYTE bBuild;
#endif
DWORD dwComInt;
BYTE _01FE[308]; // Related to ComInt
BYTE bSkipToBNet;
BYTE _0333[112];
};
#pragma pack(pop)

/*
* Create structure for command line arguments
* 60 bytes in size
*/
struct D2CmdArgStrc
{
char szSection[16];
char szKey[16];
char szCommand[16];
DWORD dwType;
DWORD dwIndex;
DWORD dwDefault;
};

/*
* Prototypes
*/
int GAMEAPI ParseCmdLine(D2GameCfgStrc* pCfg, char *argv);
void GAMEAPI stoLower(char *s);
int GAMEAPI GetCmdIndex(const char *s);
int GAMEAPI GetCmdData(char *s);
int GAMEAPI GameStart(HINSTANCE hInstance, D2GameCfgStrc* pCfg, D2_MODULES nModType);
void GAMEAPI SaveCmdLine(const char *argv[]);
int GAMEAPI GameInit(DWORD dwNumServicesArgs, LPSTR* lpServiceArgVectors);
VOID WINAPI D2ServerServiceMain(DWORD dwArgc, LPTSTR *lpszArgv);
VOID WINAPI D2ServerServiceHandlerProc(DWORD dwCtrlCode);
Binary file added source/Game/resources/Game.1.10f.rc
Binary file not shown.
Binary file added source/Game/resources/Game.rc
Binary file not shown.
Binary file added source/Game/resources/ICON/Blank.ico
Binary file not shown.
Binary file added source/Game/resources/ICON/Diablo.ico
Binary file not shown.
Binary file not shown.
Loading

0 comments on commit f34e6db

Please sign in to comment.