NEW
  AUTO 3,1
*--------------------------------------
* Driver For ROMXce Clock
*--------------------------------------
* we can safely use $200, PCL/H, AIL/H (used by TCLK)
*--------------------------------------
XCLK.API.RTCBUF	.EQ $2B0
XCLK.API.RDCLK	.EQ $D8F0
*--------------------------------------
XCLK.START		php
				sei
				ldx #XCLK.START2xx.L-1

.1				lda XCLK.START2xx,X
				sta XCLK.CODE2xx,X
				dex
				bpl .1

				jsr XCLK.CODE2xx
* Minutes
				lda XCLK.API.RTCBUF+1
				and #%01111111			59
				jsr XCLK.BCD2BIN
				sta TIMELO
* Hour
				lda XCLK.API.RTCBUF+2
				and #%00111111			23
				jsr XCLK.BCD2BIN
				sta TIMELO+1
* Day
				lda XCLK.API.RTCBUF+4
				and #%00111111			31
				jsr XCLK.BCD2BIN
				sta DATELO
* Year
				lda XCLK.API.RTCBUF+6	99
				jsr XCLK.BCD2BIN
				sta DATELO+1
* Month
				lda XCLK.API.RTCBUF+5
				and #%00011111			12
				jsr XCLK.BCD2BIN
				asl
				asl
				asl
				asl
				asl
				tsb DATELO
				rol DATELO+1

				plp
				rts

XCLK.BCD2BIN	tax
				and #$F0
				lsr						CC
				sta PCL					temp location
				lsr						CC
				lsr						CC
				adc PCL
				sta PCL

				txa
*				clc
				and #$0F
				adc PCL

				rts

XCLK.START2xx	bit RROMBNK2
				sta $C070
				bit $FACA
				bit $FACA
				bit $FAFE
				jsr XCLK.API.RDCLK
				bit $F851
				bit RRAMWRAMBNK1
				bit RRAMWRAMBNK1
				rts

XCLK.START2xx.L	.EQ *-XCLK.START2xx
*--------------------------------------
XCLK.CODE2xx	.EQ XCLK.API.RTCBUF-XCLK.START2xx.L
*--------------------------------------
				.LIST ON
XCLK.LEN		.EQ *-XCLK.START
				.LIST OFF
*--------------------------------------
* CONTROL SECTION :
*--------------------------------------
				.DO XCLK.LEN>125
				ERROR:XCLK Driver too big
				.FIN
*--------------------------------------
MAN
SAVE usr/src/prodos.fx/prodos.s.xclk
LOAD usr/src/prodos.fx/prodos.s
ASM
