Some fix for scrolling with lasso.
[tangerine.git] / rom / timer / subtime.c
blobeb7eda5594d951b85898773f549f43f14625b89b
1 /*
2 Copyright © 1995-2001, The AROS Development Team. All rights reserved.
3 $Id$
5 Desc: SubTime - subtract two timevals from each other.
6 Lang: english
7 */
8 #include "timer_intern.h"
10 /*****************************************************************************
12 NAME */
13 #include <devices/timer.h>
14 #include <proto/timer.h>
16 AROS_LH2(void, SubTime,
18 /* SYNOPSIS */
19 AROS_LHA(struct timeval *, dest, A0),
20 AROS_LHA(struct timeval *, src, A1),
22 /* LOCATION */
23 struct Device *, TimerBase, 8, Timer)
25 /* FUNCTION
26 SubTime() will subtract the src timeval from the destination
27 timeval, ie "dest - src --> dest".
29 INPUTS
30 dest - Destination timeval
31 src - Source timeval
33 RESULT
34 The timeval dest will contain the sum (dest - src).
36 NOTES
37 This function is safe to call from interrupts.
39 EXAMPLE
41 BUGS
42 May not preserve registers.
44 SEE ALSO
45 AddTime(), CmpTime()
47 INTERNALS
49 HISTORY
50 18-02-1997 iaint Implemented.
52 *****************************************************************************/
54 AROS_LIBFUNC_INIT
55 AROS_LIBBASE_EXT_DECL(struct Device *,TimerBase)
57 /* Normalize the terms */
58 while(src->tv_micro > 999999)
60 src->tv_secs++;
61 src->tv_micro -= 1000000;
63 while(dest->tv_micro > 999999)
65 dest->tv_secs++;
66 dest->tv_micro -= 1000000;
69 /* Check if wrap around will happen, when subtracting src->tv_micro
70 from dest->tv_micro. If yes, then normalize, by adding 1 sec to
71 micros and subtracting 1 sec from secs. Note: this check must be
72 done here, ie. before subtracting src timeval from dest timeval! */
74 if(dest->tv_micro < src->tv_micro)
76 dest->tv_micro += 1000000;
77 dest->tv_secs--;
80 dest->tv_micro -= src->tv_micro;
81 dest->tv_secs -= src->tv_secs;
83 AROS_LIBFUNC_EXIT
85 } /* SubTime */