changeset 44:2c85322348cf

add print log.
author koba <koba@cr.ie.u-ryukyu.ac.jp>
date Fri, 14 Jan 2011 23:49:23 +0900
parents 56ef94618a0e
children e01948ce859a
files Character.c Character.h Character_state.c Dandy.cc Makefile.def Makefile.demo TaskDandy.cc collision.c main.c sgoex.c
diffstat 10 files changed, 211 insertions(+), 163 deletions(-) [+]
line wrap: on
line diff
--- a/Character.c	Fri Jan 14 02:17:57 2011 +0900
+++ b/Character.c	Fri Jan 14 23:49:23 2011 +0900
@@ -100,12 +100,15 @@
 }
 
 
+static int global_id = 0;
+
+
 void
 Putenemy(int charano, float x, float y, float vx, float vy,
 	 CHARACTER * (*action)(CHARACTER *chara))
 {
   CHARACTER *q;
-
+  
   for(q = active_chara_list->next; q != NULL ;q = q->next)
     {
       if(q->f == FALSE)
@@ -114,6 +117,8 @@
 	}
     }
 
+  q->chara_id = global_id;
+  ++global_id;
   q->state = action;
   q->collision = atari;
   q->x = x;
@@ -128,7 +133,9 @@
   q->f = TRUE;
   //q->state = ALIVE;
   //q->group = ENEMY
-
+  if (q->tama == FALSE) {
+    printf("F%d:   [%d] x=%f  y=%f  vx=%f  vy=%f  CREATE\n", filpcount, q->chara_id, q->x, q->y, q->vx, q->vy);
+  }
 }
 
 void state_update()
@@ -176,6 +183,7 @@
 	      || (p->x < 0 - 200))
 	    {
 	      p->f = FALSE;
+	      p->tama = TRUE;
 	      p->state = delete_chara;
 	      p->collision = noaction;
 	    }
--- a/Character.h	Fri Jan 14 02:17:57 2011 +0900
+++ b/Character.h	Fri Jan 14 23:49:23 2011 +0900
@@ -43,9 +43,9 @@
   BOOL f; //apiarance idenfifier
   float s;
   //int group;  
+  int chara_id;
   int task;
 
-
   State state;
   Collision collision;
   struct CHARACTER *next;
--- a/Character_state.c	Fri Jan 14 02:17:57 2011 +0900
+++ b/Character_state.c	Fri Jan 14 23:49:23 2011 +0900
@@ -49,7 +49,10 @@
 CHARACTER *
 delete_chara(CHARACTER *p)
 {
-
+  if (p->tama == FALSE) {
+    printf("F%d:   [%d] x=%f  y=%f  vx=%f  vy=%f  DELETE\n", filpcount, p->chara_id, p->x, p->y, p->vx, p->vy);
+  }
+  
   CHARACTER *parent = p;
   p->f = FALSE;
   p->state = noaction;
--- a/Dandy.cc	Fri Jan 14 02:17:57 2011 +0900
+++ b/Dandy.cc	Fri Jan 14 23:49:23 2011 +0900
@@ -30,13 +30,13 @@
 #include "Character.h"
 #include "Character_state.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;
@@ -48,7 +48,11 @@
 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);
 
+static int runmode = 0;
+static TraceBuffPtr t_buff;
+static TraceBuffPtr first;
 static char *pad_trace_file;
 
 /**
@@ -62,7 +66,7 @@
  *     by capture-mode
  */
 
-SDL_Joystick *joy;
+static SDL_Joystick *joy;
 
 #define SCMP_SIZ 8
 
@@ -171,7 +175,7 @@
 static void
 print_usage()
 {
-  printf("usage: exe_file [-h|-help|--help][-capture filename][-trace filename]\n");
+  printf("usage: ./exe_file [-h|-help|--help][-capture filename][-trace filename]\n");
 }
 
 
@@ -180,31 +184,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;
 }
 
@@ -219,8 +229,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");
@@ -348,29 +363,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;
-	}
+	KeyAssign(runmode, t_buff, joy, pad);
 	
 	filpcount++;
 	count = 0;
