diff ppe/Atari.cc @ 54:3acdeb3dc3e8

collision use global_alloc (not work)
author koba <koba@cr.ie.u-ryukyu.ac.jp>
date Thu, 27 Jan 2011 21:05:30 +0900
parents b31bed246abd
children 978097c6427a
line wrap: on
line diff
--- a/ppe/Atari.cc	Tue Jan 25 17:43:30 2011 +0900
+++ b/ppe/Atari.cc	Thu Jan 27 21:05:30 2011 +0900
@@ -9,27 +9,29 @@
 {
     int w = (int)smanager->get_param(0);
     int h = (int)smanager->get_param(1);
+    long load_id = (long)smanager->get_param(2);
 
-    CollisionPropertyPtr property
-	= (CollisionPropertyPtr)smanager->get_input(rbuf, 0);
-    player *jiki = (player*)smanager->get_input(rbuf, 1);
+    CHARACTER *p = (CHARACTER*)smanager->get_input(rbuf, 0);
+    CollisionPropertyPtr property = 
+	(CollisionPropertyPtr)smanager->global_get(load_id);
+
+    int *p_infg_level = &property->infg_level;
+    int infg_level = *p_infg_level;
 
-    property->lg = *(stge*)smanager->get_input(rbuf, 2);
-    property->infg = *(stge*)smanager->get_input(rbuf, 3);
+    int tama_lv1_end = property->tama_lv1_end;
+    int tama_lv2_end = property->tama_lv2_end;
+    int laser_lv1_end = property->laser_lv1_end;
+
+    int *enemycount = &property->enemycount;
+
+    player *jiki = &property->jiki;
+
     stge *lg = &property->lg;
     stge *infg = &property->infg;
 
-    int infg_level = *(int*)smanager->get_input(rbuf, 4);
-    int tama_lv1_end = *(int*)smanager->get_input(rbuf, 5);
-    int tama_lv2_end = *(int*)smanager->get_input(rbuf, 6);
-    int laser_lv1_end = *(int*)smanager->get_input(rbuf, 7);
-
-    CHARACTER *p = &property->p;
-    int *enemycount = &property->enemycount;
-    tama1 *tlv3 = &property->tlv3;
-
     tama1 *tama_lv1 = property->tama_lv1;
     tama2 *tama_lv2 = property->tama_lv2;
+    tama1 *tlv3 = &property->tlv3;
     laser *laser_lv1 = property->laser_lv1;
     laser *laser_lv2 = &property->laser_lv2;
     laser *laser_lv3 = property->laser_lv3;
@@ -39,8 +41,7 @@
     ex = p->x;
     ey = p->y;
 
-    CollisionPropertyPtr w_property
-	= (CollisionPropertyPtr)smanager->get_output(wbuf, 0);
+    CHARACTER *q = (CHARACTER*)smanager->get_output(wbuf, 0);
     ObjContainerPtr sprite = (ObjContainerPtr)smanager->get_output(wbuf, 1);
     sprite->flag = false;
     sprite->length = 1;
@@ -54,8 +55,6 @@
 	sprite->flag = true;
 	Bom(jiki->x + 16, jiki->y + 16, &sprite->data[0]);
 	
-	property->collision_type = JIKI;
-
 	jiki->bf = FALSE;
 	jiki->zanki--;
 	jiki->muteki = 120;	
@@ -66,9 +65,8 @@
 	if (infg_level < 0)
 	    infg_level = 0;
 
-	property->infg_level = infg_level;
-
-	*w_property = *property;
+	*p_infg_level = infg_level;
+	*q = *p;
 	return 0;
     }
 #endif
@@ -81,7 +79,6 @@
 	    && (ex + w > tama_lv1[i1].x + 16)
 	    && (tama_lv1[i1].y + 128 > ey) && (tama_lv1[i1].y < ey + h)
 	    && (tama_lv1[i1].r != -1)) {
-	    property->collision_type = TAMALV1;
 
 	    tama_lv1[i1].r = -1;
 	    p->vit -= TAMALV1P;
@@ -91,18 +88,17 @@
 		sprite->flag = true;
 		Bom(p->x, p->y, &sprite->data[0]);
 		*enemycount += (p->score *
-			       ((infg->stg / 128) + infg_level + 1));
+				((infg->stg / 128) + infg_level + 1));
 		p->task = DELETE_CHARA;
 		p->f = FALSE;
 
-		*w_property = *property;
+		*q = *p;
 		return 0;
 	    }
 	}
 	if ((tama_lv1[i1].x + 64 > ex) && (ex + w > tama_lv1[i1].x)
 	    && (tama_lv1[i1].y + 128 > ey) && (tama_lv1[i1].y < ey + h)
 	    && (tama_lv1[i1].l != -1)) {
-	    property->collision_type = TAMALV1;
 
 	    tama_lv1[i1].l = -1;
 	    p->vit -= TAMALV1P;
@@ -116,7 +112,7 @@
 		p->task = DELETE_CHARA;
 		p->f = FALSE;
 
-		*w_property = *property;
+		*q = *p;
 		return 0;
 	    }
 	}
@@ -127,7 +123,6 @@
 	    && (ex + w > tama_lv2[i1].x + 128)
 	    && (tama_lv2[i1].y + 192 > ey) && (tama_lv2[i1].y < ey + h)
 	    && (tama_lv2[i1].rr != -1)) {
-	    property->collision_type = TAMALV2;
 
 	    tama_lv2[i1].rr = -1;
 	    p->vit -= TAMALV2P;
@@ -141,7 +136,7 @@
 		p->task = DELETE_CHARA;
 		p->f = FALSE;
 
-		*w_property = *property;
+		*q = *p;
 		return 0;
 	    }
 	}
@@ -151,7 +146,6 @@
 	    && (tama_lv2[i1].y - 32 + 192 > ey)
 	    && (tama_lv2[i1].y - 32 < ey + h)
 	    && (tama_lv2[i1].sr != -1)) {
-	    property->collision_type = TAMALV2;
 
 	    tama_lv2[i1].sr = -1;
 	    p->vit -= TAMALV2P;
@@ -165,7 +159,7 @@
 		p->task = DELETE_CHARA;
 		p->f = FALSE;
 
-		*w_property = *property;
+		*q = *p;
 		return 0;
 	    }
 	}
@@ -173,7 +167,6 @@
 	    && (tama_lv2[i1].y - 32 + 192 > ey)
 	    && (tama_lv2[i1].y - 32 < ey + h)
 	    && (tama_lv2[i1].sl != -1)) {
-	    property->collision_type = TAMALV2;
 
 	    tama_lv2[i1].sl = -1;
 	    p->vit -= TAMALV2P;
@@ -187,7 +180,7 @@
 		p->task = DELETE_CHARA;
 		p->f = FALSE;
 
-		*w_property = *property;
+		*q = *p;
 		return 0;
 	    }
 	}
@@ -195,7 +188,6 @@
 	    && (ex + w > tama_lv2[i1].x - 64)
 	    && (tama_lv2[i1].y + 192 > ey) && (tama_lv2[i1].y < ey + h)
 	    && (tama_lv2[i1].ll != -1)) {
-	    property->collision_type = TAMALV2;
 
 	    tama_lv2[i1].ll = -1;
 	    p->vit -= TAMALV2P;
@@ -209,14 +201,13 @@
 		p->task = DELETE_CHARA;
 		p->f = FALSE;
 
-		*w_property = *property;
+		*q = *p;
 		return 0;
 	    }
 	}
     }
     if ((tlv3->r > 0) && (jiki->x < ex + w) && (jiki->x + 128 > ex)
 	&& (jiki->y > ey + h)) {
-	property->collision_type = TAMALV3;
 
 	p->vit -= TAMALV3P;
 	infg->stg++;
@@ -229,14 +220,13 @@
 	    p->task = DELETE_CHARA;
 	    p->f = FALSE;
 
-	    *w_property = *property;
+	    *q = *p;
 	    return 0;
 	}
     }
 jumping:
     if ((tlv3->r > 0) && (jiki->x < ex + w) && (jiki->x + 128 > ex)
 	&& (jiki->y + 128 > ey) && (jiki->y < ey + h)) {
-	property->collision_type = TAMALV3;
 
 	p->vit -= TAMALV3P;
 	infg->stg++;
@@ -249,7 +239,7 @@
 	    p->task = DELETE_CHARA;
 	    p->f = FALSE;
 
-	    *w_property = *property;
+	    *q = *p;
 	    return 0;
 	}
     }
@@ -260,7 +250,6 @@
 	if ((laser_lv1[i1].x + n > ex) && (ex + w > laser_lv1[i1].x)
 	    && (laser_lv1[i1].y + n > ey) && (laser_lv1[i1].y < ey + h)
 	    && (laser_lv1[i1].r != -1)) {
-	    property->collision_type = LASERLV1;
 
 	    laser_lv1[i1].r = -1;
 	    laser_lv1[i1].y = -1;
@@ -275,7 +264,7 @@
 		p->task = DELETE_CHARA;
 		p->f = FALSE;
 
-		*w_property = *property;
+		*q = *p;
 		return 0;
 	    }
 	}
@@ -285,7 +274,6 @@
 	(laser_lv2[0].x + 128 > ex) && (ex + w > laser_lv2[0].x - 128)
 	&& (laser_lv2[0].y + 128 > ey) && (laser_lv2[0].y - 128 < ey + h)
 	&& (laser_lv2[0].r != 0)) {
-	property->collision_type = LASERLV2;
 
 	p->vit -= LASERLV2P;
 	lg->stg -= 26;
@@ -302,7 +290,7 @@
 	    p->task = DELETE_CHARA;
 	    p->f = FALSE;
 	    
-	    *w_property = *property;
+	    *q = *p;
 	    return 0;
 	}
     }
@@ -313,7 +301,6 @@
 		&& (laser_lv3[i1].y + 128 > ey)
 		&& (laser_lv3[i1].y < ey + h)
 		&& (laser_lv3[i1].r > 0)) {
-		property->collision_type = LASERLV3;
 
 		tama_lv2[i1].rr = -1;
 		p->vit -= LASERLV3P;
@@ -327,15 +314,13 @@
 		    p->task = DELETE_CHARA;
 		    p->f = FALSE;
 
-		    *w_property = *property;
+		    *q = *p;
 		    return 0;
 		}
 	    }
 	}
     }
 
-    property->collision_type = NO;
-    
-    *w_property = *property;
+    *q = *p;
     return 0;
 }