Skip to content

Commit

Permalink
ExtendedTamakoro Progress
Browse files Browse the repository at this point in the history
  • Loading branch information
Evanbowl committed Nov 8, 2024
1 parent cacfee5 commit eec0618
Show file tree
Hide file tree
Showing 2 changed files with 125 additions and 44 deletions.
23 changes: 21 additions & 2 deletions PTD/Tamakoro2/include/Game/MapObj/ExtTamakoro.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,9 @@ class TamakoroExt : public Tamakoro {
s32 mItemType;
s32 mMusicNum;
s32 mModelId;
f32 mBallColor;
s32 mBvaFrame;
f32 mBrkFrame;
bool mIsBind;
};

struct StageInstrumentEntry {
Expand Down Expand Up @@ -46,4 +48,21 @@ class RedCoin;
namespace RedCoinUtil {
extern RedCoin* tryLinkToChildRedCoin(LiveActor* pSourceActor, const JMapInfoIter& rIter);
extern bool tryAppearLinkedRedCoin(LiveActor* pSourceActor, const TVec3f& pPosition);
}
}

namespace BlueCoinUtil {
extern bool tryCreateBlueCoinForSpawningActorActionKeeper(LiveActor* pSourceActor, s32 id);
extern void appearBlueCoinActionKeeper(LiveActor* pSourceActor);
};

//TamakoroBgmParamEntry gTamakoroBgmParamTable[] = {
// {"BGM_TAMAKORO", 0x6B, 0x1E, 0x1E, 134.0f, 73.700005f, 163.48001f, 198.052f, 0, 0, 2.996985f, 0xE, 0xFFFFFFFF},
// {"BGM_TAMAKORO_2", 0xCA, 0x1E, 0xF, 84.0f, 80.0f, 92.0f, 112.0f, 0, 0, 4.99685f, 0xE, 0xF}
//};

TamakoroBgmParamEntry gTamakoroBgmParamTable[] = {
{"BGM_TAMAKORO", 0x6B, 0x1E, 0x1E, 134.0f, 73.700005f, 163.48001f, 198.052f, 0, 0, 2.996985f, 0xE, 0xFFFFFFFF},
{"BGM_TAMAKORO_2", 0xCA, 0x1E, 0xF, 84.0f, 80.0f, 92.0f, 112.0f, 0, 0, 4.99685f, 0xE, 0xF},
{"BGM_SMG_TAMAKORO", 0x6B, 0x1E, 0x1E, 134.0f, 73.700005f, 163.48001f, 198.052f, 0, 0, 2.996985f, 0xE, 0xFFFFFFFF},
{"BGM_SMG_TAMAKORO_2", 0xCA, 0x1E, 0xF, 84.0f, 80.0f, 92.0f, 112.0f, 0, 0, 4.99685f, 0xE, 0xF}
};
146 changes: 104 additions & 42 deletions PTD/Tamakoro2/source/ExtTamakoro.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@ TamakoroExt::TamakoroExt(const char* pName) : Tamakoro(pName) {
mItemType = -1;
mMusicNum = -1;
mModelId = -1;
mBallColor = 0.0f;
mBvaFrame = -1.0f;
mBrkFrame = -1.0f;
mIsBind = false;
}

TamakoroExt::~TamakoroExt() {}
Expand All @@ -19,32 +21,27 @@ kmWrite32(0x8033C8C8, 0x48000014); // b 0x10

void TamakoroDeclarePowerStar(const JMapInfoIter& rIter, TamakoroExt* pTamakoro) {
MR::getJMapInfoArg0NoInit(rIter, &pTamakoro->mItemType);
MR::getJMapInfoArg1NoInit(rIter, &pTamakoro->mBallColor);
MR::getJMapInfoArg2NoInit(rIter, &pTamakoro->mMusicNum);
MR::getJMapInfoArg1NoInit(rIter, &pTamakoro->mBrkFrame);
MR::getJMapInfoArg2NoInit(rIter, &pTamakoro->mBvaFrame);
MR::getJMapInfoArg3NoInit(rIter, &pTamakoro->mMusicNum);
MR::getJMapInfoArg7NoInit(rIter, &pTamakoro->mModelId);

if (pTamakoro->mMusicNum == -1 && MR::isEqualStageName("TamakoroSliderGalaxy"))
pTamakoro->mMusicNum = 0;

if (pTamakoro->mItemType == 0) {
pTamakoro->mIsPurpleCoin = true;
}

if (pTamakoro->mItemType == -1) {
MR::declarePowerStar(pTamakoro);
}
}

kmWrite32(0x804444BC, 0x7F64DB78); // mr r4, r27
kmCall(0x804444C0, TamakoroDeclarePowerStar);
kmWrite32(0x804444C4, 0x48000014); // b 0x14

