source: buchla-68k/ram/addfpu.c@ 60288f5

Last change on this file since 60288f5 was 0580615, checked in by Thomas Lopatic <thomas@…>, 7 years ago

Point of no return.

  • Property mode set to 100644
File size: 1.3 KB
Line 
1/*
2 =============================================================================
3 addfpu.c -- FPU time functions
4 Version 1 -- 1987-09-14 -- D.N. Lynx Crowe
5 =============================================================================
6*/
7
8#include "stddefs.h"
9
10#define MAXSEGT 32767
11
12extern unsigned tofpu(unsigned time);
13extern unsigned fromfpu(unsigned fputime);
14
15/*
16
17*/
18
19/*
20 =============================================================================
21 addfpu() -- find next higher FPU time 'k' milliseconds greater than 't'
22 =============================================================================
23*/
24
25unsigned addfpu(unsigned t, short k)
26{
27 register short x, z;
28 register unsigned y;
29
30 x = fromfpu(t);
31
32 if (x EQ MAXSEGT)
33 return(t);
34
35 y = t;
36 z = x + k;
37
38 if (z GE MAXSEGT)
39 return(tofpu(MAXSEGT));
40
41 while ((y EQ t) OR (z > x))
42 y = tofpu(++x);
43
44 return(y);
45}
46
47/*
48
49*/
50
51/*
52 =============================================================================
53 subfpu() -- find next lower FPU time 'k' milliseconds less than 't'
54 =============================================================================
55*/
56
57unsigned subfpu(unsigned t, short k)
58{
59 register short x, z;
60 register unsigned y;
61
62 x = fromfpu(t);
63
64 if (x EQ 1)
65 return(t);
66
67 y = t;
68 z = x - k;
69
70 if (z LE 1)
71 return(tofpu(1));
72
73 while ((y EQ t) OR (z < x))
74 y = tofpu(--x);
75
76 return(y);
77}
Note: See TracBrowser for help on using the repository browser.