changeset 26:6a8cb917e0ad

merge
author Shinji KONO <kono@ie.u-ryukyu.ac.jp>
date Tue, 14 Dec 2010 10:48:26 +0900
parents 6754fbb63ac7 (diff) dc3b1d4fe835 (current diff)
children 8b80f670cf1c
files Makefile Makefile.fifo64 sgoex.c sound.c
diffstat 12 files changed, 49 insertions(+), 88 deletions(-) [+]
line wrap: on
line diff
--- a/Dandy.cc	Mon Dec 13 18:18:06 2010 +0900
+++ b/Dandy.cc	Tue Dec 14 10:48:26 2010 +0900
@@ -31,13 +31,16 @@
 #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 i;
 
-int rswait = 0;
-int cf = 0;
-int cc = 0;
+static int rswait = 0;
+static int cf = 0;
+static int cc = 0;
+
+static int test_mode = 0;
+static const char *test_object  = "" ;
 
 //static SDL_Surface *screen;
 // static Uint32 background;
@@ -131,6 +134,16 @@
 int
 TMmain(TaskManager *manager,int argc, char *argv[])
 {
+    for(int i = 1; i<argc ; i++) {
+	if (strcmp(argv[i],"-t")) {
+	    test_mode=1;
+	    if (i+1<argc && argv[i+1]) {
+		i++;
+		test_object=argv[i];
+	    }
+	}
+    }
+
     task_init();
     task_initialize();
     manager->set_TMend(TMend);
@@ -144,7 +157,7 @@
     printf("game end\n");
 }
 
-static int light_sysswitch = 1;
+static int light_sysswitch = 0;
 static int light_num = 4;
 
 static void 
@@ -543,6 +556,8 @@
 
 }
 
+static float my_scale = 5;
+
 void
 PutSprite(int zorder, short x, short y, int number)
 {
@@ -556,13 +571,27 @@
     object->xyz[0] = x;
     object->xyz[1] = y;
     object->xyz[2] = 0;
+    object->c_xyz[0] = m->mx;
+    object->c_xyz[1] = m->my;
     root->addChild(object);
 
-    float scale[] = {5,5,1};
+    float scale[] = {my_scale,my_scale,1};
     /*親の回転、座標から、子の回転、座標を算出*/
     get_matrix(object->matrix, object->angle, object->xyz, scale, root->matrix);
     /*法線用の行列。Cameraの行列を抜いている(Cameraのコンストラクタで、単位行列にしている)*/
     get_matrix(object->real_matrix, object->angle, object->xyz, scale, root->real_matrix);
+#if 0
+if (my_scale == 1 && m->w > 32) {
+float v0[] = {m->w,0,0,0};
+float v1[] = {1,0,0,0};
+float w;
+applyMatrix(v1, object->matrix, v0);
+w = sqrtf( v1[0]*v1[0] + v1[1]*v1[1] + v1[2]*v1[2] );
+my_scale =  w / ((float) m->w);
+printf("scale = %g\n", my_scale);
+}
+#endif
+
 
 }
 
@@ -584,7 +613,7 @@
     object->angle[3] = angle;
     root->addChild(object);
 
-    float scale[] = {5*scalex,5*scaley,1};
+    float scale[] = {my_scale*scalex,my_scale*scaley,1};
     /*親の回転、座標から、子の回転、座標を算出*/
     get_matrix(object->matrix, object->angle, object->xyz, scale, root->matrix);
     /*法線用の行列。Cameraの行列を抜いている(Cameraのコンストラクタで、単位行列にしている)*/
--- a/Makefile	Mon Dec 13 18:18:06 2010 +0900
+++ b/Makefile	Tue Dec 14 10:48:26 2010 +0900
@@ -2,14 +2,14 @@
 include ./Makefile.def
 
 srcdir  = .
-ABI = -m32
+ABI = -m$(ABIBIT)
 
 CFLAGS  += -g $(ABI) -Wall `sdl-config --cflags` `xml2-config --cflags` $(INCLUDE)
 LIBS	+=  `sdl-config --libs`,-framework,OpenGL -lSDL_mixer -lSDL_image `xml2-config --libs`
 LIBS += -lCerium -lFifoManager
 
 TARGET = demo dandy
-OBJS    =  Character.o Bom.o tokuten.o collision.o count2.o Character_state.o schedule3.o tama2.o syokika.o Ss.o sound.o  profile.o debug.o trace.o LoadSprite.o xml.o b64_de.o tree_controll.o object.o sys.o 
+OBJS    =  Character.o Bom.o tokuten.o collision.o count2.o Character_state.o schedule3.o tama2.o syokika.o Ss.o sound.o  profile.o debug.o trace.o LoadSprite.o xml.o b64_de.o tree_controll.o object.o 
 
 all: $(TARGET)
 
--- a/Makefile.def	Mon Dec 13 18:18:06 2010 +0900
+++ b/Makefile.def	Tue Dec 14 10:48:26 2010 +0900
@@ -8,7 +8,7 @@
 OPT = -g #-O9
 CFLAGS  =  -Wall $(OPT) 
 
-ABIBIT = 32
+ABIBIT = 64
 
 INCLUDE = -I. -I.. -I${CERIUM}/include/TaskManager -I$(CERIUM)/Renderer/Engine -I$(CERIUM)/include/Cerium
 LIBS = -L${CERIUM}/TaskManager -L$(CERIUM)/Renderer/Engine
