mirror of
https://github.com/sfall-team/sfall.git
synced 2026-07-27 16:52:34 -07:00
Refactored ASM code in ScriptExtender.cpp according to the develop branch, and edited the code style.
Moved NegateFix to Bugs.cpp and simplified its code.
This commit is contained in:
@@ -19,6 +19,28 @@ void GameInitialization() {
|
||||
*(DWORD*)_gDialogMusicVol = *(DWORD*)_background_volume; // fix dialog music
|
||||
}
|
||||
|
||||
// fix for vanilla negate operator not working on floats
|
||||
static const DWORD NegateFixHack_Back = 0x46AB77;
|
||||
static void __declspec(naked) NegateFixHack() {
|
||||
__asm {
|
||||
mov eax, [ecx + 0x1C];
|
||||
cmp si, VAR_TYPE_FLOAT;
|
||||
je isFloat;
|
||||
neg ebx;
|
||||
retn;
|
||||
isFloat:
|
||||
push ebx;
|
||||
fld[esp];
|
||||
fchs;
|
||||
fstp[esp];
|
||||
pop ebx;
|
||||
call pushLongStack_;
|
||||
mov edx, VAR_TYPE_FLOAT;
|
||||
add esp, 4; // Destroy the return address
|
||||
jmp NegateFixHack_Back;
|
||||
}
|
||||
}
|
||||
|
||||
static void __declspec(naked) SharpShooterFix() {
|
||||
__asm {
|
||||
call stat_level_ // Perception
|
||||
@@ -1383,6 +1405,16 @@ skip:
|
||||
|
||||
void BugsInit()
|
||||
{
|
||||
// fix vanilla negate operator on float values
|
||||
MakeCall(0x46AB68, NegateFixHack);
|
||||
// fix incorrect int-to-float conversion
|
||||
// op_mult:
|
||||
SafeWrite16(0x46A3F4, 0x04DB); // replace operator to "fild 32bit"
|
||||
SafeWrite16(0x46A3A8, 0x04DB);
|
||||
// op_div:
|
||||
SafeWrite16(0x46A566, 0x04DB);
|
||||
SafeWrite16(0x46A4E7, 0x04DB);
|
||||
|
||||
//if (GetPrivateProfileIntA("Misc", "SharpshooterFix", 1, ini)) {
|
||||
dlog("Applying Sharpshooter patch.", DL_INIT);
|
||||
// http://www.nma-fallout.com/threads/fo2-engine-tweaks-sfall.178390/page-119#post-4050162
|
||||
|
||||
@@ -639,10 +639,10 @@ int GetFont(void) {
|
||||
//---------------------------------------------------------
|
||||
//print text to surface
|
||||
void PrintText(char *DisplayText, BYTE ColourIndex, DWORD Xpos, DWORD Ypos, DWORD TxtWidth, DWORD ToWidth, BYTE *ToSurface) {
|
||||
DWORD posOffset = Ypos*ToWidth + Xpos;
|
||||
DWORD posOffset = Ypos * ToWidth + Xpos;
|
||||
__asm {
|
||||
xor eax, eax
|
||||
MOV AL, ColourIndex
|
||||
mov al, ColourIndex
|
||||
push eax
|
||||
mov edx, DisplayText
|
||||
mov ebx, TxtWidth
|
||||
|
||||
+444
-420
File diff suppressed because it is too large
Load Diff
@@ -60,9 +60,6 @@ int GetNumGlobals();
|
||||
void GetGlobals(sGlobalVar* globals);
|
||||
void SetGlobals(sGlobalVar* globals);
|
||||
|
||||
extern DWORD AddUnarmedStatToGetYear;
|
||||
extern DWORD AvailableGlobalScriptTypes;
|
||||
|
||||
void SetAppearanceGlobals(int race, int style);
|
||||
void GetAppearanceGlobals(int *race, int *style);
|
||||
|
||||
@@ -89,6 +86,7 @@ char* _stdcall mysubstr(char* str, int pos, int length);
|
||||
// variables
|
||||
static char reg_anim_combat_check = 1;
|
||||
extern DWORD isGlobalScriptLoading;
|
||||
extern DWORD AvailableGlobalScriptTypes;
|
||||
|
||||
// types for script variables
|
||||
#define VAR_TYPE_INT (0xC001)
|
||||
|
||||
@@ -742,33 +742,6 @@ static void __declspec(naked) op_typeof() {
|
||||
}
|
||||
}
|
||||
|
||||
// fix for vanilla negate operator not working on floats
|
||||
static const DWORD NegateFixHook_Back = 0x46AB79;
|
||||
static void __declspec(naked) NegateFixHook() {
|
||||
__asm {
|
||||
mov ebx, edi;
|
||||
lea edx, [ecx+36];
|
||||
mov eax, [ecx+28];
|
||||
cmp si, VAR_TYPE_FLOAT;
|
||||
jne notfloat;
|
||||
push ebx;
|
||||
fld [esp];
|
||||
fchs
|
||||
fstp [esp];
|
||||
pop ebx;
|
||||
call pushLongStack_
|
||||
mov edx, VAR_TYPE_FLOAT
|
||||
jmp end
|
||||
notfloat:
|
||||
neg ebx
|
||||
call pushLongStack_
|
||||
mov edx, VAR_TYPE_INT
|
||||
end:
|
||||
mov eax, ecx
|
||||
jmp NegateFixHook_Back;
|
||||
}
|
||||
}
|
||||
|
||||
static void funcPow2() {
|
||||
const ScriptValue &base = opHandler.arg(0),
|
||||
&power = opHandler.arg(1);
|
||||
|
||||
@@ -84,6 +84,7 @@ static const char* debugGnw = "GNW";
|
||||
|
||||
static const char* musicOverridePath = "data\\sound\\music\\";
|
||||
|
||||
DWORD AddUnarmedStatToGetYear = 0;
|
||||
bool npcautolevel;
|
||||
|
||||
static int* scriptDialog = nullptr;
|
||||
|
||||
@@ -36,6 +36,7 @@ extern char translationIni[65];
|
||||
extern char dmModelName[65];
|
||||
extern char dfModelName[65];
|
||||
|
||||
extern DWORD AddUnarmedStatToGetYear;
|
||||
extern bool npcautolevel;
|
||||
|
||||
template<typename T>
|
||||
|
||||
Reference in New Issue
Block a user