It is currently Tue Dec 12, 2017 9:23 am

All times are UTC - 7 hours





Post new topic Reply to topic  [ 8 posts ] 
Author Message
 Post subject: PAL Frame Counter
PostPosted: Mon Dec 07, 2015 2:50 pm 
Offline
User avatar

Joined: Fri Jan 24, 2014 9:05 am
Posts: 140
Location: Hungary
I'd be interested to learn more about the timing of the frame counter in PAL units, especially how the IRQ functions. Does it happen less often than with the NTSC frame counter?
Because if it doesn't, it could be useful to easily maintain the same resolution for an audio engine in both regions by using the IRQ to update the APU registers, instead of skipping every 6th frame on NTSC, which makes arpeggios sound muddier.


Top
 Profile  
 
 Post subject: Re: PAL Frame Counter
PostPosted: Mon Dec 07, 2015 5:34 pm 
Offline
User avatar

Joined: Sun Jan 22, 2012 12:03 pm
Posts: 5891
Location: Canada
Yes the frame counter is slower on the PAL CPU (i.e. the IRQ should be similar to the video refresh length). I know of games that depend on this to have correct audio, don't know any examples that require it for IRQ but there's probably a few.

Unfortunately, exact measurements of it don't appear to be available on the wiki. You can look at emulator source (e.g. Nintendulator has tables in APU.cpp / FrameCyclesPAL) if you're just looking for numbers to plug in to your emulator.


Top
 Profile  
 
 Post subject: Re: PAL Frame Counter
PostPosted: Mon Dec 07, 2015 5:37 pm 
Offline
User avatar

Joined: Mon Jan 03, 2005 10:36 am
Posts: 2982
Location: Tampere, Finland
I think the PAL frame IRQ runs at 50Hz, unfortunately.

To achieve a 60Hz sound update rate on a PAL system, possibly a CPU cycle counting IRQ could be used. There is one problem, which is that you don't want the sound updates to fall on top of VBL updates, but by spacing things out properly and by synchronizing the IRQ to the NMI every now and then I think it should work. (NOTE: It's possible to disable interrupts to make sure the sound update IRQ wouldn't happen on top of VBL updates, but that would cause jitter in the audio timing, so it would be better to set up things such that it can't happen at all.)

I haven't tried this method personally, yet.

_________________
Download STREEMERZ for NES from fauxgame.com! — Some other stuff I've done: kkfos.aspekt.fi


Top
 Profile  
 
 Post subject: Re: PAL Frame Counter
PostPosted: Mon Dec 07, 2015 6:10 pm 
Offline
User avatar

Joined: Sun Jan 22, 2012 12:03 pm
Posts: 5891
Location: Canada
If you have a consistent NMI routine timing, an APU IRQ that is delayed to the end of NMI would probably end up in a stable configuration. Since acknowledging the APU IRQ resets its timer, it's eventually going to start at a consistent spot at the end of an overlapping NMI, and from there should have a finite series of fixed timings until it overlaps again and restarts the series.

This could actually be really bad for jitter, emphasizing it strongly by having a short stable pattern. It could also be really good for jitter though, if you get lucky with a stable pattern that has low deviation.


Top
 Profile  
 
 Post subject: Re: PAL Frame Counter
PostPosted: Tue Dec 08, 2015 1:51 am 
Offline
User avatar

Joined: Fri Nov 12, 2004 2:49 pm
Posts: 7314
Location: Chexbres, VD, Switzerland
thefox wrote:
I think the PAL frame IRQ runs at 50Hz, unfortunately.

Really ? I was pretty sure it was arround 55Hz or something crazy like that. Sort of a compromize between PAL and NTSC refresh rates.

I think it's better to assume PAL sound engines are updated at 50Hz and speed up the tempo a bit in order to compensate. If you can afford a CPU counter that allows for free update of the sound engine then I'd definitely pick up something way higher than 60Hz in order to benefit from it.


Top
 Profile  
 
 Post subject: Re: PAL Frame Counter
PostPosted: Tue Dec 08, 2015 2:08 am 
Offline
User avatar

Joined: Mon Jan 03, 2005 10:36 am
Posts: 2982
Location: Tampere, Finland
Bregalad wrote:
thefox wrote:
I think the PAL frame IRQ runs at 50Hz, unfortunately.

Really ? I was pretty sure it was arround 55Hz or something crazy like that. Sort of a compromize between PAL and NTSC refresh rates.

Well, I couldn't find a good source for this, so take it with a grain of salt.

I could test it later, I guess, but not much point if it has been done already.

_________________
Download STREEMERZ for NES from fauxgame.com! — Some other stuff I've done: kkfos.aspekt.fi


Top
 Profile  
 
 Post subject: Re: PAL Frame Counter
PostPosted: Tue Dec 08, 2015 11:03 am 
Offline
User avatar

Joined: Sun Jan 22, 2012 12:03 pm
Posts: 5891
Location: Canada
thefox wrote:
I could test it later, I guess, but not much point if it has been done already.

This is all we've got on the Wiki right now:
TODO: describe PAL


Top
 Profile  
 
 Post subject: Re: PAL Frame Counter
PostPosted: Tue Dec 08, 2015 10:30 pm 
Offline
User avatar

Joined: Mon Jan 03, 2005 10:36 am
Posts: 2982
Location: Tampere, Finland
Bregalad wrote:
thefox wrote:
I think the PAL frame IRQ runs at 50Hz, unfortunately.

Really ? I was pretty sure it was arround 55Hz or something crazy like that. Sort of a compromize between PAL and NTSC refresh rates.

I tested it, it's definitely ~50 Hz. This test prints $40F2 on PAL NES ($40F2*2 = 33252, close to the PAL PPU frame length of 33247.5 CPU clocks) across multiple powerons and resets. Same result in Nintendulator. On NTSC console the value was $3A42 (also matches Nintendulator).

NOTE: Even though the value printed by the test exactly matches the APU cycle count documented in the wiki (for NTSC), no effort was put into precisely synchronizing with APU.

ROM + source (for ASM6) attached.

EDIT: Just as a further note: 33252 makes sense considering that 26.6017125 MHz / 16 / (50Hz) = 33252.1406.


Attachments:
frame-counter-test-v01.zip [2.35 KiB]
Downloaded 113 times

_________________
Download STREEMERZ for NES from fauxgame.com! — Some other stuff I've done: kkfos.aspekt.fi
Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 8 posts ] 

All times are UTC - 7 hours


Who is online

Users browsing this forum: Google Adsense [Bot] and 3 guests


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