Skip to content

Commit

Permalink
Widescreen: Avoid clipping world view Y position for world view scrip…
Browse files Browse the repository at this point in the history
…t movements

Fix julianxhokaxhiu#474 chocobo issue and fship_22 camera movement
  • Loading branch information
tangtang95 committed Sep 24, 2022
1 parent 3977d5c commit 87d798e
Showing 1 changed file with 24 additions and 7 deletions.
31 changes: 24 additions & 7 deletions src/ff7/field/background.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -571,6 +571,8 @@ namespace ff7::field
void field_init_scripted_bg_movement()
{
vector2<short> world_pos;
short original_world_pos_y;

if ( !ff7_externals.modules_global_object->world_move_status )
{
switch ( ff7_externals.modules_global_object->world_move_mode )
Expand All @@ -591,9 +593,12 @@ namespace ff7::field
*ff7_externals.scripted_world_move_n_steps = ff7_externals.modules_global_object->field_20;
*ff7_externals.scripted_world_move_step_index = 0;
world_pos = {*ff7_externals.field_curr_delta_world_pos_x, *ff7_externals.field_curr_delta_world_pos_y};
original_world_pos_y = world_pos.y;

if(is_fieldmap_wide())
if(is_fieldmap_wide()) {
ff7_field_clip_with_camera_range(&world_pos);
world_pos.y = original_world_pos_y;
}

*ff7_externals.scripted_world_initial_pos_x = world_pos.x;
*ff7_externals.scripted_world_initial_pos_y = world_pos.y;
Expand All @@ -603,8 +608,12 @@ namespace ff7::field
*ff7_externals.field_bg_flag_CC15E4 = 1;

world_pos = {ff7_externals.modules_global_object->field_A, ff7_externals.modules_global_object->field_C};
if(is_fieldmap_wide())
field_widescreen_width_clip_with_camera_range(&world_pos);
original_world_pos_y = world_pos.y;

if(is_fieldmap_wide()) {
ff7_field_clip_with_camera_range(&world_pos);
world_pos.y = original_world_pos_y;
}

*ff7_externals.field_curr_delta_world_pos_x = world_pos.x;
*ff7_externals.field_curr_delta_world_pos_y = world_pos.y;
Expand All @@ -617,15 +626,23 @@ namespace ff7::field
*ff7_externals.scripted_world_move_step_index = 0;

world_pos = {*ff7_externals.field_curr_delta_world_pos_x, *ff7_externals.field_curr_delta_world_pos_y};
if(is_fieldmap_wide())
field_widescreen_width_clip_with_camera_range(&world_pos);
original_world_pos_y = world_pos.y;

if(is_fieldmap_wide()) {
ff7_field_clip_with_camera_range(&world_pos);
world_pos.y = original_world_pos_y;
}

*ff7_externals.scripted_world_initial_pos_x = world_pos.x;
*ff7_externals.scripted_world_initial_pos_y = world_pos.y;

world_pos = {ff7_externals.modules_global_object->field_A, ff7_externals.modules_global_object->field_C};
if(is_fieldmap_wide())
field_widescreen_width_clip_with_camera_range(&world_pos);
original_world_pos_y = world_pos.y;

if(is_fieldmap_wide()) {
ff7_field_clip_with_camera_range(&world_pos);
world_pos.y = original_world_pos_y;
}

*ff7_externals.scripted_world_final_pos_x = world_pos.x;
*ff7_externals.scripted_world_final_pos_y = world_pos.y;
Expand Down

0 comments on commit 87d798e

Please sign in to comment.