Mercurial > hg > Members > koba > t_dandy
comparison Dandy.cc @ 40:cbe5bb9068c3
add trace mode to tree_dandy2(SceneGraph)
author | koba <koba@cr.ie.u-ryukyu.ac.jp> |
---|---|
date | Wed, 12 Jan 2011 00:01:02 +0900 |
parents | 6626e451a09d |
children | 2c85322348cf |
comparison
equal
deleted
inserted
replaced
39:5484b8606e8e | 40:cbe5bb9068c3 |
---|---|
47 extern void Pad(); | 47 extern void Pad(); |
48 extern void keybord(); | 48 extern void keybord(); |
49 static int gamesyokika(int gamef); | 49 static int gamesyokika(int gamef); |
50 static int game_pause(int); | 50 static int game_pause(int); |
51 | 51 |
52 //static char *pad_trace_file; | 52 static char *pad_trace_file; |
53 | 53 |
54 /** | 54 /** |
55 * runmode: | 55 * runmode: |
56 * 0 - normal game | 56 * 0 - normal game |
57 * 1 - capture mode | 57 * 1 - capture mode |
59 * dump it into a file | 59 * dump it into a file |
60 * 2 - trace mode | 60 * 2 - trace mode |
61 * program will run with a trace file which is generated | 61 * program will run with a trace file which is generated |
62 * by capture-mode | 62 * by capture-mode |
63 */ | 63 */ |
64 int runmode; | |
65 | 64 |
66 SDL_Joystick *joy; | 65 SDL_Joystick *joy; |
67 | 66 |
68 | 67 #define SCMP_SIZ 8 |
69 | 68 |
70 const char *usr_help_str = "Usage: ./twice [-length data_length] [-count task_num]\n\ | 69 const char *usr_help_str = "Usage: ./twice [-length data_length] [-count task_num]\n\ |
71 -length Number of data (default DATA_NUM (Func.h))\n\ | 70 -length Number of data (default DATA_NUM (Func.h))\n\ |
72 -count Number of task (default 1)\n"; | 71 -count Number of task (default 1)\n"; |
73 | 72 |
91 Application * | 90 Application * |
92 application() { | 91 application() { |
93 return new Dandy(); | 92 return new Dandy(); |
94 } | 93 } |
95 | 94 |
96 | 95 static void print_usage(); |
96 static int get_option(int argc, char *argv[]); | |
97 static int opening(int gamef); | 97 static int opening(int gamef); |
98 static int dandy_closing(int gamef); | 98 static int dandy_closing(int gamef); |
99 static int dandy_main_loop(int gamef); | 99 static int dandy_main_loop(int gamef); |
100 static int dandy_main_init(int gamef); | 100 static int dandy_main_init(int gamef); |
101 extern int init(TaskManager *manager, int argc, char *argv[]); | 101 extern int init(TaskManager *manager, int argc, char *argv[]); |
133 TMmain(TaskManager *manager,int argc, char *argv[]) | 133 TMmain(TaskManager *manager,int argc, char *argv[]) |
134 { | 134 { |
135 task_init(); | 135 task_init(); |
136 task_initialize(); | 136 task_initialize(); |
137 manager->set_TMend(TMend); | 137 manager->set_TMend(TMend); |
138 if (get_option(argc, argv)) { | |
139 print_usage(); | |
140 } | |
138 | 141 |
139 return init(manager,argc, argv); | 142 return init(manager,argc, argv); |
140 } | 143 } |
141 | 144 |
142 void | 145 void |
163 sgroot->OffLightSysSwitch(); | 166 sgroot->OffLightSysSwitch(); |
164 } | 167 } |
165 } | 168 } |
166 | 169 |
167 | 170 |
171 static void | |
172 print_usage() | |
173 { | |
174 printf("usage: exe_file [-h|-help|--help][-capture filename][-trace filename]\n"); | |
175 } | |
176 | |
177 | |
178 static int | |
179 get_option(int argc, char *argv[]) | |
180 { | |
181 int i; | |
182 if (argc < 2) { | |
183 return 0; | |
184 } | |
185 for (i = 0; i < argc; i++) { | |
186 if (!strncmp(argv[i], "-capture", SCMP_SIZ)) { | |
187 if (++i >= argc) { | |
188 return 1; | |
189 } | |
190 printf("Start capture mode.\n"); | |
191 pad_trace_file = argv[i]; | |
192 runmode = 1; | |
193 return 0; | |
194 } else if (!strncmp(argv[i], "-trace", SCMP_SIZ)) { | |
195 if (++i >= argc) { | |
196 return 1; | |
197 } | |
198 printf("Start trace mode.\n"); | |
199 pad_trace_file = argv[i]; | |
200 runmode = 2; | |
201 return 0; | |
202 } else if (!strncmp(argv[i], "--help", SCMP_SIZ) || | |
203 !strncmp(argv[i], "-help", SCMP_SIZ) || | |
204 !strncmp(argv[i], "-h", SCMP_SIZ)) { | |
205 return 1; | |
206 } | |
207 } | |
208 return 1; | |
209 } | |
210 | |
211 | |
168 static int | 212 static int |
169 dandy_main_init(int gamef) | 213 dandy_main_init(int gamef) |
170 { | 214 { |
171 //Timeprof timeprof_move; | 215 //Timeprof timeprof_move; |
172 //timeprof_move = timeprof_new(); | 216 //timeprof_move = timeprof_new(); |
173 dbg_init("/dev/stdout"); | 217 dbg_init("/dev/stdout"); |
174 | 218 |
175 /** | 219 /** |
176 * timeprof があるんだけどね | 220 * timeprof があるんだけどね |
177 */ | 221 */ |
222 if ((runmode == 1)||(runmode == 2)) { | |
223 pad_file_open(pad_trace_file); | |
224 } | |
178 | 225 |
179 sgroot->createFromXMLfile("xml/character.xml"); | 226 sgroot->createFromXMLfile("xml/character.xml"); |
180 sgroot->createFromXMLfile("xml/font.xml"); | 227 sgroot->createFromXMLfile("xml/font.xml"); |
181 sgroot->createFromXMLfile("xml/effect.xml"); | 228 sgroot->createFromXMLfile("xml/effect.xml"); |
182 sgroot->createFromXMLfile("xml/boss.xml"); | 229 sgroot->createFromXMLfile("xml/boss.xml"); |
299 //PutSprite(count, 0, 0, 48); | 346 //PutSprite(count, 0, 0, 48); |
300 | 347 |
301 obj_draw(); | 348 obj_draw(); |
302 gamef = game_pause(gamef); | 349 gamef = game_pause(gamef); |
303 | 350 |
304 if (use_keybord) { | 351 switch (runmode) { |
305 keybord(); | 352 case 0: |
306 } else { | 353 if (use_keybord) { |
307 Pad(joy); | 354 keybord(); |
308 } | 355 } else { |
356 Pad(joy); | |
357 } | |
358 break; | |
359 case 1: | |
360 if (use_keybord) { | |
361 keybord(); | |
362 } else { | |
363 Pad(joy); | |
364 } | |
365 capture_pad(); | |
366 break; | |
367 case 2: | |
368 if (!pad_file_read()) { | |
369 printf("can't trace file.\n"); | |
370 runmode = 0; | |
371 } | |
372 break; | |
373 } | |
374 | |
309 filpcount++; | 375 filpcount++; |
310 count = 0; | 376 count = 0; |
311 | 377 |
312 return gamef; | 378 return gamef; |
313 } | 379 } |
314 | 380 |
315 static int | 381 static int |
316 dandy_closing(int gamef) | 382 dandy_closing(int gamef) |
317 { | 383 { |
384 pad_file_close(); | |
318 | 385 |
319 //_______________________________________________ | 386 //_______________________________________________ |
320 // SDL_mixerの後始末 | 387 // SDL_mixerの後始末 |
321 Mix_CloseAudio(); | 388 Mix_CloseAudio(); |
322 Mix_HaltMusic(); | 389 Mix_HaltMusic(); |
333 laser_lv3[0].r = 62; | 400 laser_lv3[0].r = 62; |
334 for (i = 0; i < 3; i++) { | 401 for (i = 0; i < 3; i++) { |
335 tlv3[i].y = -1; | 402 tlv3[i].y = -1; |
336 } | 403 } |
337 filpcount = 0; | 404 filpcount = 0; |
338 stage = 4; | 405 stage = 0; |
339 //for (i = 0; i < 300; i++) | 406 //for (i = 0; i < 300; i++) |
340 //enemy[i].f = FALSE; | 407 //enemy[i].f = FALSE; |
341 jiki.zanki = 3; | 408 jiki.zanki = 3; |
342 jiki.x = 60; | 409 jiki.x = 60; |
343 jiki.y = 200; | 410 jiki.y = 200; |
786 } else { | 853 } else { |
787 pad[0].se = 0; | 854 pad[0].se = 0; |
788 } | 855 } |
789 | 856 |
790 if (keys[SDLK_ESCAPE]) { | 857 if (keys[SDLK_ESCAPE]) { |
858 pad_file_close(); | |
859 | |
791 SDL_Quit(); | 860 SDL_Quit(); |
792 exit(1); | 861 exit(1); |
793 //pad[0].st = 1; | 862 //pad[0].st = 1; |
794 //pad[0].se = 1; | 863 //pad[0].se = 1; |
795 } | 864 } |