Subversion Repositories shark

Rev

Rev 1448 | 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
 
1593 tullio 21
/* CVS :        $Id: bca_lib.c,v 1.5 2006-07-03 15:34:08 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_LIB.c                          *
45
 *  libreria:    BCA_LIB                            *
46
 *  creato da:   Fabio CALABRESE                    *
47
 *                                                  *
48
 ****************************************************/
49
 
50
#ifndef __BCA_LIB_c__
51
#define __BCA_LIB_c__
52
//-------------------BEGIN---------------------------
53
 
54
// *** Librerie S.Ha.R.K ***
55
#include<kernel/kern.h>
1448 giacomo 56
 
57
#include<drivers/shark_fb26.h>
58
 
1091 pj 59
// *** Librerie Standard C ***
60
// *** Librerie FAB ***
61
#include"fab_lib/fab_msg.h"
62
// *** Librerie BCA ***
63
#include"bca.h"
64
 
1117 pj 65
char * titolo[10]={" UNIVERSITA' DEGLI \0",
1091 pj 66
                          "     STUDI DI      \0",
67
                          "       PAVIA       \0",
1593 tullio 68
                          " S.Ha.R.K project  \0",
1091 pj 69
                          "  'BaseContrAerea' \0",
70
                          "-------------------\0",
71
                          "    PAVIA  2002    \0",
72
                          "by Fabio CALABRESE \0",
73
                          "<fabiocalabrese77  \0",
74
                          "         @yahoo.it>\0"};
75
 
76
void kern_alloc_images(); // richiede DISABLED_INTERUPTS
77
void kern_free_images();  // richiede DISABLED_INTERUPTS
78
void kern_load_images();  // solo in __kernel_register_levels__()
79
 
80
void kern_alloc_borders(); // richiede DISABLED_INTERUPTS
81
void kern_free_borders();  // richiede DISABLED_INTERUPTS
82
void kern_set_border();    // consigliato in __kernel_register-levels__()
83
 
84
void kern_alloc_frames(); // richiede DISABLED_INTERUPTS
85
void kern_free_frames();  // richiede DISABLED_INTERUPTS
86
void kern_set_frames();    // consigliato in __kernel_register-levels__()
87
 
88
void kern_alloc_ballframes(); // richiede DISABLED_INTERUPTS
89
void kern_free_ballframes();  // richiede DISABLED_INTERUPTS
90
void kern_set_ballframes();    // consigliato in __kernel_register-levels__()
91
 
92
void kern_alloc_task_tables(); // richiede DISABLED_INTERUPTS
93
void kern_free_task_tables();  // richiede DISABLED_INTERUPTS
94
void kern_set_task_tables();    // consigliato in __kernel_register-levels__()
95
 
96
void kern_alloc_task_tables()
97
{
98
  int test=0,j;
99
 
100
  FAB_print("TASKS'TABLES","allocazione...");
101
  for (j=0; j<AEREO_N_MAX; j++) {
102
     aereo_table[j].image=FAB_image_alloc(AEREO_LX,AEREO_LY);
103
     if(aereo_table[j].image==NULL) test=1;
104
     }
1448 giacomo 105
  FAB_msg(test,"fatto","almeno un elemento della tabella non allocato");
1091 pj 106
}
107
void kern_free_task_tables()
108
{ int j;
109
 
110
  for (j=0; j<AEREO_N_MAX; j++) {
111
     FAB_image_free(aereo_table[j].image);
112
     }
113
}
114
void kern_set_task_tables()
115
{ int j;
116
 
117
  FAB_print(NULL,"settaggio...");
118
  for (j=0; j<AEREO_N_MAX; j++) {
119
     aereo_table[j].status  = 0;
120
     aereo_table[j].killing = 0;
121
     aereo_table[j].image->trasparent     = 1;
122
     aereo_table[j].image->trasparent_col = AEREO_TRASPARENT_COL;
123
     }
124
 
125
  FAB_print(NULL,"fatto");
126
}
127
 
