Skip to content

Commit

Permalink
Add Lego Horizon Adventures fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
TL431 authored and illusion0001 committed Nov 17, 2024
1 parent 02ad390 commit f9571d1
Show file tree
Hide file tree
Showing 4 changed files with 158 additions and 1 deletion.
17 changes: 16 additions & 1 deletion .github/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,22 @@
- `LiesOfP.NoTAA.asi`
</details>
<details><summary>


### LEGO Horizon Adventures
</summary>

- Disable TAA
- Disable Depth of Field

#### Installation

- **Note:** ***Please make sure any executable hex edits are removed/reverted first***.
- Extract the following contents of the release zip into the Win64 folder. (`LEGO Horizon Adventures\Glow\Binaries\Win64\`).
- Rename `dinput8.dll` from folder `!ASI_Loader_x64` to `winmm.dll` and copy to game folder.
- `LegoHorizonAdventures.NoTAA.asi`
</details>
<details><summary>

### Marvel's Guardians of the Galaxy
</summary>

Expand Down
1 change: 1 addition & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ add_subdirectory(source/GoW.NoTAA)
add_subdirectory(source/GoWR.NoTAA)
add_subdirectory(source/Hitman3.NoTAA)
add_subdirectory(source/LiesOfP.NoTAA)
add_subdirectory(source/LegoHorizonAdventures.NoTAA)
add_subdirectory(source/NierReplicant.Fix)
add_subdirectory(source/PlanetOfLana.NoTAA)
# TODO: Figure out linking or ditch scriptHook
Expand Down
23 changes: 23 additions & 0 deletions source/LegoHorizonAdventures.NoTAA/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
cmake_path(GET CMAKE_CURRENT_SOURCE_DIR FILENAME PROJECT_NAME)
string(REPLACE " " "_" ProjectId ${PROJECT_NAME})
project(${PROJECT_NAME})

file(GLOB SOURCES "*.cpp" "*.h" "../Shared/*.cpp" "../../include/*.h" "../../include/*.hpp")
add_library(${PROJECT_NAME} SHARED ${SOURCES})

set_target_properties(
${PROJECT_NAME}
PROPERTIES
OUTPUT_NAME ${PROJECT_NAME}
SUFFIX ".asi"
)

install(
FILES $<TARGET_PDB_FILE:${PROJECT_NAME}>
DESTINATION ${PROJECT_NAME} OPTIONAL
)

install(
TARGETS ${PROJECT_NAME}
DESTINATION ${PROJECT_NAME}
)
118 changes: 118 additions & 0 deletions source/LegoHorizonAdventures.NoTAA/dllmain.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,118 @@
#include "stdafx.h"
#include "helper.hpp"
#include "memory.hpp"

HMODULE baseModule = GetModuleHandle(NULL);

#define wstr(s) L#s
#define wxstr(s) wstr(s)
#define _PROJECT_NAME L"LegoHorizonAdventures.NoTAA"
#define _PROJECT_LOG_PATH _PROJECT_NAME L".log"

wchar_t exePath[_MAX_PATH] = { 0 };

// INI Variables
bool bDisableTAA;
bool bDisableDoF;

void ReadConfig(void)
{
inipp::Ini<wchar_t> ini;
// Get game name and exe path
LOG(_PROJECT_NAME " Built: " __TIME__ " @ " __DATE__ "\n");
LOG(L"Game Name: %s\n", Memory::GetVersionProductName().c_str());
LOG(L"Game Path: %s\n", exePath);

// Initialize config
// UE4 games use launchers so config path is relative to launcher
std::wstring config_path = _PROJECT_NAME L".ini";
std::wifstream iniFile(config_path);
if (!iniFile)
{
// no ini, lets generate one.
LOG(L"Failed to load config file.\n");
std::wstring ini_defaults = L"[Settings]\n"
wstr(bDisableTAA)" = true\n"
wstr(bDisableDoF)" = true\n";
std::wofstream iniFile(config_path);
iniFile << ini_defaults;
bDisableTAA = true;
bDisableDoF = true;
LOG(L"Created default config file.\n");
}
else
{
ini.parse(iniFile);
inipp::get_value(ini.sections[L"Settings"], wstr(bDisableTAA), bDisableTAA);
inipp::get_value(ini.sections[L"Settings"], wstr(bDisableDoF), bDisableDoF);
}

// Log config parse
LOG(L"%s: %s (%i)\n", wstr(bDisableTAA), GetBoolStr(bDisableTAA) , bDisableTAA);
LOG(L"%s: %s (%i)\n", wstr(bDisableDoF), GetBoolStr(bDisableDoF), bDisableDoF);
}

void DisableTAA(void)
{
const unsigned char patch[] = { 0x31, 0xC9, 0x90, 0x90 };
// EB02 | jmp legohorizonadventures-win64-shipping.
// 33C0 | xor eax, eax
// B905000000 | mov ecx, 5
// 390C38 | cmp dword ptr ds : [rax + rdi] , ecx
// 0F4C0C38 | cmovl ecx, dword ptr ds : [rax + rdi] --> 31C9 | xor ecx,ecx
// 90 | nop
// 90 | nop
// 33FF | xor edi, edi
WritePatchPattern(L"B9 05 00 00 00 39 0C 38 0F 4C 0C 38", patch, sizeof(patch), L"Disable TAA", 8); //sets r.AntiAliasingMethod=0
WritePatchPattern(L"B9 05 00 00 00 39 0C 38 0F 4C 0C 38", patch, sizeof(patch), L"Disable TAA", 8); //sets r.Mobile.AntiAliasing=0 (not required, but the sub body is the same)
}

void DisableDoF(void)
{
const unsigned char patch[] = { 0x31, 0xFF, 0x90 };
// 7505 | jne legohorizonadventures-win64-shipping.
// BF04000000 | mov edi, 4
// 8B3C37 | mov edi, dword ptr ds : [rdi + rsi] --> 31FF | xor edi,edi
// 90 | nop
// 488BCB | mov rcx, rbx
WritePatchPattern(L"BF 04 00 00 00 8B 3C 37 48 8B CB", patch, sizeof(patch), L"Disable DoF", 5); //sets r.DepthOfFieldQuality=0
}

DWORD __stdcall Main(void*)
{
bLoggingEnabled = false;

wchar_t LogPath[_MAX_PATH] = { 0 };
wcscpy_s(exePath, _countof(exePath), GetRunningPath(exePath));
_snwprintf_s(LogPath, _countof(LogPath), _TRUNCATE, L"%s\\%s", exePath, L"" _PROJECT_LOG_PATH);
LoggingInit(L"" _PROJECT_NAME, LogPath);
ReadConfig();

if (bDisableTAA)
DisableTAA();
if (bDisableDoF)
DisableDoF();

LOG(L"Shutting down " wstr(fp_log) " file handle.\n");
fclose(fp_log);
return true;
}

BOOL APIENTRY DllMain( HMODULE hModule,
DWORD ul_reason_for_call,
LPVOID lpReserved
)
{
switch (ul_reason_for_call)
{
case DLL_PROCESS_ATTACH:
{
CreateThread(NULL, 0, Main, 0, NULL, 0);
}
case DLL_THREAD_ATTACH:
case DLL_THREAD_DETACH:
case DLL_PROCESS_DETACH:
break;
}
return TRUE;
}

0 comments on commit f9571d1

Please sign in to comment.