SET_DAC_REG proc
	;in:	AL - reg
	;	AH,BL,BH - R,G,B(6bit)
	PUSH AX
	MOV DX,3C8h
	CLI
	OUT DX,AL
	MOV DX,3C9h

	CALL WAIT_DAC_READY
	MOV AL,AH
	OUT DX,AL
	CALL WAIT_DAC_READY
	MOV AL,BL
	OUT DX,AL
	CALL WAIT_DAC_READY
	MOV AL,BH
	OUT DX,AL
	STI
	POP AX
	RET
SET_DAC_REG endp

WAIT_DAC_READY proc
	PUSH SI
	MOV SI,1
	CALL FADE_WAIT
	POP SI
	RET
WAIT_DAC_READY endp

FADE_WAIT proc
	PUSH DX
	PUSH CX
	PUSH BX
	PUSH AX
	MOV CX,SI
F_W1:	MOV DX,100
	MOV BX,1000
	DIV BX
	DIV BX
	DIV BX
	DIV BX
	LOOP F_W1
	POP AX
	POP BX
	POP CX
	POP DX
	RET
FADE_WAIT endp
