changeset 376:7c2923fa31ff

chain.cpp added
author kazz@kazzone.cr.ie.u-ryukyu.ac.jp
date Fri, 31 Jul 2009 18:21:24 +0900
parents 49f546a33e4c (diff) eab18aa0c7f6 (current diff)
children 01b83db019ba
files SceneGraph/BlenderScript/export_xml1209.py TaskManager/Cell/spe/SchedExit.cc TaskManager/Cell/spe/SchedMail.cc TaskManager/Cell/spe/SchedNop.cc TaskManager/Cell/spe/SchedNop2Ready.cc TaskManager/Cell/spe/SchedTask.cc TaskManager/Cell/spe/SchedTaskList.cc TaskManager/Cell/spe/Scheduler.cc TaskManager/Cell/spe/TaskGroup.cc TaskManager/ChangeLog TaskManager/Test/Sum/Makefile TaskManager/Test/Sum/main.cpp TaskManager/Test/test_render/Makefile.ps3 TaskManager/Test/test_render/SceneGraph.h TaskManager/Test/test_render/ball_bound.cpp TaskManager/Test/test_render/vacuum.cpp TaskManager/Test/test_render/viewer.cpp example/HelloWorld/Makefile.ps3 example/basic/Makefile.ps3 example/dependency_task/Makefile.ps3 example/many_task/Makefile.ps3 example/post_function/Makefile.ps3 example/renew_task/Makefile.ps3 example/share_task/Makefile.ps3 include/TaskManager/BufferManager.h include/TaskManager/CellBufferManager.h include/TaskManager/CellDmaManager.h include/TaskManager/CellHTaskInfo.h include/TaskManager/CellScheduler.h include/TaskManager/CellTaskInfo.h include/TaskManager/CellTaskListInfo.h include/TaskManager/CellTaskManagerImpl.h include/TaskManager/DmaBuffer.h include/TaskManager/DmaManager.h include/TaskManager/FifoDmaManager.h include/TaskManager/FifoTaskManagerImpl.h include/TaskManager/HTask.h include/TaskManager/HTaskInfo.h include/TaskManager/ListData.h include/TaskManager/MailManager.h include/TaskManager/MainScheduler.h include/TaskManager/PpeScheduler.h include/TaskManager/Random.h include/TaskManager/SchedExit.h include/TaskManager/SchedMail.h include/TaskManager/SchedNop.h include/TaskManager/SchedNop2Ready.h include/TaskManager/SchedTask.h include/TaskManager/SchedTaskBase.h include/TaskManager/SchedTaskList.h include/TaskManager/Scheduler.h include/TaskManager/SpeThreads.h include/TaskManager/SymTable.h include/TaskManager/Task.h include/TaskManager/TaskGroup.h include/TaskManager/TaskList.h include/TaskManager/TaskListInfo.h include/TaskManager/TaskManager.h include/TaskManager/TaskManagerImpl.h include/TaskManager/TaskQueue.h include/TaskManager/TaskQueueInfo.h include/TaskManager/base.h include/TaskManager/error.h include/TaskManager/types.h
diffstat 4 files changed, 413 insertions(+), 99 deletions(-) [+]
line wrap: on
line diff
--- a/TaskManager/Test/test_render/SceneGraph.h	Fri Jul 31 17:52:27 2009 +0900
+++ b/TaskManager/Test/test_render/SceneGraph.h	Fri Jul 31 18:21:24 2009 +0900
@@ -27,6 +27,7 @@
     // xyz,angle ぐらいあればおk?
     float stack_xyz[3];
     float stack_angle[3];
