changeset 19:00c3272a801f

fix.
author koba <koba@cr.ie.u-ryukyu.ac.jp>
date Sun, 26 Dec 2010 18:57:08 +0900
parents c330ded6d728
children 6487f54ba3d1
files ChangeLog Character.c Character.h Character_state.c Character_state.h Dandy.cc Func.h Makefile Makefile.def Makefile.mac Makefile.ps3 TaskDandy.cc collision_task.cc game_task.h ppe/Atari.cc ppe/Atari.h ppe/Bom.cc ppe/Character_state.h ppe/SimpleState.cc ppe/SimpleState.h ppe/task_init.cc ppe/task_object.h ppe/tobject.h property.h schedule3.c sgoex.c sound.c spe/Character_state.h state_task.cc state_task.h
diffstat 30 files changed, 535 insertions(+), 581 deletions(-) [+]
line wrap: on
line diff
--- a/ChangeLog	Fri Dec 17 22:18:11 2010 +0900
+++ b/ChangeLog	Sun Dec 26 18:57:08 2010 +0900
@@ -1,10 +1,11 @@
 2010-12-10  Yusuke KOBAYASHI  <koba@cr.ie.u-ryukyu.ac.jp>
 	* TODO
 	Texture のタペストリ
-	2D に最適な光源の設定(Yutaka)
+	2D に最適な光源の設定 Done!
 	Polygon の生成
 	Blender ファイルの新旧の整合性
 	Scale 1 で正常な表示
+	Scale を修正して正常な表示
 	タペストリを8の倍数に合わせる
 	Scale 1 & タペストリ修正した上でテスト
 	Task Ver & Fifo Ver の2画面で動作&検証
--- a/Character.c	Fri Dec 17 22:18:11 2010 +0900
+++ b/Character.c	Sun Dec 26 18:57:08 2010 +0900
@@ -17,6 +17,7 @@
 
 #include "error.h"
 #include "state_task.h"
+#include "Func.h"
 
 #define CHARACTER_MAX_POOL_SIZE 2048
 
@@ -55,6 +56,7 @@
       q[i] = (CHARACTER*)malloc(sizeof(CHARACTER));
       q[i]->f = FALSE;
       q[i]->state = noaction;
+      q[i]->task = 0;
       q[i]->collision = noaction;
     }
 
@@ -83,7 +85,6 @@
 	}
     }
   return 1;
-
 }
 
 void TFon()
@@ -97,7 +98,7 @@
 }
 
 
-void 
+void
 Putenemy(int charano, float x, float y, float vx, float vy,
 	 CHARACTER * (*action)(CHARACTER *chara))
 {
@@ -128,23 +129,11 @@
 
 }
 
-CHARACTER *
-delete_chara(CHARACTER *p)
-{
-
-  CHARACTER *parent = p;
-  p->f = FALSE;
-  p->state = noaction;
-  p->collision = noaction;
-  return parent;
-}
-
 void state_update()
 {
   CHARACTER *p;
   for(p = active_chara_list->next; p!= NULL  ;p = p->next)
     {
-      //      SimpleStateTask(p);
       p=(*p->state)(p);
     }
 }
@@ -154,11 +143,11 @@
   CHARACTER *p;
   for(p = active_chara_list->next; p!=NULL;p = p->next)
     {
-      if((p->state != chara_state8) && (p->state != chara_state9)
-	 && (p->collision != noaction))
-	{
+      //      if((p->state != chara_state8) && (p->state != chara_state9)
+      //	 && (p->collision != noaction))
+      //	{
 	  p=(*p->collision)(p);
-	}
+	  //	}
     }
 }
 
@@ -179,8 +168,8 @@
   CHARACTER *p;
   for(p = active_chara_list->next; p!=NULL; p = p->next)
     {
-      if((p->state != chara_state8) && (p->state != chara_state9))
-	{
+      //      if((p->state != chara_state8) && (p->state != chara_state9))
+      //      {
 	  if ((p->y > 964 + 32)
 	      || (p->x > 1688 + 50)
 	      || (p->y < 0 - 128)
@@ -190,6 +179,6 @@
 	      p->state = delete_chara;
 	      p->collision = noaction;
 	    }
-	}
+	  //	}
     }
 }
--- a/Character.h	Fri Dec 17 22:18:11 2010 +0900
+++ b/Character.h	Sun Dec 26 18:57:08 2010 +0900
@@ -15,6 +15,8 @@
 #define ENEMYBULLET 3
 
 //typedef void (*STATE)(CHARACTER *p);
+typedef struct CHARACTER * (*State)(struct CHARACTER *p);
+typedef struct CHARACTER * (*Collision)(struct CHARACTER *p);
 
 typedef struct enemy_status {
   int charano;                 // sprite image number
@@ -38,12 +40,12 @@
   BOOL tama; //bullet identifier
   BOOL f; //apiarance idenfifier
   float s;
-  //int group;
-  
-  struct CHARACTER * (*state)(struct CHARACTER *p);
-  struct CHARACTER * (*collision)(struct CHARACTER *p);
-  //STATE state;
-  //STATE collision;
+  //int group;  
+  int task;
+
+
+  State state;
+  Collision collision;
   struct CHARACTER *next;
   struct CHARACTER *prev;
 
--- a/Character_state.c	Fri Dec 17 22:18:11 2010 +0900
+++ b/Character_state.c	Sun Dec 26 18:57:08 2010 +0900
@@ -37,6 +37,17 @@
   return p;
 }
 
