Skip to content

Commit

Permalink
FF7: Fix condor minigame "could not change directory" error
Browse files Browse the repository at this point in the history
  • Loading branch information
julianxhokaxhiu committed Mar 4, 2023
1 parent 7afd5a6 commit 827b939
Show file tree
Hide file tree
Showing 6 changed files with 60 additions and 0 deletions.
1 change: 1 addition & 0 deletions Changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

## FF7

- Core: Fix `ERROR: COULD NOT CHANGE TO DIRECTORY` error when starting the Condor minigame
- Input: Allow Cloud to walk/run based on the left analogue stick position ( https://github.com/julianxhokaxhiu/FFNx/issues/523 )

## FF8
Expand Down
8 changes: 8 additions & 0 deletions src/ff7.h
Original file line number Diff line number Diff line change
Expand Up @@ -3067,6 +3067,14 @@ struct ff7_externals
uint32_t snowboard_submit_draw_black_quad_graphics_object_72DD94;
uint32_t snowboard_submit_draw_white_fade_quad_graphics_object_72DD53;
uint32_t snowboard_submit_draw_opaque_quad_graphics_object_72DDD5;

// condor
uint32_t condor_enter;
uint32_t condor_exit;
uint32_t sub_5F7756;
uint32_t sub_5F4273;
uint32_t sub_5F342C;
DWORD* condor_uses_lgp;
};

uint32_t ff7gl_load_group(uint32_t group_num, struct matrix_set *matrix_set, struct p_hundred *hundred_data, struct p_group *group_data, struct polygon_data *polygon_data, struct ff7_polygon_set *polygon_set, struct ff7_game_obj *game_object);
Expand Down
3 changes: 3 additions & 0 deletions src/ff7/defs.h
Original file line number Diff line number Diff line change
Expand Up @@ -107,3 +107,6 @@ struct ff7_tex_header *load_tex_file(struct file_context *file_context, char *fi
int ff7_dsound_create(HWND hwnd, LPGUID guid);
void ff7_dsound_release();
int ff7_dsound_createsoundbuffer(const WAVEFORMATEX *waveFormatEx);

// minigames
void ff7_condor_fix_unit_texture_load(uint32_t unk, struc_3 *struc_3);
33 changes: 33 additions & 0 deletions src/ff7/minigames.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
/****************************************************************************/
// Copyright (C) 2009 Aali132 //
// Copyright (C) 2023 Julian Xhokaxhiu //
// //
// This file is part of FFNx //
// //
// FFNx is free software: you can redistribute it and/or modify //
// it under the terms of the GNU General Public License as published by //
// the Free Software Foundation, either version 3 of the License //
// //
// FFNx is distributed in the hope that it will be useful, //
// but WITHOUT ANY WARRANTY; without even the implied warranty of //
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the //
// GNU General Public License for more details. //
/****************************************************************************/

#include <stdint.h>

#include "../ff7.h"
#include "../log.h"

void ff7_condor_fix_unit_texture_load(uint32_t unk, struc_3 *struc_3)
{
ff7_externals.make_struc3(unk, struc_3);

// tell the game engine the files live inside the lgp file
if ( *ff7_externals.condor_uses_lgp )
{
struc_3->file_context.use_lgp = 1;
struc_3->file_context.lgp_num = 6;
struc_3->file_context.name_mangler = 0;
}
}
7 changes: 7 additions & 0 deletions src/ff7_data.h
Original file line number Diff line number Diff line change
Expand Up @@ -617,6 +617,13 @@ void ff7_find_externals(struct ff7_game_obj* game_object)
ff7_externals.snowboard_loop_sub_72381C = get_relative_call(snowboard_main_loop, 0x7D);
ff7_externals.sub_779E14 = get_relative_call(chocobo_main_loop, 0x70);

ff7_externals.condor_enter = get_absolute_value(main_loop, 0xA28);
ff7_externals.condor_exit = get_absolute_value(main_loop, 0xA2F);
ff7_externals.sub_5F7756 = get_relative_call(ff7_externals.condor_enter, 0x1B0);
ff7_externals.sub_5F4273 = get_relative_call(ff7_externals.sub_5F7756, 0xA2);
ff7_externals.sub_5F342C = get_relative_call(ff7_externals.sub_5F4273, 0xBF);
ff7_externals.condor_uses_lgp = (DWORD*)get_absolute_value(ff7_externals.sub_5F342C, 0x7A);

ff7_externals.fps_limiter_swirl = get_relative_call(swirl_main_loop, 0xDE);
ff7_externals.fps_limiter_battle = get_relative_call(battle_main_loop, 0x1DD);
ff7_externals.fps_limiter_coaster = get_relative_call(coaster_main_loop, 0x51);
Expand Down
8 changes: 8 additions & 0 deletions src/ff7_opengl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,14 @@ void ff7_init_hooks(struct game_obj *_game_object)
patch_code_byte(ff7_externals.coaster_sub_5EE150 + 0x16D, 5);
patch_code_byte(ff7_externals.coaster_sub_5EE150 + 0x190, 5);

// condor minigame load unit textures fix
replace_call_function(ff7_externals.sub_5F342C + 0x66E, ff7_condor_fix_unit_texture_load);
replace_call_function(ff7_externals.sub_5F342C + 0x7B9, ff7_condor_fix_unit_texture_load);
replace_call_function(ff7_externals.sub_5F342C + 0x904, ff7_condor_fix_unit_texture_load);
replace_call_function(ff7_externals.sub_5F342C + 0x977, ff7_condor_fix_unit_texture_load);
replace_call_function(ff7_externals.sub_5F342C + 0x9EA, ff7_condor_fix_unit_texture_load);
replace_call_function(ff7_externals.sub_5F342C + 0xA35, ff7_condor_fix_unit_texture_load);

// ##################################
// menu UI glitch fix
// ##################################
Expand Down

0 comments on commit 827b939

Please sign in to comment.