#include #include #include #include #include "daEnDosun_c.h" #if 0 /* called from _vf228 */ /* handles overall scale */ void sub_8009ea50( _464_struct* data ) { u32 ctr = data->ctr; // _0x14 dEn_c* en = data->en; // _0x18 if(!ctr) { en->scale.x = en->scale.y = en->scale.z = 1.0; data->x = data->y = data->z = data->_0xC = 1.0 return; } data->ctr--; /*FIXME continue */ } #endif //FIXME find if needed extern "C" int s_800b56e0(Vec,float*,float*,u8 zone); //FIXME extern "C" void* unk_8042A008; extern "C" void UnknownBullshit(void*,int,int,int,int); //FIXME extern "C" void* SoundRelatedClass; extern "C" Vec ConvertStagePositionIntoScreenPosition__Maybe(Vec); extern "C" void AnotherSoundRelatedFunction(void*,SFX,Vec,int); #define OLD 0 #define STATES_NEEDED 1 #define SETTINGS1CHANGE 1 class daEnMegaDosun_c : public daEnDosun_c { int onCreate(); // overload for mega int onExecute(); static daEnMegaDosun_c *build(); //int checkZoneBoundaries(int); #if STATES_NEEDED //FIXME USING_STATES(daEnMegaDosun_c); DECLARE_STATE(UpWait); DECLARE_STATE(DownMoveWait); DECLARE_STATE(PuruMove); DECLARE_STATE(DownMoveKameck); DECLARE_STATE(DownMove); DECLARE_STATE(DownWait); DECLARE_STATE(UpMove); #endif }; #if STATES_NEEDED CREATE_STATE(daEnMegaDosun_c, UpWait); CREATE_STATE(daEnMegaDosun_c, DownMoveWait); CREATE_STATE(daEnMegaDosun_c, PuruMove); CREATE_STATE(daEnMegaDosun_c, DownMoveKameck); CREATE_STATE(daEnMegaDosun_c, DownMove); CREATE_STATE(daEnMegaDosun_c, DownWait); CREATE_STATE(daEnMegaDosun_c, UpMove); #endif daEnMegaDosun_c *daEnMegaDosun_c::build() { OSReport("Building MegaThwomp\n"); void *buffer = AllocFromGameHeap1(sizeof(daEnMegaDosun_c)); return new(buffer) daEnMegaDosun_c; } #if 1 //FIXME stops halfway up int daEnMegaDosun_c::onCreate() { OSReport("daEnMegaDosun::onCreate()\n"); this->bigOrSmall = 1; // 0=small,1=big,2=mega this->setupBodyModel(); // add this for linking/rename this->_36D = 0; // byte this->holdsFromSettings = this->settings & 0xf; //0=normal,1=??,2=fall this->frzMgr.setSomething(1,1,1); //@0x809f5c5c this->pos.y -= 21.0; this->pos.z = -280.0; // behind layer1 (hides spikes) this->collision_struct[0] = 0x11804101; this->collision_struct[1] = 0xFFFE1000; this->collision_struct[2] = 0x0001F000; this->collision_struct[3] = 0x00005000; /* //0x80ACF990 + 0x8C = 80acfa1C 0.0,41.0,36.0,38.0, 0x03, 0x00, 0x0000,0x0000004F,0x0000820E,0x0100,0x0000 dEn_c::collisionCallback (0x80095950) */ ActivePhysics::Info hm; hm.xDistToCenter = 0.0; //FIXME find the missing link hm.yDistToCenter = 41.0; hm.xDistToEdge = 36.0; hm.yDistToEdge = 38.0; hm.category1 = 0x03; hm.category2 = 0x00; hm.bitfield1 = 0x0000004F; hm.bitfield2 = 0x0000820E; hm.unkShort1C = 0x0100; hm.callback = &dEn_c::collisionCallback; OSReport("this->aPhysiscs.initWithStruct(this,&hm);\n"); this->aPhysics.initWithStruct(this, &hm); /* 0x00000001,0xfffe1000,0x0001f000,0x00055000, * 0.0,20.0,16.0,19.0 * 0x03000000,0x0000004f,0x0000820e,0x01000000, * dEn_c::collisionCallback */ //u8 s3[] = {0,0,0,1,0xff,0xfe,0x10,0,0,1,0xf0,0,0,5,0x50,0}; u8 s3[] = {0,0,0,1,0xff,0xfe,0x10,0,0,1,0xf0,0,0xff,0xfe,0x10,0}; OSReport("this->collMgr.Init(this,(u8*)&this->collision_struct,(u8*)&s3,0);\n"); this->collMgr.Init(this,(u8*)&this->collision_struct,(u8*)&s3,0); this->pos_delta2.x = 0.0; this->pos_delta2.y = 36.0; this->pos_delta2.z = 0.0; this->_320 = 0.0; this->_324 = 48.0; OSReport("this->aPhysics.addToList();\n"); this->aPhysics.addToList(); this->scale.x = 1.0; this->scale.y = 1.0; this->scale.z = 1.0; this->max_speed.x = 0.0; this->max_speed.y = -8.0; this->max_speed.z = 0.0; this->y_speed_inc = -0.25; this->rot.x = 0; this->rot.y = 0; this->rot.z = 0; OSReport("this->doStateChange(FOO): %d\n", this->holdsFromSettings); // check settings bit if(this->holdsFromSettings == 2) { this->doStateChange(&StateID_DownMove_Kameck); }else{ this->doStateChange(&StateID_UpWait); } return 1; } #endif int daEnMegaDosun_c::onExecute() { acState.execute(); /* float tempRect[4] = {this->_320,this->_324,0.5*this->spriteSomeRectX,0.5*this->spriteSomeRectY}; int foo = this->outOfZone(this->pos, tempRect, this->currentZoneID); //float tempRect2[4] = {this->_338, this->_33C, this->_340, this->_344}; //OSReport("s_800b56e0()\n"); //int bar = s_800b56e0(this->pos, tempRect, tempRect2, this->currentZoneID); //OSReport("foo: %d, bar: %d\n", foo, bar); if(foo) { OSReport("this->outOfZone(%d) : %d\n", this->currentZoneID, foo); OSReport("daEnMegaDosun_c has left the building\n"); this->Delete(this->_390); //FIXME change to do outro when leaving screen }else{ OSReport("this->outOfZone(%d) : %d\n", this->currentZoneID, foo); } */ int ret = this->checkZoneBoundaries(0); if(ret) { OSReport("daEnMegaDosun_c has left the building\n"); } return 1; } #if STATES_NEEDED //FIXME add sideways moving //StateID_UpWait void daEnMegaDosun_c::beginState_UpWait() { OSReport("beginState_UpWait()\n"); this->countdownTimer = 0; if(!this->bigOrSmall) return; this->collision_struct[0] = 0x11804101; } void daEnMegaDosun_c::executeState_UpWait() { OSReport("executeState_UpWait()\n"); if(this->countdownTimer != 0) { this->countdownTimer--; return; } //FIXME need megasized - also needs to be less leeway float _array[] = { 48.0, 80.0 }; // small, big //CheckIfPlayerBelow(xDelta, yDelta); //if(this->CheckIfPlayerBelow(80.0, 256.0)) { if(this->CheckIfPlayerBelow(40.0, 256.0)) { this->doStateChange(&StateID_DownMoveWait); this->speed.y = 0.0; } } void daEnMegaDosun_c::endState_UpWait() { OSReport("endState_UpWait()\n"); return; } //StateID_DownMoveWait void daEnMegaDosun_c::beginState_DownMoveWait() { OSReport("beginState_DownMoveWait()\n"); this->anmVis.playState = 1; this->bodyModel.bindAnim(&this->anmVis, 0.5); } void daEnMegaDosun_c::executeState_DownMoveWait() { OSReport("executeState_DownMoveWait()\n"); if(this->anmVis.isAnimationDone()) this->doStateChange(&StateID_PuruMove); this->anmVis.process(); } void daEnMegaDosun_c::endState_DownMoveWait() { OSReport("endState_DownMoveWait()\n"); return; } //StateID_PuruMove void daEnMegaDosun_c::beginState_PuruMove() { OSReport("beginState_PuruMove()\n"); this->puruMoveCounter = 8; this->shakeIndex = 0; } void daEnMegaDosun_c::executeState_PuruMove() { OSReport("executeState_PuruMove()\n"); if(this->puruMoveCounter == 0) { this->shakePosXoffset = 0.0; this->doStateChange(&StateID_DownMove); return; } this->puruMoveCounter--; if(this->puruMoveCounter & 2 == 0) return; float _array[] = {2.0, 0.0}; this->shakeIndex ^= 1; this->shakePosXoffset = _array[this->shakeIndex]; } void daEnMegaDosun_c::endState_PuruMove() { OSReport("endState_PuruMove()\n"); return; } //StateID_DownMoveKameck void daEnMegaDosun_c::beginState_DownMoveKameck() { OSReport("beginState_DownMoveKameck()\n"); this->anmVis.playState = 1; this->bodyModel.bindAnim(&this->anmVis, 0.5); } void daEnMegaDosun_c::executeState_DownMoveKameck() { OSReport("executeState_DownMoveKameck()\n"); if(this->anmVis.isAnimationDone()) this->doStateChange(&StateID_DownMove); this->anmVis.process(); } void daEnMegaDosun_c::endState_DownMoveKameck() { OSReport("endState_DownMoveKameck()\n"); return; } //StateID_DownMove void daEnMegaDosun_c::beginState_DownMove() { OSReport("beginState_DownMove()\n"); this->speed.y = 0.0; } void daEnMegaDosun_c::executeState_DownMove() { OSReport("executeState_DownMove()\n"); this->HandleYSpeed(); this->UpdateObjectPosBasedOnSpeedValuesReal(); //FIXME what do I do? - bottom detection int ret = this->collMgr.execute(); OSReport("s_80072BC0(): %08x\n", ret); if(!ret) return; #if SETTINGS1CHANGE if((this->holdsFromSettings == 1) && (ret & 0x8000)) { OSReport("this->speed.y = 0.0;\n"); this->speed.y = 0.0; } if(this->holdsFromSettings == 2) { OSReport("ret |= 0x400000\n"); ret |= 0x400000; } #else if(this->holdsFromSettings == 1) { OSReport("ret |= 0x400000\n"); ret |= 0x400000; } #endif if(!(ret & 0x400000)) { OSReport("doStateChange(&StateID_DownWait)\n"); this->doStateChange(&StateID_DownWait); this->countdownTimer = 0x40; this->speed.y = 0.0; UnknownBullshit(unk_8042A008, 0, 1, 0, 0); }else{ this->collision_struct[0] = 0x00000001; this->speed.y = 0.0; OSReport("UnknownBullshit(%x,%d,%d,%d,%d)\n", unk_8042A008,0,1,0,0); UnknownBullshit(unk_8042A008, 0, 1, 0, 0); this->collMgr.Clear2(); } this->spawnEffects(); Vec p = ConvertStagePositionIntoScreenPosition__Maybe(this->pos); AnotherSoundRelatedFunction(SoundRelatedClass, SE_EMY_BIG_DOSSUN, p, 0); //SoundRelatedClass.AnotherSoundRelatedFunction(SE_EMY_BIG_DOSSUN, p, 0); } void daEnMegaDosun_c::endState_DownMove() { OSReport("endState_DownMove()\n"); return; } //StateID_DownWait void daEnMegaDosun_c::beginState_DownWait() { OSReport("beginState_DownWait()\n"); return; } void daEnMegaDosun_c::executeState_DownWait() { OSReport("executeState_DownWait()\n"); if(this->countdownTimer == 0) { this->doStateChange(&StateID_UpMove); }else{ this->countdownTimer--; if(this->countdownTimer & 0xff == 0x20) this->anmVis.playState = 3; } this->anmVis.process(); } void daEnMegaDosun_c::endState_DownWait() { OSReport("endState_DownWait()\n"); return; } //StateID_UpMove void daEnMegaDosun_c::beginState_UpMove() { OSReport("beginState_UpMove()\n"); this->collMgr.Clear2(); } void daEnMegaDosun_c::executeState_UpMove() { OSReport("executeState_UpMove()\n"); this->speed.y = 0.875; this->UpdateObjectPosBasedOnSpeedValuesReal(); int ret = this->collMgr.SomethingSemiImportant(0); OSReport("this->collMgr.SomethingSemiImportant(0): %08x\n", ret); if(ret != 0) { // at top this->doStateChange(&StateID_UpWait); this->countdownTimer = 0xc; } } void daEnMegaDosun_c::endState_UpMove() { OSReport("endState_UpMove()\n"); return; } #endif #if 0 int daEnMegaDosun_c::checkZoneBoundaries(int foo) { if(this->eatenState == 2) { // is eaten return 0; } if( (0 == (foo&0x8)) && \ (this->collMgr.checkBits15and16ofBitfield() != 0) ) { return 0; } int ret = 0; Rect tempRect = (Rect){this->_320, this->_324, 0.5 * this->spriteSomeRectX, 0.5 * this->spriteSomeRectY}; Rect tempRect2 = (Rect){_338, _33C, _340, _344}; if(this->outOfZone(this->pos, &tempRect, currentZoneId) || (!(foo&0x4) && s_800b56e0(pos, &tempRect, &tempRect2, currentZoneId)) ) { ret = 1; } if(ret && !(foo & 0x2)) this->Delete(this->_390); return ret; } #endif #if 0 extern "C" bool CollidedWithTile(u8 *); extern "C" void *SomeStrangeModification(dEn_c *); void ThwompaDompMoveC(dEn_c *Sprite) { bool FirstCheck; bool SecondCheck; // Check for collisions with walls? FirstCheck = CollidedWithTile(Sprite->collMgr); SomeStrangeModification(Sprite); SecondCheck = CollidedWithTile(Sprite->collMgr); OSReport("XPos = %f, FirstCheck = %d, SecondCheck = %d", Sprite->pos.x, FirstCheck, SecondCheck); if ((FirstCheck != 0) && (SecondCheck != 0)) { OSReport("Actually doing something, I swear"); Sprite->pos.y = Sprite->pos.y + 16.0; Sprite->pos.x = Sprite->pos.x - 180.0; if (Sprite->direction == 0) { Sprite->direction = 1; Sprite->pos.x = Sprite->pos.x - 80.0; } else { Sprite->direction = 0; Sprite->pos.x = Sprite->pos.x + 80.0; } } else { if (Sprite->direction == 0) { Sprite->pos.x = Sprite->pos.x + 1.0; } else { Sprite->pos.x = Sprite->pos.x - 1.0; } } return; } #endif /* class daYoshi_c : public dStageActor_c { u32 _1520; // holds actorID of actor eaten }; */