+CHARACTER *
+delete_chara(CHARACTER *p)
+{
+
+  CHARACTER *parent = p;
+  p->f = FALSE;
+  p->state = noaction;
+  p->collision = noaction;
+  return parent;
+}
+
 CHARACTER * chara_state0(CHARACTER *p)
 {
   p->x += p->vx;
--- a/Character_state.h	Fri Dec 17 22:18:11 2010 +0900
+++ b/Character_state.h	Sun Dec 26 18:57:08 2010 +0900
@@ -1,5 +1,6 @@
 
 CHARACTER * noaction(CHARACTER *p);
+CHARACTER * delete_chara(CHARACTER *p);
 CHARACTER * chara_state0(CHARACTER *p);
 CHARACTER * chara_state1(CHARACTER *p);
 CHARACTER * chara_state2(CHARACTER *p);
--- a/Dandy.cc	Fri Dec 17 22:18:11 2010 +0900
+++ b/Dandy.cc	Sun Dec 26 18:57:08 2010 +0900
@@ -151,7 +151,7 @@
 static void 
 _LightSysSwitch(Viewer *sgroot) {
   if (light_sysswitch == 1) {
-    sgroot->OnLightSysSwitch();
+    sgroot->OffLightSysSwitch();
     for (int i = 0; i < light_num; i++) {
         SceneGraphPtr light = sgroot->getLight(i);
         sgroot->OnLightSwitch(i);
@@ -242,8 +242,8 @@
     sgroot->sgroot->lightCalc();
 
     root = sgroot->createSceneGraph();
-    root->xyz[0] = screen_w/2;
-    root->xyz[1] = screen_h/2;;
+    root->xyz[0] = 0;
+    root->xyz[1] = 0;
     root->xyz[2] = 30.0f;
 
     /*親の回転、座標から、子の回転、座標を算出*/
--- a/Func.h	Fri Dec 17 22:18:11 2010 +0900
+++ b/Func.h	Sun Dec 26 18:57:08 2010 +0900
@@ -1,3 +1,6 @@
+#ifndef INCLUDE_FUNC
+#define INCLUDE_FUNC
+
 // Task ID
 enum {
 #include "SysTasks.h"
@@ -12,3 +15,5 @@
 #include "KeyID.h"
 #include "global_id.h"
 };
+
+#endif
--- a/Makefile	Fri Dec 17 22:18:11 2010 +0900
+++ b/Makefile	Sun Dec 26 18:57:08 2010 +0900
@@ -1,7 +1,6 @@
 default: macosx
 
 macosx: 
-	@echo "Make for Mac OS X"
 	@$(MAKE) -f Makefile.mac
 
 demo:
@@ -13,12 +12,8 @@
 t_dandy:
 	@$(MAKE) -f Makefile.mac t_dandy
 
-fifo64:
-	@$(MAKE) -f Makefile.macosx ABIBIT=64
-
 cell:
-	@echo "Make for PS3 (Cell)"
-	@$(MAKE) -f Makefile.ps3 dandy
+	@$(MAKE) -f Makefile.ps3 t_dandy
 
 clean:
 	@$(MAKE) -f Makefile.mac clean
--- a/Makefile.def	Fri Dec 17 22:18:11 2010 +0900
+++ b/Makefile.def	Sun Dec 26 18:57:08 2010 +0900
@@ -7,7 +7,7 @@
 ABIBIT = 32
 ABI = -m$(ABIBIT)
 CC      = g++
-OPT = -g #-O9
+OPT = -g
 CFLAGS  =  -Wall $(OPT) $(ABI)
 
 
--- a/Makefile.mac	Fri Dec 17 22:18:11 2010 +0900
+++ b/Makefile.mac	Sun Dec 26 18:57:08 2010 +0900
@@ -2,7 +2,7 @@
 include ./Makefile.def
 
 TARGET = demo dandy t_dandy
-OBJS    =  Character.o Bom.o tokuten.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 count2.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
 
 TASK_DIR  = ppe
 TASK_SRCS_TMP = $(wildcard $(TASK_DIR)/*.cc)
@@ -10,8 +10,8 @@
 TASK_SRCS = $(filter-out $(TASK_SRCS_EXCLUDE),$(TASK_SRCS_TMP))
 TASK_OBJS = $(TASK_SRCS:.cc=.o)
 
-CFLAGS  += -g $(ABI) -O2 -Wall `sdl-config --cflags` `xml2-config --cflags` $(INCLUDE)
-LIBS	+=  `sdl-config --libs`,-framework,OpenGL -lSDL_mixer -lSDL_image `xml2-config --libs`
+CFLAGS  += `sdl-config --cflags` `xml2-config --cflags` $(INCLUDE)
+LIBS	+=  `sdl-config --libs` -framework OpenGL -lSDL_mixer -lSDL_image `xml2-config --libs`
 LIBS += -lCerium -lFifoManager
 
 all: $(TARGET)
@@ -19,17 +19,17 @@
 test: $(TARGET)
 	./demo -test
 
-demo: $(OBJS) sgoex.o main.o collision.o
-	$(CC) $(ABI) -o $@ main.o sgoex.o collision.o $(OBJS) $(LIBS)
+demo: $(OBJS) main.o collision.o Character_state.o sgoex.o
+	$(CC) $(ABI) -o $@ $? $(LIBS)
 
-dandy: $(OBJS) Dandy.o collision.o
-	$(CC) $(ABI) -o $@ $(OBJS) Dandy.o collision.o $(LIBS)
+dandy: $(OBJS) Dandy.o collision.o  Character_state.o
+	$(CC) $(ABI) -o $@ $? $(LIBS)
 
-t_dandy: $(OBJS) TaskDandy.o collision_task.o $(TASK_OBJS)
-	$(CC) $(ABI) -o $@ $(OBJS) TaskDandy.o collision_task.o $(TASK_OBJS) $(LIBS)
+t_dandy: $(OBJS) TaskDandy.o collision_task.o state_task.o $(TASK_OBJS)
+	$(CC) $(ABI) -o $@ $? $(LIBS)
 
 clean:
-	rm -f $(TARGET) $(OBJS) $(TASK_OBJS) Dandy.o TaskDandy.o sgoex.o main.o
+	rm -f $(TARGET) $(OBJS) $(TASK_OBJS) Dandy.o TaskDandy.o main.o Character_state.o collision_task.o sgoex.o 
 
 .c.o:
 	$(CC) $(CFLAGS) $(INCLUDES) -c $< -o $@
--- a/Makefile.ps3	Fri Dec 17 22:18:11 2010 +0900
+++ b/Makefile.ps3	Sun Dec 26 18:57:08 2010 +0900
@@ -3,9 +3,9 @@
 
 ABI = -m32
 
-CFLAGS  += -g $(ABI) -O2 -Wall `/usr/bin/sdl-config --cflags` `xml2-config --cflags` $(INCLUDE)
-LIBS	+=  `/usr/bin/sdl-config --libs` -lGL -lGLU -lSDL_mixer -lSDL_image `xml2-config --libs`
-LIBS +=  -lCerium -lCellManager  -lspe2 -lpthread
+CFLAGS  += `/usr/bin/sdl-config --cflags` `xml2-config --cflags`
+LIBS	+= `sdl-config --libs` -lGL -lGLU -lSDL_mixer -lSDL_image `xml2-config --libs`
+LIBS +=  -lCerium -lCellManager -lspe2
 
 TASK_DIR  = spe
 TASK_SRCS_TMP = $(wildcard $(TASK_DIR)/*.cc)
@@ -21,35 +21,35 @@
 speobject:
 	cd spe; $(MAKE)
 
-link:
+spe-main:
 	ln -s $(CERIUM)/Renderer/Engine/spe-main .
 
 run: $(TARGET)
 	sudo ./$(TARGET) -width 576 -height 384 -bpp 32
-run-hd: $(TARGET)
+run-hd:
 	sudo /usr/sbin/ps3-video-mode -v 133
-	sudo ./$(TARGET) -video fb -width 1920 -height 1080 -bpp 32
+	sudo ./t_dandy -video fb -width 1920 -height 1080 -bpp 32
 
-test: $(TARGET)
+test:
 	./demo  -test
 
 demo: $(OBJS) sgoex.o main.o collision.o
-	$(CC) $(ABI) -o $@ main.o sgoex.o collision.o $(OBJS) $(LIBS)
+	$(CC) $(ABI) -o $@ $? $(LIBS)
 
 dandy: $(OBJS) Dandy.o collision.o
-	$(CC) $(ABI) -o $@ $(OBJS) Dandy.o collision.o $(LIBS)
+	$(CC) $(ABI) -o $@ $? $(LIBS)
 
 t_dandy: $(OBJS) $(TASK_OBJS) TaskDandy.o collision_task.o
-	 $(CC) $(ABI) -o $@ $(OBJS) $(TASK_OBJS) TaskDandy.o collision_task.o $(LIBS)
+	 $(CC) $(ABI) -o $@ $? $(LIBS)
 
 clean:
 	rm -f $(TARGET) $(OBJS) sgoex.o main.o Dandy.o $(TASK_DIR)/*.o
 	cd spe;$(MAKE) clean
 
 .c.o:
-	$(CC) $(CFLAGS) $(INCLUDES) -c $< -o $@
+	$(CC) $(CFLAGS) $(INCLUDE) -c $< -o $@
 
 .cc.o:
-	$(CC) $(CFLAGS) $(INCLUDES) -c $< -o $@
+	$(CC) $(CFLAGS) $(INCLUDE) -c $< -o $@
 
-debug.o:debug.h
+debug.o:debug.h
\ No newline at end of file
--- a/TaskDandy.cc	Fri Dec 17 22:18:11 2010 +0900
+++ b/TaskDandy.cc	Sun Dec 26 18:57:08 2010 +0900
@@ -30,6 +30,7 @@
 #include "Character.h"
 #include "Character_state.h"
 #include "property.h"
+#include "state_task.h"
 
 int use_keybord = 0;
 int cdp[20] = { 16, 16, 16, 17, 18, 0 };
@@ -147,7 +148,7 @@
 static void 
 _LightSysSwitch(Viewer *sgroot) {
   if (light_sysswitch == 1) {
-    sgroot->OnLightSysSwitch();
+    sgroot->OffLightSysSwitch();
     for (int i = 0; i < light_num; i++) {
         SceneGraphPtr light = sgroot->getLight(i);
         sgroot->OnLightSwitch(i);
@@ -222,6 +223,8 @@
 
     __debug("finished init_chara_list\n");
 
+    initStateList();
+
     return 1;
 }
 
@@ -238,8 +241,8 @@
     sgroot->sgroot->lightCalc();
 
     root = sgroot->createSceneGraph();
-    root->xyz[0] = screen_w/2;
-    root->xyz[1] = screen_h/2;;
+    root->xyz[0] = 0;
+    root->xyz[1] = 0;
     root->xyz[2] = 30.0f;
 
     /*親の回転、座標から、子の回転、座標を算出*/
@@ -375,9 +378,9 @@
 
     count = 1;
 
-    PutSprite(count, 700, 480, 53); //  put `push start' string on screen.  
+    PutSprite(count, 700, 480, 53); //  put `push start' string on screen.
     count++;
-    PutSprite(count, 224, 776, 119); //  put `super dandy'                   
+    PutSprite(count, 224, 776, 119); //  put `super dandy'
     count++;
     //    PutSprite(count, 200, 64, 190);
     //    PutSpriteEx(count, 8192, 8192, 0);
@@ -401,7 +404,7 @@
     } else if ((pad[0].se > 0) && (pad[0].st > 0)) {
 	gamef = 2;
     }
-    flip();  
+    flip();
     return gamef;
 }
 
@@ -542,16 +545,16 @@
 {
     SpriteTable *m = &sptable[number];
     char *name = (char *) m->texture;
-if (!name) {
-    printf("PutSprite %d unknown\n",number);
-    return;
-}
+    if (!name) {
+	printf("PutSprite %d unknown\n",number);
+	return;
+    }
     SceneGraphPtr object = sgroot->createSceneGraph(name);
     object->xyz[0] = x;
     object->xyz[1] = y;
     object->xyz[2] = 0;
     root->addChild(object);
-
+    
     float scale[] = {5,5,1};
     /*親の回転、座標から、子の回転、座標を算出*/
     get_matrix(object->matrix, object->angle, object->xyz, scale, root->matrix);
@@ -565,10 +568,10 @@
 {
     SpriteTable *m = &sptable[number];
     char *name = (char *) m->texture;
-if (!name) {
-    printf("PutSpriteEx %d unknown\n",number);
-    return;
-}
+    if (!name) {
+	printf("PutSpriteEx %d unknown\n",number);
+	return;
+    }
     SceneGraphPtr object = sgroot->createSceneGraph(name);
     object->xyz[0] = x;
     object->xyz[1] = y;
--- a/collision_task.cc	Fri Dec 17 22:18:11 2010 +0900
+++ b/collision_task.cc	Sun Dec 26 18:57:08 2010 +0900
@@ -18,36 +18,33 @@
 extern TaskManager *tmanager;
 
 CollisionPropertyPtr
-get_property(CHARACTER *p)
+get_property()
 {
     CollisionPropertyPtr property = (CollisionPropertyPtr)tmanager->allocate(sizeof(CollisionProperty));
-    
+
     property->bomend = bomend;
-    property->infg_level = infg_level;
     property->enemycount = 0;
+    property->infg_level = infg_level;
 
-    property->jiki = jiki;
-    property->p = *p;
-    property->tlv3 = tlv3[0];
     property->lg = lg;
     property->infg = infg;
-
+    property->jiki = jiki;
+    property->tlv3 = tlv3[0];
 
-    memcpy(property->tama_lv1, &tama_lv1, sizeof(tama1)*20); 
-    memcpy(property->tama_lv2, &tama_lv2, sizeof(tama2)*20);
-    memcpy(property->laser_lv1, &laser_lv1, sizeof(laser)*20);
-    memcpy(property->laser_lv2, &laser_lv2, sizeof(laser)*20);
-    memcpy(property->laser_lv3, &laser_lv3, sizeof(laser)*128);
-    memcpy(property->bchar, &bchar, sizeof(bomchar)*100);
+    memcpy(property->tama_lv1, tama_lv1, sizeof(tama1)*20);
+    memcpy(property->tama_lv2, tama_lv2, sizeof(tama2)*20);
+    memcpy(property->laser_lv1, laser_lv1, sizeof(laser)*20);
+    memcpy(property->laser_lv2, laser_lv2, sizeof(laser)*20);
+    memcpy(property->laser_lv3, laser_lv3, sizeof(laser)*128);
+    memcpy(property->bchar, bchar, sizeof(bomchar)*100);
 
     return property;
 }
 
 void
-free_property(SchedTask *s, void *prop, void *chara)
+free_property(SchedTask *s, void *prop, void *arg)
 {
     CollisionPropertyPtr property = (CollisionPropertyPtr)prop;
-    CHARACTER *character = (CHARACTER *)chara;
 
     if(bomend > property->bomend) {
 	bomend = property->bomend;
@@ -62,7 +59,6 @@
     jiki.zanki = property->jiki.zanki;
     jiki.muteki = property->jiki.muteki;
 
-    *character = property->p;
     infg = property->infg;
 
     memcpy(tama_lv1, property->tama_lv1, sizeof(tama1)*20);    
@@ -74,10 +70,11 @@
 }
 
 
-CHARACTER *atari(CHARACTER *p)
+CHARACTER*
+atari(CHARACTER *p)
 {
     int w, h, charno;
-    CollisionPropertyPtr property = get_property(p);
+    CollisionPropertyPtr property = get_property();
 
     charno = p->charano;
     w = sptable[charno].w;
@@ -87,14 +84,15 @@
 
     collision_task->set_param(0,(memaddr)w);
     collision_task->set_param(1,(memaddr)h);
-    collision_task->set_param(2,(memaddr)enemycount);
-    collision_task->set_param(3,(memaddr)tama_lv1_end);
-    collision_task->set_param(4,(memaddr)tama_lv2_end);
-    collision_task->set_param(5,(memaddr)laser_lv1_end);
+    collision_task->set_param(2,(memaddr)tama_lv1_end);
+    collision_task->set_param(3,(memaddr)tama_lv2_end);
+    collision_task->set_param(4,(memaddr)laser_lv1_end);
 
     collision_task->add_inData(property, sizeof(CollisionProperty));
+    collision_task->add_inData(p, sizeof(CHARACTER));
     collision_task->add_outData(property, sizeof(CollisionProperty));
-    collision_task->set_post(free_property, property, p);
+    collision_task->add_outData(p, sizeof(CHARACTER));
+    collision_task->set_post(free_property, (void*)property, NULL);
 
     collision_task->set_cpu(SPE_ANY);
     collision_task->spawn();
--- a/game_task.h	Fri Dec 17 22:18:11 2010 +0900
+++ b/game_task.h	Sun Dec 26 18:57:08 2010 +0900
@@ -1,7 +1,7 @@
 // Game で使用する Task ID
      ATARI,
-     SIMPLE_STATE,
      NO_ACT,
+     DELETE_CHARA,
      STATE0,
      STATE1,
      STATE2,
@@ -44,4 +44,3 @@
      STATE600,
      STATE601,
      STATE602,
-     ASTEROID,
--- a/ppe/Atari.cc	Fri Dec 17 22:18:11 2010 +0900
+++ b/ppe/Atari.cc	Sun Dec 26 18:57:08 2010 +0900
@@ -1,5 +1,5 @@
 #include "Atari.h"
-#include "tobject.h"
+#include "task_object.h"
 
 SchedDefineTask(Atari);
 
@@ -8,21 +8,21 @@
 {
     int w = (int)smanager->get_param(0);
     int h = (int)smanager->get_param(1);
-    int enemycount = (int)smanager->get_param(2);
-    int bomend = (int)smanager->get_param(3);
-    int tama_lv1_end = (int)smanager->get_param(4);
-    int tama_lv2_end = (int)smanager->get_param(5);
-    int laser_lv1_end = (int)smanager->get_param(6);
+    int tama_lv1_end = (int)smanager->get_param(2);
+    int tama_lv2_end = (int)smanager->get_param(3);
+    int laser_lv1_end = (int)smanager->get_param(4);
 
     CollisionPropertyPtr property
 	= (CollisionPropertyPtr)smanager->get_input(rbuf, 0);
+    CHARACTER *p =  (CHARACTER*)smanager->get_input(rbuf, 1);
 
+    int *bomend = &property->bomend;
+    int *enemycount = &property->enemycount;
     int infg_level = property->infg_level;
-    player *jiki = &property->jiki;
-    CHARACTER *p = &property->p;
-    tama1 *tlv3 = &property->tlv3;
     stge lg = property->lg;
     stge infg = property->infg;
+    player jiki = property->jiki;
+    tama1 tlv3 = property->tlv3;
 
     tama1 *tama_lv1 = property->tama_lv1;
     tama2 *tama_lv2 = property->tama_lv2;
@@ -38,13 +38,13 @@
 
 //自機やられ
 #ifndef INVISIBLE_MODE
-    if ((ex < jiki->x + 128 / 2) && (ex + w > jiki->x + 128 / 2)
-	&& (ey < jiki->y + 128 / 2) && (ey + h > jiki->y + 128 / 2)
-	&& jiki->muteki == 0) {
-	Bom(jiki->x + 16, jiki->y + 16, bomend, bchar);
-	jiki->bf = FALSE;
-	jiki->zanki--;
-	jiki->muteki = 120;
+    if ((ex < jiki.x + 128 / 2) && (ex + w > jiki.x + 128 / 2)
+	&& (ey < jiki.y + 128 / 2) && (ey + h > jiki.y + 128 / 2)
+	&& jiki.muteki == 0) {
+	Bom(jiki.x + 16, jiki.y + 16, bomend, bchar);
+	jiki.bf = FALSE;
+	jiki.zanki--;
+	jiki.muteki = 120;
 
 	infg.stg = 0;
 	infg_level--;
@@ -53,6 +53,7 @@
 
 	property->infg_level = infg_level;
 	property->infg = infg;
+	property->jiki = jiki;
 	smanager->swap();
 	return 0;
     }
@@ -74,8 +75,8 @@
 		Bom(p->x, p->y, bomend, bchar);
 		enemycount += (p->score *
 			       ((infg.stg / 128) + infg_level + 1));
-		p->state = delete_chara;
-		p->collision = noaction;
+		p->task = DELETE_CHARA;
+//		p->collision = noaction;
 		p->f = FALSE;
 
 		property->infg = infg;
@@ -94,8 +95,8 @@
 		Bom(p->x, p->y, bomend, bchar);
 		enemycount += (p->score *
 			       ((infg.stg / 128) + infg_level + 1));
-		p->state = delete_chara;
-		p->collision = noaction;
+		p->task = DELETE_CHARA;
+//		p->collision = noaction;
 		p->f = FALSE;
 
 		property->infg = infg;
@@ -118,8 +119,8 @@
 		Bom(p->x, p->y, bomend, bchar);
 		enemycount += (p->score *
 			       ((infg.stg / 128) + infg_level + 1));
-		p->state = delete_chara;
-		p->collision = noaction;
+		p->task = DELETE_CHARA;
+//		p->collision = noaction;
 		p->f = FALSE;
 
 		property->infg = infg;
@@ -141,8 +142,8 @@
 		Bom(p->x, p->y, bomend, bchar);
 		enemycount += (p->score *
 			       ((infg.stg / 128) + infg_level + 1));
-		p->state = delete_chara;
-		p->collision = noaction;
+		p->task = DELETE_CHARA;
+//		p->collision = noaction;
 		p->f = FALSE;
 
 		property->infg = infg;
@@ -162,8 +163,8 @@
 		Bom(p->x, p->y, bomend, bchar);
 		enemycount += (p->score *
 			       ((infg.stg / 128) + infg_level + 1));
-		p->state = delete_chara;
-		p->collision = noaction;
+		p->task = DELETE_CHARA;
+//		p->collision = noaction;
 		p->f = FALSE;
 
 		property->infg = infg;
@@ -183,8 +184,8 @@
 		Bom(p->x, p->y, bomend, bchar);
 		enemycount += (p->score *
 			       ((infg.stg / 128) + infg_level + 1));
-		p->state = delete_chara;
-		p->collision = noaction;
+		p->task = DELETE_CHARA;
+//		p->collision = noaction;
 		p->f = FALSE;
 
 		property->infg = infg;
@@ -193,8 +194,8 @@
 	    }
 	}
     }
-    if ((tlv3[0].r > 0) && (jiki->x < ex + w) && (jiki->x + 128 > ex)
-	&& (jiki->y > ey + h)) {
+    if ((tlv3.r > 0) && (jiki.x < ex + w) && (jiki.x + 128 > ex)
+	&& (jiki.y > ey + h)) {
 	p->vit -= TAMALV3P;
 	infg.stg++;
 	if (p->vit <= 0) {
@@ -202,8 +203,8 @@
 	    Bom(p->x, p->y, bomend, bchar);
 	    enemycount += (p->score *
 			   ((infg.stg / 128) + infg_level + 1));
-	    p->state = delete_chara;
-	    p->collision = noaction;
+	    p->task = DELETE_CHARA;
+//	    p->collision = noaction;
 	    p->f = FALSE;
 
 	    property->infg = infg;
@@ -212,8 +213,8 @@
 	}
     }
   jumping:
-    if ((tlv3[0].r > 0) && (jiki->x < ex + w) && (jiki->x + 128 > ex)
-	&& (jiki->y + 128 > ey) && (jiki->y < ey + h)) {
+    if ((tlv3.r > 0) && (jiki.x < ex + w) && (jiki.x + 128 > ex)
+	&& (jiki.y + 128 > ey) && (jiki.y < ey + h)) {
 	p->vit -= TAMALV3P;
 	infg.stg++;
 	if (p->vit <= 0) {
@@ -221,8 +222,8 @@
 	    Bom(p->x, p->y, bomend, bchar);
 	    enemycount += (p->score *
 			   ((infg.stg / 128) + infg_level + 1));
-	    p->state = delete_chara;
-	    p->collision = noaction;
+	    p->task = DELETE_CHARA;
+//	    p->collision = noaction;
 	    p->f = FALSE;
 
 	    property->infg = infg;
@@ -246,8 +247,8 @@
 		Bom(p->x, p->y, bomend, bchar);
 		enemycount += (p->score *
 			       ((infg.stg / 128) + infg_level + 1));
-		p->state = delete_chara;
-		p->collision = noaction;
+		p->task = DELETE_CHARA;
+//		p->collision = noaction;
 		p->f = FALSE;
 
 		property->infg = infg;
@@ -269,8 +270,8 @@
 	    Bom(p->x, p->y, bomend, bchar);
 	    enemycount += (p->score *
 			   ((infg.stg / 128) + infg_level + 1));
-	    p->state = delete_chara;
-	    p->collision = noaction;
+	    p->task = DELETE_CHARA;
+//	    p->collision = noaction;
 	    p->f = FALSE;
 
 	    property->lg = lg;
@@ -294,8 +295,8 @@
 		    Bom(p->x, p->y, bomend, bchar);
 		    enemycount += (p->score *
 				   ((infg.stg / 128) + infg_level + 1));
-		    p->state = delete_chara;
-		    p->collision = noaction;
+		    p->task = DELETE_CHARA;
+//		    p->collision = noaction;
 		    p->f = FALSE;
 
 		    property->infg = infg;
--- a/ppe/Atari.h	Fri Dec 17 22:18:11 2010 +0900
+++ b/ppe/Atari.h	Sun Dec 26 18:57:08 2010 +0900
@@ -1,6 +1,10 @@
 #ifndef INCLUDE_COLLISION
 #define INCLUDE_COLLISION
 
+#ifndef INCLUDE_FUNC
+#include "../Func.h"
+#endif
+
 #ifndef INCLUDED_SCHED_TASK
 #include "SchedTask.h"
 #endif
--- a/ppe/Bom.cc	Fri Dec 17 22:18:11 2010 +0900
+++ b/ppe/Bom.cc	Sun Dec 26 18:57:08 2010 +0900
@@ -1,16 +1,16 @@
-#include "tobject.h"
+#include "task_object.h"
 
 void
-Bom(int x, int y, int bomend, bomchar *bchar)
+Bom(int x, int y, int *bomend, bomchar *bchar)
 {
     int i;
-    bomend++;
-    if (bomend > 49) {
-	bomend = 49;
+    *bomend++;
+    if (*bomend > 49) {
+	*bomend = 49;
 	return;
     }
 
-    i = bomend;
+    i = *bomend;
     bchar[i].x = x;
     bchar[i].y = y;
     bchar[i].no = 0;
--- a/ppe/Character_state.h	Fri Dec 17 22:18:11 2010 +0900
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,57 +0,0 @@
-#ifndef INCLUDE_CHARACTER_STATE
-#define INCLUDE_CHARACTER_STATE
-
-#ifndef INCLUDE_OBJECT
-#include "tobject.h"
-#endif
-
-CHARACTER * noaction(CHARACTER *p);
-CHARACTER * chara_state0(CHARACTER *p);
-CHARACTER * chara_state1(CHARACTER *p);
-CHARACTER * chara_state2(CHARACTER *p);
-CHARACTER * chara_state3(CHARACTER *p);
-CHARACTER * chara_state4(CHARACTER *p);
-CHARACTER * chara_state5(CHARACTER *p);
-CHARACTER * chara_state6(CHARACTER *p);
-CHARACTER * chara_state7(CHARACTER *p);
-CHARACTER * chara_state8(CHARACTER *p);
-CHARACTER * chara_state9(CHARACTER *p);
-CHARACTER * chara_state10(CHARACTER *p);
-CHARACTER * chara_state11(CHARACTER *p);
-CHARACTER * chara_state12(CHARACTER *p);
-CHARACTER * chara_state13(CHARACTER *p);
-CHARACTER * chara_state20(CHARACTER *p);
-CHARACTER * chara_state21(CHARACTER *p);
-CHARACTER * chara_state22(CHARACTER *p);
-CHARACTER * chara_state23(CHARACTER *p);
-CHARACTER * chara_state24(CHARACTER *p);
-CHARACTER * chara_state25(CHARACTER *p);
-CHARACTER * chara_state26(CHARACTER *p);
-CHARACTER * chara_state27(CHARACTER *p);
-CHARACTER * chara_state28(CHARACTER *p);
-CHARACTER * chara_state29(CHARACTER *p);
-CHARACTER * chara_state30(CHARACTER *p);
-CHARACTER * chara_state31(CHARACTER *p);
-CHARACTER * chara_state32(CHARACTER *p);
-CHARACTER * chara_state33(CHARACTER *p);
-CHARACTER * chara_state34(CHARACTER *p);
-CHARACTER * chara_state35(CHARACTER *p);
-CHARACTER * chara_state40(CHARACTER *p);
-CHARACTER * chara_state41(CHARACTER *p);
-CHARACTER * chara_state400(CHARACTER *p);
-CHARACTER * chara_state401(CHARACTER *p);
-CHARACTER * chara_state402(CHARACTER *p);
-CHARACTER * chara_state410(CHARACTER *p);
-CHARACTER * chara_state411(CHARACTER *p);
-CHARACTER * chara_state500(CHARACTER *p);
-CHARACTER * chara_state501(CHARACTER *p);
-CHARACTER * chara_state600(CHARACTER *p);
-CHARACTER * chara_state601(CHARACTER *p);
-CHARACTER * chara_state602(CHARACTER *p);
-CHARACTER * asteroid(CHARACTER *p);
-
-extern int enemyfaste;
-extern int fastebos;
-extern int asteroidi;
-
-#endif
--- a/ppe/SimpleState.cc	Fri Dec 17 22:18:11 2010 +0900
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,15 +0,0 @@
-#include "SimpleState.h"
-#include "Character_state.h"
-#include "tobject.h"
-
-SchedDefineTask(SimpleState);
-
-static int
-run(SchedTask *smanager, void *rbuf, void *wbuf)
-{
-    CHARACTER *p = (CHARACTER*)smanager->get_input(rbuf, 0);
-    p = (*p->state)(p);
-    
-    smanager->swap();
-    return 0;
-}
--- a/ppe/SimpleState.h	Fri Dec 17 22:18:11 2010 +0900
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,8 +0,0 @@
-#ifndef INCLUDE_SIMPLE_STATE
-#define INCLUDE_SIMPLE_STATE
-
-#ifndef INCLUDED_SCHED_TASK
-#include "SchedTask.h"
-#endif
-
-#endif
--- a/ppe/task_init.cc	Fri Dec 17 22:18:11 2010 +0900
+++ b/ppe/task_init.cc	Sun Dec 26 18:57:08 2010 +0900
@@ -3,7 +3,6 @@
 
 /* 必ずこの位置に書いて */
 SchedExternTask(Atari);
-SchedExternTask(SimpleState);
 
 /**
  * この関数は ../spe/spe-main と違って
@@ -14,5 +13,4 @@
 task_init(void)
 {
     SchedRegisterTask(ATARI, Atari);
-    SchedRegisterTask(SIMPLE_STATE, SimpleState);
 }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/ppe/task_object.h	Sun Dec 26 18:57:08 2010 +0900
@@ -0,0 +1,119 @@
+#ifndef INCLUDE_OBJECT
+#define INCLUDE_OBJECT
+
+#define TAMALV1P 14
+#define TAMALV2P 50
+#define TAMALV3P 24
+
+#define LASERLV1P 17
+#define LASERLV2P 154
+#define LASERLV3P 51
+
+#define TRUE 1
+#define FALSE 0
+#define BOOL char
+
+typedef struct player {
+    int x;
+    int y;
+    int ch;
+    int point;
+    BOOL bf;
+    int muteki;
+    int zanki;
+    int ccount;
+} player;
+
+typedef struct tama {
+    int x;
+    int y;
+} tama;
+
+typedef struct tama1 {
+    int x;
+    int y;
+    int r;
+    int l;
+} tama1;
+
+typedef struct tama2 {
+    int x;
+    int y;
+    int rr;
+    int sr;
+    int sl;
+    int ll;
+} tama2;
+
+typedef struct stge {
+    int stg;
+} stge;
+
+typedef struct laser {
+    float x;
+    float y;
+    float sx;
+    float sy;
+    int r;
+    int enemyno;
+  float s;
+} laser;
+
+typedef struct bomchar {
+    int x;
+    int y;
+    int f;
+    int no;
+} bomchar;
+
+typedef struct CHARACTER{
+  float x; //position
+  float y;
+ 
+  float vx; //velocity
+  float vy;
+
+  float vit; //vitality
+  int score;
+  int dt1;
+  int dt2;
+  int charano; //sprite_number
+  BOOL tama; //bullet identifier
+  BOOL f; //apiarance idenfifier
+  float s;
+  int task;
+
+  struct CHARACTER * (*state)(struct CHARACTER *p);
+  struct CHARACTER * (*collision)(struct CHARACTER *p);
+  struct CHARACTER *next;
+  struct CHARACTER *prev;
+
+} CHARACTER;
+
+typedef struct CollisionProperty {
+  int bomend;
+  int enemycount;
+  int infg_level;
+
+  stge lg;
+  stge infg;
+  player jiki;
+  CHARACTER p;
+
+  tama1 tama_lv1[20];
+  tama2 tama_lv2[20];
+  tama1 tlv3;
+  laser laser_lv1[20];
+  laser laser_lv2[20];
+  laser laser_lv3[128];
+  bomchar bchar[100];
+
+} CollisionProperty, *CollisionPropertyPtr;
+
+CHARACTER * noaction(CHARACTER *p);
+CHARACTER * delete_chara(CHARACTER *p);
+void Bom(int x, int y, int *bomend, bomchar *bchar);
+void Puttama(int type, float x, float y);
+void Putenemy(int charano, float x, float y, float vx, float vy, int task);
+
+#endif
--- a/ppe/tobject.h	Fri Dec 17 22:18:11 2010 +0900
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,115 +0,0 @@
-#ifndef INCLUDE_OBJECT
-#define INCLUDE_OBJECT
-
-#define TAMALV1P 14
-#define TAMALV2P 50
-#define TAMALV3P 24
-
-#define LASERLV1P 17
-#define LASERLV2P 154
-#define LASERLV3P 51
-
-#define TRUE 1
-#define FALSE 0
-#define BOOL char
-
-typedef struct player {
-    int x;
-    int y;
-    int ch;
-    int point;
-    BOOL bf;
-    int muteki;
-    int zanki;
-    int ccount;
-} player;
-
-typedef struct tama {
-    int x;
-    int y;
-} tama;
-
-typedef struct tama1 {
-    int x;
-    int y;
-    int r;
-    int l;
-} tama1;
-
-typedef struct tama2 {
-    int x;
-    int y;
-    int rr;
-    int sr;
-    int sl;
-    int ll;
-} tama2;
-
-typedef struct stge {
-    int stg;
-} stge;
-
-typedef struct laser {
-    float x;
-    float y;
-    float sx;
-    float sy;
-    int r;
-    int enemyno;
-  float s;
-} laser;
-
-typedef struct bomchar {
-    int x;
-    int y;
-    int f;
-    int no;
-} bomchar;
-
-typedef struct CHARACTER{
-  float x; //position
-  float y;
- 
-  float vx; //velocity
-  float vy;
-
-  float vit; //vitality
-  int score;
-  int dt1;
-  int dt2;
-  int charano; //sprite_number
-  BOOL tama; //bullet identifier
-  BOOL f; //apiarance idenfifier
-  float s;
-  
-  struct CHARACTER * (*state)(struct CHARACTER *p);
-  struct CHARACTER * (*collision)(struct CHARACTER *p);
-  struct CHARACTER *next;
-  struct CHARACTER *prev;
-
-} CHARACTER;
-
-typedef struct CollisionProperty {
-  int infg_level;
-  int enemycount;
-
-  player jiki;
-  CHARACTER p;
-  stge lg;
-  stge infg;
-
-  tama1 tama_lv1[20];
-  tama2 tama_lv2[20];
-  tama1 tlv3;
-  laser laser_lv1[20];
-  laser laser_lv2[20];
-  laser laser_lv3[128];
-  bomchar bchar[100];
-
-} CollisionProperty, *CollisionPropertyPtr;
-
-CHARACTER * noaction(CHARACTER *p);
-CHARACTER * delete_chara(CHARACTER *p);
-void Bom(int x, int y, int bchar, bomchar *bchar);
-
-#endif
--- a/property.h	Fri Dec 17 22:18:11 2010 +0900
+++ b/property.h	Sun Dec 26 18:57:08 2010 +0900
@@ -12,7 +12,6 @@
   int infg_level;
 
   player jiki;
-  CHARACTER p;
   stge lg;
   stge infg;
 
--- a/schedule3.c	Fri Dec 17 22:18:11 2010 +0900
+++ b/schedule3.c	Sun Dec 26 18:57:08 2010 +0900
@@ -20,8 +20,8 @@
 void schedule()
 {
   CHARACTER *p;
-    int i;
-    if (stage == 0)
+  int i;
+  if (stage == 0)
     {
 	switch (filpcount) {
 	case 1:
@@ -140,6 +140,7 @@
 	    Putenemy(1, 1280 - 256 - 128, 1088, 0, -1, chara_state5);
 	    break;
 
+#if 0
 	case FRAME_RATE * 50:
 	    Putenemy(40, rand() % (1280 - 256) + 128, -128, 0, 1, chara_state3);
 	    break;
@@ -149,6 +150,7 @@
 	case FRAME_RATE * 54:
 	    Putenemy(40, rand() % (1280 - 256) + 128, -128, 0, 1, chara_state3);
 	    break;
+#endif
 
 	case FRAME_RATE * 60:
 	    Putenemy(1, 256, 1088, 0, -1, chara_state6);
@@ -175,6 +177,7 @@
 	    Putenemy(40, 1280 - 256 - 128, 1088, 0, -1, chara_state6);
 	    break;
 
+#if 0
 	case FRAME_RATE * 80:
 	    Putenemy(42, rand() % (1280 - 256) + 128, -128, 0, 1, chara_state7);
 	    break;
@@ -239,8 +242,10 @@
 		p->collision = noaction;
 	      }
 	    Putenemy(4, 520, -128, 0, 1, chara_state8);	// 1面ボスをPutenemy
+#endif
 	}			//case文
 
+#if 0
 	//kyeenemynoはenemyオブジェクトのID。
 	//ボスが登場していないときはkyeenemynoに-1がセットされる。
 	//move.cではenemyオブジェクトのIDはtekinoで扱うが、
@@ -262,10 +267,12 @@
 	      clear_result[0] = infg_level;
 	    }
 	}
-    }				//stage0.end
-
+#endif
+    }			//stage0.end
+    
+#if 0
     if (stage == 1) {
-	switch (filpcount) {
+      switch (filpcount) {
 	case 1:
 	    SoundStop();
 	    SoundPlay(1);
@@ -720,5 +727,5 @@
 	if (filpcount > 4000)
 	    filpcount = 4000;
 	}
+#endif
 }
-
--- a/sgoex.c	Fri Dec 17 22:18:11 2010 +0900
+++ b/sgoex.c	Sun Dec 26 18:57:08 2010 +0900
@@ -57,13 +57,6 @@
   関数プロトタイプ
   ---------------------------------------------------------------*/
 
-void DefSpriteEx(int number, short middlex, short middley)
-{
-    sptable[number].mx = middlex;
-    sptable[number].my = middley;
-}
-
-
 void SDL_GL_Enter2DMode()
 {
     //	SDL_Surface *sc = SDL_GetVideoSurface();
@@ -119,8 +112,15 @@
     return value;
 }
 
+void
+DefSpriteEx(int number, short middlex, short middley)
+{
+    sptable[number].mx = middlex;
+    sptable[number].my = middley;
+}
 
-void DefSprite(int number, const 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)
 {
     SURFACE *surfaces;
     surfaces = search_node(obj, name);
@@ -142,14 +142,14 @@
     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);
+//    printf("texMaxX = %f, w = %d, tex_w = %d\n", texMaxX[number], sptable[number].w, sptable[number].tex_w);
     sptable[number].texture = surfaces->texture;
 }
 
-void PutSprite(int zorder, short x, short y, int number)
+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);
@@ -161,7 +161,8 @@
     glDisable(GL_BLEND);
 }
 
-void PutSpriteEx(int number, int x, int y, float scalex, float scaley, float angle)
+void
+PutSpriteEx(int number, int x, int y, float scalex, float scaley, float angle)
 {
     SpriteTable *m = &sptable[number];
     x -= m->w;
@@ -171,7 +172,7 @@
     glEnable(GL_TEXTURE_2D);
     glEnable(GL_BLEND);
     glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
-    glBindTexture(GL_TEXTURE_2D, (GLuint)sptable[number].texture);
+    glBindTexture(GL_TEXTURE_2D, (GLuint&)sptable[number].texture);
     glTranslatef(x + m->w/2, y + m->h/2, 0.0);
     glRotatef(angle, 0.0, 0.0, 1.0);
     glScalef(scalex, scaley, 1.0);
--- a/sound.c	Fri Dec 17 22:18:11 2010 +0900
+++ b/sound.c	Sun Dec 26 18:57:08 2010 +0900
@@ -15,11 +15,13 @@
 int channel[8];
 //_________________________________________________________
 
+#if 0
 static char buf0[] = "pBAV";
 
-int vh_addr[10] =
-{ (int) buf0, (int) buf0, (int) buf0, (int) buf0, (int) buf0,
-  (int) buf0 };
+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/spe/Character_state.h	Fri Dec 17 22:18:11 2010 +0900
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,57 +0,0 @@
-#ifndef INCLUDE_CHARACTER_STATE
-#define INCLUDE_CHARACTER_STATE
-
-#ifndef INCLUDE_OBJECT
-#include "tobject.h"
-#endif
-
-CHARACTER * noaction(CHARACTER *p);
-CHARACTER * chara_state0(CHARACTER *p);
-CHARACTER * chara_state1(CHARACTER *p);
-CHARACTER * chara_state2(CHARACTER *p);
-CHARACTER * chara_state3(CHARACTER *p);
-CHARACTER * chara_state4(CHARACTER *p);
-CHARACTER * chara_state5(CHARACTER *p);
-CHARACTER * chara_state6(CHARACTER *p);
-CHARACTER * chara_state7(CHARACTER *p);
-CHARACTER * chara_state8(CHARACTER *p);
-CHARACTER * chara_state9(CHARACTER *p);
-CHARACTER * chara_state10(CHARACTER *p);
-CHARACTER * chara_state11(CHARACTER *p);
-CHARACTER * chara_state12(CHARACTER *p);
-CHARACTER * chara_state13(CHARACTER *p);
-CHARACTER * chara_state20(CHARACTER *p);
-CHARACTER * chara_state21(CHARACTER *p);
-CHARACTER * chara_state22(CHARACTER *p);
-CHARACTER * chara_state23(CHARACTER *p);
-CHARACTER * chara_state24(CHARACTER *p);
-CHARACTER * chara_state25(CHARACTER *p);
-CHARACTER * chara_state26(CHARACTER *p);
-CHARACTER * chara_state27(CHARACTER *p);
-CHARACTER * chara_state28(CHARACTER *p);
-CHARACTER * chara_state29(CHARACTER *p);
-CHARACTER * chara_state30(CHARACTER *p);
-CHARACTER * chara_state31(CHARACTER *p);
-CHARACTER * chara_state32(CHARACTER *p);
-CHARACTER * chara_state33(CHARACTER *p);
-CHARACTER * chara_state34(CHARACTER *p);
-CHARACTER * chara_state35(CHARACTER *p);
-CHARACTER * chara_state40(CHARACTER *p);
-CHARACTER * chara_state41(CHARACTER *p);
-CHARACTER * chara_state400(CHARACTER *p);
-CHARACTER * chara_state401(CHARACTER *p);
-CHARACTER * chara_state402(CHARACTER *p);
-CHARACTER * chara_state410(CHARACTER *p);
-CHARACTER * chara_state411(CHARACTER *p);
-CHARACTER * chara_state500(CHARACTER *p);
-CHARACTER * chara_state501(CHARACTER *p);
-CHARACTER * chara_state600(CHARACTER *p);
-CHARACTER * chara_state601(CHARACTER *p);
-CHARACTER * chara_state602(CHARACTER *p);
-CHARACTER * asteroid(CHARACTER *p);
-
-extern int enemyfaste;
-extern int fastebos;
-extern int asteroidi;
-
-#endif
--- a/state_task.cc	Fri Dec 17 22:18:11 2010 +0900
+++ b/state_task.cc	Sun Dec 26 18:57:08 2010 +0900
@@ -10,50 +10,177 @@
 #include "bom.h"
 #include "count2.h"
 #include "sgoex.h"
+#include "sankaku.h"
+#include "tama.h"
 #include "TaskManager.h"
 #include "Func.h"
 #include "property.h"
 #include "state_task.h"
 
+extern SpriteTable sptable[DEFOBJ];
+extern TaskManager *tmanager;
+
+CHARACTER *kyeenemyno;
+CHARACTER *tekino0;
+CHARACTER *enemy_part1;
+CHARACTER *enemy_part2;
+CHARACTER *enemy_part3;
+CHARACTER *enemy_part4;
+CHARACTER *enemy_part5;
+
+//int tekino0;
+int rinkx;
+int rinky;
+int rinkf1 = 0, rinkf2 = 0;
+CHARACTER *asteroiddt[200];
+int asteroidi = 0;
+int enemyfaste = 0;
+int fastebos = 0;
+
+State state_list[LIST_NUM];
+
+int
+GetStateNum(int task_num)
+{
+    int num = task_num % LIST_NUM;
+
+    return num;
+}
+
 void
+SetTaskState(int task_num, CHARACTER *(state)(CHARACTER *chara))
+{
+    int num = GetStateNum(task_num);
+    
+    state_list[num] = state;
+}
+
+void
+initStateList()
+{
+    SetTaskState(DELETE_CHARA, delete_chara);
+    SetTaskState(STATE0, chara_state0);
+    SetTaskState(STATE1, chara_state1);
+    SetTaskState(STATE2, chara_state2);
+//    SetTaskState(STATE3, chara_state3);
+    SetTaskState(STATE4, chara_state4);
+    SetTaskState(STATE5, chara_state5);
+    SetTaskState(STATE6, chara_state6);
+#if 0
+    SetTaskState(STATE7, chara_state7);
+    SetTaskState(STATE8, chara_state8);
+    SetTaskState(STATE9, chara_state9);
+    SetTaskState(STATE10, chara_state10);
+    SetTaskState(STATE11, chara_state11);
+    SetTaskState(STATE12, chara_state12);
+    SetTaskState(STATE13, chara_state13);
+    SetTaskState(STATE20, chara_state20);
+    SetTaskState(STATE21, chara_state21);
+    SetTaskState(STATE22, chara_state22);
+    SetTaskState(STATE23, chara_state23);
+    SetTaskState(STATE24, chara_state24);
+    SetTaskState(STATE25, chara_state25);
+    SetTaskState(STATE26, chara_state26);
+    SetTaskState(STATE27, chara_state27);
+    SetTaskState(STATE28, chara_state28);
+    SetTaskState(STATE29, chara_state29);
+    SetTaskState(STATE30, chara_state30);
+    SetTaskState(STATE31, chara_state31);
+    SetTaskState(STATE32, chara_state32);
+    SetTaskState(STATE33, chara_state33);
+    SetTaskState(STATE34, chara_state34);
+    SetTaskState(STATE35, chara_state35);
+    SetTaskState(STATE40, chara_state40);
+    SetTaskState(STATE41, chara_state41);
+    SetTaskState(STATE400, chara_state400);
+    SetTaskState(STATE401, chara_state401);
+    SetTaskState(STATE402, chara_state402);
+    SetTaskState(STATE410, chara_state410);
+    SetTaskState(STATE411, chara_state411);
+    SetTaskState(STATE500, chara_state500);
+    SetTaskState(STATE501, chara_state501);
+    SetTaskState(STATE600, chara_state600);
+    SetTaskState(STATE601, chara_state601);
+    SetTaskState(STATE602, chara_state602);
+#endif
+}
+
+void
+updateState(SchedTask *s, void *chara, void *arg)
+{
+    CHARACTER *p = (CHARACTER*)chara;
+
+    int num = GetStateNum(p->task);
+    p=state_list[num](p);
+}
+
+CHARACTER*
 SimpleStateTask(CHARACTER *p)
 {
-    HTaskPtr state_task = tmanager->create_task(SIMPLE_STATE);
+    int task_num = p->task;
+    HTaskPtr state_task = tmanager->create_task(task_num);
 
     state_task->add_inData(p, sizeof(CHARACTER));
     state_task->add_outData(p, sizeof(CHARACTER));
+    state_task->set_post(updateState, (void*)p, NULL);
 
     state_task->set_cpu(SPE_ANY);
     state_task->spawn();
+
+    return p;
+}
+
+CHARACTER*
+withJikiTask(CHARACTER *p)
+{
+    int task_num = p->task;
+    HTaskPtr state_task = tmanager->create_task(task_num);
+    
+    state_task->add_inData(p, sizeof(CHARACTER));
+    state_task->add_inData(&jiki, sizeof(player));
+    state_task->add_outData(p, sizeof(CHARACTER));
+    state_task->set_post(updateState, (void*)p, NULL);
+    
+    state_task->set_cpu(SPE_ANY);
+    state_task->spawn();
+    
+    return p;
+}
+
+CHARACTER*
+noaction(CHARACTER *p)
+{
+  p->state = noaction;
+  return p;
+}
+
+CHARACTER *
+delete_chara(CHARACTER *p)
+{
+
+  CHARACTER *parent = p;
+  p->f = FALSE;
+  p->state = noaction;
+  p->collision = noaction;
+  return parent;
 }
 
 CHARACTER * chara_state0(CHARACTER *p)
 {
-  p->x += p->vx;
-  p->y += p->vy;
-  p->state = STATE0;
-
-  return 0;
+    return SimpleStateTask(p);
 }
 
 CHARACTER * chara_state1(CHARACTER *p)
 {
-  p->x -= p->vx;
-  p->y -= p->vy;
-  p->state = STATE1;
-
-  return 0;
+    return SimpleStateTask(p);
 }
 
 CHARACTER * chara_state2(CHARACTER *p)
 {
-  p->vy -= 0.25;
-  p->y += p->vy;
-  p->state = chara_state2;
-  //PutSprite(count, p->x, p->y, p->charano);
-  return 0;
+    return SimpleStateTask(p);
 }
 
+#if 0
 CHARACTER * chara_state3(CHARACTER *p)
 {
   p->x += p->vx;
@@ -67,56 +194,26 @@
   p->dt1++;
   p->state = chara_state3;
   //PutSprite(count, p->x, p->y, p->charano);
-  return 0;
+  return p;
 }
+#endif
 
 CHARACTER * chara_state4(CHARACTER *p)
 {
-  p->y += p->vy;
-  p->x += p->vx;
-  if(p->y < jiki.y && p->y + 16 > jiki.y)
-    {
-      p->vy = -2;
-      p->vx = ((jiki.x > p->x) ? 4 : -4);
-      p->state = chara_state7;
-    }
-  else p->state = chara_state4;
-  //PutSprite(count, p->x, p->y, p->charano);
-  return 0;
+    return withJikiTask(p);
 }
 
 CHARACTER * chara_state5(CHARACTER *p)
 {
-  p->y += p->vy;
-  p->x += p->vx;
-  if(p->y + 96 < jiki.y 
-     && p->y + 128 > jiki.y)
-    {
-      p->vy = -2;
-      p->vx = ((jiki.x > p->x) ? 4 : -4);
-      p->state = chara_state0;
-    }
-  else p->state = chara_state5;
-  //PutSprite(count, p->x, p->y, p->charano);
-  return 0;
+    return withJikiTask(p);
 }
 
 CHARACTER * chara_state6(CHARACTER *p)
 {
-  p->y += p->vy;
-  p->x += p->vx;
-  if(p->y + 96 < jiki.y
-     && p->y + 128 > jiki.y)
-    {
-      p->vy = 2;
-      p->vx = ((jiki.x > p->x) ? 4 : -4);
-      p->state = chara_state0;
-    }
-  else p->state = chara_state6;
-  //PutSprite(count, p->x, p->y, p->charano);
-  return 0;
+    return withJikiTask(p);
 }
 
+#if 0
 CHARACTER * chara_state7(CHARACTER *p)
 {
   p->x += p->vx;
@@ -129,7 +226,7 @@
   p->dt1++;
   p->state = chara_state7;
   //PutSprite(count, p->x, p->y, p->charano);
-  return 0;
+  return p;
 }
 
 // state1 boss patern
@@ -146,10 +243,10 @@
       p->dt1 = 512;
       p->s = 0.125;
       p->state = chara_state8;
-      return 0;
+      return p;
     }
   p->state = chara_state9;
-  return 0;
+  return p;
 }
 
 CHARACTER * chara_state9(CHARACTER *p)
@@ -162,7 +259,7 @@
       DefSpriteEx(54, 16*4, 32*4);
       PutSpriteEx(54, (p->x * 4), (p->y * 4), p->s, p->s, 1);
       p->state = chara_state9;
-      return 0;
+      return p;
     }
   count++;
   DefSpriteEx(54, 16, 32);
@@ -173,7 +270,7 @@
   Putenemy(5, rinkx - 16, rinky - 16, -1, 0, chara_state10);
   p->state = chara_state11;
   p->dt1 = 8192;
-  return 0;
+  return p;
 }
 
 
@@ -186,13 +283,13 @@
       p->dt1++;
       p->state = chara_state10;
       //PutSprite(count, p->x, p->y,
-      return 0;
+      return p;
     }
   rinkf1 = 1;
   p->dt1 = rinkx;
   p->dt2 = rinky;
   p->state = chara_state13;
-  return 0;
+  return p;
 }
 
 
@@ -204,12 +301,12 @@
       DefSpriteEx(54, 16, 32);
       PutSpriteEx(54, p->x, p->y, p->s, p->s, 1);
       p->state = chara_state11;
-      return 0;
+      return p;
     }
   p->dt1 = 0;
   p->dt2 = 0;
   p->state = chara_state12;
-  return 0;
+  return p;
 }
 
 CHARACTER * chara_state12(CHARACTER *p)
@@ -226,7 +323,7 @@
       DefSpriteEx(54, 16, 32);
       PutSpriteEx(54, p->x, p->y, 2, 2, 1);
       p->state = chara_state12;
-      return 0;
+      return p;
     }
   if(p->dt1 <= 60)
     {
@@ -333,7 +430,7 @@
   count++;
   DefSpriteEx(54, 16, 32);
   PutSpriteEx(54, p->x, p->y, 2, 2, 1);
-  return 0;
+  return p;
 }
 
 
@@ -344,7 +441,7 @@
     p->f = FALSE;
     p->state = delete_chara;
     p->collision = noaction;
-    return 0;
+    return p;
   }
 
   p->x += rinkx - p->dt1;
