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
//
#define DWORD unsigned long
// returns weapon animation code
char AnimCodeByWeapon(TGameObj* weapon);
+3 -3
View File
@@ -18,10 +18,10 @@
#pragma once
#include "Structs.h"
#include <cassert>
#define DWORD unsigned long
#define BYTE unsigned char
#include "..\CommonTypes.h"
#include "Structs.h"
// Global variable constants
+1 -5
View File
@@ -18,13 +18,9 @@
#pragma once
#include "..\CommonTypes.h"
#include "Structs.h"
// TODO: place this somewhere centralized...
#ifndef DWORD
#define DWORD unsigned long
#endif
//
// WRAPPERS for FO engine functions.
// 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 MiscReset();
void MiscReset();
void _stdcall SetMapMulti(float d);
+18 -18
View File
@@ -32,6 +32,7 @@
#include "HookScripts.h"
#include "LoadGameHook.h"
#include "..\Logging.h"
#include "Stats.h"
#include "Scripting\Arrays.h"
#include "Scripting\OpcodeHandler.h"
@@ -96,24 +97,8 @@ bool isGameLoading;
TScript OverrideScriptStruct;
// 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"
//END OF SCRIPT FUNCTIONS
@@ -568,7 +553,7 @@ void LoadGlobalScripts() {
//ButtonsReload();
}
static bool _stdcall ScriptHasLoaded(TProgram* script) {
bool _stdcall ScriptHasLoaded(TProgram* script) {
for (size_t d = 0; d < checkedScripts.size(); d++) {
if (checkedScripts[d] == script) {
return 0;
@@ -578,6 +563,21 @@ static bool _stdcall ScriptHasLoaded(TProgram* script) {
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
void ClearGlobalScripts() {
isGameLoading = true;
+5 -1
View File
@@ -20,6 +20,8 @@
#include "..\main.h"
#include "..\FalloutEngine\Structs.h"
// TODO: remove this
#include "Scripting\OpcodeHandler.h"
struct sGlobalVar {
__int64 id;
@@ -73,11 +75,13 @@ void RunScriptProc(sScriptProgram* prog, int procId);
void AddProgramToMap(sScriptProgram &prog);
sScriptProgram* GetGlobalScriptProgram(TProgram* scriptPtr);
char* _stdcall mysubstr(char* str, int pos, int length);
// variables
static char reg_anim_combat_check = 1;
extern DWORD isGlobalScriptLoading;
// TODO: get rid of this global variable
extern OpcodeHandler opHandler;
// types for script variables
#define VAR_TYPE_INT (0xC001)
#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
* 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
* 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/>.
*/
#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 {
pushad;
mov edi, eax;
call FuncOffs::interpretPopShort_
call FuncOffs::interpretPopShort_;
mov ebx, eax;
mov eax, edi;
call FuncOffs::interpretPopLong_;
@@ -54,24 +60,24 @@ end:
}
}
static void __declspec(naked) op_set_array() {
void __declspec(naked) op_set_array() {
__asm {
pushad;
mov ebp, eax;
//Get args
call FuncOffs::interpretPopShort_
call FuncOffs::interpretPopShort_;
mov edx, eax;
mov eax, ebp;
call FuncOffs::interpretPopLong_;
mov edi, eax; // value
mov eax, ebp;
call FuncOffs::interpretPopShort_
call FuncOffs::interpretPopShort_;
mov ecx, eax;
mov eax, ebp;
call FuncOffs::interpretPopLong_;
mov esi, eax; // key
mov eax, ebp;
call FuncOffs::interpretPopShort_
call FuncOffs::interpretPopShort_;
mov ebx, eax;
mov eax, ebp;
call FuncOffs::interpretPopLong_;
@@ -107,29 +113,25 @@ notstring1:
push ecx; // arg 3: key type
push esi; // arg 2: key
push edi; // arg 1: arrayID
call SetArray
call SetArray;
end:
popad;
retn;
}
}
/*
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() {
void __declspec(naked) op_get_array() {
__asm {
pushad;
mov ebp, eax;
//Get args
call FuncOffs::interpretPopShort_
call FuncOffs::interpretPopShort_;
mov ebx, eax;
mov eax, ebp;
call FuncOffs::interpretPopLong_;
mov edi, eax;
mov eax, ebp;
call FuncOffs::interpretPopShort_
call FuncOffs::interpretPopShort_;
mov ecx, eax;
mov eax, ebp;
call FuncOffs::interpretPopLong_;
@@ -202,7 +204,7 @@ notstring:
}
}
static void __declspec(naked) op_free_array() {
void __declspec(naked) op_free_array() {
__asm {
pushad;
mov edi, eax;
@@ -220,7 +222,7 @@ end:
}
}
static void __declspec(naked) op_len_array() {
void __declspec(naked) op_len_array() {
__asm {
pushad;
mov edi, eax;
@@ -247,18 +249,18 @@ end:
}
}
static void __declspec(naked) op_resize_array() {
void __declspec(naked) op_resize_array() {
__asm {
pushad;
mov ebp, eax;
//Get args
call FuncOffs::interpretPopShort_
call FuncOffs::interpretPopShort_;
mov ebx, eax;
mov eax, ebp;
call FuncOffs::interpretPopLong_;
mov edi, eax;
mov eax, ebp;
call FuncOffs::interpretPopShort_
call FuncOffs::interpretPopShort_;
mov ecx, eax;
mov eax, ebp;
call FuncOffs::interpretPopLong_;
@@ -278,11 +280,11 @@ end:
}
}
static void __declspec(naked) op_temp_array() {
void __declspec(naked) op_temp_array() {
__asm {
pushad;
mov edi, eax;
call FuncOffs::interpretPopShort_
call FuncOffs::interpretPopShort_;
mov ebx, eax;
mov eax, edi;
call FuncOffs::interpretPopLong_;
@@ -314,7 +316,7 @@ end:
}
}
static void __declspec(naked) op_fix_array() {
void __declspec(naked) op_fix_array() {
__asm {
pushad;
mov edi, eax;
@@ -332,18 +334,18 @@ end:
}
}
static void __declspec(naked) op_scan_array() {
__asm {
void __declspec(naked) op_scan_array() {
__asm {
pushad;
mov ebp, eax;
//Get args
call FuncOffs::interpretPopShort_
call FuncOffs::interpretPopShort_;
mov edx, eax;
mov eax, ebp;
call FuncOffs::interpretPopLong_;
mov edi, eax; // value (needle)
mov eax, ebp;
call FuncOffs::interpretPopShort_
call FuncOffs::interpretPopShort_;
mov ecx, eax;
mov eax, ebp;
call FuncOffs::interpretPopLong_;
@@ -391,18 +393,18 @@ resultnotstr:
}
}
static void __declspec(naked) op_save_array() {
void __declspec(naked) op_save_array() {
_OP_BEGIN(ebp)
// Get args
_GET_ARG_R32(ebp, ebx, edi)
_GET_ARG_R32(ebp, edx, ecx)
__asm {
// arg check:
_GET_ARG_R32(ebp, ebx, edi)
_GET_ARG_R32(ebp, edx, ecx)
__asm {
// arg check:
cmp bx, VAR_TYPE_INT
jne end
}
_CHECK_PARSE_STR(1, ebp, dx, ecx)
__asm {
__asm {
push edi // arg 3: arrayID
push edx // arg 2: keyType
push ecx // arg 1: key
@@ -412,7 +414,7 @@ end:
_OP_END
}
static void __declspec(naked) op_load_array() {
void __declspec(naked) op_load_array() {
_OP_BEGIN(ebp)
_GET_ARG_R32(ebp, edx, ecx)
_CHECK_PARSE_STR(1, ebp, dx, ecx)
@@ -425,12 +427,12 @@ static void __declspec(naked) op_load_array() {
_OP_END
}
static void __declspec(naked) op_get_array_key() {
void __declspec(naked) op_get_array_key() {
_OP_BEGIN(ebp)
_GET_ARG_R32(ebp, edx, ecx) // index
_GET_ARG_R32(ebp, ebx, edi) // arrayID
__asm {
// arg check:
// arg check:
cmp bx, VAR_TYPE_INT;
jne wrongarg;
cmp dx, VAR_TYPE_INT;
@@ -441,17 +443,17 @@ static void __declspec(naked) op_get_array_key() {
call GetArrayKey;
}
_RET_VAL_POSSIBLY_STR(1, ebp, [esp])
goto end;
goto end;
__asm {
wrongarg:
xor eax, eax; // return 0 on wrong arguments
}
_RET_VAL_INT(ebp)
end:
end:
_OP_END
}
static void __declspec(naked) op_stack_array() {
void __declspec(naked) op_stack_array() {
_OP_BEGIN(ebp)
_GET_ARG_R32(ebp, edx, esi) // value
_GET_ARG_R32(ebp, ebx, edi) // key
@@ -460,12 +462,12 @@ static void __declspec(naked) op_stack_array() {
push ebx
}
_CHECK_PARSE_STR(1, ebp, dx, esi)
__asm {
__asm {
pop ebx
mov ecx, ebx
}
_CHECK_PARSE_STR(2, ebp, bx, edi)
__asm {
__asm {
push esi // arg 3: value
push ecx // arg 2: keyType
push edi // arg 1: key
@@ -475,6 +477,8 @@ static void __declspec(naked) op_stack_array() {
_OP_END
}
// object LISTS
struct sList {
@@ -493,7 +497,6 @@ struct sList {
};
static void FillListVector(DWORD type, std::vector<TGameObj*>& vec) {
// TODO: fix style, use wrappers
if (type == 6) {
TScript* scriptPtr;
TGameObj* self_obj;
@@ -563,7 +566,8 @@ static void _stdcall list_end2(sList* list) {
delete list;
}
static void __declspec(naked) op_list_begin() {
void __declspec(naked) op_list_begin() {
__asm {
pushad;
mov ebp, eax;
@@ -591,7 +595,7 @@ end:
}
}
static void __declspec(naked) op_list_as_array() {
void __declspec(naked) op_list_as_array() {
__asm {
pushad;
mov ebp, eax;
@@ -619,7 +623,7 @@ end:
}
}
static void __declspec(naked) op_list_next() {
void __declspec(naked) op_list_next() {
__asm {
pushad;
mov ebp, eax;
@@ -647,7 +651,7 @@ end:
}
}
static void __declspec(naked) op_list_end() {
void __declspec(naked) op_list_end() {
__asm {
pushad;
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
#include "..\OpcodeHandler.h"
/*
MACROS for operators assembly code
@@ -1,6 +1,6 @@
/*
* 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
* 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/>.
*/
#pragma once
#include "..\..\..\FalloutEngine\Fallout2.h"
#include "..\..\ScriptExtender.h"
#include "..\..\FileSystem.h"
#include "..\..\main.h"
#include "FileSystem.h"
#include "..\FileSystem.h"
#include "..\ScriptExtender.h"
//file system functions
static void __declspec(naked) op_fs_create() {
void __declspec(naked) op_fs_create() {
__asm {
pushad;
mov edi, eax;
@@ -67,7 +65,7 @@ end:
}
}
static void __declspec(naked) op_fs_copy() {
void __declspec(naked) op_fs_copy() {
__asm {
pushad;
mov ebp, eax;
@@ -118,7 +116,7 @@ end:
}
}
static void __declspec(naked) op_fs_find() {
void __declspec(naked) op_fs_find() {
__asm {
pushad;
mov ebp, eax;
@@ -153,7 +151,7 @@ end:
}
}
static void __declspec(naked) op_fs_write_byte() {
void __declspec(naked) op_fs_write_byte() {
__asm {
pushad;
mov ebp, eax;
@@ -180,7 +178,7 @@ end:
}
}
static void __declspec(naked) op_fs_write_short() {
void __declspec(naked) op_fs_write_short() {
__asm {
pushad;
mov ebp, eax;
@@ -207,7 +205,7 @@ end:
}
}
static void __declspec(naked) op_fs_write_int() {
void __declspec(naked) op_fs_write_int() {
__asm {
pushad;
mov ebp, eax;
@@ -237,7 +235,7 @@ end:
}
}
static void __declspec(naked) op_fs_write_string() {
void __declspec(naked) op_fs_write_string() {
__asm {
pushad;
mov edi, eax;
@@ -272,7 +270,7 @@ end:
}
}
static void __declspec(naked) op_fs_write_bstring() {
void __declspec(naked) op_fs_write_bstring() {
__asm {
pushad;
mov edi, eax;
@@ -307,7 +305,7 @@ end:
}
}
static void __declspec(naked) op_fs_read_byte() {
void __declspec(naked) op_fs_read_byte() {
__asm {
pushad;
mov ebp, eax;
@@ -335,7 +333,7 @@ end:
}
}
static void __declspec(naked) op_fs_read_short() {
void __declspec(naked) op_fs_read_short() {
__asm {
pushad;
mov ebp, eax;
@@ -363,7 +361,7 @@ end:
}
}
static void __declspec(naked) op_fs_read_int() {
void __declspec(naked) op_fs_read_int() {
__asm {
pushad;
mov ebp, eax;
@@ -391,7 +389,7 @@ end:
}
}
static void __declspec(naked) op_fs_read_float() {
void __declspec(naked) op_fs_read_float() {
__asm {
pushad;
mov ebp, eax;
@@ -419,7 +417,7 @@ end:
}
}
static void __declspec(naked) op_fs_delete() {
void __declspec(naked) op_fs_delete() {
__asm {
pushad;
mov ebp, eax;
@@ -429,7 +427,7 @@ static void __declspec(naked) op_fs_delete() {
call FuncOffs::interpretPopLong_;
cmp di, 0xc001;
jnz end
push eax;
push eax;
call FSdelete;
end:
popad;
@@ -437,7 +435,7 @@ end:
}
}
static void __declspec(naked) op_fs_size() {
void __declspec(naked) op_fs_size() {
__asm {
pushad;
mov ebp, eax;
@@ -465,7 +463,7 @@ end:
}
}
static void __declspec(naked) op_fs_pos() {
void __declspec(naked) op_fs_pos() {
__asm {
pushad;
mov ebp, eax;
@@ -493,7 +491,7 @@ end:
}
}
static void __declspec(naked) op_fs_seek() {
void __declspec(naked) op_fs_seek() {
__asm {
pushad;
mov ebp, eax;
@@ -520,7 +518,7 @@ end:
}
}
static void __declspec(naked) op_fs_resize() {
void __declspec(naked) op_fs_resize() {
__asm {
pushad;
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
* 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
* 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/>.
*/
#pragma once
#include "..\..\..\main.h"
#include "..\..\..\InputFuncs.h"
#include "..\..\..\FalloutEngine\Fallout2.h"
#include "..\..\Graphics.h"
#include "..\..\ScriptExtender.h"
#include "..\..\main.h"
#include "..\..\InputFuncs.h"
#include "..\Graphics.h"
#include "..\ScriptExtender.h"
#include "Graphics.h"
// graphics_functions
static void __declspec(naked) op_graphics_funcs_available() {
void __declspec(naked) op_graphics_funcs_available() {
__asm {
push ebx;
push ecx;
@@ -47,7 +47,7 @@ end:
}
}
static void __declspec(naked) op_load_shader() {
void __declspec(naked) op_load_shader() {
__asm {
push ebx;
push ecx;
@@ -86,7 +86,7 @@ result:
}
}
static void __declspec(naked) op_free_shader() {
void __declspec(naked) op_free_shader() {
__asm {
push ebx;
push ecx;
@@ -108,7 +108,7 @@ end:
}
}
static void __declspec(naked) op_activate_shader() {
void __declspec(naked) op_activate_shader() {
__asm {
push ebx;
push ecx;
@@ -130,7 +130,7 @@ end:
}
}
static void __declspec(naked) op_deactivate_shader() {
void __declspec(naked) op_deactivate_shader() {
__asm {
push ebx;
push ecx;
@@ -152,7 +152,7 @@ end:
}
}
static void __declspec(naked) op_get_shader_texture() {
void __declspec(naked) op_get_shader_texture() {
__asm {
//Store registers
push ebx;
@@ -162,19 +162,19 @@ static void __declspec(naked) op_get_shader_texture() {
//Get function args
mov ecx, eax;
call FuncOffs::interpretPopShort_;
push eax
push eax;
mov eax, ecx;
call FuncOffs::interpretPopLong_;
mov edi, eax;
mov eax, ecx;
call FuncOffs::interpretPopShort_;
push eax
push eax;
mov eax, ecx;
call FuncOffs::interpretPopLong_;
mov ebx, [esp];
cmp bx, 0xC001;
jnz fail;
mov ebx, [esp+4];
mov ebx, [esp + 4];
cmp bx, 0xc001;
jnz fail;
//set the new value
@@ -186,7 +186,7 @@ static void __declspec(naked) op_get_shader_texture() {
pop ecx;
jmp end;
fail:
mov edx, -1
mov edx, -1;
end:
//Pass back the result
mov eax, ecx;
@@ -204,7 +204,7 @@ end:
}
}
static void __declspec(naked) op_set_shader_int() {
void __declspec(naked) op_set_shader_int() {
__asm {
push ebx;
push ecx;
@@ -219,7 +219,7 @@ static void __declspec(naked) op_set_shader_int() {
mov edi, eax;
mov eax, ecx;
call FuncOffs::interpretPopLong_;
mov [esp+8], eax;
mov[esp + 8], eax;
mov eax, ecx;
call FuncOffs::interpretPopShort_;
mov edx, eax;
@@ -231,7 +231,7 @@ static void __declspec(naked) op_set_shader_int() {
mov esi, eax;
mov eax, ecx;
call FuncOffs::interpretPopLong_;
mov [esp], eax;
mov[esp], eax;
//Error check
cmp di, 0xC001;
jnz fail;
@@ -245,7 +245,7 @@ next:
mov eax, ecx;
mov ebx, ebp;
call FuncOffs::interpretGetString_;
mov [esp+4], eax;
mov[esp + 4], eax;
call SetShaderInt;
jmp end;
fail:
@@ -261,7 +261,7 @@ end:
}
}
static void __declspec(naked) op_set_shader_texture() {
void __declspec(naked) op_set_shader_texture() {
__asm {
push ebx;
push ecx;
@@ -276,7 +276,7 @@ static void __declspec(naked) op_set_shader_texture() {
mov edi, eax;
mov eax, ecx;
call FuncOffs::interpretPopLong_;
mov [esp+8], eax;
mov[esp + 8], eax;
mov eax, ecx;
call FuncOffs::interpretPopShort_;
mov edx, eax;
@@ -288,7 +288,7 @@ static void __declspec(naked) op_set_shader_texture() {
mov esi, eax;
mov eax, ecx;
call FuncOffs::interpretPopLong_;
mov [esp], eax;
mov[esp], eax;
//Error check
cmp di, 0xC001;
jnz fail;
@@ -302,7 +302,7 @@ next:
mov eax, ecx;
mov ebx, ebp;
call FuncOffs::interpretGetString_;
mov [esp+4], eax;
mov[esp + 4], eax;
call SetShaderTexture;
jmp end;
fail:
@@ -318,7 +318,7 @@ end:
}
}
static void __declspec(naked) op_set_shader_float() {
void __declspec(naked) op_set_shader_float() {
__asm {
push ebx;
push ecx;
@@ -333,7 +333,7 @@ static void __declspec(naked) op_set_shader_float() {
mov edi, eax;
mov eax, ecx;
call FuncOffs::interpretPopLong_;
mov [esp+8], eax;
mov[esp + 8], eax;
mov eax, ecx;
call FuncOffs::interpretPopShort_;
mov edx, eax;
@@ -345,14 +345,14 @@ static void __declspec(naked) op_set_shader_float() {
mov esi, eax;
mov eax, ecx;
call FuncOffs::interpretPopLong_;
mov [esp], eax;
mov[esp], eax;
//Error check
cmp di, 0xa001;
jz paramWasFloat;
cmp di, 0xc001;
jnz fail;
fild [esp+8];
fstp [esp+8];
fild[esp + 8];
fstp[esp + 8];
paramWasFloat:
cmp dx, 0x9001;
jz next;
@@ -364,7 +364,7 @@ next:
mov eax, ecx;
mov ebx, ebp;
call FuncOffs::interpretGetString_;
mov [esp+4], eax;
mov[esp + 4], eax;
call SetShaderFloat;
jmp end;
fail:
@@ -380,7 +380,7 @@ end:
}
}
static void __declspec(naked) op_set_shader_vector() {
void __declspec(naked) op_set_shader_vector() {
__asm {
push ebx;
push ecx;
@@ -393,35 +393,35 @@ static void __declspec(naked) op_set_shader_vector() {
argloopstart:
mov eax, ebp;
call FuncOffs::interpretPopShort_;
mov word ptr [esp+ecx*2+0x16], ax;
mov word ptr[esp + ecx * 2 + 0x16], ax;
mov eax, ebp;
call FuncOffs::interpretPopLong_;
mov [esp+ecx*4-0x4], eax;
mov[esp + ecx * 4 - 0x4], eax;
loop argloopstart;
//Error check
mov ecx, 4;
checkloopstart:
cmp word ptr [esp+ecx*2+0x1a], 0xa001;
cmp word ptr[esp + ecx * 2 + 0x1a], 0xa001;
jz paramWasFloat;
cmp word ptr [esp+ecx*2+0x1a], 0xc001;
cmp word ptr[esp + ecx * 2 + 0x1a], 0xc001;
jnz fail;
fild [esp+ecx*4+0x4];
fstp [esp+ecx*4+0x4];
fild[esp + ecx * 4 + 0x4];
fstp[esp + ecx * 4 + 0x4];
paramWasFloat:
loop checkloopstart;
cmp word ptr [esp+0x1a], 0x9001;
cmp word ptr[esp + 0x1a], 0x9001;
jz next;
cmp word ptr [esp+0x1a], 0x9801;
cmp word ptr[esp + 0x1a], 0x9801;
jnz fail;
next:
cmp word ptr [esp+0x18], 0xc001;
cmp word ptr[esp + 0x18], 0xc001;
jnz fail;
mov eax, ebp;
mov ebx, [esp+4];
mov ebx, [esp + 4];
xor edx, edx;
mov dx, word ptr [esp+0x1a];
mov dx, word ptr[esp + 0x1a];
call FuncOffs::interpretGetString_;
mov [esp+4], eax;
mov[esp + 4], eax;
call SetShaderVector;
add esp, 0x12;
jmp end;
@@ -436,7 +436,7 @@ end:
}
}
static void __declspec(naked) op_get_shader_version() {
void __declspec(naked) op_get_shader_version() {
__asm {
push ebx;
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 {
push ebx;
push ecx;
@@ -481,7 +481,7 @@ static void __declspec(naked) op_set_shader_mode() {
jnz fail;
push eax;
call SetShaderMode;
jmp end
jmp end;
fail:
pop eax;
end:
@@ -493,7 +493,7 @@ end:
}
}
static void __declspec(naked) op_force_graphics_refresh() {
void __declspec(naked) op_force_graphics_refresh() {
__asm {
push ebx;
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
* 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
* 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/>.
*/
#pragma once
#include "..\..\..\FalloutEngine\Fallout2.h"
#include "..\..\..\InputFuncs.h"
#include "..\..\BarBoxes.h"
#include "..\..\ScriptExtender.h"
#include "..\..\main.h"
#include "Interface.h"
#include "..\InputFuncs.h"
#include "..\ScriptExtender.h"
// input_functions
static void __declspec(naked) op_input_funcs_available() {
void __declspec(naked) op_input_funcs_available() {
__asm {
push ebx;
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 {
push ebx;
push ecx;
@@ -76,7 +74,7 @@ end:
}
}
static void __declspec(naked) op_tap_key() {
void __declspec(naked) op_tap_key() {
__asm {
push ebx;
push ecx;
@@ -102,83 +100,78 @@ end:
}
}
//// *** From helios *** ////
static void __declspec(naked) op_get_mouse_x() {
__asm {
push ecx;
push edx;
mov ecx, eax;
mov edx, ds:[VARPTR_mouse_x_];
add edx, ds:[VARPTR_mouse_hotx];
call FuncOffs::interpretPushLong_;
mov eax, ecx;
mov edx, 0xc001;
call FuncOffs::interpretPushShort_
pop edx;
pop ecx;
retn;
}
void __declspec(naked) op_get_mouse_x() {
__asm {
push ecx;
push edx;
mov ecx, eax;
mov edx, ds:[VARPTR_mouse_x_];
add edx, ds:[VARPTR_mouse_hotx];
call FuncOffs::interpretPushLong_;
mov eax, ecx;
mov edx, 0xc001;
call FuncOffs::interpretPushShort_
pop edx;
pop ecx;
retn;
}
}
//Return mouse y position
static void __declspec(naked) op_get_mouse_y() {
__asm {
push ecx;
push edx;
mov ecx, eax;
mov edx, ds:[VARPTR_mouse_y_];
add edx, ds:[VARPTR_mouse_hoty];
call FuncOffs::interpretPushLong_;
mov eax, ecx;
mov edx, 0xc001;
call FuncOffs::interpretPushShort_
pop edx;
pop ecx;
retn;
}
void __declspec(naked) op_get_mouse_y() {
__asm {
push ecx;
push edx;
mov ecx, eax;
mov edx, ds:[VARPTR_mouse_y_];
add edx, ds:[VARPTR_mouse_hoty];
call FuncOffs::interpretPushLong_;
mov eax, ecx;
mov edx, 0xc001;
call FuncOffs::interpretPushShort_
pop edx;
pop ecx;
retn;
}
}
//Return pressed mouse button (1=left, 2=right, 3=left+right)
static void __declspec(naked) op_get_mouse_buttons() {
__asm {
push ecx;
push edx;
mov ecx, eax;
mov edx, ds:[VARPTR_last_buttons];
call FuncOffs::interpretPushLong_;
mov eax, ecx;
mov edx, 0xc001;
call FuncOffs::interpretPushShort_
pop edx;
pop ecx;
retn;
}
void __declspec(naked) op_get_mouse_buttons() {
__asm {
push ecx;
push edx;
mov ecx, eax;
mov edx, ds:[VARPTR_last_buttons];
call FuncOffs::interpretPushLong_;
mov eax, ecx;
mov edx, 0xc001;
call FuncOffs::interpretPushShort_
pop edx;
pop ecx;
retn;
}
}
//Return the window number under the mous
static void __declspec(naked) op_get_window_under_mouse() {
__asm {
push ecx;
push edx;
mov ecx, eax;
mov edx, ds:[VARPTR_last_button_winID];
call FuncOffs::interpretPushLong_;
mov eax, ecx;
mov edx, 0xc001;
call FuncOffs::interpretPushShort_
pop edx;
pop ecx;
retn;
}
void __declspec(naked) op_get_window_under_mouse() {
__asm {
push ecx;
push edx;
mov ecx, eax;
mov edx, ds:[VARPTR_last_button_winID];
call FuncOffs::interpretPushLong_;
mov eax, ecx;
mov edx, 0xc001;
call FuncOffs::interpretPushShort_
pop edx;
pop ecx;
retn;
}
}
//Return screen width
static void __declspec(naked) op_get_screen_width() {
void __declspec(naked) op_get_screen_width() {
__asm {
push edx
push eax
mov edx, ds:[VARPTR_scr_size+8] // _scr_size.offx
sub edx, ds:[VARPTR_scr_size] // _scr_size.x
mov edx, ds:[VARPTR_scr_size + 8] // _scr_size.offx
sub edx, ds : [VARPTR_scr_size] // _scr_size.x
inc edx
call FuncOffs::interpretPushLong_
pop eax
@@ -189,13 +182,12 @@ static void __declspec(naked) op_get_screen_width() {
}
}
//Return screen height
static void __declspec(naked) op_get_screen_height() {
void __declspec(naked) op_get_screen_height() {
__asm {
push edx
push eax
mov edx, ds:[VARPTR_scr_size+12] // _scr_size.offy
sub edx, ds:[VARPTR_scr_size+4] // _scr_size.y
mov edx, ds:[VARPTR_scr_size + 12] // _scr_size.offy
sub edx, ds : [VARPTR_scr_size + 4] // _scr_size.y
inc edx
call FuncOffs::interpretPushLong_
pop eax
@@ -206,24 +198,21 @@ static void __declspec(naked) op_get_screen_height() {
}
}
//Stop game, the same effect as open charsscreen or inventory
static void __declspec(naked) op_stop_game() {
void __declspec(naked) op_stop_game() {
__asm {
call FuncOffs::map_disable_bk_processes_;
retn;
}
}
//Resume the game when it is stopped
static void __declspec(naked) op_resume_game() {
void __declspec(naked) op_resume_game() {
__asm {
call FuncOffs::map_enable_bk_processes_;
retn;
}
}
//Create a message window with given string
static void __declspec(naked) op_create_message_window() {
void __declspec(naked) op_create_message_window() {
__asm {
pushad
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 {
push ebx;
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 {
push ebx;
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 {
push ebx;
push ecx;
@@ -313,8 +302,8 @@ static void __declspec(naked) op_set_viewport_x() {
call FuncOffs::interpretPopLong_;
cmp dx, 0xC001;
jnz end;
mov ds:[VARPTR_wmWorldOffsetX], eax
end:
mov ds : [VARPTR_wmWorldOffsetX], eax
end :
pop edx;
pop ecx;
pop ebx;
@@ -322,7 +311,7 @@ end:
}
}
static void __declspec(naked) op_set_viewport_y() {
void __declspec(naked) op_set_viewport_y() {
__asm {
push ebx;
push ecx;
@@ -334,8 +323,8 @@ static void __declspec(naked) op_set_viewport_y() {
call FuncOffs::interpretPopLong_;
cmp dx, 0xC001;
jnz end;
mov ds:[VARPTR_wmWorldOffsetY], eax
end:
mov ds : [VARPTR_wmWorldOffsetY], eax
end :
pop edx;
pop ecx;
pop ebx;
@@ -343,7 +332,7 @@ end:
}
}
static void __declspec(naked) op_show_iface_tag() {
void __declspec(naked) op_show_iface_tag() {
__asm {
pushad;
mov ecx, eax;
@@ -369,7 +358,7 @@ end:
}
}
static void __declspec(naked) op_hide_iface_tag() {
void __declspec(naked) op_hide_iface_tag() {
__asm {
pushad;
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 {
pushad;
sub esp, 4;
@@ -416,14 +405,14 @@ static void __declspec(naked) op_is_iface_tag_active() {
jmp end;
falloutfunc:
mov ecx, eax;
mov eax, dword ptr ds:[VARPTR_obj_dude];
mov eax, dword ptr ds : [VARPTR_obj_dude];
mov edx, esp;
mov eax, [eax+0x64];
mov eax, [eax + 0x64];
call FuncOffs::proto_ptr_;
mov edx, 1;
shl edx, cl;
mov ecx, [esp];
mov eax, [ecx+0x20];
mov eax, [ecx + 0x20];
and eax, edx;
jz fail;
xor edx, edx;
@@ -443,19 +432,19 @@ end:
}
}
static void sf_intface_redraw() {
void sf_intface_redraw() {
Wrapper::intface_redraw();
}
static void sf_intface_show() {
void sf_intface_show() {
__asm call FuncOffs::intface_show_
}
static void sf_intface_hide() {
void sf_intface_hide() {
__asm call FuncOffs::intface_hide_
}
static void sf_intface_is_hidden() {
void sf_intface_is_hidden() {
int isHidden;
__asm {
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
* 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
* 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/>.
*/
#pragma once
#include "..\..\..\FalloutEngine\Fallout2.h"
#include "..\..\..\SafeWrite.h"
#include "..\..\ScriptExtender.h"
#include "..\..\main.h"
#include "..\ScriptExtender.h"
#include "Memory.h"
// memory_reading_funcs
static void __declspec(naked) op_read_byte() {
void __declspec(naked) op_read_byte() {
__asm {
push ebx;
push ecx;
@@ -34,7 +35,7 @@ static void __declspec(naked) op_read_byte() {
call FuncOffs::interpretPopLong_;
cmp dx, 0xC001;
jnz error;
movzx edx, byte ptr ds:[eax];
movzx edx, byte ptr ds : [eax];
jmp result;
error:
mov edx, 0;
@@ -51,7 +52,7 @@ result:
}
}
static void __declspec(naked) op_read_short() {
void __declspec(naked) op_read_short() {
__asm {
push ebx;
push ecx;
@@ -63,7 +64,7 @@ static void __declspec(naked) op_read_short() {
call FuncOffs::interpretPopLong_;
cmp dx, 0xC001;
jnz error;
movzx edx, word ptr ds:[eax];
movzx edx, word ptr ds : [eax];
jmp result;
error:
mov edx, 0;
@@ -80,7 +81,7 @@ result:
}
}
static void __declspec(naked) op_read_int() {
void __declspec(naked) op_read_int() {
__asm {
push ebx;
push ecx;
@@ -92,7 +93,7 @@ static void __declspec(naked) op_read_int() {
call FuncOffs::interpretPopLong_;
cmp dx, 0xC001;
jnz error;
mov edx, dword ptr ds:[eax];
mov edx, dword ptr ds : [eax];
jmp result;
error:
mov edx, 0;
@@ -109,7 +110,7 @@ result:
}
}
static void __declspec(naked) op_read_string() {
void __declspec(naked) op_read_string() {
__asm {
push ebx;
push ecx;
@@ -138,7 +139,7 @@ result:
}
}
static void __declspec(naked) op_write_byte() {
void __declspec(naked) op_write_byte() {
__asm {
pushad
mov ecx, eax;
@@ -167,7 +168,7 @@ end:
}
}
static void __declspec(naked) op_write_short() {
void __declspec(naked) op_write_short() {
__asm {
pushad;
mov ecx, eax;
@@ -196,7 +197,7 @@ end:
}
}
static void __declspec(naked) op_write_int() {
void __declspec(naked) op_write_int() {
__asm {
pushad
mov ecx, eax;
@@ -220,7 +221,7 @@ static void __declspec(naked) op_write_int() {
call SafeWrite32;
end:
popad
retn;
retn;
}
}
@@ -236,7 +237,7 @@ static void _stdcall WriteStringInternal(const char* str, char* addr) {
*addr = 0;
}
static void __declspec(naked) op_write_string() {
void __declspec(naked) op_write_string() {
__asm {
pushad;
mov ecx, eax;
@@ -319,7 +320,7 @@ legal:
}
}
static void __declspec(naked) op_call_offset() {
void __declspec(naked) op_call_offset() {
__asm {
pushad;
push eax;

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