mirror of
https://github.com/sfall-team/sfall.git
synced 2026-07-27 16:52:34 -07:00
Moved core opcode handlers and opcode list into separate translation units.
This commit is contained in:
@@ -34,7 +34,9 @@
|
|||||||
#include "..\Logging.h"
|
#include "..\Logging.h"
|
||||||
#include "Stats.h"
|
#include "Stats.h"
|
||||||
#include "Scripting\Arrays.h"
|
#include "Scripting\Arrays.h"
|
||||||
|
#include "Scripting\Opcodes.h"
|
||||||
#include "Scripting\OpcodeContext.h"
|
#include "Scripting\OpcodeContext.h"
|
||||||
|
#include "Scripting\Handlers\Utils.h"
|
||||||
|
|
||||||
#include "ScriptExtender.h"
|
#include "ScriptExtender.h"
|
||||||
|
|
||||||
@@ -83,23 +85,19 @@ stdext::hash_map<TProgram*, TGameObj*> selfOverrideMap;
|
|||||||
typedef std::tr1::unordered_map<std::string, sExportedVar> ExportedVarsMap;
|
typedef std::tr1::unordered_map<std::string, sExportedVar> ExportedVarsMap;
|
||||||
static ExportedVarsMap globalExportedVars;
|
static ExportedVarsMap globalExportedVars;
|
||||||
DWORD isGlobalScriptLoading = 0;
|
DWORD isGlobalScriptLoading = 0;
|
||||||
|
DWORD modifiedIni;
|
||||||
|
|
||||||
stdext::hash_map<__int64, int> globalVars;
|
stdext::hash_map<__int64, int> globalVars;
|
||||||
typedef stdext::hash_map<__int64, int> :: iterator glob_itr;
|
typedef stdext::hash_map<__int64, int> :: iterator glob_itr;
|
||||||
typedef stdext::hash_map<__int64, int> :: const_iterator glob_citr;
|
typedef stdext::hash_map<__int64, int> :: const_iterator glob_citr;
|
||||||
typedef std::pair<__int64, int> glob_pair;
|
typedef std::pair<__int64, int> glob_pair;
|
||||||
|
|
||||||
static void* opcodes[0x300];
|
|
||||||
DWORD AddUnarmedStatToGetYear = 0;
|
DWORD AddUnarmedStatToGetYear = 0;
|
||||||
DWORD AvailableGlobalScriptTypes = 0;
|
DWORD AvailableGlobalScriptTypes = 0;
|
||||||
bool isGameLoading;
|
bool isGameLoading;
|
||||||
|
|
||||||
TScript OverrideScriptStruct;
|
TScript OverrideScriptStruct;
|
||||||
|
|
||||||
#include "Scripting\Opcodes.hpp"
|
|
||||||
|
|
||||||
//END OF SCRIPT FUNCTIONS
|
|
||||||
|
|
||||||
static const DWORD scr_find_sid_from_program = FuncOffs::scr_find_sid_from_program_ + 5;
|
static const DWORD scr_find_sid_from_program = FuncOffs::scr_find_sid_from_program_ + 5;
|
||||||
static const DWORD scr_ptr_back = FuncOffs::scr_ptr_ + 5;
|
static const DWORD scr_ptr_back = FuncOffs::scr_ptr_ + 5;
|
||||||
static const DWORD scr_find_obj_from_program = FuncOffs::scr_find_obj_from_program_ + 7;
|
static const DWORD scr_find_obj_from_program = FuncOffs::scr_find_obj_from_program_ + 7;
|
||||||
@@ -397,6 +395,85 @@ end:
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void _stdcall SetGlobalScriptRepeat(TProgram* script, int frames) {
|
||||||
|
for (DWORD d = 0; d < globalScripts.size(); d++) {
|
||||||
|
if (globalScripts[d].prog.ptr == script) {
|
||||||
|
if (frames == -1) {
|
||||||
|
globalScripts[d].mode = !globalScripts[d].mode;
|
||||||
|
} else {
|
||||||
|
globalScripts[d].repeat = frames;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void _stdcall SetGlobalScriptType(TProgram* script, int type) {
|
||||||
|
if (type <= 3) {
|
||||||
|
for (size_t d = 0; d < globalScripts.size(); d++) {
|
||||||
|
if (globalScripts[d].prog.ptr == script) {
|
||||||
|
globalScripts[d].mode = type;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static void SetGlobalVarInternal(__int64 var, int val) {
|
||||||
|
glob_itr itr = globalVars.find(var);
|
||||||
|
if (itr == globalVars.end()) {
|
||||||
|
globalVars.insert(glob_pair(var, val));
|
||||||
|
} else {
|
||||||
|
if (val == 0) {
|
||||||
|
globalVars.erase(itr); // applies for both float 0.0 and integer 0
|
||||||
|
} else {
|
||||||
|
itr->second = val;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void _stdcall SetGlobalVarInt(DWORD var, int val) {
|
||||||
|
SetGlobalVarInternal(var, val);
|
||||||
|
}
|
||||||
|
|
||||||
|
void _stdcall SetGlobalVar(const char* var, int val) {
|
||||||
|
if (strlen(var) != 8) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
SetGlobalVarInternal(*(__int64*)var, val);
|
||||||
|
}
|
||||||
|
|
||||||
|
static DWORD GetGlobalVarInternal(__int64 val) {
|
||||||
|
glob_citr itr = globalVars.find(val);
|
||||||
|
if (itr == globalVars.end()) {
|
||||||
|
return 0;
|
||||||
|
} else {
|
||||||
|
return itr->second;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
DWORD _stdcall GetGlobalVar(const char* var) {
|
||||||
|
if (strlen(var) != 8) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
return GetGlobalVarInternal(*(__int64*)var);
|
||||||
|
}
|
||||||
|
|
||||||
|
DWORD _stdcall GetGlobalVarInt(DWORD var) {
|
||||||
|
return GetGlobalVarInternal(var);
|
||||||
|
}
|
||||||
|
|
||||||
|
void _stdcall SetSelfObject(TProgram* script, TGameObj* obj) {
|
||||||
|
if (obj) {
|
||||||
|
selfOverrideMap[script] = obj;
|
||||||
|
} else {
|
||||||
|
stdext::hash_map<TProgram*, TGameObj*>::iterator it = selfOverrideMap.find(script);
|
||||||
|
if (it != selfOverrideMap.end()) {
|
||||||
|
selfOverrideMap.erase(it);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void ScriptExtenderSetup() {
|
void ScriptExtenderSetup() {
|
||||||
|
|
||||||
toggleHighlightsKey = GetPrivateProfileIntA("Input", "ToggleItemHighlightsKey", 0, ini);
|
toggleHighlightsKey = GetPrivateProfileIntA("Input", "ToggleItemHighlightsKey", 0, ini);
|
||||||
@@ -462,8 +539,6 @@ void ScriptExtenderSetup() {
|
|||||||
HookCall(0x46E141, FreeProgramHook);
|
HookCall(0x46E141, FreeProgramHook);
|
||||||
|
|
||||||
InitNewOpcodes();
|
InitNewOpcodes();
|
||||||
InitOpcodeMetaTable();
|
|
||||||
InitMetaruleTable();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -804,11 +879,11 @@ void SetGlobals(sGlobalVar* globals) {
|
|||||||
|
|
||||||
//fuctions to load and save appearance globals
|
//fuctions to load and save appearance globals
|
||||||
void SetAppearanceGlobals(int race, int style) {
|
void SetAppearanceGlobals(int race, int style) {
|
||||||
SetGlobalVar2("HAp_Race", race);
|
SetGlobalVar("HAp_Race", race);
|
||||||
SetGlobalVar2("HApStyle", style);
|
SetGlobalVar("HApStyle", style);
|
||||||
}
|
}
|
||||||
|
|
||||||
void GetAppearanceGlobals(int *race, int *style) {
|
void GetAppearanceGlobals(int *race, int *style) {
|
||||||
*race=GetGlobalVar2("HAp_Race");
|
*race=GetGlobalVar("HAp_Race");
|
||||||
*style=GetGlobalVar2("HApStyle");
|
*style=GetGlobalVar("HApStyle");
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -35,6 +35,8 @@ typedef struct {
|
|||||||
char initialized;
|
char initialized;
|
||||||
} sScriptProgram;
|
} sScriptProgram;
|
||||||
|
|
||||||
|
void _stdcall SetGlobalScriptRepeat(TProgram* script, int frames);
|
||||||
|
void _stdcall SetGlobalScriptType(TProgram* script, int type);
|
||||||
void ScriptExtenderSetup();
|
void ScriptExtenderSetup();
|
||||||
bool _stdcall IsGameScript(const char* filename);
|
bool _stdcall IsGameScript(const char* filename);
|
||||||
void LoadGlobalScripts();
|
void LoadGlobalScripts();
|
||||||
@@ -54,6 +56,13 @@ int GetNumGlobals();
|
|||||||
void GetGlobals(sGlobalVar* globals);
|
void GetGlobals(sGlobalVar* globals);
|
||||||
void SetGlobals(sGlobalVar* globals);
|
void SetGlobals(sGlobalVar* globals);
|
||||||
|
|
||||||
|
void _stdcall SetGlobalVar(const char* var, int val);
|
||||||
|
void _stdcall SetGlobalVarInt(DWORD var, int val);
|
||||||
|
DWORD _stdcall GetGlobalVar(const char* var);
|
||||||
|
DWORD _stdcall GetGlobalVarInt(DWORD var);
|
||||||
|
|
||||||
|
void _stdcall SetSelfObject(TProgram* script, TGameObj* obj);
|
||||||
|
|
||||||
extern DWORD AddUnarmedStatToGetYear;
|
extern DWORD AddUnarmedStatToGetYear;
|
||||||
extern DWORD AvailableGlobalScriptTypes;
|
extern DWORD AvailableGlobalScriptTypes;
|
||||||
|
|
||||||
@@ -78,6 +87,7 @@ sScriptProgram* GetGlobalScriptProgram(TProgram* scriptPtr);
|
|||||||
// variables
|
// variables
|
||||||
static char reg_anim_combat_check = 1;
|
static char reg_anim_combat_check = 1;
|
||||||
extern DWORD isGlobalScriptLoading;
|
extern DWORD isGlobalScriptLoading;
|
||||||
|
extern DWORD modifiedIni;
|
||||||
|
|
||||||
// types for script variables
|
// types for script variables
|
||||||
#define VAR_TYPE_INT (0xC001)
|
#define VAR_TYPE_INT (0xC001)
|
||||||
|
|||||||
@@ -0,0 +1,403 @@
|
|||||||
|
/*
|
||||||
|
* sfall
|
||||||
|
* Copyright (C) 2008-2016 The sfall team
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "..\..\..\FalloutEngine\Fallout2.h"
|
||||||
|
#include "..\..\..\SafeWrite.h"
|
||||||
|
#include "..\..\..\Version.h"
|
||||||
|
#include "..\..\KillCounter.h"
|
||||||
|
#include "..\..\HookScripts.h"
|
||||||
|
#include "..\..\ScriptExtender.h"
|
||||||
|
#include "..\Arrays.h"
|
||||||
|
#include "AsmMacros.h"
|
||||||
|
|
||||||
|
#include "Core.h"
|
||||||
|
|
||||||
|
void __declspec(naked) op_set_global_script_repeat() {
|
||||||
|
__asm {
|
||||||
|
push ebx;
|
||||||
|
push ecx;
|
||||||
|
push edx;
|
||||||
|
mov ecx, eax;
|
||||||
|
call FuncOffs::interpretPopShort_;
|
||||||
|
mov edx, eax;
|
||||||
|
mov eax, ecx;
|
||||||
|
call FuncOffs::interpretPopLong_;
|
||||||
|
cmp dx, 0xC001;
|
||||||
|
jnz end;
|
||||||
|
push eax;
|
||||||
|
push ecx;
|
||||||
|
call SetGlobalScriptRepeat;
|
||||||
|
end:
|
||||||
|
pop edx;
|
||||||
|
pop ecx;
|
||||||
|
pop ebx;
|
||||||
|
retn;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void __declspec(naked) op_set_global_script_type() {
|
||||||
|
__asm {
|
||||||
|
push ebx;
|
||||||
|
push ecx;
|
||||||
|
push edx;
|
||||||
|
mov ecx, eax;
|
||||||
|
call FuncOffs::interpretPopShort_;
|
||||||
|
mov edx, eax;
|
||||||
|
mov eax, ecx;
|
||||||
|
call FuncOffs::interpretPopLong_;
|
||||||
|
cmp dx, 0xC001;
|
||||||
|
jnz end;
|
||||||
|
push eax;
|
||||||
|
push ecx;
|
||||||
|
call SetGlobalScriptType;
|
||||||
|
end:
|
||||||
|
pop edx;
|
||||||
|
pop ecx;
|
||||||
|
pop ebx;
|
||||||
|
retn;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void __declspec(naked) op_available_global_script_types() {
|
||||||
|
__asm {
|
||||||
|
push ebx;
|
||||||
|
push ecx;
|
||||||
|
push edx;
|
||||||
|
mov edx, AvailableGlobalScriptTypes;
|
||||||
|
mov ecx, eax;
|
||||||
|
call FuncOffs::interpretPushLong_;
|
||||||
|
mov edx, 0xc001;
|
||||||
|
mov eax, ecx;
|
||||||
|
call FuncOffs::interpretPushShort_;
|
||||||
|
pop edx;
|
||||||
|
pop ecx;
|
||||||
|
pop ebx;
|
||||||
|
retn;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void __declspec(naked) op_set_sfall_global() {
|
||||||
|
__asm {
|
||||||
|
push ebx;
|
||||||
|
push ecx;
|
||||||
|
push edx;
|
||||||
|
push edi;
|
||||||
|
push esi;
|
||||||
|
mov edi, eax;
|
||||||
|
call FuncOffs::interpretPopShort_;
|
||||||
|
mov eax, edi;
|
||||||
|
call FuncOffs::interpretPopLong_;
|
||||||
|
mov esi, eax;
|
||||||
|
mov eax, edi;
|
||||||
|
call FuncOffs::interpretPopShort_;
|
||||||
|
mov edx, eax;
|
||||||
|
mov eax, edi;
|
||||||
|
call FuncOffs::interpretPopLong_;
|
||||||
|
cmp dx, 0x9001;
|
||||||
|
jz next;
|
||||||
|
cmp dx, 0x9801;
|
||||||
|
jz next;
|
||||||
|
cmp dx, 0xc001;
|
||||||
|
jnz end;
|
||||||
|
push esi;
|
||||||
|
push eax;
|
||||||
|
call SetGlobalVarInt;
|
||||||
|
jmp end;
|
||||||
|
next:
|
||||||
|
mov ebx, eax;
|
||||||
|
mov eax, edi;
|
||||||
|
call FuncOffs::interpretGetString_;
|
||||||
|
push esi;
|
||||||
|
push eax;
|
||||||
|
call SetGlobalVar;
|
||||||
|
end:
|
||||||
|
pop esi;
|
||||||
|
pop edi;
|
||||||
|
pop edx;
|
||||||
|
pop ecx;
|
||||||
|
pop ebx;
|
||||||
|
retn;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void __declspec(naked) op_get_sfall_global_int() {
|
||||||
|
__asm {
|
||||||
|
push ebx;
|
||||||
|
push ecx;
|
||||||
|
push edx;
|
||||||
|
push edi;
|
||||||
|
push esi;
|
||||||
|
xor edx, edx;
|
||||||
|
mov edi, eax;
|
||||||
|
call FuncOffs::interpretPopShort_;
|
||||||
|
mov esi, eax;
|
||||||
|
mov eax, edi;
|
||||||
|
call FuncOffs::interpretPopLong_;
|
||||||
|
cmp si, 0x9001;
|
||||||
|
jz next;
|
||||||
|
cmp si, 0x9801;
|
||||||
|
jz next;
|
||||||
|
cmp si, 0xc001;
|
||||||
|
jnz end;
|
||||||
|
push eax;
|
||||||
|
call GetGlobalVarInt;
|
||||||
|
mov edx, eax;
|
||||||
|
jmp end;
|
||||||
|
next:
|
||||||
|
mov edx, esi;
|
||||||
|
mov ebx, eax;
|
||||||
|
mov eax, edi;
|
||||||
|
call FuncOffs::interpretGetString_;
|
||||||
|
push eax;
|
||||||
|
call GetGlobalVar;
|
||||||
|
mov edx, eax;
|
||||||
|
end:
|
||||||
|
mov eax, edi;
|
||||||
|
call FuncOffs::interpretPushLong_;
|
||||||
|
mov edx, 0xc001;
|
||||||
|
mov eax, edi;
|
||||||
|
call FuncOffs::interpretPushShort_;
|
||||||
|
pop esi;
|
||||||
|
pop edi;
|
||||||
|
pop edx;
|
||||||
|
pop ecx;
|
||||||
|
pop ebx;
|
||||||
|
retn;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void __declspec(naked) op_get_sfall_global_float() {
|
||||||
|
__asm {
|
||||||
|
push ebx;
|
||||||
|
push ecx;
|
||||||
|
push edx;
|
||||||
|
push edi;
|
||||||
|
push esi;
|
||||||
|
xor edx, edx;
|
||||||
|
mov edi, eax;
|
||||||
|
call FuncOffs::interpretPopShort_;
|
||||||
|
mov esi, eax;
|
||||||
|
mov eax, edi;
|
||||||
|
call FuncOffs::interpretPopLong_;
|
||||||
|
cmp si, 0x9001;
|
||||||
|
jz next;
|
||||||
|
cmp si, 0x9801;
|
||||||
|
jz next;
|
||||||
|
cmp si, 0xc001;
|
||||||
|
jnz end;
|
||||||
|
push eax;
|
||||||
|
call GetGlobalVarInt;
|
||||||
|
mov edx, eax;
|
||||||
|
jmp end;
|
||||||
|
next:
|
||||||
|
mov edx, esi;
|
||||||
|
mov ebx, eax;
|
||||||
|
mov eax, edi;
|
||||||
|
call FuncOffs::interpretGetString_;
|
||||||
|
push eax;
|
||||||
|
call GetGlobalVar;
|
||||||
|
mov edx, eax;
|
||||||
|
end:
|
||||||
|
mov eax, edi;
|
||||||
|
call FuncOffs::interpretPushLong_;
|
||||||
|
mov edx, 0xa001;
|
||||||
|
mov eax, edi;
|
||||||
|
call FuncOffs::interpretPushShort_;
|
||||||
|
pop esi;
|
||||||
|
pop edi;
|
||||||
|
pop edx;
|
||||||
|
pop ecx;
|
||||||
|
pop ebx;
|
||||||
|
retn;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void __declspec(naked) op_get_sfall_arg() {
|
||||||
|
__asm {
|
||||||
|
pushad;
|
||||||
|
push eax;
|
||||||
|
call GetHSArg;
|
||||||
|
pop ecx;
|
||||||
|
mov edx, eax;
|
||||||
|
mov eax, ecx;
|
||||||
|
call FuncOffs::interpretPushLong_;
|
||||||
|
mov eax, ecx;
|
||||||
|
mov edx, 0xc001;
|
||||||
|
call FuncOffs::interpretPushShort_;
|
||||||
|
popad;
|
||||||
|
retn;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static DWORD _stdcall GetSfallArgs() {
|
||||||
|
DWORD argCount = GetHSArgCount();
|
||||||
|
DWORD id = TempArray(argCount, 4);
|
||||||
|
DWORD* args = GetHSArgs();
|
||||||
|
for (DWORD i = 0; i < argCount; i++) {
|
||||||
|
arrays[id].val[i].set(*(long*)&args[i]);
|
||||||
|
}
|
||||||
|
return id;
|
||||||
|
}
|
||||||
|
|
||||||
|
void __declspec(naked) op_get_sfall_args() {
|
||||||
|
__asm {
|
||||||
|
pushad;
|
||||||
|
push eax;
|
||||||
|
call GetSfallArgs;
|
||||||
|
pop ecx;
|
||||||
|
mov edx, eax;
|
||||||
|
mov eax, ecx;
|
||||||
|
call FuncOffs::interpretPushLong_;
|
||||||
|
mov eax, ecx;
|
||||||
|
mov edx, 0xc001;
|
||||||
|
call FuncOffs::interpretPushShort_;
|
||||||
|
popad;
|
||||||
|
retn;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void __declspec(naked) op_set_sfall_arg() {
|
||||||
|
__asm {
|
||||||
|
pushad;
|
||||||
|
mov ecx, eax;
|
||||||
|
call FuncOffs::interpretPopShort_;
|
||||||
|
mov edi, eax;
|
||||||
|
mov eax, ecx;
|
||||||
|
call FuncOffs::interpretPopLong_;
|
||||||
|
mov edx, eax;
|
||||||
|
mov eax, ecx;
|
||||||
|
call FuncOffs::interpretPopShort_;
|
||||||
|
mov esi, eax;
|
||||||
|
mov eax, ecx;
|
||||||
|
call FuncOffs::interpretPopLong_;
|
||||||
|
cmp di, 0xc001;
|
||||||
|
jnz end;
|
||||||
|
cmp si, 0xc001;
|
||||||
|
jnz end;
|
||||||
|
push edx;
|
||||||
|
push eax;
|
||||||
|
call SetHSArg;
|
||||||
|
end:
|
||||||
|
popad;
|
||||||
|
retn;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void __declspec(naked) op_set_sfall_return() {
|
||||||
|
__asm {
|
||||||
|
push ebx;
|
||||||
|
push ecx;
|
||||||
|
push edx;
|
||||||
|
mov ecx, eax;
|
||||||
|
call FuncOffs::interpretPopShort_;
|
||||||
|
mov edx, eax;
|
||||||
|
mov eax, ecx;
|
||||||
|
call FuncOffs::interpretPopLong_;
|
||||||
|
cmp dx, 0xc001;
|
||||||
|
jnz end;
|
||||||
|
push eax;
|
||||||
|
call SetHSReturn;
|
||||||
|
end:
|
||||||
|
pop edx;
|
||||||
|
pop ecx;
|
||||||
|
pop ebx;
|
||||||
|
retn;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void __declspec(naked) op_init_hook() {
|
||||||
|
__asm {
|
||||||
|
push ecx;
|
||||||
|
push edx;
|
||||||
|
mov ecx, eax;
|
||||||
|
mov edx, InitingHookScripts;
|
||||||
|
call FuncOffs::interpretPushLong_;
|
||||||
|
mov eax, ecx;
|
||||||
|
mov edx, 0xc001;
|
||||||
|
call FuncOffs::interpretPushShort_;
|
||||||
|
pop edx;
|
||||||
|
pop ecx;
|
||||||
|
retn;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void __declspec(naked) op_set_self() {
|
||||||
|
__asm {
|
||||||
|
pushad;
|
||||||
|
mov ebp, eax;
|
||||||
|
call FuncOffs::interpretPopShort_;
|
||||||
|
mov edi, eax;
|
||||||
|
mov eax, ebp;
|
||||||
|
call FuncOffs::interpretPopLong_;
|
||||||
|
cmp di, 0xc001;
|
||||||
|
jnz end;
|
||||||
|
push eax;
|
||||||
|
push ebp;
|
||||||
|
call SetSelfObject;
|
||||||
|
end:
|
||||||
|
popad;
|
||||||
|
retn;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// used for both register_hook and register_hook_proc
|
||||||
|
void sf_register_hook(OpcodeContext& ctx) {
|
||||||
|
int id = ctx.arg(0).asInt();
|
||||||
|
int proc = (ctx.numArgs() > 1)
|
||||||
|
? ctx.arg(1).asInt()
|
||||||
|
: -1;
|
||||||
|
|
||||||
|
RegisterHook(ctx.program(), id, proc);
|
||||||
|
}
|
||||||
|
|
||||||
|
void __declspec(naked) op_register_hook() {
|
||||||
|
_WRAP_OPCODE(sf_register_hook, 1, 0)
|
||||||
|
}
|
||||||
|
|
||||||
|
void __declspec(naked) op_register_hook_proc() {
|
||||||
|
_WRAP_OPCODE(sf_register_hook, 2, 0)
|
||||||
|
}
|
||||||
|
|
||||||
|
void __declspec(naked) op_sfall_ver_major() {
|
||||||
|
_OP_BEGIN(ebp)
|
||||||
|
__asm {
|
||||||
|
mov eax, VERSION_MAJOR;
|
||||||
|
}
|
||||||
|
_RET_VAL_INT(ebp)
|
||||||
|
_OP_END
|
||||||
|
}
|
||||||
|
|
||||||
|
void __declspec(naked) op_sfall_ver_minor() {
|
||||||
|
_OP_BEGIN(ebp)
|
||||||
|
__asm {
|
||||||
|
mov eax, VERSION_MINOR;
|
||||||
|
}
|
||||||
|
_RET_VAL_INT(ebp)
|
||||||
|
_OP_END
|
||||||
|
}
|
||||||
|
|
||||||
|
void __declspec(naked) op_sfall_ver_build() {
|
||||||
|
_OP_BEGIN(ebp)
|
||||||
|
__asm {
|
||||||
|
mov eax, VERSION_BUILD;
|
||||||
|
}
|
||||||
|
_RET_VAL_INT(ebp)
|
||||||
|
_OP_END
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -0,0 +1,60 @@
|
|||||||
|
/*
|
||||||
|
* sfall
|
||||||
|
* Copyright (C) 2008-2016 The sfall team
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
/*
|
||||||
|
Opcodes for core sfall features.
|
||||||
|
*/
|
||||||
|
|
||||||
|
void __declspec() op_set_global_script_repeat();
|
||||||
|
|
||||||
|
void __declspec() op_set_global_script_type();
|
||||||
|
|
||||||
|
void __declspec() op_available_global_script_types();
|
||||||
|
|
||||||
|
void __declspec() op_set_sfall_global();
|
||||||
|
|
||||||
|
void __declspec() op_get_sfall_global_int();
|
||||||
|
|
||||||
|
void __declspec() op_get_sfall_global_float();
|
||||||
|
|
||||||
|
void __declspec() op_get_sfall_arg();
|
||||||
|
|
||||||
|
void __declspec() op_get_sfall_args();
|
||||||
|
|
||||||
|
void __declspec() op_set_sfall_arg();
|
||||||
|
|
||||||
|
void __declspec() op_set_sfall_return();
|
||||||
|
|
||||||
|
void __declspec() op_init_hook();
|
||||||
|
|
||||||
|
void __declspec() op_set_self();
|
||||||
|
|
||||||
|
// used for both register_hook and register_hook_proc
|
||||||
|
void sf_register_hook(OpcodeContext&);
|
||||||
|
|
||||||
|
void __declspec() op_register_hook();
|
||||||
|
|
||||||
|
void __declspec() op_register_hook_proc();
|
||||||
|
|
||||||
|
void __declspec() op_sfall_ver_major();
|
||||||
|
|
||||||
|
void __declspec() op_sfall_ver_minor();
|
||||||
|
|
||||||
|
void __declspec() op_sfall_ver_build();
|
||||||
@@ -1481,7 +1481,6 @@ end:
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
DWORD modifiedIni;
|
|
||||||
void __declspec(naked) op_modified_ini() {
|
void __declspec(naked) op_modified_ini() {
|
||||||
__asm {
|
__asm {
|
||||||
pushad;
|
pushad;
|
||||||
|
|||||||
@@ -18,8 +18,6 @@
|
|||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
extern DWORD modifiedIni;
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Misc operators
|
* Misc operators
|
||||||
*/
|
*/
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,24 @@
|
|||||||
|
/*
|
||||||
|
* sfall
|
||||||
|
* Copyright (C) 2008-2016 The sfall team
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
//
|
||||||
|
// Everything related to new sfall opcodes.
|
||||||
|
//
|
||||||
|
|
||||||
|
void InitNewOpcodes();
|
||||||
|
|
||||||
+4
-1
@@ -223,6 +223,7 @@
|
|||||||
<ClInclude Include="Modules\Scripting\Arrays.h" />
|
<ClInclude Include="Modules\Scripting\Arrays.h" />
|
||||||
<ClInclude Include="Modules\Scripting\Handlers\AsmMacros.h" />
|
<ClInclude Include="Modules\Scripting\Handlers\AsmMacros.h" />
|
||||||
<ClInclude Include="CommonTypes.h" />
|
<ClInclude Include="CommonTypes.h" />
|
||||||
|
<ClInclude Include="Modules\Scripting\Handlers\Core.h" />
|
||||||
<ClInclude Include="Modules\Scripting\Handlers\FileSystem.h" />
|
<ClInclude Include="Modules\Scripting\Handlers\FileSystem.h" />
|
||||||
<ClInclude Include="Modules\Scripting\Handlers\Graphics.h" />
|
<ClInclude Include="Modules\Scripting\Handlers\Graphics.h" />
|
||||||
<ClInclude Include="Modules\Scripting\Handlers\Interface.h" />
|
<ClInclude Include="Modules\Scripting\Handlers\Interface.h" />
|
||||||
@@ -231,7 +232,7 @@
|
|||||||
<ClInclude Include="Modules\Scripting\Handlers\Misc.h" />
|
<ClInclude Include="Modules\Scripting\Handlers\Misc.h" />
|
||||||
<ClInclude Include="Modules\Scripting\Handlers\Objects.h" />
|
<ClInclude Include="Modules\Scripting\Handlers\Objects.h" />
|
||||||
<ClInclude Include="Modules\Scripting\OpcodeContext.h" />
|
<ClInclude Include="Modules\Scripting\OpcodeContext.h" />
|
||||||
<ClInclude Include="Modules\Scripting\Opcodes.hpp" />
|
<ClInclude Include="Modules\Scripting\Opcodes.h" />
|
||||||
<ClInclude Include="Modules\Scripting\Handlers\Perks.h" />
|
<ClInclude Include="Modules\Scripting\Handlers\Perks.h" />
|
||||||
<ClInclude Include="Modules\Scripting\Handlers\Arrays.h" />
|
<ClInclude Include="Modules\Scripting\Handlers\Arrays.h" />
|
||||||
<ClInclude Include="Modules\Scripting\Handlers\Utils.h" />
|
<ClInclude Include="Modules\Scripting\Handlers\Utils.h" />
|
||||||
@@ -319,6 +320,7 @@
|
|||||||
<ClCompile Include="Modules\Scripting\Arrays.cpp" />
|
<ClCompile Include="Modules\Scripting\Arrays.cpp" />
|
||||||
<ClCompile Include="Modules\Scripting\Handlers\Anims.cpp" />
|
<ClCompile Include="Modules\Scripting\Handlers\Anims.cpp" />
|
||||||
<ClCompile Include="Modules\Scripting\Handlers\Arrays.cpp" />
|
<ClCompile Include="Modules\Scripting\Handlers\Arrays.cpp" />
|
||||||
|
<ClCompile Include="Modules\Scripting\Handlers\Core.cpp" />
|
||||||
<ClCompile Include="Modules\Scripting\Handlers\FileSystem.cpp" />
|
<ClCompile Include="Modules\Scripting\Handlers\FileSystem.cpp" />
|
||||||
<ClCompile Include="Modules\Scripting\Handlers\Graphics.cpp" />
|
<ClCompile Include="Modules\Scripting\Handlers\Graphics.cpp" />
|
||||||
<ClCompile Include="Modules\Scripting\Handlers\Interface.cpp" />
|
<ClCompile Include="Modules\Scripting\Handlers\Interface.cpp" />
|
||||||
@@ -331,6 +333,7 @@
|
|||||||
<ClCompile Include="Modules\Scripting\Handlers\Utils.cpp" />
|
<ClCompile Include="Modules\Scripting\Handlers\Utils.cpp" />
|
||||||
<ClCompile Include="Modules\Scripting\Handlers\Worldmap.cpp" />
|
<ClCompile Include="Modules\Scripting\Handlers\Worldmap.cpp" />
|
||||||
<ClCompile Include="Modules\Scripting\OpcodeContext.cpp" />
|
<ClCompile Include="Modules\Scripting\OpcodeContext.cpp" />
|
||||||
|
<ClCompile Include="Modules\Scripting\Opcodes.cpp" />
|
||||||
<ClCompile Include="Modules\Scripting\ScriptValue.cpp" />
|
<ClCompile Include="Modules\Scripting\ScriptValue.cpp" />
|
||||||
<ClCompile Include="SafeWrite.cpp" />
|
<ClCompile Include="SafeWrite.cpp" />
|
||||||
<ClCompile Include="Modules\Skills.cpp" />
|
<ClCompile Include="Modules\Skills.cpp" />
|
||||||
|
|||||||
@@ -168,9 +168,6 @@
|
|||||||
<ClInclude Include="Modules\Scripting\ScriptValue.h">
|
<ClInclude Include="Modules\Scripting\ScriptValue.h">
|
||||||
<Filter>Modules\Scripting</Filter>
|
<Filter>Modules\Scripting</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
<ClInclude Include="Modules\Scripting\Opcodes.hpp">
|
|
||||||
<Filter>Modules\Scripting</Filter>
|
|
||||||
</ClInclude>
|
|
||||||
<ClInclude Include="Modules\Misc.h">
|
<ClInclude Include="Modules\Misc.h">
|
||||||
<Filter>Modules</Filter>
|
<Filter>Modules</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
@@ -220,6 +217,12 @@
|
|||||||
<ClInclude Include="Modules\Scripting\OpcodeContext.h">
|
<ClInclude Include="Modules\Scripting\OpcodeContext.h">
|
||||||
<Filter>Modules\Scripting</Filter>
|
<Filter>Modules\Scripting</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
|
<ClInclude Include="Modules\Scripting\Handlers\Core.h">
|
||||||
|
<Filter>Modules\Scripting\Handlers</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="Modules\Scripting\Opcodes.h">
|
||||||
|
<Filter>Modules\Scripting</Filter>
|
||||||
|
</ClInclude>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ClCompile Include="main.cpp" />
|
<ClCompile Include="main.cpp" />
|
||||||
@@ -404,6 +407,8 @@
|
|||||||
<ClCompile Include="Modules\Scripting\OpcodeContext.cpp">
|
<ClCompile Include="Modules\Scripting\OpcodeContext.cpp">
|
||||||
<Filter>Modules\Scripting</Filter>
|
<Filter>Modules\Scripting</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
|
<ClCompile Include="Modules\Scripting\Handlers\Core.cpp" />
|
||||||
|
<ClCompile Include="Modules\Scripting\Opcodes.cpp" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ResourceCompile Include="version.rc" />
|
<ResourceCompile Include="version.rc" />
|
||||||
|
|||||||
Reference in New Issue
Block a user