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 [2017-01-02 21:33] – [Detect PAL/NTSC] moloch | base:detect_pal_ntsc [2020-11-10 21:51] – [Short PAL/NTSC detection] copyfault | ||
---|---|---|---|
Line 1: | Line 1: | ||
====== Detect NTSC/PAL ====== | ====== Detect NTSC/PAL ====== | ||
- | 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, | + | 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 to distinguish between the different PAL-variants (PAL N as used in the Drean-systems and EU-PAL) since they 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