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 Coding > detecting pal, drean, ntsc or old ntsc
2012-11-26 14:21
Peiselulli

Registered: Oct 2006
Posts: 81
detecting pal, drean, ntsc or old ntsc

Hello,
I want to know if a test like this is reliable for the four different machine types PAL, NTSC, NTSC(old) and DREAN (ACME source code):

OLD_NTSC = 1
NTSC = 0
PAL = 2
DREAN = 3

        !to "detect.prg",cbm
	!cpu 6510

	* = $0801
	!by $0b,$08,$00,$00,$9e,$32,$30,$36,$31,$00,$00,$00
		
detect:	sei
w0:  	lda $d012
w1:  	cmp $d012
	beq w1
	bmi w0
	and #$03
	cmp #$01
	bne w2
	lda #OLD_NTSC
	bne detected ; unconditional
w2:	cmp #$03
	lda #$00
	rol
	beq detected	;ntsc

	;check for drean or pal
	ldx #$00
	lda #$10
l	inx
	cmp $d012
	bne l
	lda #PAL
	cpx #$70
	bcc detected
	;is a drean
	lda #DREAN
detected:
	tay
	lax offset,y
l2:	lda base_text,x
	beq end
	jsr $ffd2
	inx
	bne l2
end:	lda #$0d
	jmp $ffd2

base_text:
old_ntsc_text:	!text "OLD "
ntsc_text:	!text "NTSC",0
pal_text:	!text "PAL",0
drean_text:	!text "DREAN",0

offset:		
	!byte ntsc_text-base_text
	!byte old_ntsc_text-base_text
	!byte pal_text-base_text
	!byte drean_text-base_text


 
... 63 posts hidden. Click here to view all posts....
 
2012-11-26 22:26
Flavioweb

Registered: Nov 2011
Posts: 442
Works perfectly using Vice 2.4.

Chapeau.
2012-11-26 22:31
Peiselulli

Registered: Oct 2006
Posts: 81
Ok, it can made be shorter. Instead of
	lda #PAL
	cpx #$70
	bcc detected
	;is a drean
	lda #DREAN
detected:

it can be changed to:
	lda #PAL/2
	cpx #$70
	rol
detected:

but this is not the point here.
Can somebody check it on a real Drean C64 ?
2012-11-26 23:51
hedning

Registered: Mar 2009
Posts: 4550
I could try to, tomorrow. Oh. It is already tomorrow. Later today that is, then. :)
2012-11-27 11:27
Flavioweb

Registered: Nov 2011
Posts: 442
You inspired me to write my version:
SCAN_START
   LDA $D012
LINE_CMP
   CMP $D012
   BEQ LINE_CMP
   BMI SCAN_START
   AND  #%00001111
   CLC
   LSR
   BCS IS_NTSC
   LSR
   BCS IS_OLDNTSC
;check for drean or pal
   LDX #$00
   LDA #$10
L
   INX
   CMP $D012
   BNE L
   CPX #$70
   BCC IS_PAL
IS_DREAN
    RTS
IS_NTSC
    RTS
IS_OLDNTSC
    RTS
IS_PAL
    RTS

Is from the top of my mind... so isn't tested.
Hope it works.
2012-11-27 12:30
Frantic

Registered: Mar 2003
Posts: 1626
Once this code is tested and tried I would like to encourage people to add some of this to the corresponding page on codebase 64:

http://codebase64.org/doku.php?id=base:detect_pal_ntsc
2012-11-27 20:18
Flavioweb

