It is currently Wed Apr 23, 2014 7:26 am

All times are UTC - 7 hours




Post new topic Reply to topic  [ 16 posts ]  Go to page 1, 2  Next
Author Message
PostPosted: Wed Jan 07, 2009 10:59 am 
Offline
User avatar

Joined: Mon Dec 22, 2008 10:45 pm
Posts: 283
Location: Argentina
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?


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jan 07, 2009 11:20 am 
Offline
User avatar

Joined: Wed Nov 10, 2004 6:47 pm
Posts: 1694
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).


Top
 Profile  
 
PostPosted: Wed Jan 07, 2009 12:35 pm 
Offline

Joined: Sun Sep 19, 2004 11:12 pm
Posts: 11721
Location: NE Indiana, USA (NTSC)
Petruza wrote:
Hi, is it possible to meassure time in the 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?


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jan 07, 2009 1:10 pm 
Offline
User avatar

Joined: Fri Nov 12, 2004 2:49 pm
Posts: 5916
Location: Jongny, VD, Switzerland
Altough the VBlank may not happen exactly 60 times per second (50 respectively for PAL consoles), I guess it's still the most accurate method.

_________________
Life is complex: it has both real and imaginary components.


Top
 Profile  
 
PostPosted: Wed Jan 07, 2009 2:55 pm 
Offline
User avatar

Joined: Mon Dec 22, 2008 10:45 pm
Posts: 283
Location: Argentina
tepples wrote:
Petruza wrote:
Hi, is it possible to meassure time in the 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?


I want to make a metronome. But maybe 60 hz are enough.

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...


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jan 07, 2009 3:27 pm 
Offline
User avatar

Joined: Fri Nov 12, 2004 2:49 pm
Posts: 5916
Location: Jongny, VD, Switzerland
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.

_________________
Life is complex: it has both real and imaginary components.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jan 07, 2009 4:16 pm 
Offline
Site Admin
User avatar

Joined: Mon Sep 20, 2004 6:04 am
Posts: 2785
Location: Indianapolis
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).


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jan 07, 2009 4:39 pm 
Offline

Joined: Sun Sep 19, 2004 11:12 pm
Posts: 11721
Location: NE Indiana, USA (NTSC)
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.

Looks like a texture map to me.

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:
while not done:
    wait for vblank
    update display
    counter = counter + selected_beats_per_minute
    if counter >= frames_per_minute:
        counter -= frames_per_minute
        beep

The value of frames_per_minute depends on whether you're on NTSC (use 3606) or PAL (use 3000).


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jan 07, 2009 5:29 pm 
Offline
User avatar

Joined: Mon Dec 22, 2008 10:45 pm
Posts: 283
Location: Argentina
In this post, 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.


Tepples' avatar is not weird at all, it just annoys me, I'm not sure why.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jan 07, 2009 5:55 pm 
Offline

Joined: Sat Nov 17, 2007 8:44 pm
Posts: 385
A strange thing to talk about, but it does make him seem constantly annoyed. If he's comfortable with it then I don't know why he'd change it though, I know I'm hesitant to give up stuff like that when I've used it for ages.

What's that kid from?


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jan 07, 2009 6:09 pm 
Offline

Joined: Sun Sep 19, 2004 11:12 pm
Posts: 11721
Location: NE Indiana, USA (NTSC)
UncleSporky wrote:
What's that kid from?

Pinocchio 2


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jan 07, 2009 6:42 pm 
Offline
Formerly Fx3

Joined: Fri Nov 12, 2004 4:59 pm
Posts: 2162
Location: Brazil
Whoa... :) and made by Filmation!


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jan 07, 2009 8:30 pm 
Offline
User avatar

Joined: Mon Dec 22, 2008 10:45 pm
Posts: 283
Location: Argentina
tepples wrote:
UncleSporky wrote:
What's that kid from?

Pinocchio 2


Does the name "Pin Eight" have to do with that?
Because in spanish Pin 8 would be "Pin ocho" the same as Pinocchio.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jan 07, 2009 8:35 pm 
Offline
User avatar

Joined: Mon Dec 22, 2008 10:45 pm
Posts: 283
Location: Argentina
UncleSporky wrote:
it does make him seem constantly annoyed.

You're right, that's maybe what annoys me.
Maybe in my subconscious I think tepples is always bothered by something, like Pinnochio seems to be :D


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jan 07, 2009 10:05 pm 
Offline
User avatar

Joined: Mon Aug 28, 2006 2:52 am
Posts: 402
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.

Whoa. That's deep.

_________________
- BMF
RuSteD LOgIc


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 16 posts ]  Go to page 1, 2  Next

All times are UTC - 7 hours


Who is online

Users browsing this forum: Steeler [Crawler] and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Group