Skip to content

Commit 1692b67

Browse files
FF7: Add ambient support for battles
Fixes #239
1 parent c6fe6de commit 1692b67

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

src/ff7/misc.cpp

+12-2
Original file line numberDiff line numberDiff line change
@@ -388,10 +388,19 @@ void ff7_handle_ambient_playback()
388388
{
389389
struct game_mode *mode = getmode_cached();
390390
static char filename[64]{0};
391-
static WORD last_field_id = 0;
391+
static WORD last_field_id = 0, last_battle_id = 0;
392392

393393
switch(mode->driver_mode)
394394
{
395+
case MODE_BATTLE:
396+
if (last_battle_id != ff7_externals.modules_global_object->battle_id)
397+
{
398+
last_battle_id = ff7_externals.modules_global_object->battle_id;
399+
400+
sprintf(filename, "bat_%d", last_battle_id);
401+
nxAudioEngine.playAmbient(filename);
402+
}
403+
break;
395404
case MODE_FIELD:
396405
if (last_field_id != *ff7_externals.field_id)
397406
{
@@ -402,10 +411,11 @@ void ff7_handle_ambient_playback()
402411
}
403412
break;
404413
default:
405-
if (last_field_id != 0)
414+
if (last_field_id != 0 || last_battle_id != 0)
406415
{
407416
nxAudioEngine.stopAmbient();
408417
last_field_id = 0;
418+
last_battle_id = 0;
409419
}
410420
break;
411421
}

0 commit comments

Comments
 (0)