Registered: Nov 2011
Posts: 442
This version works in Vice:
;------------------------------------------------------------------------------- 
; Vic mode detection.
; Detect Pal, Ntsc, Old Ntsc, Drean
; Based on source posted by Peiselulli
; [url=http://noname.c64.org/csdb/forums/?roomid=11&topicid=94459]
; Tass version
; (C) 2012 by FlavioWeb/Hokuto Force
;------------------------------------------------------------------------------- 
    .CPU 6502
    *= $0801
;---------------------------------------
    .BYTE $0b, $08, $00, $00, $9e, $32, $30, $36
    .BYTE $31, $00, $00, $00
;---------------------------------------
    SEI
SCAN_START
    LDA $D012
LINE_CMP
    CMP $D012
    BEQ LINE_CMP
    BMI SCAN_START
    ADC #$00
    LSR
    BCS IS_NTSC
    LSR
    BCS IS_OLDNTSC
    LDX #$00                            ; Check for drean or pal
    LDA #$10
L
    INX
    CMP $D012
    BNE L
    CPX #$70
    BCC IS_PAL
IS_DREAN
    LDX #DREAN_TEXT-OLD_NTSC_TEXT
    BNE DETECTED
IS_NTSC
    LDX #NTSC_TEXT-OLD_NTSC_TEXT
    BNE DETECTED
IS_OLDNTSC
    LDX #$00
    BEQ DETECTED
IS_PAL
    LDX #PAL_TEXT-OLD_NTSC_TEXT
DETECTED
    LDA OLD_NTSC_TEXT,X
    BEQ END
    JSR $FFD2
    INX
    BNE DETECTED
END
    CLI
    RTS
;---------------------------------------
OLD_NTSC_TEXT
    .TEXT "OLD "
NTSC_TEXT
    .TEXT "NTSC"
    .BYTE $00
PAL_TEXT
    .TEXT "PAL"
    .BYTE $00
DREAN_TEXT
    .TEXT "DREAN"
    .BYTE $00
2014-01-19 11:41
Norrland

Registered: Aug 2011
Posts: 14
Hi there!
I'll hijack this tread since I have some reported issues with the pal/ntsc-check in That Demo with the New Hubbard Tune. In this one, I ran out of (spare)time to do a proper ntsc-compatible routine for showing a flipicture with sprites/unrolled code so I added a message/program stop if the machine seemed like a non-pal (didn't care about drean).

Anyway, some people reported that they got the error message despite using pal (at least in vice, not sure if anyone encountered it on real hardware). I haven't seen it on real hardware or vice myself.

my code:
	;ntsctest
	l1 
	lda $d012

	l2 
	cmp $d012
        beq l2
        bmi l1
        and #$03
	cmp #$03	;if #$03 pal, (or drean)
	beq $0900

	;else, show ntsc-message
	lda #$30
	sta $d018	;charset on $0000 ($8000) and screenram on $0800 ($8800)
        jmp *


I'm counting the rasterlines for the test (used this code before since I once read about the topic at codebase), and to me it's seems to be exactly the same codesnippet as the short test on codebase:

Quote:

The easiest way to determine cycles/rasterline is to count the rasterlines:

312 rasterlines -> 63 cycles per line [PAL: 6569 VIC]
263 rasterlines -> 65 cycles per line [NTSC: 6567R8 VIC]
262 rasterlines -> 64 cycles per line [NTSC: 6567R56A VIC]

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

Â…and the results in the akku:

#$03 -> 312 rasterlines
#$02 -> 263 rasterlines
#$01 -> 262 rasterlines


I thought that method to test was ok, can anyone help me finding why not (or is this just emulator-related?

Groepaz: you mentioned in the release that you encountered this problem on your pal-machine. Was that real hardware or emulator?
2014-01-19 12:35
Burglar

Registered: Dec 2004
Posts: 1027
I can understand why ppl want to know how to manually detect pal/ntsc, but for real releases, what's wrong with good old $02a6?

lda $02a6
beq ntsc
bne pal

its really that simple.

and with micro64 tdwtnht also detected ntsc while I was running pal. then restarted it and it was detected as pal... so, obviously ur check is seriously broken.

again, use $02a6, it's why it's there!
2014-01-19 13:02
tlr

Registered: Sep 2003
Posts: 1701
IIRC $02a6 is far from reliable.
2014-01-19 13:40
Flavioweb

Registered: Nov 2011
Posts: 442
You forgot a SEI.
If an irq is fired in the middle of the loop... all fucks.
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
Matt
A3/AFL
Guests online: 374
Top Demos
1 Next Level  (9.8)
2 Mojo  (9.7)
3 Coma Light 13  (9.7)
4 Edge of Disgrace  (9.6)
5 No Bounds  (9.6)
6 Comaland 100%  (9.6)
7 Uncensored  (9.6)
8 The Ghost  (9.6)
9 Wonderland XIV  (9.6)
10 Bromance  (9.6)
Top onefile Demos
1 Party Elk 2  (9.7)
2 Cubic Dream  (9.6)
3 Copper Booze  (9.5)
4 Rainbow Connection  (9.5)
5 TRSAC, Gabber & Pebe..  (9.5)
6 Onscreen 5k  (9.5)
7 Dawnfall V1.1  (9.5)
8 Quadrants  (9.5)
9 Daah, Those Acid Pil..  (9.5)
10 Birth of a Flower  (9.5)
Top Groups
1 Booze Design  (9.3)
2 Nostalgia  (9.3)
3 Oxyron  (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.046 sec.