Skip to content

Commit

Permalink
fix sound effects pr
Browse files Browse the repository at this point in the history
  • Loading branch information
KrahJohlito committed Dec 15, 2018
1 parent 6301f9e commit cea2f0c
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 13 deletions.
2 changes: 1 addition & 1 deletion include/sound.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

extern struct audsrv_adpcm_t sfx[NUM_SFX_FILES];

int sfxInit(void);
int sfxInit(int bootSnd);
void sfxVolume(void);

int thmSfxEnabled;
Expand Down
7 changes: 3 additions & 4 deletions src/gui.c
Original file line number Diff line number Diff line change
Expand Up @@ -556,11 +556,10 @@ void guiShowUIConfig(void)
diaGetInt(diaUIConfig, UICFG_YOFF, &gYOff);
diaGetInt(diaUIConfig, UICFG_OVERSCAN, &gOverscan);

int changed = thmSetGuiValue(themeID, changed);
if (changed) {
sfxInit();
}
applyConfig(themeID, langID);
//wait 70ms for confirm sound to finish playing before clearing buffer
guiDelay(0070);
sfxInit(0);
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/opl.c
Original file line number Diff line number Diff line change
Expand Up @@ -1315,7 +1315,7 @@ static void deferredAudioInit(void)
LOG("Failed to initialize audsrv\n");
LOG("Audsrv returned error string: %s\n", audsrv_get_error_string());

ret = sfxInit();
ret = sfxInit(1);
if (ret >= 0)
LOG("sfxInit: %d samples loaded.\n", ret);
else
Expand Down
20 changes: 13 additions & 7 deletions src/sound.c
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/*-- Theme Sound Effects -------------------------------------------------------------------------------------------------
/*-- Theme Sound Effects ----------------------------------------------------------------------------------------------
---- SP193 wrote the code, I just made small changes. ---------------------------------------------------------------*/

#include <audsrv.h>
Expand Down Expand Up @@ -154,7 +154,7 @@ void sfxVolume(void)
}

//Returns number of audio files successfully loaded, < 0 if an unrecoverable error occurred.
int sfxInit(void)
int sfxInit(int bootSnd)
{
char full_path[256];
int ret, i, loaded;
Expand All @@ -163,14 +163,20 @@ int sfxInit(void)

sfxInitDefaults();
sfxVolume();

ret = getFadeDelay();
if (ret != 0) {
gFadeDelay = 1200;
//boot sound only needs to be read/loaded at init
if (bootSnd) {
ret = getFadeDelay();
if (ret != 0) {
gFadeDelay = 1200;
}
i = 0;
}
else {
i = 1;
}

loaded = 0;
for (i = 0; i < NUM_SFX_FILES; i++)
for (; i < NUM_SFX_FILES; i++)
{
if (thmSfxEnabled < 0)
{
Expand Down

0 comments on commit cea2f0c

Please sign in to comment.