Skip to content

Commit

Permalink
FF8: Fix crash from PR #601 (#602)
Browse files Browse the repository at this point in the history
  • Loading branch information
myst6re committed Sep 14, 2023
1 parent 5c7da23 commit fa43705
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 24 deletions.
17 changes: 8 additions & 9 deletions src/ff8/uv_patch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -157,17 +157,16 @@ void uv_patch_init()
* - And when the game uses the UVs from the SSIGPU instruction, we alter
* the computation of U and V using the forgotten bits.
*/
bool isUs = version == FF8_US_VERSION;

// Worldmap with Fog enabled
replace_call(ff8_externals.sub_53BB90 + (isUs ? 0x42D : 0x43B), worldmap_fog_filter_polygons_in_block_1);
replace_call(ff8_externals.sub_53BB90 + (isUs ? 0xADD : 0xB11), worldmap_fog_filter_polygons_in_block_1);
replace_call(ff8_externals.sub_53BB90 + (isUs ? 0x442 : 0x450), worldmap_fog_filter_polygons_in_block_2);
replace_call(ff8_externals.sub_53BB90 + (isUs ? 0xAF2 : 0xB26), worldmap_fog_filter_polygons_in_block_2);
replace_call(ff8_externals.worldmap_fog_filter_polygons_in_block_1 + (isUs ? 0x1FC : 0x202), sub_45DF20);
replace_call(ff8_externals.worldmap_fog_filter_polygons_in_block_1 + (isUs ? 0x5C8 : 0x5DC), enrich_tex_coords_sub_45E3A0);
replace_call(ff8_externals.worldmap_fog_filter_polygons_in_block_2 + (isUs ? 0x242 : 0x241), sub_45DF20);
replace_call(ff8_externals.worldmap_fog_filter_polygons_in_block_2 + (isUs ? 0x698 : 0x6CD), enrich_tex_coords_sub_45E3A0);
replace_call(ff8_externals.sub_53BB90 + (FF8_US_VERSION ? 0x42D : 0x43B), worldmap_fog_filter_polygons_in_block_1);
replace_call(ff8_externals.sub_53BB90 + (FF8_US_VERSION ? 0xADD : 0xB11), worldmap_fog_filter_polygons_in_block_1);
replace_call(ff8_externals.sub_53BB90 + (FF8_US_VERSION ? 0x442 : 0x450), worldmap_fog_filter_polygons_in_block_2);
replace_call(ff8_externals.sub_53BB90 + (FF8_US_VERSION ? 0xAF2 : 0xB26), worldmap_fog_filter_polygons_in_block_2);
replace_call(ff8_externals.worldmap_fog_filter_polygons_in_block_1 + (FF8_US_VERSION ? 0x1FC : 0x202), sub_45DF20);
replace_call(ff8_externals.worldmap_fog_filter_polygons_in_block_1 + (FF8_US_VERSION ? 0x5C8 : 0x5DC), enrich_tex_coords_sub_45E3A0);
replace_call(ff8_externals.worldmap_fog_filter_polygons_in_block_2 + (FF8_US_VERSION ? 0x242 : 0x241), sub_45DF20);
replace_call(ff8_externals.worldmap_fog_filter_polygons_in_block_2 + (FF8_US_VERSION ? 0x698 : 0x6CD), enrich_tex_coords_sub_45E3A0);
replace_call(ff8_externals.sub_461E00 + 0x50, ssigpu_sub_461220);
ff8_externals.ssigpu_callbacks_1[52] = uint32_t(ssigpu_callback_sub_461E00);
}
2 changes: 1 addition & 1 deletion src/ff8_data.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -499,7 +499,7 @@ void ff8_find_externals()
ff8_externals.ssigpu_init = get_relative_call(ff8_externals.sub_45B460, 0x26);
ff8_externals.d3dcaps = (uint32_t *)get_absolute_value(ff8_externals.ssigpu_init, 0x6C);

