Skip to content

Assert for queued sample count being too high #56

@Mr-Wiseguy

Description

@Mr-Wiseguy

Some games, such as Mystical Ninja Starring Goemon, have bugs in their audio code that trigger an underflow in the sample count calculation. This results in them sending a negative value converted to an unsigned value as the queued sample count to the runtime, which results in problems when the runtime tries to allocate a buffer to hold 4 billion samples.

There are two things to do here: the first is to mask the sample count to 17 bits as the original hardware did (the AI_LENGTH register). However, while that solves the 4 billion sample issue, it'll still cause audio glitches in a given game. Therefore, the runtime should also cast the input value to a signed 32-bit value and check if it's less than zero before the mask, and then raise an assert or warning if so. That will help people who are recompiling games with this type of bug figure out that there's code that has to be fixed in the game.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions