From 450fab6ad76e5d23b7d898abd8c3e8112b6e3053 Mon Sep 17 00:00:00 2001 From: Treeki Date: Sun, 9 Jun 2013 23:33:45 +0200 Subject: half assed fix attempts for a few bugs --- bugfixes.yaml | 6 ++++++ src/koopatlas/mapmusic.cpp | 9 +++++++-- src/randomcrap.S | 14 ++++++++++++++ 3 files changed, 27 insertions(+), 2 deletions(-) diff --git a/bugfixes.yaml b/bugfixes.yaml index 611bea3..d74ecc9 100644 --- a/bugfixes.yaml +++ b/bugfixes.yaml @@ -3,6 +3,12 @@ # yaml, hasn't it... source_files: [../src/randomcrap.S, ../src/music.cpp, ../src/fix38.S, ../src/nullsub.S, ../src/newer.cpp]#, ../src/anmconstruct.S] hooks: + - name: TryAndFixScoreGlitch + type: branch_insn + branch_type: bl + src_addr_pal: 0x8010D014 + target_func: 'TryAndFixScoreGlitch' + - name: ReplaceExceptionOccurred type: branch_insn branch_type: bl diff --git a/src/koopatlas/mapmusic.cpp b/src/koopatlas/mapmusic.cpp index d73d3da..f061059 100644 --- a/src/koopatlas/mapmusic.cpp +++ b/src/koopatlas/mapmusic.cpp @@ -38,7 +38,8 @@ void dKPMusic::play(int id) { } else { OSReport("Will switch; Fading out current track 2 over %d frames\n", FADE_OUT_LEN); - s_handle.SetTrackVolume(1<<1, FADE_OUT_LEN, 0.0f); + if (s_handle.Exists()) + s_handle.SetTrackVolume(1<<1, FADE_OUT_LEN, 0.0f); s_nextSong = id; s_countdownToSwitch = FADE_OUT_LEN; } @@ -121,6 +122,9 @@ void dKPMusic::execute() { u8 *sourceData = ((u8*)(s_adpcmInfoLoader.buffer)) + (0x30*sourceBlockID); nw4r::db::Exception_Printf_("Using ADPCM data for channel %d from block %d, data at %p\n", i, sourceBlockID, sourceData); + if (!voice) + continue; + Voice_SetADPCMLoop(voice, i, sourceData+0x28); // loop through all axVoices @@ -145,7 +149,8 @@ void dKPMusic::execute() { s_countdownToFadeIn--; if (s_countdownToFadeIn == 0) { OSReport("Going to fade in the second track now!\n"); - s_handle.SetTrackVolume(1<<1, FADE_IN_LEN, 1.0f); + if (s_handle.Exists()) + s_handle.SetTrackVolume(1<<1, FADE_IN_LEN, 1.0f); } } } diff --git a/src/randomcrap.S b/src/randomcrap.S index 6d347d5..1e09766 100644 --- a/src/randomcrap.S +++ b/src/randomcrap.S @@ -1,5 +1,19 @@ .text +.global TryAndFixScoreGlitch +TryAndFixScoreGlitch: + lwz r0, 0x4A10(r3) + + lis r8, 0x8000 + cmplw r3, r8 + bgtlr + + lwz r31, 0xC(r1) + lwz r0, 0x14(r1) + mtlr r0 + addi r1, r1, 0x10 + blr + .global ThwompNewAutoDestruction ThwompNewAutoDestruction: lfs f1, 0xB0(r31) -- cgit v1.2.3