Detecting video standard

From NESdev Wiki
Revision as of 04:22, 13 June 2009 by Ndwiki (talk | contribs) (1 revision: Rest of pages not related to reference)
Jump to navigationJump to search

Simple way to detect if program is running on PAL or NTSC system.

;
; 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