Subversion Repositories shark

Rev

Rev 1589 | Rev 1591 | 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
 
1590 tullio 21
/* CVS :        $Id: bca.c,v 1.8 2006-07-03 15:10:15 tullio 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
void end_fun(KEY_EVT* k)
1448 giacomo 90
{ sys_shutdown_message("Ending...\n");
1550 pj 91
  exit(0);
1091 pj 92
}
93
void incrementa_aerei_fun(KEY_EVT* k)
94
{ if (aereo_count<AEREO_N_MAX) aereo_count++;
95
}
96
void decrementa_aerei_fun(KEY_EVT* k)
97
{ if (aereo_count>AEREO_N_MIN) aereo_count--;
98
}
99
void incrementa_cannoni_fun(KEY_EVT* k)
100
{ if (cannone_count<CANNONE_N_MAX) cannone_count++;
101
}
102
void decrementa_cannoni_fun(KEY_EVT* k)
103
{ if (cannone_count>CANNONE_N_MIN) cannone_count--;
104
}
105
 
106
int main(int argc, char **argv)
107
{
108
    PID pid;
109
 
110
    KEY_EVT k;
111
 
1589 tullio 112
    k.flag = CNTL_BIT;
113
    k.scan = KEY_C;
114
    k.ascii = 'c';
1448 giacomo 115
    k.status = KEY_PRESSED;
116
    keyb_hook(k,end_fun,FALSE);
1589 tullio 117
 
118
    k.flag = CNTR_BIT;
119
    k.status = KEY_PRESSED;
120
    keyb_hook(k,end_fun,FALSE);
1091 pj 121
    k.flag  = 0;
122
    k.scan  = KEY_1;
123
    k.ascii = '1';
1448 giacomo 124
    k.status = KEY_PRESSED;
125
    keyb_hook(k,incrementa_aerei_fun,FALSE);
1091 pj 126
    k.flag  = 0;
127
    k.scan  = KEY_2;
128
    k.ascii = '2';
1448 giacomo 129
    k.status = KEY_PRESSED;
130
    keyb_hook(k,decrementa_aerei_fun,FALSE);
1091 pj 131
    k.flag  = 0;
132
    k.scan  = KEY_3;
133
    k.ascii = '3';
1448 giacomo 134
    k.status = KEY_PRESSED;
135
    keyb_hook(k,incrementa_cannoni_fun,FALSE);
1091 pj 136
    k.flag  = 0;
137
    k.scan  = KEY_4;
138
    k.ascii = '4';
1448 giacomo 139
    k.status = KEY_PRESSED;
140
    keyb_hook(k,decrementa_cannoni_fun,FALSE);
1091 pj 141
 
142
    /* inizializza il mutex grafico */
143
    app_mutex_init(&grx_mutex);
144
 
145
    scenario();
146
 
147
   //---init---
148
   srand(sys_gettime(NULL));
149
   aereo_count   = AEREO_N_MIN;
150
   cannone_count = CANNONE_N_MIN;
151
 
152
   pid=crea_soft_dummy_radar();
153
   task_activate(pid);
154
 
155
   pid=crea_soft_aereo_creator();
156
   task_activate(pid);
157
 
158
   pid=crea_soft_cannone_creator();
159
   task_activate(pid);
160
 
161
   pid=crea_soft_control();
162
   task_activate(pid);
163
   //----------
1448 giacomo 164
 
165
   return 0;
166
 
1091 pj 167
}
168
 
169