many tardis enhancements

This commit is contained in:
mgcaret 2017-11-04 00:07:45 -07:00
parent e152cb1180
commit c01080d4f2

134
tardis.s
View File

@ -2,13 +2,14 @@
; tardis - Get date/time from TimeLord server.
;
; options:
; -v Verbose mode, prints server info.
; -v Verbose mode, prints server info
; -n <nbp-name> Specify NBP query, default =:TimeLord@*
; -p Set ProDOS global page date/time.
; -p Set ProDOS global page date/time
; -y Patch ProDOS year table to use returned year
; -s <type> Set a clock of <type>, current supported
; types: none.
; -e <hours> Adjust time eastward.
; -w <hours> Adjust time westward.
; types: none
; -e <hours> Adjust time eastward
; -w <hours> Adjust time westward
; %hend
.pc02
@ -21,11 +22,13 @@ NBPBuf = filebuff3 ; buffer for NBP request
NBPBufSz = $0400 ; size of the file buffer
P8DtTm = $bf90
prbyte = $fdda
sptr = xczpage
sptr2 = sptr+2
stemp = sptr2+2
verbose = stemp+1 ; verbose flag
seconds = verbose+1 ; holds seconds
DX_start dx_mg_auto_origin ; load address
DX_info $02,$12,dx_cc_iie_or_iigs,$00
@ -34,6 +37,7 @@ verbose = stemp+1 ; verbose flag
DX_parm 'n',t_string ; name
DX_parm 'z',t_string ; zone
DX_parm 'p',t_nil ; set prodos time
DX_parm 'y',t_nil ; patch year table
DX_parm 's',t_string ; set clock
DX_parm 'e',t_int1 ; east adjust
DX_parm 'w',t_int1 ; west adjust
@ -146,6 +150,20 @@ exiterr1: jmp exiterr
ATcall ATPparms
bcc :+
jmp notime ; if error, bail now
; see if verbose
: lda #'v'|$80
jsr xgetparm_ch
bcs :++ ; skip if not verbose
; display raw time in hex in little-endian format
ldx #$03
: lda To,x
phx
jsr prbyte
plx
dex
bpl :-
lda #$8d
jsr cout
; now do big-endian subtraction of the base offset
; and simultaneously put the computed value in From
: sec
@ -188,7 +206,66 @@ ckwest: lda #'w'|$80
bne :--
; Use the WS card to convert value in From to ProDOS format in To
convert: ATcall CvtParms
bcs notime ; bail if error
bcs notime1 ; bail if error
ATcall ResetSec ; sigh... weird firmware
bcs notime1
; calculate seconds
; Copy converted values to the other convert parm list
ldx #$03
: lda To,x
sta SecFrom,x
dex
bpl :-
inc CvtDir
ATcall CvtParms
; call Convert again the other direction
ATcall SecParms
bcc :+
notime1: jmp notime ; bail if error
; value in SecTo is less than or equal to From and no more than 59
; secs different
: lda From+3
sec
sbc SecTo+3
sta seconds
; set Prodos date/time if asked
lda #'p'|$80 ; set prodos date/time?
jsr xgetparm_ch
bcs nosetp8 ; skip if -p not given
; Copy converted values to the global page
ldx #$03
: lda To,x
sta P8DtTm,x
dex
bpl :-
; patch year table?
nosetp8: lda #'y'|$80
jsr xgetparm_ch
bcs nosetyt
lda $c08b
lda $c08b
ldx #$03
: lda $d7b4,x ; tdays table, at september
cmp tdaysv,x ; that what ProDOS has?
bne setyterr ; not the thunderclock driver
dex
bpl :-
lda To+1 ; year (b7-1), upper bit of month (b0)
lsr
ldx #6
: sta $d7b8,x ; address of year table
dex
bpl :-
bit $c082 ; ROM back
bra nosetyt
setyterr: bit $c082 ; ROM back
lda #$01
jsr xredirect
jsr xmess
asc_hi "Can't patch clock driver!"
.byte $00
bra exiterr
nosetyt: ; TODO: set NSC or ThunderClock or something
; Display date/time
ldy To
lda To+1
@ -200,18 +277,19 @@ convert: ATcall CvtParms
lda To+3
jsr xpr_time_ay
jsr xmess
asc_hi " +"
.byte $00
ldy seconds
cpy #10
bcs :+
lda #'0'|$80
jsr cout ; leading zero
: ldy seconds
lda #$00 ; zero high byte
jsr xprdec_2 ; print seconds
jsr xmess
.byte "s"
.byte $8d,$00
; set Prodos date/time if asked
lda #'p'|$80 ; set prodos date/time?
jsr xgetparm_ch
bcs nosetp8 ; skip if -p not given
; Copy converted values to the global page
ldx #$03
: lda To,x
sta P8DtTm,x
dex
bpl :-
nosetp8: ; TODO: set NSC or ThunderClock or something
rts
notime: lda #$01
jsr xredirect
@ -462,6 +540,9 @@ next: lda #$01
rts
.endproc
;
; table to validate the P8 tclock driver, 4 bytes at $d7b4
tdaysv: .byte 242,20,51,81
;
inforeq: .byte 0,2 ; sync GetInfo
.word $0000 ; result code
.dword $00000000 ; completion address
@ -512,12 +593,25 @@ BDS: .word $000c ; 12-byte buffer for full response from TimeLord
.dword From ; Buffer pointer
Status: .dword $00000000 ; returned user bytes, first byte = 12 if OK
.word $0000 ; actual length
; Convert time paraameters
; Convert time parameters - P8 to network for calculating seconds
SecParms: .byte 0,$34 ; sync ConvertTime
.word $0000 ; result
.byte $01 ; 1 = ProDOS to AFP
SecFrom: .dword $00000000
SecTo: .dword $00000000
; Convert time to reset seconds to 0 because the firmware saves the seconds
; and reuses it when converting from P8 to network time.
ResetSec: .byte 0,$34 ; sync ConvertTime
.word $0000 ; result
.byte $00 ; 0 = from AFP to ProDOS, 1 = reverse
.dword $00000000 ; BIG ENDIAN, Jan 1, 2000 12:00 AM GMT
.dword $00000000 ; P8 Time
; Convert time parameters - network to P8
; note that ATP response is written to From
CvtParms: .byte 0,$34 ; sync ConvertTime
.word $0000 ; result
.byte $00 ; 0 = from AFP to ProDOS, 1 = reverse
CvtDir: .byte $00 ; 0 = from AFP to ProDOS, 1 = reverse
From: .dword $00000000 ;
To: .dword $00000000 ; initially contains time from ATP response
.res 4 ; fill out remaining part of buffer
.res 4 ; fill out remaining part of ATP buffer
DX_end