Mercurial > hg > Members > koba > t_dandy
comparison TaskDandy.cc @ 44:2c85322348cf
add print log.
author | koba <koba@cr.ie.u-ryukyu.ac.jp> |
---|---|
date | Fri, 14 Jan 2011 23:49:23 +0900 |
parents | 6974c3834700 |
children | e01948ce859a |
comparison
equal
deleted
inserted
replaced
43:56ef94618a0e | 44:2c85322348cf |
---|---|
30 #include "Character.h" | 30 #include "Character.h" |
31 #include "Character_state.h" | 31 #include "Character_state.h" |
32 #include "property.h" | 32 #include "property.h" |
33 #include "state_task.h" | 33 #include "state_task.h" |
34 | 34 |
35 int use_keybord = 0; | 35 static int use_keybord = 0; |
36 int cdp[20] = { 16, 16, 16, 17, 18, 0 }; | 36 static int cdp[20] = { 16, 16, 16, 17, 18, 0 }; |
37 int d, i; | 37 static int d, i; |
38 | 38 |
39 int rswait = 0; | 39 static int rswait = 0; |
40 int cf = 0; | 40 static int cf = 0; |
41 int cc = 0; | 41 static int cc = 0; |
42 | 42 |
43 //static SDL_Surface *screen; | 43 //static SDL_Surface *screen; |
44 // static Uint32 background; | 44 // static Uint32 background; |
45 // static char *pad_trace_file; | 45 // static char *pad_trace_file; |
46 | 46 |
48 extern void tokuten(); | 48 extern void tokuten(); |
49 extern void Pad(); | 49 extern void Pad(); |
50 extern void keybord(); | 50 extern void keybord(); |
51 static int gamesyokika(int gamef); | 51 static int gamesyokika(int gamef); |
52 static int game_pause(int); | 52 static int game_pause(int); |
53 static void KeyAssign(int runmode, TraceBuffPtr buff, SDL_Joystick *joy, SGO_PAD *pad); | |
53 | 54 |
54 extern void task_init(); | 55 extern void task_init(); |
55 | 56 |
57 static int runmode = 0; | |
58 static TraceBuffPtr t_buff; | |
59 static TraceBuffPtr first; | |
56 static char *pad_trace_file; | 60 static char *pad_trace_file; |
57 | 61 |
58 /** | 62 /** |
59 * runmode: | 63 * runmode: |
60 * 0 - normal game | 64 * 0 - normal game |
64 * 2 - trace mode | 68 * 2 - trace mode |
65 * program will run with a trace file which is generated | 69 * program will run with a trace file which is generated |
66 * by capture-mode | 70 * by capture-mode |
67 */ | 71 */ |
68 | 72 |
69 SDL_Joystick *joy; | 73 static SDL_Joystick *joy; |
70 | 74 |
71 #define SCMP_SIZ 8 | 75 #define SCMP_SIZ 8 |
72 | 76 |
73 const char *usr_help_str = "Usage: ./twice [-length data_length] [-count task_num]\n\ | 77 const char *usr_help_str = "Usage: ./twice [-length data_length] [-count task_num]\n\ |
74 -length Number of data (default DATA_NUM (Func.h))\n\ | 78 -length Number of data (default DATA_NUM (Func.h))\n\ |
177 static int | 181 static int |
178 get_option(int argc, char *argv[]) | 182 get_option(int argc, char *argv[]) |
179 { | 183 { |
180 int i; | 184 int i; |
181 if (argc < 2) { | 185 if (argc < 2) { |
186 runmode = 0; | |
187 return 0; | |
188 } | |
189 for (i = 0; i < argc; i++) { | |
190 if (!strncmp(argv[i], "-capture", SCMP_SIZ)) { | |
191 if (++i >= argc) { | |
192 return 1; | |
193 } | |
194 printf("Start Capture mode.\n"); | |
195 t_buff = (TraceBuffPtr)malloc(sizeof(TraceBuff)); | |
196 t_buff->next = NULL; | |
197 pad_trace_file = argv[i]; | |
198 runmode = 1; | |
182 return 0; | 199 return 0; |
183 } | 200 } else if (!strncmp(argv[i], "-trace", SCMP_SIZ)) { |
184 for (i = 0; i < argc; i++) { | 201 if (++i >= argc) { |
185 if (!strncmp(argv[i], "-capture", SCMP_SIZ)) { | 202 return 1; |
186 if (++i >= argc) { | 203 } |
187 return 1; | 204 printf("Start Trace mode.\n"); |
188 } | 205 t_buff = (TraceBuffPtr)malloc(sizeof(TraceBuff)); |
189 printf("Start capture mode.\n"); | 206 t_buff->next = NULL; |
190 pad_trace_file = argv[i]; | 207 pad_trace_file = argv[i]; |
191 runmode = 1; | 208 runmode = 2; |
192 return 0; | 209 return 0; |
193 } else if (!strncmp(argv[i], "-trace", SCMP_SIZ)) { | 210 } else if (!strncmp(argv[i], "--help", SCMP_SIZ) || |
194 if (++i >= argc) { | 211 !strncmp(argv[i], "-help", SCMP_SIZ) || |
195 return 1; | 212 !strncmp(argv[i], "-h", SCMP_SIZ)) { |
196 } | 213 return 1; |
197 printf("Start trace mode.\n"); | 214 } |
198 pad_trace_file = argv[i]; | 215 } |
199 runmode = 2; | 216 |
200 return 0; | |
201 } else if (!strncmp(argv[i], "--help", SCMP_SIZ) || | |
202 !strncmp(argv[i], "-help", SCMP_SIZ) || | |
203 !strncmp(argv[i], "-h", SCMP_SIZ)) { | |
204 return 1; | |
205 } | |
206 } | |
207 return 1; | 217 return 1; |
208 } | 218 } |
209 | 219 |
210 | 220 |
211 static int | 221 static int |
216 dbg_init("/dev/stdout"); | 226 dbg_init("/dev/stdout"); |
217 | 227 |
218 /** | 228 /** |
219 * timeprof があるんだけどね | 229 * timeprof があるんだけどね |
220 */ | 230 */ |
221 if ((runmode == 1)||(runmode == 2)) { | 231 if ((runmode == 1)||(runmode ==2)) { |
222 pad_file_open(pad_trace_file); | 232 if (!PadfileOpen(pad_trace_file)) { |
233 runmode = 0; | |
234 } else if(runmode == 2) { | |
235 PadfileRead(t_buff); | |
236 } | |
237 first = t_buff; | |
223 } | 238 } |
224 | 239 |
225 sgroot->createFromXMLfile("xml/character.xml"); | 240 sgroot->createFromXMLfile("xml/character.xml"); |
226 sgroot->createFromXMLfile("xml/font.xml"); | 241 sgroot->createFromXMLfile("xml/font.xml"); |
227 sgroot->createFromXMLfile("xml/effect.xml"); | 242 sgroot->createFromXMLfile("xml/effect.xml"); |
347 //PutSprite(count, 0, 0, 48); | 362 //PutSprite(count, 0, 0, 48); |
348 | 363 |
349 obj_draw(); | 364 obj_draw(); |
350 gamef = game_pause(gamef); | 365 gamef = game_pause(gamef); |
351 | 366 |
352 switch (runmode) { | 367 KeyAssign(runmode, t_buff, joy, pad); |
353 case 0: | |
354 if (use_keybord) { | |
355 keybord(); | |
356 } else { | |
357 Pad(joy); | |
358 } | |
359 break; | |
360 case 1: | |
361 if (use_keybord) { | |
362 keybord(); | |
363 } else { | |
364 Pad(joy); | |
365 } | |
366 capture_pad(); | |
367 break; | |
368 case 2: | |
369 if (!pad_file_read()) { | |
370 printf("can't trace file.\n"); | |
371 runmode = 0; | |
372 } | |
373 break; | |
374 } | |
375 | |
376 filpcount++; | |
377 count = 0; | |
378 | 368 |
379 return gamef; | 369 return gamef; |
380 } | 370 } |
381 | 371 |
382 static int | 372 static int |
383 dandy_closing(int gamef) | 373 dandy_closing(int gamef) |
384 { | 374 { |
385 pad_file_close(); | 375 if (runmode == 1) { |
376 PadfileWrite(first); | |
377 PadfileClose(first); | |
378 } else if (runmode == 2) { | |
379 PadfileClose(first); | |
380 } | |
386 | 381 |
387 //_______________________________________________ | 382 //_______________________________________________ |
388 // SDL_mixerの後始末 | 383 // SDL_mixerの後始末 |
389 Mix_CloseAudio(); | 384 Mix_CloseAudio(); |
390 Mix_HaltMusic(); | 385 Mix_HaltMusic(); |
851 } else { | 846 } else { |
852 pad[0].se = 0; | 847 pad[0].se = 0; |
853 } | 848 } |
854 | 849 |
855 if (keys[SDLK_ESCAPE]) { | 850 if (keys[SDLK_ESCAPE]) { |
856 pad_file_close(); | 851 pad[0].quit = 1; |
857 | |
858 SDL_Quit(); | |
859 exit(1); | |
860 //pad[0].st = 1; | |
861 //pad[0].se = 1; | |
862 } | 852 } |
863 | 853 |
864 if (keys[SDLK_0]) { | 854 if (keys[SDLK_0]) { |
865 pad[0].quit = 1; | 855 pad[0].quit = 1; |
866 } else { | 856 } else { |
867 pad[0].quit = 0; | 857 pad[0].quit = 0; |
868 } | 858 } |
869 } | 859 } |
870 | 860 |
871 | 861 |
862 static void | |
863 KeyAssign(int runmode, TraceBuffPtr buff, SDL_Joystick *joy, SGO_PAD *pad) | |
864 { | |
865 switch (runmode) { | |
866 case 0: | |
867 if (use_keybord) { | |
868 keybord(); | |
869 } else { | |
870 Pad(joy); | |
871 } | |
872 break; | |
873 case 1: | |
874 if (use_keybord) { | |
875 keybord(); | |
876 } else { | |
877 Pad(joy); | |
878 } | |
879 t_buff = CapturePad(t_buff, pad); | |
880 break; | |
881 case 2: | |
882 t_buff = TracePad(t_buff, pad); | |
883 break; | |
884 } | |
885 } | |
886 | |
872 /* end */ | 887 /* end */ |