Very good. There is just one disadvantage: you need an RTC and at least OS2.0(?) for battclock.resource.
Maybe it also works without RTC, by remembering the system time and resetting the TOD to zero at the beginning of your program. At the end you will set the system time to the saved timeval + the new TOD count. As long as your code doesn't mess with the TOD, and as long as the OS and the interrupts are disabled, I see no reason why that shouldn't work.
At the start of your program, get SysTime and reset TOD:
Code:
; a6 = TimerDevice
lea timval,a0
jsr -66(a6) ; GetSysTime
; disable interrupts, take over system
; ...
; reset TOD
lea $bfe001,a0 ; CIA-A
moveq #0,d0
move.b d0,$a00(a0) ; TODHI
move.b d0,$900(a0) ; TODMID
move.b d0,$800(a0) ; TODLO
At the end of your program, use the TOD to set the new SysTime:
Code:
lea $bfe001,a0
moveq #0,d0
move.b $a00(a0),d0 ; TODHI
lsl.w #8,d0
move.b $900(a0),d0 ; TODMID
lsl.l #8,d0
move.b $800(a0),d0 ; TODLO
; restore system, enable interrupts
; ...
; a6 = TimerDevice
; d0 = TOD count since start
lea timeval,a0
add.l TV_MICRO(a0),d0
divu TD_TODHERTZ(a6),d0
move.l d0,d1
ext.l d0
add.l d0,TV_SECS(a0)
swap d1
ext.l d1
move.l d1,TV_MICRO(a0)
; set system time, pass timeval to TR_SETSYSTIME
; ...