--- a/Makefile.fifo64	Mon Dec 13 18:18:06 2010 +0900
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,34 +0,0 @@
-# Makefile to build the SDL tests
-include ./Makefile.def
-
-srcdir  = .
-ABI = -m64
-
-CFLAGS  += -g $(ABI) -Wall `sdl-config --cflags` `xml2-config --cflags` $(INCLUDE)
-LIBS	+=  `sdl-config --libs`,-framework,OpenGL -lSDL_mixer -lSDL_image `xml2-config --libs`
-LIBS += -lCerium -lFifoManager
-
-TARGET = demo dandy
-OBJS    =  Character.o Bom.o tokuten.o collision.o count2.o Character_state.o schedule3.o tama2.o syokika.o Ss.o sound.o  profile.o debug.o trace.o LoadSprite.o xml.o b64_de.o tree_controll.o object.o sys.o 
-
-all: $(TARGET)
-
-test: $(TARGET)
-	./demo  -test
-
-demo: $(OBJS) sgoex.o main.o
-	$(CC) $(ABI) -o $@ main.o sgoex.o $(OBJS) $(LIBS)
-
-dandy: $(OBJS) Dandy.o
-	$(CC) $(ABI) -o $@ $(OBJS) Dandy.o $(LIBS)
-
-clean:
-	rm -f $(TARGET) $(OBJS)
-
-.c.o:
-	$(CC) $(CFLAGS) $(INCLUDES) -c $<
-
-.cc.o:
-	$(CC) $(CFLAGS) $(INCLUDES) -c $<
-
-debug.o:debug.h
--- a/object.c	Mon Dec 13 18:18:06 2010 +0900
+++ b/object.c	Tue Dec 14 10:48:26 2010 +0900
@@ -24,5 +24,5 @@
       next = cur->next;
       free(cur);
     }
-  free(obj->free_me);
+  free(obj);
 }
--- a/object.h	Mon Dec 13 18:18:06 2010 +0900
+++ b/object.h	Tue Dec 14 10:48:26 2010 +0900
@@ -32,7 +32,6 @@
   FVECTOR angle;            // angle
   FMATRIX transfer;         // transfer matrix
   char *name;               // object's name
-  char *free_me;            // pointer for free myself
   SURFACE *surfaces;
 } OBJECT;
 
--- a/sgoex.c	Mon Dec 13 18:18:06 2010 +0900
+++ b/sgoex.c	Tue Dec 14 10:48:26 2010 +0900
@@ -149,7 +149,7 @@
 
 void PutSprite(int zorder, short x, short y, int number)
 {
-  glBindTexture(GL_TEXTURE_2D, (GLuint&)sptable[number].texture);
+    glBindTexture(GL_TEXTURE_2D, (GLuint&)sptable[number].texture);
     glEnable(GL_BLEND);
     glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
     glBegin(GL_QUADS);
--- a/sgoex.h	Mon Dec 13 18:18:06 2010 +0900
+++ b/sgoex.h	Tue Dec 14 10:48:26 2010 +0900
@@ -83,6 +83,7 @@
   int tex_w;
   int tex_h;
   int *texture;
+  int tex_id;  // for open gl
 } SpriteTable;
 
 //extern GsSPRITE sprite[MAXOBJ];
--- a/sound.c	Mon Dec 13 18:18:06 2010 +0900
+++ b/sound.c	Tue Dec 14 10:48:26 2010 +0900
@@ -15,11 +15,13 @@
 int channel[8];
 //_________________________________________________________
 
+#if 0
 static char buf0[] = "pBAV";
 
-int vh_addr[10] =
+long vh_addr[10] =
 { (long) buf0, (long) buf0, (long) buf0, (long) buf0, (long) buf0,
   (long) buf0 };
+#endif
 
 int vb_addr[10] =
 { 0x80140d00, 0x80142700, 0x80143d00, 0x80145100, 0x80148f00,
--- a/sys.c	Mon Dec 13 18:18:06 2010 +0900
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,31 +0,0 @@
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <libxml/parser.h>
-#include "object.h"
-#include "sys.h"
-
-#define ALIGN_16BYTE 16
-
-int malloc_align16(void *free, void *aligned, int size)
-{
-  char *index;
-  unsigned int *f=(unsigned int *)free,*a=(unsigned int *)aligned;
-
-  if (free == NULL || aligned == NULL || size <= 0) return(-1);
-
-  index = (char *)malloc(size + ALIGN_16BYTE);
-  if (index == NULL)
-    {
-      return(-1);
-    }
-
-  *f = *a = (unsigned long)index;
-  if (((unsigned long)index % ALIGN_16BYTE) != 0)
-    {
-      index += ALIGN_16BYTE - ((unsigned long)index % ALIGN_16BYTE);
-      *a = (unsigned long)index;
-    }
-  return(0);
-}
-
--- a/sys.h	Mon Dec 13 18:18:06 2010 +0900
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,3 +0,0 @@
-int malloc_align16(void *free, void *aligned, int size);
-
-
--- a/xml.c	Mon Dec 13 18:18:06 2010 +0900
+++ b/xml.c	Tue Dec 14 10:48:26 2010 +0900
@@ -4,7 +4,6 @@
 #include <unistd.h>
 #include <libxml/parser.h>
 #include "object.h"
-#include "sys.h"
 #include "xml.h"
 
 #include "error.h"
@@ -344,7 +343,7 @@
 
 static OBJECT *create_object(xmlDocPtr doc)
 {
-    char *align,*head;
+    char *align;
     OBJECT *obj;
     SURFACE *tmp,**joint;
     xmlNodePtr cur;
@@ -362,14 +361,13 @@
 	return(NULL);
     }
 
-    if (malloc_align16(&head,&align,sizeof(OBJECT)) < 0)
+    if (posix_memalign((void**)&align,16,sizeof(OBJECT)) < 0)
     {
 	fprintf(stderr,"malloc failed at create_object : OBJECT\n");
 	return(NULL);
     }
 
     obj = (OBJECT *)align;
-    obj->free_me = head;
     init_object(obj);
 
     obj->surfaces = NULL;