Skip to content

Commit

Permalink
update mod loader, small cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
michael-fadely committed Jun 25, 2020
1 parent dcce47f commit 2e14909
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 26 deletions.
2 changes: 1 addition & 1 deletion sadx-mod-loader
43 changes: 19 additions & 24 deletions sadx-test-spawn/mod.cpp
Original file line number Diff line number Diff line change
@@ -1,11 +1,5 @@
#include "stdafx.h"

#include <SADXModLoader.h>
#include <shellapi.h> // for CommandLineToArgvW
#include <string>
#include <unordered_map>
#include <algorithm>

static const auto loc_40C318 = reinterpret_cast<const void*>(0x0040C318);

__declspec(naked) void ForceTrialMode()
Expand Down Expand Up @@ -107,16 +101,16 @@ static void Obj_Icecap_r(ObjectMaster* o)
extern "C"
{
__declspec(dllexport) ModInfo SADXModInfo = {
ModLoaderVer,
nullptr,
nullptr,
0,
nullptr,
0,
nullptr,
0,
nullptr,
0
/* Version: */ ModLoaderVer,
/* Init: */ nullptr,
/* Patches: */ nullptr,
/* PatchCount: */ 0,
/* Jumps: */ nullptr,
/* JumpCount: */ 0,
/* Calls: */ nullptr,
/* CallCount: */ 0,
/* Pointers: */ nullptr,
/* PointerCount: */ 0
};

__declspec(dllexport) void __cdecl Init(const char* path, const HelperFunctions& helperFunctions)
Expand All @@ -127,9 +121,9 @@ extern "C"
bool level_set = false;
bool act_set = false;

// Prevents CurrentCharacter from being overwritten. There could be other side effects,
// but there are none that I've noticed thus far.
WriteData<5>((void*)0x00415007, 0x90i8);
// NOP. Prevents CurrentCharacter from being overwritten. There could be other side
// effects, but there are none that we've noticed thus far.
WriteData<5>(reinterpret_cast<void*>(0x00415007), 0x90u);

for (int i = 1; i < argc; i++)
{
Expand Down Expand Up @@ -180,13 +174,14 @@ extern "C"

if (CurrentLevel == LevelIDs_IceCap)
{
WriteData<2>(reinterpret_cast<void*>(0x004149EC), 0x90i8);
WriteData<2>(reinterpret_cast<void*>(0x0041497F), 0x90i8);
WriteData<2>(reinterpret_cast<void*>(0x00414A70), 0x90i8);
// NOPs to disable several checks for LevelIDs_IceCap which prevent
// correct player positioning and orienting.
WriteData<2>(reinterpret_cast<void*>(0x004149EC), 0x90u);
WriteData<2>(reinterpret_cast<void*>(0x0041497F), 0x90u);
WriteData<2>(reinterpret_cast<void*>(0x00414A70), 0x90u);

using LevelObjectFunc = void(__cdecl*)(ObjectMaster* this_);
auto* level_objects = reinterpret_cast<LevelObjectFunc*>(0x0090BF38);
level_objects[LevelIDs_IceCap] = Obj_Icecap_r;
LevelObjects[LevelIDs_IceCap] = Obj_Icecap_r;
}

const float x = std::stof(argv[++i]);
Expand Down
2 changes: 1 addition & 1 deletion sadx-test-spawn/stdafx.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#pragma once

#include <SADXModLoader.h>
#include <shellapi.h> // for CommandLineToArgvW
#include <ShellAPI.h> // for CommandLineToArgvW
#include <string>
#include <unordered_map>
#include <algorithm>

0 comments on commit 2e14909

Please sign in to comment.