Language…
6 users online: Alex No, Darolac, DixyNL, Rykon-V73, synthie_cat,  Tahixham - Guests: 244 - Bots: 402
Users: 64,795 (2,377 active)
Latest user: mathew

rom address for changing level music

I can't seem to find what address in rom (or ram) controls the level music. In this case, I want to make it so the player hits a certain block and it changes the level music. This may be very simple, I'm probably just not as experienced navigating through rom/ram map addresses to find the byte. Any help is appreciated.
$1DFB is the RAM address for the music register. It's listed in the RAM Map's description of $1DF9, which is the start of the SPC700 I/O port stuff.
Thanks!
Now that I tested it I notice a little bit of lag when the block is hit to load another music track. Is the lag just from loading different music or something else?


It's mainly from loading samples, which take a while due to their size. AMK can't tell whether two songs share samples, and will always force samples to be reuploaded when you switch a song.

Thankfully, AMK does feature a switch you can set to skip uploading samples, which will significantly shorten that freeze period (often to no time at all). By default, that address is $7FB001. For obvious reasons, only use it when two songs use the exact same samples, or else you'll get some weird-sounding music.

That said, there is one issue with the flag; it is never automatically cleared. This means, you need to set the flag, then at some point after the music is uploaded, you need to clear it again (or else you'll never get new samples again). My personal recommendation is to always clear it immediately after AMK uploads the music (which is at $008075, the very end of the frame), so that you just have to set the flag when you store the music and don't need to worry about clearing it. Unfortunately, due to the hijack's position, there's not really a good spot to do so; I'd recommend just adding it as "STZ !NoUploadSamples" right into AMK's own patch file (in asm > SNES > patch.asm), at the "End:" label.

Professional frame-by-frame time wizard. YouTube - Twitter - SMW Glitch List - SMW Randomizer
So, in simpler terms what would I have to do? You lost me at the third paragraph (aka I don't have that much knowledge of asm so is there a simpler explanation?)


Basically:
Step 1. In AMK's folder, navigate to "asm > SNES > patch.asm". CTRL+F for the "End:" label (it's on line 153). Add this on the line immediately after:

Code
LDA #$00
STA !NoUploadSamples

Reapply AMK.

Step 2. Whenever you want to load a song without reloading samples, write your code like so:

Code
LDA #$xx
STA $1DFB
STA $7FB001



Note that you should only store to $7FB001 when you don't need new samples, i.e. your two songs share the exact same instruments. If you're using vanilla music it's usually fine, but most custom songs will have their own instrument sets, in which case you won't be able to fix the pause issue (unless you combine sample sets for multiple songs together; it's not super complicated to do this, but you'd want to learn the basics of music editing first).

Professional frame-by-frame time wizard. YouTube - Twitter - SMW Glitch List - SMW Randomizer
It seems I can't really add the 7FB001 flag for the songs because it just sounds glitchy, and all the songs in my hack are all vanilla instruments. Maybe it's because I have a song that plays nothing
Code
#0 w255 t50
@1 v150 o4
r1

but then playing a regular song after hitting the block?
Keep in mind that disabling sample uploads will also keep the sample table in a fixed location in ARAM. If you upload a song which is bigger than the currently playing song without reuploading the samples, you will destroy the sample table and probably crash the SPC700.

You can use AddmusicK's pad command to work around this. Whenever you need to switch between two (or more) songs without reuploading samples, check which one is the biggest (AddmusicK tells you the insert size for every song when you use it) and pad the others to that size. For example, if song A is 0x34A bytes and song B is 0x7A2 bytes, you'd add #pad $7A2 to the top of song A's TXT file.

This is probably the problem in your case because an empty song is incredibly small (a couple of bytes). Pad your empty song to the size of the song you play after it.

Do note that switching songs without switching samples still freezes the game for a while, but it's only a couple of frames and barely noticeable (unlike reuploading samples, which takes a couple of seconds).
That's helpful, except that, I have more than one song in a level. In fact, in my hack, several hundreds of songs are in one level, and several hundred blocks to control switching the songs by hitting the blocks. So there probably is no way to fix the lag in this case. If there isn't, that's fine, I was just wondering.
Several HUNDREDS???

Snes roms are limited in space, i doubt that you van fit more than 200 songs in a rom and even less if they have samples.
You might want to reduce the amount of music.

Anyways good luck with your project!
My Youtube channel

Currently working on:
Project C

Finished project:
ok maybe not several hundreds (like 300 or 400) but to be exact 153. Sorry if there was any confusion lol.