This commit is contained in:
intns 2024-06-30 18:02:49 +01:00
parent 9c217963cd
commit eba1fa9f41
24 changed files with 227 additions and 193 deletions

View File

@ -83,10 +83,10 @@
| <a href="https://github.com/projectPiki/pikmin2/tree/main/src/plugProjectKandoU/collinfo.cpp">collinfo.cpp</a> | 43044 | <a href="https://github.com/projectPiki/pikmin2/tree/main/src/plugProjectKandoU/cellPyramid.cpp">cellPyramid.cpp</a> | 48067 |
| <a href="https://github.com/projectPiki/pikmin2/tree/main/src/plugProjectKandoU/fakePiki.cpp">fakePiki.cpp</a> | 50426 | <a href="https://github.com/projectPiki/pikmin2/tree/main/src/plugProjectKandoU/aiFormation.cpp">aiFormation.cpp</a> | 53253 |
| <a href="https://github.com/projectPiki/pikmin2/tree/main/src/plugProjectKandoU/pelletState.cpp">pelletState.cpp</a> | 63252 | <a href="https://github.com/projectPiki/pikmin2/tree/main/src/plugProjectKandoU/itemUjamushi.cpp">itemUjamushi.cpp</a> | 64495 |
| <a href="https://github.com/projectPiki/pikmin2/tree/main/src/plugProjectKandoU/itemPlant.cpp">itemPlant.cpp</a> | 73525 | <a href="https://github.com/projectPiki/pikmin2/tree/main/src/plugProjectKandoU/baseGameSection.cpp">baseGameSection.cpp</a> | 86433 |
| <a href="https://github.com/projectPiki/pikmin2/tree/main/src/plugProjectKandoU/itemPlant.cpp">itemPlant.cpp</a> | 73525 | <a href="https://github.com/projectPiki/pikmin2/tree/main/src/plugProjectKandoU/baseGameSection.cpp">baseGameSection.cpp</a> | 86375 |
| <a href="https://github.com/projectPiki/pikmin2/tree/main/src/plugProjectKandoU/aiPrimitives.cpp">aiPrimitives.cpp</a> | 117085 | <a href="https://github.com/projectPiki/pikmin2/tree/main/src/plugProjectKandoU/pelletMgr.cpp">pelletMgr.cpp</a> | 134788 |
| <a href="https://github.com/projectPiki/pikmin2/tree/main/src/plugProjectKandoU/navi.cpp">navi.cpp</a> | 148896 | <a href="https://github.com/projectPiki/pikmin2/tree/main/src/plugProjectKandoU/pikiState.cpp">pikiState.cpp</a> | 155487 |
| <a href="https://github.com/projectPiki/pikmin2/tree/main/src/plugProjectKandoU/naviState.cpp">naviState.cpp</a> | 163231 | <a href="https://github.com/projectPiki/pikmin2/tree/main/src/plugProjectKandoU/singleGS_Zukan.cpp">singleGS_Zukan.cpp</a> | 163810 |
| <a href="https://github.com/projectPiki/pikmin2/tree/main/src/plugProjectKandoU/naviState.cpp">naviState.cpp</a> | 163290 | <a href="https://github.com/projectPiki/pikmin2/tree/main/src/plugProjectKandoU/singleGS_Zukan.cpp">singleGS_Zukan.cpp</a> | 163810 |
| <a href="https://github.com/projectPiki/pikmin2/tree/main/src/plugProjectKandoU/gameMapParts.cpp">gameMapParts.cpp</a> | 164131 | | |
### <section id="plugProjectKonoU">plugProjectKonoU</section>
@ -143,7 +143,7 @@
| ---- | ---- | ---- | ---- |
| <a href="https://github.com/projectPiki/pikmin2/tree/main/src/plugProjectOgawaU/ogCopyPane.cpp">ogCopyPane.cpp</a> | 7678 | <a href="https://github.com/projectPiki/pikmin2/tree/main/src/plugProjectOgawaU/ogCounterSlot.cpp">ogCounterSlot.cpp</a> | 15278 |
| <a href="https://github.com/projectPiki/pikmin2/tree/main/src/plugProjectOgawaU/ogMenuMgr.cpp">ogMenuMgr.cpp</a> | 18723 | <a href="https://github.com/projectPiki/pikmin2/tree/main/src/plugProjectOgawaU/ogObjContena.cpp">ogObjContena.cpp</a> | 31668 |
| <a href="https://github.com/projectPiki/pikmin2/tree/main/src/plugProjectOgawaU/ogObjVs.cpp">ogObjVs.cpp</a> | 44612 | <a href="https://github.com/projectPiki/pikmin2/tree/main/src/plugProjectOgawaU/ogObjSMenuMap.cpp">ogObjSMenuMap.cpp</a> | 53588 |
| <a href="https://github.com/projectPiki/pikmin2/tree/main/src/plugProjectOgawaU/ogObjVs.cpp">ogObjVs.cpp</a> | 44612 | <a href="https://github.com/projectPiki/pikmin2/tree/main/src/plugProjectOgawaU/ogObjSMenuMap.cpp">ogObjSMenuMap.cpp</a> | 53594 |
### <section id="plugProjectYamashitaU">plugProjectYamashitaU</section>
| File | Size (bytes) | File | Size (bytes) |
@ -172,9 +172,9 @@
| <a href="https://github.com/projectPiki/pikmin2/tree/main/src/sysGCU/sysShapeModel.cpp">sysShapeModel.cpp</a> | 15500 | <a href="https://github.com/projectPiki/pikmin2/tree/main/src/sysGCU/titleSection.cpp">titleSection.cpp</a> | 19709 |
| <a href="https://github.com/projectPiki/pikmin2/tree/main/src/sysGCU/JSTObjectActor.cpp">JSTObjectActor.cpp</a> | 20961 | <a href="https://github.com/projectPiki/pikmin2/tree/main/src/sysGCU/JSTObjectSystem.cpp">JSTObjectSystem.cpp</a> | 22652 |
| <a href="https://github.com/projectPiki/pikmin2/tree/main/src/sysGCU/matMath.cpp">matMath.cpp</a> | 26236 | <a href="https://github.com/projectPiki/pikmin2/tree/main/src/sysGCU/moviePlayer.cpp">moviePlayer.cpp</a> | 26335 |
| <a href="https://github.com/projectPiki/pikmin2/tree/main/src/sysGCU/windowMessage.cpp">windowMessage.cpp</a> | 29493 | <a href="https://github.com/projectPiki/pikmin2/tree/main/src/sysGCU/system.cpp">system.cpp</a> | 29872 |
| <a href="https://github.com/projectPiki/pikmin2/tree/main/src/sysGCU/windowMessage.cpp">windowMessage.cpp</a> | 29493 | <a href="https://github.com/projectPiki/pikmin2/tree/main/src/sysGCU/system.cpp">system.cpp</a> | 29884 |
| <a href="https://github.com/projectPiki/pikmin2/tree/main/src/sysGCU/memoryCard.cpp">memoryCard.cpp</a> | 31350 | <a href="https://github.com/projectPiki/pikmin2/tree/main/src/sysGCU/bootSection.cpp">bootSection.cpp</a> | 38573 |
| <a href="https://github.com/projectPiki/pikmin2/tree/main/src/sysGCU/movieMessage.cpp">movieMessage.cpp</a> | 44324 | <a href="https://github.com/projectPiki/pikmin2/tree/main/src/sysGCU/pikmin2MemoryCardMgr.cpp">pikmin2MemoryCardMgr.cpp</a> | 50866 |
| <a href="https://github.com/projectPiki/pikmin2/tree/main/src/sysGCU/movieMessage.cpp">movieMessage.cpp</a> | 44324 | <a href="https://github.com/projectPiki/pikmin2/tree/main/src/sysGCU/pikmin2MemoryCardMgr.cpp">pikmin2MemoryCardMgr.cpp</a> | 51339 |
| <a href="https://github.com/projectPiki/pikmin2/tree/main/src/sysGCU/graphics.cpp">graphics.cpp</a> | 76184 | <a href="https://github.com/projectPiki/pikmin2/tree/main/src/sysGCU/messageRendering.cpp">messageRendering.cpp</a> | 100334 |
### <section id="utilityU">utilityU</section>

View File

@ -152,7 +152,7 @@ struct Mgr : public PlayCommonData {
char padding; // _21
u16 _22; // _22
u32 _24; // _24
u32 _28; // _28
u32 mSaveSlotIndex; // _28
u32 _2C; // _2C
u64 mCardSerialNo; // _30
u8 mSoundMode; // _38, TODO: Replace with Soundmode enum

View File

@ -63,7 +63,7 @@ struct EnemyIterator {
inline bool satisfy() { return mCondition->satisfy(mContainer->get(mIndex)); }
// VTBL _00
void* mIndex; // _04;
void* mIndex; // _04
GenericContainer* mContainer; // _08
Condition<T>* mCondition; // _0C
};

View File

@ -89,16 +89,16 @@ struct GameMessageVsGetDoping : public GameMessage {
struct GameMessageVsGetOtakara : public GameMessage {
inline GameMessageVsGetOtakara(u32 onyonType)
: _04(onyonType)
, _08(1)
: mOnionType(onyonType)
, mUnused08(1)
{
}
virtual bool actVs(VsGameSection*); // _10
// _00 = VTBL
u32 _04; // _04, onyon type according to ghidra, but that enum is meant to be a short
int _08; // _08
u32 mOnionType; // _04, onyon type according to ghidra, but that enum is meant to be a short
int mUnused08; // _08
};
struct GameMessageVsGotCard : public GameMessage {

View File

@ -14,12 +14,14 @@ struct PlayerFileInfo;
struct PlayerInfoHeader;
struct PlayerInfo {
u32 _00; // _00
u32 _04; // _04
u32 mMagic; // _00
u32 mVersionType; // _04
};
struct OptionInfo {
u32 _00; // _00
u32 _04; // _04
u32 mMagic; // _00
u32 mVersionType; // _04
u32 mSaveSlotIndex; // _08
};
enum MemoryCardMgrFlags {
@ -127,7 +129,7 @@ struct Mgr : public MemoryCardMgr {
inline bool isCardInvalid() { return !mIsCard && checkStatus() != MCS_11; }
// _00-_E8 = MemoryCardMgr
u32 _D8; // _D8
u32 mErrorCode; // _D8
void* mBannerImageFile; // _DC
void* mIconImageFile; // _E0
BitFlag<u32> mFlags; // _E4

View File

@ -47,7 +47,7 @@ enum VsCaveInfoType {
enum LoseReasonFlags {
VSLOSE_Unk1 = 0x1,
VSLOSE_Extinction = 0x2,
VSLOSE_Unk3 = 0x4,
VSLOSE_Finished = 0x4,
VSLOSE_Marble = 0x80,
};

View File

@ -35,8 +35,8 @@ struct State;
struct VsGameSection : public BaseGameSection {
typedef VsGame::State StateType;
struct DropCardArg {
f32 _00; // _00
f32 _04; // _04
f32 mDropMinDistance; // _00
f32 mDropMaximumDistance; // _04
};
VsGameSection(JKRHeap*, bool);

View File

@ -17,7 +17,7 @@ struct UpdateContext {
UpdateMgr* mMgr; // _00
int mClientIndex; // _04
bool _08; // _08
bool mIsActive; // _08
bool mDoForceActive; // _09
};
@ -35,10 +35,10 @@ struct UpdateMgr {
void showInfo(Graphics&, int, int);
int mMaxClientId; // _00
u32 _04; // _04
u32 mClientCount; // _04
int* mClientListA; // _08
int* mClientListB; // _0C
u32 _10; // _10
u32 mCurrentIndex; // _10
u32 _14; // _14
};

View File

@ -29,7 +29,7 @@ struct KeyEvent : public CNode {
inline KeyEvent()
{
mFrame = 0;
mType = 0;
mType = KEYEVENT_LOOP_START;
mAnimIdx = -1;
}

View File

@ -111,8 +111,8 @@ struct System : public OSMutex {
struct GXVerifyArg {
GXVerifyArg();
u32 _00; // _00
u8 _04; // _04
u32 mUnused00; // _00
u8 mUnused04; // _04
};
System();

View File

@ -127,39 +127,50 @@ int ActWeed::exec()
if (!mIsAttacking) {
return ACTEXEC_Fail;
}
if (mWeed == nullptr) {
return ACTEXEC_Fail;
}
switch (mState) {
case WEED_Attack: {
int flockAttackResult = mFlockAttack->exec();
if (flockAttackResult == ACTEXEC_Success) {
if (!mWeed->isAlive()) {
return ACTEXEC_Success;
}
decideTarget();
initAdjust();
} else if (flockAttackResult == ACTEXEC_Fail) {
decideTarget();
initAdjust();
}
} break;
break;
}
case WEED_Adjust: {
if (mTargetFlockIdx == -1) {
decideTarget();
initAdjust();
}
if (!mWeed->isAlive()) {
return ACTEXEC_Success;
}
calcAttackPos();
mApproachPos->mGoalPosition = mAttackPosition;
int approachResult = mApproachPos->exec();
int approachResult = mApproachPos->exec();
if (approachResult == ACTEXEC_Success && mState == WEED_Adjust) {
initStickAttack();
}
} break;
break;
}
}
return ACTEXEC_Continue;
}
@ -210,6 +221,7 @@ void ActFlockAttack::init(ActionArg* arg)
isFlockArg = true;
}
}
P2ASSERTLINE(276, isFlockArg);
FlockAttackActionArg* flockArg = static_cast<FlockAttackActionArg*>(arg);
@ -217,6 +229,7 @@ void ActFlockAttack::init(ActionArg* arg)
mTarget = flockArg->mTarget;
mDamage = flockArg->mDamage;
mFlockIndex = flockArg->mFlockIndex;
if (flockArg->mType == Game::ItemWeed::WEEDTYPE_Grass) {
mWeedType = Game::ItemWeed::WEEDTYPE_Grass;
mAnimIdx = Game::IPikiAnims::NUKU;
@ -224,6 +237,7 @@ void ActFlockAttack::init(ActionArg* arg)
mAnimIdx = Game::IPikiAnims::ATTACK1;
mWeedType = Game::ItemWeed::WEEDTYPE_Stone;
}
mParent->startMotion(mAnimIdx, mAnimIdx, this, nullptr);
mFlags.clear();
mParent->mTargetVelocity = Vector3f(0.0f);
@ -238,22 +252,28 @@ int ActFlockAttack::exec()
if (!mTarget) {
return ACTEXEC_Success;
}
if (!mTarget->isAlive()) {
return ACTEXEC_Success;
}
if (isFlag(FLOCK_AnimFinished)) {
int result = ACTEXEC_Fail;
if (isFlag(FLOCK_Dead)) {
result = ACTEXEC_Success;
}
return result;
}
if (!mParent->assertMotion(mAnimIdx)) {
return ACTEXEC_Fail;
}
if (isFlag(FLOCK_AttackReady) && !isFlag(FLOCK_AttackFinished)) {
int idx = mFlockIndex;
Game::InteractFlockAttack interaction(mParent, idx, mDamage, false);
if (mTarget->stimulate(interaction)) {
// we're hitting rocks/stone
if (mWeedType == Game::ItemWeed::WEEDTYPE_Stone) {
@ -281,9 +301,11 @@ int ActFlockAttack::exec()
wp.create(&arg);
mParent->startSound(mTarget, PSSE_PK_SE_PULL_GRASS, true);
}
if (interaction.mIsFlockDead) {
setFlag(FLOCK_Dead);
}
setFlag(FLOCK_AttackFinished);
}
}

View File

@ -657,10 +657,7 @@ void BaseGameSection::initGenerators()
void* plantsgenFile = LoadTextFile(filenameCharArr);
if (plantsgenFile) {
RamStream plantsGenTxt(plantsgenFile, -1);
plantsGenTxt.mMode = 1;
if (plantsGenTxt.mMode == 1) {
plantsGenTxt.mTabCount = 0;
}
plantsGenTxt.setMode(STREAM_MODE_TEXT, 1);
plantsGeneratorMgr->read(plantsGenTxt, false);
plantsGeneratorMgr->updateUseList();
generatorFiles[fileIdx] = plantsgenFile;

View File

@ -4180,10 +4180,10 @@ void NaviAbsorbState::exec(Navi* navi)
void NaviAbsorbState::onKeyEvent(Navi* navi, SysShape::KeyEvent const& key)
{
switch (key.mType) {
case 0:
case KEYEVENT_LOOP_START:
_10 = 1;
break;
case 1:
case KEYEVENT_LOOP_END:
P2ASSERTLINE(3956, mDrop->mObjectTypeID == OBJTYPE_Honey);
ItemHoney::Item* item = mDrop;
if (!mDrop->isAlive() || !item->isShrinking()) {
@ -4863,9 +4863,9 @@ lbl_80186148:
void NaviThrowWaitState::onKeyEvent(SysShape::KeyEvent const& key)
{
switch (key.mType) {
case 2:
case KEYEVENT_2:
break;
case 1:
case KEYEVENT_LOOP_END:
if (mHoldChargeLevel < 3) {
mHoldChargeLevel++;
}

View File

@ -442,10 +442,10 @@ bool InteractSuckDone::actOnyon(Onyon* item)
}
if (gameSystem->isVersusMode()) {
const char* peltnames[2] = { VsOtakaraName::cBedamaRed, VsOtakaraName::cBedamaBlue };
const char* pelletNames[2] = { VsOtakaraName::cBedamaRed, VsOtakaraName::cBedamaBlue };
for (int i = 0; i < 2; i++) {
if (!strcmp(peltnames[i], pellet->mConfig->mParams.mName.mData)) {
if (!strcmp(pelletNames[i], pellet->mConfig->mParams.mName.mData)) {
if (i == 1 - item->mOnyonType) {
_08 = 1;

View File

@ -495,11 +495,11 @@ void CaveState::onMovieStart(SingleGameSection* game, MovieConfig* config, u32,
Screen::Game2DMgr::GameOverTitle naviType;
if (naviID == 0) {
naviType = Screen::Game2DMgr::GOTITLE_OlimarDown;
game->setPlayerMode(0);
game->setPlayerMode(NAVIID_Olimar);
} else {
naviType = (playData->mStoryFlags & STORY_DebtPaid) ? Screen::Game2DMgr::GOTITLE_PresidentDown
: Screen::Game2DMgr::GOTITLE_LouieDown;
game->setPlayerMode(1);
game->setPlayerMode(NAVIID_Louie);
}
Screen::gGame2DMgr->open_GameOver(naviType);
}
@ -624,9 +624,9 @@ void CaveState::onMovieDone(Game::SingleGameSection* game, Game::MovieConfig* co
naviMgr->getAt(naviID)->setDeadLaydown();
if (naviMgr->mDeadNavis != 2) {
if ((int)naviID == 0) {
gameSystem->mSection->setPlayerMode(1);
gameSystem->mSection->setPlayerMode(NAVIID_Louie);
} else {
gameSystem->mSection->setPlayerMode(0);
gameSystem->mSection->setPlayerMode(NAVIID_Olimar);
}
} else {
Piki* pikilist[MAX_PIKI_COUNT];

View File

@ -77,9 +77,9 @@ void GameState::init(SingleGameSection* game, StateArg* arg)
game->mIsExitingMap = false;
if ((playData->mDeadNaviID & 1) == 0) {
game->setPlayerMode(0);
game->setPlayerMode(NAVIID_Olimar);
} else {
game->setPlayerMode(1);
game->setPlayerMode(NAVIID_Louie);
}
game->setCamController();
if (game->mWeatherEfx) {
@ -629,11 +629,11 @@ void GameState::onMovieStart(SingleGameSection* game, MovieConfig* config, u32,
Screen::Game2DMgr::GameOverTitle naviType;
if (naviID == 0) {
naviType = Screen::Game2DMgr::GOTITLE_OlimarDown;
game->setPlayerMode(0);
game->setPlayerMode(NAVIID_Olimar);
} else {
naviType = (playData->mStoryFlags & STORY_DebtPaid) ? Screen::Game2DMgr::GOTITLE_PresidentDown
: Screen::Game2DMgr::GOTITLE_LouieDown;
game->setPlayerMode(1);
game->setPlayerMode(NAVIID_Louie);
}
Screen::gGame2DMgr->open_GameOver(naviType);
}
@ -867,9 +867,9 @@ void GameState::onMovieDone(SingleGameSection* game, MovieConfig* config, u32, u
naviMgr->getAt(id)->setDeadLaydown();
if (naviMgr->mDeadNavis != 2) {
if ((int)id == NAVIID_Olimar) {
gameSystem->mSection->setPlayerMode(1);
gameSystem->mSection->setPlayerMode(NAVIID_Louie);
} else {
gameSystem->mSection->setPlayerMode(0);
gameSystem->mSection->setPlayerMode(NAVIID_Olimar);
}
} else {
gameSystem->resetFlag(GAMESYS_IsGameWorldActive);

View File

@ -57,7 +57,7 @@ void UpdateContext::exit()
mMgr->removeClient(this);
mMgr = nullptr;
}
_08 = false;
mIsActive = false;
}
}
@ -67,11 +67,11 @@ void UpdateContext::exit()
*/
UpdateMgr::UpdateMgr()
{
mClientListA = nullptr;
mClientListB = nullptr;
mMaxClientId = 0;
_04 = 0;
_10 = 0;
mClientListA = nullptr;
mClientListB = nullptr;
mMaxClientId = 0;
mClientCount = 0;
mCurrentIndex = 0;
}
/**
@ -81,11 +81,13 @@ UpdateMgr::UpdateMgr()
*/
void UpdateMgr::update()
{
int i = ++_10;
int i = ++mCurrentIndex;
if (i < mMaxClientId) {
return;
}
_10 = 0;
mCurrentIndex = 0;
}
/**
@ -98,7 +100,7 @@ bool UpdateMgr::updatable(UpdateContext* context)
if (context == nullptr) {
return false;
}
return (u8)(context->mClientIndex == _10);
return (u8)(context->mClientIndex == mCurrentIndex);
}
/**
@ -110,11 +112,11 @@ void UpdateMgr::create(int count)
if (count <= 0) {
count = 1;
}
mMaxClientId = count;
mClientListA = new int[count];
mClientListB = new int[count];
_04 = 0;
_10 = 0;
mMaxClientId = count;
mClientListA = new int[count];
mClientListB = new int[count];
mClientCount = 0;
mCurrentIndex = 0;
for (int i = 0; i < mMaxClientId; i++) {
mClientListA[i] = nullptr;
mClientListB[i] = nullptr;
@ -131,22 +133,24 @@ void UpdateMgr::addClient(UpdateContext* context)
if (context->mClientIndex != -1) {
removeClient(context);
}
int v1 = mMaxClientId;
int smallestValueIndex = -1;
int smallestValue = 10000;
for (int i = 0; i < mMaxClientId; i++) {
if (mClientListA[i] < smallestValue) {
smallestValueIndex = i;
smallestValue = mClientListA[i];
}
}
if (smallestValueIndex != -1) {
context->mClientIndex = smallestValueIndex;
mClientListA[smallestValueIndex]++;
if (context->_08) {
if (context->mIsActive) {
mClientListB[smallestValueIndex]++;
}
_04++;
mClientCount++;
}
}
@ -156,14 +160,16 @@ void UpdateMgr::addClient(UpdateContext* context)
*/
void UpdateMgr::removeClient(UpdateContext* context)
{
int clientIDMaybe = context->mClientIndex;
if (clientIDMaybe != -1) {
JUT_ASSERTLINE(155, (clientIDMaybe >= 0 && clientIDMaybe < mMaxClientId), "mail to [%d-%d] %d\n", 0, mMaxClientId, clientIDMaybe);
int clientId = context->mClientIndex;
if (clientId != -1) {
JUT_ASSERTLINE(155, (clientId >= 0 && clientId < mMaxClientId), "mail to [%d-%d] %d\n", 0, mMaxClientId, clientId);
mClientListA[context->mClientIndex]--;
if (context->_08) {
if (context->mIsActive) {
mClientListB[context->mClientIndex]--;
}
_04--;
mClientCount--;
context->mClientIndex = -1;
}
}

View File

@ -56,11 +56,11 @@ void GameState::init(VsGameSection* section, StateArg* stateArg)
section->clearCaveMenus();
if (!gameSystem->isMultiplayerMode()) {
section->setPlayerMode(0);
section->setPlayerMode(NAVIID_Olimar);
}
if (gameSystem->isVersusMode()) {
section->setPlayerMode(2);
section->setPlayerMode(NAVIID_Multiplayer);
clearLoseCauses();
Screen::gGame2DMgr->startFadeBG_Floor();
}
@ -345,7 +345,7 @@ void GameState::exec(VsGameSection* section)
int redReason = -1;
int blueReason = -1;
if (isLoseCause(VSPLAYER_Red, VSLOSE_Unk3)) {
if (isLoseCause(VSPLAYER_Red, VSLOSE_Finished)) {
blueReason = 3;
} else if (isLoseCause(VSPLAYER_Red, VSLOSE_Unk1)) {
@ -357,7 +357,7 @@ void GameState::exec(VsGameSection* section)
if (blueReason == 3) {
} else if (isLoseCause(VSPLAYER_Blue, VSLOSE_Unk3)) {
} else if (isLoseCause(VSPLAYER_Blue, VSLOSE_Finished)) {
redReason = 3;
} else if (isLoseCause(VSPLAYER_Blue, VSLOSE_Unk1)) {
@ -534,13 +534,13 @@ void GameState::cleanup(VsGameSection* section)
* @note Address: 0x8022A824
* @note Size: 0x34
*/
void GameState::onBattleFinished(VsGameSection* section, int winnerMaybe, bool check)
void GameState::onBattleFinished(VsGameSection* section, int winningPlayerIndex, bool check)
{
if (mSubState) {
return;
}
setLoseCause(1 - winnerMaybe, VSLOSE_Unk3);
setLoseCause(1 - winningPlayerIndex, VSLOSE_Finished);
if (check) {
mSubState = 1;
@ -572,7 +572,7 @@ void GameState::onRedOrBlueSuckStart(VsGameSection* section, int player, bool is
mSubState = 1;
u8 loseReason = VSLOSE_Unk3;
u8 loseReason = VSLOSE_Finished;
if (!isYellow) {
loseReason |= VSLOSE_Marble;
}
@ -640,12 +640,12 @@ void GameState::onMovieStart(VsGameSection* section, MovieConfig* movie, u32 p1,
if (p2 == 0) {
gameOverTitle = Screen::Game2DMgr::GOTITLE_OlimarDown;
if (!gameSystem->isMultiplayerMode()) {
section->setPlayerMode(0);
section->setPlayerMode(NAVIID_Olimar);
}
} else {
gameOverTitle = Screen::Game2DMgr::GOTITLE_LouieDown;
if (!gameSystem->isMultiplayerMode()) {
section->setPlayerMode(1);
section->setPlayerMode(NAVIID_Louie);
}
}
Screen::gGame2DMgr->open_GameOver(gameOverTitle);
@ -691,7 +691,7 @@ void GameState::onMovieStart(VsGameSection* section, MovieConfig* movie, u32 p1,
void GameState::onMovieDone(VsGameSection* section, MovieConfig* config, u32 p1, u32 p2)
{
if (gameSystem->isMultiplayerMode()) {
section->setPlayerMode(2);
section->setPlayerMode(NAVIID_Multiplayer);
}
RoomMapMgr* mgr = static_cast<RoomMapMgr*>(mapMgr);
@ -755,7 +755,7 @@ void GameState::onMovieDone(VsGameSection* section, MovieConfig* config, u32 p1,
if (!gameSystem->isVersusMode()) {
MoviePlayArg movieArg("e00_E3_cavestart", nullptr, section->mMovieFinishCallback, 0);
if (gameSystem->isMultiplayerMode()) {
section->setPlayerMode(0);
section->setPlayerMode(NAVIID_Olimar);
}
section->setCamController();
movieArg.mDelegateStart = section->mMovieStartCallback;

View File

@ -27,7 +27,7 @@ void VSState::do_init(VsGameSection* gameSection)
{
gameSystem->mMode = GSM_VERSUS_MODE;
gameSection->setPlayerMode(2);
gameSection->setPlayerMode(NAVIID_Multiplayer);
gameSection->setCamController();
PSSystem::SceneMgr* mgr = PSSystem::getSceneMgr();

View File

@ -828,10 +828,10 @@ bool GameMessageVsRedOrSuckStart::actVs(VsGameSection* section)
bool GameMessageVsGetOtakara::actVs(VsGameSection* section)
{
if (section->mCurrentState) {
section->mYellowMarbleCounts[_04 - 2]++;
PSSetLastBeedamaDirection(_04 == 0, section->mYellowMarbleCounts[_04 - 2] == 3);
if (section->mYellowMarbleCounts[_04 - 2] >= 4) {
section->mCurrentState->onBattleFinished(section, _04, true);
section->mYellowMarbleCounts[mOnionType - 2]++;
PSSetLastBeedamaDirection(mOnionType == 0, section->mYellowMarbleCounts[mOnionType - 2] == 3);
if (section->mYellowMarbleCounts[mOnionType - 2] >= 4) {
section->mCurrentState->onBattleFinished(section, mOnionType, true);
}
}
@ -1158,8 +1158,8 @@ void VsGameSection::updateCardGeneration()
if (mSpawnTimer <= 0.0f) {
mSpawnTimer = 3.0f * randFloat() + 10.0f;
DropCardArg arg;
arg._00 = factor1;
arg._04 = factor2;
arg.mDropMinDistance = factor1;
arg.mDropMaximumDistance = factor2;
dropCard(arg);
}
}
@ -1179,7 +1179,7 @@ void VsGameSection::useCard()
void VsGameSection::dropCard(VsGameSection::DropCardArg& arg)
{
Vector3f spawn;
Cave::randMapMgr->getItemDropPosition(spawn, arg._00, arg._04);
Cave::randMapMgr->getItemDropPosition(spawn, arg.mDropMinDistance, arg.mDropMaximumDistance);
f32 radius = (randFloat() * 20.0f);
f32 angle = randFloat() * TAU;

View File

@ -79,14 +79,14 @@ StageList::StageList()
*/
void StageList::read(Stream& stream)
{
bool b = (gameSystem) ? gameSystem->mSection->disableAllocHalt() : true;
s32 stageNum = stream.readInt();
bool isAllocationHalted = (gameSystem) ? gameSystem->mSection->disableAllocHalt() : true;
s32 stageNum = stream.readInt();
for (int i = 0; i < stageNum; i++) {
StageData* currStageData = new StageData;
currStageData->read(stream);
mStageData.add(currStageData);
}
if (gameSystem && b) {
if (gameSystem && isAllocationHalted) {
gameSystem->mSection->enableAllocHalt();
}
}

View File

@ -23,7 +23,7 @@ void Mgr::setDefault()
{
mFlags.clear();
mCardSerialNo = 0;
_28 = 0;
mSaveSlotIndex = 0;
mSoundMode = 0;
mMusicVol = 0xFF;
mSeVol = -1;

View File

@ -80,7 +80,7 @@ Resource::~Resource() { mMgr->destroyResource(); }
*/
Mgr::Mgr()
: MemoryCardMgr()
, _D8(0)
, mErrorCode(0)
, mBannerImageFile(0)
, mIconImageFile(0)
{
@ -374,7 +374,7 @@ bool Mgr::doCardProc(void*, MemoryCardMgrCommand* command)
int heapSize = JKRHeap::getCurrentHeap()->getTotalFreeSize();
JKRHeap* currHeap = JKRHeap::getCurrentHeap();
_D8 = 0;
mErrorCode = 0;
switch (command->_00) {
case 7:
setFlag(MCMFLAG_IsWriting);
@ -711,47 +711,53 @@ bool Mgr::varifyCardStatus()
* @note Address: 0x804444CC
* @note Size: 0x1C0
*/
bool Mgr::commandSaveGameOption(bool param_1, bool param_2)
bool Mgr::commandSaveGameOption(bool isForceSave, bool skipReadCheck)
{
bool result = false;
if (param_1 || checkSerialNo(false)) {
u32* buffer = new (mHeap, -32) u32[0x800];
P2ASSERTLINE(1500, buffer);
int icheck = -1;
bool check = false;
if (!param_2) {
bool saveSuccessful = false;
if (isForceSave || checkSerialNo(false)) {
u32* optionBuffer = new (mHeap, -32) u32[0x800];
P2ASSERTLINE(1500, optionBuffer);
int selectedSlot = -1;
bool hasWriteFailed = false;
if (!skipReadCheck) {
for (int i = 0; i < 2; i++) {
if (!read(CARDSLOT_Unk0, cFileName, (u8*)buffer, 0x2000, i * 0x2000 + 0x2000)) {
check = true;
if (!read(CARDSLOT_Unk0, cFileName, (u8*)optionBuffer, 0x2000, i * 0x2000 + 0x2000)) {
hasWriteFailed = true;
break;
}
bool checkOption = checkOptionInfo((OptionInfo*)buffer) == 0; // sigh. sure, why not.
bool checkOption = checkOptionInfo((OptionInfo*)optionBuffer) == 0;
if (checkOption) {
icheck = i;
selectedSlot = i;
break;
}
}
}
if (icheck == -1) {
icheck = sys->mPlayData->_28 + 1 & 1;
if (selectedSlot == -1) {
selectedSlot = sys->mPlayData->mSaveSlotIndex + 1 & 1;
}
if (!check) {
sys->mPlayData->_28++;
buffer[0] = 'OpVa';
buffer[1] = '0002';
buffer[2] = sys->mPlayData->_28;
RamStream ramStream(&buffer[3], 0x1C00);
if (!hasWriteFailed) {
sys->mPlayData->mSaveSlotIndex++;
optionBuffer[0] = 'OpVa';
optionBuffer[1] = '0002';
optionBuffer[2] = sys->mPlayData->mSaveSlotIndex;
RamStream ramStream(&optionBuffer[3], 0x1C00);
writeGameOption(ramStream);
buffer[0x7FF] = calcCheckSumOptionInfo((OptionInfo*)buffer);
check = write(CARDSLOT_Unk0, cFileName, (u8*)buffer, 0x2000, icheck * 0x2000 + 0x2000);
result = check;
optionBuffer[0x7FF] = calcCheckSumOptionInfo((OptionInfo*)optionBuffer);
hasWriteFailed = write(CARDSLOT_Unk0, cFileName, (u8*)optionBuffer, 0x2000, selectedSlot * 0x2000 + 0x2000);
saveSuccessful = hasWriteFailed;
}
delete (buffer);
delete (optionBuffer);
}
if (result) {
if (saveSuccessful) {
sys->clearOptionBlockSaveFlag();
}
return result;
return saveSuccessful;
}
/**
@ -792,7 +798,7 @@ bool Mgr::commandLoadGameOption()
bool check2 = checkOptionInfo(info2);
// if both checks pass, pick buffer with higher value at 0xC, or first if equal
if (check1 && check2) {
if (info1[1]._00 >= info2[1]._00) {
if (info1[1].mMagic >= info2[1].mMagic) {
optionResult = info1;
} else {
optionResult = info2;
@ -809,14 +815,14 @@ bool Mgr::commandLoadGameOption()
// if none passed, set default
if (!optionResult) {
_D8 = 1;
mErrorCode = 1;
sys->mPlayData->setDefault();
// use buffer info to set playData variable
} else {
result = true;
sys->mPlayData->_28 = optionResult[1]._00;
RamStream ramStream((void*)&optionResult[1]._04, 0x1c00);
result = true;
sys->mPlayData->mSaveSlotIndex = optionResult[1].mMagic;
RamStream ramStream((void*)&optionResult[1].mVersionType, 0x1c00);
readGameOption(ramStream);
}
@ -855,7 +861,7 @@ bool Mgr::checkSerialNo(bool param_1)
bool result = false;
if (!(sys->mPlayData->mFlags.isSet(1))) {
if (param_1) {
_D8 = 3;
mErrorCode = 3;
}
result = true;
} else {
@ -1015,8 +1021,8 @@ int Mgr::getIndexPlayerInfo(s8 fileIndex, PlayerInfoHeader* infoHeader, bool* pa
doLoop = true;
break;
} else {
index = -1;
_D8 = 2;
index = -1;
mErrorCode = 2;
break;
}
} else {
@ -1049,8 +1055,8 @@ bool Mgr::commandLoadPlayer(s8 fileIndex)
u64 serial;
P2ASSERTBOUNDSLINE(2264, 0, fileIndex, 3);
commandLoadGameOption();
if ((s32)_D8 == 1)
_D8 = 0;
if ((s32)mErrorCode == 1)
mErrorCode = 0;
if (!isErrorOccured()) {
if (readCardSerialNo(&serial, CARDSLOT_Unk0)) {
u32* buffer = new (mHeap, -32) u32[0x3000];
@ -1089,28 +1095,29 @@ bool Mgr::loadPlayerForNoCard(s8 fileIndex)
* @note Address: 0x80445330
* @note Size: 0x178
*/
bool Mgr::loadPlayerProc(s8 fileIndex, u8* param_2)
bool Mgr::loadPlayerProc(s8 fileIndex, u8* playerDataBuffer)
{
bool result = false;
bool loadSuccess = false;
P2ASSERTBOUNDSLINE(2407, 0, fileIndex, 3);
PlayerInfoHeader infoHeader;
int playerInfo = getIndexPlayerInfo(fileIndex, &infoHeader, nullptr);
if (playerInfo >= 0 && playerInfo < 4) {
if ((result = read(CARDSLOT_Unk0, cFileName, param_2, 0xC000, playerInfo * 0xC000 + 0x6000), result)
&& !checkPlayerInfo((PlayerInfo*)param_2)) {
result = false;
_D8 = 2;
if ((loadSuccess = read(CARDSLOT_Unk0, cFileName, playerDataBuffer, 0xC000, playerInfo * 0xC000 + 0x6000), loadSuccess)
&& !checkPlayerInfo((PlayerInfo*)playerDataBuffer)) {
loadSuccess = false;
mErrorCode = 2;
}
} else {
if (infoHeader._00 == 'PlIn') {
sys->mPlayData->resetPlayer((s8)fileIndex);
playData->reset();
} else {
result = false;
_D8 = 2;
loadSuccess = false;
mErrorCode = 2;
}
}
return result;
return loadSuccess;
}
/**
@ -1125,7 +1132,7 @@ bool Mgr::commandDeletePlayer(s8 fileIndex)
result = writeInvalidPlayerInfo(playerInfo, (s8)fileIndex);
} else {
if (!modifyPlayerInfo(fileIndex, nullptr)) {
_D8 = 2;
mErrorCode = 2;
}
}
return result;
@ -1144,7 +1151,7 @@ bool Mgr::savePlayerProc(s8 fileIndex, u8* param_2, bool param_3)
P2ASSERTBOUNDSLINE(2506, 0, fileIndex, 3);
if (getIndexInvalidPlayerInfo(&idx, &tempIndex, fileIndex, ((u32*)param_2)[4], param_3)) {
if (idx < 0 || idx >= 4) {
_D8 = 2;
mErrorCode = 2;
modifyPlayerInfo(fileIndex, nullptr);
} else {
((u32*)param_2)[0x2FFF] = calcCheckSumPlayerInfo((PlayerInfo*)param_2);
@ -1174,8 +1181,8 @@ bool Mgr::commandCheckSerialNo()
{
bool result = false;
if (!(sys->mPlayData->mFlags.isSet(1))) {
result = true;
_D8 = 3;
result = true;
mErrorCode = 3;
} else {
if (verifyCardSerialNo(&sys->mPlayData->mCardSerialNo, CARDSLOT_Unk0)) {
result = true;
@ -1221,7 +1228,7 @@ void Mgr::readPlayer(Stream& stream) { playData->read(stream); }
*/
bool Mgr::checkOptionInfo(OptionInfo* optionInfo)
{
return _D0 && testCheckSumOptionInfo(optionInfo) && optionInfo->_00 == 'OpVa' && optionInfo->_04 == '0002';
return _D0 && testCheckSumOptionInfo(optionInfo) && optionInfo->mMagic == 'OpVa' && optionInfo->mVersionType == '0002';
}
/**
@ -1234,7 +1241,7 @@ u32 Mgr::calcCheckSumOptionInfo(OptionInfo* optionInfo) { return calcCheckSum(op
* @note Address: 0x804459E8
* @note Size: 0x40
*/
bool Mgr::testCheckSumOptionInfo(OptionInfo* optionInfo) { return (calcCheckSum(optionInfo, 0x1FFC) == optionInfo[0x3FF]._04); }
bool Mgr::testCheckSumOptionInfo(OptionInfo* optionInfo) { return (calcCheckSum(optionInfo, 0x1FFC) == optionInfo[0x3FF].mVersionType); }
/**
* @note Address: 0x80445A28
@ -1243,7 +1250,7 @@ bool Mgr::testCheckSumOptionInfo(OptionInfo* optionInfo) { return (calcCheckSum(
bool Mgr::checkPlayerInfo(PlayerInfo* playerInfo)
{
bool result = false;
if (_D0 != 0 && testCheckSumPlayerInfo(playerInfo) && playerInfo->_00 == 'PlVa' && playerInfo->_04 == '0003') {
if (_D0 != 0 && testCheckSumPlayerInfo(playerInfo) && playerInfo->mMagic == 'PlVa' && playerInfo->mVersionType == '0003') {
result = true;
}
return result;
@ -1259,7 +1266,7 @@ u32 Mgr::calcCheckSumPlayerInfo(PlayerInfo* playerInfo) { return calcCheckSum(pl
* @note Address: 0x80445AC4
* @note Size: 0x48
*/
bool Mgr::testCheckSumPlayerInfo(PlayerInfo* playerInfo) { return (calcCheckSum(playerInfo, 0xBFFC) == playerInfo[0x17FF]._04); }
bool Mgr::testCheckSumPlayerInfo(PlayerInfo* playerInfo) { return (calcCheckSum(playerInfo, 0xBFFC) == playerInfo[0x17FF].mVersionType); }
/**
* @note Address: 0x80445B0C
@ -1269,7 +1276,7 @@ u32 Mgr::getCardStatus()
{
u32 result;
if (checkStatus() == 2) {
switch (_D8) {
switch (mErrorCode) {
case 0:
result = 2;
break;
@ -1391,18 +1398,18 @@ bool Mgr::checkPlayerNoPlayerInfo(int param_1, s8 param_2, PlayerInfoHeader* inf
* @note Address: 0x80445FA4
* @note Size: 0x380
*/
bool Mgr::getIndexInvalidPlayerInfo(int* param_1, s8* param_2, s8 param_3, u32 param_4, bool param_5)
bool Mgr::getIndexInvalidPlayerInfo(int* playerInfoIndex, s8* playerType, s8 targetType, u32 targetValue, bool checkValue)
{
int array1[4]; // _24
int array2[4]; // _14
int playerTypes[4]; // _24
int playerValues[4]; // _14
for (int i = 0; i < 4; i++) {
array1[i] = -1;
array2[i] = 0xCDCDCDCD;
playerTypes[i] = -1;
playerValues[i] = 0xCDCDCDCD;
}
bool result = true;
int idx = -1;
bool isValid = true;
int foundIndex = -1;
u32* buffer = new (mHeap, -32) u32[0x80];
P2ASSERTLINE(3071, buffer);
@ -1412,70 +1419,70 @@ bool Mgr::getIndexInvalidPlayerInfo(int* param_1, s8* param_2, s8 param_3, u32 p
u32 bufVal = buffer[0];
s8 bufByte = ((u8*)buffer)[8];
array1[i] = bufByte;
playerTypes[i] = bufByte;
array2[i] = bufVal;
if (idx == -1 && bufByte == param_3 && bufVal != 'PlVa') {
*param_2 = param_3;
idx = i;
playerValues[i] = bufVal;
if (foundIndex == -1 && bufByte == targetType && bufVal != 'PlVa') {
*playerType = targetType;
foundIndex = i;
}
if (*(s8*)(buffer + 2) == param_3 && buffer[0] == 'PlVa' && param_5 && buffer[4] >= param_4) {
JUT_ASSERTLINE(3148, param_4 == 1, "card [%d] memory[%d]\n", buffer[4], param_4);
result = false;
_D8 = 3;
if (*(s8*)(buffer + 2) == targetType && buffer[0] == 'PlVa' && checkValue && buffer[4] >= targetValue) {
JUT_ASSERTLINE(3148, targetValue == 1, "card [%d] memory[%d]\n", buffer[4], targetValue);
isValid = false;
mErrorCode = 3;
break;
}
} else {
result = false;
isValid = false;
break;
}
}
delete (buffer);
if (result && idx == -1) {
if (isValid && foundIndex == -1) {
int array3[3];
array3[0] = -1;
array3[1] = -1;
array3[2] = -1;
u32 check = idx;
u32 check = foundIndex;
for (int i = 0; i < 4; i++) {
if (array1[i] >= 0 && array1[i] < 3) {
if (array3[array1[i]] == -1) {
array3[array1[i]] = i;
if (playerTypes[i] >= 0 && playerTypes[i] < 3) {
if (array3[playerTypes[i]] == -1) {
array3[playerTypes[i]] = i;
continue;
} else if (array2[i] == 'PlVa' && array2[array3[array1[i]]] != 'PlVa') {
idx = array3[array1[i]];
} else if (array2[i] != 'PlVa' && array2[array3[array1[i]]] == 'PlVa') {
idx = i;
} else if (array2[i] != 'PlVa' && array2[array3[array1[i]]] != 'PlVa') {
idx = i;
} else if (playerValues[i] == 'PlVa' && playerValues[array3[playerTypes[i]]] != 'PlVa') {
foundIndex = array3[playerTypes[i]];
} else if (playerValues[i] != 'PlVa' && playerValues[array3[playerTypes[i]]] == 'PlVa') {
foundIndex = i;
} else if (playerValues[i] != 'PlVa' && playerValues[array3[playerTypes[i]]] != 'PlVa') {
foundIndex = i;
}
if (idx != -1) {
param_2[0] = param_3;
if (foundIndex != -1) {
playerType[0] = targetType;
break;
}
}
}
if (result && idx == -1) {
if (isValid && foundIndex == -1) {
for (int i = 0; i < 4; i++) {
if (array1[i] < 0 || array1[i] > 2) {
idx = i;
} else if (array2[i] != 'PlVa' && array2[i] != 'PlIn') {
idx = i;
if (playerTypes[i] < 0 || playerTypes[i] > 2) {
foundIndex = i;
} else if (playerValues[i] != 'PlVa' && playerValues[i] != 'PlIn') {
foundIndex = i;
}
if (idx != -1) {
param_2[0] = param_3;
if (foundIndex != -1) {
playerType[0] = targetType;
break;
}
}
}
}
*param_1 = idx;
return result;
*playerInfoIndex = foundIndex;
return isValid;
}
inline bool Mgr::checkCheckSum(u32* buffer) { return _D0 && buffer[0x2FFF] == calcCheckSum(buffer, 0xBFFC); }
@ -1961,7 +1968,7 @@ bool Mgr::verifyCardSerialNo(u64* serial, MemoryCardMgr::ECardSlot cardSlot)
if (serialDat == *serial) {
result = true;
} else {
_D8 = 3;
mErrorCode = 3;
}
}
return result;
@ -1975,8 +1982,8 @@ bool Mgr::resetError()
{
bool result;
if (CARDProbe(0)) {
result = cardMount();
_D8 = 0;
result = cardMount();
mErrorCode = 0;
} else {
result = true;
}

View File

@ -686,8 +686,8 @@ void System::loadSoundResource()
*/
System::GXVerifyArg::GXVerifyArg()
{
_00 = 1;
_04 = 0;
mUnused00 = 1;
mUnused04 = 0;
}
/**