base:detect_pal_ntsc
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revisionNext revisionBoth sides next revision | ||
base:detect_pal_ntsc [2016-12-27 02:39] – tww_ctr | base:detect_pal_ntsc [2020-11-10 21:47] – copyfault | ||
---|---|---|---|
Line 1: | Line 1: | ||
- | ====== Detect PAL/NTSC ====== | + | ====== Detect |
- | + | ||
- | Since you cannot rely on $02a6 to detect PAL/NTSC, you better do the check yourself. The theory behind these checks is simply that PAL and NTSC systems have different ammounts of rasterlines, | + | |
+ | 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 amounts of rasterlines, | ||
===== J0x variant ===== | ===== J0x variant ===== | ||
Line 67: | Line 66: | ||
< | < | ||
+ | SEI | ||
LDX #$00 | LDX #$00 | ||
w0 LDA $D012 | w0 LDA $D012 | ||
Line 826: | Line 826: | ||
</ | </ | ||
+ | ===== When size really matters ===== | ||
+ | |||
+ | by Copyfault/ | ||
+ | |||
+ | In the following I'm going to present two routines for detecting PAL/NTSC: the first one is used for telling a EU-PAL-chip (with 63 cycles per line) apart from a "new NTSC" | ||
+ | |||
+ | The 2nd routine is capable of detecting any of the four VIC-types that have been mentioned earlier on this page (EU-PAL, NTSC old _and_ new and the one for the Drean-PAL-system). | ||
+ | |||
+ | ==== Short PAL/NTSC detection ==== | ||
+ | |||
+ | The basic idea is to constantly read the raster beam position and keeping it in a backup register until rasterline==0 (or rasterline==$100) is reached. Then the backup register holds the value of the last line that was read before reaching line 0 (or $100 resp.). | ||
+ | |||
+ | In case the last line was $ff, it does not tell much about the system at hand. Thus, the rasterline-read-and-backup-procedure is repeated until the backup value is not $ff afterwards. | ||
+ | |||
+ | The well-known table of VIC-specs now reveals that the backup value must be one of the following: | ||
+ | < | ||
+ | #$37 -> 312 rasterlines -> PAL | ||
+ | #$06 -> 263 rasterlines -> new NTSC | ||
+ | #$05 -> 262 rasterlines -> old NTSC | ||
+ | </ | ||
+ | |||
+ | It's even possible to tell new and old NTSC apart this way (not just PAL vs. NTSC as stated in the preface). The approach is NOT capable of detecting a Drean PAL-VIC-Chip since EU-PAL and PAL-N have the same number of rasterlines per frame. | ||
+ | |||
+ | |||
+ | ==== Source Code ==== | ||
+ | < | ||
+ | chk: | ||
+ | ldx #$aa //TAX | ||
+ | lda $d012 | ||
+ | bne chk+1 | ||
+ | txa | ||
+ | bmi chk | ||
+ | </ | ||
+ | This routine continuously checks $D012==0 while saving the last read $D012-value in X and repeats the whole procedure when the value stored in X has the MSB set. This luckily suffices to distinguish the case "last line was $ff" from "last line was the last one of the frame", | ||
+ | |||
+ | Why that [ldx #TAX]? There' |
base/detect_pal_ntsc.txt · Last modified: 2020-11-11 01:49 by copyfault