Log inRegister an accountBrowse CSDbHelp & documentationFacts & StatisticsThe forumsAvailable RSS-feeds on CSDbSupport CSDb Commodore 64 Scene Database
 Welcome to our latest new user ltk_tscc ! (Registered 2018-07-15) You are not logged in 
CSDb User Forums


Forums > C64 Productions > PAL/NTSC detect
2003-01-29 18:35
Dr. Jay
Account closed

Registered: Jan 2003
Posts: 32
PAL/NTSC detect

Just wanted to share a quick routine that detects PAL/NTSC WITHOUT using interrupts or latches.

;pal/NTSC detect - 0 = PAL, non-zero = NTSC

palntsc
sei ; disable interrupts
wait
lda $d012
bne wait ; wait for rasterline 0 or 256
wait1
lda $d011 ; Is rasterbeam in the area
bpl wait1 ; 0-255? if yes, wait
wait2
ldy #$00
synch1 lda $d012
cmp #$37 ; top PAL rasterline
bne synch1
lda $d012 ; if next is 0, then PAL
synch2 cmp $d012
beq synch2
lda $d012
cli ; enable interrupts
rts ; return
 
... 42 posts hidden. Click here to view all posts....
 
2010-10-02 12:13
Graham
Account closed

Registered: Dec 2002
Posts: 990
Slight improvement would be:

w0  LDA $D012
w1  CMP $D012
    BEQ w1
    BMI w0
    AND #$03

#$03 -> 312 rasterlines
#$02 -> 263 rasterlines
#$01 -> 262 rasterlines
2010-10-02 13:55
Moloch

Registered: Jan 2002
Posts: 1771
Ancient thread brought back to life, but certainly some excellent examples recently posted. Will work nicely for my NTSC/PAL detection needs, thanks!
2016-09-28 19:13
Sokrates

Registered: Jun 2014
Posts: 7
Enhanced version to differ between PAL and PAL-N. First count rasterlines, then count cycles.

    LDX #$00
w0  LDA $D012
w1  CMP $D012
    BEQ w1
    BMI w0
    AND #$03
    CMP #$03
    BNE detectionDone ; done for NTSC
    TAY
countCycles
    INX
    LDA $D012
    BPL countCycles
    CPX #$5E  ; VICE values: PAL-N=$6C PAL=$50
	      ; so choose middle value $5E for check 
    BCC isPAL
    INY ; is PAL-N
isPAL
    TYA
detectionDone
    ...

Results in the accumulator:
#$01: 262 rasterlines and 64 cycles per line [NTSC: 6567R56A VIC] (OLD NTSC)
#$02: 263 rasterlines and 65 cycles per line [NTSC: 6567R8 VIC]
#$03: 312 rasterlines and 63 cycles per line [PAL: 6569 VIC]
#$04: 312 rasterlines and 65 cycles per line [Drean PAL-N: 6572 VIC]
2016-09-28 21:09
Count Zero

Registered: Jan 2003
Posts: 813
Saw your edit on codebase - thanks for that!

Wonder whenever some special fix becomes drean-only or such. Those few more cycles likely only add advantage on calculations for some games, hm?
2016-09-29 02:08
TWW

Registered: Jul 2009
Posts: 436
Another version:

    .pseudocommand VSync {
        bit $d011
        bpl *-3
        bit $d011
        bmi *-3
    }

    lda #$ff
    sta $dc04
    sta $dc05  // Latch #$ffff to Timer A
    :VSync
    ldx #%00011001
    stx $dc0e  // Start Timer A (One shot mode (Timer stops automatically when underflow))
    :VSync
    sec
    sbc $dc05  // Hibyte number of counter
    and #%00000011


A now contains the video system as follows:

#0 - NTSC1
#1 - DREAN
#2 - PAL
#3 - NTSC2

Edit: Rectified bug.
2016-09-29 19:58
Sokrates

Registered: Jun 2014
Posts: 7
Quote: Saw your edit on codebase - thanks for that!

Wonder whenever some special fix becomes drean-only or such. Those few more cycles likely only add advantage on calculations for some games, hm?


Does anyone know about games/demos using the extra cycles of the drean?

My interest was only to have stable rasterlines for all VIC types. Just to be complete.

@TWW: I found your webpage about this topic after you post :-)
2016-09-30 23:13
Peiselulli

Registered: Oct 2006
Posts: 68
The module version of Spike+Minestorm have a drean detection and support it, also Jars Revenge ...
2016-10-01 01:02
Fungus
Account closed

Registered: Sep 2002
Posts: 440
already discussed here a couple years ago detecting pal, drean, ntsc or old ntsc
2016-10-01 21:22
Sokrates

Registered: Jun 2014
Posts: 7
Quote: The module version of Spike+Minestorm have a drean detection and support it, also Jars Revenge ...

Could you elaborate on that please? Maybe in a new thread "extra features in games/demos for drean" or so?
2016-10-04 10:14
Peiselulli

Registered: Oct 2006
Posts: 68
"support" only means that my (typical) CIA timers are adjusted if the different machines are detected, so the games will work. No more, no less.
Previous - 1 | 2 | 3 | 4 | 5 | 6 - Next
RefreshSubscribe to this thread:

You need to be logged in to post in the forum.

Search the forum:
Search   for   in  
All times are CET.
Search CSDb
Advanced
Users Online
Merlin/The Seven-A-T..
Groepaz
Grue
iAN CooG/HVSC
nucleus/TempesT
Stainless Steel/F4CG
cadaver/covertbitops
Guests online: 59
Top Demos
1 Uncensored  (9.7)
2 Edge of Disgrace  (9.7)
3 Coma Light 13  (9.6)
4 Comaland 100%  (9.6)
5 The Shores of Reflec..  (9.6)
6 Wonderland XII  (9.6)
7 Lunatico  (9.6)
8 We Come in Peace  (9.5)
9 Incoherent Nightmare  (9.5)
10 Wonderland XIII  (9.5)
Top onefile Demos
1 FMX Music Demo  (9.6)
2 Daah, Those Acid Pil..  (9.5)
3 Pandemoniac Part 2 o..  (9.5)
4 Treu Love [reu]  (9.5)
5 Merry Xmas 2017  (9.4)
6 Arok 20 Invitation  (9.4)
7 Dawnfall V1.1  (9.4)
8 In Memoriam BHF  (9.4)
9 Dawnfall  (9.4)
10 Synthesis  (9.4)
Top Groups
1 Oxyron  (9.4)
2 Booze Design  (9.4)
3 Censor Design  (9.4)
4 Finnish Gold  (9.4)
5 Crest  (9.3)
Top Original Suppliers
1 hedning  (9.7)
2 Derbyshire Ram  (9.3)
3 Jazzcat  (9.1)
4 Irata  (9.0)
5 Fungus  (9.0)

Home - Disclaimer
Copyright © No Name 2001-2018
Page generated in: 0.064 sec.