/demos/trunk/astro/rock.c |
---|
17,6 → 17,8 |
int kill_rock; |
rock_pos rocks[ROCK_NMAX]; |
extern volatile int shark_running; |
void draw_rock(int x, int y, int r, int c) |
{ |
sem_wait(&mx_grf); |
269,9 → 271,8 |
soft_task_def_usemath(ms); |
pid_RC = task_create("RockCreator", rock_creator, &ms, NULL); |
if (pid_RC == NIL) { |
FB26_close(FRAME_BUFFER_DEVICE); |
perror("Could not create task <RockCreator>"); |
sys_end(); |
shark_running = 0; |
} else |
task_activate(pid_RC); |
} |
/demos/trunk/astro/asteroid.h |
---|
16,6 → 16,9 |
#include "modules/sem.h" |
#include "modules/hartport.h" |
#include <drivers/shark_pci26.h> |
#include <drivers/shark_linuxc26.h> |
#include <drivers/shark_input26.h> |
#include <drivers/shark_keyb26.h> |
#include <drivers/shark_fb26.h> |
/demos/trunk/astro/initfile.c |
---|
10,7 → 10,6 |
* http://hartik.sssup.it |
*/ |
#include "asteroid.h" |
#include "kernel/kern.h" |
#include "modules/edf.h" |
#include "modules/hardcbs.h" |
18,9 → 17,8 |
#include "modules/dummy.h" |
#include "modules/intdrive.h" |
#include <drivers/shark_linuxc26.h> |
#include <drivers/shark_input26.h> |
#include <drivers/shark_keyb26.h> |
#include "modules/sem.h" |
#include "modules/hartport.h" |
/*+ sysyem tick in us +*/ |
#define TICK 0 |
33,16 → 31,6 |
#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; |
62,18 → 50,8 |
{ |
struct multiboot_info *mb = (struct multiboot_info *)arg; |
KEYB_PARMS kparms = BASE_KEYB; |
keyb_def_ctrlC(kparms, NULL); |
HARTPORT_init(); |
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 |
---|
24,6 → 24,8 |
rock_ini rock_new; |
extern volatile int shark_running; |
TASK shot(int i) |
{ |
int x, y; /* shot graphic position */ |
371,9 → 373,8 |
soft_task_def_usemath(ms); |
pid = task_create("Astro", astro, &ms, NULL); |
if (pid == NIL) { |
FB26_close(FRAME_BUFFER_DEVICE); |
perror("Could not create task <astro>"); |
sys_end(); |
shark_running = 0; |
} else |
task_activate(pid); |
384,9 → 385,8 |
hard_task_def_usemath(mp); |
pid = task_create("Taken", look, &mp, NULL); |
if (pid == NIL) { |
FB26_close(FRAME_BUFFER_DEVICE); |
perror("Could not create task <Taken>"); |
sys_end(); |
shark_running = 0; |
} else |
task_activate(pid); |
400,9 → 400,8 |
hard_task_def_usemath(mp); |
pid_TL = task_create("TurnLeft", turn, &mp, NULL); |
if (pid_TL == NIL) { |
FB26_close(FRAME_BUFFER_DEVICE); |
perror("Could not create task <Turn L>"); |
sys_end(); |
shark_running = 0; |
} |
incr = - ASTRO_GRAD_INC; |
415,9 → 414,8 |
hard_task_def_usemath(mp); |
pid_TR = task_create("TurnRight", turn, &mp, NULL); |
if (pid_TR == NIL) { |
FB26_close(FRAME_BUFFER_DEVICE); |
perror("Could not create task <Turn R>"); |
sys_end(); |
shark_running = 0; |
} |
incr = ASTRO_VEL_INC; |
430,9 → 428,8 |
hard_task_def_usemath(mp); |
pid_SU = task_create("SpeedUP", speed, &mp, NULL); |
if (pid_SU == NIL) { |
FB26_close(FRAME_BUFFER_DEVICE); |
perror("Could not create task <Speed UP>"); |
sys_end(); |
shark_running = 0; |
} |
incr = - ASTRO_VEL_INC; |
445,9 → 442,8 |
hard_task_def_usemath(mp); |
pid_SD = task_create("SpeedDOWN", speed, &mp, NULL); |
if (pid_SD == NIL) { |
FB26_close(FRAME_BUFFER_DEVICE); |
perror("Could not create task <Speed DOWN>"); |
sys_end(); |
shark_running = 0; |
} |
incr = 0; |
460,9 → 456,8 |
hard_task_def_usemath(mp); |
pid_SZ = task_create("SpeedZERO", speed, &mp, NULL); |
if (pid_SZ == NIL) { |
FB26_close(FRAME_BUFFER_DEVICE); |
perror("Could not create task <Speed ZERO>"); |
sys_end(); |
shark_running = 0; |
} |
hard_task_default_model(mp); |
472,9 → 467,8 |
hard_task_def_usemath(mp); |
pid = task_create("MoveAstro", move, &mp, NULL); |
if (pid == NIL) { |
FB26_close(FRAME_BUFFER_DEVICE); |
perror("Could not create task <MoveAstro>"); |
sys_end(); |
shark_running = 0; |
} else |
task_activate(pid); |
489,9 → 483,8 |
hard_task_def_usemath(mp); |
pid_FL = task_create("FlipAstro", turn, &mp, NULL); |
if (pid_FL == NIL) { |
FB26_close(FRAME_BUFFER_DEVICE); |
perror("Could not create task <Flip Astro>"); |
sys_end(); |
shark_running = 0; |
} |
#endif |
} |
/demos/trunk/astro/asteroid.c |
---|
16,6 → 16,8 |
sem_t mx_mat, mx_grf, mx_pos, mx_vel, mx_xy, mx_rk, mx_rn; /* mutex semaphores */ |
sem_t mx_st_nrg, mx_st_scr, mx_st_kil, mx_st_liv; /* mutex semaphores */ |
volatile int shark_running = 1; |
double dist_xy(int x1, int y1, int x2, int y2) |
{ |
double dst; |
63,16 → 65,54 |
void end_func(KEY_EVT *k) { |
shark_running = 0; |
} |
int device_drivers_close() { |
FB26_close(FRAME_BUFFER_DEVICE); |
sys_end(); |
KEYB26_close(); |
INPUT26_close(); |
return 0; |
} |
int device_drivers_init() { |
KEYB_PARMS kparms = BASE_KEYB; |
LINUXC26_register_module(); |
PCI26_init(); |
INPUT26_init(); |
keyb_def_ctrlC(kparms, NULL); |
KEYB26_init(&kparms); |
FB26_init(); |
FB26_open(FRAME_BUFFER_DEVICE); |
FB26_use_grx(FRAME_BUFFER_DEVICE); |
FB26_setmode(FRAME_BUFFER_DEVICE,"640x480-16"); |
return 0; |
} |
int main(int argc, char **argv) |
{ |
KEY_EVT k; |
TIME seme; |
device_drivers_init(); |
k.flag = CNTR_BIT; |
k.scan = KEY_C; |
k.ascii = 'c'; |
100,14 → 140,6 |
seme = sys_gettime(NULL); |
srand(seme); |
FB26_init(); |
FB26_open(FRAME_BUFFER_DEVICE); |
FB26_use_grx(FRAME_BUFFER_DEVICE); |
FB26_setmode(FRAME_BUFFER_DEVICE,"640x480-16"); |
frame_main(); |
init_stat(); |
114,5 → 146,12 |
init_astro(); |
init_rock(); |
while(shark_running); |
device_drivers_close(); |
sys_end(); |
return 0; |
} |
/demos/trunk/astro/stat.c |
---|
19,6 → 19,8 |
int lives; /* current player lives */ |
int crash; /* astro vs. rock */ |
extern volatile int shark_running; |
TASK stat_write() |
{ |
char st[20]; |
128,9 → 130,8 |
soft_task_def_usemath(ms); |
pid = task_create("StatWrite", stat_write, &ms, NULL); |
if (pid == NIL) { |
FB26_close(FRAME_BUFFER_DEVICE); |
perror("Could not create task <StatWrite>"); |
sys_end(); |
shark_running = 0; |
} else |
task_activate(pid); |
} |