Replaced ASM code in various opcodes with macros (from Mr.Stalin)

Unified the directory separator in documents.
Updated version number.
This commit is contained in:
NovaRain
2019-04-30 10:38:39 +08:00
parent 7500e6b637
commit 3c255085ed
14 changed files with 445 additions and 739 deletions
+5 -5
View File
@@ -1,12 +1,12 @@
;sfall configuration settings
;v3.8.17
;v3.8.18
[Main]
;Change to 1 if you want to use command line args to tell sfall to use another ini file.
UseCommandLine=0
;Uncomment and point to a file to get alternate translations for some sfall messages
;TranslationsINI=./Translations.ini
;TranslationsINI=.\Translations.ini
;XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
[Sound]
@@ -71,7 +71,7 @@ GraphicsHeight=0
GPUBlt=0
;Set to 1 to allow using 32-bit textures for talking heads
;The texture files should be placed in art/heads/<name of the talking head FRM file>/ (w/o extension)
;The texture files should be placed in art\heads\<name of the talking head FRM file>\ (w/o extension)
;The files in the folder should be numbered according to the number of frames in the talking head FRM file (0.png, 1.png, etc.)
;See the text file in the modders pack for a detailed description
;Requires DX9 graphics mode and v2.0 pixel shader support (see GPUBlt option)
@@ -376,7 +376,7 @@ ProcessorIdle=-1
LoadProtoMaxLimit=-1
;Set to 1 if using the hero appearance mod
;You can add AppChCrt.frm and AppChEdt.frm files to art/intrface/ to set a custom background for the character screen
;You can add AppChCrt.frm and AppChEdt.frm files to art\intrface\ to set a custom background for the character screen
EnableHeroAppearanceMod=0
;Set to 1 to skip the 3 opening movies
@@ -396,7 +396,7 @@ AIDrugUsePerfFix=0
;Allows the use of tiles over 80*36 in size. sfall will just split and resave them at startup
;Set to 1 to check all tiles on started (slow)
;Set to 2 if you provide a XLtiles.lst file in art/tiles/ containing a list of the tile ids that need checking
;Set to 2 if you provide a XLtiles.lst file in art\tiles\ containing a list of the tile ids that need checking
AllowLargeTiles=0
;Set to 1 to boost the maximum number of tile FRMs from 4096 to 16383
+1 -1
View File
@@ -303,7 +303,7 @@ Some utility/math functions are available:
- see "hookscripts.txt" for more details
> string message_str_game(int fileId, int messageId)
- works exactly the same as message_str, except you get messages from files in "text/english/game" folder
- works exactly the same as message_str, except you get messages from files in "text\<language>\game\" directory
- use GAME_MSG_* defines or mstr_* macros from sfall.h to use specific msg file
- Additional game msg files added by ExtraGameMsgFileList setting will have consecutive fileIds assigned beginning from 0x2000. (e.g. if you set ExtraGameMsgFileList=foo,bar in ddraw.ini, foo.msg will be associated with 0x2000 and bar.msg with 0x2001.)
+3 -3
View File
@@ -31,10 +31,10 @@ static const DWORD extraKillTypesCountAddr[] = {
0x4344E4, // Change char sheet to loop through the extra kill types
};
static int usingExtraKillTypes = 0;
static bool usingExtraKillTypes = false;
bool UsingExtraKillTypes() {
return usingExtraKillTypes != 0;
return usingExtraKillTypes;
}
static DWORD __declspec(naked) ReadKillCounter() {
@@ -53,7 +53,7 @@ static void __declspec(naked) IncKillCounter() {
}
void KillCounterInit() {
usingExtraKillTypes = 1;
usingExtraKillTypes = true;
// Overwrite the critter_kill_count_ function that reads the kill counter
MakeCall(0x42D8B5, ReadKillCounter, 2);
+41 -74
View File
@@ -512,18 +512,13 @@ static void __declspec(naked) SetGlobalScriptRepeat() {
__asm {
push ecx;
push edx;
mov ecx, eax;
call interpretPopShort_;
mov edx, eax;
mov eax, ecx;
call interpretPopLong_;
cmp dx, VAR_TYPE_INT;
jnz end;
mov edx, eax; // frames
mov ecx, eax;
_GET_ARG_INT(end);
mov edx, eax; // frames
call SetGlobalScriptRepeat2; // ecx - script
end:
pop edx;
pop ecx;
pop edx;
pop ecx;
retn;
}
}
@@ -543,14 +538,9 @@ static void __declspec(naked) SetGlobalScriptType() {
__asm {
push ecx;
push edx;
mov ecx, eax;
call interpretPopShort_;
mov edx, eax;
mov eax, ecx;
call interpretPopLong_;
cmp dx, VAR_TYPE_INT;
jnz end;
mov edx, eax; // type
mov ecx, eax;
_GET_ARG_INT(end);
mov edx, eax; // type
call SetGlobalScriptType2; // ecx - script
end:
pop edx;
@@ -563,14 +553,10 @@ static void __declspec(naked) GetGlobalScriptTypes() {
__asm {
push ecx;
push edx;
mov edx, AvailableGlobalScriptTypes;
mov ecx, eax;
call interpretPushLong_;
mov edx, VAR_TYPE_INT;
mov eax, ecx;
call interpretPushShort_;
pop edx;
pop ecx;
mov edx, AvailableGlobalScriptTypes;
_RET_VAL_INT2(ecx);
pop edx;
pop ecx;
retn;
}
}
@@ -607,7 +593,7 @@ static void SetGlobalVarFunc() {
if ((varArg.isInt() || varArg.isString()) && (valArg.isInt() || valArg.isFloat())) {
if (varArg.isString()) {
if (SetGlobalVar2(varArg.strValue(), valArg.rawValue())) {
opHandler.printOpcodeError("set_sfall_global() - The name of the global variable must consist of 8 characters.");
opHandler.printOpcodeError("set_sfall_global() - the name of the global variable must consist of 8 characters.");
}
} else {
SetGlobalVar2Int(varArg.rawValue(), valArg.rawValue());
@@ -649,7 +635,7 @@ static void GetGlobalVarIntFunc() {
if (varArg.isString()) {
const char* var = varArg.strValue();
if (strlen(var) != 8) {
opHandler.printOpcodeError("get_sfall_global_int() - The name of the global variable must consist of 8 characters.");
opHandler.printOpcodeError("get_sfall_global_int() - the name of the global variable must consist of 8 characters.");
} else {
result = GetGlobalVarInternal(*(__int64*)var);
}
@@ -695,17 +681,15 @@ static void __declspec(naked) GetGlobalVarFloat() {
static void __declspec(naked) GetSfallArg() {
__asm {
pushad;
push ecx;
push edx;
push eax;
call GetHSArg;
pop ecx;
mov edx, eax;
mov eax, ecx;
call interpretPushLong_;
mov eax, ecx;
mov edx, VAR_TYPE_INT;
call interpretPushShort_;
popad;
mov edx, eax;
pop eax;
_RET_VAL_INT2(ecx);
pop edx;
pop ecx;
retn;
}
}
@@ -722,17 +706,15 @@ static DWORD _stdcall GetSfallArgs2() {
static void __declspec(naked) GetSfallArgs() {
__asm {
pushad;
push ecx;
push edx;
push eax;
call GetSfallArgs2;
pop ecx;
mov edx, eax;
mov eax, ecx;
call interpretPushLong_;
mov eax, ecx;
mov edx, VAR_TYPE_INT;
call interpretPushShort_;
popad;
mov edx, eax;
pop eax;
_RET_VAL_INT2(ecx);
pop edx;
pop ecx;
retn;
}
}
@@ -768,34 +750,24 @@ static void __declspec(naked) SetSfallReturn() {
__asm {
push ecx;
push edx;
mov ecx, eax;
call interpretPopShort_;
mov edx, eax;
mov eax, ecx;
call interpretPopLong_;
cmp dx, VAR_TYPE_INT;
jnz end;
_GET_ARG_INT(end);
push eax;
call SetHSReturn;
end:
pop edx;
pop ecx;
pop edx;
pop ecx;
retn;
}
}
static void __declspec(naked) InitHook() {
__asm {
push ecx;
push edx;
mov ecx, eax;
mov edx, InitingHookScripts;
call interpretPushLong_;
mov eax, ecx;
mov edx, VAR_TYPE_INT;
call interpretPushShort_;
pop edx;
pop ecx;
push ecx;
mov edx, InitingHookScripts;
_RET_VAL_INT2(ecx);
pop ecx;
pop edx;
retn;
}
}
@@ -826,18 +798,13 @@ static void __declspec(naked) set_self() {
__asm {
push ecx;
push edx;
mov ecx, eax;
call interpretPopShort_;
mov edx, eax;
mov eax, ecx;
call interpretPopLong_;
cmp dx, VAR_TYPE_INT;
jnz end;
mov edx, eax; // object
mov ecx, eax;
_GET_ARG_INT(end);
mov edx, eax; // object
call SetSelfObject; // ecx - script
end:
pop edx;
pop ecx;
pop edx;
pop ecx;
retn;
}
}
+29 -1
View File
@@ -38,6 +38,20 @@
__asm mov rval, eax \
}
/*
Gets argument from stack to eax and puts its type to edx register
eax register must contain the script_ptr
jlabel - name of the jump label in case the value type is not INT
*/
#define _GET_ARG_INT(jlabel) __asm { \
__asm mov edx, eax \
__asm call interpretPopShort_ \
__asm xchg eax, edx \
__asm call interpretPopLong_ \
__asm cmp dx, VAR_TYPE_INT \
__asm jnz jlabel \
}
/*
checks argument to be integer, and jumps to GOTOFAIL if it's not
*/
@@ -105,6 +119,20 @@ notstring##num:
__asm call interpretPushShort_ \
}
/*
Returns the value to the script
eax register must contain the script_ptr
edx register must contain the returned value
rscript - register name for temporarily saving script_ptr
*/
#define _RET_VAL_INT2(rscript) __asm { \
__asm mov rscript, eax \
__asm call interpretPushLong_ \
__asm mov edx, VAR_TYPE_INT \
__asm mov eax, rscript \
__asm call interpretPushShort_ \
}
/*
handle return value which may be of any type
num - any unique number
@@ -113,7 +141,7 @@ notstring##num:
#define _RET_VAL_POSSIBLY_STR(num, rscript, type) __asm { \
__asm mov ecx, eax \
__asm mov edx, type \
__asm cmp edx, VAR_TYPE_STR \
__asm cmp edx, VAR_TYPE_STR \
__asm jne resultnotstr##num \
__asm mov edx, eax \
__asm mov eax, rscript \
+27 -67
View File
@@ -26,26 +26,18 @@
// graphics_functions
static void __declspec(naked) GraphicsFuncsAvailable() {
__asm {
push ebx;
push ecx;
push edx;
mov ecx, eax;
xor edx, edx;
mov ebx, GraphicsMode;
cmp ebx, 3;
jle end;
inc edx;
end:
call interpretPushLong_;
mov edx, VAR_TYPE_INT;
mov eax, ecx;
call interpretPushShort_;
pop edx;
pop ecx;
pop ebx;
push ecx;
cmp GraphicsMode, 3;
seta dl;
and edx, 0xFF;
_RET_VAL_INT2(ecx);
pop ecx;
pop edx;
retn;
}
}
static void __declspec(naked) funcLoadShader() {
__asm {
push ebx;
@@ -84,69 +76,49 @@ result:
retn;
}
}
static void __declspec(naked) funcFreeShader() {
__asm {
push ebx;
push ecx;
push edx;
mov ecx, eax;
call interpretPopShort_;
mov edx, eax;
mov eax, ecx;
call interpretPopLong_;
cmp dx, VAR_TYPE_INT;
jnz end;
_GET_ARG_INT(end);
push eax;
call FreeShader;
end:
pop edx;
pop ecx;
pop ebx;
pop edx;
pop ecx;
retn;
}
}
static void __declspec(naked) funcActivateShader() {
__asm {
push ebx;
push ecx;
push edx;
mov ecx, eax;
call interpretPopShort_;
mov edx, eax;
mov eax, ecx;
call interpretPopLong_;
cmp dx, VAR_TYPE_INT;
jnz end;
_GET_ARG_INT(end);
push eax;
call ActivateShader;
end:
pop edx;
pop ecx;
pop ebx;
pop edx;
pop ecx;
retn;
}
}
static void __declspec(naked) funcDeactivateShader() {
__asm {
push ebx;
push ecx;
push edx;
mov ecx, eax;
call interpretPopShort_;
mov edx, eax;
mov eax, ecx;
call interpretPopLong_;
cmp dx, VAR_TYPE_INT;
jnz end;
_GET_ARG_INT(end);
push eax;
call DeactivateShader;
end:
pop edx;
pop ecx;
pop ebx;
retn;
}
}
static void __declspec(naked) funcGetShaderTexture() {
__asm {
//Store registers
@@ -428,27 +400,22 @@ end:
retn;
}
}
static void __declspec(naked) funcGetShaderVersion() {
__asm {
push ebx;
push ecx;
push edx;
push edi;
mov edi, eax;
push eax;
call GetShaderVersion;
mov edx, eax;
mov eax, edi;
call interpretPushLong_;
mov edx, VAR_TYPE_INT;
mov eax, edi;
call interpretPushShort_;
pop edi;
mov edx, eax;
pop eax;
_RET_VAL_INT2(ecx);
pop edx;
pop ecx;
pop ebx;
retn;
}
}
static void __declspec(naked) funcSetShaderMode() {
__asm {
push ebx;
@@ -483,24 +450,17 @@ end:
retn;
}
}
static void __declspec(naked) funcForceGraphicsRefresh() {
__asm {
push ebx;
push ecx;
push edx;
mov ecx, eax;
call interpretPopShort_;
mov edx, eax;
mov eax, ecx;
call interpretPopLong_;
cmp dx, VAR_TYPE_INT;
jnz end;
_GET_ARG_INT(end);
push eax;
call ForceGraphicsRefresh;
end:
pop edx;
pop ecx;
pop ebx;
retn;
}
}
+68 -123
View File
@@ -27,24 +27,18 @@
// input_functions
static void __declspec(naked) InputFuncsAvailable() {
__asm {
push ebx;
push ecx;
push edx;
mov ecx, eax;
mov edx, 1; //They're always available from 2.9 on
call interpretPushLong_;
mov edx, VAR_TYPE_INT;
mov eax, ecx;
call interpretPushShort_;
pop edx;
pop ecx;
pop ebx;
mov edx, 1; // They're always available from 2.9 on
_RET_VAL_INT2(ecx);
pop edx;
pop ecx;
retn;
}
}
static void __declspec(naked) KeyPressed() {
__asm {
push ebx;
push ecx;
push edx;
mov ecx, eax;
@@ -70,32 +64,24 @@ end:
call interpretPushShort_;
pop edx;
pop ecx;
pop ebx;
retn;
}
}
static void __declspec(naked) funcTapKey() {
__asm {
push ebx;
push ecx;
push edx;
mov ecx, eax;
call interpretPopShort_;
mov edx, eax;
mov eax, ecx;
call interpretPopLong_;
cmp dx, VAR_TYPE_INT;
jnz end;
_GET_ARG_INT(end);
test eax, eax;
jl end;
cmp eax, 255;
jge end;
jl end;
cmp eax, 255;
jge end;
push eax;
call TapKey;
end:
pop edx;
pop ecx;
pop ebx;
pop edx;
pop ecx;
retn;
}
}
@@ -103,17 +89,13 @@ end:
//// *** From helios *** ////
static void __declspec(naked) get_mouse_x() {
__asm {
push ecx;
push edx;
mov ecx, eax;
mov edx, ds:[_mouse_x_];
add edx, ds:[_mouse_hotx];
call interpretPushLong_;
mov eax, ecx;
mov edx, VAR_TYPE_INT;
call interpretPushShort_
pop edx;
pop ecx;
push ecx;
mov edx, ds:[_mouse_x_];
add edx, ds:[_mouse_hotx];
_RET_VAL_INT2(ecx);
pop ecx;
pop edx;
retn;
}
}
@@ -121,17 +103,13 @@ static void __declspec(naked) get_mouse_x() {
//Return mouse y position
static void __declspec(naked) get_mouse_y() {
__asm {
push ecx;
push edx;
mov ecx, eax;
mov edx, ds:[_mouse_y_];
add edx, ds:[_mouse_hoty];
call interpretPushLong_;
mov eax, ecx;
mov edx, VAR_TYPE_INT;
call interpretPushShort_
pop edx;
pop ecx;
push ecx;
mov edx, ds:[_mouse_y_];
add edx, ds:[_mouse_hoty];
_RET_VAL_INT2(ecx);
pop ecx;
pop edx;
retn;
}
}
@@ -162,16 +140,12 @@ skip:
//Return the window number under the mous
static void __declspec(naked) get_window_under_mouse() {
__asm {
push ecx;
push edx;
mov ecx, eax;
mov edx, ds:[_last_button_winID];
call interpretPushLong_;
mov eax, ecx;
mov edx, VAR_TYPE_INT;
call interpretPushShort_
pop edx;
pop ecx;
push ecx;
mov edx, ds:[_last_button_winID];
_RET_VAL_INT2(ecx);
pop ecx;
pop edx;
retn;
}
}
@@ -179,34 +153,30 @@ static void __declspec(naked) get_window_under_mouse() {
//Return screen width
static void __declspec(naked) get_screen_width() {
__asm {
push edx
push eax
mov edx, ds:[_scr_size+8] // _scr_size.offx
sub edx, ds:[_scr_size] // _scr_size.x
inc edx
call interpretPushLong_
pop eax
mov edx, VAR_TYPE_INT
call interpretPushShort_
pop edx
retn
push edx;
push ecx;
mov edx, ds:[_scr_size + 8]; // _scr_size.offx
sub edx, ds:[_scr_size]; // _scr_size.x
inc edx;
_RET_VAL_INT2(ecx);
pop ecx;
pop edx;
retn;
}
}
//Return screen height
static void __declspec(naked) get_screen_height() {
__asm {
push edx
push eax
mov edx, ds:[_scr_size+12] // _scr_size.offy
sub edx, ds:[_scr_size+4] // _scr_size.y
inc edx
call interpretPushLong_
pop eax
mov edx, VAR_TYPE_INT
call interpretPushShort_
pop edx
retn
push edx;
push ecx;
mov edx, ds:[_scr_size + 12]; // _scr_size.offy
sub edx, ds:[_scr_size + 4]; // _scr_size.y
inc edx;
_RET_VAL_INT2(ecx);
pop ecx;
pop edx;
retn;
}
}
@@ -269,75 +239,50 @@ end:
static void __declspec(naked) GetViewportX() {
__asm {
push ebx;
push ecx;
push edx;
mov ecx, eax;
mov edx, ds:[_wmWorldOffsetX];
call interpretPushLong_;
mov edx, VAR_TYPE_INT;
mov eax, ecx;
call interpretPushShort_;
pop edx;
pop ecx;
pop ebx;
push ecx;
mov edx, ds:[_wmWorldOffsetX];
_RET_VAL_INT2(ecx);
pop ecx;
pop edx;
retn;
}
}
static void __declspec(naked) GetViewportY() {
__asm {
push ebx;
push ecx;
push edx;
mov ecx, eax;
mov edx, ds:[_wmWorldOffsetY];
call interpretPushLong_;
mov edx, VAR_TYPE_INT;
mov eax, ecx;
call interpretPushShort_;
pop edx;
pop ecx;
pop ebx;
push ecx;
mov edx, ds:[_wmWorldOffsetY];
_RET_VAL_INT2(ecx);
pop ecx;
pop edx;
retn;
}
}
static void __declspec(naked) SetViewportX() {
__asm {
push ebx;
push ecx;
push edx;
mov ecx, eax;
call interpretPopShort_;
mov edx, eax;
mov eax, ecx;
call interpretPopLong_;
cmp dx, VAR_TYPE_INT;
jnz end;
mov ds:[_wmWorldOffsetX], eax
_GET_ARG_INT(end);
mov ds:[_wmWorldOffsetX], eax;
end:
pop edx;
pop ecx;
pop ebx;
pop edx;
pop ecx;
retn;
}
}
static void __declspec(naked) SetViewportY() {
__asm {
push ebx;
push ecx;
push edx;
mov ecx, eax;
call interpretPopShort_;
mov edx, eax;
mov eax, ecx;
call interpretPopLong_;
cmp dx, VAR_TYPE_INT;
jnz end;
mov ds:[_wmWorldOffsetY], eax
_GET_ARG_INT(end);
mov ds:[_wmWorldOffsetY], eax;
end:
pop edx;
pop ecx;
pop ebx;
pop edx;
pop ecx;
retn;
}
}
+14 -14
View File
@@ -218,15 +218,15 @@ end:
}
}
static void _stdcall WriteStringInternal(const char* str, char* addr) {
bool hitnull=false;
while(*str) {
if(!*addr) hitnull=true;
if(hitnull&&addr[1]) break;
*addr=*str;
bool hitnull = false;
while (*str) {
if (!*addr) hitnull = true;
if (hitnull && addr[1]) break;
*addr = *str;
addr++;
str++;
}
*addr=0;
*addr = 0;
}
static void __declspec(naked) WriteString() {
__asm {
@@ -264,12 +264,12 @@ end:
}
}
static void _stdcall CallOffsetInternal(DWORD func, DWORD script) {
func=(func>>2) - 0x1d2;
bool ret=func>=5;
int argcount=func%5;
func = (func >> 2) - 0x1d2;
bool ret = func >= 5;
int argcount = func % 5;
DWORD args[5];
DWORD illegalarg=0;
for(int i=argcount*4;i>=0;i-=4) {
DWORD illegalarg = 0;
for (int i = argcount * 4; i >= 0; i -= 4) {
__asm {
mov eax, script;
call interpretPopShort_;
@@ -285,8 +285,8 @@ legal:
}
}
if(illegalarg) {
args[0]=0;
if (illegalarg) {
args[0] = 0;
} else {
__asm {
mov eax, args[4]; // args[1]
@@ -298,7 +298,7 @@ legal:
mov args[0], eax;
}
}
if(ret) {
if (ret) {
__asm {
mov eax, script;
mov edx, args[0];
File diff suppressed because it is too large Load Diff
+61 -89
View File
@@ -24,53 +24,46 @@
static void __declspec(naked) GetPerkOwed() {
__asm {
pushad;
mov ecx, eax;
push edx;
push ecx;
movzx edx, byte ptr ds:[_free_perk];
call interpretPushLong_;
mov edx, VAR_TYPE_INT;
mov eax, ecx;
call interpretPushShort_;
popad;
_RET_VAL_INT2(ecx);
pop ecx;
pop edx;
retn;
}
}
static void __declspec(naked) SetPerkOwed() {
__asm {
pushad;
mov ecx, eax;
call interpretPopShort_;
mov edx, eax;
mov eax, ecx;
call interpretPopLong_;
cmp dx, VAR_TYPE_INT;
jnz end;
and eax, 0xFF;
cmp eax, 250;
jg end;
mov byte ptr ds:[_free_perk], al
push ecx;
push edx;
_GET_ARG_INT(end);
and eax, 0xFF;
cmp eax, 250;
jg end;
mov byte ptr ds:[_free_perk], al;
end:
popad
pop edx;
pop ecx;
retn;
}
}
static void __declspec(naked) set_perk_freq() {
__asm {
pushad;
mov ecx, eax;
call interpretPopShort_;
mov edx, eax;
mov eax, ecx;
call interpretPopLong_;
cmp dx, VAR_TYPE_INT;
jnz end;
push ecx;
push edx;
_GET_ARG_INT(end);
push eax;
call SetPerkFreq;
end:
popad
pop edx;
pop ecx;
retn;
}
}
static void __declspec(naked) GetPerkAvailable() {
__asm {
pushad;
@@ -173,7 +166,7 @@ end:
static void __declspec(naked) funcSetPerkValue() {
__asm {
pushad;
sub edx, 0x5e0-8; // offset of value into perk struct; edx = ((edx/4) - 0x178 + 0x8) * 4
sub edx, 0x5e0 - 8; // offset of value into perk struct; edx = ((edx/4) - 0x178 + 0x8) * 4
push edx;
mov ecx, eax;
call interpretPopShort_;
@@ -230,36 +223,36 @@ static void __declspec(naked) fSetSelectablePerk() {
call interpretPopLong_;
push eax;
movzx eax, word ptr [esp+12];
movzx eax, word ptr [esp + 12];
cmp eax, VAR_TYPE_INT;
jne fail;
movzx eax, word ptr [esp+20];
movzx eax, word ptr [esp + 20];
cmp eax, VAR_TYPE_INT;
jne fail;
movzx eax, word ptr ds:[esp+4];
movzx eax, word ptr ds:[esp + 4];
cmp eax, VAR_TYPE_STR2;
je next1;
cmp eax, VAR_TYPE_STR;
jne fail;
next1:
movzx eax, word ptr ds:[esp+28];
movzx eax, word ptr ds:[esp + 28];
cmp eax, VAR_TYPE_STR2;
je next2;
cmp eax, VAR_TYPE_STR;
jne fail;
next2:
mov eax, ecx;
mov edx, [esp+28];
mov ebx, [esp+24];
mov edx, [esp + 28];
mov ebx, [esp + 24];
call interpretGetString_;
push eax;
mov eax, [esp+20];
mov eax, [esp + 20];
push eax;
mov eax, [esp+16];
mov eax, [esp + 16];
push eax;
mov eax, ecx;
mov edx, [esp+16];
mov ebx, [esp+12];
mov edx, [esp + 16];
mov ebx, [esp + 12];
call interpretGetString_;
push eax;
@@ -298,36 +291,36 @@ static void __declspec(naked) fSetFakePerk() {
call interpretPopLong_;
push eax;
movzx eax, word ptr [esp+12];
movzx eax, word ptr [esp + 12];
cmp eax, VAR_TYPE_INT;
jne fail;
movzx eax, word ptr [esp+20];
movzx eax, word ptr [esp + 20];
cmp eax, VAR_TYPE_INT;
jne fail;
movzx eax, word ptr ds:[esp+4];
movzx eax, word ptr ds:[esp + 4];
cmp eax, VAR_TYPE_STR2;
je next1;
cmp eax, VAR_TYPE_STR;
jne fail;
next1:
movzx eax, word ptr ds:[esp+28];
movzx eax, word ptr ds:[esp + 28];
cmp eax, VAR_TYPE_STR2;
je next2;
cmp eax, VAR_TYPE_STR;
jne fail;
next2:
mov eax, ecx;
mov edx, [esp+28];
mov ebx, [esp+24];
mov edx, [esp + 28];
mov ebx, [esp + 24];
call interpretGetString_;
push eax;
mov eax, [esp+20];
mov eax, [esp + 20];
push eax;
mov eax, [esp+16];
mov eax, [esp + 16];
push eax;
mov eax, ecx;
mov edx, [esp+16];
mov ebx, [esp+12];
mov edx, [esp + 16];
mov ebx, [esp + 12];
call interpretGetString_;
push eax;
@@ -370,36 +363,36 @@ static void __declspec(naked) fSetFakeTrait() {
call interpretPopLong_;
push eax;
movzx eax, word ptr [esp+12];
movzx eax, word ptr [esp + 12];
cmp eax, VAR_TYPE_INT;
jne fail;
movzx eax, word ptr [esp+20];
movzx eax, word ptr [esp + 20];
cmp eax, VAR_TYPE_INT;
jne fail;
movzx eax, word ptr ds:[esp+4];
movzx eax, word ptr ds:[esp + 4];
cmp eax, VAR_TYPE_STR2;
je next1;
cmp eax, VAR_TYPE_STR;
jne fail;
next1:
movzx eax, word ptr ds:[esp+28];
movzx eax, word ptr ds:[esp + 28];
cmp eax, VAR_TYPE_STR2;
je next2;
cmp eax, VAR_TYPE_STR;
jne fail;
next2:
mov eax, ecx;
mov edx, [esp+28];
mov ebx, [esp+24];
mov edx, [esp + 28];
mov ebx, [esp + 24];
call interpretGetString_;
push eax;
mov eax, [esp+20];
mov eax, [esp + 20];
push eax;
mov eax, [esp+16];
mov eax, [esp + 16];
push eax;
mov eax, ecx;
mov edx, [esp+16];
mov ebx, [esp+12];
mov edx, [esp + 16];
mov ebx, [esp + 12];
call interpretGetString_;
push eax;
@@ -537,27 +530,21 @@ end:
retn;
}
}
static void __declspec(naked) fAddPerkMode() {
__asm {
push ebx;
push ecx;
push edx;
mov ecx, eax;
call interpretPopShort_;
mov edx, eax;
mov eax, ecx;
call interpretPopLong_;
cmp dx, VAR_TYPE_INT;
jnz end;
_GET_ARG_INT(end);
push eax;
call AddPerkMode;
end:
pop edx;
pop ecx;
pop ebx;
retn;
}
}
static void __declspec(naked) remove_trait() {
__asm {
pushad;
@@ -588,23 +575,15 @@ end:
static void __declspec(naked) SetPyromaniacMod() {
__asm {
push ebx;
push ecx;
push edx;
mov ecx, eax;
call interpretPopShort_;
mov edx, eax;
mov eax, ecx;
call interpretPopLong_;
cmp dx, VAR_TYPE_INT;
jnz end;
_GET_ARG_INT(end);
push eax;
push 0x424AB6;
call SafeWrite8;
end:
pop edx;
pop ecx;
pop ebx;
retn;
}
}
@@ -617,25 +596,18 @@ static void __declspec(naked) fApplyHeaveHoFix() {
retn;
}
}
static void __declspec(naked) SetSwiftLearnerMod() {
__asm {
push ebx;
push ecx;
push edx;
mov ecx, eax;
call interpretPopShort_;
mov edx, eax;
mov eax, ecx;
call interpretPopLong_;
cmp dx, VAR_TYPE_INT;
jnz end;
_GET_ARG_INT(end);
push eax;
push 0x4AFAE2;
call SafeWrite32;
end:
pop edx;
pop ecx;
pop ebx;
pop edx;
pop ecx;
retn;
}
}
+39 -52
View File
@@ -445,10 +445,10 @@ static void __declspec(naked) set_critter_skill_points() {
mov ebx, [esp];
cmp bx, VAR_TYPE_INT;
jnz end;
mov ebx, [esp+4];
mov ebx, [esp + 4];
cmp bx, VAR_TYPE_INT;
jnz end;
mov ebx, [esp+8];
mov ebx, [esp + 8];
cmp bx, VAR_TYPE_INT;
jnz end;
test esi, esi;
@@ -456,11 +456,11 @@ static void __declspec(naked) set_critter_skill_points() {
cmp esi, 18;
jge end;
//set the new value
mov eax, [eax+0x64];
mov eax, [eax + 0x64];
mov edx, esp;
call proto_ptr_;
mov eax, [esp];
mov [eax+0x13c+esi*4], edi;
mov [eax + 0x13c + esi * 4], edi;
end:
//Restore registers and return
add esp, 12;
@@ -488,7 +488,7 @@ static void __declspec(naked) get_critter_skill_points() {
mov ebx, [esp];
cmp bx, VAR_TYPE_INT;
jnz fail;
mov ebx, [esp+4];
mov ebx, [esp + 4];
cmp bx, VAR_TYPE_INT;
jnz fail;
test esi, esi;
@@ -496,11 +496,11 @@ static void __declspec(naked) get_critter_skill_points() {
cmp esi, 18;
jge fail;
//get the value
mov eax, [eax+0x64];
mov eax, [eax + 0x64];
mov edx, esp;
call proto_ptr_;
mov eax, [esp];
mov edx, [eax+0x13c+esi*4];
mov edx, [eax + 0x13c + esi * 4];
jmp end;
fail:
xor edx, edx;
@@ -516,58 +516,54 @@ end:
retn;
}
}
static void __declspec(naked) set_available_skill_points() {
__asm {
pushad;
mov ecx, eax;
call interpretPopShort_;
xchg eax, ecx;
call interpretPopLong_;
cmp cx, VAR_TYPE_INT;
jnz end;
mov edx, eax;
xor eax, eax;
push ecx;
push edx;
_GET_ARG_INT(end);
mov edx, eax;
xor eax, eax;
call stat_pc_set_;
end:
popad;
pop edx;
pop ecx;
retn;
}
}
static void __declspec(naked) get_available_skill_points() {
__asm {
pushad;
mov ecx, eax;
mov edx, dword ptr ds:[_curr_pc_stat];
call interpretPushLong_;
mov edx, VAR_TYPE_INT;
mov eax, ecx;
call interpretPushShort_
popad;
push edx;
push ecx;
mov edx, dword ptr ds:[_curr_pc_stat];
_RET_VAL_INT2(ecx);
pop ecx;
pop edx;
retn;
}
}
static void __declspec(naked) mod_skill_points_per_level() {
__asm {
pushad;
mov ecx, eax;
call interpretPopShort_;
xchg eax, ecx;
call interpretPopLong_;
cmp cx, VAR_TYPE_INT;
jnz end;
cmp eax, 100;
jg end;
cmp eax, -100;
jl end;
add eax, 5;
push ecx;
push edx;
_GET_ARG_INT(end);
cmp eax, 100;
jg end;
cmp eax, -100;
jl end;
add eax, 5;
push eax;
push 0x43C27A;
call SafeWrite8;
end:
popad;
pop edx;
pop ecx;
retn;
}
}
static void __declspec(naked) GetCritterAP() {
__asm {
//Store registers
@@ -583,7 +579,7 @@ static void __declspec(naked) GetCritterAP() {
//Check args are valid
cmp di, VAR_TYPE_INT;
jnz fail;
mov edx, [eax+0x40];
mov edx, [eax + 0x40];
jmp end;
fail:
xor edx, edx;
@@ -627,7 +623,7 @@ static void __declspec(naked) SetCritterAP() {
jnz end;
cmp si, VAR_TYPE_INT;
jnz end;
mov [eax+0x40], ebx;
mov [eax + 0x40], ebx;
mov ecx, ds:[_obj_dude]
cmp ecx, eax;
jne end;
@@ -645,7 +641,6 @@ end:
}
}
static void __declspec(naked) fSetPickpocketMax() {
__asm {
push ebx;
@@ -1209,31 +1204,23 @@ end:
retn;
}
}
static void _stdcall SetPerkLevelMod2(int mod) {
if (mod < -25 || mod > 25) return;
PerkLevelMod = mod;
HookCall(0x49687F, &SetPerkLevelMod3);
}
static void __declspec(naked) SetPerkLevelMod() {
__asm {
push ebx;
push ecx;
push edx;
push edi;
mov ecx, eax;
call interpretPopShort_;
mov edx, eax;
mov eax, ecx;
call interpretPopLong_;
cmp dx, VAR_TYPE_INT;
jnz end;
_GET_ARG_INT(end);
push eax;
call SetPerkLevelMod2;
end:
pop edi;
pop edx;
pop ecx;
pop ebx;
retn;
}
}
+33 -55
View File
@@ -58,19 +58,13 @@ static void __declspec(naked) ForceEncounter() {
__asm {
push ecx;
push edx;
mov ecx, eax;
call interpretPopShort_;
mov edx, eax;
mov eax, ecx;
call interpretPopLong_;
cmp dx, VAR_TYPE_INT;
jnz end;
xor edx, edx; // flags
mov ecx, eax; // mapID
_GET_ARG_INT(end);
xor edx, edx; // flags
mov ecx, eax; // mapID
call ForceEncounter2;
end:
pop edx;
pop ecx;
pop edx;
pop ecx;
retn;
}
}
@@ -105,74 +99,58 @@ end:
// world_map_functions
static void __declspec(naked) funcInWorldMap() {
__asm {
push ebx;
push ecx;
push edx;
push esi;
mov esi, eax;
push eax;
call InWorldMap;
mov edx, eax;
mov eax, esi;
call interpretPushLong_;
mov edx, VAR_TYPE_INT;
mov eax, esi;
call interpretPushShort_;
pop esi;
pop edx;
pop ecx;
pop ebx;
mov edx, eax;
pop eax;
_RET_VAL_INT2(ecx);
pop edx;
pop ecx;
retn;
}
}
static void __declspec(naked) GetGameMode() {
__asm {
pushad;
mov edi, eax;
push ecx;
push edx;
push eax;
call GetCurrentLoops;
mov edx, eax;
mov eax, edi;
call interpretPushLong_;
mov edx, VAR_TYPE_INT;
mov eax, edi;
call interpretPushShort_;
popad;
mov edx, eax;
pop eax;
_RET_VAL_INT2(ecx);
pop edx;
pop ecx;
retn;
}
}
static void __declspec(naked) GetWorldMapXPos() {
__asm {
push ebx;
push ecx;
push edx;
mov ecx, eax;
mov edx, ds:[_world_xpos];
call interpretPushLong_;
mov edx, VAR_TYPE_INT;
mov eax, ecx;
call interpretPushShort_;
pop edx;
pop ecx;
pop ebx;
push ecx;
mov edx, ds:[_world_xpos];
_RET_VAL_INT2(ecx);
pop ecx;
pop edx;
retn;
}
}
static void __declspec(naked) GetWorldMapYPos() {
__asm {
push ebx;
push ecx;
push edx;
mov ecx, eax;
mov edx, ds:[_world_ypos];
call interpretPushLong_;
mov edx, VAR_TYPE_INT;
mov eax, ecx;
call interpretPushShort_;
pop edx;
pop ecx;
pop ebx;
push ecx;
mov edx, ds:[_world_ypos];
_RET_VAL_INT2(ecx);
pop ecx;
pop edx;
retn;
}
}
static void __declspec(naked) SetWorldMapPos() {
__asm {
push ebx;
+3 -3
View File
@@ -1046,6 +1046,9 @@ static void DllMain2() {
dlogr(" Done", DL_INIT);
}
dlogr("Running CritInit().", DL_INIT);
CritInit();
if (GetPrivateProfileIntA("Misc", "ExtraKillTypes", 0, ini)) {
dlog("Applying extra kill types patch.", DL_INIT);
KillCounterInit();
@@ -1166,9 +1169,6 @@ static void DllMain2() {
dlogr(" Done", DL_INIT);
}
dlogr("Running CritInit().", DL_INIT);
CritInit();
//if (GetPrivateProfileIntA("Misc", "MultiPatches", 0, ini)) {
dlog("Applying load multiple patches patch.", DL_INIT);
SafeWrite8(0x444354, 0x90); // Change step from 2 to 1
+3 -3
View File
@@ -24,13 +24,13 @@
#define VERSION_MAJOR 3
#define VERSION_MINOR 8
#define VERSION_BUILD 17
#define VERSION_BUILD 18
#define VERSION_REV 0
#ifdef WIN2K
#define VERSION_STRING "3.8.17 win2k"
#define VERSION_STRING "3.8.18 win2k"
#else
#define VERSION_STRING "3.8.17"
#define VERSION_STRING "3.8.18"
#endif
//#define CHECK_VAL (4)