Subversion Repositories shark

Compare Revisions

Ignore whitespace Rev 1348 → Rev 1349

/demos/trunk/astro/rock.c
1,12 → 1,8
/*
* Project: HARTIK (HA-rd R-eal TI-me K-ernel)
* Project: S.Ha.R.K.
*
* Coordinators: Giorgio Buttazzo <giorgio@sssup.it>
* Gerardo Lamastra <gerardo@sssup.it>
*
* Authors : Paolo Gai <pj@hartik.sssup.it>
* (see authors.txt for full list of hartik's authors)
*
* ReTiS Lab (Scuola Superiore S.Anna - Pisa - Italy)
*
* http://www.sssup.it
14,25 → 10,6
* http://hartik.sssup.it
*/
 
/*
* Copyright (C) 2000 Paolo Gai
*
* 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
*
*/
 
#include "asteroid.h"
 
PID pid_RC;
294,7 → 271,7
soft_task_def_usemath(ms);
pid_RC = task_create("RockCreator", rock_creator, &ms, NULL);
if (pid_RC == NIL) {
grx_close();
FB26_close(FRAME_BUFFER_DEVICE);
perror("Could not create task <RockCreator>");
sys_end();
} else
/demos/trunk/astro/asteroid.h
1,12 → 1,8
/*
* Project: HARTIK (HA-rd R-eal TI-me K-ernel)
* Project: S.Ha.R.K.
*
* Coordinators: Giorgio Buttazzo <giorgio@sssup.it>
* Gerardo Lamastra <gerardo@sssup.it>
*
* Authors : Paolo Gai <pj@hartik.sssup.it>
* (see authors.txt for full list of hartik's authors)
*
* ReTiS Lab (Scuola Superiore S.Anna - Pisa - Italy)
*
* http://www.sssup.it
14,37 → 10,21
* http://hartik.sssup.it
*/
 
/*
* Copyright (C) 2000 Paolo Gai
*
* 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
*
*/
 
#include <kernel/func.h>
#include <stdlib.h>
#include <drivers/keyb.h>
#include <drivers/glib.h>
#include <semaphore.h>
#include "modules/sem.h"
#include "modules/hartport.h"
 
#include <drivers/shark_keyb26.h>
#include <drivers/shark_fb26.h>
 
#include <math.h>
 
#define ASTRO_MOVE/* If defined then astro else defender */
 
#define FRAME_BUFFER_DEVICE 0
 
// DA CALCOLARE
#define RGB_BLACK rgb16( 0, 0, 0)
#define RGB_GRAY rgb16(127,127,127)
/demos/trunk/astro/initfile.c
1,12 → 1,8
/*
* Project: HARTIK (HA-rd R-eal TI-me K-ernel)
* Project: S.Ha.R.K
*
* Coordinators: Giorgio Buttazzo <giorgio@sssup.it>
* Gerardo Lamastra <gerardo@sssup.it>
*
* Authors : Paolo Gai <pj@hartik.sssup.it>
* (see authors.txt for full list of hartik's authors)
*
* ReTiS Lab (Scuola Superiore S.Anna - Pisa - Italy)
*
* http://www.sssup.it
14,44 → 10,46
* http://hartik.sssup.it
*/
 
/*
* Copyright (C) 2000 Paolo Gai
*
* 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
*
*/
 
#include "asteroid.h"
#include "kernel/kern.h"
#include "modules/edf.h"
#include "modules/cbs.h"
#include "modules/hardcbs.h"
#include "modules/rr.h"
#include "modules/dummy.h"
#include "modules/intdrive.h"
 
#include <drivers/shark_linuxc26.h>
#include <drivers/shark_input26.h>
#include <drivers/shark_keyb26.h>
 
/*+ sysyem tick in us +*/
#define TICK 0 //300
#define TICK 0
 
/*+ RR tick in us +*/
#define RRTICK 300
#define RRTICK 10000
 
/*+ Interrup Server */
#define INTDRIVE_Q 1000
#define INTDRIVE_T 10000
#define INTDRIVE_FLAG 0
 
void my_close(void *arg)
{
 
KEYB26_close();
INPUT26_close();
kern_printf("S.Ha.R.K. closed.\n\n");
 
}
 
