NEW
  AUTO 3,1
*--------------------------------------
* Driver For DS1215
*--------------------------------------
* we can safely use $200 (used by TCLK)
*--------------------------------------
DS1215.DATA		.EQ $200				Reverted YY MM DD Day HH mm SS CS
*--------------------------------------
DCLK.START		php
				sei

				lda $C400
				
				stz $C0C0
				stz $C0C1

				ldy #8
				stz $C0C2

				lda $C0C3
				pha

.1				lda DS1215.SIG-1,y

				ldx #8
				
.2				sta $C0C3
				stz $C0C0
				
				lsr
				dex
				bne .2

				dey
				bne .1

				ldx #8

.4				ldy #8

.5				pha
				lda $C0C3

				lsr
				pla
				ror

				dey
				bne .5

				pha
				lsr
				lsr
				lsr
				lsr
				tay
				pla
				and #$0F

				clc

				.HS	2C					Bit Absolute to skip adc #$0A

.6				adc #$0A
				dey
				bpl .6

				sta DS1215.DATA-1,x
				dex
				bne .4

				pha						DS1215.DATA

				lda	DS1215.DATA+1		Get MM
				asl
				asl
				asl
				asl
				asl
				ora	DS1215.DATA+2		Get DD
				sta	DATELO

*				lda	DS1215.DATA			Get YY
				
				pla
				rol
				sta	DATELO+1

				lda	DS1215.DATA+5		Get mm
				sta	TIMELO

				lda	DS1215.DATA+4		Get HH
				sta	TIMELO+1

				stz $C0C0

				pla
				sta $C0C3

				plp
				rts
*--------------------------------------
DS1215.SIG		.HS	5CA33AC55CA33AC5	Reverted 7->0
*--------------------------------------
				.LIST ON
DCLK.LEN		.EQ *-DCLK.START
				.LIST OFF
*--------------------------------------
* CONTROL SECTION :
*--------------------------------------
				.DO DCLK.LEN>125
				ERROR:NCLK Driver too big
				.FIN
*--------------------------------------
MAN
SAVE usr/src/prodos.fx/prodos.s.dclk
LOAD usr/src/prodos.fx/prodos.s
ASM
