changeset 450:01dc4e5be965

KeyStat fixed...
author kazz@henri.cr.ie.u-ryukyu.ac.jp
date Fri, 25 Sep 2009 22:04:17 +0900
parents 4f11245e3504
children 95dbf6bd8cd9
files TaskManager/Test/test_render/Application/ball_bound.cc TaskManager/Test/test_render/Application/panel.cc TaskManager/Test/test_render/SceneGraphRoot.cc TaskManager/Test/test_render/spe/spe-main.cc TaskManager/Test/test_render/task/UpdateKey.cc TaskManager/Test/test_render/viewer.cc example/word_count/spe/spe-main.cc
diffstat 7 files changed, 150 insertions(+), 142 deletions(-) [+]
line wrap: on
line diff
--- a/TaskManager/Test/test_render/Application/ball_bound.cc	Fri Sep 25 18:06:01 2009 +0900
+++ b/TaskManager/Test/test_render/Application/ball_bound.cc	Fri Sep 25 22:04:17 2009 +0900
@@ -27,25 +27,25 @@
     Pad *pad = sgroot->getController();
 
     if (pad->circle.isHold()) {
-	if (pad->left.isHold()) {
-	    node->xyz[0] -= speed;
-	    if(node->xyz[0] < ball_radius)
-	        node->xyz[0] = ball_radius;
-	} else if (pad->right.isHold()) {
-	    node->xyz[0] += speed;
-	    if(node->xyz[0] > screen_w  - ball_radius)
-  	        node->xyz[0] = screen_w - ball_radius;
-	}
+		if (pad->left.isHold()) {
+			node->xyz[0] -= speed;
+			if(node->xyz[0] < ball_radius)
+				node->xyz[0] = ball_radius;
+		} else if (pad->right.isHold()) {
+			node->xyz[0] += speed;
+			if(node->xyz[0] > screen_w  - ball_radius)
+				node->xyz[0] = screen_w - ball_radius;
+		}
 
-	if (pad->up.isHold()) {
-	    node->xyz[1] -= speed;
-	} else if (pad->down.isHold()) {
-	    node->xyz[1] += speed;
+		if (pad->up.isHold()) {
+			node->xyz[1] -= speed;
+		} else if (pad->down.isHold()) {
+			node->xyz[1] += speed;
             if(node->xyz[1] > screen_h - ball_radius)
-	        node->xyz[1] = screen_h - ball_radius;
-	}
+				node->xyz[1] = screen_h - ball_radius;
+		}
     } else {
-	node->set_move_collision(ball_move, ball_collision);
+		node->set_move_collision(ball_move, ball_collision);
     }
 }
 
@@ -57,20 +57,20 @@
     Pad *pad = sgroot->getController();
 
     if (pad->circle.isPush()) {
-	node->set_move_collision(ball_move_idle2, ball_collision_idle);
-	time = 0;
+		node->set_move_collision(ball_move_idle2, ball_collision_idle);
+		time = 0;
     }
 
     time++;
 
     if (time > 90) {
-      float w = (float)random();
+		float w = (float)random();
       
-      w = fmodf(w, screen_w - ball_radius*2);
-      node->xyz[0] = w + ball_radius;
-      node->xyz[1] = h0;
-      node->set_move_collision(ball_move, ball_collision);
-      time = 0;
+		w = fmodf(w, screen_w - ball_radius*2);
+		node->xyz[0] = w + ball_radius;
+		node->xyz[1] = h0;
+		node->set_move_collision(ball_move, ball_collision);
+		time = 0;
     }
 }
 
@@ -89,16 +89,16 @@
 
 static void
 ball_collision(SceneGraphPtr node, int screen_w, int screen_h,
-	       SceneGraphPtr tree)
+			   SceneGraphPtr tree)
 {
     if (node->xyz[1] > screen_h - ball_radius) {
-	node->xyz[1] = screen_h - ball_radius;
+		node->xyz[1] = screen_h - ball_radius;
 
-	vy *= e;
-	if (vy > -g && vy < 0) {
-	    vy = 0.0;
-	    node->set_move_collision(ball_move_idle, ball_collision_idle);
-	}
+		vy *= e;
+		if (vy > -g && vy < 0) {
+			vy = 0.0;
+			node->set_move_collision(ball_move_idle, ball_collision_idle);
+		}
     }
 }
 
