Skip to content

Commit

Permalink
Added some additonal hooks for input events.
Browse files Browse the repository at this point in the history
Cleaned up texture replacement a bit.
  • Loading branch information
michael-fadely committed Jun 23, 2015
1 parent 6d6ce7c commit b6420f4
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 9 deletions.
16 changes: 8 additions & 8 deletions src/SADXModLoader/TextureReplacement.cpp
Expand Up @@ -14,7 +14,7 @@
#include "TextureReplacement.h"

DataPointer(IDirect3DDevice8*, Direct3D_Device, 0x03D128B0);
DataPointer(char, LoadingFile, 0x3ABDF68);
DataPointer(bool, LoadingFile, 0x3ABDF68);

#pragma region Filesystem stuff

Expand Down Expand Up @@ -45,7 +45,7 @@ bool FileExists(const std::string& path)

struct CustomTextureEntry
{
unsigned int globalIndex;
uint32_t globalIndex;
std::string name;
};

Expand Down Expand Up @@ -73,7 +73,7 @@ bool BuildTextureList(const std::wstring& pvmName, NJS_TEXLIST* texList)
ifstream indexFile(pvmName + L"\\index.txt");
vector<CustomTextureEntry> customEntries;
string line;
unsigned int lineNumber = 0;
uint32_t lineNumber = 0;

// This reads the custom texture list from disk.
// The format is: gbix,filename
Expand Down Expand Up @@ -101,15 +101,15 @@ bool BuildTextureList(const std::wstring& pvmName, NJS_TEXLIST* texList)

indexFile.close();

#ifdef _DEBUG
#if 0
PrintDebug("NJS_TEXLIST Textures: 0x%08X\n", texList->textures);
PrintDebug("NJS_TEXLIST Count: %d\n", texList->nbTexture);
PrintDebug("NJS_TEXLIST New Count: %d\n\n", customEntries.size());
#endif

texList->nbTexture = customEntries.size();

for (unsigned int i = 0; i < texList->nbTexture; i++)
for (uint32_t i = 0; i < texList->nbTexture; i++)
{
#if 0
PrintDebug("NJS_TEXNAME Filename: 0x%08X\n", texList->textures[i].filename);
Expand Down Expand Up @@ -180,7 +180,7 @@ FunctionPointer(signed int, LoadPVM_D_original, (const char*, NJS_TEXLIST*), 0x0
void __cdecl LoadPVM_C(const char* pvmName, NJS_TEXLIST* texList)
{
string filename(pvmName);
LoadingFile = 1;
LoadingFile = true;

// Custom PVM Directory.
// This iterates backwards through the list of texture pack paths to find
Expand Down Expand Up @@ -235,7 +235,7 @@ signed int __cdecl LoadPVM_D(const char* pvmName, NJS_TEXLIST* texList)
{
PrintDebug("Loading PVM: [%08X] %s\n", *(int*)texList, pvmName);

for (unsigned int i = 0; i < texList->nbTexture; i++)
for (uint32_t i = 0; i < texList->nbTexture; i++)
{
NJS_TEXMEMLIST* texture = (NJS_TEXMEMLIST*)texList->textures[i].texaddr;

Expand All @@ -248,7 +248,7 @@ signed int __cdecl LoadPVM_D(const char* pvmName, NJS_TEXLIST* texList)
IDirect3DTexture8* d3dtexture = (IDirect3DTexture8*)texture->texinfo.texsurface.pSurface;
d3dtexture->Release();
D3DXCreateTextureFromFileA(Direct3D_Device, file.c_str(), &d3dtexture);
texture->texinfo.texsurface.pSurface = (unsigned int32*)d3dtexture;
texture->texinfo.texsurface.pSurface = (Uint32*)d3dtexture;
}
}
}
Expand Down
15 changes: 14 additions & 1 deletion src/SADXModLoader/dllmain.cpp
Expand Up @@ -259,6 +259,17 @@ static void __cdecl OnInput()
RaiseEvents(modInputEvents);
}

DataPointer(short, word_3B2C464, 0x3B2C464);
static void __declspec(naked) OnInput_MidJump()
{
__asm
{
inc word_3B2C464
pop esi
jmp OnInput
}
}

static bool dbgConsole, dbgScreen;
// File for logging debugging output.
static FILE *dbgFile = nullptr;
Expand Down Expand Up @@ -2334,7 +2345,9 @@ static void __cdecl InitMods(void)

// Sets up code/event handling
WriteJump((void*)0x00426063, (void*)ProcessCodes);
WriteJump((void*)0x0040FDB3, (void*)OnInput);
WriteJump((void*)0x0040FDB3, (void*)OnInput); // End of first chunk
WriteJump((void*)0x0042F1C5, (void*)OnInput_MidJump); // Cutscene stuff - Untested. Couldn't trigger ingame.
WriteJump((void*)0x0042F1E9, (void*)OnInput); // Cutscene stuff
}

static void __cdecl LoadChrmodels(void)
Expand Down

0 comments on commit b6420f4

Please sign in to comment.