Subversion Repositories shark

Rev

Rev 1448 | Rev 1589 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
1091 pj 1
/*
2
 * Project: S.Ha.R.K.
3
 *
4
 * Coordinators:
5
 *   Giorgio Buttazzo    <giorgio@sssup.it>
6
 *   Paolo Gai           <pj@gandalf.sssup.it>
7
 *
8
 * Authors     :
9
 *   Paolo Gai           <pj@gandalf.sssup.it>
10
 *   Massimiliano Giorgi <massy@gandalf.sssup.it>
11
 *   Luca Abeni          <luca@gandalf.sssup.it>
12
 *   (see the web pages for full authors list)
13
 *
14
 * ReTiS Lab (Scuola Superiore S.Anna - Pisa - Italy)
15
 *
16
 * http://www.sssup.it
17
 * http://retis.sssup.it
18
 * http://shark.sssup.it
19
 */
20
 
1550 pj 21
/* CVS :        $Id: bca.c,v 1.6 2005-01-08 14:34:28 pj Exp $ */
1091 pj 22
 
23
/*
24
 * Copyright (C) 2000 Fabio Calabrese <fabiocalabrese77@yahoo.it>
25
 *
26
 * This program is free software; you can redistribute it and/or modify
27
 * it under the terms of the GNU General Public License as published by
28
 * the Free Software Foundation; either version 2 of the License, or
29
 * (at your option) any later version.
30
 *
31
 * This program is distributed in the hope that it will be useful,
32
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
33
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
34
 * GNU General Public License for more details.
35
 *
36
 * You should have received a copy of the GNU General Public License
37
 * along with this program; if not, write to the Free Software
38
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
39
 *
40
 */
41
 
42
/****************************************************
43
 *                                                  *
44
 *  file:        bca.c                              *
45
 *  header file: bca.h                              *
46
 *  data:        15/09/2002                         *
47
 *  creato da:   Fabio CALABRESE                    *
48
 *                                                  *
49
 ******************************************************
50
 *                                                    *
51
 *  descrizione: e' il file in cui è descritto il task*
52
 *               main del programma S.Ha.R.K.         *
53
 *               "(B)ase(C)ontr(A)rea".               *
54
 *               Il codice del programma comprende    *
55
 *               anche l'implementazione di altri task*
56
 *               distribuiti nei seguenti file che    *
57
 *               quindi sono inclusi:                 *
58
 *                dummy.c                             *
59
 *                control.c                           *
60
 *                aereo.c                             *
61
 *                cannone.c                           *
62
 *                missile.c                           *
63
 *                esplo.c                             *
64
 *               Inoltre è incluso anche il file:     *
65
 *                scenario.c                          *
66
 *               che descrive come disegnare lo       *
67
 *               scenario grafico iniziale            *
68
 *                                                    *
69
 ******************************************************/
70
 
71
 
72
// *** Librerie S.Ha.R.K ***
73
#include <kernel/kern.h>
74
#include <ll/i386/cons.h>
1448 giacomo 75
 
76
#include <drivers/shark_fb26.h>
77
#include <drivers/shark_keyb26.h>
78
 
1091 pj 79
// *** Librerie Standard C ***
80
#include <stdlib.h>
81
// *** Librerie FAB ***
82
#include "fab_lib/fab_msg.h"
83
#include "fab_lib/fab_show.h"
84
#include "fab_lib/fab_tool.h"
85
#include "fab_lib/fab_grx.h"
86
// *** Librerie BCA ***
87
#include "bca.h"
88
 
89
 
90
char * titolo[10];
91
 
92
void   scenario();
93
void   info();
94
#include"scenario.c"
95
 
96
PID   crea_soft_dummy_radar ();
97
TASK  dummy_radar(void *);
98
#include"dummy.c"
99
 
100
PID   crea_soft_control();
101
TASK  control(void *);
102
#include"control.c"
103
 
104
PID   crea_soft_aereo_creator();
105
TASK  aereo_creator();
106
PID   crea_hard_aereo(int index);
107
PID   crea_soft_aereo(int index);
108
TASK  aereo(void * index);
109
#include"aereo.c"
110
 
111
PID   crea_soft_cannone_creator();
112
TASK  cannone_creator();
113
PID   crea_hard_cannone(int index);
114
PID   crea_soft_cannone(int index);
115
TASK  cannone(void * index);
116
#include"cannone.c"
117
 
118
PID   crea_hard_missile();
119
PID   crea_soft_missile();
120
TASK  missile();
121
#include"missile.c"
122
 
123
PID   crea_soft_esplo();
124
TASK  esplo(void *);
125
#include"esplo.c"
126
 
127
void end_fun(KEY_EVT* k)
1448 giacomo 128
{ sys_shutdown_message("Ending...\n");
1550 pj 129
  exit(0);
1091 pj 130
}
131
void incrementa_aerei_fun(KEY_EVT* k)
132
{ if (aereo_count<AEREO_N_MAX) aereo_count++;
133
}
134
void decrementa_aerei_fun(KEY_EVT* k)
135
{ if (aereo_count>AEREO_N_MIN) aereo_count--;
136
}
137
void incrementa_cannoni_fun(KEY_EVT* k)
138
{ if (cannone_count<CANNONE_N_MAX) cannone_count++;
139
}
140
void decrementa_cannoni_fun(KEY_EVT* k)
141
{ if (cannone_count>CANNONE_N_MIN) cannone_count--;
142
}
143
 
144
int main(int argc, char **argv)
145
{
146
    PID pid;
147
 
148
    KEY_EVT k;
149
 
150
    k.flag = 0;
151
    k.scan = KEY_ENT;
152
    k.ascii = 13;
1448 giacomo 153
    k.status = KEY_PRESSED;
154
    keyb_hook(k,end_fun,FALSE);
1091 pj 155
    k.flag  = 0;
156
    k.scan  = KEY_1;
157
    k.ascii = '1';
1448 giacomo 158
    k.status = KEY_PRESSED;
159
    keyb_hook(k,incrementa_aerei_fun,FALSE);
1091 pj 160
    k.flag  = 0;
161
    k.scan  = KEY_2;
162
    k.ascii = '2';
1448 giacomo 163
    k.status = KEY_PRESSED;
164
    keyb_hook(k,decrementa_aerei_fun,FALSE);
1091 pj 165
    k.flag  = 0;
166
    k.scan  = KEY_3;
167
    k.ascii = '3';
1448 giacomo 168
    k.status = KEY_PRESSED;
169
    keyb_hook(k,incrementa_cannoni_fun,FALSE);
1091 pj 170
    k.flag  = 0;
171
    k.scan  = KEY_4;
172
    k.ascii = '4';
1448 giacomo 173
    k.status = KEY_PRESSED;
174
    keyb_hook(k,decrementa_cannoni_fun,FALSE);
1091 pj 175
 
176
    /* inizializza il mutex grafico */
177
    app_mutex_init(&grx_mutex);
178
 
179
    scenario();
180
 
181
   //---init---
182
   srand(sys_gettime(NULL));
183
   aereo_count   = AEREO_N_MIN;
184
   cannone_count = CANNONE_N_MIN;
185
 
186
   pid=crea_soft_dummy_radar();
187
   task_activate(pid);
188
 
189
   pid=crea_soft_aereo_creator();
190
   task_activate(pid);
191
 
192
   pid=crea_soft_cannone_creator();
193
   task_activate(pid);
194
 
195
   pid=crea_soft_control();
196
   task_activate(pid);
197
   //----------
1448 giacomo 198
 
199
   return 0;
200
 
1091 pj 201
}
202
 
203