Subversion Repositories shark

Compare Revisions

Ignore whitespace Rev 1159 → Rev 1160

/demos/trunk/jumpball/demo.h
18,11 → 18,11
 
/**
------------
CVS : $Id: demo.h,v 1.2 2003-05-01 19:43:16 pj Exp $
CVS : $Id: demo.h,v 1.3 2003-05-05 09:21:55 pj Exp $
 
File: $File$
Revision: $Revision: 1.2 $
Last update: $Date: 2003-05-01 19:43:16 $
Revision: $Revision: 1.3 $
Last update: $Date: 2003-05-05 09:21:55 $
------------
**/
 
61,10 → 61,11
 
/* CPU Speed Selection
--------------------------------------------------------------------
400 - Pentium 2 400 MHz
133 - Pentium 1 133 MHz
1700 - Pentium 4 1.7 GHz
400 - Pentium 2 400 MHz
133 - Pentium 1 133 MHz
*/
#define CPU 133
#define CPU 1700
 
/*
*
78,6 → 79,7
#define WCET_JETSLIDE 2000
#define WCET_BALL 250
#define WCET_HARD_BALL 1000
#define BALL_DELAY 10000
#endif
 
#if CPU==400
86,8 → 88,17
#define WCET_JETSLIDE 2100
#define WCET_BALL 100
#define WCET_HARD_BALL 380
#define BALL_DELAY 10000
#endif
 
#if CPU==1700
#define WCET_JETCTRL 4500
#define WCET_JETDUMMY 100
#define WCET_JETSLIDE 1300
#define WCET_BALL 100
#define WCET_HARD_BALL 410
#define BALL_DELAY 100000
#endif
 
#define PERIOD_JETCTRL 100000
#define PERIOD_JETDUMMY 100000
149,12 → 160,12
*/
 
// x and y corners are specified whithout consider a border of 3 pixels
#define BALL_Y 450 /* position of the floor */
#define BALL_HEIGHT 385 /* initial height of the ball */
#define BALL_XMIN 10 /* min position X of the ball */
#define BALL_XMAX 370 /* max position X of the ball */
#define BALL_VELX 5. /* horizontal ball velocity */
#define BALL_VYMIN 11. /* min ground speed */
#define BALL_MAX_P 60 /* max number of balls */
#define BALL_Y 450 /* position of the floor */
#define BALL_HEIGHT 385 /* initial height of the ball */
#define BALL_XMIN 10 /* min position X of the ball */
#define BALL_XMAX 370 /* max position X of the ball */
#define BALL_VELX 5. /* horizontal ball velocity */
#define BALL_VYMIN 11. /* min ground speed */
#define BALL_MAX_P 60 /* max number of balls */
 
#define BALL_GROUP 2 /* task group of the balls */
/demos/trunk/jumpball/ball.c
18,11 → 18,11
 
/**
------------
CVS : $Id: ball.c,v 1.2 2003-05-01 19:43:16 pj Exp $
CVS : $Id: ball.c,v 1.3 2003-05-05 09:21:55 pj Exp $
 
File: $File$
Revision: $Revision: 1.2 $
Last update: $Date: 2003-05-01 19:43:16 $
Revision: $Revision: 1.3 $
Last update: $Date: 2003-05-05 09:21:55 $
------------
**/
 
46,7 → 46,7
*/
 
/*--------------------------------------------------------------*/
/* SIMULATION OF JUMPING BALLS */
/* SIMULATION OF JUMPING BALLS */
/*--------------------------------------------------------------*/
 
#include "demo.h"
53,25 → 53,35
#include <kernel/func.h>
#include <stdlib.h>
 
#define R 8 /* dimension of a ball */
#define G 9.8 /* acceleration of gravity */
#define R 8 /* dimension of a ball */
#define G 9.8 /* acceleration of gravity */
 
static int ballexit = 0;
static int npc = 0; /* number of tasks created */
static int npc = 0; /* number of tasks created */
 
/*--------------------------------------------------------------*/
/* Periodic task for ball simulation */
/* Delay function for jumping balls */
/*--------------------------------------------------------------*/
 
TASK palla(int i)
void my_delay(void)
{
int x, y; /* coordinate grafiche pallina */
int ox, oy; /* vecchia posizione pallina */
int x0, y0; /* posizione iniziale X pallina */
float vx, vy; /* velocitÂ… della pallina */
int xxx;
for (xxx=0; xxx<BALL_DELAY; xxx++);
}
 
/*--------------------------------------------------------------*/
/* Periodic task for ball simulation */
/*--------------------------------------------------------------*/
 
TASK palla(int i)
{
int x, y; /* coordinate grafiche pallina */
int ox, oy; /* vecchia posizione pallina */
int x0, y0; /* posizione iniziale X pallina */
float vx, vy; /* velocitÂ… della pallina */
float vy0; /* velocita' pallina al primo rimbalzo */
float ty, tx; /* variabile temporale */
float dt; /* incremento temporale */
float ty, tx; /* variabile temporale */
float dt; /* incremento temporale */
 
y = oy = y0 = BALL_HEIGHT;
x = ox = x0 = BALL_XMIN;
88,17 → 98,17
x = x0 + vx * tx;
 
if (y < 0) {
y = 0;
y = 0;
 
if (vy == 0.0)
vy = vy0;
else if (vy < BALL_VYMIN)
vy = vy0 * (1.0 - myrand(50)/100.0);
else
vy = 0.9 * vy;
if (vy == 0.0)
vy = vy0;
else if (vy < BALL_VYMIN)
vy = vy0 * (1.0 - myrand(50)/100.0);
else
vy = 0.9 * vy;
 
ty = 0.0;
y0 = 0;
y0 = 0;
}
 
if (x > BALL_XMAX) {
117,23 → 127,21
 
mutex_lock(&mutex);
grx_disc(ox, oy, R, 0);
ox = x;
oy = BALL_Y - y;
ox = x;
oy = BALL_Y - y;
mutex_unlock(&mutex);
 
if (ballexit && i!=0xFFFF) {
npc--;
return 0;
}
if (ballexit && i!=0xFFFF) {
npc--;
return 0;
}
 
mutex_lock(&mutex);
grx_disc(ox, oy, R, i);
mutex_unlock(&mutex);
 
{
int xxx;
for (xxx=0; xxx<10000; xxx++);
}
my_delay();
 
ty += dt;
tx += dt;
task_endcycle();
205,7 → 213,7
 
 
/*--------------------------------------------------------------*/
/* MAIN process */
/* MAIN process */
/*--------------------------------------------------------------*/
 
void scenario_ball()
215,7 → 223,7
//grx_line(0,BALL_Y-BALL_HEIGHT-6,383,BALL_Y-BALL_HEIGHT-6,red);
 
grx_rect(BALL_XMIN-R-1, BALL_Y-BALL_HEIGHT-R-1,
BALL_XMAX+R+1, BALL_Y+R+1, rgb16(0,200,0));
BALL_XMAX+R+1, BALL_Y+R+1, rgb16(0,200,0));
}
 
void init_ball(void)