Timing in NES, other than waiting for VBLANK
Moderator: Moderators
Timing in NES, other than waiting for VBLANK
Hi, is it possible to meassure time in the NES other than waiting for VBLANK?
This gives a precision of a 60th of a second, in NTSC, but what if you want more precision? is it possible?
This gives a precision of a 60th of a second, in NTSC, but what if you want more precision? is it possible?
There's APU frame IRQs (which is nearly the same rate as NMIs -- about 60 Hz).
There's also DMC IRQs which have an adjustable timer and can happen pretty quick (by my math... once about every 432 cycles.. which works out to about 4143 Hz). The problem with these though is they use the DMC which means if you're using the DMC for timing, you can't use it for audio. Plus using the DMC can interfere with joypad reads, which means you need to repeatedly read joypad data until you get two nonconflicting returns.
Some mappers also have a much simpler CPU cycle counter. But then you have to use that mapper, of course.
Other than that, I can't think of any. Only other way really is to count cycles (which you can't do from C).
There's also DMC IRQs which have an adjustable timer and can happen pretty quick (by my math... once about every 432 cycles.. which works out to about 4143 Hz). The problem with these though is they use the DMC which means if you're using the DMC for timing, you can't use it for audio. Plus using the DMC can interfere with joypad reads, which means you need to repeatedly read joypad data until you get two nonconflicting returns.
Some mappers also have a much simpler CPU cycle counter. But then you have to use that mapper, of course.
Other than that, I can't think of any. Only other way really is to count cycles (which you can't do from C).
Re: Timing in NES, other than waiting for VBLANK
The best answer depends on your answer to the following: Of what event are you trying to measure the time?Petruza wrote:Hi, is it possible to meassure time in the NES other than waiting for VBLANK?
Re: Timing in NES, other than waiting for VBLANK
I want to make a metronome. But maybe 60 hz are enough.tepples wrote:The best answer depends on your answer to the following: Of what event are you trying to measure the time?Petruza wrote:Hi, is it possible to meassure time in the NES other than waiting for VBLANK?
PS: Tepples, don't take it personal, but your avatar annoys me a lot can I make one for you? maybe with some NES character...
The easy way to get flexible timing at 60hz is to use sub-frame counting with 16-bit adds. Just make it so the lower byte is never reset (always carries over).
To your timer (16-bit variable), you'd add values like these every frame to get these rates:
$0100 = 60Hz.
$0001 = 1/256Hz
$0180 = 90Hz
I guess you actually could just ditch the high byte and trigger a beat whenever the low byte wraps around (check carry flag).
To your timer (16-bit variable), you'd add values like these every frame to get these rates:
$0100 = 60Hz.
$0001 = 1/256Hz
$0180 = 90Hz
I guess you actually could just ditch the high byte and trigger a beat whenever the low byte wraps around (check carry flag).
Looks like a texture map to me.Bregalad wrote:Hmmh, your avatar is much weirder too (altough it doesn't annoy me). A face viewed by front and face at the same time is really weird.
But then, if you just want to make a metronome for tempos between 40 and 240 beats per minute, here's how you could do it:
Code: Select all
while not done:
wait for vblank
update display
counter = counter + selected_beats_per_minute
if counter >= frames_per_minute:
counter -= frames_per_minute
beep
Tepples' avatar is not weird at all, it just annoys me, I'm not sure why.In [url=http://nesdev.com/bbs/viewtopic.php?p=41472#41472]this post[/url], Bregalad wrote:Hmmh, your avatar is much weirder too (altough it doesn't annoy me). A face viewed by front and face at the same time is really weird.
-
- Posts: 388
- Joined: Sat Nov 17, 2007 8:44 pm
Pinocchio 2UncleSporky wrote:What's that kid from?
Does the name "Pin Eight" have to do with that?tepples wrote:Pinocchio 2UncleSporky wrote:What's that kid from?
Because in spanish Pin 8 would be "Pin ocho" the same as Pinocchio.
Whoa. That's deep.Petruza wrote:Does the name "Pin Eight" have to do with that?
Because in spanish Pin 8 would be "Pin ocho" the same as Pinocchio.
- BMF
RuSteD LOgIc
RuSteD LOgIc