if(version == FF8_US_VERSION)
if(FF8_US_VERSION)
{
ff8_externals.worldmap_section38_position = (uint32_t **)get_absolute_value(ff8_externals.worldmap_sub_53F310, 0x296);
ff8_externals.worldmap_section39_position = (uint32_t **)get_absolute_value(ff8_externals.worldmap_sub_53F310, 0x321);
Expand Down
25 changes: 12 additions & 13 deletions src/voice.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1255,18 +1255,17 @@ void voice_init()
replace_function(ff8_externals.battle_get_actor_name_sub_47EAF0, ff8_battle_get_actor_name);

// == World Map ==
bool isUs = version == FF8_US_VERSION;
replace_call_function(ff8_externals.sub_543CB0 + (isUs ? 0x638 : 0x605), ff8_world_dialog_assign_text);
replace_call_function(ff8_externals.sub_5484B0 + (isUs ? 0x524 : 0x4FD), ff8_world_dialog_assign_text);
replace_call_function(ff8_externals.sub_54A230 + (isUs ? 0xF : 0xD), ff8_world_dialog_assign_text);
replace_call_function(ff8_externals.sub_54D7E0 + (isUs ? 0x72 : 0x6F), ff8_world_dialog_assign_text);
replace_call_function(ff8_externals.sub_54E9B0 + (isUs ? 0x206 : 0x20C), ff8_world_dialog_assign_text);
replace_call_function(ff8_externals.sub_54E9B0 + (isUs ? 0x396 : 0x3A9), ff8_world_dialog_assign_text);
replace_call_function(ff8_externals.sub_54E9B0 + (isUs ? 0x3D2 : 0x3E5), ff8_world_dialog_assign_text);
replace_call_function(ff8_externals.sub_54E9B0 + (isUs ? 0x67D : 0x68F), ff8_world_dialog_assign_text);
replace_call_function(ff8_externals.sub_54E9B0 + (isUs ? 0x6A6 : 0x6BC), ff8_world_dialog_assign_text);
replace_call_function(ff8_externals.sub_54E9B0 + (isUs ? 0xEED : 0xF72), ff8_world_dialog_assign_text);
replace_call_function(ff8_externals.sub_54FDA0 + (isUs ? 0xAE : 0xAC), ff8_world_dialog_assign_text);
replace_call_function(ff8_externals.sub_54FDA0 + (isUs ? 0x178 : 0x175), ff8_world_dialog_assign_text);
replace_call_function(ff8_externals.sub_543CB0 + (FF8_US_VERSION ? 0x638 : 0x605), ff8_world_dialog_assign_text);
replace_call_function(ff8_externals.sub_5484B0 + (FF8_US_VERSION ? 0x524 : 0x4FD), ff8_world_dialog_assign_text);
replace_call_function(ff8_externals.sub_54A230 + (FF8_US_VERSION ? 0xF : 0xD), ff8_world_dialog_assign_text);
replace_call_function(ff8_externals.sub_54D7E0 + (FF8_US_VERSION ? 0x72 : 0x6F), ff8_world_dialog_assign_text);
replace_call_function(ff8_externals.sub_54E9B0 + (FF8_US_VERSION ? 0x206 : 0x20C), ff8_world_dialog_assign_text);
replace_call_function(ff8_externals.sub_54E9B0 + (FF8_US_VERSION ? 0x396 : 0x3A9), ff8_world_dialog_assign_text);
replace_call_function(ff8_externals.sub_54E9B0 + (FF8_US_VERSION ? 0x3D2 : 0x3E5), ff8_world_dialog_assign_text);
replace_call_function(ff8_externals.sub_54E9B0 + (FF8_US_VERSION ? 0x67D : 0x68F), ff8_world_dialog_assign_text);
replace_call_function(ff8_externals.sub_54E9B0 + (FF8_US_VERSION ? 0x6A6 : 0x6BC), ff8_world_dialog_assign_text);
replace_call_function(ff8_externals.sub_54E9B0 + (FF8_US_VERSION ? 0xEED : 0xF72), ff8_world_dialog_assign_text);
replace_call_function(ff8_externals.sub_54FDA0 + (FF8_US_VERSION ? 0xAE : 0xAC), ff8_world_dialog_assign_text);
replace_call_function(ff8_externals.sub_54FDA0 + (FF8_US_VERSION ? 0x178 : 0x175), ff8_world_dialog_assign_text);
}
}
2 changes: 1 addition & 1 deletion src/world.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ void world_init()
playerPosZ = playerPosX+1;
playerPosY = playerPosX+2;
BYTE *wm_struct;
if(version == FF8_US_VERSION)
if(FF8_US_VERSION)
{
wm_struct = (BYTE*)get_absolute_value(ff8_externals.sub_53C750, 0x633);
bCollisionEnabled = (DWORD*)get_absolute_value(ff8_externals.sub_53E6B0, 0x4);
Expand Down

0 comments on commit fa43705

Please sign in to comment.