Minor code edits: replace some push/pop in ASM with pushadc/popadc pair

This commit is contained in:
NovaRain
2024-06-06 21:55:27 +08:00
parent 497973d259
commit 13e0348cc3
5 changed files with 11 additions and 31 deletions
+2 -6
View File
@@ -568,14 +568,10 @@ static void __fastcall CombatAttackHook(fo::GameObject* source, fo::GameObject*
static __declspec(naked) void combat_attack_hook() {
__asm {
push eax;
push ecx;
push edx;
pushadc;
mov ecx, eax; // source
call CombatAttackHook; // edx - target
pop edx;
pop ecx;
pop eax;
popadc;
jmp fo::funcoffs::combat_attack_;
}
}
+2 -6
View File
@@ -300,9 +300,7 @@ static void __stdcall SetHeroArt(bool newArtFlag) {
// return hero art val to normal before saving
static __declspec(naked) void SavCritNumFix() {
__asm {
push ecx;
push edx;
push eax;
pushadc;
push 0; // set hero FrmID LST index to normal range before saving
call SetHeroArt;
pop eax;
@@ -310,9 +308,7 @@ static __declspec(naked) void SavCritNumFix() {
push eax;
push 1; // return hero FrmID LST index back to hero art range after saving hero state structure
call SetHeroArt;
pop eax;
pop edx;
pop ecx;
popadc;
retn;
}
}
+2 -6
View File
@@ -442,15 +442,11 @@ static __declspec(naked) void gmovie_play_hack() {
__asm {
cmp eax, MaxMovies;
jge failPlayAvi;
push ecx;
push edx;
push eax;
pushadc;
mov ecx, eax;
call PrepareLoadMovie;
test eax,eax;
pop eax;
pop edx;
pop ecx;
popadc;
jz failPlayAvi;
push offset return; // return to here "return" label
failPlayAvi:
+4 -12
View File
@@ -136,13 +136,9 @@ static __declspec(naked) void pipboy_hack_press1() {
mov calledflag, 0;
test pageFlag, 0xFF;
jz skip;
push eax;
push edx;
push ecx;
pushadc;
call ResetPageValues;
pop ecx;
pop edx;
pop eax;
popadc;
skip:
// engine
sub ebx, 0x1F4;
@@ -157,13 +153,9 @@ static __declspec(naked) void pipboy_hack_back() {
mov calledflag, 0;
test pageFlag, 0xFF;
jz skip;
push eax;
push edx;
push ecx;
pushadc;
call ResetPageValues;
pop ecx;
pop edx;
pop eax;
popadc;
skip:
// engine
mov eax, 0x401;
+1 -1
View File
@@ -703,7 +703,7 @@ static __declspec(naked) void gdialogFreeSpeech_hack() {
jz skip;
push ecx;
push edx;
mov ecx,speechSound;
mov ecx, speechSound;
call ReleaseSound;
mov speechSound, 0;
mov lipsPlaying, 0;