diff options
-rwxr-xr-x | include/game.h | 4 | ||||
-rw-r--r-- | kamek_pal.x | 3 | ||||
-rw-r--r-- | src/apDebug.cpp | 68 | ||||
-rw-r--r-- | src/bossMegaGoomba.cpp | 66 | ||||
-rw-r--r-- | src/koopatlas/core.cpp | 6 | ||||
-rw-r--r-- | src/koopatlas/mapmusic.cpp | 51 | ||||
-rw-r--r-- | src/koopatlas/mapmusic.h | 1 | ||||
-rw-r--r-- | tilesetfixer.yaml | 5 |
8 files changed, 159 insertions, 45 deletions
diff --git a/include/game.h b/include/game.h index 403d1b3..780b76c 100755 --- a/include/game.h +++ b/include/game.h @@ -2057,6 +2057,7 @@ public: static fBase_c *search(Actors name, fBase_c *previous = 0);
static fBase_c *search(u32 id);
+ static fBase_c *searchByBaseType(int type, fBase_c *previous);
};
class dBase_c : public fBase_c {
@@ -3582,5 +3583,8 @@ namespace nw4r { }
}
+
+extern float EnemyBounceValue;
+
#endif
diff --git a/kamek_pal.x b/kamek_pal.x index 6300912..5fcb316 100644 --- a/kamek_pal.x +++ b/kamek_pal.x @@ -1,8 +1,11 @@ SECTIONS { + EnemyBounceValue = 0x8042A5F0; + /* Scrolling is annoying, clown car goes here! */ search__7fBase_cFUi = 0x80162E40; search__7fBase_cF6ActorsP7fBase_c = 0x80162E90; + searchByBaseType__7fBase_cFiP7fBase_c = 0x80162EF0; AddStockPowerup = 0x800BB330; continueFromStrongBox2 = 0x808AAFD0; diff --git a/src/apDebug.cpp b/src/apDebug.cpp index f485474..ee31c28 100644 --- a/src/apDebug.cpp +++ b/src/apDebug.cpp @@ -241,4 +241,72 @@ void APDebugDrawer::drawXlu() { p = p->next; } + + + // Now, the hardest one.. CollisionMgr_c! + fBase_c *fb = 0; + while ((fb = fBase_c::searchByBaseType(2, fb))) { + u8 *testMe = ((u8*)fb) + 0x1EC; + if (*((u32*)testMe) != 0x8030F6D0) + continue; + + u32 uptr = (u32)fb; + u8 r = u8((uptr>>16)&0xFF)+0x20; + u8 g = u8((uptr>>8)&0xFF)-0x30; + u8 b = u8(uptr&0xFF)+0x80; + u8 a = 0xFF; + + dStageActor_c *ac = (dStageActor_c*)fb; + + sensorBase_s *sensors[4] = { + ac->collMgr.pBelowInfo, ac->collMgr.pAboveInfo, + ac->collMgr.pAdjacentInfo, ac->collMgr.pAdjacentInfo}; + + for (int i = 0; i < 4; i++) { + sensorBase_s *s = sensors[i]; + if (!s) + continue; + + float mult = (i == 3) ? -1.0f : 1.0f; + + switch (s->flags & SENSOR_TYPE_MASK) { + case SENSOR_POINT: + GXBegin(GX_POINTS, GX_VTXFMT0, 1); + GXPosition3f32( + ac->pos.x + (mult * (s->asPoint()->x / 4096.0f)), + ac->pos.y + (s->asPoint()->y / 4096.0f), + 8005.0f); + GXColor4u8(r,g,b,a); + GXEnd(); + break; + case SENSOR_LINE: + GXBegin(GX_LINES, GX_VTXFMT0, 2); + if (i < 2) { + GXPosition3f32( + ac->pos.x + (s->asLine()->lineA / 4096.0f), + ac->pos.y + (s->asLine()->distanceFromCenter / 4096.0f), + 8005.0f); + GXColor4u8(r,g,b,a); + GXPosition3f32( + ac->pos.x + (s->asLine()->lineB / 4096.0f), + ac->pos.y + (s->asLine()->distanceFromCenter / 4096.0f), + 8005.0f); + GXColor4u8(r,g,b,a); + } else { + GXPosition3f32( + ac->pos.x + (mult * (s->asLine()->distanceFromCenter / 4096.0f)), + ac->pos.y + (s->asLine()->lineA / 4096.0f), + 8005.0f); + GXColor4u8(r,g,b,a); + GXPosition3f32( + ac->pos.x + (mult * (s->asLine()->distanceFromCenter / 4096.0f)), + ac->pos.y + (s->asLine()->lineB / 4096.0f), + 8005.0f); + GXColor4u8(r,g,b,a); + } + GXEnd(); + break; + } + } + } } diff --git a/src/bossMegaGoomba.cpp b/src/bossMegaGoomba.cpp index e67caac..c2ef1c7 100644 --- a/src/bossMegaGoomba.cpp +++ b/src/bossMegaGoomba.cpp @@ -28,7 +28,7 @@ class daMegaGoomba_c : public dEn_c { float dying; lineSensor_s belowSensor; - pointSensor_s adjacentSensor; + lineSensor_s adjacentSensor; ActivePhysics leftTrapAPhysics, rightTrapAPhysics; ActivePhysics stalkAPhysics; @@ -65,6 +65,8 @@ class daMegaGoomba_c : public dEn_c { void stunPlayers(); void unstunPlayers(); + bool hackOfTheCentury; + bool playerStunned[4]; void removeMyActivePhysics(); @@ -128,38 +130,39 @@ void setNewActivePhysicsRect(daMegaGoomba_c *actor, Vec *scale) { actor->belowSensor.flags = SENSOR_LINE; actor->belowSensor.lineA = s32((amtX * -28.0f) * 4096.0f); actor->belowSensor.lineB = s32((amtX * 28.0f) * 4096.0f); - actor->belowSensor.distanceFromCenter = s32((amtY * 4) * 4096.0f); + actor->belowSensor.distanceFromCenter = 0; - actor->adjacentSensor.flags = SENSOR_POINT; - actor->adjacentSensor.x = s32((amtX * 32.0f) * 4096.0f); - actor->adjacentSensor.y = s32((amtY * 22.0f) * 4096.0f); + actor->adjacentSensor.flags = SENSOR_LINE; + actor->adjacentSensor.lineA = s32((amtY * 4.0f) * 4096.0f); + actor->adjacentSensor.lineB = s32((amtY * 32.0f) * 4096.0f); + actor->adjacentSensor.distanceFromCenter = s32((amtX * 46.0f) * 4096.0f); u8 cat1 = 3, cat2 = 0, bitfield1 = 0x6f, bitfield2 = 0xffbafffe; ActivePhysics::Info info = { - 0.0f, amtY*57.0f, amtX*14.0f, amtY*31.0f, + 0.0f, amtY*57.0f, amtX*20.0f, amtY*31.0f, cat1, cat2, bitfield1, bitfield2, 0, &dEn_c::collisionCallback}; actor->aPhysics.initWithStruct(actor, &info); // Original trapezium was -12,12 to -48,48 ActivePhysics::Info left = { - amtX*-28.0f, amtY*56.0f, amtX*14.0f, amtY*31.0f, + amtX*-32.0f, amtY*55.0f, amtX*12.0f, amtY*30.0f, cat1, cat2, bitfield1, bitfield2, 0, &dEn_c::collisionCallback}; actor->leftTrapAPhysics.initWithStruct(actor, &left); - actor->leftTrapAPhysics.trpValue0 = amtX * 14.0f; - actor->leftTrapAPhysics.trpValue1 = amtX * 14.0f; - actor->leftTrapAPhysics.trpValue2 = amtX * -14.0f; - actor->leftTrapAPhysics.trpValue3 = amtX * 14.0f; + actor->leftTrapAPhysics.trpValue0 = amtX * 12.0f; + actor->leftTrapAPhysics.trpValue1 = amtX * 12.0f; + actor->leftTrapAPhysics.trpValue2 = amtX * -12.0f; + actor->leftTrapAPhysics.trpValue3 = amtX * 12.0f; actor->leftTrapAPhysics.collisionCheckType = 3; ActivePhysics::Info right = { - amtX*28.0f, amtY*56.0f, amtX*14.0f, amtY*31.0f, + amtX*32.0f, amtY*55.0f, amtX*12.0f, amtY*30.0f, cat1, cat2, bitfield1, bitfield2, 0, &dEn_c::collisionCallback}; actor->rightTrapAPhysics.initWithStruct(actor, &right); - actor->rightTrapAPhysics.trpValue0 = amtX * -14.0f; - actor->rightTrapAPhysics.trpValue1 = amtX * -14.0f; - actor->rightTrapAPhysics.trpValue2 = amtX * -14.0f; - actor->rightTrapAPhysics.trpValue3 = amtX * 14.0f; + actor->rightTrapAPhysics.trpValue0 = amtX * -12.0f; + actor->rightTrapAPhysics.trpValue1 = amtX * -12.0f; + actor->rightTrapAPhysics.trpValue2 = amtX * -12.0f; + actor->rightTrapAPhysics.trpValue3 = amtX * 12.0f; actor->rightTrapAPhysics.collisionCheckType = 3; ActivePhysics::Info stalk = { @@ -245,7 +248,13 @@ void daMegaGoomba_c::playerCollision(ActivePhysics *apThis, ActivePhysics *apOth //unk=0 does _vfs, unk=1 does playSeCmnStep //char ret = usedForDeterminingStatePress_or_playerCollision(this, apThis, apOther, 0); + float saveBounce = EnemyBounceValue; + EnemyBounceValue = 5.2f; + char ret = usedForDeterminingStatePress_or_playerCollision(this, apThis, apOther, 2); + + EnemyBounceValue = saveBounce; + if(ret == 1) { // regular jump apOther->someFlagByte |= 2; if(this->takeHit(1)) { @@ -349,13 +358,6 @@ void daMegaGoomba_c::setupCollision() { this->pos_delta2.y = 16.0; this->pos_delta2.z = 0.0; - this->spriteSomeRectX = 32.0; - this->spriteSomeRectY = 32.0; - this->_320 = 0.0; - this->_324 = 16.0; - this->_328 = 80.0; - this->_32C = 256.0; - this->pos.z = (foo == 0) ? 1500.0 : -2500.0; this->_518 = 2; @@ -419,7 +421,11 @@ int daMegaGoomba_c::onDelete() { int daMegaGoomba_c::onExecute() { //80033450 acState.execute(); - checkZoneBoundaries(0); + if (!hackOfTheCentury) { + hackOfTheCentury = true; + } else { + checkZoneBoundaries(0); + } updateModelMatrices(); return true; @@ -524,7 +530,9 @@ void daMegaGoomba_c::endState_Turn() { // Walk State void daMegaGoomba_c::beginState_Walk() { //inline this piece of code - this->direction = dSprite_c__getXDirectionOfFurthestPlayerRelativeToVEC3(this, this->pos); + //YOU SUCK, WHOEVER ADDED THIS LINE OF CODE AND MADE ME SPEND AGES + //HUNTING DOWN WHAT WAS BREAKING TURNING. -Treeki + //this->direction = dSprite_c__getXDirectionOfFurthestPlayerRelativeToVEC3(this, this->pos); this->speed.x = this->speed.z = 0.0; this->max_speed.x = (this->direction) ? -this->XSpeed : this->XSpeed; this->speed.y = -4.0; @@ -549,10 +557,10 @@ void daMegaGoomba_c::executeState_Walk() { this->doStateChange(&StateID_Turn); //this->acState.setField10ToOne(); } - u32 bitfield2 = this->collMgr.adjacentTileProps[this->direction]; + /*u32 bitfield2 = this->collMgr.adjacentTileProps[this->direction]; if(bitfield2) { this->doStateChange(&StateID_Turn); - } + }*/ DoStuffAndMarkDead(this, this->pos, 1.0); @@ -632,7 +640,9 @@ void daMegaGoomba_c::dieOther_End() { void daMegaGoomba_c::dieOther_Execute() { bodyModel._vf1C(); - if (counter_500 == 0) + if (counter_500 == 0) { + SpawnEffect("Wm_ob_icebreaksmk", 0, &pos, &(S16Vec){0,0,0}, &(Vec){5.0f, 5.0f, 5.0f}); Delete(1); + } } diff --git a/src/koopatlas/core.cpp b/src/koopatlas/core.cpp index 03b8dae..71122e5 100644 --- a/src/koopatlas/core.cpp +++ b/src/koopatlas/core.cpp @@ -47,6 +47,7 @@ dScKoopatlas_c *dScKoopatlas_c::build() { } bool WMInit_StartLoading(void*); +bool WMInit_LoadStaticFiles(void*); bool StockWMInit_LoadEffects(void*); bool WMInit_LoadSIAnims(void*); bool WMInit_EndLoading(void*); @@ -58,6 +59,7 @@ bool WMInit_SetupWipe(void*); ChainedFunc initFunctions[] = { WMInit_StartLoading, + WMInit_LoadStaticFiles, StockWMInit_LoadEffects, WMInit_LoadSIAnims, WMInit_EndLoading, @@ -135,6 +137,10 @@ bool WMInit_StartLoading(void *ptr) { return true; } +bool WMInit_LoadStaticFiles(void *ptr) { + return dKPMusic::loadInfo(); +} + bool WMInit_LoadSIAnims(void *ptr) { SpammyReport("WMInit_LoadSIAnims called\n"); diff --git a/src/koopatlas/mapmusic.cpp b/src/koopatlas/mapmusic.cpp index 1ccd775..8890df5 100644 --- a/src/koopatlas/mapmusic.cpp +++ b/src/koopatlas/mapmusic.cpp @@ -13,7 +13,6 @@ static int s_countdownToSwitch = -1; static int s_countdownToFadeIn = -1; static dDvdLoader_c s_adpcmInfoLoader; -static bool s_adpcmInfoLoaded = false; #define FADE_OUT_LEN 30 #define FADE_IN_LEN 30 @@ -25,15 +24,20 @@ void dKPMusic::play(int id) { if (s_playing) { // Switch track OSReport("Trying to switch to song %d (Current one is %d)...\n", id, s_song); - if (s_song == id || s_nextSong == id) - return; - if (s_countdownToSwitch >= 0 || s_countdownToFadeIn >= 0) - return; - OSReport("Will switch; Fading out current track 2 over %d frames\n", FADE_OUT_LEN); - - s_handle.SetTrackVolume(1<<1, FADE_OUT_LEN, 0.0f); - s_nextSong = id; - s_countdownToSwitch = FADE_OUT_LEN; + if (s_song == id || s_nextSong == id) { + OSReport("This song is already playing or is scheduled. Not gonna do that.\n"); + } else if (s_countdownToFadeIn >= 0) { + OSReport("There's already a track being faded in (CountdownToFadeIn=%d)\n", s_countdownToFadeIn); + } else if (s_countdownToSwitch >= 0) { + OSReport("We were already going to switch tracks, but the rstm hasn't been changed yet, so the next song is being changed to this one\n"); + s_nextSong = id; + } else { + OSReport("Will switch; Fading out current track 2 over %d frames\n", FADE_OUT_LEN); + + s_handle.SetTrackVolume(1<<1, FADE_OUT_LEN, 0.0f); + s_nextSong = id; + s_countdownToSwitch = FADE_OUT_LEN; + } } else { // New track @@ -59,22 +63,24 @@ extern "C" void DVDCancel(void *crap); extern "C" void AxVoice_SetADPCM(void *axVoice, void *adpcm); extern "C" void Voice_SetADPCMLoop(void *voice, int channel, void *adpcmLoop); -void dKPMusic::execute() { - if (!s_adpcmInfoLoaded) { - if (s_adpcmInfoLoader.load("/NewerRes/MapADPCMInfo.bin")) - s_adpcmInfoLoaded = true; - } +bool dKPMusic::loadInfo() { + return s_adpcmInfoLoader.load("/NewerRes/MapADPCMInfo.bin"); +} +void dKPMusic::execute() { if (!s_playing) return; + if (s_handle.GetSound() == 0) { + OSReport("SOUND IS NOT PLAYING!\n"); + return; + } + if (s_countdownToSwitch >= 0) { s_countdownToSwitch--; if (s_countdownToSwitch == 0) { OSReport("Switching brstm files to song %d.\n", s_nextSong); - s_countdownToFadeIn = BUFFER_CLEAR_DELAY; - char brstmPath[48]; sprintf(brstmPath, "/Sound/new/map%d.er", s_nextSong); @@ -83,7 +89,18 @@ void dKPMusic::execute() { u8 **fileStreamPointer = (u8**)(player+0x808); u8 *fileStream = *fileStreamPointer; DVDHandle *fileInfo = (DVDHandle*)(fileStream+0x28); + + if (fileInfo->unk4 == 1) { + OSReport("Was reading chunk, will try again next frame...\n"); + s_countdownToSwitch++; + return; + } + + if (s_nextSong > 0) + s_countdownToFadeIn = BUFFER_CLEAR_DELAY; + DVDCancel(fileInfo); + //OSReport("CANCEL successfully called!\n"); bool result = DVDFastOpen(DVDConvertPathToEntrynum(brstmPath), fileInfo); OSReport("StrmSound is at %p, StrmPlayer is at %p, FileStream pointer is at %p, FileStream is at %p, FileInfo is at %p\n", sound, player, fileStreamPointer, fileStream, fileInfo); diff --git a/src/koopatlas/mapmusic.h b/src/koopatlas/mapmusic.h index 785f870..e5d69f2 100644 --- a/src/koopatlas/mapmusic.h +++ b/src/koopatlas/mapmusic.h @@ -3,6 +3,7 @@ class dKPMusic { public: + static bool loadInfo(); static void play(int id); static void execute(); static void stop(); diff --git a/tilesetfixer.yaml b/tilesetfixer.yaml index e3850dd..a18838b 100644 --- a/tilesetfixer.yaml +++ b/tilesetfixer.yaml @@ -6,4 +6,9 @@ hooks: branch_type: bl src_addr_pal: 0x80081718 target_func: 'TilesetFixerHack(void *, void *, int, int)' + - name: TilesetFixHack2 + type: branch_insn + branch_type: bl + src_addr_pal: 0x800817C4 + target_func: 'TilesetFixerHack(void *, void *, int, int)' |