Subversion Repositories shark

Rev

Rev 1591 | 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
 
1592 tullio 21
/* CVS :        $Id: bca.c,v 1.10 2006-07-03 15:30:11 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
 *                                                    *
55
 ******************************************************/
56
 
57
 
58
// *** Librerie S.Ha.R.K ***
59
#include <kernel/kern.h>
60
#include <ll/i386/cons.h>
1448 giacomo 61
 
62
#include <drivers/shark_fb26.h>
63
#include <drivers/shark_keyb26.h>
64
 
1591 tullio 65
// *** Standard C library ***
1091 pj 66
#include <stdlib.h>
1591 tullio 67
 
68
// *** FAB library ***
1091 pj 69
#include "fab_lib/fab_msg.h"
70
#include "fab_lib/fab_show.h"
71
#include "fab_lib/fab_tool.h"
72
#include "fab_lib/fab_grx.h"
1591 tullio 73
 
74
// *** BCA library ***
1091 pj 75
#include "bca.h"
76
 
1591 tullio 77
void end_fun(KEY_EVT* k) {
78
        sys_shutdown_message("Ending...\n");
79
        exit(0);
1091 pj 80
}
1591 tullio 81
 
82
void inc_planes(KEY_EVT* k) {
83
        if (aereo_count < AEREO_N_MAX) aereo_count++;
1091 pj 84
}
1591 tullio 85
 
86
void dec_planes(KEY_EVT* k) {
87
        if (aereo_count > AEREO_N_MIN) aereo_count--;
1091 pj 88
}
1591 tullio 89
 
90
void inc_cannon(KEY_EVT* k) {
91
        if (cannone_count < CANNONE_N_MAX) cannone_count++;
1091 pj 92
}
1591 tullio 93
 
94
void dec_cannon(KEY_EVT* k) {
95
        if (cannone_count > CANNONE_N_MIN) cannone_count--;
1091 pj 96
}
97
 
1591 tullio 98
int main(int argc, char **argv) {
99
        PID pid_dummy_radar, pid_aereo_creator, pid_cannone_creator, pid_control;
1091 pj 100
 
1591 tullio 101
        KEY_EVT k;
1091 pj 102
 
1591 tullio 103
        k.flag = CNTL_BIT;
104
        k.scan = KEY_C;
105
        k.ascii = 'c';
106
        k.status = KEY_PRESSED;
107
        keyb_hook(k, end_fun, FALSE);
1589 tullio 108
 
1591 tullio 109
        k.flag = CNTR_BIT;
110
        k.status = KEY_PRESSED;
111
        keyb_hook(k, end_fun, FALSE);
112
 
113
        k.flag  = 0;
114
        k.scan  = KEY_1;
115
        k.ascii = '1';
116
        k.status = KEY_PRESSED;
117
        keyb_hook(k, inc_planes, FALSE);
118
 
119
        k.flag  = 0;
120
        k.scan  = KEY_2;
121
        k.ascii = '2';
122
        k.status = KEY_PRESSED;
123
        keyb_hook(k, dec_planes, FALSE);
124
 
125
        k.flag  = 0;
126
        k.scan  = KEY_3;
127
        k.ascii = '3';
128
        k.status = KEY_PRESSED;
129
        keyb_hook(k, inc_cannon, FALSE);
130
 
131
        k.flag  = 0;
132
        k.scan  = KEY_4;
133
        k.ascii = '4';
134
        k.status = KEY_PRESSED;
135
        keyb_hook(k, dec_cannon, FALSE);
1091 pj 136
 
1591 tullio 137
        /* inizializza il mutex grafico */
138
        app_mutex_init(&grx_mutex);
1091 pj 139
 
1591 tullio 140
        scenario();
1091 pj 141
 
1591 tullio 142
        //---init---
143
        srand(sys_gettime(NULL));
144
        aereo_count   = AEREO_N_MIN;
145
        cannone_count = CANNONE_N_MIN;
1091 pj 146
 
1591 tullio 147
        pid_dummy_radar = crea_soft_dummy_radar();
148
        if (pid_dummy_radar == -1) {
149
                sys_shutdown_message("bca.c(main): could not create task <dummy_radar>");
150
                exit(1);
151
        }
152
        task_activate(pid_dummy_radar);
1091 pj 153
 
1591 tullio 154
        pid_aereo_creator = crea_soft_aereo_creator();
155
        if (pid_aereo_creator == -1) {
156
                sys_shutdown_message("bca.c(main): could not create task <aereo_creator>");
157
                exit(1);
158
        }
159
        task_activate(pid_aereo_creator);
1091 pj 160
 
1591 tullio 161
        pid_cannone_creator = crea_soft_cannone_creator();
162
        if (pid_cannone_creator == -1) {
163
                sys_shutdown_message("bca.c(main): could not create task <cannone_creator>");
164
                exit(1);
165
        }
166
        task_activate(pid_cannone_creator);
1091 pj 167
 
1591 tullio 168
        pid_control = crea_soft_control();
169
        if (pid_control == -1) {
170
                sys_shutdown_message("bca.c(main): could not create task <control>");
171
                exit(1);
172
        }
173
        task_activate(pid_control);
174
        //----------
1448 giacomo 175
 
1591 tullio 176
        return 0;
1091 pj 177
}
178
 
179