User Tools

Site Tools


base:detect_pal_ntsc

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revisionBoth sides next revision
base:detect_pal_ntsc [2020-11-10 21:51] – [Short PAL/NTSC detection] copyfaultbase:detect_pal_ntsc [2020-11-10 21:55] – [Source Code] copyfault
Line 853: Line 853:
 <code> <code>
 chk:           chk:          
-              ldx #$aa   //TAX+              ldx #$aa   //$aa = TAX
               lda $d012               lda $d012
               bne chk+1               bne chk+1
Line 861: Line 861:
 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", since the highest possible value is $37 (on PAL). 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", since the highest possible value is $37 (on PAL).
  
-Why that [ldx #TAX]? There's a small probability that the routine starts when we accidently *are* on line $0 (or $100). The [bne chk+1] would not branch, i.e. the check-for-line$0-loop would end promptly, without any backup value stored in X yet. Thus, we need an init value for X that forces the line$0-check to be repeated for this rare case. It could by any value with MSB set, but using $aa (=TAX as opcode) contributes to making the whole routine as short as possbile.+Why that [''ldx #$aa'']? There's a small probability that the routine starts when we accidently **are** on line $0 (or $100). The [''bne chk+1''] would not branch, i.e. the check-for-line$0-loop would end promptly, without any backup value stored in X yet. Thus, we need an init value for X that forces the line$0-check to be repeated in this rare case. It could by any value with MSB set, but using $aa (=TAX as opcode) contributes to making the whole routine as short as possbile.
base/detect_pal_ntsc.txt · Last modified: 2020-11-11 01:49 by copyfault