128
 
129
void kern_alloc_ballframes()
130
{
131
  int test=0,j;
132
 
133
  FAB_print("FAB_BALLFRAMEs","allocazione...");
134
  ballframe_radar = FAB_ballframe_alloc();
135
  if (ballframe_radar==NULL) test=1;
136
  for (j=0; j<3; j++) {
137
    ballframe_lucerossa[j] = FAB_ballframe_alloc();
138
    if (ballframe_lucerossa[j]==NULL) test=1;
139
    }
1448 giacomo 140
  FAB_msg(test,"fatto","almeno un ballframe non allocato");
1091 pj 141
}
142
void kern_free_ballframes()
143
{ int j;
144
 
145
  FAB_ballframe_free(ballframe_radar);
146
  for (j=0; j<3; j++)
147
    FAB_ballframe_free(ballframe_lucerossa[j]);
148
}
149
void kern_set_ballframes()
150
{ int j;
151
 
152
  FAB_print(NULL,"settaggio...");
153
  FAB_ballframe_border_set(ballframe_radar,border_verde7,7,
154
                           FRAME_MISURE_LINE_COLOR);
155
  FAB_ballframe_color_set(ballframe_radar,0,FAB_blue);
156
  for(j=0; j<3; j++) {
157
    FAB_ballframe_border_set(ballframe_lucerossa[j],border_verde7,7,
158
                             FRAME_MISURE_LINE_COLOR);
159
    FAB_ballframe_color_set(ballframe_lucerossa[j],0,FAB_red);
160
    }
161
  FAB_print(NULL,"fatto");
162
}
163
 
164
void kern_alloc_frames()
165
{
166
  int test=0;
167
 
168
  FAB_print("FAB_FRAMEs","allocazione...");
169
  frame_bca = FAB_frame_alloc();
170
  if (frame_bca==NULL) test=1;
171
  frame_misure_oriz = FAB_frame_alloc();
172
  if (frame_misure_oriz==NULL) test=1;
173
  frame_misure_vert = FAB_frame_alloc();
174
  if (frame_misure_vert==NULL) test=1;
175
  frame_titolo = FAB_frame_alloc();
176
  if (frame_titolo==NULL) test=1;
177
  frame_comandi = FAB_frame_alloc();
178
  if (frame_comandi==NULL) test=1;
179
  frame_control = FAB_frame_alloc();
180
  if (frame_control==NULL) test=1;
181
 
1448 giacomo 182
  FAB_msg(test,"fatto","almeno un frame non allocato");
1091 pj 183
}
184
void kern_free_frames()
185
{
186
  FAB_frame_free(frame_bca);
187
  FAB_frame_free(frame_misure_oriz);
188
  FAB_frame_free(frame_misure_vert);
189
  FAB_frame_free(frame_titolo);
190
  FAB_frame_free(frame_comandi);
191
  FAB_frame_free(frame_control);
192
 
193
}
194
 
195
void kern_set_frames()
196
{
197
  FAB_print(NULL,"settaggio...");
198
  FAB_frame_border_set(frame_bca,border_blu7,7,FAB_rgb(255,0,0));
199
  FAB_frame_color_set(frame_bca,0,image_bca,FAB_green);
200
  FAB_frame_border_set(frame_misure_oriz,border_verde7,7,FRAME_MISURE_LINE_COLOR);
201
  FAB_frame_color_set(frame_misure_oriz,0,NULL,FRAME_MISURE_BACK_COLOR);
202
  FAB_frame_border_set(frame_misure_vert,border_verde7,7,FRAME_MISURE_LINE_COLOR);
203
  FAB_frame_color_set(frame_misure_vert,0,NULL,FRAME_MISURE_BACK_COLOR);
204
  FAB_frame_border_set(frame_titolo,border_bianco7,7,FAB_white);
205
  FAB_frame_color_set(frame_titolo,0,NULL,FRAME_TITOLO_BACK_COLOR1);
206
  FAB_frame_border_set(frame_comandi,border_giallo7,7,FAB_yellow);
207
  FAB_frame_color_set(frame_comandi,0,NULL,FRAME_COMANDI_BACK_COLOR1);
208
  FAB_frame_border_set(frame_control,border_verde7,7,FAB_green);
209
  FAB_frame_color_set(frame_control,0,NULL,FRAME_CONTROL_BACK_COLOR);
210
 
211
  FAB_print(NULL,"fatto");
212
}
213
 