--- a/TaskManager/Test/test_render/Application/panel.cc	Fri Sep 25 18:06:01 2009 +0900
+++ b/TaskManager/Test/test_render/Application/panel.cc	Fri Sep 25 22:04:17 2009 +0900
@@ -22,14 +22,14 @@
     SceneGraphPtr panel;
 
     if (bg == 2) {
-	sgroot->createFromXMLfile(manager, "xml_file/panel_512.xml");
-	panel = sgroot->createSceneGraph(PANEL_512);
+		sgroot->createFromXMLfile(manager, "xml_file/panel_512.xml");
+		panel = sgroot->createSceneGraph(PANEL_512);
     } else if (bg == 3) {
-	sgroot->createFromXMLfile(manager, "xml_file/panel_1024.xml");
-	panel = sgroot->createSceneGraph(PANEL_1024);
+		sgroot->createFromXMLfile(manager, "xml_file/panel_1024.xml");
+		panel = sgroot->createSceneGraph(PANEL_1024);
     } else {
-	sgroot->createFromXMLfile(manager, "xml_file/panel_2048.xml");
-	panel = sgroot->createSceneGraph(PANEL_2048);
+		sgroot->createFromXMLfile(manager, "xml_file/panel_2048.xml");
+		panel = sgroot->createSceneGraph(PANEL_2048);
     }
 
     panel->set_move_collision(panel_move, panel_collision);
--- a/TaskManager/Test/test_render/SceneGraphRoot.cc	Fri Sep 25 18:06:01 2009 +0900
+++ b/TaskManager/Test/test_render/SceneGraphRoot.cc	Fri Sep 25 22:04:17 2009 +0900
@@ -33,19 +33,19 @@
     SceneGraphPtr p = sg_available_list;
 
     while (p) {
-	SceneGraphPtr tmp = p->next;
-	delete p;
-	p = tmp;
-	cnt--;
+		SceneGraphPtr tmp = p->next;
+		delete p;
+		p = tmp;
+		cnt--;
     }
 
     p = sg_remove_list;
 
     while (p) {
-	SceneGraphPtr tmp = p->next;
-	delete p;
-	p = tmp;
-	cnt--;
+		SceneGraphPtr tmp = p->next;
+		delete p;
+		p = tmp;
+		cnt--;
     }
 
     delete [] sg_src;
@@ -63,15 +63,15 @@
 SceneGraphRoot::registSceneGraph(SceneGraphPtr sg)
 {
     for (int i = 0; i < SGLIST_LENGTH; i++) {
-	if (strcmp(sg->name, sglist_table[i]) == 0) {
-	    sg->sgid = i;
-	    sg_src[i] = sg;
-	    return;
-	}
+		if (strcmp(sg->name, sglist_table[i]) == 0) {
+			sg->sgid = i;
+			sg_src[i] = sg;
+			return;
+		}
     }
 
     fprintf(stderr, "error: (%s:%3d) Can't find Scene \"%s\"\n",
-	    __FUNCTION__, __LINE__, sg->name);
+			__FUNCTION__, __LINE__, sg->name);
 }
 
 void
@@ -80,13 +80,13 @@
     SceneGraphPtr last = sg_available_list;
 
     if (!last) {
-	sg_available_list = sg;
+		sg_available_list = sg;
     } else {
-	while (last->next) {
-	    last = last->next;
-	}
-	last->next = sg;
-	sg->prev = last;
+		while (last->next) {
+			last = last->next;
+		}
+		last->next = sg;
+		sg->prev = last;
     }
 
     cnt++;
