Skip to content

Commit

Permalink
Yussy
Browse files Browse the repository at this point in the history
  • Loading branch information
JoshuaMKW committed Jun 25, 2024
1 parent 45f4347 commit 8829804
Show file tree
Hide file tree
Showing 16 changed files with 318 additions and 197 deletions.
24 changes: 24 additions & 0 deletions include/object/jizo_stone.hxx
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#pragma once

#include <SMS/MapObj/MapObjGeneral.hxx>
#include <BetterSMS/module.hxx>

class TJizoStone : public TMapObjGeneral {
public:
BETTER_SMS_FOR_CALLBACK static JDrama::TNameRef *instantiate() {
return new TJizoStone("TJizoStone");
}

TJizoStone(const char *name);
~TJizoStone() override = default;

void touchWater(THitActor *actor) override;
void initMapCollisionData() override;
void initMapObj() override;
void setGroundCollision() override;

protected:
void playBoingAnim();
};

extern ObjData jizoStoneData;
4 changes: 2 additions & 2 deletions include/object/key_chest.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@ public:
void playOpenAnim();
void spawnShine();

private:
private:
bool mOpening;
bool mHasFinishedSounds;
bool mHasFinishedSounds;
};

extern ObjData keyChestData;
38 changes: 38 additions & 0 deletions include/object/pearl.hxx
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
#pragma once

#include <BetterSMS/module.hxx>
#include <SMS/MapObj/MapObjGeneral.hxx>

class TPearlCracked : public TMapObjGeneral {
protected:
enum class State : u8 {
STATE_NORMAL,
STATE_BROKEN,
STATE_RESTING,
};

public:
BETTER_SMS_FOR_CALLBACK static JDrama::TNameRef *instantiate() {
return new TPearlCracked("TPearlCracked");
}

TPearlCracked(const char *name);
~TPearlCracked() override = default;

void control() override;
void initMapCollisionData() override;
void initMapObj() override;
void setGroundCollision() override;

protected:
bool checkMarioRiding(TMario *player);
bool checkMarioPounding(TMario *player);
void swapToCracked();
void playFractureAnim();
void spawnShine();

private:
State mState;
};

extern ObjData pearlData;
73 changes: 0 additions & 73 deletions include/settings.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -14,77 +14,6 @@ using namespace BetterSMS;
extern const u8 gSaveBnr[];
extern const u8 gSaveIcon[];

