Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Assert for queued sample count being too high #56

Open
Mr-Wiseguy opened this issue Jul 28, 2024 · 0 comments
Open

Assert for queued sample count being too high #56

Mr-Wiseguy opened this issue Jul 28, 2024 · 0 comments

Comments

@Mr-Wiseguy
Copy link
Member

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant