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

Last change on this file since a3eb131 was 432327d, checked in by Thomas Lopatic <thomas@…>, 7 years ago

Fix conversion warnings.

  • Property mode set to 100644
File size: 1.2 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 "ram.h"
9
10#define MAXSEGT 32767
11
12/*
13 =============================================================================
14 addfpu() -- find next higher FPU time 'k' milliseconds greater than 't'
15 =============================================================================
16*/
17
18uint16_t addfpu(uint16_t t, int16_t k)
19{
20 uint16_t x, y;
21 int32_t z;
22
23 x = fromfpu(t);
24
25 if (x EQ MAXSEGT)
26 return(t);
27
28 y = t;
29 z = (int32_t)x + k;
30
31 if (z GE MAXSEGT)
32 return(tofpu(MAXSEGT));
33
34 while ((y EQ t) OR (z > x))
35 y = tofpu(++x);
36
37 return(y);
38}
39
40/*
41 =============================================================================
42 subfpu() -- find next lower FPU time 'k' milliseconds less than 't'
43 =============================================================================
44*/
45
46uint16_t subfpu(uint16_t t, int16_t k)
47{
48 uint16_t x, y;
49 int32_t z;
50
51 x = fromfpu(t);
52
53 if (x EQ 1)
54 return(t);
55
56 y = t;
57 z = (int32_t)x - k;
58
59 if (z LE 1)
60 return(tofpu(1));
61
62 while ((y EQ t) OR (z < x))
63 y = tofpu(--x);
64
65 return(y);
66}
67
Note: See TracBrowser for help on using the repository browser.