@@ -109,15 +109,15 @@
 
     /* XMLのノードを一つずつ解析  */
     for (cur=cur->children; cur; cur=cur->next) {
-	/* 扱うのはsurfaceオンリー  */
-	if (xmlStrcmp(cur->name,(xmlChar*)"surface") != 0) {
-	    continue;
-	}
+		/* 扱うのはsurfaceオンリー  */
+		if (xmlStrcmp(cur->name,(xmlChar*)"surface") != 0) {
+			continue;
+		}
 
-	/* ポリゴン(SceneGraph)生成  */
-	tmp = new SceneGraph(manager, cur);
+		/* ポリゴン(SceneGraph)生成  */
+		tmp = new SceneGraph(manager, cur);
 
-	registSceneGraph(tmp);
+		registSceneGraph(tmp);
     }
 
     xmlFreeDoc(doc);
@@ -130,7 +130,7 @@
     SceneGraphPtr p;
 
     if (id < 0 || id > SGLIST_LENGTH) {
-	return NULL;
+		return NULL;
     }
 
     /* オリジナルの SceneGraph */
@@ -192,17 +192,17 @@
     list = list->next;
 
     if(sg_exec_tree != NULL) {
-      return;
+		return;
     }
 
     /*removeのflagをもとにtreeを形成*/
     /* spe から送り返されてきた property の配列を見て生成する for()*/
     /*
-    for (Property *t = property[0]; is_end(t); t++){
-	SceneGraphPtr s = application->scenegraph_factory(t); // SceneGraphNode を作る
-	t->scenegraph = s; // property list には SceneGraphへのポインタが入っている
-	application->scenegraph_connector(property[0], s); // add する
-    }
+	  for (Property *t = property[0]; is_end(t); t++){
+	  SceneGraphPtr s = application->scenegraph_factory(t); // SceneGraphNode を作る
+	  t->scenegraph = s; // property list には SceneGraphへのポインタが入っている
+	  application->scenegraph_connector(property[0], s); // add する
+	  }
     */
 
       
@@ -250,49 +250,49 @@
         list->move_execute(screen_w, screen_h);
         list->collision_check(screen_w, screen_h, list);	
         
-	list->frame++; 
+		list->frame++; 
         list = list->next;
 
     }
 
     if(sg_exec_tree != NULL) {
-      return;
+		return;
     }
 
     /*removeのflagをもとにtreeを形成*/
     while (t) {
-	SceneGraphPtr c = NULL;
-	if (!t->isRemoved()) {
-	    c = t->clone();	    
-	    addNext(c);
-	    cur_parent->addChild(c);
-	    c->frame = t->frame;
+		SceneGraphPtr c = NULL;
+		if (!t->isRemoved()) {
+			c = t->clone();	    
+			addNext(c);
+			cur_parent->addChild(c);
+			c->frame = t->frame;
             /*親の回転、座標から、子の回転、座標を算出*/
             get_matrix(c->matrix, c->angle, c->xyz, cur_parent->matrix);
         } 
 
-	if (t->children != NULL && c != NULL) {
-	    cur_parent = c;
-	    t = t->children;
-	} else if (t->brother != NULL) {
-	    t = t->brother;
-	} else {
-	    while (t) {
-		if (t->brother != NULL) {
-		    t = t->brother;
-		    break;
+		if (t->children != NULL && c != NULL) {
+			cur_parent = c;
+			t = t->children;
+		} else if (t->brother != NULL) {
+			t = t->brother;
 		} else {
-		    if (t->parent == NULL) {
-			t = NULL;
-			break;
-		    } else {
+			while (t) {
+				if (t->brother != NULL) {
+					t = t->brother;
+					break;
+				} else {
+					if (t->parent == NULL) {
+						t = NULL;
+						break;
+					} else {
                         cur_parent = cur_parent->parent;
                         t = t->parent;
 			
-		    }
+					}
+				}
+			}	    
 		}
-	    }	    
-	}
     }
 
       
@@ -314,10 +314,10 @@
     SceneGraphPtr p = list;
 
     while (p) {
-	SceneGraphPtr p1 = p->next;
-	delete p;
-	p = p1;
-	cnt--;
+		SceneGraphPtr p1 = p->next;
+		delete p;
+		p = p1;
+		cnt--;
     }
 }
 
@@ -328,13 +328,13 @@
     SceneGraphPtr p1;
 
     while (p) {
-	p1 = p->next;
-	if (p->isRemoved()) {
-	    sg_exec_tree = p->realRemoveFromTree(sg_exec_tree);
-	    sg_available_list = p->realRemoveFromList(sg_available_list);
-	}
-	delete p;
-	p = p1;
+		p1 = p->next;
+		if (p->isRemoved()) {
+			sg_exec_tree = p->realRemoveFromTree(sg_exec_tree);
+			sg_available_list = p->realRemoveFromList(sg_available_list);
+		}
+		delete p;
+		p = p1;
     }
 }
 
