Skip to content

Implement MSU-1 Revision 2 Resume Spec#3

Open
Sunlitspace542 wants to merge 4 commits intonesdev-org:masterfrom
Sunlitspace542:master
Open

Implement MSU-1 Revision 2 Resume Spec#3
Sunlitspace542 wants to merge 4 commits intonesdev-org:masterfrom
Sunlitspace542:master

Conversation

@Sunlitspace542
Copy link
Copy Markdown

This implements the revision 2 MSU-1 specification as used by the SD2SNES/FXPak Pro and other emulators (Ares, BSNES, SNES9x).
When $2007 (MSU control register) is written to so that only the resume bit is set, the current track number and offset into it are saved. The audio track can then be resumed from the saved point by writing the matching track number to $2004+$2005 (MSU track select register). The chip revision ($2000 read, bits 0-2) has been changed to '2' to match the other implementations of this spec.

I claim no copyright on these changes, and I accept any licensing changes.

…ype should match trackSelect

This fixes the click/pop when track 0 is played with the resume variables initialized to defaults
@Sunlitspace542 Sunlitspace542 changed the title Implement MSU-1 Resume Spec Implement MSU-1 Revision 2 Resume Spec Mar 1, 2026
@zeta0134
Copy link
Copy Markdown
Collaborator

I'm not personally familiar with this chip or the feature, so I'm hesitating to merge this just because I'm not sure how to test the changes. Can you name some software (homebrew or otherwise) that depends on it?

@Sunlitspace542
Copy link
Copy Markdown
Author

Chrono-Trigger MSU-1 uses the resume feature.

The resume bit doesn't seem to be a bit of storage, but rather a command to store the current state, so we don't need to store it or serialize it.

The SMSU-1 spec says the resume bit is ignored if it's set at the same time as bit 1, but nothing seems to do this. This change keeps the existing behavior of only checking bit 0, but adds a comment about this for clarity.

Adds a const for the starting offset to keep everything cleanly synced up. Also sets the track to -1 after resume, mostly for clarity; because the offset has been reset, it's fine if we use it. The track actually doesn't need to be changed at all, but if we're changing it, -1 is better than 0.
@Fiskbit
Copy link
Copy Markdown
Member

Fiskbit commented Apr 13, 2026

Sorry it's taken so long to get to this; we don't currently have SNES experts actively helping, so there's been some learning curve.

I had trouble finding documentation on how this feature is supposed to work. Someone kindly sent me a specification for MSU-1 that included revision 2 (the resume bit). It is...not the most illuminating. But the gist as I understand it is that writing %100 to $2007 (even while a song is paused) causes the track and position to be saved, and the position is automatically restored if you write to $2005 with the saved track number. The saved state is then cleared.

I've made some small changes to the code that I think improve it. In particular, we don't actually need to store the resume bit (it's not storage), and I made a note of how the implementation differs from the spec (but based on other implementations, I think that deviation is wise).

I tried to push this to your branch to update this PR, but I don't have permission (possibly because the fork is from SourMesen/Mesen2, not nesdev-org/MesenCE; I'm not sure and I'm pretty inexperienced with git and GitHub). Since I can't push it to you, either you'll need to pull my commit into your branch so it gets into this PR, or we'll set up a new PR from my branch with your existing commit and mine.

My commit: 92d0218

At this point, we just need to do some testing to verify the feature is actually working as intended. Setting up the Chrono Trigger hack seems to be a pain, so I imagine it might be several days before we get to that.

SNES: Minor MSU-1 code improvements.
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

Successfully merging this pull request may close these issues.

3 participants