Small library bug

support for the gba/nds sound library from www.maxmod.org

Moderator: eKid

Post Reply
kuwanger
Posts: 3
Joined: Mon Sep 28, 2009 1:14 am

Small library bug

Post by kuwanger » Wed May 05, 2010 2:32 pm

I noticed a small bug in maxmod 1.06. There's code in source/mm_mas.s that looks something like this:

Code: Select all

mpp_Update_ACHN_notest:
        ...
        push {lr}
        ...
        ldrb    r0, [r6, #MCA_SAMPLE]
        sub     r0, #1
        bcc     .mppt_achn_nostart @ no sample!!
        ...
.mppt_achn_noinst:
        
        push    {r4}
        ...
.mppt_achn_nostart:
        ...
.mpp_achn_updated:
        pop     {r4}
        pop     {r0}
        bx      r0
Ie, there's a bit of code that might skip pushing r4, resulting in lr being popped into r4 and junk into r0 which is then jumped to. So, I made a simple diff to fix this:

Code: Select all

diff -ur maxmod_1.06src-org/source/mm_mas.s maxmod_1.06src/source/mm_mas.s
--- maxmod_1.06src-org/source/mm_mas.s  2008-12-23 12:51:50.000000000 -0500
+++ maxmod_1.06src/source/mm_mas.s      2010-05-05 07:18:08.000000000 -0400
@@ -2002,7 +2002,7 @@

        ldrb    r0, [r6, #MCA_SAMPLE]
        sub     r0, #1
-       bcc     .mppt_achn_nostart      @ no sample!!
+       bcc     .mppt_achn_nostart_push @ no sample!!

        @bl     mpp_SamplePointer
        mpp_SamplePointer
@@ -2040,6 +2040,9 @@
        bl      mpph_PitchSlide_Up              @ pitch slide
 #endif 
        b       .mppt_av_finished               @
+.mppt_achn_nostart_push:       @ push r4 before jump
+       push {r4}
+       b .mppt_achn_nostart
 .mppt_av_minus:                                        @ --slide down
        neg     r1, r2                          @ r1 = slide value
        mov     r0, r5                          @ r0 = frequency
I'm pretty sure this is the correct behavior. Anyways, I hope this is useful.

Post Reply

Who is online

Users browsing this forum: No registered users and 2 guests