Split opcode handler categories into separate translation units.

This commit is contained in:
phobos2077
2016-11-14 02:07:08 +07:00
parent adcf3be520
commit b026f8eadd
38 changed files with 1944 additions and 1054 deletions
+6
View File
@@ -0,0 +1,6 @@
#pragma once
#ifndef DWORD
typedef unsigned long DWORD;
typedef unsigned char BYTE;
#endif // !DWORD
-2
View File
@@ -21,8 +21,6 @@
// Various utility functions, based on FO engine functions // Various utility functions, based on FO engine functions
// //
#define DWORD unsigned long
// returns weapon animation code // returns weapon animation code
char AnimCodeByWeapon(TGameObj* weapon); char AnimCodeByWeapon(TGameObj* weapon);
+3 -3
View File
@@ -18,10 +18,10 @@
#pragma once #pragma once
#include "Structs.h" #include <cassert>
#define DWORD unsigned long #include "..\CommonTypes.h"
#define BYTE unsigned char #include "Structs.h"
// Global variable constants // Global variable constants
+1 -5
View File
@@ -18,13 +18,9 @@
#pragma once #pragma once
#include "..\CommonTypes.h"
#include "Structs.h" #include "Structs.h"
// TODO: place this somewhere centralized...
#ifndef DWORD
#define DWORD unsigned long
#endif
// //
// WRAPPERS for FO engine functions. // WRAPPERS for FO engine functions.
// Use those as you would if there were source code for the engine... // Use those as you would if there were source code for the engine...
+3 -1
View File
@@ -58,4 +58,6 @@ void ApplyNumbersInDialoguePatch();
void ApplyInstantWeaponEquipPatch(); void ApplyInstantWeaponEquipPatch();
void MiscReset(); void MiscReset();
void _stdcall SetMapMulti(float d);
+18 -18
View File
@@ -32,6 +32,7 @@
#include "HookScripts.h" #include "HookScripts.h"
#include "LoadGameHook.h" #include "LoadGameHook.h"
#include "..\Logging.h" #include "..\Logging.h"
#include "Stats.h"
#include "Scripting\Arrays.h" #include "Scripting\Arrays.h"
#include "Scripting\OpcodeHandler.h" #include "Scripting\OpcodeHandler.h"
@@ -96,24 +97,8 @@ bool isGameLoading;
TScript OverrideScriptStruct; TScript OverrideScriptStruct;
// handler for all new sfall opcodes // handler for all new sfall opcodes
static OpcodeHandler opHandler; OpcodeHandler opHandler;
#include "Scripting\AsmMacros.h"
#include "Scripting\AnimOps.hpp"
#include "Scripting\FileSystemOps.hpp"
#include "Scripting\GraphicsOp.hpp"
#include "Scripting\InterfaceOp.hpp"
#include "Scripting\MemoryOp.hpp"
#include "Scripting\MiscOps.hpp"
#include "Scripting\ObjectsOps.hpp"
#include "Scripting\PerksOp.hpp"
#include "Scripting\StatsOp.hpp"
#include "Scripting\ScriptArrays.hpp"
#include "Scripting\ScriptUtils.hpp"
#include "Scripting\WorldmapOps.hpp"
#include "Scripting\MetaruleOp.hpp"
#include "Scripting\Opcodes.hpp" #include "Scripting\Opcodes.hpp"
//END OF SCRIPT FUNCTIONS //END OF SCRIPT FUNCTIONS
@@ -568,7 +553,7 @@ void LoadGlobalScripts() {
//ButtonsReload(); //ButtonsReload();
} }
static bool _stdcall ScriptHasLoaded(TProgram* script) { bool _stdcall ScriptHasLoaded(TProgram* script) {
for (size_t d = 0; d < checkedScripts.size(); d++) { for (size_t d = 0; d < checkedScripts.size(); d++) {
if (checkedScripts[d] == script) { if (checkedScripts[d] == script) {
return 0; return 0;
@@ -578,6 +563,21 @@ static bool _stdcall ScriptHasLoaded(TProgram* script) {
return 1; return 1;
} }
void _stdcall RegAnimCombatCheck(DWORD newValue) {
char oldValue = reg_anim_combat_check;
reg_anim_combat_check = (newValue > 0);
if (oldValue != reg_anim_combat_check) {
SafeWrite8(0x459C97, reg_anim_combat_check); // reg_anim_func
SafeWrite8(0x459D4B, reg_anim_combat_check); // reg_anim_animate
SafeWrite8(0x459E3B, reg_anim_combat_check); // reg_anim_animate_reverse
SafeWrite8(0x459EEB, reg_anim_combat_check); // reg_anim_obj_move_to_obj
SafeWrite8(0x459F9F, reg_anim_combat_check); // reg_anim_obj_run_to_obj
SafeWrite8(0x45A053, reg_anim_combat_check); // reg_anim_obj_move_to_tile
SafeWrite8(0x45A105, reg_anim_combat_check); // reg_anim_obj_run_to_tile
SafeWrite8(0x45AE53, reg_anim_combat_check); // reg_anim_animate_forever
}
}
// this runs before actually loading/starting the game // this runs before actually loading/starting the game
void ClearGlobalScripts() { void ClearGlobalScripts() {
isGameLoading = true; isGameLoading = true;
+5 -1
View File
@@ -20,6 +20,8 @@
#include "..\main.h" #include "..\main.h"
#include "..\FalloutEngine\Structs.h" #include "..\FalloutEngine\Structs.h"
// TODO: remove this
#include "Scripting\OpcodeHandler.h"
struct sGlobalVar { struct sGlobalVar {
__int64 id; __int64 id;
@@ -73,11 +75,13 @@ void RunScriptProc(sScriptProgram* prog, int procId);
void AddProgramToMap(sScriptProgram &prog); void AddProgramToMap(sScriptProgram &prog);
sScriptProgram* GetGlobalScriptProgram(TProgram* scriptPtr); sScriptProgram* GetGlobalScriptProgram(TProgram* scriptPtr);
char* _stdcall mysubstr(char* str, int pos, int length);
// variables // variables
static char reg_anim_combat_check = 1; static char reg_anim_combat_check = 1;
extern DWORD isGlobalScriptLoading; extern DWORD isGlobalScriptLoading;
// TODO: get rid of this global variable
extern OpcodeHandler opHandler;
// types for script variables // types for script variables
#define VAR_TYPE_INT (0xC001) #define VAR_TYPE_INT (0xC001)
#define VAR_TYPE_FLOAT (0xA001) #define VAR_TYPE_FLOAT (0xA001)
-197
View File
@@ -1,197 +0,0 @@
/*
* sfall
* Copyright (C) 2008, 2009, 2010, 2012 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
void _stdcall RegAnimCombatCheck(DWORD newValue) {
char oldValue = reg_anim_combat_check;
reg_anim_combat_check = (newValue > 0);
if (oldValue != reg_anim_combat_check) {
SafeWrite8(0x459C97, reg_anim_combat_check); // reg_anim_func
SafeWrite8(0x459D4B, reg_anim_combat_check); // reg_anim_animate
SafeWrite8(0x459E3B, reg_anim_combat_check); // reg_anim_animate_reverse
SafeWrite8(0x459EEB, reg_anim_combat_check); // reg_anim_obj_move_to_obj
SafeWrite8(0x459F9F, reg_anim_combat_check); // reg_anim_obj_run_to_obj
SafeWrite8(0x45A053, reg_anim_combat_check); // reg_anim_obj_move_to_tile
SafeWrite8(0x45A105, reg_anim_combat_check); // reg_anim_obj_run_to_tile
SafeWrite8(0x45AE53, reg_anim_combat_check); // reg_anim_animate_forever
}
}
static void __declspec(naked) op_reg_anim_combat_check() {
_OP_BEGIN(ebp)
_GET_ARG_R32(ebp, ecx, edx) // new value
_CHECK_ARG_INT(cx, end1)
__asm {
push edx
call RegAnimCombatCheck
}
end1:
_OP_END
}
// new reg_anim functions (all using existing engine code)
// checks if combat mode is enabled (using R8 8-bit register) and jumps to GOTOFAIL if it is (does nothing if reg_anim_combat_check is 0)
#define _CHECK_COMBAT_MODE(R8, GOTOFAIL) __asm { \
__asm mov R8, reg_anim_combat_check \
__asm test byte ptr ds:VARPTR_combat_state, R8 \
__asm jnz GOTOFAIL }
static void __declspec(naked) op_reg_anim_destroy() {
_OP_BEGIN(ebp)
_GET_ARG_R32(ebp, edx, esi) // object
_CHECK_ARG_INT(dx, end1)
_CHECK_COMBAT_MODE(al, end1)
__asm {
mov eax, esi // object
call FuncOffs::register_object_must_erase_;
}
end1:
_OP_END
}
static void __declspec(naked) op_reg_anim_animate_and_hide() {
_OP_BEGIN(ebp)
_GET_ARG_R32(ebp, ebx, esi) // delay
_GET_ARG_R32(ebp, ecx, edi) // animID
_GET_ARG_R32(ebp, edx, eax) // object
// eax should not change until function call
_CHECK_ARG_INT(bx, end)
_CHECK_ARG_INT(cx, end)
_CHECK_ARG_INT(dx, end)
__asm {
_CHECK_COMBAT_MODE(bl, end)
mov ebx, esi // delay
mov edx, edi // animID
call FuncOffs::register_object_animate_and_hide_;
}
end:
_OP_END
}
static void __declspec(naked) op_reg_anim_light() {
_OP_BEGIN(ebp)
_GET_ARG_R32(ebp, ebx, esi) // delay
_GET_ARG_R32(ebp, ecx, edi) // light radius
_GET_ARG_R32(ebp, edx, eax) // object
// eax should not change until function call
_CHECK_ARG_INT(bx, end)
_CHECK_ARG_INT(cx, end)
_CHECK_ARG_INT(dx, end)
__asm {
// check for valid radius
cmp di, 0
jge dontfixMin
mov di, 0
jmp dontfixMax
dontfixMin:
cmp di, 8
jle dontfixMax
mov di, 8
dontfixMax:
_CHECK_COMBAT_MODE(bl, end)
mov ebx, esi // delay
mov edx, edi // light radius
call FuncOffs::register_object_light_;
}
end:
_OP_END
}
static void __declspec(naked) op_reg_anim_change_fid() {
_OP_BEGIN(ebp)
_GET_ARG_R32(ebp, ebx, esi) // delay
_GET_ARG_R32(ebp, ecx, edi) // FID
_GET_ARG_R32(ebp, edx, eax) // object
// eax should not change until function call
_CHECK_ARG_INT(bx, end)
_CHECK_ARG_INT(cx, end)
_CHECK_ARG_INT(dx, end)
__asm {
_CHECK_COMBAT_MODE(bl, end)
mov ebx, esi // delay
mov edx, edi // FID
call FuncOffs::register_object_change_fid_
}
end:
_OP_END
}
static void __declspec(naked) op_reg_anim_take_out() {
_OP_BEGIN(ebp)
_GET_ARG_R32(ebp, ebx, esi) // delay - not used
_GET_ARG_R32(ebp, ecx, edi) // weapon hold frame ID
_GET_ARG_R32(ebp, edx, eax) // object
// eax should not change until function call
_CHECK_ARG_INT(bx, end)
_CHECK_ARG_INT(cx, end)
_CHECK_ARG_INT(dx, end)
__asm {
_CHECK_COMBAT_MODE(bl, end)
//mov ebx, esi // delay - not used
mov edx, edi // holdFrame
call FuncOffs::register_object_take_out_;
}
end:
_OP_END
}
static void __declspec(naked) op_reg_anim_turn_towards() {
_OP_BEGIN(ebp)
_GET_ARG_R32(ebp, ebx, esi) // delay - not used
_GET_ARG_R32(ebp, ecx, edi) // tile
_GET_ARG_R32(ebp, edx, eax) // object
// eax should not change until function call
_CHECK_ARG_INT(bx, end)
_CHECK_ARG_INT(cx, end)
_CHECK_ARG_INT(dx, end)
__asm {
_CHECK_COMBAT_MODE(bl, end)
// mov ebx, esi // delay - not used
mov edx, edi // tile
call FuncOffs::register_object_turn_towards_;
}
end:
_OP_END
}
static void __declspec(naked) op_explosions_metarule() {
_OP_BEGIN(ebp)
_GET_ARG_R32(ebp, ebx, esi) // arg3
_GET_ARG_R32(ebp, ecx, edi) // arg2
_GET_ARG_R32(ebp, edx, eax) // arg1
// eax should not change until function call
_CHECK_ARG_INT(bx, fail)
_CHECK_ARG_INT(cx, fail)
_CHECK_ARG_INT(dx, fail)
__asm {
push esi
push edi
push eax
call ExplosionsMetaruleFunc;
jmp end;
}
fail:
__asm {
mov eax, -1
}
end:
_RET_VAL_INT(ebp)
_OP_END
}
+187
View File
@@ -0,0 +1,187 @@
/*
* 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 "..\..\Explosions.h"
#include "..\..\ScriptExtender.h"
#include "AsmMacros.h"
#include "Anims.h"
// checks if combat mode is enabled (using R8 8-bit register) and jumps to GOTOFAIL if it is (does nothing if reg_anim_combat_check is 0)
#define _CHECK_COMBAT_MODE(R8, GOTOFAIL) __asm { \
__asm mov R8, reg_anim_combat_check \
__asm test byte ptr ds:VARPTR_combat_state, R8 \
__asm jnz GOTOFAIL }
void __declspec(naked) op_reg_anim_combat_check() {
_OP_BEGIN(ebp)
_GET_ARG_R32(ebp, ecx, edx) // new value
_CHECK_ARG_INT(cx, end1)
__asm {
push edx
call RegAnimCombatCheck
}
end1:
_OP_END
}
void __declspec(naked) op_reg_anim_destroy() {
_OP_BEGIN(ebp)
_GET_ARG_R32(ebp, edx, esi) // object
_CHECK_ARG_INT(dx, end1)
_CHECK_COMBAT_MODE(al, end1)
__asm {
mov eax, esi // object
call FuncOffs::register_object_must_erase_;
}
end1:
_OP_END
}
void __declspec(naked) op_reg_anim_animate_and_hide() {
_OP_BEGIN(ebp)
_GET_ARG_R32(ebp, ebx, esi) // delay
_GET_ARG_R32(ebp, ecx, edi) // animID
_GET_ARG_R32(ebp, edx, eax) // object
// eax should not change until function call
_CHECK_ARG_INT(bx, end)
_CHECK_ARG_INT(cx, end)
_CHECK_ARG_INT(dx, end)
__asm {
_CHECK_COMBAT_MODE(bl, end)
mov ebx, esi // delay
mov edx, edi // animID
call FuncOffs::register_object_animate_and_hide_;
}
end:
_OP_END
}
void __declspec(naked) op_reg_anim_light() {
_OP_BEGIN(ebp)
_GET_ARG_R32(ebp, ebx, esi) // delay
_GET_ARG_R32(ebp, ecx, edi) // light radius
_GET_ARG_R32(ebp, edx, eax) // object
// eax should not change until function call
_CHECK_ARG_INT(bx, end)
_CHECK_ARG_INT(cx, end)
_CHECK_ARG_INT(dx, end)
__asm {
// check for valid radius
cmp di, 0
jge dontfixMin
mov di, 0
jmp dontfixMax
dontfixMin :
cmp di, 8
jle dontfixMax
mov di, 8
dontfixMax :
_CHECK_COMBAT_MODE(bl, end)
mov ebx, esi // delay
mov edx, edi // light radius
call FuncOffs::register_object_light_;
}
end:
_OP_END
}
void __declspec(naked) op_reg_anim_change_fid() {
_OP_BEGIN(ebp)
_GET_ARG_R32(ebp, ebx, esi) // delay
_GET_ARG_R32(ebp, ecx, edi) // FID
_GET_ARG_R32(ebp, edx, eax) // object
// eax should not change until function call
_CHECK_ARG_INT(bx, end)
_CHECK_ARG_INT(cx, end)
_CHECK_ARG_INT(dx, end)
__asm {
_CHECK_COMBAT_MODE(bl, end)
mov ebx, esi // delay
mov edx, edi // FID
call FuncOffs::register_object_change_fid_
}
end:
_OP_END
}
void __declspec(naked) op_reg_anim_take_out() {
_OP_BEGIN(ebp)
_GET_ARG_R32(ebp, ebx, esi) // delay - not used
_GET_ARG_R32(ebp, ecx, edi) // weapon hold frame ID
_GET_ARG_R32(ebp, edx, eax) // object
// eax should not change until function call
_CHECK_ARG_INT(bx, end)
_CHECK_ARG_INT(cx, end)
_CHECK_ARG_INT(dx, end)
__asm {
_CHECK_COMBAT_MODE(bl, end)
//mov ebx, esi // delay - not used
mov edx, edi // holdFrame
call FuncOffs::register_object_take_out_;
}
end:
_OP_END
}
void __declspec(naked) op_reg_anim_turn_towards() {
_OP_BEGIN(ebp)
_GET_ARG_R32(ebp, ebx, esi) // delay - not used
_GET_ARG_R32(ebp, ecx, edi) // tile
_GET_ARG_R32(ebp, edx, eax) // object
// eax should not change until function call
_CHECK_ARG_INT(bx, end)
_CHECK_ARG_INT(cx, end)
_CHECK_ARG_INT(dx, end)
__asm {
_CHECK_COMBAT_MODE(bl, end)
// mov ebx, esi // delay - not used
mov edx, edi // tile
call FuncOffs::register_object_turn_towards_;
}
end:
_OP_END
}
void __declspec(naked)op_explosions_metarule() {
_OP_BEGIN(ebp)
_GET_ARG_R32(ebp, ebx, esi) // arg3
_GET_ARG_R32(ebp, ecx, edi) // arg2
_GET_ARG_R32(ebp, edx, eax) // arg1
// eax should not change until function call
_CHECK_ARG_INT(bx, fail)
_CHECK_ARG_INT(cx, fail)
_CHECK_ARG_INT(dx, fail)
__asm {
push esi
push edi
push eax
call ExplosionsMetaruleFunc;
jmp end;
}
fail:
__asm {
mov eax, -1
}
end:
_RET_VAL_INT(ebp)
_OP_END
}
+39
View File
@@ -0,0 +1,39 @@
/*
* 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
// new reg_anim functions (all using existing engine code)
void __declspec() op_reg_anim_combat_check();
void __declspec() op_reg_anim_destroy();
void __declspec() op_reg_anim_animate_and_hide();
void __declspec() op_reg_anim_light();
void __declspec() op_reg_anim_change_fid();
void __declspec() op_reg_anim_take_out();
void __declspec() op_reg_anim_turn_towards();
void __declspec() op_explosions_metarule();
@@ -1,6 +1,6 @@
/* /*
* sfall * sfall
* Copyright (C) 2008, 2009, 2010, 2012 The sfall team * Copyright (C) 2008-2016 The sfall team
* *
* This program is free software: you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by
@@ -16,13 +16,19 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>. * along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
#pragma once #include "..\..\..\FalloutEngine\Fallout2.h"
#include "..\..\ScriptExtender.h"
#include "..\Arrays.h"
#include "AsmMacros.h"
#include "Utils.h"
static void __declspec(naked) op_create_array() { #include "Arrays.h"
void __declspec(naked) op_create_array() {
__asm { __asm {
pushad; pushad;
mov edi, eax; mov edi, eax;
call FuncOffs::interpretPopShort_ call FuncOffs::interpretPopShort_;
mov ebx, eax; mov ebx, eax;
mov eax, edi; mov eax, edi;
call FuncOffs::interpretPopLong_; call FuncOffs::interpretPopLong_;
@@ -54,24 +60,24 @@ end:
} }
} }
static void __declspec(naked) op_set_array() { void __declspec(naked) op_set_array() {
__asm { __asm {
pushad; pushad;
mov ebp, eax; mov ebp, eax;
//Get args //Get args
call FuncOffs::interpretPopShort_ call FuncOffs::interpretPopShort_;
mov edx, eax; mov edx, eax;
mov eax, ebp; mov eax, ebp;
call FuncOffs::interpretPopLong_; call FuncOffs::interpretPopLong_;
mov edi, eax; // value mov edi, eax; // value
mov eax, ebp; mov eax, ebp;
call FuncOffs::interpretPopShort_ call FuncOffs::interpretPopShort_;
mov ecx, eax; mov ecx, eax;
mov eax, ebp; mov eax, ebp;
call FuncOffs::interpretPopLong_; call FuncOffs::interpretPopLong_;
mov esi, eax; // key mov esi, eax; // key
mov eax, ebp; mov eax, ebp;
call FuncOffs::interpretPopShort_ call FuncOffs::interpretPopShort_;
mov ebx, eax; mov ebx, eax;
mov eax, ebp; mov eax, ebp;
call FuncOffs::interpretPopLong_; call FuncOffs::interpretPopLong_;
@@ -107,29 +113,25 @@ notstring1:
push ecx; // arg 3: key type push ecx; // arg 3: key type
push esi; // arg 2: key push esi; // arg 2: key
push edi; // arg 1: arrayID push edi; // arg 1: arrayID
call SetArray call SetArray;
end: end:
popad; popad;
retn; retn;
} }
} }
/* void __declspec(naked) op_get_array() {
used in place of [] operator when compiling in sslc
so it works as get_array if first argument is int and as substr(x, y, 1) if first argument is string
*/
static void __declspec(naked) op_get_array() {
__asm { __asm {
pushad; pushad;
mov ebp, eax; mov ebp, eax;
//Get args //Get args
call FuncOffs::interpretPopShort_ call FuncOffs::interpretPopShort_;
mov ebx, eax; mov ebx, eax;
mov eax, ebp; mov eax, ebp;
call FuncOffs::interpretPopLong_; call FuncOffs::interpretPopLong_;
mov edi, eax; mov edi, eax;
mov eax, ebp; mov eax, ebp;
call FuncOffs::interpretPopShort_ call FuncOffs::interpretPopShort_;
mov ecx, eax; mov ecx, eax;
mov eax, ebp; mov eax, ebp;
call FuncOffs::interpretPopLong_; call FuncOffs::interpretPopLong_;
@@ -202,7 +204,7 @@ notstring:
} }
} }
static void __declspec(naked) op_free_array() { void __declspec(naked) op_free_array() {
__asm { __asm {
pushad; pushad;
mov edi, eax; mov edi, eax;
@@ -220,7 +222,7 @@ end:
} }
} }
static void __declspec(naked) op_len_array() { void __declspec(naked) op_len_array() {
__asm { __asm {
pushad; pushad;
mov edi, eax; mov edi, eax;
@@ -247,18 +249,18 @@ end:
} }
} }
static void __declspec(naked) op_resize_array() { void __declspec(naked) op_resize_array() {
__asm { __asm {
pushad; pushad;
mov ebp, eax; mov ebp, eax;
//Get args //Get args
call FuncOffs::interpretPopShort_ call FuncOffs::interpretPopShort_;
mov ebx, eax; mov ebx, eax;
mov eax, ebp; mov eax, ebp;
call FuncOffs::interpretPopLong_; call FuncOffs::interpretPopLong_;
mov edi, eax; mov edi, eax;
mov eax, ebp; mov eax, ebp;
call FuncOffs::interpretPopShort_ call FuncOffs::interpretPopShort_;
mov ecx, eax; mov ecx, eax;
mov eax, ebp; mov eax, ebp;
call FuncOffs::interpretPopLong_; call FuncOffs::interpretPopLong_;
@@ -278,11 +280,11 @@ end:
} }
} }
static void __declspec(naked) op_temp_array() { void __declspec(naked) op_temp_array() {
__asm { __asm {
pushad; pushad;
mov edi, eax; mov edi, eax;
call FuncOffs::interpretPopShort_ call FuncOffs::interpretPopShort_;
mov ebx, eax; mov ebx, eax;
mov eax, edi; mov eax, edi;
call FuncOffs::interpretPopLong_; call FuncOffs::interpretPopLong_;
@@ -314,7 +316,7 @@ end:
} }
} }
static void __declspec(naked) op_fix_array() { void __declspec(naked) op_fix_array() {
__asm { __asm {
pushad; pushad;
mov edi, eax; mov edi, eax;
@@ -332,18 +334,18 @@ end:
} }
} }
static void __declspec(naked) op_scan_array() { void __declspec(naked) op_scan_array() {
__asm { __asm {
pushad; pushad;
mov ebp, eax; mov ebp, eax;
//Get args //Get args
call FuncOffs::interpretPopShort_ call FuncOffs::interpretPopShort_;
mov edx, eax; mov edx, eax;
mov eax, ebp; mov eax, ebp;
call FuncOffs::interpretPopLong_; call FuncOffs::interpretPopLong_;
mov edi, eax; // value (needle) mov edi, eax; // value (needle)
mov eax, ebp; mov eax, ebp;
call FuncOffs::interpretPopShort_ call FuncOffs::interpretPopShort_;
mov ecx, eax; mov ecx, eax;
mov eax, ebp; mov eax, ebp;
call FuncOffs::interpretPopLong_; call FuncOffs::interpretPopLong_;
@@ -391,18 +393,18 @@ resultnotstr:
} }
} }
static void __declspec(naked) op_save_array() { void __declspec(naked) op_save_array() {
_OP_BEGIN(ebp) _OP_BEGIN(ebp)
// Get args // Get args
_GET_ARG_R32(ebp, ebx, edi) _GET_ARG_R32(ebp, ebx, edi)
_GET_ARG_R32(ebp, edx, ecx) _GET_ARG_R32(ebp, edx, ecx)
__asm { __asm {
// arg check: // arg check:
cmp bx, VAR_TYPE_INT cmp bx, VAR_TYPE_INT
jne end jne end
} }
_CHECK_PARSE_STR(1, ebp, dx, ecx) _CHECK_PARSE_STR(1, ebp, dx, ecx)
__asm { __asm {
push edi // arg 3: arrayID push edi // arg 3: arrayID
push edx // arg 2: keyType push edx // arg 2: keyType
push ecx // arg 1: key push ecx // arg 1: key
@@ -412,7 +414,7 @@ end:
_OP_END _OP_END
} }
static void __declspec(naked) op_load_array() { void __declspec(naked) op_load_array() {
_OP_BEGIN(ebp) _OP_BEGIN(ebp)
_GET_ARG_R32(ebp, edx, ecx) _GET_ARG_R32(ebp, edx, ecx)
_CHECK_PARSE_STR(1, ebp, dx, ecx) _CHECK_PARSE_STR(1, ebp, dx, ecx)
@@ -425,12 +427,12 @@ static void __declspec(naked) op_load_array() {
_OP_END _OP_END
} }
static void __declspec(naked) op_get_array_key() { void __declspec(naked) op_get_array_key() {
_OP_BEGIN(ebp) _OP_BEGIN(ebp)
_GET_ARG_R32(ebp, edx, ecx) // index _GET_ARG_R32(ebp, edx, ecx) // index
_GET_ARG_R32(ebp, ebx, edi) // arrayID _GET_ARG_R32(ebp, ebx, edi) // arrayID
__asm { __asm {
// arg check: // arg check:
cmp bx, VAR_TYPE_INT; cmp bx, VAR_TYPE_INT;
jne wrongarg; jne wrongarg;
cmp dx, VAR_TYPE_INT; cmp dx, VAR_TYPE_INT;
@@ -441,17 +443,17 @@ static void __declspec(naked) op_get_array_key() {
call GetArrayKey; call GetArrayKey;
} }
_RET_VAL_POSSIBLY_STR(1, ebp, [esp]) _RET_VAL_POSSIBLY_STR(1, ebp, [esp])
goto end; goto end;
__asm { __asm {
wrongarg: wrongarg:
xor eax, eax; // return 0 on wrong arguments xor eax, eax; // return 0 on wrong arguments
} }
_RET_VAL_INT(ebp) _RET_VAL_INT(ebp)
end: end:
_OP_END _OP_END
} }
static void __declspec(naked) op_stack_array() { void __declspec(naked) op_stack_array() {
_OP_BEGIN(ebp) _OP_BEGIN(ebp)
_GET_ARG_R32(ebp, edx, esi) // value _GET_ARG_R32(ebp, edx, esi) // value
_GET_ARG_R32(ebp, ebx, edi) // key _GET_ARG_R32(ebp, ebx, edi) // key
@@ -460,12 +462,12 @@ static void __declspec(naked) op_stack_array() {
push ebx push ebx
} }
_CHECK_PARSE_STR(1, ebp, dx, esi) _CHECK_PARSE_STR(1, ebp, dx, esi)
__asm { __asm {
pop ebx pop ebx
mov ecx, ebx mov ecx, ebx
} }
_CHECK_PARSE_STR(2, ebp, bx, edi) _CHECK_PARSE_STR(2, ebp, bx, edi)
__asm { __asm {
push esi // arg 3: value push esi // arg 3: value
push ecx // arg 2: keyType push ecx // arg 2: keyType
push edi // arg 1: key push edi // arg 1: key
@@ -475,6 +477,8 @@ static void __declspec(naked) op_stack_array() {
_OP_END _OP_END
} }
// object LISTS // object LISTS
struct sList { struct sList {
@@ -493,7 +497,6 @@ struct sList {
}; };
static void FillListVector(DWORD type, std::vector<TGameObj*>& vec) { static void FillListVector(DWORD type, std::vector<TGameObj*>& vec) {
// TODO: fix style, use wrappers
if (type == 6) { if (type == 6) {
TScript* scriptPtr; TScript* scriptPtr;
TGameObj* self_obj; TGameObj* self_obj;
@@ -563,7 +566,8 @@ static void _stdcall list_end2(sList* list) {
delete list; delete list;
} }
static void __declspec(naked) op_list_begin() {
void __declspec(naked) op_list_begin() {
__asm { __asm {
pushad; pushad;
mov ebp, eax; mov ebp, eax;
@@ -591,7 +595,7 @@ end:
} }
} }
static void __declspec(naked) op_list_as_array() { void __declspec(naked) op_list_as_array() {
__asm { __asm {
pushad; pushad;
mov ebp, eax; mov ebp, eax;
@@ -619,7 +623,7 @@ end:
} }
} }
static void __declspec(naked) op_list_next() { void __declspec(naked) op_list_next() {
__asm { __asm {
pushad; pushad;
mov ebp, eax; mov ebp, eax;
@@ -647,7 +651,7 @@ end:
} }
} }
static void __declspec(naked) op_list_end() { void __declspec(naked) op_list_end() {
__asm { __asm {
pushad; pushad;
mov ebp, eax; mov ebp, eax;
+57
View File
@@ -0,0 +1,57 @@
/*
* 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
void __declspec() op_create_array();
void __declspec() op_set_array();
/*
used in place of [] operator when compiling in sslc
so it works as get_array if first argument is int and as substr(x, y, 1) if first argument is string
*/
void __declspec() op_get_array();
void __declspec() op_free_array();
void __declspec() op_len_array();
void __declspec() op_resize_array();
void __declspec() op_temp_array();
void __declspec() op_fix_array();
void __declspec() op_scan_array();
void __declspec() op_save_array();
void __declspec() op_load_array();
void __declspec() op_get_array_key();
void __declspec() op_stack_array();
void __declspec() op_list_begin();
void __declspec() op_list_as_array();
void __declspec() op_list_next();
void __declspec() op_list_end();
@@ -1,5 +1,7 @@
#pragma once #pragma once
#include "..\OpcodeHandler.h"
/* /*
MACROS for operators assembly code MACROS for operators assembly code
@@ -1,6 +1,6 @@
/* /*
* sfall * sfall
* Copyright (C) 2008, 2009, 2010, 2012 The sfall team * Copyright (C) 2008-2016 The sfall team
* *
* This program is free software: you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by
@@ -16,15 +16,13 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>. * along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
#pragma once #include "..\..\..\FalloutEngine\Fallout2.h"
#include "..\..\ScriptExtender.h"
#include "..\..\FileSystem.h"
#include "..\..\main.h" #include "FileSystem.h"
#include "..\FileSystem.h" void __declspec(naked) op_fs_create() {
#include "..\ScriptExtender.h"
//file system functions
static void __declspec(naked) op_fs_create() {
__asm { __asm {
pushad; pushad;
mov edi, eax; mov edi, eax;
@@ -67,7 +65,7 @@ end:
} }
} }
static void __declspec(naked) op_fs_copy() { void __declspec(naked) op_fs_copy() {
__asm { __asm {
pushad; pushad;
mov ebp, eax; mov ebp, eax;
@@ -118,7 +116,7 @@ end:
} }
} }
static void __declspec(naked) op_fs_find() { void __declspec(naked) op_fs_find() {
__asm { __asm {
pushad; pushad;
mov ebp, eax; mov ebp, eax;
@@ -153,7 +151,7 @@ end:
} }
} }
static void __declspec(naked) op_fs_write_byte() { void __declspec(naked) op_fs_write_byte() {
__asm { __asm {
pushad; pushad;
mov ebp, eax; mov ebp, eax;
@@ -180,7 +178,7 @@ end:
} }
} }
static void __declspec(naked) op_fs_write_short() { void __declspec(naked) op_fs_write_short() {
__asm { __asm {
pushad; pushad;
mov ebp, eax; mov ebp, eax;
@@ -207,7 +205,7 @@ end:
} }
} }
static void __declspec(naked) op_fs_write_int() { void __declspec(naked) op_fs_write_int() {
__asm { __asm {
pushad; pushad;
mov ebp, eax; mov ebp, eax;
@@ -237,7 +235,7 @@ end:
} }
} }
static void __declspec(naked) op_fs_write_string() { void __declspec(naked) op_fs_write_string() {
__asm { __asm {
pushad; pushad;
mov edi, eax; mov edi, eax;
@@ -272,7 +270,7 @@ end:
} }
} }
static void __declspec(naked) op_fs_write_bstring() { void __declspec(naked) op_fs_write_bstring() {
__asm { __asm {
pushad; pushad;
mov edi, eax; mov edi, eax;
@@ -307,7 +305,7 @@ end:
} }
} }
static void __declspec(naked) op_fs_read_byte() { void __declspec(naked) op_fs_read_byte() {
__asm { __asm {
pushad; pushad;
mov ebp, eax; mov ebp, eax;
@@ -335,7 +333,7 @@ end:
} }
} }
static void __declspec(naked) op_fs_read_short() { void __declspec(naked) op_fs_read_short() {
__asm { __asm {
pushad; pushad;
mov ebp, eax; mov ebp, eax;
@@ -363,7 +361,7 @@ end:
} }
} }
static void __declspec(naked) op_fs_read_int() { void __declspec(naked) op_fs_read_int() {
__asm { __asm {
pushad; pushad;
mov ebp, eax; mov ebp, eax;
@@ -391,7 +389,7 @@ end:
} }
} }
static void __declspec(naked) op_fs_read_float() { void __declspec(naked) op_fs_read_float() {
__asm { __asm {
pushad; pushad;
mov ebp, eax; mov ebp, eax;
@@ -419,7 +417,7 @@ end:
} }
} }
static void __declspec(naked) op_fs_delete() { void __declspec(naked) op_fs_delete() {
__asm { __asm {
pushad; pushad;
mov ebp, eax; mov ebp, eax;
@@ -429,7 +427,7 @@ static void __declspec(naked) op_fs_delete() {
call FuncOffs::interpretPopLong_; call FuncOffs::interpretPopLong_;
cmp di, 0xc001; cmp di, 0xc001;
jnz end jnz end
push eax; push eax;
call FSdelete; call FSdelete;
end: end:
popad; popad;
@@ -437,7 +435,7 @@ end:
} }
} }
static void __declspec(naked) op_fs_size() { void __declspec(naked) op_fs_size() {
__asm { __asm {
pushad; pushad;
mov ebp, eax; mov ebp, eax;
@@ -465,7 +463,7 @@ end:
} }
} }
static void __declspec(naked) op_fs_pos() { void __declspec(naked) op_fs_pos() {
__asm { __asm {
pushad; pushad;
mov ebp, eax; mov ebp, eax;
@@ -493,7 +491,7 @@ end:
} }
} }
static void __declspec(naked) op_fs_seek() { void __declspec(naked) op_fs_seek() {
__asm { __asm {
pushad; pushad;
mov ebp, eax; mov ebp, eax;
@@ -520,7 +518,7 @@ end:
} }
} }
static void __declspec(naked) op_fs_resize() { void __declspec(naked) op_fs_resize() {
__asm { __asm {
pushad; pushad;
mov ebp, eax; mov ebp, eax;
@@ -0,0 +1,55 @@
/*
* 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
//file system functions
void __declspec() op_fs_create();
void __declspec() op_fs_copy();
void __declspec() op_fs_find();
void __declspec() op_fs_write_byte();
void __declspec() op_fs_write_short();
void __declspec() op_fs_write_int();
void __declspec() op_fs_write_string();
void __declspec() op_fs_write_bstring();
void __declspec() op_fs_read_byte();
void __declspec() op_fs_read_short();
void __declspec() op_fs_read_int();
void __declspec() op_fs_read_float();
void __declspec() op_fs_delete();
void __declspec() op_fs_size();
void __declspec() op_fs_pos();
void __declspec() op_fs_seek();
void __declspec() op_fs_resize();
@@ -1,6 +1,6 @@
/* /*
* sfall * sfall
* Copyright (C) 2008, 2009, 2010, 2012 The sfall team * Copyright (C) 2008-2016 The sfall team
* *
* This program is free software: you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by
@@ -16,15 +16,15 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>. * along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
#pragma once #include "..\..\..\main.h"
#include "..\..\..\InputFuncs.h"
#include "..\..\..\FalloutEngine\Fallout2.h"
#include "..\..\Graphics.h"
#include "..\..\ScriptExtender.h"
#include "..\..\main.h" #include "Graphics.h"
#include "..\..\InputFuncs.h"
#include "..\Graphics.h"
#include "..\ScriptExtender.h"
// graphics_functions void __declspec(naked) op_graphics_funcs_available() {
static void __declspec(naked) op_graphics_funcs_available() {
__asm { __asm {
push ebx; push ebx;
push ecx; push ecx;
@@ -47,7 +47,7 @@ end:
} }
} }
static void __declspec(naked) op_load_shader() { void __declspec(naked) op_load_shader() {
__asm { __asm {
push ebx; push ebx;
push ecx; push ecx;
@@ -86,7 +86,7 @@ result:
} }
} }
static void __declspec(naked) op_free_shader() { void __declspec(naked) op_free_shader() {
__asm { __asm {
push ebx; push ebx;
push ecx; push ecx;
@@ -108,7 +108,7 @@ end:
} }
} }
static void __declspec(naked) op_activate_shader() { void __declspec(naked) op_activate_shader() {
__asm { __asm {
push ebx; push ebx;
push ecx; push ecx;
@@ -130,7 +130,7 @@ end:
} }
} }
static void __declspec(naked) op_deactivate_shader() { void __declspec(naked) op_deactivate_shader() {
__asm { __asm {
push ebx; push ebx;
push ecx; push ecx;
@@ -152,7 +152,7 @@ end:
} }
} }
static void __declspec(naked) op_get_shader_texture() { void __declspec(naked) op_get_shader_texture() {
__asm { __asm {
//Store registers //Store registers
push ebx; push ebx;
@@ -162,19 +162,19 @@ static void __declspec(naked) op_get_shader_texture() {
//Get function args //Get function args
mov ecx, eax; mov ecx, eax;
call FuncOffs::interpretPopShort_; call FuncOffs::interpretPopShort_;
push eax push eax;
mov eax, ecx; mov eax, ecx;
call FuncOffs::interpretPopLong_; call FuncOffs::interpretPopLong_;
mov edi, eax; mov edi, eax;
mov eax, ecx; mov eax, ecx;
call FuncOffs::interpretPopShort_; call FuncOffs::interpretPopShort_;
push eax push eax;
mov eax, ecx; mov eax, ecx;
call FuncOffs::interpretPopLong_; call FuncOffs::interpretPopLong_;
mov ebx, [esp]; mov ebx, [esp];
cmp bx, 0xC001; cmp bx, 0xC001;
jnz fail; jnz fail;
mov ebx, [esp+4]; mov ebx, [esp + 4];
cmp bx, 0xc001; cmp bx, 0xc001;
jnz fail; jnz fail;
//set the new value //set the new value
@@ -186,7 +186,7 @@ static void __declspec(naked) op_get_shader_texture() {
pop ecx; pop ecx;
jmp end; jmp end;
fail: fail:
mov edx, -1 mov edx, -1;
end: end:
//Pass back the result //Pass back the result
mov eax, ecx; mov eax, ecx;
@@ -204,7 +204,7 @@ end:
} }
} }
static void __declspec(naked) op_set_shader_int() { void __declspec(naked) op_set_shader_int() {
__asm { __asm {
push ebx; push ebx;
push ecx; push ecx;
@@ -219,7 +219,7 @@ static void __declspec(naked) op_set_shader_int() {
mov edi, eax; mov edi, eax;
mov eax, ecx; mov eax, ecx;
call FuncOffs::interpretPopLong_; call FuncOffs::interpretPopLong_;
mov [esp+8], eax; mov[esp + 8], eax;
mov eax, ecx; mov eax, ecx;
call FuncOffs::interpretPopShort_; call FuncOffs::interpretPopShort_;
mov edx, eax; mov edx, eax;
@@ -231,7 +231,7 @@ static void __declspec(naked) op_set_shader_int() {
mov esi, eax; mov esi, eax;
mov eax, ecx; mov eax, ecx;
call FuncOffs::interpretPopLong_; call FuncOffs::interpretPopLong_;
mov [esp], eax; mov[esp], eax;
//Error check //Error check
cmp di, 0xC001; cmp di, 0xC001;
jnz fail; jnz fail;
@@ -245,7 +245,7 @@ next:
mov eax, ecx; mov eax, ecx;
mov ebx, ebp; mov ebx, ebp;
call FuncOffs::interpretGetString_; call FuncOffs::interpretGetString_;
mov [esp+4], eax; mov[esp + 4], eax;
call SetShaderInt; call SetShaderInt;
jmp end; jmp end;
fail: fail:
@@ -261,7 +261,7 @@ end:
} }
} }
static void __declspec(naked) op_set_shader_texture() { void __declspec(naked) op_set_shader_texture() {
__asm { __asm {
push ebx; push ebx;
push ecx; push ecx;
@@ -276,7 +276,7 @@ static void __declspec(naked) op_set_shader_texture() {
mov edi, eax; mov edi, eax;
mov eax, ecx; mov eax, ecx;
call FuncOffs::interpretPopLong_; call FuncOffs::interpretPopLong_;
mov [esp+8], eax; mov[esp + 8], eax;
mov eax, ecx; mov eax, ecx;
call FuncOffs::interpretPopShort_; call FuncOffs::interpretPopShort_;
mov edx, eax; mov edx, eax;
@@ -288,7 +288,7 @@ static void __declspec(naked) op_set_shader_texture() {
mov esi, eax; mov esi, eax;
mov eax, ecx; mov eax, ecx;
call FuncOffs::interpretPopLong_; call FuncOffs::interpretPopLong_;
mov [esp], eax; mov[esp], eax;
//Error check //Error check
cmp di, 0xC001; cmp di, 0xC001;
jnz fail; jnz fail;
@@ -302,7 +302,7 @@ next:
mov eax, ecx; mov eax, ecx;
mov ebx, ebp; mov ebx, ebp;
call FuncOffs::interpretGetString_; call FuncOffs::interpretGetString_;
mov [esp+4], eax; mov[esp + 4], eax;
call SetShaderTexture; call SetShaderTexture;
jmp end; jmp end;
fail: fail:
@@ -318,7 +318,7 @@ end:
} }
} }
static void __declspec(naked) op_set_shader_float() { void __declspec(naked) op_set_shader_float() {
__asm { __asm {
push ebx; push ebx;
push ecx; push ecx;
@@ -333,7 +333,7 @@ static void __declspec(naked) op_set_shader_float() {
mov edi, eax; mov edi, eax;
mov eax, ecx; mov eax, ecx;
call FuncOffs::interpretPopLong_; call FuncOffs::interpretPopLong_;
mov [esp+8], eax; mov[esp + 8], eax;
mov eax, ecx; mov eax, ecx;
call FuncOffs::interpretPopShort_; call FuncOffs::interpretPopShort_;
mov edx, eax; mov edx, eax;
@@ -345,14 +345,14 @@ static void __declspec(naked) op_set_shader_float() {
mov esi, eax; mov esi, eax;
mov eax, ecx; mov eax, ecx;
call FuncOffs::interpretPopLong_; call FuncOffs::interpretPopLong_;
mov [esp], eax; mov[esp], eax;
//Error check //Error check
cmp di, 0xa001; cmp di, 0xa001;
jz paramWasFloat; jz paramWasFloat;
cmp di, 0xc001; cmp di, 0xc001;
jnz fail; jnz fail;
fild [esp+8]; fild[esp + 8];
fstp [esp+8]; fstp[esp + 8];
paramWasFloat: paramWasFloat:
cmp dx, 0x9001; cmp dx, 0x9001;
jz next; jz next;
@@ -364,7 +364,7 @@ next:
mov eax, ecx; mov eax, ecx;
mov ebx, ebp; mov ebx, ebp;
call FuncOffs::interpretGetString_; call FuncOffs::interpretGetString_;
mov [esp+4], eax; mov[esp + 4], eax;
call SetShaderFloat; call SetShaderFloat;
jmp end; jmp end;
fail: fail:
@@ -380,7 +380,7 @@ end:
} }
} }
static void __declspec(naked) op_set_shader_vector() { void __declspec(naked) op_set_shader_vector() {
__asm { __asm {
push ebx; push ebx;
push ecx; push ecx;
@@ -393,35 +393,35 @@ static void __declspec(naked) op_set_shader_vector() {
argloopstart: argloopstart:
mov eax, ebp; mov eax, ebp;
call FuncOffs::interpretPopShort_; call FuncOffs::interpretPopShort_;
mov word ptr [esp+ecx*2+0x16], ax; mov word ptr[esp + ecx * 2 + 0x16], ax;
mov eax, ebp; mov eax, ebp;
call FuncOffs::interpretPopLong_; call FuncOffs::interpretPopLong_;
mov [esp+ecx*4-0x4], eax; mov[esp + ecx * 4 - 0x4], eax;
loop argloopstart; loop argloopstart;
//Error check //Error check
mov ecx, 4; mov ecx, 4;
checkloopstart: checkloopstart:
cmp word ptr [esp+ecx*2+0x1a], 0xa001; cmp word ptr[esp + ecx * 2 + 0x1a], 0xa001;
jz paramWasFloat; jz paramWasFloat;
cmp word ptr [esp+ecx*2+0x1a], 0xc001; cmp word ptr[esp + ecx * 2 + 0x1a], 0xc001;
jnz fail; jnz fail;
fild [esp+ecx*4+0x4]; fild[esp + ecx * 4 + 0x4];
fstp [esp+ecx*4+0x4]; fstp[esp + ecx * 4 + 0x4];
paramWasFloat: paramWasFloat:
loop checkloopstart; loop checkloopstart;
cmp word ptr [esp+0x1a], 0x9001; cmp word ptr[esp + 0x1a], 0x9001;
jz next; jz next;
cmp word ptr [esp+0x1a], 0x9801; cmp word ptr[esp + 0x1a], 0x9801;
jnz fail; jnz fail;
next: next:
cmp word ptr [esp+0x18], 0xc001; cmp word ptr[esp + 0x18], 0xc001;
jnz fail; jnz fail;
mov eax, ebp; mov eax, ebp;
mov ebx, [esp+4]; mov ebx, [esp + 4];
xor edx, edx; xor edx, edx;
mov dx, word ptr [esp+0x1a]; mov dx, word ptr[esp + 0x1a];
call FuncOffs::interpretGetString_; call FuncOffs::interpretGetString_;
mov [esp+4], eax; mov[esp + 4], eax;
call SetShaderVector; call SetShaderVector;
add esp, 0x12; add esp, 0x12;
jmp end; jmp end;
@@ -436,7 +436,7 @@ end:
} }
} }
static void __declspec(naked) op_get_shader_version() { void __declspec(naked) op_get_shader_version() {
__asm { __asm {
push ebx; push ebx;
push ecx; push ecx;
@@ -458,7 +458,7 @@ static void __declspec(naked) op_get_shader_version() {
} }
} }
static void __declspec(naked) op_set_shader_mode() { void __declspec(naked) op_set_shader_mode() {
__asm { __asm {
push ebx; push ebx;
push ecx; push ecx;
@@ -481,7 +481,7 @@ static void __declspec(naked) op_set_shader_mode() {
jnz fail; jnz fail;
push eax; push eax;
call SetShaderMode; call SetShaderMode;
jmp end jmp end;
fail: fail:
pop eax; pop eax;
end: end:
@@ -493,7 +493,7 @@ end:
} }
} }
static void __declspec(naked) op_force_graphics_refresh() { void __declspec(naked) op_force_graphics_refresh() {
__asm { __asm {
push ebx; push ebx;
push ecx; push ecx;
@@ -0,0 +1,46 @@
/*
* 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
// graphics_functions
void __declspec() op_graphics_funcs_available();
void __declspec() op_load_shader();
void __declspec() op_free_shader();
void __declspec() op_activate_shader();
void __declspec() op_deactivate_shader();
void __declspec() op_get_shader_texture();
void __declspec() op_set_shader_int();
void __declspec() op_set_shader_texture();
void __declspec() op_set_shader_float();
void __declspec() op_set_shader_vector();
void __declspec() op_get_shader_version();
void __declspec() op_set_shader_mode();
void __declspec() op_force_graphics_refresh();
@@ -1,6 +1,6 @@
/* /*
* sfall * sfall
* Copyright (C) 2008, 2009, 2010, 2012 The sfall team * Copyright (C) 2008-2016 The sfall team
* *
* This program is free software: you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by
@@ -16,16 +16,14 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>. * along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
#pragma once #include "..\..\..\FalloutEngine\Fallout2.h"
#include "..\..\..\InputFuncs.h"
#include "..\..\BarBoxes.h"
#include "..\..\ScriptExtender.h"
#include "..\..\main.h" #include "Interface.h"
#include "..\InputFuncs.h" void __declspec(naked) op_input_funcs_available() {
#include "..\ScriptExtender.h"
// input_functions
static void __declspec(naked) op_input_funcs_available() {
__asm { __asm {
push ebx; push ebx;
push ecx; push ecx;
@@ -43,7 +41,7 @@ static void __declspec(naked) op_input_funcs_available() {
} }
} }
static void __declspec(naked) op_key_pressed() { void __declspec(naked) op_key_pressed() {
__asm { __asm {
push ebx; push ebx;
push ecx; push ecx;
@@ -76,7 +74,7 @@ end:
} }
} }
static void __declspec(naked) op_tap_key() { void __declspec(naked) op_tap_key() {
__asm { __asm {
push ebx; push ebx;
push ecx; push ecx;
@@ -102,83 +100,78 @@ end:
} }
} }
//// *** From helios *** //// void __declspec(naked) op_get_mouse_x() {
static void __declspec(naked) op_get_mouse_x() { __asm {
__asm { push ecx;
push ecx; push edx;
push edx; mov ecx, eax;
mov ecx, eax; mov edx, ds:[VARPTR_mouse_x_];
mov edx, ds:[VARPTR_mouse_x_]; add edx, ds:[VARPTR_mouse_hotx];
add edx, ds:[VARPTR_mouse_hotx]; call FuncOffs::interpretPushLong_;
call FuncOffs::interpretPushLong_; mov eax, ecx;
mov eax, ecx; mov edx, 0xc001;
mov edx, 0xc001; call FuncOffs::interpretPushShort_
call FuncOffs::interpretPushShort_ pop edx;
pop edx; pop ecx;
pop ecx; retn;
retn; }
}
} }
//Return mouse y position void __declspec(naked) op_get_mouse_y() {
static void __declspec(naked) op_get_mouse_y() { __asm {
__asm { push ecx;
push ecx; push edx;
push edx; mov ecx, eax;
mov ecx, eax; mov edx, ds:[VARPTR_mouse_y_];
mov edx, ds:[VARPTR_mouse_y_]; add edx, ds:[VARPTR_mouse_hoty];
add edx, ds:[VARPTR_mouse_hoty]; call FuncOffs::interpretPushLong_;
call FuncOffs::interpretPushLong_; mov eax, ecx;
mov eax, ecx; mov edx, 0xc001;
mov edx, 0xc001; call FuncOffs::interpretPushShort_
call FuncOffs::interpretPushShort_ pop edx;
pop edx; pop ecx;
pop ecx; retn;
retn; }
}
} }
//Return pressed mouse button (1=left, 2=right, 3=left+right) void __declspec(naked) op_get_mouse_buttons() {
static void __declspec(naked) op_get_mouse_buttons() { __asm {
__asm { push ecx;
push ecx; push edx;
push edx; mov ecx, eax;
mov ecx, eax; mov edx, ds:[VARPTR_last_buttons];
mov edx, ds:[VARPTR_last_buttons]; call FuncOffs::interpretPushLong_;
call FuncOffs::interpretPushLong_; mov eax, ecx;
mov eax, ecx; mov edx, 0xc001;
mov edx, 0xc001; call FuncOffs::interpretPushShort_
call FuncOffs::interpretPushShort_ pop edx;
pop edx; pop ecx;
pop ecx; retn;
retn; }
}
} }
//Return the window number under the mous void __declspec(naked) op_get_window_under_mouse() {
static void __declspec(naked) op_get_window_under_mouse() { __asm {
__asm { push ecx;
push ecx; push edx;
push edx; mov ecx, eax;
mov ecx, eax; mov edx, ds:[VARPTR_last_button_winID];
mov edx, ds:[VARPTR_last_button_winID]; call FuncOffs::interpretPushLong_;
call FuncOffs::interpretPushLong_; mov eax, ecx;
mov eax, ecx; mov edx, 0xc001;
mov edx, 0xc001; call FuncOffs::interpretPushShort_
call FuncOffs::interpretPushShort_ pop edx;
pop edx; pop ecx;
pop ecx; retn;
retn; }
}
} }
//Return screen width void __declspec(naked) op_get_screen_width() {
static void __declspec(naked) op_get_screen_width() {
__asm { __asm {
push edx push edx
push eax push eax
mov edx, ds:[VARPTR_scr_size+8] // _scr_size.offx mov edx, ds:[VARPTR_scr_size + 8] // _scr_size.offx
sub edx, ds:[VARPTR_scr_size] // _scr_size.x sub edx, ds : [VARPTR_scr_size] // _scr_size.x
inc edx inc edx
call FuncOffs::interpretPushLong_ call FuncOffs::interpretPushLong_
pop eax pop eax
@@ -189,13 +182,12 @@ static void __declspec(naked) op_get_screen_width() {
} }
} }
//Return screen height void __declspec(naked) op_get_screen_height() {
static void __declspec(naked) op_get_screen_height() {
__asm { __asm {
push edx push edx
push eax push eax
mov edx, ds:[VARPTR_scr_size+12] // _scr_size.offy mov edx, ds:[VARPTR_scr_size + 12] // _scr_size.offy
sub edx, ds:[VARPTR_scr_size+4] // _scr_size.y sub edx, ds : [VARPTR_scr_size + 4] // _scr_size.y
inc edx inc edx
call FuncOffs::interpretPushLong_ call FuncOffs::interpretPushLong_
pop eax pop eax
@@ -206,24 +198,21 @@ static void __declspec(naked) op_get_screen_height() {
} }
} }
//Stop game, the same effect as open charsscreen or inventory void __declspec(naked) op_stop_game() {
static void __declspec(naked) op_stop_game() {
__asm { __asm {
call FuncOffs::map_disable_bk_processes_; call FuncOffs::map_disable_bk_processes_;
retn; retn;
} }
} }
//Resume the game when it is stopped void __declspec(naked) op_resume_game() {
static void __declspec(naked) op_resume_game() {
__asm { __asm {
call FuncOffs::map_enable_bk_processes_; call FuncOffs::map_enable_bk_processes_;
retn; retn;
} }
} }
//Create a message window with given string void __declspec(naked) op_create_message_window() {
static void __declspec(naked) op_create_message_window() {
__asm { __asm {
pushad pushad
mov ebx, dword ptr ds : [VARPTR_curr_font_num]; mov ebx, dword ptr ds : [VARPTR_curr_font_num];
@@ -265,7 +254,7 @@ end:
} }
} }
static void __declspec(naked) op_get_viewport_x() { void __declspec(naked) op_get_viewport_x() {
__asm { __asm {
push ebx; push ebx;
push ecx; push ecx;
@@ -283,7 +272,7 @@ static void __declspec(naked) op_get_viewport_x() {
} }
} }
static void __declspec(naked) op_get_viewport_y() { void __declspec(naked) op_get_viewport_y() {
__asm { __asm {
push ebx; push ebx;
push ecx; push ecx;
@@ -301,7 +290,7 @@ static void __declspec(naked) op_get_viewport_y() {
} }
} }
static void __declspec(naked) op_set_viewport_x() { void __declspec(naked) op_set_viewport_x() {
__asm { __asm {
push ebx; push ebx;
push ecx; push ecx;
@@ -313,8 +302,8 @@ static void __declspec(naked) op_set_viewport_x() {
call FuncOffs::interpretPopLong_; call FuncOffs::interpretPopLong_;
cmp dx, 0xC001; cmp dx, 0xC001;
jnz end; jnz end;
mov ds:[VARPTR_wmWorldOffsetX], eax mov ds : [VARPTR_wmWorldOffsetX], eax
end: end :
pop edx; pop edx;
pop ecx; pop ecx;
pop ebx; pop ebx;
@@ -322,7 +311,7 @@ end:
} }
} }
static void __declspec(naked) op_set_viewport_y() { void __declspec(naked) op_set_viewport_y() {
__asm { __asm {
push ebx; push ebx;
push ecx; push ecx;
@@ -334,8 +323,8 @@ static void __declspec(naked) op_set_viewport_y() {
call FuncOffs::interpretPopLong_; call FuncOffs::interpretPopLong_;
cmp dx, 0xC001; cmp dx, 0xC001;
jnz end; jnz end;
mov ds:[VARPTR_wmWorldOffsetY], eax mov ds : [VARPTR_wmWorldOffsetY], eax
end: end :
pop edx; pop edx;
pop ecx; pop ecx;
pop ebx; pop ebx;
@@ -343,7 +332,7 @@ end:
} }
} }
static void __declspec(naked) op_show_iface_tag() { void __declspec(naked) op_show_iface_tag() {
__asm { __asm {
pushad; pushad;
mov ecx, eax; mov ecx, eax;
@@ -369,7 +358,7 @@ end:
} }
} }
static void __declspec(naked) op_hide_iface_tag() { void __declspec(naked) op_hide_iface_tag() {
__asm { __asm {
pushad; pushad;
mov ecx, eax; mov ecx, eax;
@@ -395,7 +384,7 @@ end:
} }
} }
static void __declspec(naked) op_is_iface_tag_active() { void __declspec(naked) op_is_iface_tag_active() {
__asm { __asm {
pushad; pushad;
sub esp, 4; sub esp, 4;
@@ -416,14 +405,14 @@ static void __declspec(naked) op_is_iface_tag_active() {
jmp end; jmp end;
falloutfunc: falloutfunc:
mov ecx, eax; mov ecx, eax;
mov eax, dword ptr ds:[VARPTR_obj_dude]; mov eax, dword ptr ds : [VARPTR_obj_dude];
mov edx, esp; mov edx, esp;
mov eax, [eax+0x64]; mov eax, [eax + 0x64];
call FuncOffs::proto_ptr_; call FuncOffs::proto_ptr_;
mov edx, 1; mov edx, 1;
shl edx, cl; shl edx, cl;
mov ecx, [esp]; mov ecx, [esp];
mov eax, [ecx+0x20]; mov eax, [ecx + 0x20];
and eax, edx; and eax, edx;
jz fail; jz fail;
xor edx, edx; xor edx, edx;
@@ -443,19 +432,19 @@ end:
} }
} }
static void sf_intface_redraw() { void sf_intface_redraw() {
Wrapper::intface_redraw(); Wrapper::intface_redraw();
} }
static void sf_intface_show() { void sf_intface_show() {
__asm call FuncOffs::intface_show_ __asm call FuncOffs::intface_show_
} }
static void sf_intface_hide() { void sf_intface_hide() {
__asm call FuncOffs::intface_hide_ __asm call FuncOffs::intface_hide_
} }
static void sf_intface_is_hidden() { void sf_intface_is_hidden() {
int isHidden; int isHidden;
__asm { __asm {
call FuncOffs::intface_is_hidden_ call FuncOffs::intface_is_hidden_
@@ -0,0 +1,75 @@
/*
* 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
// input_functions
void __declspec() op_input_funcs_available();
void __declspec() op_key_pressed();
void __declspec() op_tap_key();
//// *** From helios *** ////
void __declspec() op_get_mouse_x();
//Return mouse y position
void __declspec() op_get_mouse_y();
//Return pressed mouse button (1=left, 2=right, 3=left+right)
void __declspec() op_get_mouse_buttons();
//Return the window number under the mous
void __declspec() op_get_window_under_mouse();
//Return screen width
void __declspec() op_get_screen_width();
//Return screen height
void __declspec() op_get_screen_height();
//Stop game, the same effect as open charsscreen or inventory
void __declspec() op_stop_game();
//Resume the game when it is stopped
void __declspec() op_resume_game();
//Create a message window with given string
void __declspec() op_create_message_window();
void __declspec() op_get_viewport_x();
void __declspec() op_get_viewport_y();
void __declspec() op_set_viewport_x();
void __declspec() op_set_viewport_y();
void __declspec() op_show_iface_tag();
void __declspec() op_hide_iface_tag();
void __declspec() op_is_iface_tag_active();
void sf_intface_redraw();
void sf_intface_show();
void sf_intface_hide();
void sf_intface_is_hidden();
@@ -1,6 +1,6 @@
/* /*
* sfall * sfall
* Copyright (C) 2008, 2009, 2010, 2012 The sfall team * Copyright (C) 2008-2016 The sfall team
* *
* This program is free software: you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by
@@ -16,13 +16,14 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>. * along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
#pragma once #include "..\..\..\FalloutEngine\Fallout2.h"
#include "..\..\..\SafeWrite.h"
#include "..\..\ScriptExtender.h"
#include "..\..\main.h" #include "Memory.h"
#include "..\ScriptExtender.h"
// memory_reading_funcs
static void __declspec(naked) op_read_byte() { void __declspec(naked) op_read_byte() {
__asm { __asm {
push ebx; push ebx;
push ecx; push ecx;
@@ -34,7 +35,7 @@ static void __declspec(naked) op_read_byte() {
call FuncOffs::interpretPopLong_; call FuncOffs::interpretPopLong_;
cmp dx, 0xC001; cmp dx, 0xC001;
jnz error; jnz error;
movzx edx, byte ptr ds:[eax]; movzx edx, byte ptr ds : [eax];
jmp result; jmp result;
error: error:
mov edx, 0; mov edx, 0;
@@ -51,7 +52,7 @@ result:
} }
} }
static void __declspec(naked) op_read_short() { void __declspec(naked) op_read_short() {
__asm { __asm {
push ebx; push ebx;
push ecx; push ecx;
@@ -63,7 +64,7 @@ static void __declspec(naked) op_read_short() {
call FuncOffs::interpretPopLong_; call FuncOffs::interpretPopLong_;
cmp dx, 0xC001; cmp dx, 0xC001;
jnz error; jnz error;
movzx edx, word ptr ds:[eax]; movzx edx, word ptr ds : [eax];
jmp result; jmp result;
error: error:
mov edx, 0; mov edx, 0;
@@ -80,7 +81,7 @@ result:
} }
} }
static void __declspec(naked) op_read_int() { void __declspec(naked) op_read_int() {
__asm { __asm {
push ebx; push ebx;
push ecx; push ecx;
@@ -92,7 +93,7 @@ static void __declspec(naked) op_read_int() {
call FuncOffs::interpretPopLong_; call FuncOffs::interpretPopLong_;
cmp dx, 0xC001; cmp dx, 0xC001;
jnz error; jnz error;
mov edx, dword ptr ds:[eax]; mov edx, dword ptr ds : [eax];
jmp result; jmp result;
error: error:
mov edx, 0; mov edx, 0;
@@ -109,7 +110,7 @@ result:
} }
} }
static void __declspec(naked) op_read_string() { void __declspec(naked) op_read_string() {
__asm { __asm {
push ebx; push ebx;
push ecx; push ecx;
@@ -138,7 +139,7 @@ result:
} }
} }
static void __declspec(naked) op_write_byte() { void __declspec(naked) op_write_byte() {
__asm { __asm {
pushad pushad
mov ecx, eax; mov ecx, eax;
@@ -167,7 +168,7 @@ end:
} }
} }
static void __declspec(naked) op_write_short() { void __declspec(naked) op_write_short() {
__asm { __asm {
pushad; pushad;
mov ecx, eax; mov ecx, eax;
@@ -196,7 +197,7 @@ end:
} }
} }
static void __declspec(naked) op_write_int() { void __declspec(naked) op_write_int() {
__asm { __asm {
pushad pushad
mov ecx, eax; mov ecx, eax;
@@ -220,7 +221,7 @@ static void __declspec(naked) op_write_int() {
call SafeWrite32; call SafeWrite32;
end: end:
popad popad
retn; retn;
} }
} }
@@ -236,7 +237,7 @@ static void _stdcall WriteStringInternal(const char* str, char* addr) {
*addr = 0; *addr = 0;
} }
static void __declspec(naked) op_write_string() { void __declspec(naked) op_write_string() {
__asm { __asm {
pushad; pushad;
mov ecx, eax; mov ecx, eax;
@@ -319,7 +320,7 @@ legal:
} }
} }
static void __declspec(naked) op_call_offset() { void __declspec(naked) op_call_offset() {
__asm { __asm {
pushad; pushad;
push eax; push eax;

Some files were not shown because too many files have changed in this diff Show More