@@ -378,67 +475,33 @@
 	  Puttama(5, p->x + 8, p->y + 24);
 	}
     }
-  return 0;
+  return p;
 }
-
+#endif
 
 CHARACTER * chara_state20(CHARACTER *p)
 {
-  p->x += p->vx;
-  p->y += p->vy;
-  p->vy -= 0.5;
-  p->vy += 0.4;
-  return 0;
+    return SimpleStateTask(p);
 }
 
 CHARACTER * chara_state21(CHARACTER *p)
 {
-  p->x += p->vx;
-  p->y += p->vy;
-  p->vx += 0.5;
-  p->vy += 0.4;
-  return 0;
+    return SimpleStateTask(p);
 }
 
+#if 0
 //ここまでgetate boss
 
 
 CHARACTER * chara_state22(CHARACTER *p)
 {
-  int sf;
-
-  sf = rand() % 4;
-  if((sf == 0) || (sf == 1))
-    {
-      p->x = -35;
-      p->y = rand() % (120 - 35);
-      p->vx = (rand() % 4 + 1);
-      p->vy = rand() % 3 + 1;
-      p->state = chara_state23;
-    }
-  if((sf == 2))
-    {
-      p->x = rand() % 290;
-      p->y = -30;
-      p->vx = rand() % 3 - 1;
-      p->vy = (rand() % 4 + 1);
-      p->state = chara_state23;
-    }
-  if(sf == 3)
-    {
-      p->x = 320;
-      p->y = rand() % (120 - 35);
-      p->vx = (rand() % 4 + 1) * -1;
-      p->vy = rand() % 3 -1;
-      p->state = chara_state23;
-    }
-  return 0;
+    return SimpleStateTask(p);
 }
 	  
 CHARACTER * chara_state23(CHARACTER *p)
 {
   p=asteroid(p);
-  return 0;
+  return p;
 }
 
 CHARACTER * chara_state24(CHARACTER *p)
