assorted kono progress

This commit is contained in:
HeartPiece 2024-05-18 00:08:26 +10:00
parent 27bbc0712b
commit b06d60c503
6 changed files with 87 additions and 67 deletions

View File

@ -102,7 +102,7 @@
| File | Size (bytes) | File | Size (bytes) |
| ---- | ---- | ---- | ---- |
| <a href="https://github.com/projectPiki/pikmin2/tree/main/src/plugProjectKonoU/khCaveResult.cpp">khCaveResult.cpp</a> | 42208 | <a href="https://github.com/projectPiki/pikmin2/tree/main/src/plugProjectKonoU/khFinalResult.cpp">khFinalResult.cpp</a> | 59951 |
| <a href="https://github.com/projectPiki/pikmin2/tree/main/src/plugProjectKonoU/khDayEndResult.cpp">khDayEndResult.cpp</a> | 81577 | <a href="https://github.com/projectPiki/pikmin2/tree/main/src/plugProjectKonoU/khWorldMap.cpp">khWorldMap.cpp</a> | 157461 |
| <a href="https://github.com/projectPiki/pikmin2/tree/main/src/plugProjectKonoU/khDayEndResult.cpp">khDayEndResult.cpp</a> | 81617 | <a href="https://github.com/projectPiki/pikmin2/tree/main/src/plugProjectKonoU/khWorldMap.cpp">khWorldMap.cpp</a> | 157286 |
### <section id="plugProjectMorimuraU">plugProjectMorimuraU</section>
| File | Size (bytes) | File | Size (bytes) |
@ -137,7 +137,7 @@
| <a href="https://github.com/projectPiki/pikmin2/tree/main/src/plugProjectNishimuraU/SaraiState.cpp">SaraiState.cpp</a> | 27370 | <a href="https://github.com/projectPiki/pikmin2/tree/main/src/plugProjectNishimuraU/MarState.cpp">MarState.cpp</a> | 28356 |
| <a href="https://github.com/projectPiki/pikmin2/tree/main/src/plugProjectNishimuraU/FrogState.cpp">FrogState.cpp</a> | 30811 | <a href="https://github.com/projectPiki/pikmin2/tree/main/src/plugProjectNishimuraU/SnakeCrowState.cpp">SnakeCrowState.cpp</a> | 32065 |
| <a href="https://github.com/projectPiki/pikmin2/tree/main/src/plugProjectNishimuraU/HanachirashiState.cpp">HanachirashiState.cpp</a> | 32837 | <a href="https://github.com/projectPiki/pikmin2/tree/main/src/plugProjectNishimuraU/KabutoState.cpp">KabutoState.cpp</a> | 32923 |
| <a href="https://github.com/projectPiki/pikmin2/tree/main/src/plugProjectNishimuraU/TankState.cpp">TankState.cpp</a> | 33068 | <a href="https://github.com/projectPiki/pikmin2/tree/main/src/plugProjectNishimuraU/playCamera.cpp">playCamera.cpp</a> | 33631 |
| <a href="https://github.com/projectPiki/pikmin2/tree/main/src/plugProjectNishimuraU/TankState.cpp">TankState.cpp</a> | 33069 | <a href="https://github.com/projectPiki/pikmin2/tree/main/src/plugProjectNishimuraU/playCamera.cpp">playCamera.cpp</a> | 33631 |
| <a href="https://github.com/projectPiki/pikmin2/tree/main/src/plugProjectNishimuraU/ShadowCylinder.cpp">ShadowCylinder.cpp</a> | 36098 | <a href="https://github.com/projectPiki/pikmin2/tree/main/src/plugProjectNishimuraU/BombSaraiState.cpp">BombSaraiState.cpp</a> | 36432 |
| <a href="https://github.com/projectPiki/pikmin2/tree/main/src/plugProjectNishimuraU/RandMapScore.cpp">RandMapScore.cpp</a> | 37034 | <a href="https://github.com/projectPiki/pikmin2/tree/main/src/plugProjectNishimuraU/DangoMushi.cpp">DangoMushi.cpp</a> | 37037 |
| <a href="https://github.com/projectPiki/pikmin2/tree/main/src/plugProjectNishimuraU/Hanachirashi.cpp">Hanachirashi.cpp</a> | 39557 | <a href="https://github.com/projectPiki/pikmin2/tree/main/src/plugProjectNishimuraU/SnakeCrow.cpp">SnakeCrow.cpp</a> | 39739 |
@ -161,7 +161,7 @@
| ---- | ---- | ---- | ---- |
| <a href="https://github.com/projectPiki/pikmin2/tree/main/src/plugProjectYamashitaU/enemyStoneDrawInfo.cpp">enemyStoneDrawInfo.cpp</a> | 19376 | <a href="https://github.com/projectPiki/pikmin2/tree/main/src/plugProjectYamashitaU/singleGS_ZukanParms.cpp">singleGS_ZukanParms.cpp</a> | 22080 |
| <a href="https://github.com/projectPiki/pikmin2/tree/main/src/plugProjectYamashitaU/vtxAnm.cpp">vtxAnm.cpp</a> | 31268 | <a href="https://github.com/projectPiki/pikmin2/tree/main/src/plugProjectYamashitaU/enemyAction.cpp">enemyAction.cpp</a> | 51416 |
| <a href="https://github.com/projectPiki/pikmin2/tree/main/src/plugProjectYamashitaU/kochappyState.cpp">kochappyState.cpp</a> | 65627 | <a href="https://github.com/projectPiki/pikmin2/tree/main/src/plugProjectYamashitaU/gameLightMgr.cpp">gameLightMgr.cpp</a> | 74592 |
| <a href="https://github.com/projectPiki/pikmin2/tree/main/src/plugProjectYamashitaU/kochappyState.cpp">kochappyState.cpp</a> | 65638 | <a href="https://github.com/projectPiki/pikmin2/tree/main/src/plugProjectYamashitaU/gameLightMgr.cpp">gameLightMgr.cpp</a> | 74592 |
| <a href="https://github.com/projectPiki/pikmin2/tree/main/src/plugProjectYamashitaU/chappyState.cpp">chappyState.cpp</a> | 76099 | | |
### <section id="sysBootupU">sysBootupU</section>

