Skip to content

Commit

Permalink
Merge 'Improve music sequence identification for the two relevant SFX…
Browse files Browse the repository at this point in the history
… settings' (#2075)
  • Loading branch information
cjohnson57 committed Aug 26, 2023
2 parents d09f6d5 + 045e5ed commit 1f06fa4
Show file tree
Hide file tree
Showing 8 changed files with 8,891 additions and 8,883 deletions.
528 changes: 264 additions & 264 deletions ASM/build/asm_symbols.txt

Large diffs are not rendered by default.

Binary file modified ASM/build/bundle.o
Binary file not shown.
166 changes: 83 additions & 83 deletions ASM/build/c_symbols.txt

Large diffs are not rendered by default.

13 changes: 7 additions & 6 deletions ASM/c/music.c
Original file line number Diff line number Diff line change
Expand Up @@ -3,33 +3,34 @@
extern uint8_t CFG_SPEEDUP_MUSIC_FOR_LAST_TRIFORCE_PIECE;
extern uint8_t CFG_SLOWDOWN_MUSIC_WHEN_LOWHP;

static uint16_t previousSceneIndex = 0;
static uint16_t previousSeqIndexChange = 0;
static uint8_t isSlowedDown = 0;
static uint8_t isSpeedup = 0;
void manage_music_changes() {

if (CFG_SPEEDUP_MUSIC_FOR_LAST_TRIFORCE_PIECE && !isSlowedDown) {
if (z64_file.scene_flags[0x48].unk_00_ == TRIFORCE_PIECES_REQUIRED - 1 && z64_game.scene_index != previousSceneIndex) {
if (z64_file.scene_flags[0x48].unk_00_ == TRIFORCE_PIECES_REQUIRED - 1 &&
z64_Audio_GetActiveSeqId(0) != previousSeqIndexChange) {
// One tone up : 2^(2/12)
z64_ScalePitchAndTempo(1.12246f, 0);
previousSceneIndex = z64_game.scene_index;
previousSeqIndexChange = z64_Audio_GetActiveSeqId(0);
isSpeedup = 1;
}
}
if (CFG_SLOWDOWN_MUSIC_WHEN_LOWHP) {
if (Health_IsCritical()) {
if (z64_game.scene_index != previousSceneIndex || isSpeedup) {
if (z64_Audio_GetActiveSeqId(0) != previousSeqIndexChange || isSpeedup) {
// One tone down : 2^(-2/12)
z64_ScalePitchAndTempo(0.89089f, 0);
previousSceneIndex = z64_game.scene_index;
previousSeqIndexChange = z64_Audio_GetActiveSeqId(0);
isSlowedDown = 1;
isSpeedup = 0;
}
}
else if (isSlowedDown) {
z64_ScalePitchAndTempo(1.0f, 0);
isSlowedDown = 0;
previousSceneIndex = 0;
previousSeqIndexChange = 0;
}
}
}
Expand Down
3 changes: 3 additions & 0 deletions ASM/c/z64.h
Original file line number Diff line number Diff line change
Expand Up @@ -1939,6 +1939,7 @@ typedef enum {
#define z64_ScalePitchAndTempo_addr 0x800C64A0
#define Font_LoadChar_addr 0x8005BCE4
#define GetItem_Draw_addr 0x800570C0
#define z64_Audio_GetActiveSeqId_addr 0x800CAB18

/* rom addresses */
#define z64_icon_item_static_vaddr 0x007BD000
Expand Down Expand Up @@ -2021,6 +2022,7 @@ typedef void(*Message_ContinueTextbox_proc) (z64_game_t *play, uint16_t textId);
typedef void(*PlaySFX_proc) (uint16_t sfxId);
typedef void(*z64_ScalePitchAndTempo_proc)(float scaleTempoAndFreq, uint8_t duration);
typedef void(*GetItem_Draw_proc)(z64_game_t *game, int16_t drawId);
typedef uint16_t (*z64_Audio_GetActiveSeqId_proc)(uint8_t seqId);

/* data */
#define z64_file_mq (*(OSMesgQueue*) z64_file_mq_addr)
Expand Down Expand Up @@ -2106,6 +2108,7 @@ typedef void(*GetItem_Draw_proc)(z64_game_t *game, int16_t drawId);

#define Message_ContinueTextbox ((Message_ContinueTextbox_proc)Message_ContinueTextbox_addr)
#define z64_ScalePitchAndTempo ((z64_ScalePitchAndTempo_proc)z64_ScalePitchAndTempo_addr)
#define z64_Audio_GetActiveSeqId ((z64_Audio_GetActiveSeqId_proc)z64_Audio_GetActiveSeqId_addr)

#define PlaySFX ((PlaySFX_proc)PlaySFX_addr)
#define Font_LoadChar ((Font_LoadChar_proc)Font_LoadChar_addr)
Expand Down
Loading

0 comments on commit 1f06fa4

Please sign in to comment.