+  RHDN Forum Archive
|-+  Romhacking
| |-+  ROM Hacking Discussion
| | |-+  Where are the sound effects located in SMB?
Pages: [1]
Author Topic: Where are the sound effects located in SMB?  (Read 2 times)
eleventhirtyfour
Guest
« on: February 16, 2009, 07:25:22 pm »

I'm doing a hack of Super Mario Bros. (Lame, I know) and I have no idea where or even how to find where the sound effects are located. I'm using Windhex to edit it and I've already changed all of the music but I want different sound effects, so yeah that's about it. Thanks in advance!
HaxorKyo
Guest
« Reply #1 on: February 17, 2009, 01:00:47 am »

it isn't lame to hack SMB. Don't let anybody tell you different either.
tc
Guest
« Reply #2 on: February 17, 2009, 01:32:05 am »

Sound effects are perhaps the least understood element in all of rom hacking.
eleventhirtyfour
Guest
« Reply #3 on: February 17, 2009, 08:48:13 am »

Oh, I didn't know that. Well, still, if anyone knows where the data is for at least one sound effect that would be great! See, my game is about robots and the music is completely ridiculous and just sounds like random blips and beeps all over the place. The sound effects are way louder than the music and they just remind you that you're playing Super Mario Bros. and take away from the feel of the robot-ness.
Disch
Guest
« Reply #4 on: February 17, 2009, 11:26:07 am »

Relevent link:  SMB Disassembly

After searching it, I think I've found relevent sound effect code/data:

Code:
;--------------------------------

SwimStompEnvelopeData:
      .db $9f, $9b, $98, $96, $95, $94, $92, $90
      .db $90, $9a, $97, $95, $93, $92

PlayFlagpoleSlide:
       lda #$40               ;store length of flagpole sound
       sta Squ1_SfxLenCounter
       lda #$62               ;load part of reg contents for flagpole sound
       jsr SetFreq_Squ1
       ldx #$99               ;now load the rest
       bne FPS2nd

PlaySmallJump:
       lda #$26               ;branch here for small mario jumping sound
       bne JumpRegContents

PlayBigJump:
       lda #$18               ;branch here for big mario jumping sound

JumpRegContents:
       ldx #$82               ;note that small and big jump borrow each others' reg contents
       ldy #$a7               ;anyway, this loads the first part of mario's jumping sound
       jsr PlaySqu1Sfx
       lda #$28               ;store length of sfx for both jumping sounds
       sta Squ1_SfxLenCounter ;then continue on here

...

I have no idea where in the ROM this is, but if you search for that string of data at the top (9F 9B 98 96 95 ...) in a hex editor you should be able to find it.

I didn't bother deciphering this to figure out how to change sound effects the way you want -- however you can play around with it in a hex editor to try and tweak things.  Knowing how 6502 and NES sound work would help, but isn't a requirement.  I don't recommend changing any code unless you really know what you're doing, but you should be able to change the constants without messing things up horribly.

To further clarify:  the "constants" are the stuff in data tables (in a ".db" line -- like all that stuff in the SwimStompEnvelopeData table) and/or stuff in a "LD* #$xx" line (line must have a # symbol).

So the first bit of code pasted above:
Code:
       lda #$40               ;store length of flagpole sound
       sta Squ1_SfxLenCounter
       lda #$62               ;load part of reg contents for flagpole sound
       jsr SetFreq_Squ1

would look like this in the ROM:

Code:
  A9 40 8D xx xx A9 62 20 xx xx

The '40' and '62' would be safe to change.
eleventhirtyfour
Guest
« Reply #5 on: February 17, 2009, 12:31:45 pm »

Thanks! I'll try messing around with that data soon!

Also, (sorry, being a noob) where did you get the values A9 and 8D and also A9 and 20? I just changed the swim/stomp sound effect becuase I typed in the string shown and just messed with it until I thought it was good, but I'm not sure about how to find the others (besides the one you already gave surrounding values to)... I hope that made sense.
« Last Edit: February 17, 2009, 02:20:12 pm by eleventhirtyfour »
Disch
Guest
« Reply #6 on: February 17, 2009, 03:15:46 pm »

Quote from: eleventhirtyfour on February 17, 2009, 12:31:45 pm
(sorry, being a noob)

You have no need to apologize.  You've already shown more initiative than many newbies do.  Nothing wrong with asking questions as long as you're willing to learn, which you seem to demonstrate quite well.  :thumbsup:

Quote
where did you get the values A9 and 8D and also A9 and 20? I just changed the swim/stomp sound effect becuase I typed in the string shown and just messed with it until I thought it was good, but I'm not sure about how to find the others (besides the one you already gave surrounding values to)... I hope that made sense.

These are the opcodes which represent the 6502 instructions.  A good reference page is here:

Obelisk

LDA Immediate mode is represented by opcode A9.  Therefore the line "lda #$40" would be seen as "A9 40" in the ROM.  STA absolute is opcode 9D, therefore "sta $1234" would be seen as "9D 34 12" in the ROM.  And so on.


EDIT:

Since I just realized I only answered part of your question...

It looks like a lot of the sound effects are 'hardcoded' which basically means that the data used in making them is intertwined with the code (all these immediate values -- the ones with the # symbol -- determine how the sound effect will sound, rather than a neat and easy-to-edit table like that SwimStompEnvelopeData table).

If you want to edit these sound effects, it'll be tricky, and you might not be able get it the way you want, but the key is to skim the code and change the immediate values.  You should be able to use the comments and variable names in the disassembly to get some clue as to what the value does.  For example in that code snippit I pasted before:

Code:
       lda #$28               ;store length of sfx for both jumping sounds
       sta Squ1_SfxLenCounter ;then continue on here
Here, the immediate (#) value of $28 is being written to Squ1_SfxLenCounter, which indicates that this value determines how long the sound effect is to play.  So you can change that value to make the sound effect shorter/longer.

If you haven't already done so, you really should pick up the disassembly (I linked to it earlier) even if you don't understand 6502.  You can use it to find data tables and other stuff like this in the ROM.

Below the section I pasted is another set of tables labelled 'ExtraLifeFreqData', 'PowerUpGrabFreqData', and 'PUp_VGrow_FreqData' which you might want to look at as well.  Just skim that whole section of the disassembly to look for stuff that's editable.

EDIT AGAIN:

doh you replied before I finished editing!  oh well   :laugh:
« Last Edit: February 17, 2009, 03:53:38 pm by Disch »
eleventhirtyfour
Guest
« Reply #7 on: February 17, 2009, 03:41:09 pm »

Whoa! Thanks for that. Right now it looks kind of like gibberish but I'll save it as more and more things that seemed foreign before are becoming part of the regular stuff now. I found a few more things on that disassembly document that were easy to find and change (1-Up sound, Upgrade sound, Brick smash sound). Thanks again!
doppelganger
Guest
« Reply #8 on: April 02, 2009, 01:59:04 am »

You're quite welcome. :-P
Pages: [1]  


Powered by SMF 1.1.4 | SMF © 2006-2007, Simple Machines LLC