Log inRegister an accountBrowse CSDbHelp & documentationFacts & StatisticsThe forumsAvailable RSS-feeds on CSDbSupport CSDb Commodore 64 Scene Database
 Welcome to our latest new user dstar ! (Registered 2024-05-25) 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: 447
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: 629
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: 1060
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: 11148
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: 11148
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: 1727
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: 4617
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: 11148
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
Kruthers
Guests online: 61
Top Demos
1 Next Level  (9.8)
2 13:37  (9.7)
3 Mojo  (9.7)
4 Coma Light 13  (9.7)
5 Edge of Disgrace  (9.6)
6 No Bounds  (9.6)
7 Comaland 100%  (9.6)
8 Uncensored  (9.6)
9 Wonderland XIV  (9.6)
10 Bromance  (9.5)
Top onefile Demos
1 Layers  (9.6)
2 It's More Fun to Com..  (9.6)
3 Cubic Dream  (9.6)
4 Party Elk 2  (9.6)
5 Copper Booze  (9.6)
6 TRSAC, Gabber & Pebe..  (9.5)
7 Rainbow Connection  (9.5)
8 Dawnfall V1.1  (9.5)
9 Quadrants  (9.5)
10 Daah, Those Acid Pil..  (9.5)
Top Groups
1 Covert Bitops  (9.4)
2 Nostalgia  (9.4)
3 Oxyron  (9.3)
4 Booze Design  (9.3)
5 Crest  (9.3)
Top Crackers
1 Mr. Z  (9.9)
2 Antitrack  (9.8)
3 OTD  (9.8)
4 S!R  (9.7)
5 Faayd  (9.7)

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