From cccb93935e965e10613b16a93aa6970f5f7975aa Mon Sep 17 00:00:00 2001 From: Stephen Simpson Date: Wed, 12 Oct 2011 22:36:16 -0500 Subject: removed MAME goomba and lowered amount in launch state --- src/bossMegaGoomba.cpp | 20 ++++++++------------ 1 file changed, 8 insertions(+), 12 deletions(-) diff --git a/src/bossMegaGoomba.cpp b/src/bossMegaGoomba.cpp index 36f521c..9817a02 100644 --- a/src/bossMegaGoomba.cpp +++ b/src/bossMegaGoomba.cpp @@ -93,7 +93,7 @@ class daMegaGoomba_c : public dEn_c { }; extern "C" void *PlaySound(dStageActor_c *, int soundID); -//extern void * HandleXSpeed(daMegaGoomba_c*); +extern void * HandleXSpeed(daMegaGoomba_c*); //extern void * HandleYSpeed(daMegaGoomba_c*); daMegaGoomba_c *daMegaGoomba_c::build() { @@ -405,8 +405,8 @@ void daMegaGoomba_c::executeState_Launch() { this->rot.y = sin(this->timer * 3.14 / 5) * 4000; dStageActor_c *spawner = NULL; - // 120ticks / 80numbers * 4cases = 6avg kuribo - int randChoice = GenerateRandomNumber(80); + // 120ticks / 120numbers * 3cases = 3avg kuribo + int randChoice = GenerateRandomNumber(120); int randChoiceX = GenerateRandomNumber(12); int randChoiceY = GenerateRandomNumber(7); switch(randChoice) { @@ -429,12 +429,6 @@ void daMegaGoomba_c::executeState_Launch() { spawner->speed.y = randChoiceY + 3.0; spawner->scale = (Vec){1.0, 1.0, 1.0}; break; - case 4: - spawner = CreateActor(EN_MAME_KURIBO, 0, this->pos, 0, 0); - spawner->speed.x = randChoiceX - 6.0; - spawner->speed.y = randChoiceY + 3.0; - spawner->scale = (Vec){1.0, 1.0, 1.0}; - break; default: break; }; @@ -495,9 +489,11 @@ void daMegaGoomba_c::beginState_Walk() { } void daMegaGoomba_c::executeState_Walk() { - float delta = (this->direction) ? -this->XSpeed : this->XSpeed; - this->pos.x += delta; - + //HandleAcceleration(); + HandleXSpeed(); + UpdateObjectPosBasedOnSpeedValues_real(); + //DoGravityMaybe(); + int Choice; float TimerMax = 150.0; if (this->timer > TimerMax) { -- cgit v1.2.3 From 7a4ee17ea46742a5aff331ad195eb5be098c01b2 Mon Sep 17 00:00:00 2001 From: Stephen Simpson Date: Wed, 12 Oct 2011 23:05:13 -0500 Subject: Started adding animations in. also fix for updated effects --- include/g3dhax.h | 179 +++++++++++++++++++++++++++++++++++++++++++++++++++---- src/effects.cpp | 8 +-- 2 files changed, 171 insertions(+), 16 deletions(-) diff --git a/include/g3dhax.h b/include/g3dhax.h index d816a24..ddeb3ee 100644 --- a/include/g3dhax.h +++ b/include/g3dhax.h @@ -1,6 +1,8 @@ #ifndef __KAMEK_G3DHAX_H #define __KAMEK_G3DHAX_H +#include + // nw4r::g3d wrapper namespace nw4r { @@ -26,6 +28,10 @@ namespace nw4r { void * /*ResMat*/ GetResMat(const char *str) const; }; + class ResAnmChr { public: void* data; ResAnmChr(void *p = NULL) { data = p; } }; + class ResAnmTexPat { public: void* data; ResAnmTexPat(void *p = NULL) { data = p; } }; + class ResAnmTexSrt { public: void* data; ResAnmTexSrt(void *p = NULL) { data = p; } }; + class ResFile { public: void * /*ResFileData*/ data; @@ -42,11 +48,11 @@ namespace nw4r { void * /*ResTex*/ GetResTex(const char *str) const; void * /*ResTex*/ GetResTex(const ResName n) const; void * /*ResTex*/ GetResTex(u32 idx) const; - void * /*ResAnmChr*/ GetResAnmChr(const char *str) const; + ResAnmChr GetResAnmChr(const char *str) const; void * /*ResAnmVis*/ GetResAnmVis(const char *str) const; void * /*ResAnmClr*/ GetResAnmClr(const char *str) const; - void * /*ResAnmTexPat*/ GetResAnmTexPat(const char *str) const; - void * /*ResAnmTexSrt*/ GetResAnmTexSrt(const char *str) const; + ResAnmTexPat GetResAnmTexPat(const char *str) const; + ResAnmTexSrt GetResAnmTexSrt(const char *str) const; void * /*ResAnmScn*/ GetResAnmScn(const char *str) const; bool Bind(ResFile rhs); @@ -133,19 +139,40 @@ namespace nw4r { } -class mHeapAllocator_c { // Actually that weird subclass. INCOMPLETE!! +namespace EGG { + class Allocator { + public: + char data1[0x10]; + + Allocator(void *heap, s32 align); + virtual ~Allocator(); + + virtual void *alloc(u32 size); + virtual void free(void *block); + + void *heap; + s32 alignment; + }; +} + +class mAllocator_c : public EGG::Allocator { public: - char data1[0x10]; + mAllocator_c(); + ~mAllocator_c(); + + void *alloc(u32 size); + void free(void *block); +}; +class mHeapAllocator_c : public mAllocator_c { + public: mHeapAllocator_c(); - virtual ~mHeapAllocator_c(); - virtual void *alloc(u32 size); - virtual void free(void *block); + ~mHeapAllocator_c(); bool link(s32 size, void *heap, const char *name, int align); u32 unlink(); - char data2[8]; + bool linkAndBecomeCurrentHeap(s32 size, void *heap, const char *name, int align); }; namespace m3d { @@ -186,6 +213,8 @@ namespace m3d { void *scnObj; }; + class banm_c; + class mdl_c { public: mdl_c(); @@ -202,12 +231,138 @@ namespace m3d { void sub_80064BF0(); void setDrawMatrix(const Mtx matrix); - void setScale(float x, float y, float z); - void setScale(Vec *scale); - void calcWorld(bool unk); + + void bindAnim(banm_c *animation, float unk); char data[0x3C]; }; + + + + + class banm_c { + public: + virtual ~banm_c(); + + virtual int _vf0C() = 0; + virtual void detach(); + virtual void process(); + + bool testAnmFlag(u32 flag); /* nw4r::g3d::AnmObj::AnmFlag */ + + void *anmObj; // should be NW4R AnmObj class + void *frameHeap; // should be a frame heap + mAllocator_c allocator; + + private: + void setupHeap(mAllocator_c *allocator, u32 *sizeOutput); + float _getCurrentFrame(); + float _setCurrentFrame(float value); + float _getUpdateRate(); + float _setUpdateRate(float value); + }; + + class fanm_c : public banm_c { + public: + fanm_c(); + ~fanm_c(); + + void process(); + + void _80169050(float _unk, float updateRate, float _unk2, u8 _unk3); + void setCurrentFrame(float value); + bool isAnimationDone(); // I think + bool querySomething(float value); + + // 28 might be Max Frame? + float _28, _2C, currentFrame; + u8 _34; + }; + + class anmChr_c : public fanm_c { + public: + ~anmChr_c(); + int _vf0C(); + + bool setup(nw4r::g3d::ResMdl modelRes, nw4r::g3d::ResAnmChr anmRes, + mAllocator_c *allocator, u32 *sizeOutPtr); + + void bind(/*b*/mdl_c *model, nw4r::g3d::ResAnmChr anmRes, int unk); + }; + + class anmTexPat_c : public banm_c { + public: + class child_c : public fanm_c { + ~child_c(); + int _vf0C(); + + // some methods missing + }; + + // some methods missing + + ~anmTexPat_c(); + int _vf0C(); + void detach(); + void process(); + + bool setup(nw4r::g3d::ResMdl modelRes, nw4r::g3d::ResAnmTexPat anmRes, + mAllocator_c *allocator, u32 *sizeOutPtr, int count); + + void bindEntry(/*b*/mdl_c *model, nw4r::g3d::ResAnmTexPat resource, + int entryNumber, int _param4); + + float getFrameForEntry(int number); + void setFrameForEntry(float value, int number); + float getUpdateRateForEntry(int number); + void setUpdateRateForEntry(float value, int number); + bool isEntryAnimationDone(int number); + bool queryEntrySomething(float value, int number); + void setEntryByte34(u8 value, int number); + float getEntryField28(int number); + + private: + child_c *children; + + void processOneEntry(int number); + }; + + class anmTexSrt_c : public banm_c { + public: + class child_c : public fanm_c { + ~child_c(); + int _vf0C(); + + // some methods missing + }; + + // some methods missing + + ~anmTexSrt_c(); + int _vf0C(); + void detach(); + void process(); + + bool setup(nw4r::g3d::ResMdl modelRes, nw4r::g3d::ResAnmTexSrt anmRes, + mAllocator_c *allocator, u32 *sizeOutPtr, int count); + + void bindEntry(/*b*/mdl_c *model, nw4r::g3d::ResAnmTexSrt resource, + int entryNumber, int _param4); + + float getFrameForEntry(int number); + void setFrameForEntry(float value, int number); + float getUpdateRateForEntry(int number); + void setUpdateRateForEntry(float value, int number); + bool isEntryAnimationDone(int number); + void setEntryByte34(u8 value, int number); + float getEntryField28(int number); + float getEntryField2C(int number); + + private: + child_c *children; + + void processOneEntry(int number); + }; }; diff --git a/src/effects.cpp b/src/effects.cpp index 8d0e565..40f08a2 100644 --- a/src/effects.cpp +++ b/src/effects.cpp @@ -1004,7 +1004,7 @@ const char* effects_name_list [] = { "Wm_ob_treasureboxwait_b" }; -extern "C" void SpawnEffect(const char*, int, Vec*, int, int); +extern "C" bool SpawnEffect(const char*, int, Vec*, S16Vec*, Vec*); // Just call CreateEffect(this, number_between_0_and_1000); bool CreateEffect(dEn_c* enemy, int effect_num) { @@ -1022,7 +1022,7 @@ bool CreateEffect(Vec* pos, S16Vec* rot, Vec* scale, int effect_num) { return false; if (effect_num < 0) return false; - Vec tempVec = (Vec){ pos.x, pos.y, 5500.0 }; + Vec tempVec = (Vec){ pos->x, pos->y, 5500.0 }; const char* effect_name = effects_name_list[effect_num]; return SpawnEffect(effect_name, 0, &tempVec, rot, scale); } @@ -1030,8 +1030,8 @@ bool CreateEffect(Vec* pos, S16Vec* rot, Vec* scale, int effect_num) { bool CreateEffect(const char* name, Vec* pos) { //check effects name list bool exists = false; - for( int ii = 0; ii < sizeof(effect_name_list); ii++) { - if (strncmp(name, effects_name_list[ii], strlen(effects_name_list) ) ) { + for( int ii = 0; ii < sizeof(effects_name_list); ii++) { + if (memcmp(name, effects_name_list[ii], strlen(effects_name_list[ii]) ) ) { exists = true; break; } -- cgit v1.2.3 From 9098cb8b28c089d8abe1b2ff7d9010ab5c6d8766 Mon Sep 17 00:00:00 2001 From: Stephen Simpson Date: Thu, 13 Oct 2011 21:23:12 -0500 Subject: Started work on animations --- include/g3dhax.h | 5 ++- kamek_pal.x | 52 +++++++++++++++++++++++++ src/bossMegaGoomba.cpp | 103 ++++++++++++++++++++++++++++++++++++++++--------- src/effects.cpp | 9 +++++ src/effects.h | 8 +++- 5 files changed, 157 insertions(+), 20 deletions(-) diff --git a/include/g3dhax.h b/include/g3dhax.h index ddeb3ee..f2cdd29 100644 --- a/include/g3dhax.h +++ b/include/g3dhax.h @@ -231,6 +231,9 @@ namespace m3d { void sub_80064BF0(); void setDrawMatrix(const Mtx matrix); + void setScale(float x, float y, float z); + void setScale(Vec *scale); + void calcWorld(bool unk); void bindAnim(banm_c *animation, float unk); @@ -309,7 +312,7 @@ namespace m3d { bool setup(nw4r::g3d::ResMdl modelRes, nw4r::g3d::ResAnmTexPat anmRes, mAllocator_c *allocator, u32 *sizeOutPtr, int count); - void bindEntry(/*b*/mdl_c *model, nw4r::g3d::ResAnmTexPat resource, + void bindEntry(/*b*/mdl_c *model, nw4r::g3d::ResAnmTexPat *resource, int entryNumber, int _param4); float getFrameForEntry(int number); diff --git a/kamek_pal.x b/kamek_pal.x index 2a6e3e4..702f857 100644 --- a/kamek_pal.x +++ b/kamek_pal.x @@ -545,6 +545,7 @@ SECTIONS { setScale__Q23m3d5mdl_cFfff = 0x8016A270; setScale__Q23m3d5mdl_cFP7Point3d = 0x8016A290; calcWorld__Q23m3d5mdl_cFb = 0x8016A2E0; + bindAnim__Q23m3d5mdl_cFPQ23m3d6banm_cf = 0x8016a0c0; SetupTextures_Player__FPQ23m3d5mdl_ci = 0x800B3E50; SetupTextures_Map__FPQ23m3d5mdl_ci = 0x800B3F50; @@ -982,6 +983,57 @@ SECTIONS { GetResAnmChr = 0x8023A1F0; GetResAnmTexPat = 0x8023A340; + GetResAnmChr__Q34nw4r3g3d7ResFileCFPCc = 0x8023a1f0; + GetResAnmTexPat__Q34nw4r3g3d7ResFileCFPCc = 0x8023a340; + + __ct__12mAllocator_cFv = 0x8016a720; + __vt__12mAllocator_cFv = 0x80329a04; + __dt__12mAllocator_cFv = 0x8016a770; + + __vt__Q23m3d6banm_c = 0x80329920; + __dt__Q23m3d6banm_cFv = 0x80168000; + detach__Q23m3d6banm_cFv = 0x80168070; + process__Q23m3d6banm_cFv = 0x8002a1f0; + setupHeap__Q23m3d6banm_cFv = 0x801680e0; + testAnmFlag__Q23m3d6banm_cFv = 0x801681a0; + getFrameFromObj__Q23m3d6banm_cFv = 0x801681c0; + setFrameOnObj__Q23m3d6banm_cFv = 0x801681e0; + getUpdateRate__Q23m3d6banm_cFv = 0x80168200; + setUpdateRate__Q23m3d6banm_cFv = 0x80168220; + __ct__Q23m3d6fanm_cFv = 0x80168e50; + __vt__Q23m3d6fanm_c = 0x80329968; + __dt__Q23m3d6fanm_cFv = 0x80168ec0; + process__Q23m3d6fanm_cFv = 0x80168f20; + setFrame__Q23m3d6fanm_cFv = 0x80169120; + isAnimationDone__Q23m3d6fanm_cFv = 0x80169160; + querySomething__Q23m3d6fanm_cFv = 0x80169220; + + /*FIXME not right dtor ?*/ + __vt__Q23m3d8anmChr_c = 0x80303708; + __dt__Q23m3d8anmChr_cFv = 0x800260c0; + vf0C__Q23m3d8anmChr_cFv = 0x8002a210; + setup__Q23m3d8anmChr_cFQ34nw4r3g3d6ResMdlQ34nw4r3g3d9ResAnmChrP12mAllocator_cPUi = 0x80165210; + bind__Q23m3d8anmChr_cFPQ23m3d5mdl_cQ34nw4r3g3d9ResAnmChri = 0x80165330; + internalBind__Q23m3d8anmChr_cFv = 0x801653c0; + + __vt__Q23m3d11anmTexPat_c = 0x80329890; + __dt__Q23m3d11anmTexPat_cFv = 0x80166bb0; + detach__Q23m3d11anmTexPat_cFv = 0x80166c20; + setup__Q23m3d11anmTexPat_cFQ34nw4r3g3d6ResMdlQ34nw4r3g3d12ResAnmTexPatP12mAllocator_cPUii = 0x80166970; + bindEntry__Q23m3d11anmTexPat_cFv = 0x80166d10; + bindEntry__Q23m3d11anmTexPat_cFPQ23m3d5mdl_cPQ34nw4r3g3d12ResAnmTexPatii = 0x80166d10; + process__Q23m3d11anmTexPat_cFv = 0x80166f10; + processOneEntry__Q23m3d11anmTexPat_cFv = 0x80166fc0; + getFrameForEntry__Q23m3d11anmTexPat_cFv = 0x80167020; + setFrameForEntry__Q23m3d11anmTexPat_cFv = 0x80167020; + getUpdateForEntry__Q23m3d11anmTexPat_cFv = 0x80167040; + setUpdateForEntry__Q23m3d11anmTexPat_cFv = 0x80167050; + isEntryAnimationDone__Q23m3d11anmTexPat_cFv = 0x80167060; + queryEntrySomething__Q23m3d11anmTexPat_cFv = 0x80167070; + setEntryByte34__Q23m3d11anmTexPat_cFv = 0x80167080; + getEntryField28__Q23m3d11anmTexPat_cFv = 0x801670a0; + vf0C__Q23m3d11anmTexPat_cFv = 0x801670c0; + m3d__mdl_c__DoStuff = 0x80169ED0; __ashldi3 = 0x802DD4DC; diff --git a/src/bossMegaGoomba.cpp b/src/bossMegaGoomba.cpp index 9817a02..8d4d19a 100644 --- a/src/bossMegaGoomba.cpp +++ b/src/bossMegaGoomba.cpp @@ -11,7 +11,14 @@ class daMegaGoomba_c : public dEn_c { int onDraw(); mHeapAllocator_c allocator; + nw4r::g3d::ResFile resFile; m3d::mdl_c bodyModel; + m3d::anmChr_c animationChr; + nw4r::g3d::ResAnmTexPat resTexPat; + m3d::anmTexPat_c animationPat; + //mAllocator_c allocator2; + //FIXME add this back in ? + //EGG::Effect effect; float timer; float dying; @@ -59,6 +66,7 @@ class daMegaGoomba_c : public dEn_c { void dieFall_Execute(); static daMegaGoomba_c *build(); + void setupBodyModel(); void updateModelMatrices(); // bool preSpriteCollision(ActivePhysics *apThis, ActivePhysics *apOther); @@ -92,9 +100,7 @@ class daMegaGoomba_c : public dEn_c { DECLARE_STATE(Launch); }; -extern "C" void *PlaySound(dStageActor_c *, int soundID); -extern void * HandleXSpeed(daMegaGoomba_c*); -//extern void * HandleYSpeed(daMegaGoomba_c*); +//extern "C" void *PlaySound(dStageActor_c *, int soundID); daMegaGoomba_c *daMegaGoomba_c::build() { void *buffer = AllocFromGameHeap1(sizeof(daMegaGoomba_c)); @@ -102,6 +108,7 @@ daMegaGoomba_c *daMegaGoomba_c::build() { } +//FIXME makes these dEn_c::HandleXSpeed(); extern "C" void *HandleXSpeed(daMegaGoomba_c *); extern "C" void *HandleYSpeed(daMegaGoomba_c *); extern "C" void *UpdateObjectPosBasedOnSpeedValues_real(daMegaGoomba_c *); @@ -189,27 +196,77 @@ void daMegaGoomba_c::dieFall_Execute() { this->dEn_c::dieFall_Execute(); } -int daMegaGoomba_c::onCreate() { +void HexDump(char* address, u32 length) { + length = (length + 0x1f) & ~0x1f; + char line[0x11] = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}; + for(u32 ii=0; ii < length; ii += 0x10) { + for(u32 jj=0; jj < 0x10; jj++) { + line[jj] = address[ii+jj]; + } + OSReport("%08x: %04x %04x %04x %04x %04x %04x %04x %04x |%s|\n", + (u32)(address+ii), + *(u16*)(address+ii+0x00), + *(u16*)(address+ii+0x02), + *(u16*)(address+ii+0x04), + *(u16*)(address+ii+0x06), + *(u16*)(address+ii+0x08), + *(u16*)(address+ii+0x0a), + *(u16*)(address+ii+0x0c), + *(u16*)(address+ii+0x0e), + line); + for(u32 jj=0; jj<0x10; jj++) line[jj] = 0; + } +} - OSReport("Creating the MegaGoomba Model\n"); +void daMegaGoomba_c::setupBodyModel() { + OSReport("Here 0\n"); allocator.link(-1, GameHeaps[0], 0, 0x20); - nw4r::g3d::ResFile rf(getResource("kuribo", "g3d/t02.brres")); - bodyModel.setup(rf.GetResMdl("kuribo"), &allocator, 0x224, 1, 0); + OSReport("Here 1\n"); + this->resFile.data = getResource("kuribo", "g3d/t02.brres"); + nw4r::g3d::ResMdl mdl = this->resFile.GetResMdl("kuribo"); + HexDump((char*)&mdl, 0x10); + bodyModel.setup(mdl, &allocator, 0x224, 1, 0); SetupTextures_Enemy(&bodyModel, 0); + bool ret; + OSReport("Here 2\n"); + nw4r::g3d::ResAnmChr anmChr = this->resFile.GetResAnmChr("walk"); + HexDump((char*)&anmChr, 0x10); + + OSReport("Here 3\n"); + ret = this->animationChr.setup(mdl, anmChr, &this->allocator, 0); + + OSReport("Here 4\n"); + nw4r::g3d::ResAnmTexPat anmPat = this->resFile.GetResAnmTexPat("walk"); + HexDump((char*)&anmPat, 0x10); + + OSReport("Here 5\n"); + this->resTexPat = anmPat; + + OSReport("Here 6\n"); + ret = this->animationPat.setup(mdl, anmPat, &this->allocator, 0, 1); + + OSReport("Here 7\n"); + this->animationPat.bindEntry(&this->bodyModel, &anmPat, 0, 0); + + + OSReport("Here 8\n"); allocator.unlink(); +} - OSReport("Creating MegaGoomba's Physics Struct\n"); +int daMegaGoomba_c::onCreate() { - // Keeping naming + OSReport("Creating MG's body model\n"); + setupBodyModel(); + + OSReport("Creating MegaGoomba's Physics Struct\n"); + //TODO find data for a fun, yet challenging, battle ActivePhysics::Info HitMeBaby; HitMeBaby.xDistToCenter = 0.0; HitMeBaby.yDistToCenter = 18.0; HitMeBaby.xDistToEdge = 24.0; HitMeBaby.yDistToEdge = 24.0; - - //TODO find data for a fun, yet challenging, battle HitMeBaby.category1 = 0x3; HitMeBaby.category2 = 0x0; HitMeBaby.bitfield1 = 0x4f; @@ -217,11 +274,12 @@ int daMegaGoomba_c::onCreate() { HitMeBaby.unkShort1C = 0; HitMeBaby.callback = &dEn_c::collisionCallback; - - OSReport("Making the Physics Class and adding to the list\n"); this->aPhysics.initWithStruct(this, &HitMeBaby); this->aPhysics.addToList(); + //sub_80034060(); + + //FIXME move this stuff elsewhere pos.y -= 16.0; pos.z = 3000.0; rot.x = rot.y = rot.z = speed.x = dying = 0.0; @@ -486,12 +544,21 @@ void daMegaGoomba_c::beginState_Walk() { this->timer = 1.0; this->direction = dSprite_c__getXDirectionOfFurthestPlayerRelativeToVEC3(this, this->pos); //TODO add rot.changing on switching directions until animations added + + // DO SOMETHING COOL // + OSReport("Here11\n"); + nw4r::g3d::ResAnmChr anmChr = this->resFile.GetResAnmChr("walk"); + OSReport("Here12\n"); + this->animationChr.bind(&this->bodyModel, anmChr, 0); + OSReport("Here13\n"); + this->bodyModel.bindAnim(&this->animationChr, 1.0); + OSReport("Here14\n"); } void daMegaGoomba_c::executeState_Walk() { - //HandleAcceleration(); - HandleXSpeed(); - UpdateObjectPosBasedOnSpeedValues_real(); + //HandleAcceleration(this); + HandleXSpeed(this); + UpdateObjectPosBasedOnSpeedValues_real(this); //DoGravityMaybe(); int Choice; @@ -514,9 +581,9 @@ void daMegaGoomba_c::executeState_Walk() { break; //FIXME test case for sound effects case 3: - OSReport("PlaySound(this, %d)\n", this->toPlay); + //OSReport("PlaySound(this, %d)\n", this->toPlay); if(this->timeToPlay) { - PlaySound(this, this->toPlay); + //PlaySound(this, this->toPlay); this->timeToPlay = false; this->toPlay++; if(this->toPlay > 1977) diff --git a/src/effects.cpp b/src/effects.cpp index 40f08a2..3b2d5c7 100644 --- a/src/effects.cpp +++ b/src/effects.cpp @@ -1041,6 +1041,15 @@ bool CreateEffect(const char* name, Vec* pos) { return SpawnEffect(name, 0, pos, 0, 0); } +bool CreateEffect(int effect_num, Vec* pos, S16Vec* rot, Vec* scale) { + if (effect_num > 1000) + return false; + if (effect_num < 0) + return false; + const char* effect_name = effects_name_list[effect_num]; + return SpawnEffect(effect_name, 0, pos, rot, scale); +} + /* void* CustomEffectSpawn(const char* name) { // FILL ME IN diff --git a/src/effects.h b/src/effects.h index ea4ba2a..ceda53f 100644 --- a/src/effects.h +++ b/src/effects.h @@ -4,9 +4,15 @@ #include #include +/* +S16Vec* tRot = &(S16Vec){ 0, 0, 0}; +Vec* tScale = &(Vec){0.0, 0.0, 0.0}; +*/ + bool CreateEffect(dEn_c* enemy, int effect_num); bool CreateEffect(Vec* pos, S16Vec* rot, Vec* scale, int effect_num); -bool CreateEffect(const char* name, Vec* pos); +bool CreateEffect(Vec* pos, S16Vec* rot, Vec* scale, int effect_num); +bool CreateEffect(int effect_num, Vec* pos, S16Vec* rot = 0, Vec* scale = 0); // Actually will return an EGG::Effect instance //void* CustomEffectSpawn(const char* name); -- cgit v1.2.3 From 48713b7a405c95022e85f4cf5ce7c27363815d74 Mon Sep 17 00:00:00 2001 From: Stephen Simpson Date: Fri, 14 Oct 2011 00:33:51 -0500 Subject: Got working anmPat animations. anmChr needs fixing added rotation to MegaGoomba based on direction. added eyes blinking to MegaGoomba. added speed and jump changes based on how many hits MG has taken. --- kamek_pal.x | 8 +-- src/bossMegaGoomba.cpp | 134 +++++++++++++++++-------------------------------- 2 files changed, 51 insertions(+), 91 deletions(-) diff --git a/kamek_pal.x b/kamek_pal.x index 702f857..8030c51 100644 --- a/kamek_pal.x +++ b/kamek_pal.x @@ -1025,12 +1025,12 @@ SECTIONS { process__Q23m3d11anmTexPat_cFv = 0x80166f10; processOneEntry__Q23m3d11anmTexPat_cFv = 0x80166fc0; getFrameForEntry__Q23m3d11anmTexPat_cFv = 0x80167020; - setFrameForEntry__Q23m3d11anmTexPat_cFv = 0x80167020; - getUpdateForEntry__Q23m3d11anmTexPat_cFv = 0x80167040; - setUpdateForEntry__Q23m3d11anmTexPat_cFv = 0x80167050; + setFrameForEntry__Q23m3d11anmTexPat_cFfi = 0x80167020; + getUpdateRateForEntry__Q23m3d11anmTexPat_cFv = 0x80167040; + setUpdateRateForEntry__Q23m3d11anmTexPat_cFfi = 0x80167050; isEntryAnimationDone__Q23m3d11anmTexPat_cFv = 0x80167060; queryEntrySomething__Q23m3d11anmTexPat_cFv = 0x80167070; - setEntryByte34__Q23m3d11anmTexPat_cFv = 0x80167080; + setEntryByte34__Q23m3d11anmTexPat_cFUci = 0x80167080; getEntryField28__Q23m3d11anmTexPat_cFv = 0x801670a0; vf0C__Q23m3d11anmTexPat_cFv = 0x801670c0; diff --git a/src/bossMegaGoomba.cpp b/src/bossMegaGoomba.cpp index 8d4d19a..e836afb 100644 --- a/src/bossMegaGoomba.cpp +++ b/src/bossMegaGoomba.cpp @@ -1,6 +1,7 @@ #include #include #include +#include #include "player.h" @@ -27,8 +28,6 @@ class daMegaGoomba_c : public dEn_c { unsigned int Xkey_count; HermiteKey keysY[0x10]; unsigned int Ykey_count; -// HermiteKey keysZ[0x10]; -// unsigned int Zkey_count; char life; @@ -39,27 +38,10 @@ class daMegaGoomba_c : public dEn_c { u32 marker2_start; int pickedChoice; u32 marker2_end; - u32 marker3_start; float XSpeed; - u32 marker3_end; - u32 marker4_start; float JumpHeight; - u32 marker4_end; - u32 marker5_start; float JumpDist; - u32 marker5_end; - u32 marker6_start; float JumpTime; - u32 marker6_end; - u32 marker7_start; - int playIt; - u32 marker7_end; - u32 marker8_start; - int toPlay; - u32 marker8_end; - u32 marker9_start; - bool timeToPlay; - u32 marker9_end; bool takeHit(char count); @@ -100,14 +82,14 @@ class daMegaGoomba_c : public dEn_c { DECLARE_STATE(Launch); }; -//extern "C" void *PlaySound(dStageActor_c *, int soundID); - daMegaGoomba_c *daMegaGoomba_c::build() { void *buffer = AllocFromGameHeap1(sizeof(daMegaGoomba_c)); return new(buffer) daMegaGoomba_c; } +extern "C" void *PlaySound(daMegaGoomba_c *, int soundID); + //FIXME makes these dEn_c::HandleXSpeed(); extern "C" void *HandleXSpeed(daMegaGoomba_c *); extern "C" void *HandleYSpeed(daMegaGoomba_c *); @@ -133,6 +115,10 @@ bool daMegaGoomba_c::takeHit(char count) { c = 127 - l; } this->life -= c; + this->XSpeed += 0.25; + this->JumpHeight += 12.0; + this->JumpDist += 12.0; + this->JumpTime += 5.0; doStateChange(&StateID_Shrink); setNewActivePhysicsRect(this, &this->scale); return (life <= 0) ? true : false; @@ -219,39 +205,25 @@ void HexDump(char* address, u32 length) { } void daMegaGoomba_c::setupBodyModel() { - OSReport("Here 0\n"); allocator.link(-1, GameHeaps[0], 0, 0x20); - OSReport("Here 1\n"); this->resFile.data = getResource("kuribo", "g3d/t02.brres"); nw4r::g3d::ResMdl mdl = this->resFile.GetResMdl("kuribo"); - HexDump((char*)&mdl, 0x10); bodyModel.setup(mdl, &allocator, 0x224, 1, 0); SetupTextures_Enemy(&bodyModel, 0); bool ret; - OSReport("Here 2\n"); nw4r::g3d::ResAnmChr anmChr = this->resFile.GetResAnmChr("walk"); - HexDump((char*)&anmChr, 0x10); - - OSReport("Here 3\n"); ret = this->animationChr.setup(mdl, anmChr, &this->allocator, 0); - OSReport("Here 4\n"); nw4r::g3d::ResAnmTexPat anmPat = this->resFile.GetResAnmTexPat("walk"); - HexDump((char*)&anmPat, 0x10); - - OSReport("Here 5\n"); this->resTexPat = anmPat; - - OSReport("Here 6\n"); ret = this->animationPat.setup(mdl, anmPat, &this->allocator, 0, 1); - - OSReport("Here 7\n"); this->animationPat.bindEntry(&this->bodyModel, &anmPat, 0, 0); + this->bodyModel.bindAnim(&this->animationPat, 1.0); + this->animationPat.setFrameForEntry(1.0, 0); - OSReport("Here 8\n"); allocator.unlink(); } @@ -282,7 +254,9 @@ int daMegaGoomba_c::onCreate() { //FIXME move this stuff elsewhere pos.y -= 16.0; pos.z = 3000.0; - rot.x = rot.y = rot.z = speed.x = dying = 0.0; + speed.x = dying = 0.0; + rot.x = rot.z = 0; + rot.y = 0x2000; // 0x2000 is left. 0xe000 is for right. direction = 0; life = 3; //TODO 1) allow setting bounding rect with settings @@ -297,28 +271,13 @@ int daMegaGoomba_c::onCreate() { this->marker1_end = 0xaabbff11; this->marker2_start = 0xaabbcc12; this->marker2_end = 0xaabbff12; - this->marker3_start = 0xaabbcc13; - this->marker3_end = 0xaabbff13; - this->marker4_start = 0xaabbcc14; - this->marker4_end = 0xaabbff14; - this->marker5_start = 0xaabbcc15; - this->marker5_end = 0xaabbff15; - this->marker6_start = 0xaabbcc16; - this->marker6_end = 0xaabbff16; - this->marker7_start = 0xaabbcc17; - this->marker7_end = 0xaabbff17; - this->marker8_start = 0xaabbcc18; - this->marker8_end = 0xaabbff18; - this->marker9_start = 0xaabbcc19; - this->marker9_end = 0xaabbff19; + this->pickedChoice = -1; - this->XSpeed = 2.0; // GOOD FOR FINAL SPEED? + // 2.0 is good final speed + this->XSpeed = 1.5; this->JumpHeight = 48.0; this->JumpDist = 64.0; this->JumpTime = 50.0; - this->playIt = 0; - this->toPlay = 0; - this->timeToPlay = false; OSReport("Setting MegaGoomba's State\n"); doStateChange(&StateID_Grow); @@ -350,6 +309,8 @@ int daMegaGoomba_c::onExecute() { int daMegaGoomba_c::onDraw() { bodyModel.scheduleForDrawing(); + animationChr.process(); + animationPat.process(); return true; } @@ -360,10 +321,12 @@ void daMegaGoomba_c::updateModelMatrices() { if(this->life > 0) { if(this->pos.x < this->Bounding.left) { this->direction = !this->direction; + rot.y = (this->direction) ? 0xe000 : 0x2000; this->speed.x = -this->speed.x; this->pos.x = this->Bounding.left; } else if (this->pos.x > this->Bounding.right) { this->direction = !this->direction; + rot.y = (this->direction) ? 0xe000 : 0x2000; this->speed.x = -this->speed.x; this->pos.x = this->Bounding.right; } @@ -416,9 +379,8 @@ void daMegaGoomba_c::executeState_Grow() { setNewActivePhysicsRect(this, &this->scale); } - //TODO grow sound - //if(this->timer == 60.0) - // PlaySound(this, SE_GROW); + if(this->timer == 60.0) + PlaySound(this, SE_EMY_KURI_CHANGE_BIG); if (this->timer > 170.0) { doStateChange(&StateID_Walk); } @@ -442,9 +404,8 @@ void daMegaGoomba_c::executeState_Shrink() { this->scale = (Vec){modifier, modifier, modifier}; setNewActivePhysicsRect(this, &this->scale); - //TODO shrink sound - //if(this->timer == 2.0) - // PlaySound(this, SE_SHRINK); + if(this->timer == 2.0) + PlaySound(this, SE_EMY_KURIBO_L_DAMAGE_02); if (this->timer > 60.0) { doStateChange(&StateID_Walk); } } @@ -496,7 +457,7 @@ void daMegaGoomba_c::executeState_Launch() { this->timer = this->timer + 1.0; } void daMegaGoomba_c::endState_Launch() { - this->rot.y = 0; + rot.y = (this->direction) ? 0xe000 : 0x2000; } // Jump State @@ -543,23 +504,36 @@ void daMegaGoomba_c::endState_Jump() { } void daMegaGoomba_c::beginState_Walk() { this->timer = 1.0; this->direction = dSprite_c__getXDirectionOfFurthestPlayerRelativeToVEC3(this, this->pos); - //TODO add rot.changing on switching directions until animations added + rot.y = (this->direction) ? 0xe000 : 0x2000; - // DO SOMETHING COOL // - OSReport("Here11\n"); + //SETUP WALK ANIMATION// nw4r::g3d::ResAnmChr anmChr = this->resFile.GetResAnmChr("walk"); - OSReport("Here12\n"); this->animationChr.bind(&this->bodyModel, anmChr, 0); - OSReport("Here13\n"); - this->bodyModel.bindAnim(&this->animationChr, 1.0); - OSReport("Here14\n"); + this->bodyModel.bindAnim(&this->animationChr, 2.0); + /*this->animationChr._setUpdateRate(2.0); FIXME*/ + this->bodyModel.bindAnim(&this->animationPat, 0.0); + this->animationPat.setUpdateRateForEntry(1.0, 0); + this->animationPat.setEntryByte34(0, 0); + float num = (float)GenerateRandomNumber(0xB4); + this->animationPat.setFrameForEntry(num, 0); } void daMegaGoomba_c::executeState_Walk() { + /* + nw4r::g3d::ResMdl mdl* = this->bodyModel.GetResMdl(); + ResNode resNode = mdl->GetResNode("leg_left"); + resNode._C; + mMtx mtx; + this->bodyModel.GetSomeMatrix(resNode._C, &mtx); + Vec vctr; + ConvertMatrixToTranslationVector(&mtx, &vctr); + */ //HandleAcceleration(this); - HandleXSpeed(this); - UpdateObjectPosBasedOnSpeedValues_real(this); + //HandleXSpeed(this); + //UpdateObjectPosBasedOnSpeedValues_real(this); //DoGravityMaybe(); + float delta = (this->direction) ? -this->XSpeed : this->XSpeed; + this->pos.x += delta; int Choice; float TimerMax = 150.0; @@ -577,23 +551,9 @@ void daMegaGoomba_c::executeState_Walk() { case 1: doStateChange(&StateID_Launch); break; - case 2: - break; - //FIXME test case for sound effects - case 3: - //OSReport("PlaySound(this, %d)\n", this->toPlay); - if(this->timeToPlay) { - //PlaySound(this, this->toPlay); - this->timeToPlay = false; - this->toPlay++; - if(this->toPlay > 1977) - this->toPlay = 0; - } else { - this->timeToPlay = true; - } - break; default: this->direction = dSprite_c__getXDirectionOfFurthestPlayerRelativeToVEC3(this, pos); + rot.y = (this->direction) ? 0xe000 : 0x2000; this->timer = 0; break; }; -- cgit v1.2.3