Mercurial > hg > Members > koba > t_dandy
view collision_task.cc @ 64:07bc996c8e49
fix t_dandy on ps3.
author | koba <koba@cr.ie.u-ryukyu.ac.jp> |
---|---|
date | Fri, 11 Feb 2011 18:20:30 +0900 |
parents | 3c2fc35a6b55 |
children | f27a6af6514c |
line wrap: on
line source
#include <stdio.h> #include <stdlib.h> #include <SDL.h> #include "Func.h" #include "TaskManager.h" #include "Character.h" #include "Character_state.h" #include "count2.h" #include "tokuten.h" #include "object.h" #include "sgoex.h" #include "debug_db.h" #include "StateList.h" #include "property.h" #include "collision_task.h" extern SpriteTable sptable[DEFOBJ]; extern DebugDB dtable[DEFOBJ]; extern TaskManager *tmanager; HTaskPtr update_task; HTaskPtr reflect_task; void state_check(CHARACTER *p) { int num = GetStateNum(p->state_task); if (p->collision_task == true) { //debug if (p->tama == FALSE) { printf("F%d: DELETE [NAME]%s_%d [COORD]x= %f y= %f vx= %f vy= %f\n", filpcount, dtable[p->charano].name, p->chara_id, p->x, p->y, p->vx, p->vy); printf(" [BULLET]tlv1 = %d, tlv2 = %d llv1 = %d\n", tama_lv1_end+1, tama_lv2_end+1, laser_lv1_end+1); } p->state_task = DELETE_CHARA; p->state = delete_chara; p->collision = noaction; return; } p->state = state_list[num].state; } static CollisionPropertyPtr get_property() { CollisionPropertyPtr property = (CollisionPropertyPtr)tmanager->allocate(sizeof(CollisionProperty)); property->infg_level = infg_level; property->tama_lv1_end = tama_lv1_end; property->tama_lv2_end = tama_lv2_end; property->laser_lv1_end = laser_lv1_end; property->enemycount = enemycount; property->jiki = jiki; property->lg = lg; property->infg = infg; memcpy(property->tama_lv1, tama_lv1, sizeof(tama1)*20); memcpy(property->tama_lv2, tama_lv2, sizeof(tama2)*20); property->tlv3 = tlv3[0]; memcpy(property->laser_lv1, laser_lv1, sizeof(laser)*20); property->laser_lv2 = laser_lv2[0]; memcpy(property->laser_lv3, laser_lv3, sizeof(laser)*64); return property; } void reflect_property(SchedTask *s, void *prop, void *none) { CollisionPropertyPtr property = (CollisionPropertyPtr)prop; infg_level = property->infg_level; tama_lv1_end = property->tama_lv1_end; tama_lv2_end = property->tama_lv2_end; laser_lv1_end = property->laser_lv1_end; enemycount = property->enemycount; if (jiki.bf == FALSE) { jiki = property->jiki; } lg = property->lg; infg = property->infg; memcpy(tama_lv1, property->tama_lv1, sizeof(tama1)*20); memcpy(tama_lv2, property->tama_lv2, sizeof(tama2)*20); tlv3[0] = property->tlv3; memcpy(laser_lv1, property->laser_lv1, sizeof(laser)*20); laser_lv2[0] = property->laser_lv2; memcpy(laser_lv3, property->laser_lv3, sizeof(laser)*64); } void after_free(SchedTask *s, void *object, void *none) { free(object); } void collision_allocate() { HTaskPtr alloc_task = tmanager->create_task(DataAllocate); alloc_task->set_param(0, (memaddr)1); alloc_task->set_param(1, (memaddr)sizeof(CollisionProperty)); alloc_task->set_param(2, (memaddr)COLLDATA); #ifndef PPE_ONLY alloc_task->set_cpu(SPE_0); #else alloc_task->set_cpu(CPU_PPE); #endif alloc_task->spawn(); } HTaskPtr collision_update() { update_task = tmanager->create_task(DataUpdate); CollisionPropertyPtr property = get_property(); update_task->set_param(0, (memaddr)1); update_task->set_param(1, (memaddr)COLLDATA); update_task->set_inData(0, property, sizeof(CollisionProperty)); update_task->set_post(after_free, (void*)property, NULL); #ifndef PPE_ONLY update_task->set_cpu(SPE_0); #else update_task->set_cpu(CPU_PPE); #endif return update_task; } HTaskPtr collision_reflect() { reflect_task = tmanager->create_task(COLLDATA_REFLECT); CollisionPropertyPtr property = (CollisionPropertyPtr)tmanager->allocate(sizeof(CollisionProperty)); reflect_task->set_param(0, (memaddr)COLLDATA); reflect_task->set_outData(0, property, sizeof(CollisionProperty)); reflect_task->set_post(reflect_property, (void*)property, NULL); #ifndef PPE_ONLY reflect_task->set_cpu(SPE_0); #else reflect_task->set_cpu(CPU_PPE); #endif return reflect_task; } void collision_free() { HTaskPtr free_task = tmanager->create_task(DataFree); free_task->set_param(0, (memaddr)COLLDATA); #ifndef PPE_ONLY free_task->set_cpu(SPE_0); #else free_task->set_cpu(CPU_PPE); #endif free_task->spawn(); } void collision_check(SchedTask *s, void *object, void *chara) { CHARACTER *p = (CHARACTER*)chara; state_check(p); free(object); } CHARACTER* atari(CHARACTER *p) { int w, h, charno; charno = p->charano; w = sptable[charno].w; h = sptable[charno].h; int obj_size = sizeof(ObjContainer); ObjContainerPtr obj = (ObjContainerPtr)tmanager->allocate(obj_size); obj->flag = false; obj->length = 0; HTaskPtr collision_task = tmanager->create_task(ATARI); collision_task->set_param(0,(memaddr)w); collision_task->set_param(1,(memaddr)h); collision_task->set_param(2, (memaddr)COLLDATA); collision_task->set_inData(0, p, sizeof(CHARACTER)); collision_task->set_outData(0, p, sizeof(CHARACTER)); collision_task->set_outData(1, obj, obj_size); collision_task->set_post(collision_check, (void*)obj, (void*)p); #ifndef PPE_ONLY collision_task->set_cpu(SPE_0); #else collision_task->set_cpu(CPU_PPE); #endif collision_task->wait_for(update_task); reflect_task->wait_for(collision_task); collision_task->spawn(); return p; }