+    int id;
 
     // xml ファイルから生成した時のオブジェクトリスト
     SceneGraphPtr next;
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/TaskManager/Test/test_render/chain.cpp	Fri Jul 31 18:21:24 2009 +0900
@@ -0,0 +1,142 @@
+#include <iostream.h>
+#include <math.h>
+#include "SceneGraphRoot.h"
+#include "SGList.h"
+
+#define FALSE 0
+#define TRUE !FALSE
+#define CHAIN_LEN 30
+
+static double m = 100.0;
+static double k = 1000.0;
+static double g = 9.8;
+static double dt = 0.01;
+static double chain_width = 5;
+static double safe = 0.995;
+
+typedef struct {
+    double x, y, next_x, next_y;
+    double vx, vy, next_vx, next_vy;
+    int can_move;
+} CHAIN_VARS;
+
+CHAIN_VARS cv[CHAIN_LEN];
+
+void
+init_chain_vars(CHAIN_VARS *cv) {
+    cv->x = 0, cv->y = 0, cv->next_x = 0, cv->next_y = 0;
+    cv->vx = 0, cv->vy = 0, cv->next_vx = 0, cv->next_vy = 0;
+    cv->can_move = TRUE;
+}
+
+void
+set_vector(CHAIN_VARS *cv, SceneGraphPtr sg) {
+    sg->xyz[0] = (float)cv->next_x;
+    sg->xyz[1] = (float)cv->next_y;
+    sg->xyz[2] = 0.0f;
+}
+
+
+static void
+chain_move_ope(SceneGraphPtr node, int screen_w, int screen_h)
+{
+    Pad *pad = sgroot->getController();
+
+    if (pad->circle.isHold()) {
+        cv[CHAIN_LEN-1].can_move = FALSE;
+        if (pad->left.isHold()) {
+            cv[CHAIN_LEN-1].x += -1.0;
+        } else if (pad->right.isHold()) {
+            cv[CHAIN_LEN-1].x += 1.0;
+        }
+
+        if (pad->up.isHold()) {
+            cv[CHAIN_LEN-1].y += -1.0;
+        } else if (pad->down.isHold()) {
+            cv[CHAIN_LEN-1].y += 1.0;
+        }
+    } else {
+        cv[CHAIN_LEN-1].can_move = TRUE;
+    }
+}
+
+void
+chain_move(SceneGraphPtr sg, int w, int h)
+{
+    int id = sg->id;
+    if(cv[id].can_move) {
+        double dx = cv[id-1].x - cv[id].x;
+        double dy = cv[id-1].y - cv[id].y;
+        double l = sqrt(dx * dx + dy * dy);
+        double a = k * (l - chain_width) / m;
+        double ax = a * dx / l;
+        double ay = a * dy / l;
+        if(id < CHAIN_LEN - 1) {
+            dx = cv[id+1].x - cv[id].x;
+            dy = cv[id+1].y - cv[id].y;
+            l = sqrt(dx * dx + dy * dy);
+            a = k * (l - chain_width) / m;
+            ax += a * dx / l;
+            ay += a * dy / l;
+        }
+        ay += g;
+        cv[id].vx *= safe;
+        cv[id].vy *= safe;
+        cv[id].next_vx = cv[id].vx + ax * dt;
+        cv[id].next_vy = cv[id].vy + ay * dt;
+        cv[id].next_x = cv[id].x + cv[id].vx * dt;
+        cv[id].next_y = cv[id].y + cv[id].vy * dt;
+    } else {
+        cv[id].next_x = cv[id].x;
+        cv[id].next_y = cv[id].y;
+    }
+    set_vector(&cv[id], sg);
+    if(id == CHAIN_LEN -1) {
+        for(int i = 0; i < CHAIN_LEN; i++) {
+            cv[i].vx = cv[i].next_vx;
+            cv[i].vy = cv[i].next_vy;
+            cv[i].x = cv[i].next_x;
+            cv[i].y = cv[i].next_y;
+        }
+    }
+    //    cout << id << ", " << sg->xyz[1] << endl;
+}
+
+void
+chain_collision(SceneGraphPtr sg, int w, int h, SceneGraphPtr osg)
+{
+
+}
+
+void
+chain_init(int w, int h)
+{
+    SceneGraphPtr root_chain, chain;
+    CHAIN_VARS rcv;
+
+    sgroot->createFromXMLfile("xml_file/chain.xml");
+
+    root_chain = sgroot->createSceneGraph(CHAIN);
+    root_chain->set_move_collision(chain_move_ope, chain_collision);
+    init_chain_vars(&rcv);
+    rcv.next_x = w / 2;
+    rcv.next_y = 0.0;
+    set_vector(&rcv, root_chain);
+
+    for(int i = 0; i < CHAIN_LEN; i++) {
+        chain = sgroot->createSceneGraph(CHAIN);
+        chain->id = i;
+        init_chain_vars(&cv[i]);
+        if(i == 0)
+            cv[i].can_move = FALSE;
+        cv[i].x = 0;
+        cv[i].y = chain_width * i;
+        set_vector(&cv[i], chain);
+        chain->angle[1] = 90 * (i % 2);
+        chain->set_move_collision(chain_move, chain_collision);
+
+        root_chain->addChild(chain);
+    }
+
+    sgroot->setSceneData(root_chain);
+}
--- a/TaskManager/Test/test_render/vacuum.cpp	Fri Jul 31 17:52:27 2009 +0900
+++ b/TaskManager/Test/test_render/vacuum.cpp	Fri Jul 31 18:21:24 2009 +0900
@@ -5,7 +5,16 @@
 #define ENCOUNT 55
 using namespace std;
 
