; vga library for pmode 1
; 
; ****************************************************************
; * vgapalette(border,a,b,c,d)
; ****************************************************************
; this sets up 4 colors for your palette including border color
; color format 1rrrrrbbbbbggggg bits for each color setting.... use word values
FUNCTION	VGAPALETTE	BORDER,COLA,COLB,COLC,COLD
REM	; vgapalette(border,colora,colorb,colorc,colord)
REM	; change color pallete  1rrrrrgggggbbbbb use word values
DEF	BORDER	WORD
DEF	COLA	WORD
DEF	COLB	WORD
DEF	COLC	WORD
DEF	COLD	WORD
BORDER	FDB	0
COLA	FDB	0
COLB	FDB	0
COLC	FDB	0
COLD	FDB	0
VGAPALETTE	LDA	$FF02
	LDA	$FF03
	ANDA	#252
	ORA	#1
	STA	$FF03
	LDA	$FF02
IVGA	LDA	$FF03
	BPL	IVGA
	LDA	$FF02
; **********************************************
; * fiddle 512 byte *regs*
; **********************************************
	LDA	#$3E	;change palette
	STA	$401
	LDA	#$00
	STA	$400
	STA	$402
	STA	$403
	STA	$406
	STA	$407
	LDA	#$0B	;kill	
	STA	$405	;extras - border/STATUS OVERRIDE
	LDA	#$00	;no vg6
	STA	$408
; colors
	LDD	BORDER
	STD	$484	;bg border color
	LDD	COLA
	STD	$422	;normally green
	STD	$42A	;normally white
	LDD	COLB
	STD	$424	;normally yellow
	STD	$42C	;normally cyan
	LDD	COLC
	STD	$426	;normally blue
	STD	$42E	;normally megenta
	LDD	COLD
	STD	$428	;normally red
	STD	$430	;normally orange
; 
; *
; **********************************************
; *
	LDA   	#$90  	SET COMBO LOCK 1
	STA  	$FF22  	WRITE TO PIA
	LDA   	#$48  	SET COMBO LOCK 2
	STA  	$FF22  	WRITE TO PIA
	LDA   	#$A0  	SET COMBO LOCK 3
	STA  	$FF22  	WRITE TO PIA
	LDA   	#$F8  	SET COMBO LOCK 4
	STA  	$FF22  	WRITE TO PIA
	LDA	#0
	STA	$FF22
WVS2	LDA	$FF03
	BPL	WVS2
	LDA	$FF02
;	LDA	#$E0
;	STA	$FF22	
;	STA	$FFC3
;	STA	$FFC5	;cg6
	RTS
ENDFUNCTION
