Detecting video standard: Difference between revisions

From NESdev Wiki
Jump to navigationJump to search
m (1 revision: Rest of pages not related to reference)
(An updated version uses no zero page scratch variables and isn't fooled by the $2002 race glitch)
 
Line 1: Line 1:
Simple way to detect if program is running on PAL or NTSC system.
#REDIRECT [[Detect TV system]]
 
<pre>
;
; Detects the video standard under which the program is running.
; Out:  A = 0 for 60 Hz (NTSC or PAL/M) or 1 for 50 Hz (PAL)
; Trash:@vdh, @vdl (variables on zeropage)
;
detectpalntsc:
 
  @vdl = $00
  @vdh = $01
 
  lda $2002
  bpl detectpalntsc
  lda #$00
  sta @vdh
  sta @vdl
@vdc: 
    lda @vdl
    clc
    adc #$01
    sta @vdl
    lda @vdh
    adc #$00
    sta @vdh
    lda $2002
    bpl @vdc
  lda @vdh
  sbc #$03
  rts
</pre>

Latest revision as of 21:31, 23 February 2011

Redirect to: