My game's music skips a frame in Nestopia

Discuss technical or other issues relating to programming the Nintendo Entertainment System, Famicom, or compatible systems.

Moderator: Moderators

Post Reply
User avatar
SecretServiceDude
Posts: 99
Joined: Wed Oct 22, 2008 3:49 pm
Location: Los Angeles, CA

My game's music skips a frame in Nestopia

Post by SecretServiceDude » Mon Nov 17, 2008 8:17 am

Several seconds after starting my game, there's a single frame where the music seems to pop/skip. I've run the game on Nestopia, Nintendulator and FCEU, but the anomaly only crops up on Nestopia.

According to the wiki, reading PPUSTATUS at the exact start of NMI can cause the program to lose frames, but AFAIK I'm not doing that.

...Or am I?

Sorry I don't have more detailed info than that. Any ideas?

User avatar
Bregalad
Posts: 7889
Joined: Fri Nov 12, 2004 2:49 pm
Location: Chexbres, VD, Switzerland

Post by Bregalad » Mon Nov 17, 2008 8:29 am

...Or am I?
Well, usually you don't read $2002 in the main programm except when waiting for sprite zero hits, and when you do that you know a VBlank isn't going to be triggered. So I guess you aren't, but I can't guarantee that.

Are you sure your emulator runs at full speed ? This may simply be due to lag if your computer isn't powerfull enough, altough it's not likely that it will happen at a predictable time.

You also should make sure you (or the music engine you use) don't assume any values in RAM. Usually you'd want to clear $000-$7ff with zeroes manually. Nestopia is one of the only emulators to fill the RAM with garbage instead of full clean $00s.
Life is complex: it has both real and imaginary components.

User avatar
SecretServiceDude
Posts: 99
Joined: Wed Oct 22, 2008 3:49 pm
Location: Los Angeles, CA

Post by SecretServiceDude » Mon Nov 17, 2008 8:41 am

Bregalad wrote:Are you sure your emulator runs at full speed ? This may simply be due to lag if your computer isn't powerfull enough, altough it's not likely that it will happen at a predictable time.
At first I thought it might be lag, but the skip always occurs at the same time on my computer, regardless of whether or not other programs are running in the background.

Bregalad wrote:You also should make sure you (or the music engine you use) don't assume any values in RAM. Usually you'd want to clear $000-$7ff with zeroes manually. Nestopia is one of the only emulators to fill the RAM with garbage instead of full clean $00s.
I clear out $000-$7ff with zeroes in the reset handler, except for sprite OAM, which I fill with $fe.

User avatar
BMF54123
Posts: 409
Joined: Mon Aug 28, 2006 2:52 am
Contact:

Post by BMF54123 » Mon Nov 17, 2008 4:03 pm

I get occasional single-frame lags in Nestopia all the time, in every game, probably as a result of it running slightly slower than my screen's refresh rate. The easiest way to see if it's emulator-related (if your computer's fast enough) is to turn on the NTSC filter, disable field merging, enable Vsync, and make sure you're running a 60Hz video mode. If the NTSC flickering "hiccups" at the same time your sound lags, then it's an emulator issue.

Another thing you could do is put a sprite somewhere onscreen that alternates between black and white each frame. That would be easier to catch than an NTSC hiccup.

Post Reply