TIME __kernel_register_levels__(void *arg)
{
struct multiboot_info *mb = (struct multiboot_info *)arg;
 
INTDRIVE_register_level(INTDRIVE_Q,INTDRIVE_T,INTDRIVE_FLAG);
EDF_register_level(EDF_ENABLE_ALL);
CBS_register_level(CBS_ENABLE_ALL, 0);
HCBS_register_level(HCBS_ENABLE_ALL, 1);
RR_register_level(RRTICK, RR_MAIN_YES, mb);
dummy_register_level();
 
68,10 → 66,12
 
HARTPORT_init();
 
keyb_set_map(itaMap);
keyb_def_ctrlC(kparms, NULL);
KEYB_init(&kparms);
LINUXC26_register_module();
INPUT26_init();
KEYB26_init(&kparms);
 
sys_atrunlevel(my_close, NULL, RUNLEVEL_BEFORE_EXIT);
 
__call_main__(mb);
 
return (void *)0;
/demos/trunk/astro/astro.c
3,9 → 3,6
*
* Coordinators: Giorgio Buttazzo <giorgio@sssup.it>
*
* Authors : Paolo Gai <pj@hartik.sssup.it>
* (see authors.txt for full list of hartik's authors)
*
* ReTiS Lab (Scuola Superiore S.Anna - Pisa - Italy)
*
* http://www.sssup.it
13,25 → 10,6
* http://shark.sssup.it
*/
 
/*
* Copyright (C) 2000 Paolo Gai
*
* 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
*
*/
 
#include "asteroid.h"
 
int nshot; /* number of shot active */
395,7 → 373,7
soft_task_def_usemath(ms);
pid = task_create("Astro", astro, &ms, NULL);
if (pid == NIL) {
grx_close();
FB26_close(FRAME_BUFFER_DEVICE);
perror("Could not create task <astro>");
sys_end();
} else
408,7 → 386,7
hard_task_def_usemath(mp);
pid = task_create("Taken", look, &mp, NULL);
if (pid == NIL) {
grx_close();
FB26_close(FRAME_BUFFER_DEVICE);
perror("Could not create task <Taken>");
sys_end();
} else
424,7 → 402,7
hard_task_def_usemath(mp);
pid_TL = task_create("TurnLeft", turn, &mp, NULL);
if (pid_TL == NIL) {
grx_close();
FB26_close(FRAME_BUFFER_DEVICE);
perror("Could not create task <Turn L>");
sys_end();
}
439,7 → 417,7
hard_task_def_usemath(mp);
pid_TR = task_create("TurnRight", turn, &mp, NULL);
if (pid_TR == NIL) {
grx_close();
FB26_close(FRAME_BUFFER_DEVICE);
perror("Could not create task <Turn R>");
sys_end();
}
454,7 → 432,7
hard_task_def_usemath(mp);
pid_SU = task_create("SpeedUP", speed, &mp, NULL);
if (pid_SU == NIL) {
grx_close();
FB26_close(FRAME_BUFFER_DEVICE);
perror("Could not create task <Speed UP>");
sys_end();
}
469,7 → 447,7
hard_task_def_usemath(mp);
pid_SD = task_create("SpeedDOWN", speed, &mp, NULL);
if (pid_SD == NIL) {
grx_close();
FB26_close(FRAME_BUFFER_DEVICE);
perror("Could not create task <Speed DOWN>");
sys_end();
}
484,7 → 462,7
hard_task_def_usemath(mp);
pid_SZ = task_create("SpeedZERO", speed, &mp, NULL);
if (pid_SZ == NIL) {
grx_close();
FB26_close(FRAME_BUFFER_DEVICE);
perror("Could not create task <Speed ZERO>");
sys_end();
}
496,7 → 474,7
hard_task_def_usemath(mp);
pid = task_create("MoveAstro", move, &mp, NULL);
if (pid == NIL) {
grx_close();
FB26_close(FRAME_BUFFER_DEVICE);
perror("Could not create task <MoveAstro>");
sys_end();
} else
513,7 → 491,7
hard_task_def_usemath(mp);
pid_FL = task_create("FlipAstro", turn, &mp, NULL);
if (pid_FL == NIL) {
grx_close();
FB26_close(FRAME_BUFFER_DEVICE);
perror("Could not create task <Flip Astro>");
sys_end();
}
549,43 → 527,51
k.flag = 0;
k.scan = KEY_SPC;
k.ascii = ' ';
keyb_hook(k,new_shot);
k.status = KEY_PRESSED;
keyb_hook(k,new_shot,FALSE);
 
k.flag = 0;
k.scan = KEY_O;
k.ascii = 'o';
keyb_hook(k,pad);
k.status = KEY_PRESSED;
keyb_hook(k,pad,FALSE);
 
k.flag = 0;
k.scan = KEY_P;
k.ascii = 'p';
keyb_hook(k,pad);
k.status = KEY_PRESSED;
keyb_hook(k,pad,FALSE);
 
k.flag = 0;
k.scan = KEY_S;
k.ascii = 's';
keyb_hook(k,pad);
k.status = KEY_PRESSED;
keyb_hook(k,pad,FALSE);
 
k.flag = 0;
k.scan = KEY_Z;
k.ascii = 'z';
keyb_hook(k,pad);
k.status = KEY_PRESSED;
keyb_hook(k,pad,FALSE);
 
#ifdef ASTRO_MOVE
k.flag = 0;
k.scan = KEY_A;
k.ascii = 'a';
keyb_hook(k,pad);
k.status = KEY_PRESSED;
keyb_hook(k,pad,FALSE);
 
k.flag = 0;
k.scan = KEY_F;
k.ascii = 'f';
keyb_hook(k,pad);
k.status = KEY_PRESSED;
keyb_hook(k,pad,FALSE);
#else
k.flag = 0;
k.scan = KEY_X;
k.ascii = 'x';
keyb_hook(k,pad);
k.status = KEY_PRESSED;
keyb_hook(k,pad,FALSE);
 
#endif
}
/demos/trunk/astro/asteroid.c
53,18 → 53,6
 
}
 
