Skip to content

NTSC/PAL/U64/SCPU Detection

cpudetect  	lda $d012
cpu1  	cmp $d012
    	beq cpu1
    	bmi cpudetect
	
	cmp #$37
	beq paldetected
		
	lda $d0bc
	and #%10000000 ;bit 7 is enabled on stock c64
	cmp #$00	   ;so 0 is SCPU
	beq scpudetected
	
	lda $d030
	cmp #$ff
	bne u64detected
	
	lda #$01		;NTSC detected
	sta cputype
	jmp cpux
	
u64detected
	lda #$02
	sta cputype
	lda #15
	sta $d031 ;set CPU to 48MHz
	jmp cpux
	
scpudetected lda #$03
	sta cputype
	sta $d07b 	;set 20mhz mode on SCPU
	jmp cpux
	
paldetected
	lda #$00
	sta cputype

cpux	rts

cputype	.byte $ff ;0 PAL, 1 NTSC, 2 Ultimate64, 3 SCPU