Fixed Fill_W not uncovering all tiles to the left (#287)

This commit is contained in:
NovaRain
2020-02-28 07:41:49 +08:00
parent c2626de4fa
commit ac0b0ef7ef
+33
View File
@@ -2596,6 +2596,34 @@ skip:
}
}
static const DWORD wmSubTileMarkRadiusVisited_Ret = 0x4C3730;
static void __declspec(naked) wmSubTileMarkRadiusVisited_hack() {
__asm {
call fo::funcoffs::wmMarkSubTileOffsetVisitedFunc_;
cmp ebp, 7; // count of horizontal sub-tiles
je fix;
jmp wmSubTileMarkRadiusVisited_Ret;
fix:
test esi, esi; // if this is zero, then need to apply the fix
jz checkTiles;
jback:
xor ecx, ecx;
dec esi;
cmovnz ebp, ecx; // ebp=0 to continue uncovering sub-tiles
dec dword ptr [esp + 0x1C - 0x14]; // subtract one tile from the left
jmp wmSubTileMarkRadiusVisited_Ret;
checkTiles:
mov eax, ds:[FO_VAR_world_xpos]; // player's X position
mov ecx, 350;
xor edx, edx;
div ecx; // eax: count of tiles on the left of the player's position
mov esi, eax;
cmp eax, 1;
jg jback;
jmp wmSubTileMarkRadiusVisited_Ret;
}
}
void BugFixes::init()
{
#ifndef NDEBUG
@@ -3266,6 +3294,11 @@ void BugFixes::init()
// and the AI attack animation are performed simultaneously
// Note: all events in combat will occur before the AI attack
HookCall(0x422E5F, combat_ai_hook); // execute all events after the end of the combat sequence
// Fix for the "Fill_W" flag in worldmap.txt not uncovering all tiles to the left edge of the world map
MakeJump(0x4C372B, wmSubTileMarkRadiusVisited_hack);
SafeWrite16(0x4C3723, 0xC931); // mov ecx, esi > xor ecx, ecx
SafeWrite8(0x4C3727, 0x51); // push esi > push ecx
}
}