OpenCores
URL https://opencores.org/ocsvn/openmsp430/openmsp430/trunk

Subversion Repositories openmsp430

[/] [openmsp430/] [trunk/] [fpga/] [actel_m1a3pl_dev_kit/] [software/] [spacewar/] [bzsin.c] - Blame information for rev 80

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 80 olivier.gi
// ************************************************************
2
// global variables
3
//
4
// sine table 0 - 64 binary degrees
5
// rocket size of 128 calculated into table
6
/* Description:
7
Contains byte values for scaled rocket size values for the first quadrent
8
of angles.
9
*/
10
const char sintbl[] = {
11
  0, 3, 6, 9, 12, 15, 18, 21,
12
  24, 28, 31, 34, 37, 40, 43, 46,
13
  48, 51, 54, 57, 60, 63, 65, 68,
14
  71, 73, 76, 78, 81, 83, 85, 88,
15
  90, 92, 94, 96, 98, 100, 102, 104,
16
  106, 108, 109, 111, 112, 114, 115, 117,
17
  118, 119, 120, 121, 122, 123, 124, 124,
18
  125, 126, 126, 127, 127, 127, 127, 127,
19
  128
20
  };
21
 
22
// ************************************************************
23
//
24
//    blitzkrieg sine routine
25
//
26
//    enter angle to be converted
27
//
28
/* Description:
29
Fast lookup table sine routine.  The sine routine uses 256 units for a
30
complete circle.
31
The first  quadrent is 0x00 - 0x3f ->   0 -  89 degrees.
32
The second quadrent is 0x40 - 0x7f ->  90 - 179 degrees.
33
The third  quadrent is 0x80 - 0xbf -> 180 - 269 degrees.
34
The fourth quadrent is 0xc0 - 0xff -> 270 - 359 degrees.
35
This fuction is call as a cosine by adding 64 to the angle to return the x
36
vector part of the rocket size.  This fuction is call as a sine to return the y
37
vector part of the rocket size.
38
*/
39
int bzsin(char angle)
40
{
41
  int sine;
42
 
43
  if(angle & 0x40) angle = angle ^ 0x3F;  // invert angle in second quad
44
  sine = sintbl[angle & 0x3F];            // convert char to int
45
  return (angle & 0x80) ? -sine : sine ;  // change sign for 180 - 360 degrees
46
}
47
 

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.