@@ -455,7 +518,7 @@
   rinkf1 = 0;
   rinkf2 = 0;
   p->state = chara_state25;
-  return 0;
+  return p;
 }
 
 CHARACTER * chara_state25(CHARACTER *p)
@@ -485,7 +548,7 @@
       p->state = chara_state27;
       rinkf1 = 5;
       rinkx = 0;
-      return 0;
+      return p;
     }
   if((enemy_part5->f == TRUE) && (enemy_part1->f != TRUE))
     {
@@ -496,7 +559,7 @@
     {
       p->dt1 = 0;
     }
-  return 0;
+  return p;
 }
 
 CHARACTER * chara_state26(CHARACTER *p)
@@ -520,10 +583,10 @@
       p->dt2 = 0;
       rinkf1 = 0;
       p->state = chara_state25;
-      return 0;
+      return p;
     }
   p->dt2++;
-  return 0;
+  return p;
 }
 
 CHARACTER * chara_state27(CHARACTER *p) //rocket punch
@@ -576,10 +639,10 @@
       rinkf1 = 0;
       rinkx = 0;
       p->state = chara_state25;
-      return 0;
+      return p;
     }
   p->dt2++;
-  return 0;
+  return p;
 }
 CHARACTER * chara_state28(CHARACTER *p)
 {
@@ -605,7 +668,7 @@
 				     1 ? -1 : 1), chara_state29);
     }
   p->dt1 += 3;
