Log inRegister an accountBrowse CSDbHelp & documentationFacts & StatisticsThe forumsAvailable RSS-feeds on CSDbSupport CSDb Commodore 64 Scene Database
You are not logged in - nap
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
 
... 67 posts hidden. Click here to view all posts....
 
2009-02-15 13:41
TNT
Account closed

Registered: Oct 2004
Posts: 189
WTF happened to my post above? Well, tlr pointed out the need for extra check.

Can anyone find something wrong with this approach:
.w	ldx	$d012
	cpx	$d012
	beq	*-3
	lda	$d012
	bne	.w
	inx
	beq	.w
	cpx	#20

2009-02-15 16:35
tlr

Registered: Sep 2003
Posts: 1714
Quote: WTF happened to my post above? Well, tlr pointed out the need for extra check.

Can anyone find something wrong with this approach:
.w	ldx	$d012
	cpx	$d012
	beq	*-3
	lda	$d012
	bne	.w
	inx
	beq	.w
	cpx	#20



Nice approach using just $d012 to avoid the race condition!
I think that will work.
2009-02-15 17:03
j0x

Registered: Mar 2004
Posts: 215
l1 lda $d012
l2 cmp $d012
   beq l2
   bmi l1
   cmp #$20
   bcc ntsc


2009-02-15 17:16
tlr

Registered: Sep 2003
Posts: 1714
Quote:
l1 lda $d012
l2 cmp $d012
   beq l2
   bmi l1
   cmp #$20
   bcc ntsc




12 bytes. Very impressive!
2009-02-15 22:00
Devia

Registered: Oct 2004
Posts: 401
Quote:
l1 lda $d012
l2 cmp $d012
   beq l2
   bmi l1
   cmp #$20
   bcc ntsc




That's brilliant.
2009-02-16 09:02
Frantic

Registered: Mar 2003
Posts: 1627
I put it on codebase:

http://codebase64.org/doku.php?id=base:detect_pal_ntsc

I also wonder... does Ninja's older routine have any benefits over and above this short 12 byte routine? (Didn't have any time/energy to look into it myself now, sorry.) If not, I guess it could just as well be removed.

//FTC
2009-02-16 12:54
Devia

Registered: Oct 2004
Posts: 401
You still need to catch NMI and disable IRQ for it to be completely reliable - and the 12 bytes is without the bcc in the end, which may be obsolete depending on how you implement it.


2009-02-16 14:28
Ninja

Registered: Jan 2002
Posts: 405
Frantic:

Technically, my routine does not have an advantage. From an educational point of view, it has (it was supplement code to an article after all) :) If you don't know the topic, then it surely helps to read my routine first, before you use the other (probably with disabling interrupts there, too).
2009-02-16 20:32
Frantic

Registered: Mar 2003
Posts: 1627
Okok... Thanks for the information. In fact, I added the whole article to the page, since I guess it might add something of value to someone out there. (Just tell me if you mind...)
2009-02-16 20:49
Kickback

Registered: Apr 2004
Posts: 97
Actually this helps me BIGTIME. Because I always thought that the PAL/NTSC register was the way to go.

Thanks guys for the information, helps me with NTSc/PAL intros ;-)
Previous - 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 - 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
nucleus/TempesT
DKT/Samar
Scrap/Genesis Project
Youth
Apollyon/ALD
master_hacker
d'Arc/Topaz Beerline
kbs/Pht/Lxt
soci/Singular
Skate/Plush
Higgie/Kraze/Onslaught
Knight Rider/TREX
Gildan Jondal/Suicyc..
tlr
Guests online: 178
Top Demos
1 Next Level  (9.8)
2 Mojo  (9.7)
3 Coma Light 13  (9.7)
4 Edge of Disgrace  (9.6)
5 Comaland 100%  (9.6)
6 No Bounds  (9.6)
7 Uncensored  (9.6)
8 Wonderland XIV  (9.6)
9 Memento Mori  (9.6)
10 Bromance  (9.5)
Top onefile Demos
1 It's More Fun to Com..  (9.7)
2 Party Elk 2  (9.7)
3 Cubic Dream  (9.6)
4 Copper Booze  (9.5)
5 TRSAC, Gabber & Pebe..  (9.5)
6 Rainbow Connection  (9.5)
7 Wafer Demo  (9.5)
8 Dawnfall V1.1  (9.5)
9 Quadrants  (9.5)
10 Daah, Those Acid Pil..  (9.5)
Top Groups
1 Nostalgia  (9.3)
2 Oxyron  (9.3)
3 Booze Design  (9.3)
4 Censor Design  (9.3)
5 Crest  (9.3)
Top Swappers
1 Derbyshire Ram  (10)
2 Jerry  (9.8)
3 Violator  (9.8)
4 Acidchild  (9.7)
5 Starlight  (9.6)

Home - Disclaimer
Copyright © No Name 2001-2024
Page generated in: 0.04 sec.