214
void kern_alloc_borders()
215
{
216
  int test=0;
217
 
218
  FAB_print("FAB_BORDERs","allocazione...");
219
  border_blu7 = FAB_border_alloc(7);
220
  if (border_blu7==NULL) test=1;
221
  border_verde7 = FAB_border_alloc(7);
222
  if (border_verde7==NULL) test=1;
223
  border_rosso7 = FAB_border_alloc(7);
224
  if (border_rosso7==NULL) test=1;
225
  border_bianco7 = FAB_border_alloc(7);
226
  if (border_bianco7==NULL) test=1;
227
  border_giallo7 = FAB_border_alloc(7);
228
  if (border_giallo7==NULL) test=1;
229
 
1448 giacomo 230
  FAB_msg(test,"fatto","almeno un bordo non allocato");
1091 pj 231
}
232
void kern_free_borders()
233
{
234
  FAB_border_free(border_blu7);
235
  FAB_border_free(border_verde7);
236
  FAB_border_free(border_rosso7);
237
  FAB_border_free(border_bianco7);
238
  FAB_border_free(border_giallo7);
239
}
240
 
241
void kern_set_borders()
242
{
243
  FAB_print(NULL,"settaggio...");
244
  border_blu7->buf[0]=FAB_rgb(  0,  0, 50);
245
  border_blu7->buf[1]=FAB_rgb(  0, 50,200);
246
  border_blu7->buf[2]=FAB_rgb( 50,100,255);
247
  border_blu7->buf[3]=FAB_rgb(100,150,255);
248
  border_blu7->buf[4]=FAB_rgb( 50,100,255);
249
  border_blu7->buf[5]=FAB_rgb(  0, 50,200);
250
  border_blu7->buf[6]=FAB_rgb(  0,  0, 50);
251
 
252
  border_verde7->buf[0]=FAB_rgb(  0, 50,  0);
253
  border_verde7->buf[1]=FAB_rgb(  0,100, 50);
254
  border_verde7->buf[2]=FAB_rgb( 50,255,100);
255
  border_verde7->buf[3]=FAB_rgb(100,255,150);
256
  border_verde7->buf[4]=FAB_rgb( 50,255,100);
257
  border_verde7->buf[5]=FAB_rgb(  0,100, 50);
258
  border_verde7->buf[6]=FAB_rgb(  0, 50,  0);
259
 
260
  border_rosso7->buf[0]=FAB_rgb( 50,  0,  0);
261
  border_rosso7->buf[1]=FAB_rgb(200, 25, 25);
262
  border_rosso7->buf[2]=FAB_rgb(255, 75, 75);
263
  border_rosso7->buf[3]=FAB_rgb(255,125,125);
264
  border_rosso7->buf[4]=FAB_rgb(255, 75, 75);
265
  border_rosso7->buf[5]=FAB_rgb(200, 25, 25);
266
  border_rosso7->buf[6]=FAB_rgb( 50,  0,  0);
267
 
268
  border_bianco7->buf[0]=FAB_rgb( 25, 25, 25);
269
  border_bianco7->buf[1]=FAB_rgb( 75, 75, 75);
270
  border_bianco7->buf[2]=FAB_rgb(125,125,125);
271
  border_bianco7->buf[3]=FAB_rgb(255,255,255);
272
  border_bianco7->buf[4]=FAB_rgb(125,125,125);
273
  border_bianco7->buf[5]=FAB_rgb( 75, 75, 75);
274
  border_bianco7->buf[6]=FAB_rgb( 25, 25, 25);
275
 
276
  border_giallo7->buf[0]=FAB_rgb( 25, 25,  0);
277
  border_giallo7->buf[1]=FAB_rgb(115,115, 25);
278
  border_giallo7->buf[2]=FAB_rgb(170,170, 75);
279
  border_giallo7->buf[3]=FAB_rgb(255,255,100);
280
  border_giallo7->buf[4]=FAB_rgb(170,170, 75);
281
  border_giallo7->buf[5]=FAB_rgb(115,115, 25);
282
  border_giallo7->buf[6]=FAB_rgb( 25, 25,  0);
283
 
284
  FAB_print(NULL,"fatto");
285
}
286
 