@@ -381,7 +374,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の後始末
@@ -855,12 +853,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]) {
@@ -871,4 +864,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 */
--- a/Makefile.def	Fri Jan 14 02:17:57 2011 +0900
+++ b/Makefile.def	Fri Jan 14 23:49:23 2011 +0900
@@ -7,7 +7,7 @@
 ABIBIT = 32
 ABI = -m$(ABIBIT)
 CC      = g++
-OPT = -g
+OPT = -pg
 CFLAGS  =  -Wall $(OPT) $(ABI)
 
 
--- a/Makefile.demo	Fri Jan 14 02:17:57 2011 +0900
+++ b/Makefile.demo	Fri Jan 14 23:49:23 2011 +0900
@@ -3,7 +3,7 @@
 srcdir  = .
 
 CC      = gcc
-CFLAGS  = -g -O2 -Wall `sdl-config --cflags` `xml2-config --cflags`
+CFLAGS  = -pg -O2 -Wall `sdl-config --cflags` `xml2-config --cflags`
 LIBS	=  `sdl-config --libs`,-framework,OpenGL -lSDL_mixer -lSDL_image `xml2-config --libs`
 TARGET = demo
 OBJS    = sgoex.o Character.o Bom.o tokuten.o collision.o count2.o Character_state.o schedule3.o tama2.o syokika.o Ss.o sound.o main.o profile.o debug.o trace.o LoadSprite.o xml.o b64_de.o tree_controll.o object.o sys.o #back.o 
--- 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 */
--- a/collision.c	Fri Jan 14 02:17:57 2011 +0900
+++ b/collision.c	Fri Jan 14 23:49:23 2011 +0900
@@ -41,7 +41,6 @@
 	infg_level--;
 	if (infg_level < 0)
 	    infg_level = 0;
-
 	return p;
     }
 #endif
--- a/main.c	Fri Jan 14 02:17:57 2011 +0900
+++ b/main.c	Fri Jan 14 23:49:23 2011 +0900
@@ -29,7 +29,7 @@
 
 #include "error.h"
 
-
+static int runmode = 0;
 static int gamef = 0;
 static int use_keybord = 0;
 static int i;
@@ -38,9 +38,6 @@
 static int cf = 0;
 static int cc = 0;
 
-static int runmode;
-static TraceBuffPtr first;
-
 static Uint32 background;
 static TraceBuffPtr t_buff;
 static char *pad_trace_file;
@@ -53,6 +50,7 @@
 static void gamesyokika(SDL_Joystick *joy);
 static void opening(SDL_Joystick *joy);
 static void pause(SDL_Joystick *joy);
+static void KeyAssign(int runmode, TraceBuffPtr buff, SDL_Joystick *joy, SGO_PAD *pad);
 
 extern void SDL_GL_Enter2DMode();
 extern void SDL_GL_Leave2DMode();
@@ -75,7 +73,7 @@
 static void
 print_usage()
 {
-  printf("usage: exe_file [-h|-help|--help][-capture filename][-trace filename]\n");
+  printf("usage: ./exe_file [-h|-help|--help][-capture filename][-trace filename]\n");
 }
 
 
@@ -136,6 +134,7 @@
       return 0;
     }
 
+    TraceBuffPtr first;
     if ((runmode == 1)||(runmode ==2)) {
       if (!PadfileOpen(pad_trace_file)) {
 	runmode = 0;
@@ -250,26 +249,7 @@
 	obj_draw();
 	pause(joy);
 
-	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;
-	}
+	KeyAssign(runmode, t_buff, joy, pad);
 
 	glFlush();
 	SDL_GL_SwapBuffers( );
@@ -315,7 +295,8 @@
 }
 
 
-void gamesyokika(SDL_Joystick *joy)
+static void
+gamesyokika(SDL_Joystick *joy)
 {
     laser_lv3[0].r = 62;
     laser_lv3[0].r = 62;
@@ -352,7 +333,8 @@
 }
 
 
-void opening(SDL_Joystick *joy)
+static void
+opening(SDL_Joystick *joy)
 {
     //for (i = 0; i < 300; i++) {
     //};
@@ -404,7 +386,7 @@
     }
 }
 
-void
+static void
 pause(SDL_Joystick *joy)
 {
     if (jiki.zanki != 0 && jiki.bf != FALSE) {
@@ -501,3 +483,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;
+    }
+}
--- a/sgoex.c	Fri Jan 14 02:17:57 2011 +0900
+++ b/sgoex.c	Fri Jan 14 23:49:23 2011 +0900
@@ -32,9 +32,6 @@
 
 //static int padd;
 
-extern int runmode;
-extern TraceBuffPtr first;
-
 static const int sgo_tpx[12] =
 { 0, 64, 128, 192, 256, 320, 0, 64, 128, 192, 256, 320 };
 static const int sgo_tpy[12] = { 0, 0, 0, 0, 0, 0, 256, 256, 256, 256, 256, 256 };
@@ -144,7 +141,7 @@
     texMinX[number] = 0.0f;
     texMinY[number] = 0.0f;
     texMaxX[number] = (GLfloat)sptable[number].w / sptable[number].tex_w;
-    texMaxY[number] = (GLfloat)sptable[number].h / sptable[number].tex_h;  
+    texMaxY[number] = (GLfloat)sptable[number].h / sptable[number].tex_h;
 //    printf("texMaxX = %f, w = %d, tex_w = %d\n", texMaxX[number], sptable[number].w, sptable[number].tex_w);
     sptable[number].texture = surfaces->texture;
 }