A2osX/ProDOS.FX/ProDOS.S.TCLK.txt

126 lines
3.3 KiB
Plaintext
Raw Normal View History

2019-10-16 06:09:13 +00:00
NEW
AUTO 3,1
2019-10-17 20:21:22 +00:00
*--------------------------------------
2019-10-16 06:09:13 +00:00
* Thunderclock driver
* hard coded for slot 1
2019-10-17 20:21:22 +00:00
*--------------------------------------
clkmode .EQ $0538 clock mode
2019-11-06 13:14:42 +00:00
rdtcp .EQ $C108 Thunderclock read entry
wttcp .EQ $C10B Thunderclock write entry
*--------------------------------------
2023-11-04 14:42:28 +00:00
TCLK.START .PH CLK
ldx TCLK.Cx2+2 clock slot = $C1.
2019-10-16 06:09:13 +00:00
lda clkmode,x save current mode
pha
lda #$A3 send numeric mode byte to Thunderclock
TCLK.Cx1 jsr wttcp
TCLK.Cx2 jsr rdtcp read month, day of week, day of month
2019-10-17 20:21:22 +00:00
2019-10-16 06:09:13 +00:00
clc and time into input buffer.
ldx #$04 index for 5 values.
ldy #$0C read minutes 1st, month last.
2019-10-17 20:21:22 +00:00
2023-11-04 14:42:28 +00:00
.1 lda ROM.INBUF,y convert values to binary.
2019-10-16 06:09:13 +00:00
and #$07 no value > 5 decimal.
2023-11-04 14:42:28 +00:00
sta ZP.PCL 'tens' place value
2019-10-16 06:09:13 +00:00
asl multiply by 10
asl
2023-11-04 14:42:28 +00:00
adc ZP.PCL
2019-10-16 06:09:13 +00:00
asl
2023-11-04 14:42:28 +00:00
adc ROM.INBUF+1,y add to ascii 'ones' place
2019-10-16 06:09:13 +00:00
sec and subtract out the ascii
sbc #$B0
2023-11-04 14:42:28 +00:00
sta ZP.PCL,x save converted value.
2019-10-16 06:09:13 +00:00
dey index to next lowest value
dey
dey
dex are there more values?
bpl .1 if yes.
2019-10-17 20:21:22 +00:00
2019-10-16 06:09:13 +00:00
tay contains month
lsr
ror
ror
ror high bit of month held in carry
2023-11-04 14:42:28 +00:00
ora ZP.A1L
sta GP.DATE save low value of date.
2019-10-16 06:09:13 +00:00
php save high bit of month.
and #$1F isolate day.
adc tdays-1,y (y = month)
bcc .2 branch if not Sept 13 thru 30th
2019-10-17 20:21:22 +00:00
2019-10-16 06:09:13 +00:00
adc #$03 adj for mod 7 when day > 256
2019-10-17 20:21:22 +00:00
2019-10-16 06:09:13 +00:00
.2 sec
2019-10-17 20:21:22 +00:00
2019-10-16 06:09:13 +00:00
.3 sbc #$07
bcs .3 loop until < 0.
2019-10-17 20:21:22 +00:00
2019-10-16 06:09:13 +00:00
adc #$07 make it in the range of 0-6.
2023-11-04 14:42:28 +00:00
sbc ZP.PCH the delta provides years offset.
2019-10-16 06:09:13 +00:00
bcs .4 branch if positive
2019-10-17 20:21:22 +00:00
2019-10-16 06:09:13 +00:00
adc #$07 else make it positive again.
2019-10-17 20:21:22 +00:00
2019-10-16 06:09:13 +00:00
.4 tay
lda yradj,y look up year
plp and combine it with hi bit of month
rol
2023-11-04 14:42:28 +00:00
sta GP.DATE+1 P8 date
2019-10-17 20:21:22 +00:00
2023-11-04 14:42:28 +00:00
lda ZP.A1L+1 hour
sta GP.TIME+1 P8 time
lda ZP.A2L minute
sta GP.TIME
2019-10-17 20:21:22 +00:00
2019-10-16 06:09:13 +00:00
pla restore previous mode.
ldx TCLK.Cx2+2 clock slot = $C1
sta clkmode,x
2019-11-06 13:14:42 +00:00
rts
2019-10-16 06:09:13 +00:00
* this table contains entries for the cumulative # of days in a year,
* one entry for each month. the values are modulo 256.
tdays .DA #$00 January
.DA #$1F February
.DA #$3B March
.DA #$5A April
.DA #$78 May
.DA #$97 June
.DA #$B5 July
.DA #$D3 August
.DA #$F2 September
.DA #$14 October (MOD 256)
.DA #$33 November
.DA #$51 December
* the following table is used to look up the current year, based on
* the current month, day and day of week. The 1st entry corresponds
* to the year in which January 1st falls on a Monday. The 2nd entry
* is the year which January 1st is Sunday, and so on backwards thru
* the days of the week.
* https://calormen.com/tmp/proyear.html
* For 2022 - 2027: $18, $17, $16, $1B, $1A, $19, $18
yradj .DA #$18 Monday
2019-10-17 20:21:22 +00:00
.DA #$17 Sunday
.DA #$16 Saturday
.DA #$1B Friday
.DA #$1A Thursday
.DA #$19 Wednesday
.DA #$18 Tuesday
*--------------------------------------
2023-11-04 14:42:28 +00:00
.EP
*--------------------------------------
* .LIST ON
2019-11-01 20:06:04 +00:00
TCLK.LEN .EQ *-TCLK.START
.LIST OFF
2019-10-16 06:09:13 +00:00
*--------------------------------------
MAN
SAVE usr/src/prodos.fx/prodos.s.tclk
LOAD usr/src/prodos.fx/prodos.s
2019-10-16 06:09:13 +00:00
ASM