| |
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.... |
| |
MagerValp
Registered: Dec 2001 Posts: 1074 |
TWW's cycle counter is impressive, but seems like overkill for most things :) I prefer a straightforward approach:
init:
lda #$7f ; Disable kernal IRQ.
sta $dc0d
lda #$ff ; Start on line 255.
: cmp $d012
bne :-
@nextline:
lda $d012 ; Wait until the next line.
: cmp $d012
beq :- ; A contains the previous line number.
bit $d011 ; Are we back on line 0?
bmi @nextline
ora #$30 ; A contains the LSB of the last line number:
sta $0400 ; $05 = 262 x 64 cycle NTSC
lda #1 ; $06 = 263 x 65 cycle NTSC
sta $d800 ; $37 = 312 x 63 cycle PAL or 312 x 65 cycle DREAN
|
| |
Peiselulli
Registered: Oct 2006 Posts: 81 |
@MagerValp : But the main reason for starting this thread is missing : detection between "drean" an "pal". |
| |
TWW
Registered: Jul 2009 Posts: 545 |
Slightly improved version:
// Use CIA #1 Timer B to count cycled in a frame
lda #$ff
sta $dc06
sta $dc07 // Latch #$ffff to Timer B
bit $d011
bpl *-3 // Wait untill Raster > 256
bit $d011
bmi *-3 // Wait untill Raster = 0
ldx #%00011001
stx $dc0f // Start Timer B (One shot mode (Timer stops automatically when underflow))
bit $d011
bpl *-3 // Wait untill Raster > 256
bit $d011
bmi *-3 // Wait untill Raster = 0
sec
sbc $dc07 // Hibyte number of total cycles
and #%00000011
|
| |
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? |
| |
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 ;) |
| |
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. |
| |
Peiselulli
Registered: Oct 2006 Posts: 81 |
But unfortunately I'm waiting for a test result on a drean machine since then ;-( |
| |
chatGPZ
Registered: Dec 2001 Posts: 11358 |
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 :) |
| |
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) |
| |
chatGPZ
Registered: Dec 2001 Posts: 11358 |
there are a couple new ones... not exactly sure which though, tlr is the VIC guy =) |
Previous - 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 - Next |