File: general.C

package info (click to toggle)
battleball 2.0-13
  • links: PTS
  • area: main
  • in suites: woody
  • size: 1,016 kB
  • ctags: 3,097
  • sloc: cpp: 15,310; makefile: 48; csh: 34
file content (37 lines) | stat: -rw-r--r-- 965 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
// Copyright (c) 1997 Philip A. Hardin (pahardin@cs.utexas.edu)
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License v2 or later.


#include <math.h>
#include <sys/time.h>      // to get select()
//#include <sys/select.h>  // to get select() on some other systems
#include "general.h"
#include "ang2d.h"

const ang2d MA_PI= 1024;   // PI, in machine angles, min. 512


/************************************************************************/
double *sinTbl, *cosTbl;

void InitFixed() {
  // the following never gets freed, but who cares?
  sinTbl= new double[2*MA_PI +MA_PI/2];
  cosTbl= sinTbl +MA_PI/2;
  forii(2*MA_PI +MA_PI/2)
    sinTbl[i]= sin(i*M_PI/MA_PI);
}

void SleepFor(int val)
{ struct timeval tv2;
  fd_set * const no_fd = 0;
  tv2.tv_sec=0;
  tv2.tv_usec=val;
  select(0,no_fd,no_fd,no_fd,&tv2);
}

//char *str_dup(char *s)
//{ return strcpy(malloc(strlen(s)+1),s);
//}