-  return 0;
+  return p;
 }
 
 
@@ -618,17 +681,16 @@
       Puttama(0, p->x, p->y);
     }
   p->dt1++;
-  return 0;
+  return p;
 }
-
+#endif
 
 CHARACTER * chara_state30(CHARACTER *p)
 {
-  p->x = p->x - 32;
-  p->y = p->y;
-  return 0;
+    return SimpleStateTask(p);
 }
 
+#if 0
 CHARACTER * chara_state31(CHARACTER *p) //right hand
 {
   
@@ -638,7 +700,7 @@
       p->f = FALSE;
       p->state = delete_chara;
       p->collision = noaction;
-      return 0;
+      return p;
     }
 
   if(rinkf1 == 0)
@@ -663,7 +725,7 @@
 	}
       else 
 	{
-	  return 0;
+	  return p;
 	}
       count++;
       PutSprite(count, p->x - 4, p->y - 20, 90 + p->dt2 % 4);
@@ -672,7 +734,7 @@
   if(rinkf1 == 7)
     {
       Putenemy(22, p->x + 14, p->y + 14, 0, 0, chara_state40);
-      return 0;
+      return p;
     }
   if(rinkf1 == 11)
     {
@@ -682,13 +744,13 @@
 	}
       else 
 	{
-	  return 0;
+	  return p;
 	}
       count++;
       PutSprite(count, p->x + 8, p->y + 44, 58 + p->dt2 % 4);
       p->dt2++;
     }