+<<<<<<< local
+static void cube_move_left(SceneGraphPtr node, int screen_w, int screen_h);
+static void cube_move_right(SceneGraphPtr node, int screen_w, int screen_h);
+static void cube_move_idle(SceneGraphPtr node, int screen_w, int screen_h);
+static void cube_collision(SceneGraphPtr node, int screen_w, int screen_h,
+                           SceneGraphPtr tree);
+static void cube_split(SceneGraphPtr root);
+=======
 static float vacuum_speed = 10.0f;
+>>>>>>> other
 
 
 /*オブジェクト毎にファイルを分けてみた
@@ -19,12 +28,58 @@
 no_move_idle(SceneGraphPtr node, int screen_w, int screen_h)
 {
 
+<<<<<<< local
+    if (node->xyz[0] < 0) {
+        node->set_move_collision(cube_move_right, cube_collision);
+    }
+
+    if (node->xyz[1] < 0 || node->xyz[1] > screen_h) {
+        node->stack_xyz[1] = -node->stack_xyz[1];
+    }
+
+    //node->angle[0] += 2.0f;
+    //node->angle[1] += 2.0f * node->stack_xyz[1];
+    //node->angle[2] += 2.0f * node->stack_xyz[2];
+
+    if (++node->frame > 60) {
+        cube_split(node);
+    }
+=======
+>>>>>>> other
 }
 
 void
 no_collision_idle(SceneGraphPtr node, int screen_w, int screen_h,SceneGraphPtr tree)
 {
+<<<<<<< local
+    node->xyz[0] += node->stack_xyz[0];
+#if 0
+    node->xyz[1] -= node->stack_xyz[0] * node->stack_xyz[1];
+    node->xyz[2] -= node->stack_xyz[0] * node->stack_xyz[2];
+#else
+    node->xyz[1] += node->stack_xyz[1];
+#endif
 
+    if (node->xyz[0] > screen_w) {
+        node->set_move_collision(cube_move_left, cube_collision);
+    }
+=======
+>>>>>>> other
+
+<<<<<<< local
+    if (node->xyz[1] < 0 || node->xyz[1] > screen_h) {
+        node->stack_xyz[1] = -node->stack_xyz[1];
+    }
+
+    //node->angle[0] += 2.0f;
+    //node->angle[1] += 2.0f * node->stack_xyz[1];
+    //node->angle[2] += 2.0f * node->stack_xyz[2];
+
+    if (++node->frame > 60) {
+        cube_split(node);
+    }
+=======
+>>>>>>> other
 }
 
 void
@@ -33,6 +88,10 @@
 {
     Pad *pad = sgroot->getController();
 
+<<<<<<< local
+    if (pad->circle.isPush()) {
+        cube_split(node);
+=======
     if(node->frame%ENCOUNT == ENCOUNT-1) {
       if(random()%2) {
       add_cubecollision_object(REDCUBE,node,screen_w,screen_h);
@@ -40,6 +99,7 @@
       else {
       add_cubecollision_object(ENEMY,node,screen_w,screen_h);
       }
+>>>>>>> other
     }
 
     if (pad->cross.isHold()) {
@@ -56,8 +116,14 @@
 
 }
 
+<<<<<<< local
+static void
+cube_collision(SceneGraphPtr node, int screen_w, int screen_h,
+               SceneGraphPtr tree)
+=======
 void
 lock_attack(SceneGraphPtr node,SceneGraphIteratorPtr it)
+>>>>>>> other
 {
 
   SceneGraphPtr enemy;
@@ -93,20 +159,79 @@
 
 }
 
+<<<<<<< local
+static void
+vacuum_coll(SceneGraphPtr node, int screen_w, int screen_h,
+            SceneGraphPtr tree)
+{
+    SceneGraphIteratorPtr it = sgroot->getIterator();
+    SceneGraphPtr bigm;
+    Pad *pad = sgroot->getController();
+    float dx, dy, r;
+    float q = 0;
+=======
 void
 lockon_collision(SceneGraphPtr node,int w,int h,SceneGraphPtr tree) {
+>>>>>>> other
 
+<<<<<<< local
+    if (pad->cross.isRelease()) {
+        return;
+    }
+=======
   Pad *pad = sgroot->getController();
   SceneGraphPtr lockon_enemy = node->parent;
+>>>>>>> other
 
   /* node->angle[0] = -lockon_enemy->angle[0];
   node->angle[1] = -lockon_enemy->angle[1];
   node->angle[2] = -lockon_enemy->angle[2];*/
 
