rev |
line source |
nuclear@0
|
1 #include <SDL/SDL.h>
|
nuclear@0
|
2 #include <math.h>
|
nuclear@0
|
3
|
nuclear@0
|
4 #include "main.h"
|
nuclear@0
|
5 #include "bitfonts.h"
|
nuclear@0
|
6
|
nuclear@0
|
7 #include "blitting.h"
|
nuclear@0
|
8 #include "plasma.h"
|
nuclear@0
|
9 #include "rotozoomer.h"
|
nuclear@0
|
10 #include "radialblur.h"
|
nuclear@0
|
11 #include "bunny3d.h"
|
nuclear@0
|
12 #include "render3d.h"
|
nuclear@0
|
13
|
nuclear@0
|
14 #if defined ProjectCaanoo || defined ProjectWiz
|
nuclear@0
|
15 #include <unistd.h>
|
nuclear@0
|
16 #endif
|
nuclear@0
|
17
|
nuclear@0
|
18 #ifdef ProjectWin
|
nuclear@0
|
19 #undef main
|
nuclear@0
|
20 #endif
|
nuclear@0
|
21
|
nuclear@0
|
22 SDL_Surface *screen = NULL;
|
nuclear@0
|
23 SDL_Joystick *joy = NULL;
|
nuclear@0
|
24
|
nuclear@0
|
25 int fps = 0, pframe = 0, nframe = 0, atime = 0;
|
nuclear@0
|
26 int frametime = 0;
|
nuclear@0
|
27 int quit = 0;
|
nuclear@0
|
28 int desc_next = 0;
|
nuclear@0
|
29
|
nuclear@0
|
30 int where_is = MENU;
|
nuclear@0
|
31
|
nuclear@0
|
32 // -------------------------------------
|
nuclear@0
|
33
|
nuclear@0
|
34 char sbuffer[256];
|
nuclear@0
|
35 unsigned char fonts[59*64];
|
nuclear@0
|
36
|
nuclear@0
|
37 void InitFonts()
|
nuclear@0
|
38 {
|
nuclear@0
|
39 int i = 0;
|
nuclear@0
|
40 for (int n=0; n<59; n++)
|
nuclear@0
|
41 {
|
nuclear@0
|
42 for (int y=0; y<8; y++)
|
nuclear@0
|
43 {
|
nuclear@0
|
44 int c = bitfonts[i++];
|
nuclear@0
|
45 for (int x=0; x<8; x++)
|
nuclear@0
|
46 {
|
nuclear@0
|
47 fonts[(n << 6) + x + (y<<3)] = ((c >> (7 - x)) & 1) * 255;
|
nuclear@0
|
48 }
|
nuclear@0
|
49 }
|
nuclear@0
|
50 }
|
nuclear@0
|
51 }
|
nuclear@0
|
52
|
nuclear@0
|
53 void DrawFontX2(int xp, int yp, int ch, unsigned short *vram)
|
nuclear@0
|
54 {
|
nuclear@0
|
55 if (xp <0 || xp > 312) return;
|
nuclear@0
|
56 vram += xp + yp * ScreenWidth;
|
nuclear@0
|
57 for (int y=0; y<8; y++)
|
nuclear@0
|
58 {
|
nuclear@0
|
59 int yc = yp + y;
|
nuclear@0
|
60 if ((yc>=1) && (yc<ScreenHeight - 1))
|
nuclear@0
|
61 {
|
nuclear@0
|
62 int yi = y << 3;
|
nuclear@0
|
63 for (int x=0; x<8; x++)
|
nuclear@0
|
64 {
|
nuclear@0
|
65 unsigned char c = fonts[(ch << 6) + yi + x] * 0x01010101;
|
nuclear@0
|
66 *vram |= c;
|
nuclear@0
|
67 *(vram+1) |= c;
|
nuclear@0
|
68 *(vram+ScreenWidth) |= c;
|
nuclear@0
|
69 *(vram+ScreenWidth+1) |= c;
|
nuclear@0
|
70 vram+=2;
|
nuclear@0
|
71 }
|
nuclear@0
|
72 vram-=16;
|
nuclear@0
|
73 }
|
nuclear@0
|
74 vram+=2*ScreenWidth;
|
nuclear@0
|
75 }
|
nuclear@0
|
76 }
|
nuclear@0
|
77
|
nuclear@0
|
78 void DrawFont(int xp, int yp, int ch, unsigned short *vram)
|
nuclear@0
|
79 {
|
nuclear@0
|
80 if (xp <0 || xp > 312) return;
|
nuclear@0
|
81 vram += xp + yp * ScreenWidth;
|
nuclear@0
|
82 for (int y=0; y<8; y++)
|
nuclear@0
|
83 {
|
nuclear@0
|
84 int yc = yp + y;
|
nuclear@0
|
85 if ((yc>=1) && (yc<ScreenHeight - 1))
|
nuclear@0
|
86 {
|
nuclear@0
|
87 int yi = y << 3;
|
nuclear@0
|
88 for (int x=0; x<8; x++)
|
nuclear@0
|
89 {
|
nuclear@0
|
90 *vram++ |= (fonts[(ch << 6) + yi + x] * 0x01010101);
|
nuclear@0
|
91 }
|
nuclear@0
|
92 vram-=8;
|
nuclear@0
|
93 }
|
nuclear@0
|
94 vram+=ScreenWidth;
|
nuclear@0
|
95 }
|
nuclear@0
|
96 }
|
nuclear@0
|
97
|
nuclear@0
|
98 void DrawText(int xtp, int ytp, int cn, bool zoom, char *text, unsigned short *vram)
|
nuclear@0
|
99 {
|
nuclear@0
|
100 for (int n = 0; n<cn; n++)
|
nuclear@0
|
101 {
|
nuclear@0
|
102 char c = *text++;
|
nuclear@0
|
103 if (c>96 && c<123) c-=32;
|
nuclear@0
|
104
|
nuclear@0
|
105 if (!zoom)
|
nuclear@0
|
106 {
|
nuclear@0
|
107 if (c>31 && c<92) DrawFont(xtp, ytp, c - 32, vram);
|
nuclear@0
|
108 else if (c==0) n = cn;
|
nuclear@0
|
109 xtp+=8; if (xtp>ScreenWidth -8 -1) n = cn;
|
nuclear@0
|
110 }
|
nuclear@0
|
111 else
|
nuclear@0
|
112 {
|
nuclear@0
|
113 if (c>31 && c<92) DrawFontX2(xtp, ytp, c - 32, vram);
|
nuclear@0
|
114 else if (c==0) n = cn;
|
nuclear@0
|
115 xtp+=16; if (xtp>ScreenWidth -16 -1) n = cn;
|
nuclear@0
|
116 }
|
nuclear@0
|
117 }
|
nuclear@0
|
118 }
|
nuclear@0
|
119
|
nuclear@0
|
120 void ShowFPS(unsigned short *vram)
|
nuclear@0
|
121 {
|
nuclear@0
|
122 if (SDL_GetTicks() - atime >= 1000)
|
nuclear@0
|
123 {
|
nuclear@0
|
124 atime = SDL_GetTicks();
|
nuclear@0
|
125 fps = nframe - pframe;
|
nuclear@0
|
126 pframe = nframe;
|
nuclear@0
|
127 }
|
nuclear@0
|
128 sprintf(sbuffer, "FPS = %d", fps);
|
nuclear@0
|
129 DrawText(8, 8, 16, false, sbuffer, vram);
|
nuclear@0
|
130 }
|
nuclear@0
|
131
|
nuclear@0
|
132 void ClearScreen(unsigned short *vram)
|
nuclear@0
|
133 {
|
nuclear@0
|
134 memset(vram, 0, 2*ScreenSize);
|
nuclear@0
|
135 }
|
nuclear@0
|
136
|
nuclear@0
|
137 void speeddown(int ticks)
|
nuclear@0
|
138 {
|
nuclear@0
|
139 do{}while(SDL_GetTicks() - frametime < ticks);
|
nuclear@0
|
140 frametime = SDL_GetTicks();
|
nuclear@0
|
141 }
|
nuclear@0
|
142
|
nuclear@0
|
143 // -------------------------------------
|
nuclear@0
|
144
|
nuclear@0
|
145 void InitEffects()
|
nuclear@0
|
146 {
|
nuclear@0
|
147 InitBlitting();
|
nuclear@0
|
148 InitPlasma();
|
nuclear@0
|
149 InitRotozoomer();
|
nuclear@0
|
150 InitRadialblur();
|
nuclear@0
|
151
|
nuclear@0
|
152 initRender3D();
|
nuclear@0
|
153 InitBunny3D();
|
nuclear@0
|
154 }
|
nuclear@0
|
155
|
nuclear@0
|
156 void Init()
|
nuclear@0
|
157 {
|
nuclear@0
|
158 SDL_Init (SDL_INIT_VIDEO | SDL_INIT_JOYSTICK);
|
nuclear@0
|
159 SDL_ShowCursor(SDL_DISABLE);
|
nuclear@0
|
160 screen = SDL_SetVideoMode (ScreenWidth, ScreenHeight, 16, SDL_SWSURFACE);
|
nuclear@0
|
161
|
nuclear@0
|
162 if (SDL_NumJoysticks() > 0)
|
nuclear@0
|
163 joy = SDL_JoystickOpen(0);
|
nuclear@0
|
164
|
nuclear@0
|
165 InitFonts();
|
nuclear@0
|
166 InitEffects();
|
nuclear@0
|
167 }
|
nuclear@0
|
168
|
nuclear@0
|
169 void KeyCommands()
|
nuclear@0
|
170 {
|
nuclear@0
|
171 SDL_Event event;
|
nuclear@0
|
172
|
nuclear@0
|
173 #ifdef ProjectWin
|
nuclear@0
|
174 while (SDL_PollEvent (&event))
|
nuclear@0
|
175 {
|
nuclear@0
|
176 switch (event.type)
|
nuclear@0
|
177 {
|
nuclear@0
|
178 case SDL_KEYDOWN:
|
nuclear@0
|
179 if (event.key.keysym.sym==SDLK_ESCAPE)
|
nuclear@0
|
180 {
|
nuclear@0
|
181 if (where_is==RES)
|
nuclear@0
|
182 quit = 1;
|
nuclear@0
|
183 else if (where_is==BENCH)
|
nuclear@0
|
184 where_is = RES;
|
nuclear@0
|
185 }
|
nuclear@0
|
186 if (event.key.keysym.sym==SDLK_SPACE)
|
nuclear@0
|
187 if (where_is==DESC)
|
nuclear@0
|
188 desc_next = 1;
|
nuclear@0
|
189 break;
|
nuclear@0
|
190
|
nuclear@0
|
191 case SDL_QUIT:
|
nuclear@0
|
192 quit = 1;
|
nuclear@0
|
193 break;
|
nuclear@0
|
194
|
nuclear@0
|
195 default:
|
nuclear@0
|
196 break;
|
nuclear@0
|
197 }
|
nuclear@0
|
198 }
|
nuclear@0
|
199 #else
|
nuclear@0
|
200 while (SDL_PollEvent (&event))
|
nuclear@0
|
201 {
|
nuclear@0
|
202 switch (event.type)
|
nuclear@0
|
203 {
|
nuclear@0
|
204 case SDL_JOYBUTTONDOWN:
|
nuclear@0
|
205 if ( event.jbutton.button == BUTTON_HOME )
|
nuclear@0
|
206 {
|
nuclear@0
|
207 if (where_is==RES)
|
nuclear@0
|
208 quit = 1;
|
nuclear@0
|
209 else if (where_is==BENCH)
|
nuclear@0
|
210 where_is = RES;
|
nuclear@0
|
211 }
|
nuclear@0
|
212
|
nuclear@0
|
213 if (event.jbutton.button==BUTTON_A)
|
nuclear@0
|
214 if (where_is==DESC)
|
nuclear@0
|
215 desc_next = 1;
|
nuclear@0
|
216 break;
|
nuclear@0
|
217 }
|
nuclear@0
|
218 }
|
nuclear@0
|
219 #endif
|
nuclear@0
|
220 }
|
nuclear@0
|
221
|
nuclear@0
|
222 // -------------------------------------
|
nuclear@0
|
223
|
nuclear@0
|
224 char* test_name[NUM_TESTS];
|
nuclear@0
|
225 char* test_description[NUM_TESTS];
|
nuclear@0
|
226 int total_frames[NUM_TESTS];
|
nuclear@0
|
227 int start_frames[NUM_TESTS+1];
|
nuclear@0
|
228 float test_fps[NUM_TESTS];
|
nuclear@0
|
229
|
nuclear@0
|
230 int test_time_start;
|
nuclear@0
|
231
|
nuclear@0
|
232 void InitBench()
|
nuclear@0
|
233 {
|
nuclear@0
|
234 nframe = 0;
|
nuclear@0
|
235
|
nuclear@0
|
236 test_name[TEST_BLITTING] = "Blitting Test";
|
nuclear@0
|
237 test_description[TEST_BLITTING] = "A simple memset blitting test. Tests how fast it is to write stuff to the video ram.";
|
nuclear@0
|
238 total_frames[TEST_BLITTING] = 3000;
|
nuclear@0
|
239
|
nuclear@0
|
240 test_name[TEST_PLASMA] = "Plasma";
|
nuclear@0
|
241 test_description[TEST_PLASMA] = "A lightweight demo effect. Addition of integer sine values read from small LUTs.";
|
nuclear@0
|
242 total_frames[TEST_PLASMA] = 3000;
|
nuclear@0
|
243
|
nuclear@0
|
244 test_name[TEST_ROTOZOOMER] = "Rotozoomer";
|
nuclear@0
|
245 test_description[TEST_ROTOZOOMER] = "Rotozoomer test 1. Zooming in and out.";
|
nuclear@0
|
246 total_frames[TEST_ROTOZOOMER] = 2000;
|
nuclear@0
|
247
|
nuclear@0
|
248 test_name[TEST_ROTOZOOMER_NEAR] = "Rotozoomer Near";
|
nuclear@0
|
249 test_description[TEST_ROTOZOOMER_NEAR] = "Rotozoomer test 2. Close up, optimum speed, cache does not affect.";
|
nuclear@0
|
250 total_frames[TEST_ROTOZOOMER_NEAR] = 2500;
|
nuclear@0
|
251
|
nuclear@0
|
252 test_name[TEST_ROTOZOOMER_FAR] = "Rotozoomer Far";
|
nuclear@0
|
253 test_description[TEST_ROTOZOOMER_FAR] = "Rotozoomer test 3. Far in the distance. Slowest version because of cache misses. Good tests for cache performance.";
|
nuclear@0
|
254 total_frames[TEST_ROTOZOOMER_FAR] = 1500;
|
nuclear@0
|
255
|
nuclear@0
|
256 test_name[TEST_RADIALBLUR] = "Radial Blur";
|
nuclear@0
|
257 test_description[TEST_RADIALBLUR] = "A true RGB effect with lot's of reads and huge arrays. The way this effect was written is not cache friendly and that could be also a good test for cache or memory read performance.";
|
nuclear@0
|
258 total_frames[TEST_RADIALBLUR] = 500;
|
nuclear@0
|
259
|
nuclear@0
|
260 test_name[TEST_BUNNY3D] = "3D Bunny";
|
nuclear@0
|
261 test_description[TEST_BUNNY3D] = "This is a massive model (69451 polygons) and a total overkill for most handhelds. Also, this is software rendering.";
|
nuclear@0
|
262 total_frames[TEST_BUNNY3D] = 80;
|
nuclear@0
|
263
|
nuclear@0
|
264 int sum_frames = 0;
|
nuclear@0
|
265 int i = 0;
|
nuclear@0
|
266 for (i=0; i<NUM_TESTS; i++)
|
nuclear@0
|
267 {
|
nuclear@0
|
268 test_fps[i] = 0;
|
nuclear@0
|
269 start_frames[i] = sum_frames;
|
nuclear@0
|
270 sum_frames += total_frames[i];
|
nuclear@0
|
271 }
|
nuclear@0
|
272 start_frames[i] = sum_frames;
|
nuclear@0
|
273 }
|
nuclear@0
|
274
|
nuclear@0
|
275 void RasterScreen(int ntime, int sr, int sg, int sb, unsigned short *vram)
|
nuclear@0
|
276 {
|
nuclear@0
|
277 float t = (float)ntime / 4.0f;
|
nuclear@0
|
278
|
nuclear@0
|
279 for (int y=0; y<ScreenHeight; y++)
|
nuclear@0
|
280 {
|
nuclear@0
|
281 int yp = (int)(sin((y+4*t)/15.0f)*cos((y-3*t)/63.0f)*15 + 16);
|
nuclear@0
|
282 for (int x=0; x<ScreenWidth; x++)
|
nuclear@0
|
283 {
|
nuclear@0
|
284 *vram++ = ((yp>>sr)<<11) | (((yp << 1)>>sg) << 5) | (yp>>sb);
|
nuclear@0
|
285 }
|
nuclear@0
|
286 }
|
nuclear@0
|
287 }
|
nuclear@0
|
288
|
nuclear@0
|
289 void SquaresScreen(int ntime, unsigned short *vram)
|
nuclear@0
|
290 {
|
nuclear@0
|
291 int t = ntime >> 1;
|
nuclear@0
|
292
|
nuclear@0
|
293 for (int y=0; y<ScreenHeight; y++)
|
nuclear@0
|
294 {
|
nuclear@0
|
295 for (int x=0; x<ScreenWidth; x++)
|
nuclear@0
|
296 {
|
nuclear@0
|
297 int c = (((x - t) & 15)==0 || ((y - t) & 15)==0) * 15;
|
nuclear@0
|
298 *vram++ = ((c>>3)<<11) | (((c << 1)>>2) << 5) | (c>>1);
|
nuclear@0
|
299 }
|
nuclear@0
|
300 }
|
nuclear@0
|
301 }
|
nuclear@0
|
302
|
nuclear@0
|
303 void RenderTestDescription(int test_num, int ntime, unsigned short *vram)
|
nuclear@0
|
304 {
|
nuclear@0
|
305 sprintf(sbuffer, test_name[test_num]);
|
nuclear@0
|
306 DrawText(8, 8, 16, true, sbuffer, vram);
|
nuclear@0
|
307
|
nuclear@0
|
308 sprintf(sbuffer, test_description[test_num]);
|
nuclear@0
|
309 DrawText(384 - 4 * ntime, 160, 256, false, sbuffer, vram);
|
nuclear@0
|
310 }
|
nuclear@0
|
311
|
nuclear@0
|
312 void DrawBar(int char_y, float percentage, unsigned short *vram)
|
nuclear@0
|
313 {
|
nuclear@0
|
314 int xp = (int)((ScreenWidth - 4) * percentage);
|
nuclear@0
|
315
|
nuclear@0
|
316 unsigned short cbar = (7 << 11) | (31 << 5) | 15;
|
nuclear@0
|
317
|
nuclear@0
|
318 for (int y=0; y<9; y++)
|
nuclear@0
|
319 {
|
nuclear@0
|
320 int yi = char_y * 11 + y + 2;
|
nuclear@0
|
321 for (int x=0; x<=xp; x++)
|
nuclear@0
|
322 {
|
nuclear@0
|
323 int xi = 2 + x;
|
nuclear@0
|
324 int i = yi * ScreenWidth + xi;
|
nuclear@0
|
325 *(vram + i) |= cbar;
|
nuclear@0
|
326 }
|
nuclear@0
|
327 }
|
nuclear@0
|
328 }
|
nuclear@0
|
329
|
nuclear@0
|
330 void RenderTestResults(int ntime, float res_max, unsigned short *vram)
|
nuclear@0
|
331 {
|
nuclear@0
|
332 int tmaxframe = 64;
|
nuclear@0
|
333 float tscale = (float)ntime / float(tmaxframe);
|
nuclear@0
|
334 if (tscale > 1.0f) tscale = 1.0f;
|
nuclear@0
|
335
|
nuclear@0
|
336 for (int i=0; i<NUM_TESTS; i++)
|
nuclear@0
|
337 {
|
nuclear@0
|
338 sprintf(sbuffer, "%s", test_name[i]);
|
nuclear@0
|
339 DrawText(8, i * 11 + 3, 32, false, sbuffer, vram);
|
nuclear@0
|
340
|
nuclear@0
|
341 sprintf(sbuffer, "%.1f", test_fps[i]);
|
nuclear@0
|
342 DrawText(256, i * 11 + 3, 32, false, sbuffer, vram);
|
nuclear@0
|
343
|
nuclear@0
|
344 DrawBar(i, (test_fps[i] / res_max) * tscale, vram);
|
nuclear@0
|
345 }
|
nuclear@0
|
346 }
|
nuclear@0
|
347
|
nuclear@0
|
348 void show_test_description(int test_num, unsigned short *vram)
|
nuclear@0
|
349 {
|
nuclear@0
|
350 where_is = DESC;
|
nuclear@0
|
351
|
nuclear@0
|
352 int tframe = 0;
|
nuclear@0
|
353 desc_next = 0;
|
nuclear@0
|
354
|
nuclear@0
|
355 srand(SDL_GetTicks());
|
nuclear@0
|
356
|
nuclear@0
|
357 int sr = (rand() % 2) + 1;
|
nuclear@0
|
358 int sg = (rand() % 2) + 1;
|
nuclear@0
|
359 int sb = (rand() % 2) + 1;
|
nuclear@0
|
360
|
nuclear@0
|
361 int l = 2 * strlen(test_description[test_num]) + 2 * 56;
|
nuclear@0
|
362
|
nuclear@0
|
363 while (!desc_next && tframe < l)
|
nuclear@0
|
364 {
|
nuclear@0
|
365 RasterScreen(tframe, sr, sg, sb, vram);
|
nuclear@0
|
366 RenderTestDescription(test_num, tframe, vram);
|
nuclear@0
|
367 SDL_Flip(screen);
|
nuclear@0
|
368 speeddown(20);
|
nuclear@0
|
369 KeyCommands();
|
nuclear@0
|
370 tframe++;
|
nuclear@0
|
371 }
|
nuclear@0
|
372 }
|
nuclear@0
|
373
|
nuclear@0
|
374 float find_max_result()
|
nuclear@0
|
375 {
|
nuclear@0
|
376 float max = 0.0f;
|
nuclear@0
|
377 for (int i=0; i<NUM_TESTS; i++)
|
nuclear@0
|
378 {
|
nuclear@0
|
379 if (test_fps[i] > max) max = test_fps[i];
|
nuclear@0
|
380 }
|
nuclear@0
|
381
|
nuclear@0
|
382 return max;
|
nuclear@0
|
383 }
|
nuclear@0
|
384
|
nuclear@0
|
385 void show_test_results(unsigned short *vram)
|
nuclear@0
|
386 {
|
nuclear@0
|
387 where_is = RES;
|
nuclear@0
|
388
|
nuclear@0
|
389 int tframe = 0;
|
nuclear@0
|
390
|
nuclear@0
|
391 float fmax = find_max_result();
|
nuclear@0
|
392
|
nuclear@0
|
393 while (!quit)
|
nuclear@0
|
394 {
|
nuclear@0
|
395 SquaresScreen(tframe, vram);
|
nuclear@0
|
396 RenderTestResults(tframe, fmax, vram);
|
nuclear@0
|
397 SDL_Flip(screen);
|
nuclear@0
|
398 speeddown(20);
|
nuclear@0
|
399 KeyCommands();
|
nuclear@0
|
400 tframe++;
|
nuclear@0
|
401 }
|
nuclear@0
|
402 }
|
nuclear@0
|
403
|
nuclear@0
|
404
|
nuclear@0
|
405 void RunBenchScript(int ntime, unsigned short *vram)
|
nuclear@0
|
406 {
|
nuclear@0
|
407 for (int i=0; i<=NUM_TESTS; i++)
|
nuclear@0
|
408 {
|
nuclear@0
|
409 if (nframe == start_frames[i])
|
nuclear@0
|
410 {
|
nuclear@0
|
411 if (i<NUM_TESTS)
|
nuclear@0
|
412 show_test_description(i, vram);
|
nuclear@0
|
413
|
nuclear@0
|
414 test_time_start = SDL_GetTicks();
|
nuclear@0
|
415 }
|
nuclear@0
|
416
|
nuclear@0
|
417 if (nframe == start_frames[i]-1)
|
nuclear@0
|
418 test_fps[i-1] = (float)total_frames[i-1] / ((float)(SDL_GetTicks() - test_time_start) / 1000.0f);
|
nuclear@0
|
419 }
|
nuclear@0
|
420
|
nuclear@0
|
421 if (where_is==RES)
|
nuclear@0
|
422 show_test_results(vram);
|
nuclear@0
|
423
|
nuclear@0
|
424 if (nframe >= start_frames[TEST_BLITTING] && nframe < start_frames[TEST_PLASMA])
|
nuclear@0
|
425 {
|
nuclear@0
|
426 RunBlitting(ntime, vram);
|
nuclear@0
|
427 }
|
nuclear@0
|
428 else if (nframe >= start_frames[TEST_PLASMA] && nframe < start_frames[TEST_ROTOZOOMER])
|
nuclear@0
|
429 {
|
nuclear@0
|
430 RunPlasma(ntime, vram);
|
nuclear@0
|
431 }
|
nuclear@0
|
432 else if (nframe >= start_frames[TEST_ROTOZOOMER] && nframe < start_frames[TEST_ROTOZOOMER_NEAR])
|
nuclear@0
|
433 {
|
nuclear@0
|
434 RunRotozoomerNormal(ntime, vram);
|
nuclear@0
|
435 }
|
nuclear@0
|
436 else if (nframe >= start_frames[TEST_ROTOZOOMER_NEAR] && nframe < start_frames[TEST_ROTOZOOMER_FAR])
|
nuclear@0
|
437 {
|
nuclear@0
|
438 RunRotozoomerNear(ntime, vram);
|
nuclear@0
|
439 }
|
nuclear@0
|
440 else if (nframe >= start_frames[TEST_ROTOZOOMER_FAR] && nframe < start_frames[TEST_RADIALBLUR])
|
nuclear@0
|
441 {
|
nuclear@0
|
442 RunRotozoomerFar(ntime, vram);
|
nuclear@0
|
443 }
|
nuclear@0
|
444 else if (nframe >= start_frames[TEST_RADIALBLUR] && nframe < start_frames[TEST_BUNNY3D])
|
nuclear@0
|
445 {
|
nuclear@0
|
446 RunRadialblur(ntime, vram);
|
nuclear@0
|
447 }
|
nuclear@0
|
448 else if (nframe >= start_frames[TEST_BUNNY3D] && nframe < start_frames[NUM_TESTS])
|
nuclear@0
|
449 {
|
nuclear@0
|
450 RunBunny3D(ntime, vram);
|
nuclear@0
|
451 }
|
nuclear@0
|
452 else
|
nuclear@0
|
453 {
|
nuclear@0
|
454 show_test_results(vram);
|
nuclear@0
|
455 }
|
nuclear@0
|
456 }
|
nuclear@0
|
457
|
nuclear@0
|
458 void RunBench()
|
nuclear@0
|
459 {
|
nuclear@0
|
460 while (!quit)
|
nuclear@0
|
461 {
|
nuclear@0
|
462 where_is = BENCH;
|
nuclear@0
|
463 KeyCommands();
|
nuclear@0
|
464
|
nuclear@0
|
465 unsigned short *vram = (unsigned short*)screen->pixels;
|
nuclear@0
|
466 RunBenchScript(nframe, vram);
|
nuclear@0
|
467
|
nuclear@0
|
468 ShowFPS(vram);
|
nuclear@0
|
469
|
nuclear@0
|
470 SDL_Flip(screen);
|
nuclear@0
|
471 nframe++;
|
nuclear@0
|
472 }
|
nuclear@0
|
473 }
|
nuclear@0
|
474
|
nuclear@0
|
475 void BackToSystem()
|
nuclear@0
|
476 {
|
nuclear@0
|
477 #if defined ProjectCaanoo || defined ProjectWiz
|
nuclear@0
|
478 SDL_Quit();
|
nuclear@0
|
479 chdir("/usr/gp2x");
|
nuclear@0
|
480 execl("/usr/gp2x/gp2xmenu", "/usr/gp2x/gp2xmenu", NULL);
|
nuclear@0
|
481 #endif
|
nuclear@0
|
482 }
|
nuclear@0
|
483
|
nuclear@0
|
484 int main (int argc, char *argv[])
|
nuclear@0
|
485 {
|
nuclear@0
|
486 Init();
|
nuclear@0
|
487
|
nuclear@0
|
488 InitBench();
|
nuclear@0
|
489 RunBench();
|
nuclear@0
|
490
|
nuclear@0
|
491 BackToSystem();
|
nuclear@0
|
492 }
|