Subversion Repositories shark

Rev

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