| |
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
|
|
| |
Devia
Registered: Oct 2004 Posts: 401 |
How many lines does the Drean have?
And is the Drean 6572 or 6573?
|
| |
tlr
Registered: Sep 2003 Posts: 1787 |
Nice detection code!
@devia: 312 lines. |
| |
Moloch
Registered: Jan 2002 Posts: 2924 |
Nice detection routine, will have to give it some testing.
Quoting DeviaHow many lines does the Drean have?
And is the Drean 6572 or 6573?
6572
Lots of details here
http://www.solidstate.com.ar/2011/06/flashback-vic-ii-timings/ |
| |
Flavioweb
Registered: Nov 2011 Posts: 463 |
Works perfectly using Vice 2.4.
Chapeau. |
| |
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 ?
|
| |
hedning
Registered: Mar 2009 Posts: 4720 |
I could try to, tomorrow. Oh. It is already tomorrow. Later today that is, then. :) |
| |
Flavioweb
Registered: Nov 2011 Posts: 463 |
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. |
| |
Frantic
Registered: Mar 2003 Posts: 1646 |
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 |
| |
Flavioweb
Registered: Nov 2011 Posts: 463 |
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
|
| |
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? |
... 63 posts hidden. Click here to view all posts.... |
Previous - 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 - Next |