+<<<<<<< local
+    for (; it->hasNext(MCUBE);) {
+        it->next(MCUBE);
+        SceneGraphPtr mcube = it->get();
+=======
   if(pad->circle.isRelease()) {
     lockon_enemy->remove();
   }
+>>>>>>> other
 
+<<<<<<< local
+        dx = node->xyz[0] - mcube->xyz[0];
+        dy = node->xyz[1] - mcube->xyz[1];
+
+        r = sqrt(dx*dx + dy*dy);
+
+        if (r >= 1) q = 300/r;
+
+        if (r < 50.0f) {
+            mcube->remove();
+            continue;
+        }
+
+        if (dx == 0) {
+            if(mcube->xyz[1] > node->xyz[1]) {
+                mcube->xyz[1] -= q;
+            } else if(mcube->xyz[1] < node->xyz[1]) {
+                mcube->xyz[1] += q;
+            }
+        } else {
+            if(mcube->xyz[0] > node->xyz[0]) {
+                mcube->xyz[0] -= q*cos(atan(dy/dx));
+                mcube->xyz[1] -= q*sin(atan(dy/dx));
+                mcube->stack_xyz[0] = -q*cos(atan(dy/dx));
+                mcube->stack_xyz[1] = -q*sin(atan(dy/dx));
+            } else if(mcube->xyz[0] < mcube->xyz[0]) {
+                mcube->xyz[0] += q*cos(atan(dy/dx));
+                mcube->xyz[1] += q*sin(atan(dy/dx));
+                mcube->stack_xyz[0] = -q*cos(atan(dy/dx));
+                mcube->stack_xyz[1] = -q*sin(atan(dy/dx));
+            }
+        }
+    }
+=======
+>>>>>>> other
 }
 
 
