Skip to content

when music loops, it starts at wrong speed #31

@ricardoquesada

Description

@ricardoquesada

The speed of the song changes when it loops and the Y register has garbage.

And easy way to reproduce the bug is:

play_music:
    ldy #$28
    jsr $1003
    rts

and play the attached .sid.

uc-marionette.sid.zip

There is a path in the play code that it seems that Y is being used without being initialized.

The code that seems to have the bug is this one:

j104D   LDA a1704               ; play routine
        BEQ b1088               ; if this condition is triggered...
        LDA #$02
        STA a171A
        LDX #$8C
        LDA #$00
b105B   DEX 
        STA f1724,X
        BNE b105B
        LDX #$02
b1063   LDA #$02
        STA f1736,X
        LDA #$FE
        STA f1733,X
        DEX 
        BPL b1063
        LDA #$0F
        STA a1720
        LDA #$00
        STA a176D
        STA a176C
        LDA #$F0
        STA $D417
        LDA #$00
        STA a1704
        RTS 

b1088   DEC a171A
        BPL b10B2
        LDA a1719
        CMP #$02
        BPL b10A3               ; ... and if this condition is triggered...
        LDY a171C
        LDA f1E95,Y
        STA a171B
        CMP #$02
        BPL b10A3
        LDA #$02
b10A3   STA a171A               ; then Y is being used without being initialized
        INY 
        LDA f1E95,Y

Although it seems this commit fixes it, but I haven't tried. It seems that that commit is not present on the latest release:
e1267c8

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions