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....
 
2014-01-22 05:21
Flavioweb

Registered: Nov 2011
Posts: 463
Here it is the stabilized TWW version:
INIT
    SEI
    CLD
    LDX #$FF
    TXS
    LDA #$2F
    STA $00
    LDA #$35
    STA $01
;-------------------
    LDX #<NO_NMI
    LDY #>NO_NMI
    STX $0318
    STY $0319
    STX $FFFA
    STY $FFFB
    LDY #$00
    STY $DC03                           ; Port $DC01 = Input
    DEY
    STY $DC02                           ; Port $DC00 = Output
;-------------------
    LDA #$7F
    STA $DC0D
    STA $DD0D
    LDA $DC0D
    LDA $DD0D
;-------------------
    LDA #$00
    STA $DD0E                           ; Stop CIA #2 Timer A
    STA $DD04
    STA $DD05                           ; Set Timer A = 0 (NMI will trigger immediately when Timer A is restarted)
    LDA #$81
    STA $DD0D                           ; Set Timer A as NMI source
    LDA #$01
    STA $DD0E                           ; Start Timer A (triggers NMI and unless the NMI get's acked, any new NMI's will be ignored).
    LDA #$00                            ; From this point on we will not be disturbed and can commence testing.
    STA $D015                           ; No Sprites
;------------------------------------------------------------------------------
; Detect the model
;---------------------------------------
; 312 rasterlines -> 63 cycles per line PAL        => 312 * 63 = 19656 Cycles / VSYNC
; 262 rasterlines -> 64 cycles per line NTSC V1    => 262 * 64 = 16768 Cycles / VSYNC
; 263 rasterlines -> 65 cycles per line NTSC V2    => 263 * 65 = 17095 Cycles / VSYNC
; 312 rasterlines -> 65 cycles per line PAL DREAN  => 312 * 65 = 20280 Cycles / VSYNC
;------------------------------------------------------------------------------
    LDA #$FF                            ; Use CIA #1 Timer A to count cycled in a frame
    STA $DC06
    STA $DC07                           ; Latch #$ffff to Timer B
    LDY #%00011001
    LDA #$7F
WAIT_BEAM_01
    CMP $D012
    BNE WAIT_BEAM_01
    BIT $DEAD
    BIT $BEEF
    STA $D011
    STY $DC0F                           ; Start Timer B (One shot mode (Timer stops automatically when underflow)
    LDY #$00
    LDA #$1B
    STA $D011
    LDA #$7F
WAIT_BEAM_02
    CMP $D012
    BNE WAIT_BEAM_02
    BIT $DEAD
    BIT $BEEF
    STA $D011
;-------------------
    STY $DC0F
    LDX $DC06
    LDY $DC07
    STY $0400
    STX $0401
    LDA #$1B                            ; TURN BACK ON SCREEN TO SEE RESULT
    STA $D011
;-------------------
WAIT_SOME_SPACE
    LDA $DC01
    AND $DC00
    AND #$10
    BNE WAIT_SOME_SPACE
    JMP INIT
;-------------------
NO_NMI
    RTI

In $0400/$0401 there are values to subtract from $FFFF to obtain cycles/VSYNC (-1).
PAL: $B338 ($FFFF-$B338 = $4CC7)
NTSC: $BD39 ($FFFF-$BD39 = $42C6)
DREAN: $B0C8 ($FFFF-$B0C8 = $4F37)

Tested on "x64 2.4.5 r27742M".
Someone can test it on real hardware?
2014-01-22 09:12
Fungus

Registered: Sep 2002
Posts: 680
Mine counted cycles also and used vsync to check. Although I made a small math error about old ntsc. sprites and DMA don't matter with a timer, since the clock runs independant of such stuff, and the up to 1 line delay doesn't matter really.

Nice different ways of checking, cool to see. Not that anyone cares about NTSC ;)
2014-01-22 11:45
MagerValp

Registered: Dec 2001
Posts: 1074
Quoting Peiselulli
@MagerValp : But the main reason for starting this thread is missing : detection between "drean" an "pal".