@@ -115,25 +240,44 @@
 {
     Pad *pad = sgroot->getController();
 
+<<<<<<< local
+    if (pad->right.isHold()) {
+        node->xyz[0] += vacuum_speed;
+    } else if (pad->left.isHold()) {
+        node->xyz[0] -= vacuum_speed;
+=======
     if (pad->right.isHold() && w > node->xyz[0]) {
       node->xyz[0] += vacuum_speed;
       node->angle[0] += 2;
     } else if (pad->left.isHold() && 0 < node->xyz[0]) {
       node->xyz[0] -= vacuum_speed;
       node->angle[0] -= 2;
+>>>>>>> other
     }
 
+<<<<<<< local
+    if (pad->up.isHold()) {
+        node->xyz[1] -= vacuum_speed;
+    } else if (pad->down.isHold()) {
+        node->xyz[1] += vacuum_speed;
+=======
     if (pad->up.isHold() && 0 < node->xyz[1]) {
       node->xyz[1] -= vacuum_speed;
       node->angle[1] -= 2;
     } else if (pad->down.isHold() && h > node->xyz[1]) {
       node->xyz[1] += vacuum_speed;
       node->angle[1] += 2;
+>>>>>>> other
     }
 
     if (pad->start.isPush()) {
+<<<<<<< local
+        node->xyz[0] = w/2;
+        node->xyz[1] = h*0.8;
+=======
       node->xyz[0] = w/2;
       node->xyz[1] = h*0.8;
+>>>>>>> other
     }
 }
 
--- a/TaskManager/Test/test_render/viewer.cpp	Fri Jul 31 17:52:27 2009 +0900
+++ b/TaskManager/Test/test_render/viewer.cpp	Fri Jul 31 18:21:24 2009 +0900
@@ -57,15 +57,15 @@
     SDL_Event event;
 
     while(SDL_PollEvent(&event)) {
-	if (event.type==SDL_QUIT) {
-	    return true;
-	}
+        if (event.type==SDL_QUIT) {
+            return true;
+        }
     }
 
     Uint8 *keys=SDL_GetKeyState(NULL);
 
     if (keys[SDLK_q] == SDL_PRESSED) {
-	return true;
+        return true;
     }
 
     return false;
@@ -94,10 +94,14 @@
 extern void init_position(int, int);
 //extern void vacuum_init(int w, int h);
 extern void untitled_init(void);
+<<<<<<< local
+extern void chain_init(int w, int h);
+=======
 extern void boss1_init(int w, int h);
 extern void init_gaplant(int w, int h);
 extern void vacuum_init2(int w, int h);
 
+>>>>>>> other
 void
 Viewer::run_init(const char *xml, int sg_number)
 {
@@ -114,38 +118,47 @@
     switch (sg_number) {
     case 0:
     case 1:
-	create_cube_split(sg_number);
-	break;
+        create_cube_split(sg_number);
+        break;
     case 2:
     case 3:
     case 4:
-	panel_init(sg_number);
-	break;
+        panel_init(sg_number);
+        break;
     case 5:
-	universe_init();
-	break;
+        universe_init();
+        break;
     case 6:
-	ieshoot_init();
-	break;
+        ieshoot_init();
+        break;
     case 7:
-	ball_bound_init(this->width, this->height);
-	break;
+        ball_bound_init(this->width, this->height);
+        break;
     case 8:
-	lcube_init(this->width, this->height);
-	break;
+        lcube_init(this->width, this->height);
+        break;
     case 9:
-	direction_init();
-	break;
+        direction_init();
+        break;
     case 10:
-	init_position(this->width, this->height);
-	break;
+        init_position(this->width, this->height);
+        break;
     case 11:
+<<<<<<< local
+        vacuum_init(this->width, this->height);
+        break;
+=======
 	//vacuum_init(this->width, this->height);
 	break;
+>>>>>>> other
     case 12:
         untitled_init();
         break;
     case 13:
+<<<<<<< local
+        chain_init(this->width, this-> height);
+        break;
+=======
 	boss1_init(this->width, this->height);
 	break;
     case 14:
@@ -154,9 +167,10 @@
     case 15:
 	vacuum_init2(this->width, this->height);
 	break;
+>>>>>>> other
     default:
-	node_init();
-	break;
+        node_init();
+        break;
     }
 
     sgpack = (SceneGraphPack*)manager->allocate(sizeof(SceneGraphPack));
@@ -179,14 +193,14 @@
 
     /* 各 SPU が持つ、SpanPack の address list */
     spackList_ptr =
-	(SpanPack**)manager->allocate(sizeof(SpanPack*)*spackList_length_align);
+        (SpanPack**)manager->allocate(sizeof(SpanPack*)*spackList_length_align);
 
     for (int i = 0; i < spackList_length; i++) {
-	spackList_ptr[i] = &spackList[i];
+        spackList_ptr[i] = &spackList[i];
     }
 
     for (int i = 1; i <= spackList_length; i++) {
-	spackList[i-1].init(i*split_screen_h);
+        spackList[i-1].init(i*split_screen_h);
     }
 
     task_next = manager->create_task(TASK_DUMMY);
@@ -204,6 +218,13 @@
 #endif
 
     for (int i = 0; i < spe_num; i++) {
+<<<<<<< local
+        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();
+=======
 	task_tex = manager->create_task(TASK_INIT_TEXTURE);
 	/* 
 	 * ここはもう少しわかりやすい使い方がいいかもしれぬ。こんなもん?
@@ -211,6 +232,7 @@
 	task_tex->set_cpu((CPU_TYPE)((int)SPE_0 + i));
 	task_next->wait_for(task_tex);
 	task_tex->spawn();
+>>>>>>> other
     }
 
     task_next->set_post(&post2runLoop, NULL); // set_post(function(this->run_loop()), NULL)
@@ -229,15 +251,15 @@
     quit_flg = quit_check();
 
     if (quit_flg == true) {
-	this_time = get_ticks();
-	run_finish();
-	return;
+        this_time = get_ticks();
+        run_finish();
+        return;
     }
 
     clean_pixels();
 
     for (int i = 1; i <= spackList_length; i++) {
-	spackList[i-1].reinit(i*split_screen_h);
+        spackList[i-1].reinit(i*split_screen_h);
     }
 
     task_next = manager->create_task(TASK_DUMMY);
@@ -277,35 +299,35 @@
     int range = (spackList_length + range_base - 1) / range_base;
 
     for (int i = 0; i < range_base; i++) {
-	int index_start = range*i;
-	int index_end = (index_start + range >= spackList_length)
-	    ? spackList_length : index_start + range;
+        int index_start = range*i;
+        int index_end = (index_start + range >= spackList_length)
+            ? spackList_length : index_start + range;
 
-	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);
-	task_create_sp->add_inData(&spackList[index_start], sizeof(SpanPack));
+        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);
+        task_create_sp->add_inData(&spackList[index_start], sizeof(SpanPack));
 
-	task_create_sp->add_param(index_start);
+        task_create_sp->add_param(index_start);
 
-	/**
-	 * ex. screen_height が 480, spenum が 6 の場合、各SPEのy担当範囲
-	 *   [  1.. 80] [ 81..160] [161..240]
-	 *   [241..320] [321..400] [401..480]
-	 *
-	 * ex. screen_height が 1080, spenum が 5 の場合、
-	 *   [  1..216] [217..432] [433..648]
-	 *   [649..864] [865..1080]
-	 */
-	task_create_sp->add_param(index_start*split_screen_h + 1);
-	task_create_sp->add_param(index_end*split_screen_h);
+        /**
+         * ex. screen_height が 480, spenum が 6 の場合、各SPEのy担当範囲
+         *   [  1.. 80] [ 81..160] [161..240]
+         *   [241..320] [321..400] [401..480]
+         *
+         * ex. screen_height が 1080, spenum が 5 の場合、
+         *   [  1..216] [217..432] [433..648]
+         *   [649..864] [865..1080]
+         */
+        task_create_sp->add_param(index_start*split_screen_h + 1);
+        task_create_sp->add_param(index_end*split_screen_h);
 
-	task_next->wait_for(task_create_sp);
-	task_create_sp->wait_for(task_create_pp);
+        task_next->wait_for(task_create_sp);
+        task_create_sp->wait_for(task_create_pp);
 
-	task_create_sp->set_cpu(SPE_ANY);
-	task_create_sp->spawn();
+        task_create_sp->set_cpu(SPE_ANY);
+        task_create_sp->spawn();
     }
 
     task_create_pp->spawn();
@@ -321,64 +343,69 @@
 {
     HTaskPtr task_next;
     HTaskPtr task_draw;
-    
+
     task_next = manager->create_task(TASK_DUMMY);
+<<<<<<< local
+    task_next->set_post(post2runLoop, NULL);
+
+=======
     
+>>>>>>> other
     ppack->clear();
     for (int i = 0; i < spackList_length; i++) {
-	SpanPack *spack = &spackList[i];
-	int startx = 1;
-	int endx = split_screen_w;
+        SpanPack *spack = &spackList[i];
+        int startx = 1;
+        int endx = split_screen_w;
 
-	int starty = spack->info.y_top - split_screen_h + 1;
-	//int endy = spack->info.y_top;
-	int rangey = (starty + split_screen_h - 1 > this->height)
-	    ? this->height - starty + 1 : split_screen_h;
+        int starty = spack->info.y_top - split_screen_h + 1;
+        //int endy = spack->info.y_top;
+        int rangey = (starty + split_screen_h - 1 > this->height)
+            ? this->height - starty + 1 : split_screen_h;
 
-	while (startx < this->width) {
-	    if (spack->info.size > 0) {
-		// Draw SpanPack
-		task_draw = manager->create_task(TASK_DRAW_SPAN);
-		task_draw->add_inData(spack, sizeof(SpanPack));
-		
-		task_draw->add_param(
-		    (uint32)&pixels[(startx-1) + this->width*(starty-1)]);
-		task_draw->add_param(this->width);
-	    } else {
+        while (startx < this->width) {
+            if (spack->info.size > 0) {
+                // Draw SpanPack
+                task_draw = manager->create_task(TASK_DRAW_SPAN);
+                task_draw->add_inData(spack, sizeof(SpanPack));
+
+                task_draw->add_param(
+                    (uint32)&pixels[(startx-1) + this->width*(starty-1)]);
+                task_draw->add_param(this->width);
+            } else {
 #if 0
-		//break;
-		// Draw Background (現在は塗りつぶし)
-		task_draw = manager->create_task(TASK_DRAW_BACK);
-		task_draw->add_param(0xffffffff);
+                //break;
+                // Draw Background (現在は塗りつぶし)
+                task_draw = manager->create_task(TASK_DRAW_BACK);
+                task_draw->add_param(0xffffffff);
 
-		for (int k = 0; k < rangey; k++) {
-		    task_draw->add_outData(
-			&pixels[(startx-1)+this->width*(k+starty-1)],
-			(endx - startx + 1)*sizeof(int));
-		}
+                for (int k = 0; k < rangey; k++) {
+                    task_draw->add_outData(
+                        &pixels[(startx-1)+this->width*(k+starty-1)],
+                        (endx - startx + 1)*sizeof(int));
+                }
 #else
-		memset(&pixels[(startx-1)+this->width*(starty-1)],
-		       0, (this->width)*sizeof(int)*rangey);
-		//wmemset((wchar_t*)&pixels[(startx-1)+this->width*(starty-1)],
-		//0xFFFFFFFF, (this->width)*sizeof(int)*rangey/sizeof(wchar_t));
-		break;
+                memset(&pixels[(startx-1)+this->width*(starty-1)],
+                       0, (this->width)*sizeof(int)*rangey);
+                //wmemset((wchar_t*)&pixels[(startx-1)+this->width*(starty-1)],
+                //0xFFFFFFFF, (this->width)*sizeof(int)*rangey/sizeof(wchar_t));
+                break;
 #endif
-	    }
+            }
 
-	    task_draw->add_param(startx);
-	    task_draw->add_param(endx);
-	    task_draw->add_param(rangey);
-	    task_draw->set_cpu(SPE_ANY);
-	    task_next->wait_for(task_draw);
-	    task_draw->spawn();
+            task_draw->add_param(startx);
+            task_draw->add_param(endx);
+            task_draw->add_param(rangey);
+            task_draw->set_cpu(SPE_ANY);
+            task_next->wait_for(task_draw);
+            task_draw->spawn();
 
-	    startx += split_screen_w;
-	    endx += split_screen_w;
+            startx += split_screen_w;
+            endx += split_screen_w;
 
-	    if (endx > this->width) {
-		endx = this->width;
-	    }
-	}
+            if (endx > this->width) {
+                endx = this->width;
+            }
+        }
     }
 
     task_next->set_post(post2runLoop, NULL); // set_post(function(this->run_loop()), NULL)
@@ -392,7 +419,7 @@
 Viewer::run_finish(void)
 {
     if (this_time != start_time) {
-	printf("%f FPS\n", (((float)frames)/(this_time-start_time))*1000.0);
+        printf("%f FPS\n", (((float)frames)/(this_time-start_time))*1000.0);
     }
 
     delete sgroot;