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

Subversion Repositories openmsp430

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

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 80 olivier.gi
#include <stdlib.h>
2
#include "spacewar.h"
3
 
4
//************************************************************
5
// externals
6
//
7
extern volatile int xinit, yinit;
8
 
9
extern void set_xy(int, int);
10
 
11
// ************************************************************
12
//
13
// cline
14
//
15
//  continue line draw
16
//
17
/* Description:
18
Draws short lines based on fixed size increments so longer lines have more
19
points.  First calculates the delta x and delta y.  Finds the larger.  Scales
20
the larger by dividing by 2 until delta is less that fixed_inc.  Scales the
21
other increment at the same time.  Also generates the loop counter for # of
22
increments to draw the line.  Finally the function draws the line with points.
23
*/
24
void cline(int xfin, int yfin)
25
{
26
int delta_x, delta_y, delta_adj;
27
int i = 1;
28
 
29
  delta_x = (xfin - xinit);
30
  delta_y = (yfin - yinit);
31
  // find larger delta_x or delta_y - use the larger to scale
32
  delta_adj = (abs(delta_y) <= abs(delta_x)) ? abs(delta_x) : abs(delta_y);
33
 
34
  // calc the delta inc
35
  while(fixed_inc < delta_adj) {
36
    i += i; ;                     // double loop counter
37
    delta_x = delta_x >> 1;       // 1/2 inc size x
38
    delta_y = delta_y >> 1;       // 1/2 inc size y
39
    delta_adj = delta_adj >> 1;
40
  }
41
 
42
  // draw the line with dots
43
  while(i--) {
44
    set_xy(xinit, yinit);         // move dot 
45
    xinit += delta_x;
46
    yinit += delta_y;
47
  }
48
}
49
 

powered by: WebSVN 2.1.0

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