| |
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.... |
| |
Dr. Jay Account closed
Registered: Jan 2003 Posts: 32 |
LOL. I saw the LDY after I posted it ... artifact from an earlier attempt. Yes, I like the LDA $D011 ... much more elegant. And as for the ROM issue ... everything I've come to understand says that checking the $02a6 etc is unreliable as different versions, mods, carts, etc. may change this ... but I'm stuck in NTSC-land with a 64C so I haven't had the opportunity to try this on many other stock machines.
|
| |
Ninja
Registered: Jan 2002 Posts: 406 |
I think the main problem with $02A6 is, that it is set after a reset only. So, load some scene-production which doesn't care about KERNAL-variables and maybe exits with a plain RTS, and $02A6 is as reliable as your house-number :)
Also, the KERNAL-method does not work with accelerators.
False detections because of $02A6 are really annoying; especially as PAL/NTSC-checks are public and easy to implement.
So much for the preaching... ;) |
| |
Perff Administrator
Posts: 1665 |
ninjadrm: Ok sorry for my "lame" idea. I just thought I remembered that somewhere in the ROM it said lda #$X sta $02A6 and thought of that as a 100% way to determin PAL/NTSC
Well.. I was wrong. You're right. Sorry. :) |
| |
Ninja
Registered: Jan 2002 Posts: 406 |
Perff: No need to be sorry or to excuse for a "lame" idea; it was just meant to be constructive criticism :) |
| |
Graham Account closed
Registered: Dec 2002 Posts: 990 |
do NOT use the pal/ntsc flag since it is unreliable, even without any kind of extensions. the best way is really to check if certain rasterlines exist or not.
|
| |
AlexC
Registered: Jan 2008 Posts: 293 |
Quote: do NOT use the pal/ntsc flag since it is unreliable, even without any kind of extensions. the best way is really to check if certain rasterlines exist or not.
Does it mean that original ROM can set this flag wrongly? Haven't studied this part of ROM but I remember that the detection routine used is quite short. |
| |
chatGPZ
Registered: Dec 2001 Posts: 11127 |
yes, the rom routine has a flaw that sometimes makes it report ntsc when the machine is infact pal. (atleast thats how i remember it =D) |
| |
AlexC
Registered: Jan 2008 Posts: 293 |
Quote: yes, the rom routine has a flaw that sometimes makes it report ntsc when the machine is infact pal. (atleast thats how i remember it =D)
Thanks for clearing it up for me. I need to get NTSC machine to experiment a bit. |
| |
Devia
Registered: Oct 2004 Posts: 401 |
So the shortest/fastes routine for reliable detection would be something like:
PALNTSC
sei
lda $01
pha
lda #<INT_NMI
sta $fffa
lda #>INT_NMI
sta $fffb
lda #$35
sta $01
;---important stuff start
: bit $d011
bpl :-
: lda $d012
cmp #<263
bcs :+ ;Result >= 0 then PAL
bit $d011
bmi :-
clc ;NTSC
:
;---important stuff end
pla
sta $01
rts
INT_NMI
rti
|
| |
tlr
Registered: Sep 2003 Posts: 1717 |
I came to basically the same conclusion:
http://codebase64.org/doku.php?id=bae:dtv_detect (scroll down) |
Previous - 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 - Next |