-  return 0;
+  return p;
 }
 
 
@@ -701,7 +763,7 @@
       p->f = FALSE;
       p->state = delete_chara;
       p->collision = noaction;
-      return 0;
+      return p;
     }
   p->x = kyeenemyno->x - 40;
   p->y = kyeenemyno->y + 28;
@@ -720,9 +782,9 @@
       Putenemy(23, p->x + 14,
 	       p->y + 14, 0, 0, chara_state41);
       //      rinkf1=8;
-      return 0;
+      return p;
     }
-  return 0;
+  return p;
 }
 
 
@@ -734,7 +796,7 @@
       p->f = FALSE;
       p->state = delete_chara;
       p->collision = noaction;
-      return 0;
+      return p;
     }
   p->x = kyeenemyno->x + 32;
   p->y = kyeenemyno->y;
@@ -748,7 +810,7 @@
     {
       p->charano = enemystate[11].charano;
     }
-  return 0;
+  return p;
 }
 
 
@@ -760,7 +822,7 @@
       p->f = FALSE;
       p->state = delete_chara;
       p->collision = noaction;
-      return 0;
+      return p;
     }
   p->x = kyeenemyno->x - 32;
   p->y = kyeenemyno->y;
@@ -772,7 +834,7 @@
     {
       p->charano = enemystate[12].charano;
     }