287
void kern_alloc_images()
288
{
289
  int j,test=0;
290
 
291
  FAB_print("FAB_IMAGEs","allocazione...");
292
 
293
  image_missile[0] = FAB_image_alloc(MISSILE_LX,MISSILE_LY);
294
  if (image_missile[0]==NULL) test=1;
295
  image_missile[1] = FAB_image_alloc(MISSILE_LX,MISSILE_LY);
296
  if (image_missile[1]==NULL) test=1;
297
 
298
  for (j=0; j<2; j++) {
299
     image_cannone[j] = FAB_image_alloc(CANNONE_LX,CANNONE_LY);
300
     if (image_cannone[j]==NULL) test=1;
301
     }
302
 
303
  for (j=0; j<4; j++) {
304
     image_aereo[j] = FAB_image_alloc(AEREO_LX,AEREO_LY);
305
     if (image_aereo[j]==NULL) test=1;
306
     }
307
 
308
  for (j=0; j<5; j++) {
309
     image_esplo[j] = FAB_image_alloc(ESPLO_LX,ESPLO_LY);
310
     if (image_esplo[j]==NULL) test=1;
311
     }
312
 
313
  image_sfondo = FAB_image_alloc(96,96);
314
  if (image_sfondo==NULL) test=1;
315
 
316
  image_bca = FAB_image_alloc(500,500);
317
  if (image_bca==NULL) test=1;
318
 
1448 giacomo 319
  FAB_msg(test,"fatto","almeno un'immagine non allocata");
1091 pj 320
}
321
void kern_free_images()
322
{
323
  int j;
324
 
325
  FAB_image_free(image_missile[0]);
326
  FAB_image_free(image_missile[1]);
327
  for (j=0; j<2; j++)  FAB_image_free(image_cannone[j]);
328
  for (j=0; j<4; j++)  FAB_image_free(image_aereo[j]);
329
  for (j=0; j<5; j++)  FAB_image_free(image_esplo[j]);
330
  FAB_image_free(image_sfondo);
331
  FAB_image_free(image_bca);
332
}
333
 
