changeset 9:c88a4f98b5ef

no compile errors
author Shinji KONO <kono@ie.u-ryukyu.ac.jp>
date Tue, 07 Dec 2010 23:45:46 +0900
parents 5c405fb3b164
children a6dc38328741
files Dandy.cc Dandy.h Makefile main.c
diffstat 4 files changed, 53 insertions(+), 66 deletions(-) [+]
line wrap: on
line diff
--- a/Dandy.cc	Tue Dec 07 23:13:25 2010 +0900
+++ b/Dandy.cc	Tue Dec 07 23:45:46 2010 +0900
@@ -13,11 +13,11 @@
 }
 
 Application *
-Dandy::application() {
+application() {
     return new Dandy();
 }
 
-Viewer *sgroot;
+static Viewer *sgroot;
 
 static int dandy_closing(int gamef);
 static int dandy_main_loop(int gamef);
@@ -48,7 +48,7 @@
 extern void task_initialize();
 static void TMend(TaskManager *manager);
 
-static
+static void
 task_init() 
 {
 }
@@ -69,7 +69,7 @@
     printf("game end\n");
 }
 
-extern "C" {
+
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
@@ -87,8 +87,6 @@
 #include "sgoex.h"
 #include "sound.h"
 #include "bool.h"
-#include "Character.h"
-#include "Character_state.h"
 #include "bom.h"
 #include "count2.h"
 #include "tokuten.h"
@@ -98,9 +96,10 @@
 #include "trace.h"
 #include "LoadSprite.h"
 #include <SDL_mixer.h>
+#include "error.h"
 
-#include "error.h"
-}
+#include "Character.h"
+#include "Character_state.h"
 
 int gamef = 0;
 int use_keybord = 0;
@@ -119,11 +118,9 @@
 extern void tokuten();
 extern void Pad();
 extern void keybord();
-//extern void PutSpriteEx(int number, int x, int y, GLfloat scalex, GLfloat scaley, GLfloat angle);
-//GLuint texture[250] = {0};
-static void gamesyokika();
-static void opening();
-static void pause();
+static void gamesyokika(SDL_Joystick *joy);
+static void opening(SDL_Joystick *joy);
+static void game_pause(SDL_Joystick *joy);
 //static char *pad_trace_file;
 
 /**
@@ -138,12 +135,13 @@
  */
 int runmode;
 