Yes, but that was in 2012, H Macaroni's thread necrophilia was regarding PAL vs NTSC. For Drean vs PAL it's of course a little more work.

I'd love to see some Drean releases though, two extra cycles per line should allow for some neat tricks not possible on PAL.
2014-01-22 20:56
Peiselulli

Registered: Oct 2006
Posts: 81
But unfortunately I'm waiting for a test result on a drean machine since then ;-(
2014-01-22 21:47
chatGPZ

Registered: Dec 2001
Posts: 11350
Quote:
I'd love to see some Drean releases though, two extra cycles per line should allow for some neat tricks not possible on PAL.

i'd love to see one or two people who own such machines and are willing to run a bunch of testprogs - because everything in VICE regarding drean is pure guesswork :)
2014-01-23 00:28
Durandal

Registered: May 2006
Posts: 30
Quote: Quote:
I'd love to see some Drean releases though, two extra cycles per line should allow for some neat tricks not possible on PAL.

i'd love to see one or two people who own such machines and are willing to run a bunch of testprogs - because everything in VICE regarding drean is pure guesswork :)


Me, hedning and Thierry already did 3 years ago ;)

http://csdb.dk/forums/?roomid=7&topicid=73859#81066

(unless there's some new tests that need to be done on the Drean)
2014-01-23 00:49
chatGPZ

Registered: Dec 2001
Posts: 11350
there are a couple new ones... not exactly sure which though, tlr is the VIC guy =)
2014-01-24 18:00
tlr

Registered: Sep 2003
Posts: 1787
Quoting Groepaz
i'd love to see one or two people who own such machines and are willing to run a bunch of testprogs - because everything in VICE regarding drean is pure guesswork :)

It's not pure guesswork since those much valued tests The_WOZ, Thierry and hedning did.

It's far less verified than PAL emulation but not so far from NTSC emulation IMO. This goes for x64sc. For x64 all bets are off as usual.

Sorry for the late answer BTW. Was away watching Kraftwerk... ;)
2014-01-24 20:11
hedning

Registered: Mar 2009
Posts: 4720
I'm willing to test stuff on my drean if people need it. Just PM me.
2014-01-26 11:14
chatGPZ

Registered: Dec 2001
Posts: 11350
ok so that improved since last time i checked (which was the first and last time i ever run a supposedly drean specific program =P)

then instead everyone bug tlr about fixing that damned sprite x stretch bug =D
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
Mojzesh/TGR🇬🇧
theK/ATL
Epyx/TSA
WVL/Xenon
Thunder.Bird/HF/MYD!..
katon/Lepsi De
Sychamis
Unlock/Padua/Albion
Ax!s/Onslaught - TND
Vent
MWR/Visdom
psych
hedning/G★P
Almighty God/Level 6..
Acidchild/Padua
rambo/Therapy/ Resou..
Brittle/Dentifrice^(?)
Alta
Guests online: 131
Top Demos
1 Next Level  (9.7)
2 13:37  (9.7)
3 Coma Light 13  (9.7)
4 Edge of Disgrace  (9.6)
5 Mojo  (9.6)
6 Uncensored  (9.6)
7 Wonderland XIV  (9.6)
8 Comaland 100%  (9.6)
9 No Bounds  (9.6)
10 Christmas Megademo  (9.5)
Top onefile Demos
1 Layers  (9.6)
2 Party Elk 2  (9.6)
3 Cubic Dream  (9.6)
4 Copper Booze  (9.6)
5 Libertongo  (9.5)
6 Rainbow Connection  (9.5)
7 Onscreen 5k  (9.5)
8 Morph  (9.5)
9 Dawnfall V1.1  (9.5)
10 It's More Fun to Com..  (9.5)
Top Groups
1 Performers  (9.3)
2 Booze Design  (9.3)
3 Oxyron  (9.3)
4 Nostalgia  (9.3)
5 Censor Design  (9.3)
Top Webmasters
1 Slaygon  (9.6)
2 Perff  (9.6)
3 Morpheus  (9.5)
4 Sabbi  (9.5)
5 CreaMD  (9.1)

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