Mercurial > hg > Members > koba > t_dandy
diff 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 |
line wrap: on
line diff
--- a/TaskDandy.cc Fri Jan 14 02:17:57 2011 +0900 +++ b/TaskDandy.cc Fri Jan 14 23:49:23 2011 +0900 @@ -32,13 +32,13 @@ #include "property.h" #include "state_task.h" -int use_keybord = 0; -int cdp[20] = { 16, 16, 16, 17, 18, 0 }; -int d, i; +static int use_keybord = 0; +static int cdp[20] = { 16, 16, 16, 17, 18, 0 }; +static int d, i; -int rswait = 0; -int cf = 0; -int cc = 0; +static int rswait = 0; +static int cf = 0; +static int cc = 0; //static SDL_Surface *screen; // static Uint32 background; @@ -50,9 +50,13 @@ extern void keybord(); static int gamesyokika(int gamef); static int game_pause(int); +static void KeyAssign(int runmode, TraceBuffPtr buff, SDL_Joystick *joy, SGO_PAD *pad); extern void task_init(); +static int runmode = 0; +static TraceBuffPtr t_buff; +static TraceBuffPtr first; static char *pad_trace_file; /** @@ -66,7 +70,7 @@ * by capture-mode */ -SDL_Joystick *joy; +static SDL_Joystick *joy; #define SCMP_SIZ 8 @@ -179,31 +183,37 @@ { int i; if (argc < 2) { - return 0; + runmode = 0; + 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; + if (!strncmp(argv[i], "-capture", SCMP_SIZ)) { + if (++i >= argc) { + return 1; + } + printf("Start Capture mode.\n"); + t_buff = (TraceBuffPtr)malloc(sizeof(TraceBuff)); + t_buff->next = NULL; + 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"); + t_buff = (TraceBuffPtr)malloc(sizeof(TraceBuff)); + t_buff->next = NULL; + 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; } @@ -218,8 +228,13 @@ /** * timeprof があるんだけどね */ - if ((runmode == 1)||(runmode == 2)) { - pad_file_open(pad_trace_file); + if ((runmode == 1)||(runmode ==2)) { + if (!PadfileOpen(pad_trace_file)) { + runmode = 0; + } else if(runmode == 2) { + PadfileRead(t_buff); + } + first = t_buff; } sgroot->createFromXMLfile("xml/character.xml"); @@ -349,32 +364,7 @@ obj_draw(); gamef = game_pause(gamef); - 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; + KeyAssign(runmode, t_buff, joy, pad); return gamef; } @@ -382,7 +372,12 @@ static int dandy_closing(int gamef) { - pad_file_close(); + if (runmode == 1) { + PadfileWrite(first); + PadfileClose(first); + } else if (runmode == 2) { + PadfileClose(first); + } //_______________________________________________ // SDL_mixerの後始末 @@ -853,12 +848,7 @@ } if (keys[SDLK_ESCAPE]) { - pad_file_close(); - - SDL_Quit(); - exit(1); - //pad[0].st = 1; - //pad[0].se = 1; + pad[0].quit = 1; } if (keys[SDLK_0]) { @@ -869,4 +859,29 @@ } +static void +KeyAssign(int runmode, TraceBuffPtr buff, SDL_Joystick *joy, SGO_PAD *pad) +{ + switch (runmode) { + case 0: + if (use_keybord) { + keybord(); + } else { + Pad(joy); + } + break; + case 1: + if (use_keybord) { + keybord(); + } else { + Pad(joy); + } + t_buff = CapturePad(t_buff, pad); + break; + case 2: + t_buff = TracePad(t_buff, pad); + break; + } +} + /* end */