diff options
Diffstat (limited to 'src/bossThwompaDomp.cpp')
-rw-r--r-- | src/bossThwompaDomp.cpp | 312 |
1 files changed, 276 insertions, 36 deletions
diff --git a/src/bossThwompaDomp.cpp b/src/bossThwompaDomp.cpp index 1c366b8..268b4bd 100644 --- a/src/bossThwompaDomp.cpp +++ b/src/bossThwompaDomp.cpp @@ -1,6 +1,7 @@ #include <common.h> #include <game.h> #include <g3dhax.h> +#include <sfx.h> #include "daEnDosun_c.h" @@ -22,30 +23,65 @@ void sub_8009ea50( _464_struct* data ) { } #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(); + int onCreate(); // overload for mega + int onExecute(); static daEnMegaDosun_c *build(); //int checkZoneBoundaries(int); +#if STATES_NEEDED //FIXME - //USING_STATES(daEnMegaDosun_c); - //DECLARE_STATE(Wait); + 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 0 +#if 1 +//FIXME stops halfway up int daEnMegaDosun_c::onCreate() { - //FIXME + 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 @@ -54,17 +90,10 @@ int daEnMegaDosun_c::onCreate() { this->pos.y -= 21.0; this->pos.z = -280.0; // behind layer1 (hides spikes) - //FIXME might be u32 0x11804101 - /* - this->collision_struct[0] = 0x11; - this->collision_struct[1] = 0x80; - this->collision_struct[2] = 0x41; - this->collision_struct[3] = 0x01; - */ - this->collision_struct = 0x11804101; - this->_5C0 = 0xFFFE1000; - this->_5C4 = 0x1F000; - this->_5C8 = 0x5000; + this->collision_struct[0] = 0x11804101; + this->collision_struct[1] = 0xFFFE1000; + this->collision_struct[2] = 0x0001F000; + this->collision_struct[3] = 0x00005000; /* //0x80ACF990 + 0x8C = 80acfa1C @@ -74,6 +103,7 @@ int daEnMegaDosun_c::onCreate() { */ ActivePhysics::Info hm; hm.xDistToCenter = 0.0; + //FIXME find the missing link hm.yDistToCenter = 41.0; hm.xDistToEdge = 36.0; hm.yDistToEdge = 38.0; @@ -83,6 +113,7 @@ int daEnMegaDosun_c::onCreate() { 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, @@ -90,8 +121,9 @@ int daEnMegaDosun_c::onCreate() { * 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}; - //FIXME 0x80ACF990 + 0x58 = 80acf9e8 + //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; @@ -100,6 +132,7 @@ int daEnMegaDosun_c::onCreate() { this->_320 = 0.0; this->_324 = 48.0; + OSReport("this->aPhysics.addToList();\n"); this->aPhysics.addToList(); this->scale.x = 1.0; @@ -113,6 +146,7 @@ int daEnMegaDosun_c::onCreate() { 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); @@ -124,22 +158,230 @@ int daEnMegaDosun_c::onCreate() { } #endif -#if 0 int daEnMegaDosun_c::onExecute() { acState.execute(); - //FIXME change to do outro when leaving screen - //this->checkZoneBoundaries(0); + /* + 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.s_80072BC0(); + 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 -//FIXME #if 0 int daEnMegaDosun_c::checkZoneBoundaries(int foo) { - if(this->_36C == 2) { // is eaten + if(this->eatenState == 2) { // is eaten return 0; } @@ -150,16 +392,14 @@ int daEnMegaDosun_c::checkZoneBoundaries(int foo) { int ret = 0; -#if 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->s800064da0(pos, &tempRect, currentZoneId) || + if(this->outOfZone(this->pos, &tempRect, currentZoneId) || (!(foo&0x4) && s_800b56e0(pos, &tempRect, &tempRect2, currentZoneId)) ) { ret = 1; } -#endif if(ret && !(foo & 0x2)) this->Delete(this->_390); @@ -173,22 +413,22 @@ 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; @@ -205,8 +445,8 @@ void ThwompaDompMoveC(dEn_c *Sprite) { else { Sprite->pos.x = Sprite->pos.x - 1.0; } } - - + + return; } #endif |