diff --git a/saco/game/address.h b/saco/game/address.h
index ddcec5e..002eaf4 100644
--- a/saco/game/address.h
+++ b/saco/game/address.h
@@ -2,6 +2,7 @@
#pragma once
#define ADDR_HWND 0xC97C1C
+#define ADDR_ID3D9DEVICE 0xC97C28
#define ADDR_KEYSTATES 0xB73458
diff --git a/saco/game/game.h b/saco/game/game.h
index f64635b..44d1b89 100644
--- a/saco/game/game.h
+++ b/saco/game/game.h
@@ -64,6 +64,8 @@ public:
void DrawGangZone(float* fPos, DWORD dwColor);
DWORD GetD3DDevice();
+ DWORD GetD3D() { return *(DWORD *)ADDR_ID3D9DEVICE; };
+
HWND GetMainWindowHwnd() { return *(HWND *)ADDR_HWND; };
void StartGame();
diff --git a/saco/main.cpp b/saco/main.cpp
index d70609f..a4ae1e9 100644
--- a/saco/main.cpp
+++ b/saco/main.cpp
@@ -7,6 +7,9 @@ int iGtaVersion=0;
GAME_SETTINGS tSettings;
CHAR szArtworkProxy[MAX_PATH+1];
+CHAR szConfigFile[MAX_PATH+1];
+CHAR byte_1026E710[256]; // unused
+CHAR szChatLogFile[MAX_PATH+1];
CHAR szSAMPDir[MAX_PATH+1];
CHAR szCacheDir[MAX_PATH+1];
@@ -23,6 +26,11 @@ CFontRender *pDefaultFont=0;
//DWORD dword_1026EBA4=0;
//DWORD dword_1026EBA8=0;
+BOOL bGameInited=FALSE;
+
+IDirect3D9 *pD3D;
+IDirect3DDevice9 *pD3DDevice = NULL;
+
HANDLE hInstance=0;
bool bShowDebugLabels = false;
@@ -34,6 +42,7 @@ CFileSystem *pFileSystem=NULL;
// forwards
+BOOL SubclassGameWindow();
void TheGraphicsLoop();
LONG WINAPI exc_handler(_EXCEPTION_POINTERS* exc_inf);
void sub_1009DD50();
@@ -213,8 +222,55 @@ void CallRwRenderStateGet(int state, int *option)
//----------------------------------------------------
+void DoInitStuff()
+{
+ // GAME INIT
+ if(!bGameInited)
+ {
+ SetupDirectories();
+
+ sprintf(szConfigFile, "%s\\sa-mp.cfg", szSAMPDir);
+ sprintf(szChatLogFile, "%s\\chatlog.txt", szSAMPDir);
+
+ pConfig = new CConfig(szConfigFile);
+
+ timeBeginPeriod(1); // increases the accuracy of Sleep()
+ sub_1009DD50();
+ SubclassGameWindow();
+
+ // Grab the real IDirect3D9 * from the game.
+ pD3D = (IDirect3D9 *)pGame->GetD3D();
+
+ // Grab the real IDirect3DDevice9 * from the game.
+ pD3DDevice = (IDirect3DDevice9 *)pGame->GetD3DDevice();
+
+ // TODO: DoInitStuff
+
+ bGameInited = TRUE;
+
+ return;
+ }
+
+
+
+}
+
+//----------------------------------------------------
+
+void DoProcessStuff()
+{
+ DoInitStuff();
+}
+
+//----------------------------------------------------
+
void TheGraphicsLoop()
{
+ _asm pushad // because we're called from a hook
+
+ DoProcessStuff();
+
+ _asm popad
}
//----------------------------------------------------
diff --git a/saco/main.h b/saco/main.h
index fa776ee..a535c1f 100644
--- a/saco/main.h
+++ b/saco/main.h
@@ -22,6 +22,8 @@ typedef struct _GAME_SETTINGS {
CHAR szDebugScript[MAX_SETTINGS_STRING+1];
} GAME_SETTINGS;
+#include "d3d9/include/d3d9.h"
+#include "d3d9/include/d3dx9core.h"
#include "game/game.h"
#include "../raknet/RakClientInterface.h"
diff --git a/saco/saco.vcproj b/saco/saco.vcproj
index 153b943..bfa9e08 100644
--- a/saco/saco.vcproj
+++ b/saco/saco.vcproj
@@ -19,6 +19,7 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+