View File

@ -145,6 +145,8 @@ struct TVec2 {
return dist;
}
f32 dot(const TVec2<f32>& other) const { return x * other.x + y * other.y; }
bool isAbove(const TVec2<T>& other) const { return (x >= other.x) && (y >= other.y) ? true : false; }
bool isZero() const { return squared() <= 32.0f * FLT_EPSILON; }

View File

@ -34,6 +34,8 @@ enum MailCategory {
};
union MailSaveFlags {
inline u8 getReverseByte(int i) { return byteView[15 - i]; }
u32 typeView[4];
u8 byteView[16];
};
@ -652,29 +654,42 @@ struct SceneDayEndResultItem : public ::Screen::SceneBase {
// TODO: work out if this has extra members
};
struct MailTableDataEntry {
u64 mMessageID; // _00
u8 mFlag[4]; // _08
const char mFileName[0]; // _0C
};
struct MailTableData {
MailTableData(MailTableData* data, MailSaveFlags& flags, int i)
MailTableData(MailTableDataEntry* data, MailSaveFlags& flags, int i)
{
u8 bit = flags.getReverseByte(i >> 3);
int shift = (i - (int(i >> 3) << 3));
mMessageID = data->mMessageID;
mFlag[0] = data->mFlag[0];
mFlag[1] = data->mFlag[1];
mFlag[2] = data->mFlag[2];
mFileName = data->mFileName;
int byte = i >> 3;
mSaveFlag = bool(flags.byteView[15 - byte] & (1 << (i - (byte << 3))));
mFileName = (const char*)&data->mFileName;
mSaveFlag = ((1 << shift) & bit) != 0;
}
inline u32 calcSaveFlag(MailSaveFlags& flags, int i)
{
u32 cleared = (i >> 3);
return (1 << (i - (cleared << 3))) & flags.byteView[15 - (i >> 3)];
}
inline const char* getFileName() { return mFileName; }
u64 mMessageID; // _00
u8 mFlag[3]; // _08
char* mFileName; // _0C
u8 mSaveFlag; // _10
u64 mMessageID; // _00
u8 mFlag[3]; // _08
const char* mFileName; // _0C
u8 mSaveFlag; // _10
};
struct MailTableFile {
int mEntries; // _00
MailTableData** mData; // _04, might be double pointer
int mEntries; // _00
MailTableDataEntry** mData; // _04
};
struct SceneDayEndResultMail : public ::Screen::SceneBase {

View File

@ -102,6 +102,12 @@ struct khUtilColorAnm : public P2DScreen::CallBackNode {
inline void setColor(JUtility::TColor color, int id) { mColorList[id] = color; }
inline void setDisabledColor(JUtility::TColor color) { mDisabledColor = color; }
inline void reset()
{
mColor = mColorList[0];
mFrame = 0;
}
// _00 = VTBL
// _00-_1C = P2DScreen::Node
JUtility::TColor* mColorList; // _1C

View File

@ -2343,30 +2343,34 @@ void SceneDayEndResultMail::doUserCallBackFunc(Resource::MgrCommand* mgr)
JUT_PANICLINE(2674, "failed");
}
// problem is from here
int offset = 4;
MailSaveFlags saveFlags = Game::playData->mMailSaveData.mPastLogs;
u32 entries = file->mEntries;
mTableData = new MailTableData*[entries];
for (int i = 0; i < entries; i++) {
mTableData[i] = new MailTableData(file[offset].mData[0], saveFlags, i);
mTableData[i]
= new MailTableData(reinterpret_cast<MailTableDataEntry*>((u8*)file + offset), saveFlags, i); // this is the main issue
int fileNameLen = 0;
for (u8* ptr = (u8*)mTableData[i]->mFileName; *ptr; ptr++, fileNameLen++) {
;
}
offset += (fileNameLen + 16) & ~0x3;
}
// to here
if (!getDispMember()->isID(OWNER_KH, MEMBER_DAY_END_RESULT)) {
JUT_PANICLINE(2690, "disp member err");
}
DispDayEndResult* dispResult = static_cast<DispDayEndResult*>(getDispMember());
if (dispResult->mMail.mHeap && !dispResult->mMail.mBackupHeap) {
dispResult->mMail.mBackupHeap = makeSolidHeap(-1, dispResult->mMail.mHeap, false);
int mailID = -1;
int mailID;
DispDayEndResultMail& dispResult = static_cast<DispDayEndResult*>(getDispMember())->mMail;
if (dispResult.mHeap && !dispResult.mBackupHeap) {
dispResult.mBackupHeap = makeSolidHeap(-1, dispResult.mHeap, false);
mailID = -1;
for (int i = 0; i < entries; i++) {
if (dispResult->mMail.mMailCategory != mTableData[i]->mFlag[0]) {
if (dispResult.mMailCategory != mTableData[i]->mFlag[0]) {
continue;
}
@ -2379,7 +2383,7 @@ void SceneDayEndResultMail::doUserCallBackFunc(Resource::MgrCommand* mgr)
JUT_ASSERTLINE(2710, mailID != -1, "error");
for (int i = 0; i < entries; i++) {
if (dispResult->mMail.mMailCategory != mTableData[i]->mFlag[0]) {
if (dispResult.mMailCategory != mTableData[i]->mFlag[0]) {
continue;
}
if (!mTableData[i]->mSaveFlag || (s8)mTableData[i]->mFlag[1] < 0) {
@ -2391,20 +2395,20 @@ void SceneDayEndResultMail::doUserCallBackFunc(Resource::MgrCommand* mgr)
}
}
dispResult->mMail.mTodayMailID = mailID;
dispResult.mTodayMailID = mailID;
if (dispResult->mMail.mTodayMailID < 128) {
int byte = dispResult->mMail.mTodayMailID >> 3;
saveFlags.byteView[15 - byte] |= (1 << (dispResult->mMail.mTodayMailID - (byte << 3)));
if (dispResult.mTodayMailID < 128) {
int byte = dispResult.mTodayMailID >> 3;
saveFlags.byteView[15 - byte] |= (1 << (dispResult.mTodayMailID - (byte << 3)));
}
Game::playData->mMailSaveData.mPastLogs = saveFlags;
Game::playData->mMailSaveData.set_history(dispResult->mMail.mTodayMailID);
Game::playData->mMailSaveData.set_history(dispResult.mTodayMailID);
mMailFlags = Game::playData->mMailSaveData.mHistory;
LoadResource::Arg iconArg("/user/Koono/mail_icon.szs");
iconArg.mHeap = dispResult->mMail.mBackupHeap;
iconArg.mHeap = dispResult.mBackupHeap;
LoadResource::Node* iconNode = gLoadResourceMgr->mountArchive(iconArg);
if (iconNode) {
mIconArchive = static_cast<JKRMemArchive*>(iconNode->mArchive);

View File

@ -783,21 +783,18 @@ void WorldMap::update(::Game::WorldMap::UpdateArg& arg)
mRocketAngle = JGeometry::TVec2f(temp.x * x - temp.y * y, temp.x * y + temp.y * x);
f32 angle = mRocketAngle.squared();
mRocketAngle.normalize();
// f32 angle = mRocketAngle.x * mRocketAngle.x + mRocketAngle.y + mRocketAngle.y;
// if (angle > FLT_EPSILON) {
// mRocketAngle = angle;
// }
Vector2f rot;
getRotDir(temp, 0.0f);
mRocketPosition.x += msVal._04 * (mRocketAngle.x * msVal._00);
mRocketPosition.y += msVal._04 * (mRocketAngle.y * msVal._00);
// this is the regswap
JGeometry::TVec2f vec(getPaneCenterX(cPointPane) - mRocketPosition.x, getPaneCenterY(cPointPane) - mRocketPosition.y);
f32 dist = vec.x * vec.x + vec.y + vec.y; // is this a typo?
if (!isFlag(WMAPFLAG_Unk4)) {
vec.normalize();
if (vec.x * mRocketAngle.x + vec.y * mRocketAngle.y > 0.7f) {
// resetFlag(WMAPFLAG_Unk2);
if (vec.dot(mRocketAngle) > 0.7f) {
if (!isFlag(WMAPFLAG_Unk1)) {
setFlag(WMAPFLAG_Unk1 | WMAPFLAG_Unk2);
} else if (!isFlag(WMAPFLAG_Unk2)) {
@ -981,7 +978,7 @@ void WorldMap::update(::Game::WorldMap::UpdateArg& arg)
break;
}
case WMAP_Unk10: { // UP TO HERE
case WMAP_Unk10: {
f32 angle = pikmin2_atan2f(mRocketAngle.x, -mRocketAngle.y);
if (mRocketAngleMode == ROT_Unk1 && angle > 0.0f) {
@ -996,17 +993,14 @@ void WorldMap::update(::Game::WorldMap::UpdateArg& arg)
mRocketAngle.x = pikmin2_sinf(angle);
mRocketAngle.y = -pikmin2_cosf(angle);
// dumb shit here
f32 dist = mRocketAngle.squared();
if (!mRocketAngle.isZero()) {
f32 mod = sqrtf(dist);
dist = mod / 2 * -(dist * mod - 3.0f);
mRocketAngle.scale(dist);
}
mRocketPosition.add(msVal._04 * mRocketAngle.x * msVal._00, msVal._04 * mRocketAngle.y * msVal._00);
mRocketAngle.normalize();
f32 zero = 0.0f;
if (mRocketAngle.x * zero + mRocketAngle.y * -1.0f > 0.95f) {
mRocketPosition.x += msVal._04 * (mRocketAngle.x * msVal._00);
mRocketPosition.y += msVal._04 * (mRocketAngle.y * msVal._00);
JGeometry::TVec2f vec(0.0f, -1.0f);
f32 downComponent = vec.x * mRocketAngle.x + vec.y * mRocketAngle.y;
if (downComponent > 0.95f) {
if (!isFlag(WMAPFLAG_Unk1)) {
setFlag(WMAPFLAG_Unk1 | WMAPFLAG_Unk2);
} else if (!isFlag(WMAPFLAG_Unk2)) {
@ -1019,8 +1013,7 @@ void WorldMap::update(::Game::WorldMap::UpdateArg& arg)
mScreenInfo->search('Nlwin')->show();
if (!mInitArg.mDoNewEntriesEfx) {
Vector2f efxPos2(getPaneCenterX(target) + msVal._50[0].x, getPaneCenterY(target) + msVal._50[0].y);
efx2d::Arg arg(efxPos2);
efx2d::Arg arg(Vector2f(getPaneCenterX(target) + msVal._50[0].x, getPaneCenterY(target) + msVal._50[0].y));
efx2d::T2DChangesmoke efx;
efx.create(&arg);
}
@ -1031,16 +1024,16 @@ void WorldMap::update(::Game::WorldMap::UpdateArg& arg)
mScreenInfo->search('Nrwin')->show();
if (!mInitArg.mDoNewEntriesEfx) {
Vector2f efxPos2(getPaneCenterX(target) + msVal._50[0].x, getPaneCenterY(target) + msVal._50[0].y);
efx2d::Arg arg(efxPos2);
// Vector2f efxPos2(getPaneCenterX(target) + msVal._50[0].x, getPaneCenterY(target) + msVal._50[0].y);
efx2d::Arg arg(Vector2f(getPaneCenterX(target) + msVal._50[1].x, getPaneCenterY(target) + msVal._50[1].y));
efx2d::T2DChangesmoke efx;
efx.create(&arg);
}
}
if (mInitArg.mHasNewPiklopediaEntries || mInitArg.mHasNewTreasureHoardEntries) {
khUtilColorAnm* anm = mColorAnim2;
anm->mColor = anm->mColorList[0];
anm->mFrame = 0;
mColorAnim2->reset();
if (!mInitArg.mDoNewEntriesEfx) {
mScaleMgr->up();
PSSystem::spSysIF->playSystemSe(PSSE_SY_WMAP_ZUKAN_NEW, 0);
@ -1060,7 +1053,7 @@ void WorldMap::update(::Game::WorldMap::UpdateArg& arg)
for (int i = 0; i < mOnyonCount; i++) {
mOnyonArray[i].mOnyonPane->setOffset(1000.0f, 0.0f);
}
if (mRocketMoveCounter++ > 5) {
if (++mRocketMoveCounter > 5) {
mCurrentCourseIndex = mInitArg.mInitialCourseIndex;
if (mCurrentCourseIndex < 0) {
mCurrentCourseIndex = 0;
@ -1071,13 +1064,15 @@ void WorldMap::update(::Game::WorldMap::UpdateArg& arg)
mRocketPosition = Vector2f(getPaneCenterX(cPointPane), getPaneCenterY(cPointPane));
mRocketScale = 0.01f;
paneRocket->setOffset(mRocketPosition.x, mRocketPosition.y);
paneRocket->setAngle(TODEGREES(JMAAtan2Radian(-mRocketAngle.x, -mRocketAngle.y)));
f32 atanVal = JMAAtan2Radian(-mRocketAngle.x, -mRocketAngle.y) * JMath::TAngleConstant_<f32>::RADIAN_TO_DEGREE_FACTOR();
paneRocket->setAngle(atanVal);
paneRocket->updateScale(mRocketScale);
for (int i = 0; i < mOnyonCount; i++) {
mOnyonArray[i].mOffset = mRocketPosition;
mOnyonArray[i].mAngle.set(mRocketAngle);
mOnyonArray[i].mOnyonPane->setOffset(mRocketPosition.x, mRocketPosition.y);
mOnyonArray[i].mOnyonPane->setAngle(TODEGREES(JMAAtan2Radian(-mRocketAngle.x, -mRocketAngle.y)));
f32 atanVal = JMAAtan2Radian(-mRocketAngle.x, -mRocketAngle.y) * JMath::TAngleConstant_<f32>::RADIAN_TO_DEGREE_FACTOR();
mOnyonArray[i].mOnyonPane->setAngle(atanVal);
mOnyonArray[i].mOnyonPane->updateScale(mRocketScale);
}
mRocketMoveCounter = 0;
@ -3246,15 +3241,13 @@ f32 WorldMap::rocketMove(J2DPane* pane, bool flag)
angle.x = mRocketAngle.x;
angle.y = mRocketAngle.y;
JGeometry::TVec2f pos(getPaneCenterX(pane) - mRocketPosition.x, getPaneCenterY(pane) - mRocketPosition.y);
f32 otherFactor = msVal._4C;
f32 dist = pos.x * pos.x + pos.y * pos.y;
f32 factor = msVal._08;
int num = (mRocketMoveCounter - 86) / 5;
f32 dist = pos.squared();
f32 otherFactor = msVal._4C;
if (mRocketMoveCounter > 90) {
for (int i = mRocketMoveCounter; i < 90; i++) {
factor *= 0.99f;
}
// something weird going on here
for (int i = mRocketMoveCounter; i > 90; i--) {
factor *= 0.99f;
}
pos.normalize();
@ -3278,8 +3271,9 @@ f32 WorldMap::rocketMove(J2DPane* pane, bool flag)
val2 += TAU;
}
f32 phi;
f32 theta = val3 * otherFactor + (val1 * factor + (val2 * (1.0f - factor)));
f32 phi = theta - val1;
phi = theta - val1;
_B4.set(pikmin2_sinf(phi), -pikmin2_cosf(phi));
@ -3550,8 +3544,7 @@ void WorldMap::rocketUpdate(J2DPane* pane)
shipPane->setOffset(mRocketPosition.x, mRocketPosition.y);
shipPane->setAngle(TODEGREES(JMAAtan2Radian(-mRocketAngle.x, -mRocketAngle.y)));
f32 scale = tag2num(pane->mMessageID);
mRocketScale *= msVal._08 + (1.0f - msVal._08) * scale;
mRocketScale = mRocketScale * msVal._08 + (1.0f - msVal._08) * tag2num(pane->mMessageID);
f32 scale2 = msVal._1C[mOpenCourses] * mRocketScale;
shipPane->updateScale(scale2);
@ -3569,13 +3562,13 @@ void WorldMap::rocketUpdate(J2DPane* pane)
mEffectDir.x = -mRocketAngle.x;
mEffectDir.y = -mRocketAngle.y;
efx2d::WorldMap::ArgDirScale arg(mEffectPos, mEffectDir, scale);
efx2d::WorldMap::ArgDirScale arg(mEffectPos, mEffectDir, scale2);
efx2d::WorldMap::T2DRocketA efx;
efx.mResMgrId = 1;
efx.mGroup = 3;
efx.create(&arg);
mEfxRocketSparks->setGlobalParticleScale(scale);
mEfxRocketGlow->setGlobalParticleScale(scale);
mEfxRocketSparks->setGlobalParticleScale(scale2);
mEfxRocketGlow->setGlobalParticleScale(scale2);
/*
stwu r1, -0x100(r1)
@ -4199,7 +4192,7 @@ void WorldMap::changeInfo()
u64 tags2[4]
= { '8396_01', '8398_01', '8401_01', '8410_01' }; // "Hole of Beasts" "White Flower Garden" "Bulblax Kingdom" "Snagret Hole"
u64 tags3[4] = { '8397_01', '8402_01', '8403_01',
'8411_01' }; // "Citadel of Spiders" "Glutton's Kitchen" "Shower Room" "Submerged Castle"
'8411_01' }; // "Citadel of Spiders" "Glutton's Kitchen" "Shower Room" "Submerged Castle"
u64 tags4[4] = { '8412_01', '8413_01', '8414_01', 'no_data' }; // "Cavern of Chaos" "Hole of Heroes" "Dream Den"
u64* caveTags[4] = { tags1, tags2, tags3, tags4 };