class HUDSetting final : public Settings::IntSetting {
public:
enum HUD { SMS, E3, SPACEWORLD };

HUDSetting() : IntSetting("HUD Style", &mHUDValue) {
mValueRange = {0, 2, 1};
mValueChangedCB = valueChanged;
}
~HUDSetting() override {}

void getValueName(char *dst) const override {
switch (mHUDValue) {
case SMS:
strncpy(dst, "DEFAULT", 8);
break;
case E3:
strncpy(dst, "E3 DEMO", 8);
break;
case SPACEWORLD:
strncpy(dst, "SPACEWORLD", 11);
break;
}
}

void load(JSUMemoryInputStream &in) override {
IntSetting::load(in);
mValueChangedCB(&mHUDValue, &mHUDValue,
getKind()); // We manually update here to set instructions on load
}

// clang-format off
static void valueChanged(void* old, void* cur, ValueKind kind) {
//if (*reinterpret_cast<int*>(cur) == LongJumpMappingSetting::BUTTON_Z) {
// PowerPC::writeU32(reinterpret_cast<u32*>(SMS_PORT_REGION(0x80249670, 0, 0, 0)), 0x540004A5);
// PowerPC::writeU32(reinterpret_cast<u32*>(SMS_PORT_REGION(0x80249730, 0, 0, 0)), 0x540004A5);
// PowerPC::writeU32(reinterpret_cast<u32*>(SMS_PORT_REGION(0x80249C34, 0, 0, 0)), 0x540004A5);
// PowerPC::writeU32(reinterpret_cast<u32*>(SMS_PORT_REGION(0x8024BF30, 0, 0, 0)), 0x540004A5);
// PowerPC::writeU32(reinterpret_cast<u32*>(SMS_PORT_REGION(0x8024C248, 0, 0, 0)), 0x540004A5);
// PowerPC::writeU32(reinterpret_cast<u32*>(SMS_PORT_REGION(0x8024C36C, 0, 0, 0)), 0x540004A5);
// PowerPC::writeU32(reinterpret_cast<u32*>(SMS_PORT_REGION(0x80252124, 0, 0, 0)), 0x540004A5);
// PowerPC::writeU32(reinterpret_cast<u32*>(SMS_PORT_REGION(0x802A8834, 0, 0, 0)), 0x540006F7);
// PowerPC::writeU32(reinterpret_cast<u32*>(SMS_PORT_REGION(0x802A8840, 0, 0, 0)), 0x540006F7);
// PowerPC::writeU32(reinterpret_cast<u32*>(SMS_PORT_REGION(0x802A884C, 0, 0, 0)), 0x41820010); // Allow L button meaning updates
// PowerPC::writeU32(reinterpret_cast<u32*>(SMS_PORT_REGION(0x802A8860, 0, 0, 0)), 0x54000673);
// PowerPC::writeU32(reinterpret_cast<u32*>(SMS_PORT_REGION(0x802A886C, 0, 0, 0)), 0x54000673);
// PowerPC::writeU32(reinterpret_cast<u32*>(SMS_PORT_REGION(0x802A88C8, 0, 0, 0)), 0x54000673);
// PowerPC::writeU32(reinterpret_cast<u32*>(SMS_PORT_REGION(0x802A88D4, 0, 0, 0)), 0x54000673);
//}
//else {
// PowerPC::writeU32(reinterpret_cast<u32*>(SMS_PORT_REGION(0x80249670, 0, 0, 0)), 0x540004E7);
// PowerPC::writeU32(reinterpret_cast<u32*>(SMS_PORT_REGION(0x80249730, 0, 0, 0)), 0x540004E7);
// PowerPC::writeU32(reinterpret_cast<u32*>(SMS_PORT_REGION(0x80249C34, 0, 0, 0)), 0x540004E7);
// PowerPC::writeU32(reinterpret_cast<u32*>(SMS_PORT_REGION(0x8024BF30, 0, 0, 0)), 0x540004E7);
// PowerPC::writeU32(reinterpret_cast<u32*>(SMS_PORT_REGION(0x8024C248, 0, 0, 0)), 0x540004E7);
// PowerPC::writeU32(reinterpret_cast<u32*>(SMS_PORT_REGION(0x8024C36C, 0, 0, 0)), 0x54000427);
// PowerPC::writeU32(reinterpret_cast<u32*>(SMS_PORT_REGION(0x80252124, 0, 0, 0)), 0x540004E7);
// PowerPC::writeU32(reinterpret_cast<u32*>(SMS_PORT_REGION(0x802A8834, 0, 0, 0)), 0x54000673);
// PowerPC::writeU32(reinterpret_cast<u32*>(SMS_PORT_REGION(0x802A8840, 0, 0, 0)), 0x54000673);
// PowerPC::writeU32(reinterpret_cast<u32*>(SMS_PORT_REGION(0x802A884C, 0, 0, 0)), 0x60000000); // Allow L button meaning updates
// PowerPC::writeU32(reinterpret_cast<u32*>(SMS_PORT_REGION(0x802A8860, 0, 0, 0)), 0x540006F7);
// PowerPC::writeU32(reinterpret_cast<u32*>(SMS_PORT_REGION(0x802A886C, 0, 0, 0)), 0x540006F7);
// PowerPC::writeU32(reinterpret_cast<u32*>(SMS_PORT_REGION(0x802A88C8, 0, 0, 0)), 0x540006F7);
// PowerPC::writeU32(reinterpret_cast<u32*>(SMS_PORT_REGION(0x802A88D4, 0, 0, 0)), 0x540006F7);
//}
}
// clang-format on

private:
int mHUDValue;
};

