Jump to content



4

Detecting PAL/NTSC the RIGHT way


8 replies to this topic

#1 dmlloyd OFFLINE  

dmlloyd

    Chopper Commander

  • 167 posts

Posted Mon Aug 1, 2011 11:49 AM

Wanted to start a topic on this subject since I don't think it's really well-covered here, and to pick up any tips/tricks that other people know. Apologies in advance for anything you might consider "common knowledge" or obvious; I want to get it all down in one place.

There are two aspects to detecting PAL and NTSC: ANTIC and GTIA. In a stock PAL system, we all know that ANTIC runs at approx. 50Hz, NTSC-style hires artifacting does not work, and PAL multi-line color artifacting is in effect. And in an NTSC system, ANTIC runs at approx. 60Hz, NTSC artifacting works, and PAL artifacting doesn't.

However, another common system configuration is an NTSC system with a PAL ANTIC in it, meaning 50Hz but *with* NTSC artifacting (maybe) and *without* PAL colors. And though I have never heard of anyone actually doing it, it is also theoretically possible to fit an NTSC ANTIC into a PAL machine.

Thus I think it is really important to break down these items into separate considerations - especially when designing games.

ANTIC Considerations

Detecting a 50Hz ANTIC basically amounts to watching VCOUNT to see if it ever exceeds 131. The only way to know for sure is to disable IRQ and NMI and record VCOUNT: if VCOUNT is greater than 131 at that time then it's definitely 50Hz; else wait for it to either exceed 131 (50Hz) or cycle back to 0 (60Hz).

This simple technique should be used when you're considering timing for movement speed, music tempo, and other frame rate related items, and can even affect things like SIO and keyboard rates, so this is not necessarily limited to games.

GTIA Considerations

Detecting a PAL GTIA is really easy. Just read the PAL register ($D014) and check whether it reports PAL ($1) or NTSC ($F).

When a PAL GTIA is detected, it's a safe bet that you have PAL artifacting available (see http://en.wikipedia....Colour_encoding for info; basically each line only encodes half of the color information and the other half is copied pixel for pixel from the previous line, which makes special modes like RIP/TIP possible but only nice-looking on PAL displays).

If an NTSC GTIA is detected, you will not have PAL color tricks available, however you may have NTSC hi-res artifacting available (in which single hires pixels take on either orange/blue or green/purple color depending on what GTIA you have and whether the pixel is in an even or odd column). However, many SVideo-equipped NTSC Ataris actually suppress this artifacting; for this reason (and for the reason that the actual colors vary depending on the GTIA), you may want to use caution before relying too heavily on this trick.

Another important consideration is that there is a subtle CPU clock speed difference between NTSC and PAL systems. An NTSC GTIA generally means your clock will be running at 14.31818÷8=1.78977 MHz. A PAL GTIA means 1.77344 MHz. This is a very small difference but it may be significant for your application, so it is important to know about it.

So...

It would be nice for every PAL game to run on NTSC systems which are equipped with a PAL ANTIC. For this reason it is important to have separate detection of 50/60Hz ANTIC versus PAL/NTSC GTIA. Granted there are many, many games which simply only work on NTSC or PAL, which is very unfortunate, but hopefully that time is in the past.

I would be very interested to hear anyone else's tricks and techniques related to this topic. Thanks!

#2 snicklin OFFLINE  

snicklin

    Dragonstomper

  • 593 posts
  • Location:UK

Posted Mon Aug 1, 2011 12:51 PM

I'd rather comment on your production of a high quality article like this. Is there any way this can be made sticky and placed into a specific section of this site? Or could we find a way of encouraging getting this information onto the atariwiki?

#3 Kr0tki OFFLINE  

Kr0tki

    Dragonstomper

  • 725 posts
  • Location:Warszawa, Poland

Posted Mon Aug 1, 2011 1:40 PM

dmlloyd, what about SECAM? The SECAM GTIA still contains $1 at $D014, but there's no colour delay like in PAL.

#4 dmlloyd OFFLINE  

dmlloyd

    Chopper Commander

  • 167 posts

Posted Mon Aug 1, 2011 1:58 PM

View PostKr0tki, on Mon Aug 1, 2011 1:40 PM, said:

dmlloyd, what about SECAM? The SECAM GTIA still contains $1 at $D014, but there's no colour delay like in PAL.

That's a good point. I wonder though, whether there are enough SECAM Ataris to really matter? Perhaps there are. If so it would be wise for game/program authors to allow the user to specify the color standard they want: NTSC/SECAM or PAL - and detect $1 as PAL by default (since I think that'd be substantially more common).

#5 flashjazzcat OFFLINE  

flashjazzcat

    Quadrunner

  • 5,408 posts
  • Jumping through hOOPs...
  • Location:United Kingdom

Posted Mon Aug 1, 2011 2:04 PM

View Postsnicklin, on Mon Aug 1, 2011 12:51 PM, said:

I'd rather comment on your production of a high quality article like this. Is there any way this can be made sticky and placed into a specific section of this site? Or could we find a way of encouraging getting this information onto the atariwiki?
Seconded. If only every technical piece was this well-written.

#6 Rybags OFFLINE  

Rybags

    Quadrunner

  • 10,313 posts
  • Location:Australia

Posted Mon Aug 1, 2011 4:29 PM

The VCount compare shouldn't check for a specific value.

>=133 for PAL is a better idea. It's documented (by Phaeron) but not well known that VCount actually reads 1 higher than it's normal highest value. It's only for 1 cycle or so, but that's enough for software to occasionally see the higher value.

#7 dmlloyd OFFLINE  

dmlloyd

    Chopper Commander

  • 167 posts

Posted Mon Aug 1, 2011 4:44 PM

View PostRybags, on Mon Aug 1, 2011 4:29 PM, said:

The VCount compare shouldn't check for a specific value.

>=133 for PAL is a better idea. It's documented (by Phaeron) but not well known that VCount actually reads 1 higher than it's normal highest value. It's only for 1 cycle or so, but that's enough for software to occasionally see the higher value.

Good tip, thanks.

#8 tf_hh OFFLINE  

tf_hh

    Star Raider

  • 57 posts
  • Location:21255 Wistedt in Germany

Posted Fri Aug 19, 2011 5:33 AM

Hi,

View PostKr0tki, on Mon Aug 1, 2011 1:40 PM, said:

dmlloyd, what about SECAM? The SECAM GTIA still contains $1 at $D014, but there's no colour delay like in PAL.
I have some contacts with french atari users in the past. None of them uses SECAM machines any more, because SECAM was dated out. Today in france PAL is used like in the most other european countries.

So I think, there´s no need / no value for a special option for a few, few machines...

Just my 2c, Juergen

#9 Marsupilami OFFLINE  

Marsupilami

    Star Raider

  • 68 posts

Posted Sun Aug 21, 2011 4:42 AM

View Posttf_hh, on Fri Aug 19, 2011 5:33 AM, said:

Hi,

View PostKr0tki, on Mon Aug 1, 2011 1:40 PM, said:

dmlloyd, what about SECAM? The SECAM GTIA still contains $1 at $D014, but there's no colour delay like in PAL.
I have some contacts with french atari users in the past. None of them uses SECAM machines any more, because SECAM was dated out. Today in france PAL is used like in the most other european countries.

So I think, there´s no need / no value for a special option for a few, few machines...

Just my 2c, Juergen
Hello,
Sorry but i have to disagree: SECAM was not "Dated out". Most of my 800XL are SECAM and it's not only used in France :
http://en.wikipedia.org/wiki/SECAM




1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users