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

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

Fix conversion warnings.

  • Property mode set to 100644
File size: 1.2 KB
RevLine 
[f40a309]1/*
2 =============================================================================
3 addfpu.c -- FPU time functions
4 Version 1 -- 1987-09-14 -- D.N. Lynx Crowe
5 =============================================================================
6*/
7
[b28a12e]8#include "ram.h"
[f40a309]9
10#define MAXSEGT 32767
11
12/*
13 =============================================================================
14 addfpu() -- find next higher FPU time 'k' milliseconds greater than 't'
15 =============================================================================
16*/
17
[7258c6a]18uint16_t addfpu(uint16_t t, int16_t k)
[f40a309]19{
[432327d]20 uint16_t x, y;
21 int32_t z;
[f40a309]22
23 x = fromfpu(t);
24
25 if (x EQ MAXSEGT)
26 return(t);
27
28 y = t;
[432327d]29 z = (int32_t)x + k;
[f40a309]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
[7258c6a]46uint16_t subfpu(uint16_t t, int16_t k)
[f40a309]47{
[432327d]48 uint16_t x, y;
49 int32_t z;
[f40a309]50
51 x = fromfpu(t);
52
53 if (x EQ 1)
54 return(t);
55
56 y = t;
[432327d]57 z = (int32_t)x - k;
[f40a309]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}
[6262b5c]67
Note: See TracBrowser for help on using the repository browser.