# HG changeset patch # User koba # Date 1294759047 -32400 # Node ID 6974c383470035ccd1a612a3180026f4695ee048 # Parent cbe5bb9068c32a7d8acfde68dcb9dd57a78209c1 all trace mode moving. diff -r cbe5bb9068c3 -r 6974c3834700 TaskDandy.cc --- a/TaskDandy.cc Wed Jan 12 00:01:02 2011 +0900 +++ b/TaskDandy.cc Wed Jan 12 00:17:27 2011 +0900 @@ -52,7 +52,8 @@ static int game_pause(int); extern void task_init(); -//static char *pad_trace_file; + +static char *pad_trace_file; /** * runmode: @@ -64,10 +65,10 @@ * program will run with a trace file which is generated * by capture-mode */ -int runmode; SDL_Joystick *joy; +#define SCMP_SIZ 8 const char *usr_help_str = "Usage: ./twice [-length data_length] [-count task_num]\n\ -length Number of data (default DATA_NUM (Func.h))\n\ @@ -97,7 +98,8 @@ return new Dandy(); } -static void get_input(int argc, char *argv[]); +static void print_usage(); +static int get_option(int argc, char *argv[]); static int opening(int gamef); static int dandy_closing(int gamef); static int dandy_main_loop(int gamef); @@ -132,7 +134,9 @@ task_init(); task_initialize(); manager->set_TMend(TMend); - get_input(argc, argv); + if (get_option(argc, argv)) { + print_usage(); + } return init(manager,argc, argv); } @@ -163,6 +167,47 @@ } +static void +print_usage() +{ + printf("usage: exe_file [-h|-help|--help][-capture filename][-trace filename]\n"); +} + + +static int +get_option(int argc, char *argv[]) +{ + int i; + if (argc < 2) { + return 0; + } + for (i = 0; i < argc; i++) { + if (!strncmp(argv[i], "-capture", SCMP_SIZ)) { + if (++i >= argc) { + return 1; + } + printf("Start capture mode.\n"); + pad_trace_file = argv[i]; + runmode = 1; + return 0; + } else if (!strncmp(argv[i], "-trace", SCMP_SIZ)) { + if (++i >= argc) { + return 1; + } + printf("Start trace mode.\n"); + pad_trace_file = argv[i]; + runmode = 2; + return 0; + } else if (!strncmp(argv[i], "--help", SCMP_SIZ) || + !strncmp(argv[i], "-help", SCMP_SIZ) || + !strncmp(argv[i], "-h", SCMP_SIZ)) { + return 1; + } + } + return 1; +} + + static int dandy_main_init(int gamef) { @@ -173,6 +218,9 @@ /** * timeprof があるんだけどね */ + if ((runmode == 1)||(runmode == 2)) { + pad_file_open(pad_trace_file); + } sgroot->createFromXMLfile("xml/character.xml"); sgroot->createFromXMLfile("xml/font.xml"); @@ -301,11 +349,30 @@ obj_draw(); gamef = game_pause(gamef); - if (use_keybord) { - keybord(); - } else { - Pad(joy); + switch (runmode) { + case 0: + if (use_keybord) { + keybord(); + } else { + Pad(joy); + } + break; + case 1: + if (use_keybord) { + keybord(); + } else { + Pad(joy); + } + capture_pad(); + break; + case 2: + if (!pad_file_read()) { + printf("can't trace file.\n"); + runmode = 0; + } + break; } + filpcount++; count = 0; @@ -315,6 +382,7 @@ static int dandy_closing(int gamef) { + pad_file_close(); //_______________________________________________ // SDL_mixerの後始末 @@ -335,7 +403,7 @@ tlv3[i].y = -1; } filpcount = 0; - stage = 4; + stage = 0; //for (i = 0; i < 300; i++) //enemy[i].f = FALSE; jiki.zanki = 3; @@ -785,6 +853,8 @@ } if (keys[SDLK_ESCAPE]) { + pad_file_close(); + SDL_Quit(); exit(1); //pad[0].st = 1;