void endfun(KEY_EVT *k)
{
cprintf("Ctrl-Brk pressed! Ending...\n");
sys_end();
}
 
void my_grx_close(void *arg)
{
grx_close();
kern_printf("Graphic mode closed.\n");
}
 
void frame_main()
{
#ifdef ASTRO_MOVE
92,21 → 80,29
frame_astro();
}
 
void end_func(KEY_EVT *k) {
 
FB26_close(FRAME_BUFFER_DEVICE);
sys_end();
 
}
 
int main(int argc, char **argv)
{
KEY_EVT k;
TIME seme;
int modenum;
 
k.flag = CNTR_BIT;
k.scan = KEY_C;
k.ascii = 'c';
keyb_hook(k,endfun);
k.status = KEY_PRESSED;
keyb_hook(k,end_func,FALSE);
 
k.flag = CNTL_BIT;
k.scan = KEY_C;
k.ascii = 'c';
keyb_hook(k,endfun);
k.status = KEY_PRESSED;
keyb_hook(k,end_func,FALSE);
 
sem_init(&mx_mat,0,1);
sem_init(&mx_grf,0,1);
123,11 → 119,9
seme = sys_gettime(NULL);
srand(seme);
 
sys_atrunlevel(my_grx_close, NULL, RUNLEVEL_BEFORE_EXIT);
FB26_init();
 
grx_init();
modenum = grx_getmode(640, 480, 16);
grx_setmode(modenum);
FB26_open(FRAME_BUFFER_DEVICE);
 
frame_main();
 
/demos/trunk/astro/stat.c
1,12 → 1,8
/*
* Project: HARTIK (HA-rd R-eal TI-me K-ernel)
* Project: S.Ha.R.K.
*
* Coordinators: Giorgio Buttazzo <giorgio@sssup.it>
* Gerardo Lamastra <gerardo@sssup.it>
*
* Authors : Paolo Gai <pj@hartik.sssup.it>
* (see authors.txt for full list of hartik's authors)
*
* ReTiS Lab (Scuola Superiore S.Anna - Pisa - Italy)
*
* http://www.sssup.it
14,25 → 10,6
* http://hartik.sssup.it
*/
 
/*
* Copyright (C) 2000 Paolo Gai
*
* 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
*
*/
 
#include "asteroid.h"
#include <string.h>
 
152,7 → 129,7
soft_task_def_usemath(ms);
pid = task_create("StatWrite", stat_write, &ms, NULL);
if (pid == NIL) {
grx_close();
FB26_close(FRAME_BUFFER_DEVICE);
perror("Could not create task <StatWrite>");
sys_end();
} else
173,11 → 150,13
k.flag = 0;
k.scan = KEY_N;
k.ascii = 'n';
keyb_hook(k,new_game);
k.status = KEY_PRESSED;
keyb_hook(k,new_game,FALSE);
 
k.flag = 0;
k.scan = KEY_B;
k.ascii = 'b';
keyb_hook(k,start_game);
k.status = KEY_PRESSED;
keyb_hook(k,start_game,FALSE);
}
 
/demos/trunk/astro/makefile
12,5 → 12,5
include $(BASE)/config/example.mk
 
asteroid:
make -f $(SUBMAKE) APP=asteroid INIT= OTHEROBJS="initfile.o astro.o stat.o rock.o" SHARKOPT="__OLDCHAR__ __GRX__"
make -f $(SUBMAKE) APP=asteroid INIT= OTHEROBJS="initfile.o astro.o stat.o rock.o" SHARKOPT="__LINUXC26__ __NEWPCI__ __INPUT__ __FB__"