-  return 0;
+  return p;
 }
 
 CHARACTER * chara_state35(CHARACTER *p) // bust
@@ -783,7 +845,7 @@
       p->f = FALSE;
       p->state = delete_chara;
       p->collision = noaction;
-      return 0;
+      return p;
     }
   p->x = kyeenemyno->x;
   p->y = kyeenemyno->y + 32;
@@ -825,7 +887,7 @@
     p->charano = enemystate[15].charano;
     p->dt2 = 0;
   }
-  return 0;
+  return p;
 }
 
 
@@ -837,7 +899,7 @@
       p->f = FALSE;
       p->state = delete_chara;
       p->collision = noaction;
-      return 0;
+      return p;
     }
   if ((rinkf1 == 8) && (p->dt1 % 3 == 1))
     {
@@ -849,7 +911,7 @@
       else
 	{
 	  //                                  rinkf1=9;
-	  return 0;
+	  return p;
 	}
     }
   if (rinkf1 == 9)
@@ -875,7 +937,7 @@
 	}
     }
   p->dt1++;
-  return 0;
+  return p;
 }
 
 
@@ -887,7 +949,7 @@
       p->f = FALSE;
       p->state = delete_chara;
       p->collision = noaction;
-      return 0;
+      return p;
     }
   p->x = kyeenemyno->x - 20 - 7;
   p->y = kyeenemyno->y + 28 + 15;
