C-64 PAL Colour Mix

This little program demonstrates how the colours output by the PAL VIC-II chip of the C-64 are blended. The blending is done by alternating between two colours on even/odd scanlines.

Binary

Download the C-64 binary here (242 bytes.)

Screenshots

C-64

A real Commodore 64, PAL version. This screenshot is a digital camera photograph of an actual television screen connected to the C-64 using a composite cable.



Note that the result of the blending of two colours differs depending on which of the two colours are on the even and which are on the odd scanlines.

VICE

VICE version 1.16, x64 with double size and PAL emulation.



This time, the result of the blending are the same no matter which colour are on the even and odd scanlines.

Source code

Here's the source code (suitable for the ACME cross assembler.)

;---------------------------------------------------

!to "colmix3.prg"

;---------------------------------------------------

	* = $0801

; Basic header
	!word *+10 : !word 2005
	!byte $9E : !pet "2061" : !byte 0
	!word 0

Start
	lda $DD02	; VIC bank $4000-$7FFF
	ora #$03
	sta $DD02
	lda $DD00
	and #$FC
	ora #$02
	sta $DD00

	lda #$80	; Bitmap at $4000, screen at $6000
	sta $D018

	lda $D011	; Bitmap mode
	ora #$20
	sta $D011

	lda #$00
	sta $D020

	ldx #$00	; Fill bitmap with 00/FF pattern
	ldy #$40
	stx $FD
	sty $FE
	ldx #$20
	ldy #$00
.bmf	lda #$00
	sta ($FD),y
	iny
	lda #$FF
	sta ($FD),y
	iny
	bne .bmf
	inc $FE
	dex
	bne .bmf

	ldx #$00	; Fill screen with 00
	ldy #$60
	stx $FD
	sty $FE
	ldx #$04
	ldy #$00
	lda #$00
.scf	sta ($FD),y
	iny
	bne .scf
	inc $FE
	dex
	bne .scf


	lda #$00	; Create colour boxes
	sta $FB
.scc1	ldx $FB
	lda BoxTabScrLo,x
	sta $FD
	lda BoxTabScrHi,x
	sta $FE
	lda BoxTabColour,x
	ldx #4
.scc2	ldy #3
.scc3	sta ($FD),y
	dey
	bpl .scc3
	pha
	lda $FD
	clc
	adc #$28
	sta $FD
	lda $FE
	adc #$00
	sta $FE
	pla
	dex
	bne .scc2
	inc $FB
	lda $FB
	cmp #28
	bne .scc1

	rts
	
;---------------------------------------------------

;.data

BoxTabColour
	!byte $66,$22,$44,$CC,$55,$33,$77
	!byte $69,$B2,$84,$EC,$A5,$F3,$D7
	!byte $96,$2B,$48,$CE,$5A,$3F,$7D
	!byte $99,$BB,$88,$EE,$AA,$FF,$DD

BoxTabScrLo
	!byte $7B,$80,$85,$8A,$8F,$94,$99
	!byte $43,$48,$4D,$52,$57,$5C,$61
	!byte $0B,$10,$15,$1A,$1F,$24,$29
	!byte $D3,$D8,$DD,$E2,$E7,$EC,$F1

BoxTabScrHi
	!byte $60,$60,$60,$60,$60,$60,$60
	!byte $61,$61,$61,$61,$61,$61,$61
	!byte $62,$62,$62,$62,$62,$62,$62
	!byte $62,$62,$62,$62,$62,$62,$62

;---------------------------------------------------