13 February 2021, 05:38 | #1 |
Registered User
Join Date: Feb 2021
Location: Becej / Serbia
Posts: 120
|
How to find out if we are on PAL or NTSC?
I am trying to write a function that gets an audio frequency and then returns the nearest AUDxPER value to be used for that frequency. It works like this:
Code:
; PAL VERSION ; d0 - frequency*100 (unsigned longword) move.l d0, d1 lsr.l #1, d1 move.l #354687500, d2 add.l d1, d2 divu.l d0, d2 ; d2 - AUDxPER ; NTSC VERSION ; d0 - frequency*100 (unsigned longword) move.l d0, d1 lsr.l #1, d1 move.l #357954600, d2 add.l d1, d2 divu.l d0, d2 ; d2 - AUDxPER |
13 February 2021, 09:17 | #2 |
Defendit numerus
Join Date: Mar 2017
Location: Crossing the Rubicon
Age: 53
Posts: 4,479
|
Check VPOSR http://www.winnicki.net/amiga/memmap/VPOSR.html
|
13 February 2021, 09:51 | #3 |
Registered User
Join Date: Jan 2019
Location: Germany
Posts: 3,247
|
That tells you the vertical frequency of the currently active screen mode (and only so if this is a native screen mode), but not the system clock frequency. To check for PALN/NTSC, please read the graphics/gfxbase.h include file, there is a flag for it. One is dynamic and changes with the active monitor, but for the system clock frequency, there is a flag named something like REALLYPAL that corresponds to the installed crystal.
|
13 February 2021, 10:21 | #4 | |
Defendit numerus
Join Date: Mar 2017
Location: Crossing the Rubicon
Age: 53
Posts: 4,479
|
Quote:
It tells you which version of Agnus/Alice you have installed, and usually is supposed to have its associated crystal. It has nothing to do with active video mode, as with both crystals and versions of Agnus-hr/Alice you can have NTSC or PAL lines. |
|
13 February 2021, 10:39 | #5 | |
Registered User
Join Date: Feb 2021
Location: Becej / Serbia
Posts: 120
|
Quote:
Code:
; d0 - frequency*100 move.l #354687500, d2 move.w vposr, d1 and.w #$1000, d1 beq .skip move.l #357954600, d2 .skip: move.l d0, d1 lsr.l #1, d1 add.l d1, d2 divu.l d0, d2 ; d2 - AUDxPER |
|
13 February 2021, 10:50 | #6 |
Defendit numerus
Join Date: Mar 2017
Location: Crossing the Rubicon
Age: 53
Posts: 4,479
|
|
13 February 2021, 11:12 | #7 |
Defendit numerus
Join Date: Mar 2017
Location: Crossing the Rubicon
Age: 53
Posts: 4,479
|
Just noticed.. you sure used values are perfect?
In literature are reported values for PAL CCK = 3546895 and for NTSC = 3579545 |
13 February 2021, 16:39 | #8 |
Registered User
Join Date: Feb 2021
Location: Becej / Serbia
Posts: 120
|
I calculated the PAL one, don't remember where I got the NTSC from. Got the PAL as 227*15625 = 3546875. Think I'll go with your values instead, they are probably the correct ones.
Last edited by orangespider; 13 February 2021 at 16:45. |
13 February 2021, 16:45 | #9 | |
Defendit numerus
Join Date: Mar 2017
Location: Crossing the Rubicon
Age: 53
Posts: 4,479
|
Quote:
On NTSC is even more different due to alternating length lines (it only average to 64us EDIT:~63,56us). So use my posted values Last edited by ross; 13 February 2021 at 16:58. |
|
13 February 2021, 16:49 | #10 |
Registered User
Join Date: Feb 2021
Location: Becej / Serbia
Posts: 120
|
I just got to those alternating length lines. I'm tying the timing of the phase shift to those cycles and it just gets more and more complicated as I read the documentation.
|
13 February 2021, 16:57 | #11 |
Defendit numerus
Join Date: Mar 2017
Location: Crossing the Rubicon
Age: 53
Posts: 4,479
|
Well, alternating lines are neutral in regard to your phase shift, only CCK is significant. Or I'm missing something?
|
13 February 2021, 17:57 | #12 | |
Registered User
Join Date: Feb 2021
Location: Becej / Serbia
Posts: 120
|
Quote:
The current idea I am working on is: 1) find a vposr/hvposr nearby that we will use to start the whole thing 2) precalculate vposr/hvposr for all the next steps knowing the delays we want to have 3) vposr/hvposr wait to: start up the dma 4) vposr/hvposr wait to: stop the dma when we started playing the 2nd sample from the first pair 5) vposr/hvposr wait to: write to channel 0 when all of the channels are on idle 6) vposr/hvposr wait to: write to channel 1 at 90 degrees 7) vposr/hvposr wait to: write to channel 3 at 180 degrees 8) vposr/hvposr wait to: write to channel 2 at 270 degrees 9) fire up the audio DMA again So the uneven scanlines are a problem, yes. |
|
13 February 2021, 22:55 | #13 |
Registered User
Join Date: Sep 2019
Location: Essen/Germany
Age: 55
Posts: 463
|
In my library, I do it this way: https://github.com/skeetor/amiga-uti...stemTakeover.s (line 21)
|
14 February 2021, 08:32 | #14 | |
Registered User
Join Date: Aug 2004
Location:
Posts: 3,344
|
Quote:
|
|
14 February 2021, 09:35 | #15 |
Registered User
Join Date: Feb 2021
Location: Becej / Serbia
Posts: 120
|
|
14 February 2021, 11:35 | #16 | |||
Defendit numerus
Join Date: Mar 2017
Location: Crossing the Rubicon
Age: 53
Posts: 4,479
|
Quote:
furthermore I seem to remember that in some condition there is a bug in the KS1.x in reporting this value. Quote:
Quote:
As EClockFrequency (the base clock for CIA chips) is CCK/5 then you need EClockFrequency*500.. |
|||
14 February 2021, 12:49 | #17 | |
Registered User
Join Date: Sep 2009
Location: Norway
Posts: 1,711
|
Quote:
The crystal frequencies are exactly 28.37516MHz for PAL and ~28.63636363MHz (repeating) for NTSC. These are nominal values, real case frequencies will be off by a small fraction because of crystal tolerances and possibly other external factors. So nominal Paula rates are: PAL: exactly 3546895Hz NTSC: ~3579545.45Hz (repeating) Last edited by 8bitbubsy; 14 February 2021 at 13:15. |
|
14 February 2021, 18:20 | #18 |
Registered User
Join Date: Aug 2004
Location:
Posts: 3,344
|
You could roll your own check, e.g. disable ints, wait for vblank, read e clock. Wait for a certain number of scanlines, read e clock again. The difference between readings should fall within two distinct ranges depending on Amiga crystal frequency.
|
14 February 2021, 18:29 | #19 | |
Defendit numerus
Join Date: Mar 2017
Location: Crossing the Rubicon
Age: 53
Posts: 4,479
|
Quote:
You need two independent sources to do what you written. |
|
19 February 2021, 01:20 | #20 |
Moderator
Join Date: Nov 2004
Location: Eksjö / Sweden
Posts: 5,627
|
Reading VFreq from Execbase is reliable - to reveal if the motherboard (and therefore the crystal, if Paula is used) is PAL or NTSC.
If you're turning off the system (say, for audio in games or demos), native modes are often used so that this is enough. If you're running in Workbench, it's best to use system functions for audio if possible, and the user shouldn't have to change his or her Workbench screen mode to play audio correctly. There are both native and expanded high-horizontal-frequency modes. |
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
Thread Tools | |
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
How to switch PAL Rev 6A A500 between PAL/NTSC? | BarryB | support.Hardware | 10 | 03 August 2016 14:41 |
Pal - Ntsc | dr.mushroom | New to Emulation or Amiga scene | 26 | 12 April 2014 09:48 |
NTSC A500 Pal/NTSC mod pics | kipper2k | Hardware pics | 2 | 29 March 2009 07:56 |
NTSC to PAL ...what's next? | NfernalNfluence | support.Hardware | 7 | 28 July 2007 12:19 |
Ntsc / Pal | killergorilla | project.SPS (was CAPS) | 3 | 09 July 2003 18:25 |
|
|