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

Subversion Repositories openmsp430

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

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 80 olivier.gi
#include "spacewar.h"
2
 
3
//************************************************************
4
// externals
5
//
6
extern volatile int xinit, yinit;
7
 
8
extern void cline(int, int);
9
void set_xy(int, int);
10
extern void point(rkt_data *);
11
 
12
//************************************************************
13
//
14
// rkt2
15
//
16
//    draws rocket # 2
17
//
18
// pa_x = xd2 + xs2
19
// pa_y = yd2 + ys2
20
// pb_x = xd2 - xs2
21
// pb_y = yd2 - ys2
22
// pc_x = xd2 - xs2/2
23
// pc_y = yd2 - ys2/2
24
// pd_x = (xd2 - xs2) - ys2/2
25
// pd_y = (yd2 - ys2) + xs2/2
26
// pf_x = (xd2 - xs2) + ys2/2
27
// pf_y = (yd2 - ys2) - xs2/2
28
//
29
/* Description:
30
Draws rocket 2 made of five lines.  This rocket looks like an arrowhead
31
Also draws rocket 2 torpedos as points. On exit leaves the DAC parked at the
32
center of the screen.
33
*/
34
void rocket2(rkt_data *rkt2)
35
{
36
int tmp_x, tmp_y;
37
int half_xs2, half_ys2;
38
 
39
  tmp_x = rkt2->xdisp - rkt2->xsize;    // pb_x = xd2 - xs2
40
  tmp_y = rkt2->ydisp - rkt2->ysize;    // pb_y = yd2 - ys2
41
 
42
  half_xs2 = rkt2->xsize >> 1;          // xs2/2
43
  half_ys2 = rkt2->ysize >> 1;          // ys2/2
44
 
45
  xinit = tmp_x;                        // start pb_x
46
  yinit = tmp_y;                        // start pb_y
47
  cline(rkt2->xdisp + rkt2->xsize, rkt2->ydisp + rkt2->ysize);  // draw line #1 b->a
48
  cline(tmp_x + half_ys2, tmp_y - half_xs2); // draw line #2 a->f
49
  cline(rkt2->xdisp - half_xs2, rkt2->ydisp - half_ys2); // draw line #3 f->c
50
  cline(tmp_x - half_ys2, tmp_y + half_xs2); // draw line #4 c->d
51
  cline(rkt2->xdisp + rkt2->xsize, rkt2->ydisp + rkt2->ysize); // draw line #5 d->a
52
 
53
  point(rkt2);                          // update and draw rkt2's torpedoes
54
  set_xy(center, center);               // park dot at center of screen
55
}

powered by: WebSVN 2.1.0

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