Subversion Repositories shark

Rev

Rev 1550 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
1085 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
 *   (see the web pages for full authors list)
11
 *
12
 * ReTiS Lab (Scuola Superiore S.Anna - Pisa - Italy)
13
 *
14
 * http://www.sssup.it
15
 * http://retis.sssup.it
16
 * http://shark.sssup.it
17
 */
18
 
19
/**
20
 ------------
1550 pj 21
 CVS :        $Id: demo.c,v 1.8 2005-01-08 14:35:17 pj Exp $
1085 pj 22
 
23
 File:        $File$
1550 pj 24
 Revision:    $Revision: 1.8 $
25
 Last update: $Date: 2005-01-08 14:35:17 $
1085 pj 26
 ------------
27
**/
28
 
29
/*
1158 pj 30
 * Copyright (C) 2000-2003 Paolo Gai
1085 pj 31
 *
32
 * This program is free software; you can redistribute it and/or modify
33
 * it under the terms of the GNU General Public License as published by
34
 * the Free Software Foundation; either version 2 of the License, or
35
 * (at your option) any later version.
36
 *
37
 * This program is distributed in the hope that it will be useful,
38
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
39
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
40
 * GNU General Public License for more details.
41
 *
42
 * You should have received a copy of the GNU General Public License
43
 * along with this program; if not, write to the Free Software
44
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
45
 *
46
 */
47
 
48
#include "demo.h"
49
#include <kernel/func.h>
50
#include <string.h>
51
#include <stdlib.h>
52
 
53
/* useful colors... */
54
int white;
55
int black;
56
int red;
57
int gray;
58
 
1380 giacomo 59
void app_mutex_init(mutex_t *m);
60
 
1085 pj 61
static void version( void )
62
{
1158 pj 63
  cprintf( "S.Ha.R.K. Jumpball Demo 1.0\n" );
64
  cprintf( "---------------------------\n" );
1085 pj 65
  cprintf( "by Paolo Gai 1999-2001\n"   );
66
  cprintf( "   <pj@sssup.it>\n"         );
1158 pj 67
  cprintf( "---------------------------\n" );
1085 pj 68
}
69
 
70
int myrand(int x)
71
{
72
  return rand()%x;
73
}
74
 
75
void reverse(char s[])
76
{
77
  int c, i, j;
78
 
79
  for (i = 0, j = strlen(s)-1; i<j; i++, j--)
80
  {
81
    c = s[i];
82
    s[i] = s[j];
83
    s[j] = c;
84
  }
85
}
86
 
87
char * itoa(int n, char *s)
88
{
89
  int i, sign;
90
 
91
  if ((sign = n) < 0)
92
    n = -n;
93
 
94
  i = 0;
95
 
96
  do
97
  {
98
    s[i++] = n % 10 + '0';
99
  } while ((n /= 10) > 0);
100
 
101
  if (sign < 0)
102
    s[i++] = '-';
103
 
104
  s[i] = 0;
105
 
106
  reverse(s);
107
 
108
  return s;
109
}
110
 
111
 
112
void scenario()
113
{
1158 pj 114
  grx_text("S.Ha.R.K. Jumpball Demo 1.0", 0, 0, rgb16(0,255,0), black );
115
  grx_text("  by Paolo Gai 1999-2001"   , 0, 8, rgb16(0,255,0), black );
116
  grx_text("       pj@sssup.it"         , 0,16, rgb16(0,255,0), black );
1085 pj 117
 
118
  grx_text("Ctrl-C, Ctrr-C, Enter: exit"             ,320, 0, gray, black );
1158 pj 119
  grx_text("Alt-C                : void statistics"  ,320, 8, gray, black );
1085 pj 120
  grx_text("Space                : create noise ball",320,16, gray, black );
121
  grx_text("Backspace            : kill noise balls" ,320,24, gray, black );
122
 
123
 
124
  #ifdef JET_ON
125
  scenario_jetcontrol();
126
  #endif
127
 
128
  #ifdef BALL_ON
129
  scenario_ball();
130
  #endif
131
}
132
 
133
void endfun(KEY_EVT *k)
134
{
1550 pj 135
  exit(0);
1085 pj 136
}
137
 
138
void zerofun(KEY_EVT *k)
139
{
140
  int i;
141
  for (i=0; i<MAX_PROC; i++) jet_delstat(i);
142
}
143
 
144
int main(int argc, char **argv)
145
{
146
 
147
    KEY_EVT k;
148
 
1379 giacomo 149
    version();
150
 
1085 pj 151
    srand(4);
152
 
153
    k.flag = CNTR_BIT;
154
    k.scan = KEY_C;
155
    k.ascii = 'c';
1379 giacomo 156
    k.status = KEY_PRESSED;
157
    keyb_hook(k,endfun,FALSE);
1085 pj 158
    k.flag = CNTL_BIT;
159
    k.scan = KEY_C;
160
    k.ascii = 'c';
1379 giacomo 161
    k.status = KEY_PRESSED;
162
    keyb_hook(k,endfun,FALSE);
1085 pj 163
    k.flag = ALTL_BIT;
164
    k.scan = KEY_C;
165
    k.ascii = 'c';
1379 giacomo 166
    k.status = KEY_PRESSED;
167
    keyb_hook(k,zerofun,FALSE);
1085 pj 168
    k.flag = 0;
169
    k.scan = KEY_ENT;
170
    k.ascii = 13;
1379 giacomo 171
    k.status = KEY_PRESSED;
172
    keyb_hook(k,endfun,FALSE);
1085 pj 173
 
1380 giacomo 174
    /* init the graphic mutex */
175
    app_mutex_init(&mutex);
176
 
1085 pj 177
    /* useful colors ... */
178
    white = rgb16(255,255,255);
179
    black = rgb16(0,0,0);
180
    red   = rgb16(255,0,0);
181
    gray  = rgb16(128,128,128);
182
 
183
    scenario();
184
 
185
    #ifdef JET_ON
186
    init_jetcontrol();
187
    #endif
188
 
189
    #ifdef BALL_ON
190
    init_ball();
191
    #endif
192
 
193
    group_activate(1);
194
 
195
    return 0;
196
}
197
 
198