News: 11 March 2016 - Forum Rules
Current Moderators - DarkSol, KingMike, MathOnNapkins, Azkadellia, Danke

Author Topic: How to get the disassembly code for sound effects in NES games  (Read 2526 times)

Justamariofan

  • Jr. Member
  • **
  • Posts: 15
    • View Profile
Okay, so I found out if I am going to change sound effects for an NES game, I need to do disassembly of some sort, but specifically, how do I find the code to a certain sound effect?

Cyneprepou4uk

  • Sr. Member
  • ****
  • Posts: 474
  • I am the baldest romhacker
    • View Profile
Re: How to get the disassembly code for sound effects in NES games
« Reply #1 on: June 28, 2020, 01:24:41 am »
You can disable music and play sound only, set write breakpoints to apu registers combined with a trace logger
iromhacker.ru - NES ROM hacking tutorials for beginners. Please use Google Translate browser extension

Bregalad

  • Hero Member
  • *****
  • Posts: 2747
    • View Profile
Re: How to get the disassembly code for sound effects in NES games
« Reply #2 on: June 28, 2020, 08:51:21 am »
Okay, so I found out if I am going to change sound effects for an NES game, I need to do disassembly of some sort, but specifically, how do I find the code to a certain sound effect?
Depends on the game.

Some early games don't use any sound effect engine and simply have a small routine writing directly to the APU registers. Modifying the sound effect means modifying that routine, but your options are limited.

More advanced games tends to store music and sound effect using the same data bytecode, so you'd have to figure out how the specific music/SFX data bytecode works, and find where the sound effect you want to affect is stored, and change that data.

Some other games could do it yet another way...
« Last Edit: July 09, 2020, 12:54:56 pm by Bregalad »

Justamariofan

  • Jr. Member
  • **
  • Posts: 15
    • View Profile
Re: How to get the disassembly code for sound effects in NES games
« Reply #3 on: July 08, 2020, 07:15:52 am »
Let's say if I were to change up the sound effects for Super Mario Bros 2 by using the sound effects from Super Mario Bros. To be specific, if I wanted to copy over the Super jump and the 1up sound effect from the first game and paste them to the second game. Would there be a way to do it from the apu registers? Would I have to do some coding, or is there something that I need to do by hand? Sorry for the lack of paragraphs. Keyboard wasn't working all that well.

Cyneprepou4uk

  • Sr. Member
  • ****
  • Posts: 474
  • I am the baldest romhacker
    • View Profile
Re: How to get the disassembly code for sound effects in NES games
« Reply #4 on: July 08, 2020, 09:30:27 am »
Find data of those sounds and export it to other game. If games use different sound engines, this data should be properly converted first.

Also if you end up with data longer than in other game, you need to put it into free space and change pointers to it.

I don't think it will require any coding.

Quote
Would there be a way to do it from the apu registers?
Not sure what you mean by that.
iromhacker.ru - NES ROM hacking tutorials for beginners. Please use Google Translate browser extension

Justamariofan

  • Jr. Member
  • **
  • Posts: 15
    • View Profile
Re: How to get the disassembly code for sound effects in NES games
« Reply #5 on: July 09, 2020, 03:08:47 am »
Find data of those sounds and export it to other game. If games use different sound engines, this data should be properly converted first.

Also if you end up with data longer than in other game, you need to put it into free space and change pointers to it.

I don't think it will require any coding.
Not sure what you mean by that.
How do I know which data is used for the sound effect? Do I have to look at the data and copy it to another game while playing the sound effect?

Cyneprepou4uk

  • Sr. Member
  • ****
  • Posts: 474
  • I am the baldest romhacker
    • View Profile
Re: How to get the disassembly code for sound effects in NES games
« Reply #6 on: July 09, 2020, 06:35:56 am »
Set a read breakpoint to a sound id ram address before playing the sound. Depending on the engine, code might be reading pointers for data of several apu channels for the current sound effect, or something else in your case. Code/data logger can help you see it.

Well, yeah, you can look and copy during playing the sound if you want, but it's not mandatory.

You can also try to find it at smb disassembly
https://gist.github.com/1wErt3r/4048722
iromhacker.ru - NES ROM hacking tutorials for beginners. Please use Google Translate browser extension