--- a/TaskManager/Test/test_render/spe/spe-main.cc	Fri Sep 25 18:06:01 2009 +0900
+++ b/TaskManager/Test/test_render/spe/spe-main.cc	Fri Sep 25 22:04:17 2009 +0900
@@ -15,6 +15,9 @@
 
 SchedExternTask(ShowTime);
 
+SchedExternTask(InitKey);
+SchedExternTask(UpdateKey);
+
 void
 task_init(Scheduler *s)
 {
@@ -33,4 +36,7 @@
     //SchedRegisterTask(TASK_CREATE_PP, CreatePolygon);
 
     SchedRegisterTask(SHOW_TIME, ShowTime);
+
+	SchedRegisterTask(INIT_KEY_TASK, InitKey);
+	SchedRegisterTask(UPDATE_KEY, UpdateKey);
 }
--- a/TaskManager/Test/test_render/task/UpdateKey.cc	Fri Sep 25 18:06:01 2009 +0900
+++ b/TaskManager/Test/test_render/task/UpdateKey.cc	Fri Sep 25 22:04:17 2009 +0900
@@ -8,7 +8,7 @@
 int 
 UpdateKey::run(SchedTask *smanager, void *rbuf, void *wbuf)
 {
-    key_stat *key = (key_stat*)smanager->get_input(0);
+    key_stat *key = (key_stat*)smanager->get_input(rbuf, 0);
     key_stat *gdata = (key_stat*)smanager->global_get(KEY_STATUS); 
     memcpy(gdata, key, sizeof(key_stat));
 
--- a/TaskManager/Test/test_render/viewer.cc	Fri Sep 25 18:06:01 2009 +0900
+++ b/TaskManager/Test/test_render/viewer.cc	Fri Sep 25 22:04:17 2009 +0900
@@ -121,54 +121,54 @@
     switch (sg_number) {
     case 0:
     case 1:
-	create_cube_split(manager, sg_number);
+		create_cube_split(manager, sg_number);
         break;
     case 2:
     case 3:
     case 4:
-	panel_init(manager, sg_number);
+		panel_init(manager, sg_number);
         break;
     case 5:
-	universe_init(manager);
+		universe_init(manager);
         break;
     case 6:
-	ieshoot_init(manager);
+		ieshoot_init(manager);
         break;
     case 7:
-	ball_bound_init(manager, this->width, this->height);
+		ball_bound_init(manager, this->width, this->height);
         break;
     case 8:
-	lcube_init(manager, this->width, this->height);
+		lcube_init(manager, this->width, this->height);
         break;
     case 9:
-	direction_init(manager);
+		direction_init(manager);
         break;
     case 10:
-	init_position(manager, this->width, this->height);
+		init_position(manager, this->width, this->height);
         break;
     case 11:
         //        vacuum_init(manager, this->width, this->height);
         break;
     case 12:
-	untitled_init(manager);
+		untitled_init(manager);
         break;
     case 13:
-	boss1_init(manager, this->width, this->height);
+		boss1_init(manager, this->width, this->height);
         break;
     case 14:
-	init_gaplant(manager, this->width, this->height);
+		init_gaplant(manager, this->width, this->height);
         break;
     case 15:
-	vacuum_init2(manager, this->width, this->height);
+		vacuum_init2(manager, this->width, this->height);
         break;
     case 16:
         chain_init(manager, this->width, this-> height);
-	speLoop();
-	return;
+		speLoop();
+		return;
         break;
     case 17:
         chain_old_init(manager, this->width, this-> height);
-	break;
+		break;
     default:
         node_init(manager);
         break;
@@ -220,7 +220,7 @@
         task_tex = manager->create_task(TASK_INIT_TEXTURE);
         /*
          * ここはもう少しわかりやすい使い方がいいかもしれぬ。こんなもん?
-        */
+		 */
         task_tex->set_cpu((CPU_TYPE)((int)SPE_0 + i));
         task_next->wait_for(task_tex);
         task_tex->spawn();
@@ -236,6 +236,7 @@
     HTaskPtr task_next = initLoop();
     // key の情報を格納する領域を確保する (global_alloc(KEY_STATUS))
     HTaskPtr init_key_task = manager->create_task(INIT_KEY_TASK);
+	init_key_task->set_cpu(SPE_0);
     init_key_task->spawn();
     
     // SPE に送信する KEY_STATUS の領域確保
@@ -260,43 +261,43 @@
 {
     Pad *pad = sgroot->getController();
     if (pad->right.isHold()) {
-	keyPtr->right = HOLD;
+		keyPtr->right = HOLD;
     } else if (pad->right.isPush()) {
-	keyPtr->right = PUSH;
+		keyPtr->right = PUSH;
     } else {
-	keyPtr->right = NONE;
+		keyPtr->right = NONE;
     }
     
     if (pad->left.isHold()) {
-	keyPtr->left = HOLD;
+		keyPtr->left = HOLD;
     } else if (pad->left.isPush()) {
-	keyPtr->left = PUSH;
+		keyPtr->left = PUSH;
     } else {
-	keyPtr->left = NONE;
+		keyPtr->left = NONE;
     }
 
     if (pad->up.isHold()) {
-	keyPtr->up = HOLD;
+		keyPtr->up = HOLD;
     } else if (pad->up.isPush()) {
-	keyPtr->up = PUSH;
+		keyPtr->up = PUSH;
     } else {
-	keyPtr->up = NONE;
+		keyPtr->up = NONE;
     }
 
     if (pad->down.isHold()) {
-	keyPtr->down = HOLD;
+		keyPtr->down = HOLD;
     } else if (pad->down.isPush()) {
-	keyPtr->down = PUSH;
+		keyPtr->down = PUSH;
     } else {
-	keyPtr->down = NONE;
+		keyPtr->down = NONE;
     }
 
     if (pad->circle.isHold()) {
-	keyPtr->circle = HOLD;
+		keyPtr->circle = HOLD;
     } else if (pad->circle.isPush()) {
-	keyPtr->circle = PUSH;
+		keyPtr->circle = PUSH;
     } else {
-	keyPtr->circle = NONE;
+		keyPtr->circle = NONE;
     }
 }
 
@@ -312,6 +313,7 @@
     viewer->getKey();
     HTaskPtr update_key = viewer->manager->create_task(UPDATE_KEY);
     update_key->add_inData(viewer->keyPtr, sizeof(key_stat));
+	update_key->set_cpu(SPE_0);
     update_key->spawn();
 
     /* TASK_MOVE は外から引数で取ってくるべき */
@@ -391,7 +393,7 @@
         int index_end = (index_start + range >= spackList_length)
             ? spackList_length : index_start + range;
 
-	HTaskPtr task_create_sp = manager->create_task(TASK_CREATE_SPAN);
+		HTaskPtr task_create_sp = manager->create_task(TASK_CREATE_SPAN);
         task_create_sp->add_inData(ppack, sizeof(PolygonPack));
         task_create_sp->add_inData(spackList_ptr,
                                    sizeof(SpanPack*)*spackList_length_align);
@@ -503,7 +505,7 @@
             } else {
                 memset(&pixels[(startx-1)+this->width*(starty-1)],
                        0, (this->width)*sizeof(int)*rangey);
-		break;
+				break;
             }
 
             task_draw->add_param(startx);
--- a/example/word_count/spe/spe-main.cc	Fri Sep 25 18:06:01 2009 +0900
+++ b/example/word_count/spe/spe-main.cc	Fri Sep 25 22:04:17 2009 +0900
@@ -9,7 +9,7 @@
  * 必ずこの関数名でお願いします。
  */
 void
-task_init(void)
+task_init(Scheduler *s)
 {
     SchedRegisterTask(TASK_PRINT, Print);
     SchedRegisterTask(TASK_EXEC, Exec);