class BugsExploitsSetting final : public Settings::SwitchSetting {
public:
BugsExploitsSetting() : SwitchSetting("Bugs/Exploits", &mBugsExploitsValue) {
Expand Down Expand Up @@ -187,5 +116,3 @@ public:
private:
bool mTutorialValue;
};

HUDSetting::HUD getHUDKind();
44 changes: 0 additions & 44 deletions src/fludd/goop.cpp

This file was deleted.

4 changes: 4 additions & 0 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,10 @@
#include "enemy/firey_petey.hxx"
#include "object/darkness_effect.hxx"
#include "object/follow_key.hxx"
#include "object/jizo_stone.hxx"
#include "object/key_chest.hxx"
#include "object/launch_star.hxx"
#include "object/pearl.hxx"
#include "object/tornado_obj.hxx"
#include "object/water_balloon.hxx"
#include "p_settings.hxx"
Expand Down Expand Up @@ -140,6 +142,8 @@ static void initModule() {
Objects::registerObjectAsMapObj("LaunchStar", &launchStarData, TLaunchStarObj::instantiate);
Objects::registerObjectAsMapObj("KeyFollow", &followKeyData, TFollowKey::instantiate);
Objects::registerObjectAsMapObj("KeyChest", &keyChestData, TKeyChest::instantiate);
Objects::registerObjectAsMapObj("JizoStone", &jizoStoneData, TJizoStone::instantiate);
Objects::registerObjectAsMapObj("Pearl", &pearlData, TPearlCracked::instantiate);
Objects::registerObjectAsMisc("FireyPetey", TFireyPetey::instantiate);
Objects::registerObjectAsMisc("FireyPeteyManager", TFireyPeteyManager::instantiate);
}
Expand Down
62 changes: 62 additions & 0 deletions src/object/jizo_stone.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
#include "object/jizo_stone.hxx"

#include <SMS/MSound/MSoundSESystem.hxx>

TJizoStone::TJizoStone(const char *name) : TMapObjGeneral(name) {}

void TJizoStone::touchWater(THitActor *actor) { playBoingAnim(); }

void TJizoStone::initMapCollisionData() {
mCollisionManager = new TMapCollisionManager(1, "mapObj", this);
mCollisionManager->init("jizo_stone", 1, nullptr);
}

void TJizoStone::initMapObj() {
TMapObjGeneral::initMapObj();

if (mCollisionManager) {
mCollisionManager->changeCollision(0);
mCollisionManager->mCurrentMapCollision->setAllActor(this);
}
}

void TJizoStone::setGroundCollision() {
auto *model = getModel();
if (mCollisionManager) {
mCollisionManager->mCurrentMapCollision->_5C &= 0xFFFFFFFE; // Enable
mCollisionManager->mCurrentMapCollision->moveMtx(*model->mJointArray);
}
}

void TJizoStone::playBoingAnim() {
if (!mActorData->isCurAnmAlreadyEnd(MActor::BCK)) {
return;
}

if (gpMSound->gateCheck(MSD_SE_EN_SAMBOHEAD_W_HIT)) {
MSoundSE::startSoundActor(MSD_SE_EN_SAMBOHEAD_W_HIT, reinterpret_cast<Vec *>(&mTranslation),
0, nullptr, 0, 4);
}

mActorData->setBck("jizo_stone_boing");
auto *ctrl = mActorData->getFrameCtrl(MActor::BCK);
ctrl->mAnimState = J3DFrameCtrl::ONCE;
ctrl->mFrameRate = 1.5f;
mModelLoadFlags &= ~0x100;
}

ObjData jizoStoneData{.mMdlName = "jizo_stone",
.mObjectID = 0x40000F80 /*0x80000FFF*/,
.mLiveManagerName = gLiveManagerName, // const_cast<char *>("木マネージャー")
.mObjKey = gUnkManagerName, // const_cast<char *>("waterballoon"),
.mAnimInfo = nullptr,
.mObjCollisionData = nullptr,
.mMapCollisionInfo = nullptr,
.mSoundInfo = nullptr,
.mPhysicalInfo = nullptr,
.mSinkData = nullptr,
._28 = nullptr,
.mBckMoveData = nullptr,
._30 = 50.0f,
.mUnkFlags = 0x4 /*0x02130100*/,
.mKeyCode = cexp_calcKeyCode("JizoStone")};
35 changes: 18 additions & 17 deletions src/object/key_chest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,24 +19,25 @@
#include "object/follow_key.hxx"
#include "object/key_chest.hxx"

TKeyChest::TKeyChest(const char *name) : TMapObjGeneral(name), mOpening(false), mHasFinishedSounds(false) {}
TKeyChest::TKeyChest(const char *name)
: TMapObjGeneral(name), mOpening(false), mHasFinishedSounds(false) {}

void TKeyChest::control() {
TMapObjGeneral::control();

if (mOpening) {
// Play chest next open sound when first sound has ended
bool isNextSoundReady = gpMSound->gateCheck(0x1967) && gpMSound->gateCheck(0x1966);
if (!mHasFinishedSounds && isNextSoundReady) {
MSoundSE::startSoundActor(0x1966, mTranslation, 0, nullptr, 0, 4);
mHasFinishedSounds = true;
}

if (mActorData->isCurAnmAlreadyEnd(MActor::BCK)) {
mOpening = false;
spawnShine();
}
}
TMapObjGeneral::control();

if (mOpening) {
// Play chest next open sound when first sound has ended
bool isNextSoundReady = gpMSound->gateCheck(0x1967) && gpMSound->gateCheck(0x1966);
if (!mHasFinishedSounds && isNextSoundReady) {
MSoundSE::startSoundActor(0x1966, mTranslation, 0, nullptr, 0, 4);
mHasFinishedSounds = true;
}

if (mActorData->isCurAnmAlreadyEnd(MActor::BCK)) {
mOpening = false;
spawnShine();
}
}
}

void TKeyChest::playIdleAnim() {}
Expand Down Expand Up @@ -82,7 +83,7 @@ void TKeyChest::spawnShine() {
void TKeyChest::touchPlayer(THitActor *actor) {
if (actor->mObjectID == OBJECT_ID_MARIO) {
TMario *player = reinterpret_cast<TMario *>(actor);
auto *data = SME::Player::getEclipseData(player);
auto *data = SME::Player::getEclipseData(player);
if (data->mIsHoldingKey) {
auto *nameRef = TMarNameRefGen::getInstance()->getRootNameRef();
u16 keyCode = JDrama::TNameRef::calcKeyCode("TreasureKey");
Expand Down
Loading

0 comments on commit 8829804

Please sign in to comment.