base:detect_pal_ntsc
Differences
This shows you the differences between two versions of the page.
Next revision | Previous revisionNext revisionBoth sides next revision | ||
base:detect_pal_ntsc [2015-04-17 04:31] – external edit 127.0.0.1 | base:detect_pal_ntsc [2018-10-29 10:50] – [Sokrates' variant] mrr19121970 | ||
---|---|---|---|
Line 1: | Line 1: | ||
- | ====== Detect | + | ====== Detect NTSC/PAL ====== |
- | Since you cannot rely on $02a6 to detect | + | Since you cannot rely on $02a6 to detect NTSC/PAL, you better do the check yourself. The theory behind these checks is simply that PAL and NTSC systems have different |
===== J0x variant ===== | ===== J0x variant ===== | ||
Line 62: | Line 62: | ||
EDIT: This check assumes that the machine is not a Drean PAL-N, which has 312 lines and 65 cycles per line. | EDIT: This check assumes that the machine is not a Drean PAL-N, which has 312 lines and 65 cycles per line. | ||
+ | ===== Sokrates' | ||
+ | |||
+ | Graham' | ||
+ | |||
+ | < | ||
+ | SEI | ||
+ | LDX #$00 | ||
+ | w0 LDA $D012 | ||
+ | w1 CMP $D012 | ||
+ | BEQ w1 | ||
+ | BMI w0 | ||
+ | AND #$03 | ||
+ | CMP #$03 | ||
+ | BNE detectionDone ; done for NTSC | ||
+ | TAY | ||
+ | countCycles | ||
+ | INX | ||
+ | LDA $D012 | ||
+ | BPL countCycles | ||
+ | CPX #$5E ; VICE values: PAL-N=$6C PAL=$50 | ||
+ | ; so choose middle value $5E for check | ||
+ | BCC isPAL | ||
+ | INY ; is PAL-N | ||
+ | isPAL | ||
+ | TYA | ||
+ | detectionDone | ||
+ | ... | ||
+ | </ | ||
+ | |||
+ | Results in the accumulator: | ||
+ | |||
+ | < | ||
+ | #$01: 262 rasterlines and 64 cycles per line [NTSC: 6567R56A VIC] (OLD NTSC) | ||
+ | #$02: 263 rasterlines and 65 cycles per line [NTSC: 6567R8 VIC] | ||
+ | #$03: 312 rasterlines and 63 cycles per line [PAL: 6569 VIC] | ||
+ | #$04: 312 rasterlines and 65 cycles per line [Drean PAL-N: 6572 VIC] | ||
+ | </ | ||
===== TLR's more advanced variant ===== | ===== TLR's more advanced variant ===== | ||
Line 575: | Line 612: | ||
; eof | ; eof | ||
</ | </ | ||
+ | |||
+ | |||
+ | ===== TWW's Variant ===== | ||
+ | |||
+ | Count' | ||
+ | |||
+ | < | ||
+ | // | ||
+ | // Detect PAL/NTSC | ||
+ | // | ||
+ | // 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 => #> | ||
+ | |||
+ | DetectC64Model: | ||
+ | |||
+ | // 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 cycles used | ||
+ | and #%00000011 | ||
+ | rts | ||
+ | </ | ||
+ | |||
===== Older routine ===== | ===== Older routine ===== |
base/detect_pal_ntsc.txt · Last modified: 2020-11-11 01:49 by copyfault