Skip to content

Commit

Permalink
Common: Play custom main_menu music file on new game screen
Browse files Browse the repository at this point in the history
  • Loading branch information
julianxhokaxhiu committed Dec 16, 2024
1 parent c26c107 commit 7f3739e
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 2 deletions.
4 changes: 4 additions & 0 deletions Changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

- Full commit list since last stable release: https://github.com/julianxhokaxhiu/FFNx/compare/1.21.3...master

## Commmon

- Music: Add the ability to play a custom `main_menu` music file on the new game screen.

# 1.21.3

- Full commit list since last stable release: https://github.com/julianxhokaxhiu/FFNx/compare/1.21.2...1.21.3
Expand Down
3 changes: 3 additions & 0 deletions src/common.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1246,6 +1246,9 @@ void common_flip(struct game_obj *game_object)
// Update day night time cycle
if (!ff8 && enable_time_cycle) ff7::time.update();

// Handle main menu background music
handle_mainmenu_playback();

// FF8 does not clear the screen properly in the card game module
if (ff8)
{
Expand Down
5 changes: 3 additions & 2 deletions src/ff7_data.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ static struct game_mode ff7_modes[] = {
{FF7_MODE_BATTLE_MENU, "MODE_BATTLE_MENU", MODE_MENU, true },
{FF7_MODE_UNKNOWN18, "MODE_UNKNOWN18", MODE_UNKNOWN, false },
{FF7_MODE_EXIT, "MODE_EXIT", MODE_EXIT, true },
{FF7_MODE_MAIN_MENU, "MODE_MAIN_MENU", MODE_MENU, true },
{FF7_MODE_MAIN_MENU, "MODE_MAIN_MENU", MODE_MAIN_MENU, true },
{FF7_MODE_UNKNOWN21, "MODE_UNKNOWN21", MODE_UNKNOWN, false },
{FF7_MODE_INTRO, "MODE_INTRO", MODE_INTRO, true },
{FF7_MODE_SWIRL, "MODE_SWIRL", MODE_SWIRL, true },
Expand Down Expand Up @@ -121,6 +121,7 @@ inline void ff7_find_externals(struct ff7_game_obj* game_object)
ff7_set_main_loop(MODE_CREDITS, credits_main_loop);
menu_main_loop = get_absolute_value(main_loop, 0x62E);
ff7_set_main_loop(MODE_MENU, menu_main_loop);
ff7_set_main_loop(MODE_MAIN_MENU, menu_main_loop);
battle_main_loop = get_absolute_value(main_loop, 0x89A);
ff7_set_main_loop(MODE_BATTLE, battle_main_loop);
field_main_loop = get_absolute_value(main_loop, 0x8F8);
Expand Down Expand Up @@ -299,7 +300,7 @@ inline void ff7_find_externals(struct ff7_game_obj* game_object)
ff7_externals.config_menu_sub = ff7_externals.menu_subs_call_table[8];
ff7_externals.menu_sub_6FEDB0 = ff7_externals.menu_subs_call_table[10];

ff7_externals.config_initialize = get_relative_call(main_init_loop, 0x4B0);
ff7_externals.config_initialize = get_relative_call(main_init_loop, 0x4B0);

ff7_externals.menu_tutorial_window_state = (BYTE*)get_absolute_value((uint32_t)ff7_externals.menu_tutorial_sub_6C49FD, 0x9);
ff7_externals.menu_tutorial_window_text_ptr = (DWORD*)get_absolute_value((uint32_t)ff7_externals.menu_tutorial_sub_6C49FD, 0x18);
Expand Down
25 changes: 25 additions & 0 deletions src/music.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,31 @@ uint8_t ff7_last_akao_call_type = 0;
uint32_t ff7_last_music_id = 0;
int16_t ff7_next_field_music_relative_id = -1;

void handle_mainmenu_playback()
{
struct game_mode *mode = getmode_cached();
static bool is_main_menu = false;

switch (mode->driver_mode)
{
case MODE_MAIN_MENU:
if (!is_main_menu)
{
is_main_menu = true;

nxAudioEngine.playMusic("main_menu", 0xFF, 0);
}
break;
default:
if (is_main_menu)
{
nxAudioEngine.stopMusic();
is_main_menu = false;
}
break;
}
}

void music_flush()
{
nxAudioEngine.flush();
Expand Down
1 change: 1 addition & 0 deletions src/music.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,5 +23,6 @@

#include <stdint.h>

void handle_mainmenu_playback();
void ff7_play_midi(uint32_t music_id);
void music_init();

0 comments on commit 7f3739e

Please sign in to comment.