/demos/trunk/bca/scenario.c |
---|
0,0 → 1,168 |
/* |
* Project: S.Ha.R.K. |
* |
* Coordinators: |
* Giorgio Buttazzo <giorgio@sssup.it> |
* Paolo Gai <pj@gandalf.sssup.it> |
* |
* Authors : |
* Paolo Gai <pj@gandalf.sssup.it> |
* Massimiliano Giorgi <massy@gandalf.sssup.it> |
* Luca Abeni <luca@gandalf.sssup.it> |
* (see the web pages for full authors list) |
* |
* ReTiS Lab (Scuola Superiore S.Anna - Pisa - Italy) |
* |
* http://www.sssup.it |
* http://retis.sssup.it |
* http://shark.sssup.it |
*/ |
/* CVS : $Id: scenario.c,v 1.1 2002-10-01 10:25:01 pj Exp $ */ |
/* |
* Copyright (C) 2000 Fabio Calabrese <fabiocalabrese77@yahoo.it> |
* |
* This program is free software; you can redistribute it and/or modify |
* it under the terms of the GNU General Public License as published by |
* the Free Software Foundation; either version 2 of the License, or |
* (at your option) any later version. |
* |
* This program is distributed in the hope that it will be useful, |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
* GNU General Public License for more details. |
* |
* You should have received a copy of the GNU General Public License |
* along with this program; if not, write to the Free Software |
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
* |
*/ |
//*************************** |
//* file: scenario.c * |
//* included by: bca.c * |
//*************************** |
void scenario_ca() |
{ //SFONDO |
FAB_image_fill(image_sfondo,0,0,800,600); |
//FRAME_BCA |
FAB_frame_put(frame_bca,X0-7,Y0-7,500+7*2,500+7*2); |
} |
void scenario_misure() |
{ int x, y, cx, cy; |
char* str_km ="X.Xkm"; |
char* str_m ="XXXXm"; |
int h; |
//FRAME_MISURE orizzontale |
FAB_frame_put(frame_misure_oriz, X0-7, Y1+7+20-7, |
500+7*2, FRAME_MISURE_ORIZ_LY+7*2); |
cy = frame_misure_oriz->y0 + 10; |
cx = frame_misure_oriz->x0 + |
(frame_misure_oriz->x1 - frame_misure_oriz->x0) / 2; |
for(x=frame_misure_oriz->x0 ;x<frame_misure_oriz->x1+1 ;x+=5) |
grx_line(x,cy,x+2,cy,FRAME_MISURE_LINE_COLOR); |
for(y=frame_misure_oriz->y0; y<cy-1; y+=5) { |
grx_line(frame_misure_oriz->x0,y,frame_misure_oriz->x0,y+2,FRAME_MISURE_LINE_COLOR); |
grx_line(cx,y,cx,y+2,FRAME_MISURE_LINE_COLOR); |
grx_line(frame_misure_oriz->x1,y,frame_misure_oriz->x1,y+2,FRAME_MISURE_LINE_COLOR); |
} |
sprintf(str_km,"%02.1fkm",0.0); |
grx_text(str_km,frame_misure_oriz->x0+10,cy+2,FRAME_MISURE_LINE_COLOR,frame_misure_oriz->color); |
sprintf(str_km,"%02.1fkm",BASE_L/2.0); |
grx_text(str_km,cx-10,cy+2,FRAME_MISURE_LINE_COLOR,frame_misure_oriz->color); |
sprintf(str_km,"%02.1fkm",BASE_L); |
grx_text(str_km,frame_misure_oriz->x1-FRAME_MISURE_ORIZ_LY,cy+2,FRAME_MISURE_LINE_COLOR,frame_misure_oriz->color); |
//FRAME_MISURE verticale |
FAB_frame_put(frame_misure_vert, X1+7+20-7, Y0-7, |
FRAME_MISURE_VERT_LX+7*2, 500+7*2); |
cy = frame_misure_vert->y0 + |
(frame_misure_vert->y1 - frame_misure_vert->y0) / 2; |
cx = frame_misure_vert->x0 + 10; |
for(y=frame_misure_vert->y1; y>frame_misure_vert->y0-1; y-=5) |
grx_line(cx,y,cx,y-2,FRAME_MISURE_LINE_COLOR); |
h=0; |
for(y=frame_misure_vert->y1; y>frame_misure_vert->y0-1; |
y-=500.0*(X1-X0)/BASE_H, h+=500) { |
for(x=frame_misure_vert->x0; x<cx-1; x+=5) |
grx_line(x,y,x+2,y,FRAME_MISURE_LINE_COLOR); |
sprintf(str_m,"%dm",h); |
grx_text(str_m, cx+2, y-6, |
FRAME_MISURE_LINE_COLOR, frame_misure_vert->color); |
} |
} |
void scenario_radar() |
{ FAB_ballframe_put(ballframe_radar, |
frame_bca->x1+7+30, frame_bca->y1+7+30, 30); |
FAB_ballframe_put(ballframe_lucerossa[2],605,546,20); |
FAB_ballframe_put(ballframe_lucerossa[1],594,578,15); |
FAB_ballframe_put(ballframe_lucerossa[0],574,591,10); |
} |
void scenario_titolo() |
{ int x0,y0; |
x0 = frame_misure_vert->x1+7+20-7; |
y0 = frame_bca->y0-7; |
FAB_frame_put(frame_titolo,x0,y0,800-x0-20+7,170); |
x0 = frame_titolo->x0; |
y0 = frame_titolo->y0; |
grx_text(titolo[0],x0+2,y0+10,FRAME_TITOLO_TEXT_COLOR2,FRAME_TITOLO_BACK_COLOR1); |
grx_text(titolo[1],x0+2,y0+20,FRAME_TITOLO_TEXT_COLOR2,FRAME_TITOLO_BACK_COLOR1); |
grx_text(titolo[2],x0+2,y0+30,FRAME_TITOLO_TEXT_COLOR2,FRAME_TITOLO_BACK_COLOR1); |
grx_text(titolo[3],x0+2,y0+46,FRAME_TITOLO_TEXT_COLOR2,FRAME_TITOLO_BACK_COLOR1); |
grx_text(titolo[4],x0+2,y0+66,FRAME_TITOLO_TEXT_COLOR1,FRAME_TITOLO_BACK_COLOR2); |
grx_text(titolo[5],x0+2,y0+81,FRAME_TITOLO_TEXT_COLOR2,FRAME_TITOLO_BACK_COLOR1); |
grx_text(titolo[6],x0+2,y0+96,FRAME_TITOLO_TEXT_COLOR2,FRAME_TITOLO_BACK_COLOR1); |
grx_text(titolo[7],x0+2,y0+116,FRAME_TITOLO_TEXT_COLOR2,FRAME_TITOLO_BACK_COLOR1); |
grx_text(titolo[8],x0+2,y0+133,FRAME_TITOLO_TEXT_COLOR2,FRAME_TITOLO_BACK_COLOR1); |
grx_text(titolo[9],x0+2,y0+141,FRAME_TITOLO_TEXT_COLOR2,FRAME_TITOLO_BACK_COLOR1); |
} |
void scenario_comandi() |
{ int x0, y0; |
x0 = frame_misure_vert->x1+7+20-7; |
y0 = frame_titolo->y1+7+20-7; |
FAB_frame_put(frame_comandi,x0,y0,800-x0-20+7,100+7*2); |
x0 = frame_comandi->x0; |
y0 = frame_comandi->y0; |
grx_text(" COMANDI \0",x0+2,y0+10,FRAME_COMANDI_TEXT_COLOR1,FRAME_COMANDI_BACK_COLOR1); |
grx_text("-------------------\0",x0+2,y0+20,FRAME_COMANDI_TEXT_COLOR2,FRAME_COMANDI_BACK_COLOR1); |
grx_text(" esci \0",x0+2,y0+40,FRAME_COMANDI_TEXT_COLOR2,FRAME_COMANDI_BACK_COLOR1); |
grx_text("[INVIO]",x0+2,y0+40,FRAME_COMANDI_TEXT_COLOR3,FRAME_COMANDI_BACK_COLOR2); |
grx_text(" +/- aerei \0",x0+2,y0+60,FRAME_COMANDI_TEXT_COLOR2,FRAME_COMANDI_BACK_COLOR1); |
grx_text("[1/2]",x0+2,y0+60,FRAME_COMANDI_TEXT_COLOR3,FRAME_COMANDI_BACK_COLOR2); |
grx_text(" +/- cannoni\0",x0+2,y0+80,FRAME_COMANDI_TEXT_COLOR2,FRAME_COMANDI_BACK_COLOR1); |
grx_text("[3/4]",x0+2,y0+80,FRAME_COMANDI_TEXT_COLOR3,FRAME_COMANDI_BACK_COLOR2); |
} |
void scenario_control() |
{ int x0,y0; |
x0 = frame_misure_vert->x1+7+20-7; |
y0 = frame_comandi->y1+7+20-7; |
FAB_frame_put(frame_control,x0,y0,800-x0-20+7,frame_misure_vert->y1+7-y0); |
x0 = frame_control->x0; |
y0 = frame_control->y0; |
grx_text(" CONTROL \0",x0+2, y0+5,FRAME_CONTROL_TEXT_COLOR2,FRAME_CONTROL_BACK_COLOR); |
grx_line(x0-3, y0+15, |
frame_control->x1+3, y0+15, |
FRAME_CONTROL_TEXT_COLOR1); |
grx_line(x0-3, frame_control->y1-81, |
frame_control->x1+3, frame_control->y1-81, |
FRAME_CONTROL_TEXT_COLOR1); |
} |
void scenario() |
{ scenario_ca(); |
scenario_misure(); |
scenario_radar(); |
scenario_titolo(); |
scenario_comandi(); |
scenario_control(); |
} |
void info() |
{ int i; |
for(i=0; i<10; i++) kern_printf("%s\n",titolo[i]); |
} |
/demos/trunk/bca/initfile.c |
---|
0,0 → 1,137 |
/* |
* Project: S.Ha.R.K. |
* |
* Coordinators: |
* Giorgio Buttazzo <giorgio@sssup.it> |
* Paolo Gai <pj@gandalf.sssup.it> |
* |
* Authors : |
* Paolo Gai <pj@gandalf.sssup.it> |
* Massimiliano Giorgi <massy@gandalf.sssup.it> |
* Luca Abeni <luca@gandalf.sssup.it> |
* (see the web pages for full authors list) |
* |
* ReTiS Lab (Scuola Superiore S.Anna - Pisa - Italy) |
* |
* http://www.sssup.it |
* http://retis.sssup.it |
* http://shark.sssup.it |
*/ |
/* CVS : $Id: initfile.c,v 1.1 2002-10-01 10:25:01 pj Exp $ */ |
/* |
* Copyright (C) 2000 Fabio Calabrese <fabiocalabrese77@yahoo.it> |
* |
* This program is free software; you can redistribute it and/or modify |
* it under the terms of the GNU General Public License as published by |
* the Free Software Foundation; either version 2 of the License, or |
* (at your option) any later version. |
* |
* This program is distributed in the hope that it will be useful, |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
* GNU General Public License for more details. |
* |
* You should have received a copy of the GNU General Public License |
* along with this program; if not, write to the Free Software |
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
* |
*/ |
/**************************************************** |
* * |
* file: initfile.h * |
* data: 15/09/2002 * |
* creato da: Fabio CALABRESE * |
* * |
****************************************************** |
* * |
* descrizione: inizializza i moduli di scheduling e * |
* di risorse per il programma SHaRK * |
* "(B)ase(C)ontr(A)rea", il cui task * |
* main e' nel file bca.c. * |
* * |
******************************************************/ |
#define PI |
// *** Librerie S.Ha.R.K *** |
#include "kernel/kern.h" |
#include "modules/edf.h" |
#include "modules/cbs.h" |
#include "modules/rr.h" |
#include "modules/dummy.h" |
#include "modules/sem.h" |
#include "modules/hartport.h" |
#include "modules/cabs.h" |
#include "drivers/keyb.h" |
// *** Librerie Standard C *** |
// *** Librerie FAB *** |
// *** Librerie BCA *** |
#include"BCA.h" |
/*+ system tick in us +*/ |
#define TICK 1000 |
/*+ RR tick in us +*/ |
#define RRTICK 10000 |
TIME __kernel_register_levels__(void *arg) |
{ |
struct multiboot_info *mb = (struct multiboot_info *)arg; |
EDF_register_level(EDF_ENABLE_ALL); |
CBS_register_level(CBS_ENABLE_ALL, 0); |
RR_register_level(RRTICK, RR_MAIN_YES, mb); |
dummy_register_level(); |
SEM_register_module(); |
CABS_register_module(); |
PI_register_module(); |
NOP_register_module(); |
kern_init_bca(); |
// periodic timer |
return TICK; |
// one-shot timer |
// return 0 |
} |
TASK __init__(void *arg) |
{ |
struct multiboot_info *mb = (struct multiboot_info *)arg; |
KEYB_PARMS kparms = BASE_KEYB; |
HARTPORT_init(); |
keyb_def_ctrlC(kparms, NULL); |
KEYB_init(&kparms); |
__call_main__(mb); |
return (void *)0; |
} |
#ifdef PI |
int app_mutex_init(mutex_t *m) |
{ |
PI_mutexattr_t attr; |
PI_mutexattr_default(attr); |
return mutex_init(m, &attr); |
} |
#else |
int app_mutex_init(mutex_t *m) |
{ |
NOP_mutexattr_t attr; |
NOP_mutexattr_default(attr); |
return mutex_init(m, &attr); |
} |
#endif |
/demos/trunk/bca/missile.c |
---|
0,0 → 1,198 |
/* |
* Project: S.Ha.R.K. |
* |
* Coordinators: |
* Giorgio Buttazzo <giorgio@sssup.it> |
* Paolo Gai <pj@gandalf.sssup.it> |
* |
* Authors : |
* Paolo Gai <pj@gandalf.sssup.it> |
* Massimiliano Giorgi <massy@gandalf.sssup.it> |
* Luca Abeni <luca@gandalf.sssup.it> |
* (see the web pages for full authors list) |
* |
* ReTiS Lab (Scuola Superiore S.Anna - Pisa - Italy) |
* |
* http://www.sssup.it |
* http://retis.sssup.it |
* http://shark.sssup.it |
*/ |
/* CVS : $Id: missile.c,v 1.1 2002-10-01 10:25:01 pj Exp $ */ |
/* |
* Copyright (C) 2000 Fabio Calabrese <fabiocalabrese77@yahoo.it> |
* |
* This program is free software; you can redistribute it and/or modify |
* it under the terms of the GNU General Public License as published by |
* the Free Software Foundation; either version 2 of the License, or |
* (at your option) any later version. |
* |
* This program is distributed in the hope that it will be useful, |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
* GNU General Public License for more details. |
* |
* You should have received a copy of the GNU General Public License |
* along with this program; if not, write to the Free Software |
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
* |
*/ |
//************************** |
//* file: missile.c * |
//* included by: bca.c * |
//************************** |
TASK missile(void *arg) |
{ |
PID esplo_pid; |
int img; |
int i, index; // indice nella cannone_table |
int distx, disty; |
int xx0,yy0,xx1,yy1; |
double vel, acc; |
double a; |
double y; |
double x; |
double old_x; // [pixel]: conserva valore x prima di aggiornare |
double old_y; |
double dx; // [pixel/us]: spostamento periodico |
double dy; |
int first_time; |
int killing; |
index = (int)arg; |
img=0; |
y = MISSILE_Y_MAX; |
x = cannone_table[index].x; |
a = FAB_rad(270); |
vel = MISSILE_V_MIN; |
acc = MISSILE_ACC_MIN; |
dx = 0; |
dy = 0; |
first_time = 1; |
killing = 0; |
while(1){ |
old_x = x; |
old_y = y; |
if (vel<MISSILE_V_MAX) { |
vel += acc*MISSILE_PERIOD/(60*60*1000000.0); |
if (vel>MISSILE_V_MAX) vel = MISSILE_V_MAX; |
} |
if (acc<MISSILE_ACC_MAX) { |
acc += MISSILE_ACC_MIN; |
if (acc>MISSILE_ACC_MAX) acc = MISSILE_ACC_MAX; |
} |
cannone_table[index].missile_vel=vel; |
dx = cos(a)*vel * (X1-X0) / (double)BASE_L |
* (MISSILE_PERIOD / (60*60*1000000.0)); |
dy = sin(a)*vel * (Y1-Y0) / ((double)BASE_H/1000) |
* (MISSILE_PERIOD / (60*60*1000000.0)); |
x += dx; |
y += dy; |
xx0 = old_x - MISSILE_LX/2; |
yy0 = old_y - MISSILE_LY/2; |
xx1 = xx0 + MISSILE_LX-1; |
yy1 = yy0 + MISSILE_LY-1; |
if (x<MISSILE_X_MIN || x>MISSILE_X_MAX |
|| y<MISSILE_Y_MIN || y>MISSILE_Y_MAX) { |
killing = 1; |
} |
if (killing) { |
if (!first_time) { |
mutex_lock(&grx_mutex); |
FAB_image_put_within(image_bca,X0,Y0,xx0,yy0,xx1,yy1); |
mutex_unlock(&grx_mutex); |
} |
cannone_table[index].fire = 0; |
//il task cannone si accorge che il suo missile ha finito |
// quindi ne ricreer uno nuovo in caso di bersaglio!!! |
return NULL; |
} |
if ( (int)x != (int)old_x |
||(int)y != (int)old_y ) {//...se c' lo spostamento reale |
// di almeno un pixel... |
mutex_lock(&grx_mutex); //...aggiorna disegno... |
if (first_time) { |
first_time=0; |
} |
else { |
if (yy1<Y1-CANNONE_LY) FAB_image_put_within(image_bca,X0,Y0,xx0,yy0,xx1,yy1); |
else FAB_image_put_within(image_bca,X0,Y0,xx0,yy0,xx1,Y1-CANNONE_LY); |
} |
FAB_image_put_within(image_missile[img++], x - MISSILE_LX/2, y - MISSILE_LY/2, |
X0, Y0, |
X1, Y1-CANNONE_LY); |
mutex_unlock(&grx_mutex); |
if (img==2) img = 0; |
} |
//Ha colpito un aereo? |
for (i=0; i<AEREO_N_MAX; i++) |
if (aereo_table[i].status){ |
distx = aereo_table[i].x-x; |
disty = aereo_table[i].y-y; |
if (distx<0) distx *= -1; |
if (disty<0) disty *= -1; |
if ( distx<(AEREO_LX+MISSILE_LX)/2-1 |
&&disty<(AEREO_LY+MISSILE_LY)/2-1 ) { // BERSAGLIO COLPITO! |
esplo_pid = crea_soft_esplo(i); |
task_activate(esplo_pid); |
killing=1; |
aereo_table[i].killing=1; |
break; |
} |
} |
task_endcycle(); |
} |
return NULL; |
} |
PID crea_hard_missile(int index) |
{ |
HARD_TASK_MODEL m; |
PID pid; |
hard_task_default_model(m); |
hard_task_def_level(m,0); |
hard_task_def_arg(m,(void*)index); |
hard_task_def_periodic(m); |
hard_task_def_wcet(m, MISSILE_WCET); |
hard_task_def_mit(m,MISSILE_PERIOD); |
pid = task_create("hard_missile", missile, &m, NULL); |
return pid; |
} |
PID crea_soft_missile(int index) |
{ |
SOFT_TASK_MODEL m; |
PID pid; |
soft_task_default_model(m); |
soft_task_def_level(m,0); |
soft_task_def_arg(m,(void*)index); |
soft_task_def_periodic(m); |
soft_task_def_period(m,MISSILE_PERIOD); |
soft_task_def_wcet(m, MISSILE_WCET); |
soft_task_def_met(m,MISSILE_MET); |
pid = task_create("soft_missile", missile, &m, NULL); |
return pid; |
} |
/demos/trunk/bca/bca_lib.c |
---|
0,0 → 1,413 |
/* |
* Project: S.Ha.R.K. |
* |
* Coordinators: |
* Giorgio Buttazzo <giorgio@sssup.it> |
* Paolo Gai <pj@gandalf.sssup.it> |
* |
* Authors : |
* Paolo Gai <pj@gandalf.sssup.it> |
* Massimiliano Giorgi <massy@gandalf.sssup.it> |
* Luca Abeni <luca@gandalf.sssup.it> |
* (see the web pages for full authors list) |
* |
* ReTiS Lab (Scuola Superiore S.Anna - Pisa - Italy) |
* |
* http://www.sssup.it |
* http://retis.sssup.it |
* http://shark.sssup.it |
*/ |
/* CVS : $Id: bca_lib.c,v 1.1 2002-10-01 10:25:00 pj Exp $ */ |
/* |
* Copyright (C) 2000 Fabio Calabrese <fabiocalabrese77@yahoo.it> |
* |
* This program is free software; you can redistribute it and/or modify |
* it under the terms of the GNU General Public License as published by |
* the Free Software Foundation; either version 2 of the License, or |
* (at your option) any later version. |
* |
* This program is distributed in the hope that it will be useful, |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
* GNU General Public License for more details. |
* |
* You should have received a copy of the GNU General Public License |
* along with this program; if not, write to the Free Software |
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
* |
*/ |
/**************************************************** |
* * |
* file: BCA_LIB.c * |
* libreria: BCA_LIB * |
* creato da: Fabio CALABRESE * |
* * |
****************************************************/ |
#ifndef __BCA_LIB_c__ |
#define __BCA_LIB_c__ |
//-------------------BEGIN--------------------------- |
// *** Librerie S.Ha.R.K *** |
#include<kernel/kern.h> |
#include<drivers/glib.h> |
#include<drivers/gd.h> |
// *** Librerie Standard C *** |
// *** Librerie FAB *** |
#include"FAB_LIB/FAB_msg.h" |
// *** Librerie BCA *** |
#include"BCA.h" |
extern char * titolo[10]={" UNIVERSITA' DEGLI \0", |
" STUDI DI \0", |
" PAVIA \0", |
"Progetto S.Ha.R.K.\0", |
" 'BaseContrAerea' \0", |
"-------------------\0", |
" PAVIA 2002 \0", |
"by Fabio CALABRESE \0", |
"<fabiocalabrese77 \0", |
" @yahoo.it>\0"}; |
void kern_alloc_images(); // richiede DISABLED_INTERUPTS |
void kern_free_images(); // richiede DISABLED_INTERUPTS |
void kern_load_images(); // solo in __kernel_register_levels__() |
void kern_alloc_borders(); // richiede DISABLED_INTERUPTS |
void kern_free_borders(); // richiede DISABLED_INTERUPTS |
void kern_set_border(); // consigliato in __kernel_register-levels__() |
void kern_alloc_frames(); // richiede DISABLED_INTERUPTS |
void kern_free_frames(); // richiede DISABLED_INTERUPTS |
void kern_set_frames(); // consigliato in __kernel_register-levels__() |
void kern_alloc_ballframes(); // richiede DISABLED_INTERUPTS |
void kern_free_ballframes(); // richiede DISABLED_INTERUPTS |
void kern_set_ballframes(); // consigliato in __kernel_register-levels__() |
void kern_alloc_task_tables(); // richiede DISABLED_INTERUPTS |
void kern_free_task_tables(); // richiede DISABLED_INTERUPTS |
void kern_set_task_tables(); // consigliato in __kernel_register-levels__() |
// *** Corpo delle funzioni in CA.h *** // |
void kern_init_bca() |
{ |
FAB_clr(); |
FAB_show_sched_modules(); |
kern_alloc_task_tables(); |
kern_set_task_tables(); |
kern_alloc_borders(); |
kern_set_borders(); |
kern_alloc_images(); |
kern_load_images(); |
kern_alloc_frames(); |
kern_set_frames(); |
kern_alloc_ballframes(); |
kern_set_ballframes(); |
} |
void kern_alloc_task_tables() |
{ |
int test=0,j; |
FAB_print("TASKS'TABLES","allocazione..."); |
for (j=0; j<AEREO_N_MAX; j++) { |
aereo_table[j].image=FAB_image_alloc(AEREO_LX,AEREO_LY); |
if(aereo_table[j].image==NULL) test=1; |
} |
FAB_msg(test,NULL,"fatto","almeno un elemento della tabella non allocato"); |
} |
void kern_free_task_tables() |
{ int j; |
for (j=0; j<AEREO_N_MAX; j++) { |
FAB_image_free(aereo_table[j].image); |
} |
} |
void kern_set_task_tables() |
{ int j; |
FAB_print(NULL,"settaggio..."); |
for (j=0; j<AEREO_N_MAX; j++) { |
aereo_table[j].status = 0; |
aereo_table[j].killing = 0; |
aereo_table[j].image->trasparent = 1; |
aereo_table[j].image->trasparent_col = AEREO_TRASPARENT_COL; |
} |
FAB_print(NULL,"fatto"); |
} |
void kern_alloc_ballframes() |
{ |
int test=0,j; |
FAB_print("FAB_BALLFRAMEs","allocazione..."); |
ballframe_radar = FAB_ballframe_alloc(); |
if (ballframe_radar==NULL) test=1; |
for (j=0; j<3; j++) { |
ballframe_lucerossa[j] = FAB_ballframe_alloc(); |
if (ballframe_lucerossa[j]==NULL) test=1; |
} |
FAB_msg(test,NULL,"fatto","almeno un ballframe non allocato"); |
} |
void kern_free_ballframes() |
{ int j; |
FAB_ballframe_free(ballframe_radar); |
for (j=0; j<3; j++) |
FAB_ballframe_free(ballframe_lucerossa[j]); |
} |
void kern_set_ballframes() |
{ int j; |
FAB_print(NULL,"settaggio..."); |
FAB_ballframe_border_set(ballframe_radar,border_verde7,7, |
FRAME_MISURE_LINE_COLOR); |
FAB_ballframe_color_set(ballframe_radar,0,FAB_blue); |
for(j=0; j<3; j++) { |
FAB_ballframe_border_set(ballframe_lucerossa[j],border_verde7,7, |
FRAME_MISURE_LINE_COLOR); |
FAB_ballframe_color_set(ballframe_lucerossa[j],0,FAB_red); |
} |
FAB_print(NULL,"fatto"); |
} |
void kern_alloc_frames() |
{ |
int test=0; |
FAB_print("FAB_FRAMEs","allocazione..."); |
frame_bca = FAB_frame_alloc(); |
if (frame_bca==NULL) test=1; |
frame_misure_oriz = FAB_frame_alloc(); |
if (frame_misure_oriz==NULL) test=1; |
frame_misure_vert = FAB_frame_alloc(); |
if (frame_misure_vert==NULL) test=1; |
frame_titolo = FAB_frame_alloc(); |
if (frame_titolo==NULL) test=1; |
frame_comandi = FAB_frame_alloc(); |
if (frame_comandi==NULL) test=1; |
frame_control = FAB_frame_alloc(); |
if (frame_control==NULL) test=1; |
FAB_msg(test,NULL,"fatto","almeno un frame non allocato"); |
} |
void kern_free_frames() |
{ |
FAB_frame_free(frame_bca); |
FAB_frame_free(frame_misure_oriz); |
FAB_frame_free(frame_misure_vert); |
FAB_frame_free(frame_titolo); |
FAB_frame_free(frame_comandi); |
FAB_frame_free(frame_control); |
} |
void kern_set_frames() |
{ |
FAB_print(NULL,"settaggio..."); |
FAB_frame_border_set(frame_bca,border_blu7,7,FAB_rgb(255,0,0)); |
FAB_frame_color_set(frame_bca,0,image_bca,FAB_green); |
FAB_frame_border_set(frame_misure_oriz,border_verde7,7,FRAME_MISURE_LINE_COLOR); |
FAB_frame_color_set(frame_misure_oriz,0,NULL,FRAME_MISURE_BACK_COLOR); |
FAB_frame_border_set(frame_misure_vert,border_verde7,7,FRAME_MISURE_LINE_COLOR); |
FAB_frame_color_set(frame_misure_vert,0,NULL,FRAME_MISURE_BACK_COLOR); |
FAB_frame_border_set(frame_titolo,border_bianco7,7,FAB_white); |
FAB_frame_color_set(frame_titolo,0,NULL,FRAME_TITOLO_BACK_COLOR1); |
FAB_frame_border_set(frame_comandi,border_giallo7,7,FAB_yellow); |
FAB_frame_color_set(frame_comandi,0,NULL,FRAME_COMANDI_BACK_COLOR1); |
FAB_frame_border_set(frame_control,border_verde7,7,FAB_green); |
FAB_frame_color_set(frame_control,0,NULL,FRAME_CONTROL_BACK_COLOR); |
FAB_print(NULL,"fatto"); |
} |
void kern_alloc_borders() |
{ |
int test=0; |
FAB_print("FAB_BORDERs","allocazione..."); |
border_blu7 = FAB_border_alloc(7); |
if (border_blu7==NULL) test=1; |
border_verde7 = FAB_border_alloc(7); |
if (border_verde7==NULL) test=1; |
border_rosso7 = FAB_border_alloc(7); |
if (border_rosso7==NULL) test=1; |
border_bianco7 = FAB_border_alloc(7); |
if (border_bianco7==NULL) test=1; |
border_giallo7 = FAB_border_alloc(7); |
if (border_giallo7==NULL) test=1; |
FAB_msg(test,NULL,"fatto","almeno un bordo non allocato"); |
} |
void kern_free_borders() |
{ |
FAB_border_free(border_blu7); |
FAB_border_free(border_verde7); |
FAB_border_free(border_rosso7); |
FAB_border_free(border_bianco7); |
FAB_border_free(border_giallo7); |
} |
void kern_set_borders() |
{ |
FAB_print(NULL,"settaggio..."); |
border_blu7->buf[0]=FAB_rgb( 0, 0, 50); |
border_blu7->buf[1]=FAB_rgb( 0, 50,200); |
border_blu7->buf[2]=FAB_rgb( 50,100,255); |
border_blu7->buf[3]=FAB_rgb(100,150,255); |
border_blu7->buf[4]=FAB_rgb( 50,100,255); |
border_blu7->buf[5]=FAB_rgb( 0, 50,200); |
border_blu7->buf[6]=FAB_rgb( 0, 0, 50); |
border_verde7->buf[0]=FAB_rgb( 0, 50, 0); |
border_verde7->buf[1]=FAB_rgb( 0,100, 50); |
border_verde7->buf[2]=FAB_rgb( 50,255,100); |
border_verde7->buf[3]=FAB_rgb(100,255,150); |
border_verde7->buf[4]=FAB_rgb( 50,255,100); |
border_verde7->buf[5]=FAB_rgb( 0,100, 50); |
border_verde7->buf[6]=FAB_rgb( 0, 50, 0); |
border_rosso7->buf[0]=FAB_rgb( 50, 0, 0); |
border_rosso7->buf[1]=FAB_rgb(200, 25, 25); |
border_rosso7->buf[2]=FAB_rgb(255, 75, 75); |
border_rosso7->buf[3]=FAB_rgb(255,125,125); |
border_rosso7->buf[4]=FAB_rgb(255, 75, 75); |
border_rosso7->buf[5]=FAB_rgb(200, 25, 25); |
border_rosso7->buf[6]=FAB_rgb( 50, 0, 0); |
border_bianco7->buf[0]=FAB_rgb( 25, 25, 25); |
border_bianco7->buf[1]=FAB_rgb( 75, 75, 75); |
border_bianco7->buf[2]=FAB_rgb(125,125,125); |
border_bianco7->buf[3]=FAB_rgb(255,255,255); |
border_bianco7->buf[4]=FAB_rgb(125,125,125); |
border_bianco7->buf[5]=FAB_rgb( 75, 75, 75); |
border_bianco7->buf[6]=FAB_rgb( 25, 25, 25); |
border_giallo7->buf[0]=FAB_rgb( 25, 25, 0); |
border_giallo7->buf[1]=FAB_rgb(115,115, 25); |
border_giallo7->buf[2]=FAB_rgb(170,170, 75); |
border_giallo7->buf[3]=FAB_rgb(255,255,100); |
border_giallo7->buf[4]=FAB_rgb(170,170, 75); |
border_giallo7->buf[5]=FAB_rgb(115,115, 25); |
border_giallo7->buf[6]=FAB_rgb( 25, 25, 0); |
FAB_print(NULL,"fatto"); |
} |
void kern_alloc_images() |
{ |
int j,test=0; |
FAB_print("FAB_IMAGEs","allocazione..."); |
image_missile[0] = FAB_image_alloc(MISSILE_LX,MISSILE_LY); |
if (image_missile[0]==NULL) test=1; |
image_missile[1] = FAB_image_alloc(MISSILE_LX,MISSILE_LY); |
if (image_missile[1]==NULL) test=1; |
for (j=0; j<2; j++) { |
image_cannone[j] = FAB_image_alloc(CANNONE_LX,CANNONE_LY); |
if (image_cannone[j]==NULL) test=1; |
} |
for (j=0; j<4; j++) { |
image_aereo[j] = FAB_image_alloc(AEREO_LX,AEREO_LY); |
if (image_aereo[j]==NULL) test=1; |
} |
for (j=0; j<5; j++) { |
image_esplo[j] = FAB_image_alloc(ESPLO_LX,ESPLO_LY); |
if (image_esplo[j]==NULL) test=1; |
} |
image_sfondo = FAB_image_alloc(96,96); |
if (image_sfondo==NULL) test=1; |
image_bca = FAB_image_alloc(500,500); |
if (image_bca==NULL) test=1; |
FAB_msg(test,NULL,"fatto","almeno un'immagine non allocata"); |
} |
void kern_free_images() |
{ |
int j; |
FAB_image_free(image_missile[0]); |
FAB_image_free(image_missile[1]); |
for (j=0; j<2; j++) FAB_image_free(image_cannone[j]); |
for (j=0; j<4; j++) FAB_image_free(image_aereo[j]); |
for (j=0; j<5; j++) FAB_image_free(image_esplo[j]); |
FAB_image_free(image_sfondo); |
FAB_image_free(image_bca); |
} |
void kern_load_images() |
{ int test=0; |
FAB_print(NULL,"caricamento dai file..."); |
FAB_print(NULL," [missile1.raw]..."); |
if(FAB_image_load(image_missile[0],"BCA_raw/missile1.raw")==-1) test=1; |
FAB_image_trasparent_set(image_missile[0],MISSILE_TRASPARENT_COL); |
FAB_print(NULL," [missile2.raw]..."); |
if(FAB_image_load(image_missile[1],"BCA_raw/missile2.raw")==-1) test=1; |
FAB_image_trasparent_set(image_missile[1],MISSILE_TRASPARENT_COL); |
FAB_print(NULL," [aereo1.raw]..."); |
if(FAB_image_load(image_aereo[0],"BCA_raw/aereo1.raw")==-1) test=1; |
FAB_image_trasparent_set(image_aereo[0],AEREO_TRASPARENT_COL); |
FAB_print(NULL," [aereo2.raw]..."); |
if(FAB_image_load(image_aereo[1],"BCA_raw/aereo2.raw")==-1) test=1; |
FAB_image_trasparent_set(image_aereo[1],AEREO_TRASPARENT_COL); |
FAB_print(NULL," [aereo1_h.raw]..."); |
if(FAB_image_load(image_aereo[2],"BCA_raw/aereo1_h.raw")==-1) test=1; |
FAB_image_trasparent_set(image_aereo[2],AEREO_TRASPARENT_COL); |
FAB_print(NULL," [aereo2_h.raw]..."); |
if(FAB_image_load(image_aereo[3],"BCA_raw/aereo2_h.raw")==-1) test=1; |
FAB_image_trasparent_set(image_aereo[3],AEREO_TRASPARENT_COL); |
FAB_print(NULL," [cannon.raw]..."); |
if(FAB_image_load(image_cannone[0],"BCA_raw/cannon.raw")==-1) test=1; |
FAB_image_trasparent_set(image_cannone[0],CANNONE_TRASPARENT_COL); |
FAB_print(NULL," [cannon_h.raw]..."); |
if(FAB_image_load(image_cannone[1],"BCA_raw/cannon_h.raw")==-1) test=1; |
FAB_image_trasparent_set(image_cannone[1],CANNONE_TRASPARENT_COL); |
FAB_print(NULL," [esplo1.raw]..."); |
if(FAB_image_load(image_esplo[0],"BCA_raw/esplo1.raw")==-1) test=1; |
FAB_image_trasparent_set(image_esplo[0],ESPLO_TRASPARENT_COL); |
FAB_print(NULL," [esplo2.raw]..."); |
if(FAB_image_load(image_esplo[1],"BCA_raw/esplo2.raw")==-1) test=1; |
FAB_image_trasparent_set(image_esplo[1],ESPLO_TRASPARENT_COL); |
FAB_print(NULL," [esplo3.raw]..."); |
if(FAB_image_load(image_esplo[2],"BCA_raw/esplo3.raw")==-1) test=1; |
FAB_image_trasparent_set(image_esplo[2],ESPLO_TRASPARENT_COL); |
FAB_print(NULL," [esplo4.raw]..."); |
if(FAB_image_load(image_esplo[3],"BCA_raw/esplo4.raw")==-1) test=1; |
FAB_image_trasparent_set(image_esplo[3],ESPLO_TRASPARENT_COL); |
FAB_print(NULL," [esplo5.raw]..."); |
if(FAB_image_load(image_esplo[4],"BCA_raw/esplo5.raw")==-1) test=1; |
FAB_image_trasparent_set(image_esplo[4],ESPLO_TRASPARENT_COL); |
FAB_print(NULL," [sfondo.raw]..."); |
if(FAB_image_load(image_sfondo,"BCA_raw/sfondo.raw")==-1) test=1; |
FAB_image_no_trasparent_set(image_sfondo); |
FAB_print(NULL," [bca.raw]..."); |
if(FAB_image_load(image_bca,"BCA_raw/bca.raw")==-1) test=1; |
FAB_image_no_trasparent_set(image_bca); |
FAB_msg(test,NULL,"fatto","almeno un file non esiste oppure ha un formato incompatibile"); |
} |
//----------------------END-------------------------- |
#endif |
/demos/trunk/bca/readme |
---|
0,0 → 1,11 |
Hi, |
This is a nice simulation made by Fabio Calabrese |
(fabiocalabrese77@yahoo.it). |
Documentation is also available in PDF form on the shark website (only |
in italian, sorry). |
Enjoy |
PJ |
/demos/trunk/bca/bca_raw/esplo5.raw |
---|
0,0 → 1,65 |
ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ)&ÿÿÿÿÿÿÿÿÿ |
ÿÿÿÿÿÿ +*#! |
.*% ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ ):'+) :-65/1&&ÿÿÿÿÿÿ *-"&* %!&$)"%+-&% &!+%)&ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ |
+.(B= 7342)& |
+ ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ $ )&.(:/G7'H7/@3-) 62& +* EE HJ MRNSHNOS2JN7Y\K<=/0/@@('& |
+/,")#+#?4 i]GcU:i[6}nEmEuDzo-xr(^ZDB :6'%30//3627 9=BE`a7**! *'1-KH7*'ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ |
+ &QC(eW2o`9E4]M,QE[Uzv9eb/63#!+*#% 47 |
+$& |