diff --git a/CMakeLists.txt b/CMakeLists.txt index 1871d1fc..183b89aa 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -239,6 +239,10 @@ foreach(FFNX_SHADER IN LISTS FFNX_SHADERS) endforeach() endforeach() +# List .gitkeep files to remove them on INSTALL +FILE(GLOB_RECURSE HEXT_GIT_KEEP_FILES RELATIVE ${CMAKE_CURRENT_SOURCE_DIR}/misc/ ${CMAKE_CURRENT_SOURCE_DIR}/misc/hext/ff8/**/.gitkeep) +LIST(TRANSFORM HEXT_GIT_KEEP_FILES PREPEND ${CMAKE_BINARY_DIR}/bin/) + # INSTALL add_custom_command( TARGET ${RELEASE_NAME} @@ -278,6 +282,8 @@ add_custom_command( COMMAND ${CMAKE_COMMAND} -E copy_directory ${CMAKE_CURRENT_SOURCE_DIR}/misc/hext ${CMAKE_BINARY_DIR}/bin/hext + COMMAND ${CMAKE_COMMAND} -E rm ${HEXT_GIT_KEEP_FILES} + # ambient .toml COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_SOURCE_DIR}/misc/${RELEASE_NAME}.ambient.toml diff --git a/Changelog.md b/Changelog.md index d18ecbf9..9da23f9c 100644 --- a/Changelog.md +++ b/Changelog.md @@ -31,6 +31,9 @@ - SFX: Add missing support for audio effects to be stopped in time - Speedhack: Fix support in field which were not getting the real speed up despite FFNx prompting it on screen. +# FF8 Steam + +- Files: Fix `app_path` option support ( https://github.com/julianxhokaxhiu/FFNx/pull/714 ) # 1.19.1 diff --git a/src/common.cpp b/src/common.cpp index 4d5c409d..c913ef5b 100644 --- a/src/common.cpp +++ b/src/common.cpp @@ -2585,7 +2585,7 @@ time_t qpc_diff_time(time_t* t1, time_t* t2, time_t* out) if (ff8) ret *= gamehacks.getCurrentSpeedhack(); - if (out != NULL) *out = ret; + if (out != nullptr) *out = ret; return ret; } @@ -2703,7 +2703,7 @@ uint32_t get_version() void get_data_lang_path(PCHAR buffer) { - strcpy(buffer, basedir); + strcpy(buffer, ff8 ? ff8_externals.app_path : basedir); PathAppendA(buffer, R"(data\lang-)"); switch (version) { @@ -3282,6 +3282,7 @@ __declspec(dllexport) HANDLE __stdcall dotemuCreateFileA(LPCSTR lpFileName, DWOR if (strstr(lpFileName, "DISK1") != NULL || strstr(lpFileName, "DISK2") != NULL || strstr(lpFileName, "DISK3") != NULL || strstr(lpFileName, "DISK4") != NULL) { + PathAppendA(newPath, ff8_externals.app_path); PathAppendA(newPath, R"(data\disk)"); PathAppendA(newPath, pos); diff --git a/src/ff7/misc.cpp b/src/ff7/misc.cpp index 5021826b..bb23a877 100644 --- a/src/ff7/misc.cpp +++ b/src/ff7/misc.cpp @@ -146,7 +146,7 @@ void ff7_use_analogue_controls(float analog_threshold) float horizontalRotSpeed = 0.0f; const float zoomSpeedMax = 1000.0f; float zoomSpeed = 0.0f; - + float invertedVerticalCameraScale = -1.0; if(enable_inverted_vertical_camera_controls) invertedVerticalCameraScale = 1.0; @@ -181,9 +181,9 @@ void ff7_use_analogue_controls(float analog_threshold) else if(gamepad.leftStickY < -analog_threshold && !(gamepad.leftStickX < -analog_threshold || gamepad.leftStickX > analog_threshold)) inputDir = {0.0f, -1.0f, 0.0f}; - if (gamepad.IsPressed(XINPUT_GAMEPAD_RIGHT_THUMB) + if (gamepad.IsPressed(XINPUT_GAMEPAD_RIGHT_THUMB) && std::abs(gamepad.rightStickX) < right_analog_stick_deadzone - && std::abs(gamepad.rightStickY) < right_analog_stick_deadzone) + && std::abs(gamepad.rightStickY) < right_analog_stick_deadzone) { if(!isCameraReset) { @@ -191,7 +191,7 @@ void ff7_use_analogue_controls(float analog_threshold) ff7::battle::camera.reset(); isCameraReset = true; } - } else + } else { isCameraReset = false; @@ -246,11 +246,11 @@ void ff7_use_analogue_controls(float analog_threshold) inputDir = {0.707f, -0.707f, 0.0f}; else if(joystick.GetState()->lY > joystick.GetDeadZone(analog_threshold) && !(joystick.GetState()->lX < joystick.GetDeadZone(-analog_threshold) || joystick.GetState()->lX > joystick.GetDeadZone(analog_threshold))) - inputDir = {0.0f, -1.0f, 0.0f}; + inputDir = {0.0f, -1.0f, 0.0f}; - if ((joystick.GetState()->rgbButtons[11] & 0x80) + if ((joystick.GetState()->rgbButtons[11] & 0x80) && std::abs(joystick.GetState()->lRz) < joystick.GetDeadZone(right_analog_stick_deadzone) - && std::abs(joystick.GetState()->lZ) < joystick.GetDeadZone(right_analog_stick_deadzone)) + && std::abs(joystick.GetState()->lZ) < joystick.GetDeadZone(right_analog_stick_deadzone)) { if(!isCameraReset) { @@ -258,8 +258,8 @@ void ff7_use_analogue_controls(float analog_threshold) ff7::battle::camera.reset(); isCameraReset = true; } - } else - { + } else + { isCameraReset = false; bx::Vec3 rightAnalogDir( @@ -267,7 +267,7 @@ void ff7_use_analogue_controls(float analog_threshold) static_cast(joystick.GetState()->lRz) / static_cast(SHRT_MAX), 0.0f); float length = std::min(bx::length(rightAnalogDir), 1.0f); if(length > right_analog_stick_deadzone) - { + { rightAnalogDir = bx::normalize(rightAnalogDir); float scale = (length - right_analog_stick_deadzone) / (1.0 - right_analog_stick_deadzone); rightAnalogDir.x *= scale; @@ -340,7 +340,7 @@ struct ff7_gamepad_status* ff7_update_gamepad_status() { float analog_threshold = enable_auto_run ? left_analog_stick_deadzone + 0.25f * (1.0f - left_analog_stick_deadzone) : 0.5f; float run_threshold = left_analog_stick_deadzone + 0.75f * (1.0f - left_analog_stick_deadzone); - + // Reset ZeroMemory(ff7_externals.gamepad_status, sizeof(ff7_gamepad_status)); gamepad_analogue_intent = INTENT_NONE; @@ -420,7 +420,7 @@ struct ff7_gamepad_status* ff7_update_gamepad_status() // Update the player intent based on the analogue movement if (enable_auto_run) { - bx::Vec3 joyDir = {static_cast(joystick.GetState()->lX) / static_cast(joystick.GetDeadZone(1.0f)), + bx::Vec3 joyDir = {static_cast(joystick.GetState()->lX) / static_cast(joystick.GetDeadZone(1.0f)), static_cast(joystick.GetState()->lY) / static_cast(joystick.GetDeadZone(1.0f)), 0.0f}; auto joyLength = std::min(bx::length(joyDir), 1.0f); if (joyLength > run_threshold) gamepad_analogue_intent = INTENT_RUN; @@ -634,9 +634,10 @@ void ff7_limit_fps() } framerate *= gamehacks.getCurrentSpeedhack(); + double frame_time = game_object->countspersecond / framerate; do qpc_get_time(&gametime); - while ((gametime > last_gametime) && qpc_diff_time(&gametime, &last_gametime, NULL) < ((ff7_game_obj*)common_externals.get_game_object())->countspersecond / framerate); + while (gametime > last_gametime && qpc_diff_time(&gametime, &last_gametime, nullptr) < frame_time); last_gametime = gametime; } diff --git a/src/ff8.h b/src/ff8.h index e86f230c..d2cf455a 100644 --- a/src/ff8.h +++ b/src/ff8.h @@ -1507,6 +1507,7 @@ struct ff8_externals uint32_t scan_text_data; uint32_t scan_text_positions; uint32_t fps_limiter; + double *time_volume_change_related_1A78BE0; }; void ff8gl_field_78(struct ff8_polygon_set *polygon_set, struct ff8_game_obj *game_object); diff --git a/src/ff8_data.cpp b/src/ff8_data.cpp index fd0575b6..f3d47be1 100644 --- a/src/ff8_data.cpp +++ b/src/ff8_data.cpp @@ -823,6 +823,7 @@ void ff8_find_externals() ff8_externals.scan_text_data = get_absolute_value(ff8_externals.scan_get_text_sub_B687C0, 0x27); ff8_externals.fps_limiter = get_relative_call(ff8_externals.field_main_loop, 0x261); + ff8_externals.time_volume_change_related_1A78BE0 = (double *)get_absolute_value(ff8_externals.fps_limiter, 0x3F); // Required by Steam edition switch (version) diff --git a/src/ff8_opengl.cpp b/src/ff8_opengl.cpp index 77de3172..436d7a78 100644 --- a/src/ff8_opengl.cpp +++ b/src/ff8_opengl.cpp @@ -905,21 +905,9 @@ int ff8_limit_fps() struct ff8_game_obj *game_object = (ff8_game_obj *)common_externals.get_game_object(); struct game_mode *mode = getmode_cached(); - switch(mode->driver_mode) - { - case MODE_FIELD: - if (ff8_externals.movie_object->movie_is_playing) - { - // Some movies do not expect to be frame limited - qpc_get_time(&last_gametime); - return 0; - } - break; - case MODE_GAMEOVER: - // Gameover screen has nothing to limit - qpc_get_time(&last_gametime); - return 0; - } + // For cross music play (vanilla music only) + qpc_get_time(&gametime); + *ff8_externals.time_volume_change_related_1A78BE0 = (1000.0 / game_object->countspersecond) * qpc_diff_time(&gametime, &last_gametime, nullptr); if (ff8_fps_limiter < FPS_LIMITER_60FPS) { @@ -948,9 +936,10 @@ int ff8_limit_fps() } framerate *= gamehacks.getCurrentSpeedhack(); + double frame_time = game_object->countspersecond / framerate; do qpc_get_time(&gametime); - while ((gametime > last_gametime) && qpc_diff_time(&gametime, &last_gametime, NULL) < ((ff8_game_obj*)common_externals.get_game_object())->countspersecond / framerate); + while (gametime > last_gametime && qpc_diff_time(&gametime, &last_gametime, nullptr) < frame_time); last_gametime = gametime; diff --git a/src/movies.cpp b/src/movies.cpp index 0aff4abf..4c14f041 100644 --- a/src/movies.cpp +++ b/src/movies.cpp @@ -196,12 +196,7 @@ uint32_t ff8_movie_frames; void ff8_prepare_movie(uint32_t disc, uint32_t movie) { - char fmvName[260]; - char camName[260]; - - char newFmvName[260]; - char newCamName[260]; - + char fmvName[MAX_PATH], camName[MAX_PATH], newFmvName[MAX_PATH], newCamName[MAX_PATH]; uint32_t camOffset = 0; // Unexpected cases default to current disk @@ -209,8 +204,8 @@ void ff8_prepare_movie(uint32_t disc, uint32_t movie) disc = ff8_currentdisk - 1; } - _snprintf(fmvName, sizeof(fmvName), "data/movies/disc%02i_%02ih.%s", disc, movie, ffmpeg_video_ext.c_str()); - _snprintf(camName, sizeof(camName), "data/movies/disc%02i_%02i.cam", disc, movie); + _snprintf(fmvName, sizeof(fmvName), "%s/data/movies/disc%02i_%02ih.%s", ff8_externals.app_path, disc, movie, ffmpeg_video_ext.c_str()); + _snprintf(camName, sizeof(camName), "%s/data/movies/disc%02i_%02i.cam", ff8_externals.app_path, disc, movie); redirect_path_with_override(fmvName, newFmvName, sizeof(newFmvName)); redirect_path_with_override(camName, newCamName, sizeof(newCamName)); diff --git a/src/sfx.cpp b/src/sfx.cpp index ccda1c2d..9ee833c7 100644 --- a/src/sfx.cpp +++ b/src/sfx.cpp @@ -666,7 +666,7 @@ void sfx_process_footstep(bool is_player_moving) if (*ff7_externals.input_run_button_status != 0 || gamepad_analogue_intent == INTENT_RUN) pace = 0.30f; qpc_get_time(¤t_playback_time); - if (qpc_diff_time(¤t_playback_time, &last_playback_time, NULL) >= ((ff7_game_obj*)common_externals.get_game_object())->countspersecond * pace) + if (qpc_diff_time(¤t_playback_time, &last_playback_time, nullptr) >= ((ff7_game_obj*)common_externals.get_game_object())->countspersecond * pace) { if (use_external_sfx) ff7_sfx_play_layered(0.0f, 159, 7); else common_externals.play_sfx(159); @@ -686,7 +686,7 @@ void sfx_process_wm_footstep(int player_model_id, int player_walkmap_type) pace = 0.5f; qpc_get_time(¤t_playback_time); - if (qpc_diff_time(¤t_playback_time, &last_playback_time, NULL) >= ((ff7_game_obj*)common_externals.get_game_object())->countspersecond * pace) + if (qpc_diff_time(¤t_playback_time, &last_playback_time, nullptr) >= ((ff7_game_obj*)common_externals.get_game_object())->countspersecond * pace) { char track_name[64]; if (use_external_sfx)