void TamakoroCreateDummyModel(TamakoroExt* pTamakoro, const JMapInfoIter& rIter) {
MR::startBva(pTamakoro, "Tamakoro");
if (pTamakoro->mBvaFrame != -2)
MR::startBva(pTamakoro, "Tamakoro");

MR::startBrk(pTamakoro, "Color");

if (pTamakoro->mModelId != -1) {
DummyDisplayModel* pModel = MR::createDummyDisplayModel(pTamakoro, rIter, -1, pTamakoro->mTranslation, TVec3f(0.0f, 0.0f, 0.0f));
DummyDisplayModel* pModel = MR::createDummyDisplayModelCrystalItem(pTamakoro, rIter, pTamakoro->mTranslation, TVec3f(0.0f, 0.0f, 0.0f));

if (pModel) {
pModel->initFixedPosition((MtxPtr)pTamakoro->getBaseMtx(), TVec3f(0.0f, 0.0f, 0.0f), TVec3f(0.0f, 0.0f, 0.0f));
Expand All @@ -53,39 +50,59 @@ void TamakoroCreateDummyModel(TamakoroExt* pTamakoro, const JMapInfoIter& rIter)
}
}

#ifdef REDCOINSYSTEM
if (pTamakoro->mModelId == 24) {
RedCoin* pCoin = RedCoinUtil::tryLinkToChildRedCoin(pTamakoro, rIter);
switch (pTamakoro->mItemType) {
case -1:
MR::declarePowerStar(pTamakoro);
break;
case 0:
pTamakoro->mIsPurpleCoin = true;
break;
case 1:
MR::declareCoin(pTamakoro, 1);
break;
case 2:
MR::declareStarPiece(pTamakoro, 6);

if (pTamakoro->mDummyDisplayModel) {
MR::setScale(pTamakoro->mDummyDisplayModel, 0.75f);
}
break;
case 3:
RedCoinUtil::tryLinkToChildRedCoin(pTamakoro, rIter);
break;
case 4:
BlueCoinUtil::tryCreateBlueCoinForSpawningActorActionKeeper(pTamakoro, pTamakoro->mDummyDisplayModel->_A8);
break;
}
#endif
}

kmWrite32(0x8044458C, 0x7F84E378); // mr r4, r28
kmCall(0x80444590, TamakoroCreateDummyModel); // bl TamakoroCreateDummyModel


void TamakoroPurpleCoinSetBrkFrame(TamakoroExt* pTamakoro) {
if (pTamakoro->mBallColor == -1.0f)
if (pTamakoro->mBrkFrame == -1.0f)
MR::setBrkFrameAndStop(pTamakoro, 1.0f);
else
MR::setBrkFrameAndStop(pTamakoro, pTamakoro->mBallColor);
MR::setBrkFrameAndStop(pTamakoro, pTamakoro->mBrkFrame);
}

kmCall(0x804445DC, TamakoroPurpleCoinSetBrkFrame);

void TamakoroDetermineAnimFrame(TamakoroExt* pTamakoro, const JMapInfoIter& rIter) {
if (pTamakoro->mBvaFrame != -2) {
if (pTamakoro->mItemType == -1) {
if (pTamakoro->mBvaFrame == -1.0f)
pTamakoro->mBvaFrame = (f32)MR::hasPowerStarInCurrentStageWithDeclarer(pTamakoro->mName, -1);

if (pTamakoro->mItemType == -1 && pTamakoro->mModelId == -1) {
MR::setBvaFrameAndStop(pTamakoro, MR::hasPowerStarInCurrentStageWithDeclarer(pTamakoro->mName, -1));
}
else {
MR::setBvaFrameAndStop(pTamakoro, 3.0f);
if (pTamakoro->mBrkFrame == -1.0f)
pTamakoro->mBrkFrame = 0.0f;
}

MR::setBvaFrameAndStop(pTamakoro, pTamakoro->mBvaFrame);
}

if (pTamakoro->mBallColor == -1.0f)
MR::setBrkFrameAndStop(pTamakoro, 0.0f);
else
MR::setBrkFrameAndStop(pTamakoro, pTamakoro->mBallColor);
MR::setBrkFrameAndStop(pTamakoro, pTamakoro->mBrkFrame);
}

kmWrite32(0x804445E4, 0x7F63DB78); // mr r3, r27
Expand All @@ -94,20 +111,16 @@ kmCall(0x804445EC, TamakoroDetermineAnimFrame); // bl TamakoroDetermineAnimFrame
kmWrite32(0x804445F0, 0x48000034); // b 0x54

void TamakoroHandleBreak(TamakoroExt* pTamakoro, const char* pStr) {
if (pTamakoro->mMusicNum != 1) // only stop music if there is star ball music playing
if (pTamakoro->mMusicNum != 3) // only stop music if there is star ball music playing
MR::stopStageBGM(10);

if (pTamakoro->mModelId == 24) {
RedCoinUtil::tryAppearLinkedRedCoin(pTamakoro, pTamakoro->mTranslation);
}
}


kmWrite32(0x80446B78, 0x7FC3F378); // mr r3, r30
kmCall(0x80446B7C, TamakoroHandleBreak); // bl TamakoroHandleBreak

void TamakoroHandleAppearPowerStar(TamakoroExt* pTamakoro) {
if (pTamakoro->mMusicNum != 1) // only start last stage music if there is star ball music playing
if (pTamakoro->mMusicNum != 3) // only start last stage music if there is star ball music playing
MR::startLastStageBGM();

if (pTamakoro->mItemType == -1) {
Expand All @@ -124,16 +137,30 @@ void TamakoroStopStageBgm(TamakoroExt* pTamakoro) {
MR::emitEffect(pTamakoro, "Break");
MR::startActionSound(pTamakoro, "SmRideEnd", -1, -1, -1);
MR::startSoundPlayer("SE_PV_JUMP_S", -1, -1);

if (MR::isValidSwitchDead(pTamakoro))
MR::onSwitchDead(pTamakoro);

if (pTamakoro->mMusicNum != 1) {
if (pTamakoro->mMusicNum != 3) {
MR::stopStageBGM(40);
}

#ifdef REDCOINSYSTEM
if (pTamakoro->mModelId == 24) {
RedCoinUtil::tryAppearLinkedRedCoin(pTamakoro, pTamakoro->mTranslation);
pTamakoro->mIsBind = false;

switch (pTamakoro->mItemType) {
case 1:
MR::appearCoinPop(pTamakoro, pTamakoro->mTranslation, 1);
break;
case 2:
MR::appearStarPiece(pTamakoro, pTamakoro->mTranslation, 6, 10.0f, 40.0f, 0);
break;
case 3:
RedCoinUtil::tryAppearLinkedRedCoin(pTamakoro, pTamakoro->mTranslation);
break;
case 4:
BlueCoinUtil::appearBlueCoinActionKeeper(pTamakoro);
break;
}
#endif
}

kmCall(0x80446B48, TamakoroStopStageBgm); // bl TamakoroStopStageBgm
Expand All @@ -142,19 +169,54 @@ kmWrite32(0x80446B4C, 0x48000034); // b 0x34
void TamakoroStartStageBgm(TamakoroExt* pTamakoro) {
const char* seqName = "BGM_TAMAKORO";

if (pTamakoro->mMusicNum == 0)
seqName = "BGM_TAMAKORO_2";
switch (pTamakoro->mMusicNum) {
case 0:
seqName = "BGM_TAMAKORO_2";
break;
case 1:
seqName = "BGM_SMG_TAMAKORO";
break;
case 2:
seqName = "BGM_SMG_TAMAKORO_2";
break;
}

if (pTamakoro->mMusicNum != 1) {
if (pTamakoro->mMusicNum != 3) {
MR::startStageBGM(seqName, false);
pTamakoro->mAudioCtrl->init(seqName);
}

pTamakoro->mIsBind = true;
}

kmBranch(0x80447790, TamakoroStartStageBgm); // b TamakoroStartStageBgm



void TamakoroControlBgm(TamakoroExt* pTamakoro, f32 f, bool b, s32 l) {
if (pTamakoro->mIsBind) {
pTamakoro->mAudioCtrl->control(f, b, l);
}
}

kmWrite32(0x8044486C, 0x7FE3FB78); // mr r3, r31
kmCall(0x80444878, TamakoroControlBgm);


TamakoroBgmParamEntry* TamakoroSelectBgm(AudTamakoroBgmCtrl* pBgmCtrl, const char* pName) {
for (s32 i = 0; i < 4; i++) {
TamakoroBgmParamEntry* pEntry = &gTamakoroBgmParamTable[i];
OSReport("%s, %s\n", pName, pEntry->mName);

if (MR::isEqualString(pName, pEntry->mName))
return pEntry;
}

return &gTamakoroBgmParamTable[0];
}

kmCall(0x80222428, TamakoroSelectBgm); // bl TamakoroSelectBgm
kmWrite32(0x8022242C, 0x4800000C); // b 0xC


StageInstrumentEntry* LoadNewStageBgm(const char* pStr1, const char* pStr2) {
Expand Down

0 comments on commit eec0618

Please sign in to comment.