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

Subversion Repositories openmsp430

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

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 80 olivier.gi
#include "spacewar.h"
2
 
3
//************************************************************
4
// externals
5
//
6
 
7
extern void reset_rkts(rkt_data *, rkt_data *);
8
extern void reset_game(rkt_data *);
9
extern void explode(int, int);
10
extern void rocket1(rkt_data *);
11
extern void rocket2(rkt_data *);
12
extern int bzsin(char);
13
 
14
//************************************************************
15
//
16
// chk_shlds
17
//
18
//    check rockets shields for game end
19
//
20
/* Description:
21
Checks if shields of first rocket structure is zero.  If zero then draws an
22
explosion for the first structure rocket and adds a point to the second
23
structure rocket game score.
24
*/
25
void chk_shlds(rkt_data *rkta, rkt_data *rktb)
26
{
27
 
28
  if(rkta->shield == 0) {             // rkt a dead ?
29
    explode(rkta->xdisp, rkta->ydisp);  // yes - explode
30
    rktb->game++;                     // add one rktb's game total
31
  }
32
}
33
 
34
//************************************************************
35
//
36
// score
37
//
38
//    check for game end, show score
39
//
40
/* Description:
41
Checks if shields of rocket 1 the rocket 2.  Explodes and scores if shields
42
equal zero.  Sets rocket 1 position to top left and rocket 2 to bottom left.
43
Starts displaying the number of games won by rocket pictures.
44
Resets all rocket positions back to inital positions.
45
*/
46
void score(rkt_data *rkt1, rkt_data *rkt2)
47
{
48
  int i, j;
49
 
50
  chk_shlds(rkt1, rkt2);              // rkt1 dead ?
51
  chk_shlds(rkt2, rkt1);              // rkt2 dead ?
52
 
53
  if((rkt1->shield == 0) || (rkt2->shield == 0)) {
54
    reset_rkts(rkt1, rkt2);           // reset rkt positons                        
55
 
56
    rkt1->xsize = 0;
57
    rkt1->ysize = rktsiz;
58
    rkt2->xsize = 0;
59
    rkt2->ysize = rktsiz;
60
 
61
    reset_game(rkt1);
62
    reset_game(rkt2);
63
 
64
    for(i = 0; i < 512; i++) {        // show score
65
      rkt1->xdisp = rktsiz << 2;      // left side of screen
66
      rkt2->xdisp = rktsiz << 2;      // left side of screen
67
 
68
      for(j = 0; j < rkt1->game; j++) {
69
        rocket1(rkt1);
70
        rkt1->xdisp += rktsiz << 1;
71
      }
72
      for(j = 0; j < rkt2->game; j++) {
73
        rocket2(rkt2);
74
        rkt2->xdisp += rktsiz << 1;
75
      }
76
    }
77
    reset_rkts(rkt1, rkt2);           // reset rkt positons                        
78
  }
79
}

powered by: WebSVN 2.1.0

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