+SDL_Joystick *joy;
 
 static int 
 dandy_main_init(int gamef)
 {
-    Timeprof timeprof_move;
-    timeprof_move = timeprof_new();
+    //Timeprof timeprof_move;
+    //timeprof_move = timeprof_new();
     dbg_init("/dev/stdout");
 
     /**
@@ -153,7 +151,7 @@
 
 
 
-    //SDL_Joystick *joy=SDL_JoystickOpen(0);
+    joy=SDL_JoystickOpen(0);
   
     sgroot->createFromXMLfile("xml/character.xml");
     sgroot->createFromXMLfile("xml/font.xml");
@@ -214,8 +212,8 @@
 static int
 dandy_main_loop(int gamef)
 {
-	viewer->sgroot->flip();
-	viewer->sgroot->lightCalc();
+	sgroot->sgroot->flip();
+	sgroot->sgroot->lightCalc();
 	
 
 	if ((pad[0].l1 != 0) && (pad[0].r1 != 0) &&
@@ -233,11 +231,11 @@
 	schedule();
 	enemyfaste = count;
     
-	timeprof_begin(timeprof_move);
+	// timeprof_begin(timeprof_move);
 	//Move(); //enemy move
 	collision_detect();
 	outofwindow();
-	timeprof_end(timeprof_move);
+	// timeprof_end(timeprof_move);
 	state_update();
 	asteroidi = 0;
 	//charpatern();
@@ -259,7 +257,7 @@
 	//PutSprite(count, 0, 0, 48);
 
 	obj_draw();
-	pause(joy);
+	game_pause(joy);
 
 	if (use_keybord) {
 	    keybord();
@@ -285,7 +283,8 @@
 }
 
 
-void gamesyokika(SDL_Joystick *joy)
+static void
+gamesyokika(SDL_Joystick *joy)
 {
     laser_lv3[0].r = 62;
     laser_lv3[0].r = 62;
@@ -321,8 +320,8 @@
     opening(joy);
 }
 
-
-void opening(SDL_Joystick *joy)
+static void
+opening(SDL_Joystick *joy)
 {
     //for (i = 0; i < 300; i++) {
     //};
@@ -374,8 +373,8 @@
     }
 }
 
-void
-pause(SDL_Joystick *joy)
+static void
+game_pause(SDL_Joystick *joy)
 {
     if (jiki.zanki != 0 && jiki.bf != FALSE) {
 	if (pad[0].se == 1) {
@@ -472,6 +471,7 @@
     }
 }
 
+
 SpriteTable sptable[DEFOBJ];
 
 
@@ -481,33 +481,23 @@
     sptable[number].my = middley;
 }
 
-static int power_of_two(int input)
-{
-    int value = 1;
 
-    while ( value < input ) {
-        value <<= 1;
-    }
-    return value;
-}
-
-
-void DefSprite(int number, char *name, float w, float h, int color, OBJECT *obj)
+void DefSprite(int number, const char *name, float w, float h, int color, OBJECT *obj)
 {
     SpriteTable *m = &sptable[number];
-    sptable[number].w = w;
-    sptable[number].h = h;
-    sptable[number].color = (color & 32);
-    sptable[number].mx = w / 2;
-    sptable[number].my = h / 2;
-    sptable[number].tex_w = power_of_two(sptable[number].w);
-    sptable[number].tex_h = power_of_two(sptable[number].h);
-    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;  
+    m->w = w;
+    m->h = h;
+    m->color = (color & 32);
+    m->mx = w / 2;
+    m->my = h / 2;
+    m->tex_w = power_of_two(sptable[number].w);
+    m->tex_h = power_of_two(sptable[number].h);
+    //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;  
     // printf("texMaxX = %f, w = %d, tex_w = %d\n", texMaxX[number], sptable[number].w, sptable[number].tex_w);
-    sptable[number].texture = (int *)name;
+    m->texture = (int *)name;
 
 }
 
@@ -515,18 +505,18 @@
 {
     SpriteTable *m = &sptable[number];
     char *name = (char *) m->texture;
-    SceneGraphPtr object = sgroot->createSceneGraph(m->name);
-    object->x = x;
-    object->y = y;
+    SceneGraphPtr object = sgroot->createSceneGraph(name);
+    object->xyz[0] = x;
+    object->xyz[1] = y;
 }
 
 void PutSpriteEx(int number, int x, int y, float scalex, float scaley, float angle)
 {
     SpriteTable *m = &sptable[number];
     char *name = (char *) m->texture;
-    SceneGraphPtr object = sgroot->createSceneGraph(m->name);
-    object->x = x;
-    object->y = y;
+    SceneGraphPtr object = sgroot->createSceneGraph(name);
+    object->xyz[0] = x;
+    object->xyz[1] = y;
 }
 
 
--- a/Dandy.h	Tue Dec 07 23:13:25 2010 +0900
+++ b/Dandy.h	Tue Dec 07 23:45:46 2010 +0900
@@ -8,7 +8,6 @@
 #include "Func.h"
 
 class Dandy : public Application {
-    Application* application();
     bool app_main(Viewer *viewer);
     HTaskPtr application_task(HTaskPtr next, Viewer* viewer);
     MainLoopPtr init(Viewer *viewer, int w, int h);
--- a/Makefile	Tue Dec 07 23:13:25 2010 +0900
+++ b/Makefile	Tue Dec 07 23:45:46 2010 +0900
@@ -9,7 +9,7 @@
 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 main.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 sys.o 
 
 all: $(TARGET)
 
@@ -17,7 +17,7 @@
 	./demo  -test
 
 demo: $(OBJS) sgoex.o
-	$(CC) $(ABI) -o $@ sgoex.o $(OBJS) $(LIBS)
+	$(CC) $(ABI) -o $@ main.o sgoex.o $(OBJS) $(LIBS)
 
 dandy: $(OBJS) Dandy.o
 	$(CC) $(ABI) -o $@ $(OBJS) Dandy.o $(LIBS)
--- a/main.c	Tue Dec 07 23:13:25 2010 +0900
+++ b/main.c	Tue Dec 07 23:45:46 2010 +0900
@@ -29,14 +29,13 @@
 
 #include "error.h"
 
-int gamef = 0;
-int use_keybord = 0;
-int cdp[20] = { 16, 16, 16, 17, 18, 0 };
-int d, i;
+static int gamef = 0;
+static int use_keybord = 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 Uint32 background;
 // static char *pad_trace_file;
@@ -63,7 +62,6 @@
  *     program will run with a trace file which is generated           
  *     by capture-mode
  */
-int runmode;
 
 #ifdef ENABLE_TRACEMODE
 #define SCMP_SIZ 8