334
void kern_load_images()
335
{ int test=0;
336
 
337
  FAB_print(NULL,"caricamento dai file...");
338
 
339
  FAB_print(NULL,"  [missile1.raw]...");
340
  if(FAB_image_load(image_missile[0],"BCA_raw/missile1.raw")==-1) test=1;
341
  FAB_image_trasparent_set(image_missile[0],MISSILE_TRASPARENT_COL);
342
  FAB_print(NULL,"  [missile2.raw]...");
343
  if(FAB_image_load(image_missile[1],"BCA_raw/missile2.raw")==-1) test=1;
344
  FAB_image_trasparent_set(image_missile[1],MISSILE_TRASPARENT_COL);
345
 
346
  FAB_print(NULL,"  [aereo1.raw]...");
347
  if(FAB_image_load(image_aereo[0],"BCA_raw/aereo1.raw")==-1) test=1;
348
  FAB_image_trasparent_set(image_aereo[0],AEREO_TRASPARENT_COL);
349
  FAB_print(NULL,"  [aereo2.raw]...");
350
  if(FAB_image_load(image_aereo[1],"BCA_raw/aereo2.raw")==-1) test=1;
351
  FAB_image_trasparent_set(image_aereo[1],AEREO_TRASPARENT_COL);
352
  FAB_print(NULL,"  [aereo1_h.raw]...");
353
  if(FAB_image_load(image_aereo[2],"BCA_raw/aereo1_h.raw")==-1) test=1;
354
  FAB_image_trasparent_set(image_aereo[2],AEREO_TRASPARENT_COL);
355
  FAB_print(NULL,"  [aereo2_h.raw]...");
356
  if(FAB_image_load(image_aereo[3],"BCA_raw/aereo2_h.raw")==-1) test=1;
357
  FAB_image_trasparent_set(image_aereo[3],AEREO_TRASPARENT_COL);
358
 
359
  FAB_print(NULL,"  [cannon.raw]...");
360
  if(FAB_image_load(image_cannone[0],"BCA_raw/cannon.raw")==-1) test=1;
361
  FAB_image_trasparent_set(image_cannone[0],CANNONE_TRASPARENT_COL);
362
  FAB_print(NULL,"  [cannon_h.raw]...");
363
  if(FAB_image_load(image_cannone[1],"BCA_raw/cannon_h.raw")==-1) test=1;
364
  FAB_image_trasparent_set(image_cannone[1],CANNONE_TRASPARENT_COL);
365
 
366
  FAB_print(NULL,"  [esplo1.raw]...");
367
  if(FAB_image_load(image_esplo[0],"BCA_raw/esplo1.raw")==-1) test=1;
368
  FAB_image_trasparent_set(image_esplo[0],ESPLO_TRASPARENT_COL);
369
  FAB_print(NULL,"  [esplo2.raw]...");
370
  if(FAB_image_load(image_esplo[1],"BCA_raw/esplo2.raw")==-1) test=1;
371
  FAB_image_trasparent_set(image_esplo[1],ESPLO_TRASPARENT_COL);
372
  FAB_print(NULL,"  [esplo3.raw]...");
373
  if(FAB_image_load(image_esplo[2],"BCA_raw/esplo3.raw")==-1) test=1;
374
  FAB_image_trasparent_set(image_esplo[2],ESPLO_TRASPARENT_COL);
375
  FAB_print(NULL,"  [esplo4.raw]...");
376
  if(FAB_image_load(image_esplo[3],"BCA_raw/esplo4.raw")==-1) test=1;
377
  FAB_image_trasparent_set(image_esplo[3],ESPLO_TRASPARENT_COL);
378
  FAB_print(NULL,"  [esplo5.raw]...");
379
  if(FAB_image_load(image_esplo[4],"BCA_raw/esplo5.raw")==-1) test=1;
380
  FAB_image_trasparent_set(image_esplo[4],ESPLO_TRASPARENT_COL);
381
 
382
  FAB_print(NULL,"  [sfondo.raw]...");
383
  if(FAB_image_load(image_sfondo,"BCA_raw/sfondo.raw")==-1) test=1;
384
  FAB_image_no_trasparent_set(image_sfondo);
385
 
386
  FAB_print(NULL,"  [bca.raw]...");
387
  if(FAB_image_load(image_bca,"BCA_raw/bca.raw")==-1) test=1;
388
  FAB_image_no_trasparent_set(image_bca);
389
 
1448 giacomo 390
  FAB_msg(test,"fatto","almeno un file non esiste oppure ha un formato incompatibile");
1091 pj 391
}
392
 
1448 giacomo 393
// *** Corpo delle funzioni in CA.h *** //
394
void kern_init_bca()
395
{
396
  FAB_clr();
397
 
398
  kern_alloc_task_tables();
399
  kern_set_task_tables();
400
 
401
  kern_alloc_borders();
402
  kern_set_borders();
403
  kern_alloc_images();
404
  kern_load_images();
405
  kern_alloc_frames();
406
  kern_set_frames();
407
  kern_alloc_ballframes();
408
  kern_set_ballframes();
409
}
1091 pj 410
 
411
//----------------------END--------------------------
412
#endif