@@ -901,7 +963,7 @@
       else
 	{
 	  rinkf1 = 9;
-	  return 0;
+	  return p;
 	}
     }
   if (rinkf1 == 9)
@@ -923,21 +985,18 @@
 	  p->f = FALSE;
 	  p->state = delete_chara;
 	  p->collision = noaction;
-	  return 0;
+	  return p;
 	  //          rinkf1=11;
 	}
     }
   p->dt1++;
-  return 0;
+  return p;
 }
 
 
 CHARACTER * chara_state400(CHARACTER *p)
 {
-  p->vy++;
-  p->y += p->vy / 4;
-  p->state = chara_state400;
-  return 0;
+    return SimpleStateTask(p);
 }
 
 
@@ -955,7 +1014,7 @@
       Puttama(1, p->x + 8, p->y + 24);
     }
   p->dt1++;
-  return 0;
+  return p;
 }
 
 
@@ -973,7 +1032,7 @@
       Puttama(1, p->x + 8, p->y + 24);
     }
   p->dt1++;
-  return 0;
+  return p;
 }
 
 
@@ -981,7 +1040,7 @@
 {
   kyeenemyno = p;
   p->state = chara_state411;
-  return 0;
+  return p;
 }
 
 
@@ -1030,7 +1089,7 @@
     {
       p->y = 232;
     }
-  return 0;
+  return p;
 }
 
 
@@ -1066,7 +1125,7 @@
   if (p->dt1 == 50) {
     /*Putenemy(44,0,0,1,1,411); */
   }
-  return 0;
+  return p;
 }
 
 
@@ -1079,7 +1138,7 @@
       Puttama(11, p->x, p->y);
     }
   p->dt1++;
-  return 0;
+  return p;
 }
 
 
@@ -1104,7 +1163,7 @@
     p->y = 0;
   if (p->y > 232)
     p->y = 232;
-  return 0;
+  return p;
 }
 
 
@@ -1129,7 +1188,7 @@
   if (p->dt2 > 800) {
     p->state = chara_state602;
   }
-  return 0;
+  return p;
 }
 
 
@@ -1144,7 +1203,7 @@
     p->state = chara_state600;
     p->dt2 = 0;
   }
-  return 0;
+  return p;
 }
 
 
@@ -1170,5 +1229,6 @@
 	}
     }
     asteroidi++;
-    return 0;
+    return p;
 }
+#endif
--- a/state_task.h	Fri Dec 17 22:18:11 2010 +0900
+++ b/state_task.h	Sun Dec 26 18:57:08 2010 +0900
@@ -1,1 +1,12 @@
-void SimpleStateTask(CHARACTER *p);
+#ifndef INCLUDE_STATE_TASK
+#define INCLUDE_STATE_TASK
+
+#define LIST_NUM 50
+
+extern State state_list[LIST_NUM];
+
+int GetStateNum(int task_num);
+void SetTaskState(int task_num, CHARACTER *state);
+void initStateList();
+
+#endif