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

Change the song the Etecoons sing #593

Open
CPColin opened this issue Oct 27, 2024 · 3 comments
Open

Change the song the Etecoons sing #593

CPColin opened this issue Oct 27, 2024 · 3 comments
Assignees

Comments

@CPColin
Copy link
Collaborator

CPColin commented Oct 27, 2024

Bear with me on this one.

The song the Etecoons sing in the room called "Hell" is identified here as sound 0x35 in sound library 2. That sound effect is shown in this disassembly as a series of twelve staccato, reverberating notes, followed by a single sustained note.

There's a whole lot of free space in that bank. We could maybe program in a different song, then modify the pointer to that sound effect to point at it. We could program in a couple of songs and point at one of them when the ROM is generated. It's probably too much to let users define songs in the YAML, but first things first.

Try the intro to the first music you hear in Super Mario Bros and see what happens! Step one will be to figure out where this table lives in the ROM and point sound 0x35 at a different sound effect. It looks like the table starts at $39B3, minus an offset of $1500 that was added by the disassembly, plus an offset of $CF8104, where the SPC engine is written to the ROM. (This suggests that the table starts at $CFA5B7 and the 0x35th entry would be an additional 0x34 words (0x68 bytes) on, at $CFA61F.)

@CPColin CPColin self-assigned this Oct 27, 2024
@CPColin
Copy link
Collaborator Author

CPColin commented Oct 28, 2024

Okay, all the RAM addresses shown in that disassembly are locations in the SPC engine itself, not locations in the main SNES RAM. That means we can't easily expand the instruction list for this sound effect and will have to squeeze ourselves into the space between the .sound35 and .sound36 labels. The former is located at ROM offset 0x27ABA7 in this hex editor I'm using and the latter is at 0x27AC27.

The instruction list starts with a pointer for each voice the sound effects use (the vanilla song uses only one) and each voice must end with a terminator of 0xFF. With one voice, we get the current maximum of 25 notes. If we want to change the number of voices, we have to change the 21st call in the table that starts at 0x27A4BF, which is located at 0x27A50F. It currently points at SPC location 0x3992, which is one voice at high priority. Change the location to 0x39A8 and we'll get two voices at high priority. Unfortunately, we can't go higher than that, but we don't have many notes to work with anyway.

@CPColin
Copy link
Collaborator Author

CPColin commented Nov 16, 2024

Other ROM locations:

  • The sound1InstructionLists label points at 0x2796F5
  • The soundB label lives at 0x279709 and has the value 0x2D1A
  • The instruction list for "Uncharged power beam" starts at 0x279922 in the ROM and is the location pointed at by the above label
  • The sound2InstructionLists label point at 0x27A5BB
  • The sound35 label in that list lives at 0x27A623 and has the value 0x3F9F
  • The voice list for sound35 starts at 0x27ABA7
  • voice0 for sound35 starts at 0x27ABA9 and ends with its terminator at 0x27AC26

This suggests that editing the location 0x279709 to have the value 0x3F9F (little-endian) and reloading (and hard-resetting) the game will replace the uncharged power beam sound effect with the Etecoon song.

@CPColin
Copy link
Collaborator Author

CPColin commented Nov 17, 2024

I should find a better way to write this out:

 E-4 .  $1D,$70,$0A,$AD,$07
        $1D,$20,$0A,$AD,$07
 E-4 .  $1D,$70,$0A,$AD,$07
        $1D,$20,$0A,$AD,$07
rest .  $1D,$00,$0A,$AD,$0E
 E-4 .  $1D,$70,$0A,$AD,$07
        $1D,$20,$0A,$AD,$07
rest .  $1D,$00,$0A,$AD,$0E
 C-4 .  $1D,$70,$0A,$AD,$07
        $1D,$20,$0A,$AD,$07
 E-4 .. $1D,$70,$0A,$AD,$0E
        $1D,$20,$0A,$AD,$0E
 G-4 .. $1D,$70,$0A,$B0,$0E
        $1D,$20,$0A,$B0,$0E
rest .. $1D,$00,$0A,$B0,$1C
 G-3 .. $1D,$70,$0A,$A4,$0E
        $1D,$20,$0A,$A4,$0E
done    $FF

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