This page is a mirror of Tepples' nesdev forum mirror (URL TBD).
Last updated on Oct-18-2019 Download

How to make Sound Effects?

How to make Sound Effects?
by on (#89215)
I am making an NES styled Megaman game. I was wondering if anyone could give me a simple tutorial on how to make NES style sound effects. I'm already pretty well versed in how to make NES style music.

I also had a question. Why is it in some NES games the tiles on the far right side of the screen that are scrolling on to the screen are shown on the far left at the same time in weird color palettes? I already programmed this into my game for the most part, but I was wanting to know the science behind it.

by on (#89216)
Making sound effects is the same as with making NES music, except perhaps with an extremely high tempo. I assume you've heard of famitracker?

As for the color glitches and or tile glitches, they aren't always on the left or right.

Kirby's Adventure has them on the trailing edge of the screen (they're on the left if you're scrolling right, and on the right if you're scrolling left.)

Sometimes they're on the top or the bottom of the screen.

This happens because NES has 4 screen sized (256x240) areas that it pulls tiles from, but without very special cart hardware two of them must always be the same.

If the unique screen sized areas are called A and B, they can be laid out like this:
Code:
AA
BB

or like this:
Code:
AB
AB


They can be thought of as laid out infinitely more like this
Code:
AAAAAAAAAAAAAAAAAAA
BBBBBBBBBBBBBBBBBBB
AAAAAAAAAAAAAAAAAAA
BBBBBBBBBBBBBBBBBBB
AAAAAAAAAAAAAAAAAAA
BBBBBBBBBBBBBBBBBBB
etc.

because when you scroll to the end, it just loops.
The NES has tiles that are 8x8, however it can only update the palette for 16x16 pixel areas. So let's say I have this setup
Code:
AA
BB

and am scrolling right.
Code:
L = tile at the left edge of the screen
R = tile at the right edge of the screen
0 = Tiles in the middle. There would be more of them, but it would stretch the page.

L0000R
L0000R
L0000R
L0000R

It would repeat like this:
Code:
L0000RL0000RL0000R
L0000RL0000RL0000R
L0000RL0000RL0000R
L0000RL0000RL0000R

I have just scrolled to the right. I have updated the "R" column with new tiles. I want to update the palette which must be done in 16x16 pixel (or 2x2 tile) blocks. So when I update R's palette, L's palette also changes. If R and L are supposed to have different palettes, it makes L have R's palette which is what causes the problem.

Note that this only happens in games that scroll in the direction that doesn't correspond to how that tile memory is laid out.

Super Mario Bros. uses this setup:
Code:
AB
AB

and only scrolls left and right, so it never has this problem.
Ice Climber has this setup:
Code:
AA
BB

and only scrolls vertically, so it never has this problem.

Metroid scrolls both horizontally and vertically, but never at the same time. Its cart hardware allows it to use the mario setup when it scrolls horizontally and the Ice Climber setup when it scrolls vertically so it never has this problem.

Kirby's level hubs can scroll left/up at the same time so this problem is unavoidable.

Here's a topic for further reading: http://nesdev.com/bbs/viewtopic.php?p=79590

Edit: As for tile glitches, you may as well also be aware that some games don't draw the first 8 pixels at the start of each row. Check it out in Kirby's Adventure, Super Mario Bros. 3, or Megaman 3. I actually never noticed this until I started NES programming. Once you see it, you can't unsee it, at least on an emulator. Some TVs will actually hide the fact that those pixels aren't rendered because they tend to be outside of television safe area

This is an attempt to make the wrong colors appear for less time if you have the screens laid out like this:

Code:
AA
BB

It also hides the tile glitches you describe.

The screen is exactly 256 pixels. So is the NES display resolution. So the same thing that happens with the colors happens with the tile graphics if you scroll to a new area and those pixels are displayed.

If I scroll one pixel to the right to a new tile, I update it to the column of tiles on the right. But 7 pixels of that tile are still being displayed on the left of the screen which will now appear wrong. A game where this happens doesn't immediately come to mind, because it's so easy to just hide those eight pixels.

Note that Super Mario Bros. 3 hides those pixels and STILL has tile errors, but this is because they did it poorly, not because it is impossible to hide them. Kirby's Adventure did it right, but still has color errors which are unavoidable in a two way scrolling game without expensive cart hardware.

by on (#89220)
My music engine treats drum hits like a pair of sound effects: usually one on the triangle channel and one on the noise channel.

I can think of a few ways to conceal this artifact with horizontal arrangement of the nametables (vertical mirroring). Two of them depend on a scanline counter: either that of the MMC3 or one created by (ab)using the DMC IRQ. Jurassic Park and M.C. Kids, for instance, switch to a blank CHR ROM bank for the top and bottom few scanlines. Crystalis uses a scanline counter, and when the visible area is about to protrude into the status bar area, it resets the scroll position to the top of the screen. The credit crawl routines in Concentration Room and the NESdev Compo multicart use a cruder method of writing a row of blank tiles over the tile row that is split between the top and bottom of the screen.

by on (#89291)
For sound effects, I just use unique code for each sound. This allows me a ton of flexibility. But I have many sound effects that are similar, so I have routines that are shared by those sound effects.