From a26abd9e30fa0d99aa32f66ff2179857148c308c Mon Sep 17 00:00:00 2001 From: PikHacker Date: Sun, 1 Sep 2024 23:43:46 -0400 Subject: [PATCH] lots of sysGCU cleanup --- docs/recommended_todo.md | 46 ++-- include/Caption.h | 3 +- include/Game/Data.h | 5 +- include/Game/Entities/ItemBridge.h | 2 +- include/Game/Entities/ItemGate.h | 2 +- include/Game/GameSystem.h | 2 +- include/Game/NaviState.h | 2 +- include/Game/THPPlayer.h | 4 +- include/Game/gameChallenge2D.h | 2 +- include/GameFlow.h | 21 -- include/JSystem/J3D/J3DTypes.h | 6 +- include/LoadResource.h | 4 +- include/P2JME/Caption.h | 10 +- include/P2JME/IllustratedBook.h | 2 +- include/P2JME/Movie.h | 15 +- include/P2JME/TSequenceProcessor.h | 32 ++- include/P2JME/messageObj.h | 7 +- include/P2JME/messageRendering.h | 105 ++++---- include/PSSystem/PSScene.h | 8 + include/Vector2.h | 2 +- src/JSystem/J2D/J2DScreen.cpp | 2 +- src/JSystem/J3D/J3DModelData.cpp | 4 +- src/JSystem/J3D/J3DModelLoaderCalcSize.cpp | 4 +- src/plugProjectEbisawaU/ebiP2TitleChappy.cpp | 10 +- src/plugProjectEbisawaU/ebiP2TitleKogane.cpp | 7 +- src/plugProjectEbisawaU/ebiP2TitlePikmin.cpp | 10 +- src/plugProjectEbisawaU/ebiP2TitleUnit.cpp | 8 +- src/plugProjectKandoU/baseGameSection.cpp | 29 +-- src/plugProjectKandoU/efxModelObjects.cpp | 2 +- src/plugProjectKandoU/fakePiki.cpp | 4 +- src/plugProjectKandoU/gameChallenge2D.cpp | 5 +- src/plugProjectKandoU/gameMapParts.cpp | 11 +- src/plugProjectKandoU/gameSeaMgr.cpp | 5 +- src/plugProjectKandoU/interactPiki.cpp | 2 +- src/plugProjectKandoU/itemBigFountain.cpp | 2 +- src/plugProjectKandoU/itemBridge.cpp | 22 +- src/plugProjectKandoU/itemGate.cpp | 24 +- src/plugProjectKandoU/itemPlant.cpp | 4 +- src/plugProjectKandoU/mapMgr.cpp | 4 +- src/plugProjectKandoU/navi.cpp | 2 +- src/plugProjectKandoU/naviMgr.cpp | 22 +- src/plugProjectKandoU/naviState.cpp | 12 +- src/plugProjectKandoU/navi_demoCheck.cpp | 4 +- src/plugProjectKandoU/onyonMgr.cpp | 24 +- src/plugProjectKandoU/pelletFruit.cpp | 2 +- src/plugProjectKandoU/pelletMgr.cpp | 23 +- src/plugProjectKandoU/pelletNumber.cpp | 6 +- src/plugProjectKandoU/pikiMgr.cpp | 18 +- src/plugProjectKandoU/pikiState.cpp | 4 +- src/plugProjectKandoU/singleGS_Movie.cpp | 2 +- src/plugProjectKandoU/vsGS_Game.cpp | 2 +- src/plugProjectKandoU/vsGS_Title.cpp | 2 +- src/plugProjectMorimuraU/blackManMgr.cpp | 6 +- .../challengeResult2D.cpp | 2 +- src/plugProjectMorimuraU/enemyNestMgr.cpp | 10 +- src/plugProjectMorimuraU/panModokiMgr.cpp | 6 +- src/plugProjectMorimuraU/tyreMgr.cpp | 3 +- src/plugProjectMorimuraU/vsSelect2D.cpp | 5 +- src/plugProjectMorimuraU/zukan2D.cpp | 12 +- src/plugProjectNishimuraU/Baby.cpp | 2 +- src/plugProjectNishimuraU/BigFoot.cpp | 2 +- src/plugProjectNishimuraU/BigTreasure.cpp | 4 +- src/plugProjectNishimuraU/Damagumo.cpp | 2 +- src/plugProjectNishimuraU/Fuefuki.cpp | 2 +- src/plugProjectNishimuraU/Hanachirashi.cpp | 2 +- src/plugProjectNishimuraU/Houdai.cpp | 2 +- src/plugProjectNishimuraU/IKSystemMgr.cpp | 13 +- src/plugProjectNishimuraU/KumaChappy.cpp | 2 +- src/plugProjectNishimuraU/Mar.cpp | 2 +- src/plugProjectNishimuraU/Sarai.cpp | 2 +- src/plugProjectNishimuraU/Tadpole.cpp | 2 +- src/plugProjectOgawaU/ogCallBackMessage.cpp | 4 +- src/plugProjectOgawaU/ogObjContena.cpp | 8 +- src/plugProjectOgawaU/ogObjKantei.cpp | 2 +- src/plugProjectYamashitaU/enemyMgrBase.cpp | 7 +- src/plugProjectYamashitaU/enemyStoneMgr.cpp | 2 +- src/plugProjectYamashitaU/farm.cpp | 2 +- src/sysCommonU/sysMath.cpp | 2 +- src/sysGCU/JSTObjectActor.cpp | 246 +++++++++--------- src/sysGCU/JSTObjectGameActor.cpp | 2 +- src/sysGCU/captionMessage.cpp | 37 +-- src/sysGCU/captionMgr.cpp | 9 +- src/sysGCU/commonSaveData.cpp | 50 +--- src/sysGCU/demoSection.cpp | 11 +- src/sysGCU/dvdStatus.cpp | 34 +-- src/sysGCU/dvdThread.cpp | 5 +- src/sysGCU/gameConfig.cpp | 56 ---- src/sysGCU/gameflow.cpp | 22 +- src/sysGCU/graphics.cpp | 4 +- src/sysGCU/illustratedBookMessage.cpp | 18 +- src/sysGCU/loadResource.cpp | 15 +- src/sysGCU/memoryCard.cpp | 23 +- src/sysGCU/messageAnalyzer.cpp | 4 +- src/sysGCU/messageRendering.cpp | 236 ++++++++--------- src/sysGCU/messageSequence.cpp | 99 ++++--- src/sysGCU/modelEffect.cpp | 8 +- src/sysGCU/modelMgr.cpp | 2 +- src/sysGCU/movieMessage.cpp | 74 +++--- src/sysGCU/pikmin2MemoryCardMgr.cpp | 10 +- src/sysGCU/pikmin2THPPlayer.cpp | 6 +- src/sysGCU/reset.cpp | 2 +- src/sysGCU/section.cpp | 27 +- src/sysGCU/sysShapeModel.cpp | 37 ++- src/sysGCU/titleSection.cpp | 18 +- src/sysGCU/windowMessage.cpp | 58 ++--- 105 files changed, 825 insertions(+), 958 deletions(-) diff --git a/docs/recommended_todo.md b/docs/recommended_todo.md index 06febb405..3c0838162 100644 --- a/docs/recommended_todo.md +++ b/docs/recommended_todo.md @@ -36,11 +36,11 @@ | J2D/J2DTextBoxEx.cpp | 19100 | JAudio//JAS/JASChannel.cpp | 19252 | | JAudio//JAS/JASBNKParser.cpp | 19529 | JStudio/fvb.cpp | 20332 | | J3D/J3DTevs.cpp | 20723 | J3D/J3DMtxBuffer.cpp | 20816 | -| J3D/J3DModelLoaderCalcSize.cpp | 21313 | J3D/J3DMaterial.cpp | 21616 | +| J3D/J3DModelLoaderCalcSize.cpp | 21358 | J3D/J3DMaterial.cpp | 21616 | | JAudio//JAI/JAIAnimation.cpp | 22715 | J2D/J2DWindow.cpp | 23735 | | J3D/J3DGD.cpp | 24264 | J3D/J3DModel.cpp | 25170 | | JAudio//JAI/JAIBasic.cpp | 29235 | J3D/J3DMaterialAttach.cpp | 29965 | -| J2D/J2DScreen.cpp | 30751 | JStudio/functionvalue.cpp | 31270 | +| J2D/J2DScreen.cpp | 30766 | JStudio/functionvalue.cpp | 31270 | | J3D/J3DMaterialFactory_v21.cpp | 35247 | JMessage/processor.cpp | 35777 | | J2D/J2DPicture.cpp | 41698 | JAudio//JAS/JASAramStream.cpp | 47117 | | J2D/J2DWindowEx.cpp | 47225 | JAudio//JAS/JASSeqParser.cpp | 47291 | @@ -77,17 +77,17 @@ | pathfinder.cpp | 22687 | itemPikihead.cpp | 24012 | | gameCPlate.cpp | 24190 | dynCreature.cpp | 25766 | | gameDynamics.cpp | 27134 | vsCardMgr.cpp | 30816 | -| itemBridge.cpp | 32201 | itemGate.cpp | 32864 | +| itemBridge.cpp | 32279 | itemGate.cpp | 33044 | | routeMgr.cpp | 34733 | piki.cpp | 35847 | | gamePlayDataMemCard.cpp | 36191 | gamePlayData.cpp | 37263 | -| fakePiki.cpp | 42168 | collinfo.cpp | 43051 | +| fakePiki.cpp | 42148 | collinfo.cpp | 43051 | | cellPyramid.cpp | 48069 | aiFormation.cpp | 53090 | | pelletState.cpp | 63252 | itemUjamushi.cpp | 64521 | -| itemPlant.cpp | 73535 | baseGameSection.cpp | 86417 | -| aiPrimitives.cpp | 117179 | pelletMgr.cpp | 134271 | -| navi.cpp | 148733 | pikiState.cpp | 155829 | -| naviState.cpp | 163224 | singleGS_Zukan.cpp | 163862 | -| gameMapParts.cpp | 164137 | | | +| itemPlant.cpp | 73541 | baseGameSection.cpp | 86125 | +| aiPrimitives.cpp | 117179 | pelletMgr.cpp | 134458 | +| navi.cpp | 148740 | pikiState.cpp | 155809 | +| naviState.cpp | 163222 | singleGS_Zukan.cpp | 163862 | +| gameMapParts.cpp | 164114 | | | ###
plugProjectKonoU
| File | Size (bytes) | File | Size (bytes) | @@ -104,15 +104,15 @@ | panModoki.cpp | 45170 | kingChappyState.cpp | 50807 | | umiMushi.cpp | 60146 | kingChappy.cpp | 64498 | | hiScore2D.cpp | 76415 | blackMan.cpp | 121903 | -| zukan2D.cpp | 134432 | challengeResult2D.cpp | 142175 | -| challengeSelect2D.cpp | 186008 | vsSelect2D.cpp | 196475 | +| zukan2D.cpp | 134438 | challengeResult2D.cpp | 142165 | +| challengeSelect2D.cpp | 186008 | vsSelect2D.cpp | 196392 | ###
plugProjectNishimuraU
| File | Size (bytes) | File | Size (bytes) | | ---- | ---- | ---- | ---- | | TyreShadow.cpp | 7271 | nslibmath.cpp | 7593 | | UmimushiShadow.cpp | 7675 | SnakeJointMgr.cpp | 7850 | -| KumaChappy.cpp | 10300 | SnakeWholeShadow.cpp | 11928 | +| KumaChappy.cpp | 10290 | SnakeWholeShadow.cpp | 11928 | | SnakeCrowShadow.cpp | 12091 | Kabuto.cpp | 12121 | | BabyState.cpp | 12837 | Kogane.cpp | 14498 | | RandMapMgr.cpp | 15237 | Rock.cpp | 17638 | @@ -129,8 +129,8 @@ | HanachirashiState.cpp | 32837 | KabutoState.cpp | 32923 | | TankState.cpp | 33069 | playCamera.cpp | 33865 | | BombSaraiState.cpp | 36432 | DangoMushi.cpp | 36921 | -| RandMapScore.cpp | 37057 | Hanachirashi.cpp | 39560 | -| SnakeCrow.cpp | 39754 | Mar.cpp | 41695 | +| RandMapScore.cpp | 37057 | Hanachirashi.cpp | 39550 | +| SnakeCrow.cpp | 39754 | Mar.cpp | 41685 | | DangoMushiState.cpp | 42130 | HoudaiShotGun.cpp | 44137 | | OniKurage.cpp | 45364 | SnakeWhole.cpp | 49311 | | MiniHoudaiShotGun.cpp | 49861 | KumaKochappyState.cpp | 50172 | @@ -142,7 +142,7 @@ | File | Size (bytes) | File | Size (bytes) | | ---- | ---- | ---- | ---- | | ogCopyPane.cpp | 7678 | ogCounterSlot.cpp | 15278 | -| ogMenuMgr.cpp | 18723 | ogObjContena.cpp | 31686 | +| ogMenuMgr.cpp | 18723 | ogObjContena.cpp | 31506 | | ogObjVs.cpp | 44615 | ogObjSMenuMap.cpp | 53594 | ###
plugProjectYamashitaU
@@ -161,21 +161,21 @@ | File | Size (bytes) | File | Size (bytes) | | ---- | ---- | ---- | ---- | | geomIntersection.cpp | 10969 | camera.cpp | 13560 | -| geomTraceMove.cpp | 14985 | sysMath.cpp | 24889 | +| geomTraceMove.cpp | 14985 | sysMath.cpp | 24879 | | geomOBBTree.cpp | 79647 | geometry.cpp | 98859 | ###
sysGCU
| File | Size (bytes) | File | Size (bytes) | | ---- | ---- | ---- | ---- | | aramMgr.cpp | 4254 | JSTObjectCamera.cpp | 7561 | -| section.cpp | 7985 | JSTObjectGameActor.cpp | 9285 | -| sysShapeModel.cpp | 15500 | titleSection.cpp | 19740 | -| JSTObjectActor.cpp | 20961 | JSTObjectSystem.cpp | 22652 | +| section.cpp | 7740 | JSTObjectGameActor.cpp | 9275 | +| sysShapeModel.cpp | 15503 | titleSection.cpp | 19706 | +| JSTObjectActor.cpp | 20176 | JSTObjectSystem.cpp | 22652 | | matMath.cpp | 26236 | moviePlayer.cpp | 26415 | -| windowMessage.cpp | 29493 | system.cpp | 29894 | -| memoryCard.cpp | 31375 | bootSection.cpp | 38584 | -| movieMessage.cpp | 44324 | pikmin2MemoryCardMgr.cpp | 51639 | -| graphics.cpp | 76184 | messageRendering.cpp | 88271 | +| windowMessage.cpp | 29714 | system.cpp | 29894 | +| memoryCard.cpp | 31280 | bootSection.cpp | 38584 | +| movieMessage.cpp | 44386 | pikmin2MemoryCardMgr.cpp | 51733 | +| graphics.cpp | 76138 | messageRendering.cpp | 89561 | ###
utilityU
| File | Size (bytes) | File | Size (bytes) | diff --git a/include/Caption.h b/include/Caption.h index 4cc51da0a..30b9b4bbc 100644 --- a/include/Caption.h +++ b/include/Caption.h @@ -2,6 +2,7 @@ #define _CAPTION_H #include "CNode.h" +#include "BitFlag.h" struct Graphics; struct Stream; @@ -47,7 +48,7 @@ struct Mgr : public CNode { P2JME::Caption::TControl* mControls; // _18 Node* mNode; // _1C - u8 _20[4]; // _20 + BitFlag mUnusedFlags; // _20 }; } // namespace Caption diff --git a/include/Game/Data.h b/include/Game/Data.h index 9baaa3714..9123bc6cd 100644 --- a/include/Game/Data.h +++ b/include/Game/Data.h @@ -125,6 +125,9 @@ struct PlayCommonData { namespace CommonSaveData { // Size: 0x48 struct Mgr : public PlayCommonData { + + enum Flags { SaveFlag_SerialNoSet = 1 }; + enum SoundMode { SM_Mono = 0, SM_Stereo = 1, SM_SurroundSound = 2 }; Mgr(); @@ -146,7 +149,7 @@ struct Mgr : public PlayCommonData { void setDeflicker(); void setDeflicker(bool); - int _18; // _18 + int mSaveCount; // _18, how many times the game has been saved, doesn't seem to have a purpose u32 mTime; // _1C char mFileIndex; // _20 char padding; // _21 diff --git a/include/Game/Entities/ItemBridge.h b/include/Game/Entities/ItemBridge.h index 9efa8623d..7e162f36b 100644 --- a/include/Game/Entities/ItemBridge.h +++ b/include/Game/Entities/ItemBridge.h @@ -142,7 +142,7 @@ struct Item : public WorkItem { // _00-_1EC = WorkItem Mabiki mMabiki; // _1EC f32 mFaceDir; // _1F4 - u8 _1F8; // _1F8 + u8 mBreakDelay; // _1F8 WayPoint* mBridgeWP; // _1FC, follows bridge as it unfurls WayPoint* mEndWP; // _200, waypoint on other side of bridge PlatInstanceAttacher mPlatInstanceAttacher; // _204 diff --git a/include/Game/Entities/ItemGate.h b/include/Game/Entities/ItemGate.h index aac4262af..9dc6027f3 100644 --- a/include/Game/Entities/ItemGate.h +++ b/include/Game/Entities/ItemGate.h @@ -154,7 +154,7 @@ struct ItemGate : public WorkItem { efx::TEgateA* mEgateEfxA; // _21C efx::TEgateBC* mEgateEfxBC; // _220 Plane mPlanes[4]; // _224 - Vector3f _264; // _264 + Vector3f mGateDirection; // _264 Vector3f _270; // _270 u8 mColor; // _27C Sys::MatBaseAnimator* mMatAnimator; // _280 diff --git a/include/Game/GameSystem.h b/include/Game/GameSystem.h index 143d2922c..212be6762 100644 --- a/include/Game/GameSystem.h +++ b/include/Game/GameSystem.h @@ -22,7 +22,7 @@ enum GameSystemMode { }; enum GameSystemFlags { - GAMESYS_IsSoundFXActive = 0x1, // set when sound effects are enabled + GAMESYS_IsSoundSceneActive = 0x1, // set when a scene for audio is loaded GAMESYS_IsPlaying = 0x2, // set when the game is running GAMESYS_DisableCollision = 0x4, // disables collision detection GAMESYS_DisablePause = 0x8, // while enabled, time of day will not advance, and the game cannot be paused diff --git a/include/Game/NaviState.h b/include/Game/NaviState.h index 5f806847c..1c826d5ac 100644 --- a/include/Game/NaviState.h +++ b/include/Game/NaviState.h @@ -370,7 +370,7 @@ struct NaviFlickState : public NaviState { // _00 = VTBL // _00-_10 = NaviState - s32 _10; // _10 + s32 mSubState; // _10 Creature* mFlicker; // _14 Vector3f mDirection; // _18 f32 mDamage; // _24 diff --git a/include/Game/THPPlayer.h b/include/Game/THPPlayer.h index 2d3adf616..18731f364 100644 --- a/include/Game/THPPlayer.h +++ b/include/Game/THPPlayer.h @@ -47,7 +47,7 @@ struct THPPlayer : public JKRDisposer, public CNode { struct THPPlayerFileSettingTable { const char* mThpFilePath; // _00 const char* mIniFilePath; // _04 - u8 _08; // _08, unknown + u8 mDrawPosType; // _08 EMovieIndex mThpID; // _0C }; @@ -89,7 +89,7 @@ struct THPPlayer : public JKRDisposer, public CNode { DvdThreadCommand mThreadCommand; // _5C Delegate _C8; // _C8 THPPlayerLoadResourceArg mLoadResArg; // _DC - u8 _E4; // _E4 + u8 mDrawPosType; // _E4 u32 : 0; // reset alignment u8 _E8; // _E8 }; diff --git a/include/Game/gameChallenge2D.h b/include/Game/gameChallenge2D.h index cf6dd6df2..cde7bcdf1 100644 --- a/include/Game/gameChallenge2D.h +++ b/include/Game/gameChallenge2D.h @@ -56,7 +56,7 @@ struct Challenge2D_ResultInfo { struct Vs2D_TitleInfo { struct Info { Info(); - u32 mInfo; // _00 + u32 mIndex; // _00 }; Vs2D_TitleInfo(int stageNum); diff --git a/include/GameFlow.h b/include/GameFlow.h index 7cf62b60f..ccb11351f 100644 --- a/include/GameFlow.h +++ b/include/GameFlow.h @@ -79,27 +79,6 @@ struct GameFlow : public ISectionMgr { */ ~GameFlow(); - /** - * @brief Runs the game. - */ - inline void runGame() - { - JKRExpHeap* expHeap; - JKRHeap* parentHeap; - JKRHeap::TState state(parentHeap = JKRHeap::sCurrentHeap); - parentHeap->state_register(&state, -1); - expHeap = makeExpHeap(parentHeap->getFreeSize(), parentHeap, true); - - setSection(); - - mSection->init(); - mSection->run(); - mSection->exit(); - - expHeap->destroy(); - parentHeap->becomeCurrentHeap(); - } - /** * @brief Loops infinitely, calling runGame() each time. */ diff --git a/include/JSystem/J3D/J3DTypes.h b/include/JSystem/J3D/J3DTypes.h index 21e18cd8e..2ded87013 100644 --- a/include/JSystem/J3D/J3DTypes.h +++ b/include/JSystem/J3D/J3DTypes.h @@ -25,7 +25,7 @@ enum J3DModelLoaderFlagTypes { = J3DMLF_MtxSoftImageCalc | J3DMLF_MtxMayaCalc | J3DMLF_MtxBasicCalc | J3DMLF_04, // 0 - 2 (0 = Basic, 1 = SoftImage, 2 = Maya) J3DMLF_UseImmediateMtx = 0x00000010, - J3DMLF_06 = 0x00000020, + J3DMLF_UsePostTexMtx = 0x00000020, J3DMLF_07 = 0x00000040, J3DMLF_08 = 0x00000080, J3DMLF_NoMatrixTransform = 0x00000100, @@ -33,12 +33,12 @@ enum J3DModelLoaderFlagTypes { J3DMLF_11 = 0x00000400, J3DMLF_12 = 0x00000800, J3DMLF_13 = 0x00001000, - J3DMLF_14 = 0x00002000, + J3DMLF_DoBdlMaterialCalc = 0x00002000, J3DMLF_15 = 0x00004000, J3DMLF_16 = 0x00008000, J3DMLF_TevNumShift = 0x00010000, J3DMLF_18 = 0x00020000, - J3DMLF_19 = 0x00040000, + J3DMLF_UseSingleSharedDL = 0x00040000, J3DMLF_20 = 0x00080000, J3DMLF_21 = 0x00100000, J3DMLF_UseUniqueMaterials = 0x00200000, diff --git a/include/LoadResource.h b/include/LoadResource.h index 9ccec5528..29aec9163 100644 --- a/include/LoadResource.h +++ b/include/LoadResource.h @@ -38,8 +38,8 @@ struct Arg { int mAramID; // _20 int* mDvdFileCompression; // _24 u32* mNewSize; // _28 - u8 mUseAram; // _2C - u8 mUseDVD; // _2D + bool mUseAram; // _2C + bool mUseDVD; // _2D }; struct ArgAramOnly : Arg { diff --git a/include/P2JME/Caption.h b/include/P2JME/Caption.h index 015c85f02..f7d1cc1a6 100644 --- a/include/P2JME/Caption.h +++ b/include/P2JME/Caption.h @@ -15,7 +15,7 @@ struct TRenderingProcessor : public P2JME::Window::TRenderingProcessor { // _00 = VTBL // _00-_144 = P2JME::Window::TRenderingProcessor - f32 _144; // _144 + f32 mDrawAlphaLevel; // _144 0 to 1, used for telling when fade out is done }; struct TSequenceProcessor : public P2JME::Window::TSequenceProcessor { @@ -50,10 +50,10 @@ struct TControl : public P2JME::Window::TControl { // _00 = VTBL // _00-_5C = P2JME::Window::TControl - int mState; // _5C - int mStartFrame; // _60 - int mEndFrame; // _64 - int _68; // _68, unknown + int mState; // _5C + int mStartFrame; // _60 + int mEndFrame; // _64 + int mFadeoutFrameLength; // _68 }; } // namespace Caption diff --git a/include/P2JME/IllustratedBook.h b/include/P2JME/IllustratedBook.h index e1e91920f..1c8b5928e 100644 --- a/include/P2JME/IllustratedBook.h +++ b/include/P2JME/IllustratedBook.h @@ -57,7 +57,7 @@ struct TControl : public P2JME::Window::TControl { f32 mCurrentTextHeight; // _60 J2DTextBox* mTextBox; // _64 f32 mMaxScroll; // _68 - f32 _6C; // _6C + f32 mScrollVal; // _6C f32 mScrollSpeed; // _70 }; diff --git a/include/P2JME/Movie.h b/include/P2JME/Movie.h index eaef9d76a..5c82db49d 100644 --- a/include/P2JME/Movie.h +++ b/include/P2JME/Movie.h @@ -49,9 +49,9 @@ struct AbtnPane : public P2DScreen::CallBackNode { // _00 = VTBL // _00-_1C = P2DScreen::CallBackNode - u32 mState; // _1C - f32 mTimer1; // _20 - f32 mTimer2; // _24 + u32 mState; // _1C, 0 = inactive, 1 = active + f32 mAnimAlpha; // _20, used to make button alpha change over time + f32 mAppearAlpha; // _24, goes from 0 to 1 when the button should be visible }; struct MessageWindowScreen : P2DScreen::Mgr_tuning { @@ -121,6 +121,8 @@ struct TControl : public P2JME::Window::TControl { MODEFLAG_Finish = 3, }; + enum ControlFlag { ControlFlag_UnsuspendOnFinish = 1 }; + TControl(); virtual ~TControl() { } // _08 (weak) @@ -138,11 +140,8 @@ struct TControl : public P2JME::Window::TControl { J2DPane* mPaneMgDemo; // _64 bool mIsActive; // _68 EModeFlag mModeFlag; // _6C - union { - u8 bytesView[4]; - u32 dwordView; - } mFlags; // _70 - u8 mIsPaused; // _74 + BitFlag mFlags; // _70 + u8 mIsPaused; // _74 }; } // namespace Movie } // namespace P2JME diff --git a/include/P2JME/TSequenceProcessor.h b/include/P2JME/TSequenceProcessor.h index 86eacdd60..23c3ef70c 100644 --- a/include/P2JME/TSequenceProcessor.h +++ b/include/P2JME/TSequenceProcessor.h @@ -10,6 +10,13 @@ namespace P2JME { struct TSequenceProcessor : public JMessage::TSequenceProcessor { TSequenceProcessor(const JMessage::TReference*, JMessage::TControl*); + enum seqProcFlags { + SeqProc_IsActive = 0x1, // Active when text is being written + SeqProc_IsWaitingPressA = 0x2, // Text page finished, waiting for confirmation + SeqProc_IsWriting = 0x4, // Set while text is writing, unset when waiting for press A + SeqProc_IsForceFinish = 0x8, // Pressed B to force finish page + }; + virtual ~TSequenceProcessor() { } // _08 (weak) virtual void do_character(int); // _10 virtual bool do_tag(u32, const void*, u32); // _14 @@ -33,20 +40,21 @@ struct TSequenceProcessor : public JMessage::TSequenceProcessor { void setAbtnWait(); void resetAbtnWait(); + inline void setFlag(u8 flag) { mFlags.typeView |= flag; } + inline void resetFlag(u8 flag) { mFlags.typeView &= ~flag; } + inline bool isFlag(u8 flag) const { return mFlags.typeView & flag; } + // _00 = VTBL // _00-_4C = JMessage::TSequenceProcessor - f32 _4C; // _4C - f32 _50; // _50 - Controller* mController1; // _54 - Controller* mController2; // _58 - int _5C; // _5C - u32 _60; // _60 - u32 _64; // _64 - BitFlag mFlags; // _68 - u8 _6C; // _6C - s8 _6D; // _6D - s8 _6E; // _6E - s8 _6F; // _6F + f32 mPageFinishWaitDuration; // _4C, how long to delay input after a text page finishes, usually 0.11f + f32 mPageFinishWaitTimer; // _50, set to above value on page finish, must be 0 to proceed + Controller* mController1; // _54 + Controller* mController2; // _58 + int mCharactersWritten; // _5C, increments for each character written, when 0 the start sound will play + u32 mUnused0; // _60 + u32 mUnused1; // _64 + BitFlag mFlags; // _68 + u8 mFastSeType; // _6C, when 1 or 2, the ship voice uses the "fast" setting }; struct TSeqProcNoSeq : public TSequenceProcessor { diff --git a/include/P2JME/messageObj.h b/include/P2JME/messageObj.h index 8b858afc2..28865dc33 100644 --- a/include/P2JME/messageObj.h +++ b/include/P2JME/messageObj.h @@ -81,7 +81,7 @@ struct DrawInfo : public CNode { // _00 = VTBL // _00-_18 = CNode - u32 _18; // _18 + u32 mIndex; // _18 f32 mTimer; // _1C f32 mTimeLimit; // _20 }; @@ -133,7 +133,7 @@ struct TSequenceProcessor : public P2JME::TSequenceProcessor { inline bool isFastSE() { bool ret = false; - switch (_6C) { + switch (mFastSeType) { case 0: break; case 1: @@ -169,7 +169,8 @@ struct TControl : public P2JME::TControl { { mSequenceProc = new TSequenceProcessor(getReference(), this); } - void initRenderingProcessor(u32); + + void initRenderingProcessor(u32 animCount); // _00 = VTBL // _00-_50 = P2JME::TControl diff --git a/include/P2JME/messageRendering.h b/include/P2JME/messageRendering.h index 916954373..502ac8d5c 100644 --- a/include/P2JME/messageRendering.h +++ b/include/P2JME/messageRendering.h @@ -120,59 +120,58 @@ struct TRenderingProcessor : public TRenderingProcessorBase { // _00 = VTBL // _00-_38 = JMessage::TRenderingProcessor - f32 mTextBoxWidth; // _38 - f32 mTextBoxHeight; // _3C - int _40; // _40 - Matrixf* mMtx1; // _44 - Matrixf* mMtx2; // _48 - JUTFont* mMainFont; // _4C - JUTFont* mRubyFont; // _50 - f32 _54; // _54 - f32 _58; // _58 - JUtility::TColor _5C; // _5C - JUtility::TColor _60; // _60 - JUtility::TColor mColorData1; // _64 - JUtility::TColor mColorData2; // _68 - JUtility::TColor mColorData3; // _6C - JUtility::TColor mColorData4; // _70 - JUtility::TColor mColorData5; // _74 - f32 _78; // _78 - JGeometry::TBox2f mMesgBounds; // _7C - BitFlag mFlags; // _8C - JGeometry::TBox2f mLocate; // _90 - u32 _A0; // _A0 - u8 mCurrLine; // _A4 - u8 mParagraphNum; // _A5 - u8 mPageInfoNum; // _A6 - u8 _A7; // _A7 - f32* mLineWidths; // _A8 - u8* mOnePageLines; // _AC - u8* mPageInfoCounts; // _B0 - f32 _B4; // _B4 - s32 mCharacterNum; // _B8 - f32 _BC; // _BC - f32 _C0; // _C0 - f32 _C4; // _C4 - f32 mLineHeight; // _C8 - JUtility::TColor _CC; // _CC - JUtility::TColor _D0; // _D0 - JUtility::TColor _D4; // _D4 - JUtility::TColor _D8; // _D8 - u8 mMatrixType; // _DC - f32 mFontWidthAdjusted; // _E0 - f32 mFontHeightAdjusted; // _E4 - f32 mFontWidth; // _E8 - f32 mFontHeight; // _EC - u8 _F0; // _F0 - u8 _F1; // _F1 - u8 _F2; // _F2 - u32 _F4; // _F4 - u8 _F8; // _F8 - u32 _FC; // _FC - char* mRubyBuffer; // _100 - f32 _104; // _104 - f32 _108; // _108 - f32 _10C; // _10C + f32 mTextBoxWidth; // _38 + f32 mTextBoxHeight; // _3C + int mInfoIndex; // _40 + Matrixf* mMtx1; // _44 + Matrixf* mMtx2; // _48 + JUTFont* mMainFont; // _4C + JUTFont* mRubyFont; // _50 + f32 mXOffset; // _54 + f32 mYOffset; // _58 + JUtility::TColor mImageColorA; // _5C + JUtility::TColor mImageColorB; // _60 + JUtility::TColor mColorData1; // _64 + JUtility::TColor mColorData2; // _68 + JUtility::TColor mColorData3; // _6C + JUtility::TColor mColorData4; // _70 + JUtility::TColor mColorData5; // _74 + f32 mBaseAlphaModifier; // _78 + JGeometry::TBox2f mMesgBounds; // _7C + BitFlag mFlags; // _8C + JGeometry::TBox2f mLocate; // _90 + u32 mSelectSeparateNum; // _A0 + u8 mCurrLine; // _A4 + u8 mParagraphNum; // _A5 + u8 mPageInfoNum; // _A6 + f32* mLineWidths; // _A8 + u8* mOnePageLines; // _AC + u8* mPageInfoCounts; // _B0 + f32 _B4; // _B4 + s32 mCharacterNum; // _B8 + f32 mActiveCharWidth; // _BC + f32 mActiveLineHeight; // _C0 + f32 mCharacterWidth; // _C4 + f32 mLineHeight; // _C8 + JUtility::TColor mDefaultWhite; // _CC + JUtility::TColor mDefaultBlack; // _D0 + JUtility::TColor mDefaultCharColor; // _D4 + JUtility::TColor mDefaultGradColor; // _D8 + u8 mMatrixType; // _DC + f32 mFontWidthAdjusted; // _E0 + f32 mFontHeightAdjusted; // _E4 + f32 mFontWidth; // _E8 + f32 mFontHeight; // _EC + u8 mCurrColorIndex; // _F0 + u8 mSecondaryColorIndex; // _F1 + u8 mDoDrawRuby; // _F2 + u32 mRubyStartCharIndex; // _F4 + u8 mRubyCurrentStringSize; // _F8 + u32 mRubyBufferCurrentSize; // _FC + char* mRubyBuffer; // _100 + f32 mRubyCurrentXPos; // _104 + f32 mRubyCurrentYPos; // _108 + f32 mRubyWidthModifier; // _10C }; } // namespace P2JME diff --git a/include/PSSystem/PSScene.h b/include/PSSystem/PSScene.h index a3d4736cf..a2cf39bbf 100644 --- a/include/PSSystem/PSScene.h +++ b/include/PSSystem/PSScene.h @@ -114,6 +114,14 @@ struct SceneMgr { mScenes->mChild->stopMainSeq(time); } + inline void doStopMainSeqCheck(u32 time) + { + checkScene(); + Scene* scene = mScenes->mChild; + if (scene) + scene->stopMainSeq(time); + } + inline Scene* getChild() { checkScene(); diff --git a/include/Vector2.h b/include/Vector2.h index 9f6779b0f..73a2af184 100644 --- a/include/Vector2.h +++ b/include/Vector2.h @@ -35,7 +35,7 @@ struct Vector2 { inline f32 angleBetween(Vector2& other) { - f32 angle = JMath::atanTable_.atan2_((this->y - other.y), -(this->x - other.x)); + f32 angle = JMAAtan2Radian((this->y - other.y), -(this->x - other.x)); return angle; } diff --git a/src/JSystem/J2D/J2DScreen.cpp b/src/JSystem/J2D/J2DScreen.cpp index 5b7e849fa..79fe66423 100644 --- a/src/JSystem/J2D/J2DScreen.cpp +++ b/src/JSystem/J2D/J2DScreen.cpp @@ -922,7 +922,7 @@ J2DResReference* J2DScreen::getResReference(JSURandomInputStream* input, u32 fla input->seek(initialPosition + size2, SEEK_SET); size1 = size1 - size2; char* data; - if (flags & (J3DMLF_TevNumShift | J3DMLF_18 | J3DMLF_19 | J3DMLF_20 | J3DMLF_21)) { + if (flags & (J3DMLF_TevNumShift | J3DMLF_18 | J3DMLF_UseSingleSharedDL | J3DMLF_20 | J3DMLF_21)) { data = new char[size1]; } else { data = new (-4) char[size1]; diff --git a/src/JSystem/J3D/J3DModelData.cpp b/src/JSystem/J3D/J3DModelData.cpp index 51b0c26d9..89fa98f2c 100644 --- a/src/JSystem/J3D/J3DModelData.cpp +++ b/src/JSystem/J3D/J3DModelData.cpp @@ -38,7 +38,7 @@ void J3DModelData::newSharedDisplayList(u32 flags) { const u16 count = mMaterialTable.getMaterialNum(); for (u16 i = 0; i < count; i++) { - if (flags & J3DMLF_19) { + if (flags & J3DMLF_UseSingleSharedDL) { mMaterialTable.getMaterialNodePointer(i)->newSingleSharedDisplayList(mMaterialTable.getMaterialNodePointer(i)->countDLSize()); } else { mMaterialTable.getMaterialNodePointer(i)->newSharedDisplayList(mMaterialTable.getMaterialNodePointer(i)->countDLSize()); @@ -107,7 +107,7 @@ void J3DModelData::simpleCalcMaterial(u16 jointIndex, Mtx mtx) */ void J3DModelData::syncJ3DSysFlags() const { - if (mModelLoaderFlags & J3DMLF_06) { + if (mModelLoaderFlags & J3DMLF_UsePostTexMtx) { j3dSys.mFlags |= 0x40000000; } else { j3dSys.mFlags &= ~0x40000000; diff --git a/src/JSystem/J3D/J3DModelLoaderCalcSize.cpp b/src/JSystem/J3D/J3DModelLoaderCalcSize.cpp index 26d792937..d234f0f83 100644 --- a/src/JSystem/J3D/J3DModelLoaderCalcSize.cpp +++ b/src/JSystem/J3D/J3DModelLoaderCalcSize.cpp @@ -344,10 +344,10 @@ int J3DModelLoader::calcLoadBinaryDisplayListSize(const void* stream, u32 flags) case J3DFBT_Material: mMaterialBlock = (const J3DMaterialBlock*)nextBlock; matFlags |= (J3DMLF_21 | J3DMLF_Material_PE_Full | J3DMLF_Material_Color_LightOn); - if ((flags & (J3DMLF_13 | J3DMLF_14)) == 0) { + if ((flags & (J3DMLF_13 | J3DMLF_DoBdlMaterialCalc)) == 0) { _18 = 1; size += calcSizeMaterial((const J3DMaterialBlock*)nextBlock, matFlags); - } else if ((flags & (J3DMLF_13 | J3DMLF_14)) == J3DMLF_14) { + } else if ((flags & (J3DMLF_13 | J3DMLF_DoBdlMaterialCalc)) == J3DMLF_DoBdlMaterialCalc) { _18 = 1; size += calcSizePatchedMaterial((const J3DMaterialBlock*)nextBlock, matFlags); } diff --git a/src/plugProjectEbisawaU/ebiP2TitleChappy.cpp b/src/plugProjectEbisawaU/ebiP2TitleChappy.cpp index d740672bd..993636ffd 100644 --- a/src/plugProjectEbisawaU/ebiP2TitleChappy.cpp +++ b/src/plugProjectEbisawaU/ebiP2TitleChappy.cpp @@ -76,8 +76,8 @@ void Chappy::TAnimator::setArchive(JKRArchive* arc) void* file = arc->getResource("chappy/swallow_model.bmd"); P2ASSERTLINE(122, file); - mModelData = J3DModelLoaderDataBase::load(file, 0x100000); - mModelData->newSharedDisplayList(0x40000); + mModelData = J3DModelLoaderDataBase::load(file, J3DMLF_21); + mModelData->newSharedDisplayList(J3DMLF_UseSingleSharedDL); mModelData->makeSharedDL(); mAnimFolder.load(mModelData, arc); @@ -202,7 +202,7 @@ void Chappy::TUnit::startAIState_(enumAIState state) case CHAPPYAI_Turn: { f32 angle = mManager->mParams.mWalkAngleRand.mValue; - f32 angleBetweenPos = JMath::atanTable_.atan2_(mTargetPos.y - mPosition.y, mTargetPos.x - mPosition.x); + f32 angleBetweenPos = JMAAtan2Radian(mTargetPos.y - mPosition.y, mTargetPos.x - mPosition.x); f32 final = angle * DEG2RAD * PI * (randEbisawaFloat() * 2.0f + -1.0f) + angleBetweenPos; mTargetAngle = Vector2f(cosf(final), sinf(final)); break; @@ -328,8 +328,8 @@ void Chappy::TUnit::update() break; case CHAPPYAI_Turn: - f32 initAngle = JMath::atanTable_.atan2_(mAngle.y, mAngle.x); - f32 angle = initAngle - JMath::atanTable_.atan2_(mTargetAngle.y, mTargetAngle.x); + f32 initAngle = JMAAtan2Radian(mAngle.y, mAngle.x); + f32 angle = initAngle - JMAAtan2Radian(mTargetAngle.y, mTargetAngle.x); while (angle < -PI) { angle += TAU; } diff --git a/src/plugProjectEbisawaU/ebiP2TitleKogane.cpp b/src/plugProjectEbisawaU/ebiP2TitleKogane.cpp index 7e51d1583..31cbc94ca 100644 --- a/src/plugProjectEbisawaU/ebiP2TitleKogane.cpp +++ b/src/plugProjectEbisawaU/ebiP2TitleKogane.cpp @@ -66,13 +66,14 @@ void TAnimator::setArchive(JKRArchive* arc) { void* file = arc->getResource("kogane/kogane_title.bmd"); P2ASSERTLINE(0x75, file); - mModelData = J3DModelLoaderDataBase::load(file, 0x240030); + mModelData = J3DModelLoaderDataBase::load(file, J3DMLF_UseUniqueMaterials | J3DMLF_UseSingleSharedDL | J3DMLF_UsePostTexMtx + | J3DMLF_UseImmediateMtx); for (u16 i = 0; i < mModelData->getShapeNum(); i++) { mModelData->getShapeNodePointer(i)->setTexMtxLoadType(0x2000); } - mModelData->newSharedDisplayList(0x40000); + mModelData->newSharedDisplayList(J3DMLF_UseSingleSharedDL); mModelData->makeSharedDL(); mAnimFolder.load(mModelData, arc); } @@ -175,7 +176,7 @@ void TUnit::startState(enumState state) break; case KSTATE_Turn: f32 angle = mManager->mParams.mWalkRandomAngle.mValue; - f32 line = JMath::atanTable_.atan2_(mTargetPos.y - mPosition.y, mTargetPos.x - mPosition.x); + f32 line = JMAAtan2Radian(mTargetPos.y - mPosition.y, mTargetPos.x - mPosition.x); f32 test = angle * DEG2RAD * PI * (randEbisawaFloat() * 2.0f + -1.0f) + line; mTargetAngle = Vector2f(cosf(test), sinf(test)); break; diff --git a/src/plugProjectEbisawaU/ebiP2TitlePikmin.cpp b/src/plugProjectEbisawaU/ebiP2TitlePikmin.cpp index f7b61fb82..783434340 100644 --- a/src/plugProjectEbisawaU/ebiP2TitlePikmin.cpp +++ b/src/plugProjectEbisawaU/ebiP2TitlePikmin.cpp @@ -102,19 +102,19 @@ void Pikmin::TAnimator::setArchive(JKRArchive* arc) void* file; file = arc->getResource("pikmin/title_red_piki.bmd"); P2ASSERTLINE(176, file); - mModelDataRed = J3DModelLoaderDataBase::load(file, 0x20100000); + mModelDataRed = J3DModelLoaderDataBase::load(file, J3DMLF_Material_PE_FogOff | J3DMLF_21); file = arc->getResource("pikmin/title_yellow_piki.bmd"); P2ASSERTLINE(186, file); - mModelDataYellow = J3DModelLoaderDataBase::load(file, 0x20100000); + mModelDataYellow = J3DModelLoaderDataBase::load(file, J3DMLF_Material_PE_FogOff | J3DMLF_21); file = arc->getResource("pikmin/title_blue_piki.bmd"); P2ASSERTLINE(196, file); - mModelDataBlue = J3DModelLoaderDataBase::load(file, 0x20100000); + mModelDataBlue = J3DModelLoaderDataBase::load(file, J3DMLF_Material_PE_FogOff | J3DMLF_21); file = arc->getResource("pikmin/title_black_piki.bmd"); P2ASSERTLINE(206, file); - mModelDataPurple = J3DModelLoaderDataBase::load(file, 0x20100000); + mModelDataPurple = J3DModelLoaderDataBase::load(file, J3DMLF_Material_PE_FogOff | J3DMLF_21); file = arc->getResource("pikmin/title_white_piki.bmd"); P2ASSERTLINE(216, file); - mModelDataWhite = J3DModelLoaderDataBase::load(file, 0x20100000); + mModelDataWhite = J3DModelLoaderDataBase::load(file, J3DMLF_Material_PE_FogOff | J3DMLF_21); file = arc->getResource("pikmin/wait.bck"); P2ASSERTLINE(228, file); mWaitAnim = (J3DAnmTransform*)J3DAnmLoaderDataBase::load(file); diff --git a/src/plugProjectEbisawaU/ebiP2TitleUnit.cpp b/src/plugProjectEbisawaU/ebiP2TitleUnit.cpp index cea67f5b2..befed4287 100644 --- a/src/plugProjectEbisawaU/ebiP2TitleUnit.cpp +++ b/src/plugProjectEbisawaU/ebiP2TitleUnit.cpp @@ -94,7 +94,7 @@ void TMapBase::setArchive(JKRArchive* arc) { void* file = arc->getResource("opening.bmd"); P2ASSERTLINE(96, file); - mMainModelData = J3DModelLoaderDataBase::load(file, 0x20100000); + mMainModelData = J3DModelLoaderDataBase::load(file, J3DMLF_Material_PE_FogOff | J3DMLF_21); file = arc->getResource("opening_wait.bck"); P2ASSERTLINE(106, file); @@ -191,7 +191,7 @@ void TBGEnemyBase::setArchive(JKRArchive* arc) { void* file = arc->getResource("enemy.bmd"); P2ASSERTLINE(199, file); - mMainModelData = J3DModelLoaderDataBase::load(file, 0x20100000); + mMainModelData = J3DModelLoaderDataBase::load(file, J3DMLF_Material_PE_FogOff | J3DMLF_21); file = arc->getResource("enemy.bck"); P2ASSERTLINE(209, file); @@ -243,7 +243,7 @@ void TBlackPlane::setArchive(JKRArchive* arc) { void* file = arc->getResource("cam.bmd"); P2ASSERTLINE(258, file); - mMainModelData = J3DModelLoaderDataBase::load(file, 0x10100000); + mMainModelData = J3DModelLoaderDataBase::load(file, J3DMLF_Material_PE_Full | J3DMLF_21); file = arc->getResource("cam.bck"); P2ASSERTLINE(268, file); @@ -264,7 +264,7 @@ void TBlackPlane::setArchive(JKRArchive* arc) for (u16 i = 0; i < mModel->getModelData()->getMaterialNum(); i++) { J3DMaterialAnm* anm = new J3DMaterialAnm; mModel->mModelData->getMaterialNodePointer(i)->change(); - mModel->mModelData->getMaterialNodePointer(i)->mMaterialAnm = anm; + mModel->mModelData->getMaterialNodePointer(i)->setMaterialAnm(anm); } j3dSys.ErrorReport(mModel->mModelData->getMaterialTable().entryTevRegAnimator(mAnimColor)); diff --git a/src/plugProjectKandoU/baseGameSection.cpp b/src/plugProjectKandoU/baseGameSection.cpp index e18b75511..e6a0fb42e 100644 --- a/src/plugProjectKandoU/baseGameSection.cpp +++ b/src/plugProjectKandoU/baseGameSection.cpp @@ -634,10 +634,7 @@ void BaseGameSection::initGenerators() if (defaultGenFile) { RamStream defaultGenTxt(defaultGenFile, -1); - defaultGenTxt.mMode = 1; - if (defaultGenTxt.mMode == 1) { - defaultGenTxt.mTabCount = 0; - } + defaultGenTxt.setMode(STREAM_MODE_TEXT, 1); generatorMgr->read(defaultGenTxt, false); generatorMgr->updateUseList(); @@ -680,10 +677,7 @@ void BaseGameSection::initGenerators() void* initgenFile = LoadTextFile(filenameCharArr); if (initgenFile) { RamStream initgenTxt(initgenFile, -1); - initgenTxt.mMode = 1; - if (initgenTxt.mMode == 1) { - initgenTxt.mTabCount = 0; - } + initgenTxt.setMode(STREAM_MODE_TEXT, 1); onceGeneratorMgr->read(initgenTxt, false); onceGeneratorMgr->updateUseList(); generatorFiles[fileIdx] = initgenFile; @@ -711,10 +705,7 @@ void BaseGameSection::initGenerators() if (nonLoopFile) { RamStream noonloopTxt(nonLoopFile, -1); - noonloopTxt.mMode = 1; - if (noonloopTxt.mMode == 1) { - noonloopTxt.mTabCount = 0; - } + noonloopTxt.setMode(STREAM_MODE_TEXT, 1); GeneratorMgr* currentNonloopMgr = new GeneratorMgr; currentNonloopMgr->mUnusedFlag = true; // is nonrepeating? @@ -765,10 +756,7 @@ void BaseGameSection::initGenerators() void* loopFile = LoadTextFile(filenameCharArr); if (loopFile) { RamStream loopTxt(loopFile, -1); - loopTxt.mMode = 1; - if (loopTxt.mMode == 1) { - loopTxt.mTabCount = 0; - } + loopTxt.setMode(STREAM_MODE_TEXT, 1); GeneratorMgr* currentLoopMgr = new GeneratorMgr; currentLoopMgr->mUnusedFlag = true; // is nonrepeating? @@ -796,10 +784,7 @@ void BaseGameSection::initGenerators() void* dayFile = LoadTextFile(filenameCharArr); if (dayFile) { RamStream dayTxt(dayFile, -1); - dayTxt.mMode = 1; - if (dayTxt.mMode == 1) { - dayTxt.mTabCount = 0; - } + dayTxt.setMode(STREAM_MODE_TEXT, 1); dayGeneratorMgr->read(dayTxt, false); dayGeneratorMgr->updateUseList(); generatorFiles[fileIdx] = dayFile; @@ -2086,7 +2071,7 @@ bool BaseGameSection::isAllocHalt() void BaseGameSection::setupFloatMemory() { bool cave = false; - gameSystem->mFlags.typeView &= 0xFE; // this matches, but it's a bit odd + gameSystem->resetFlag(GAMESYS_IsSoundSceneActive); PSSystem::SingletonBase::newInstance(); PSSystem::SingletonBase::newInstance(); @@ -2296,7 +2281,7 @@ void BaseGameSection::setupFloatMemory() pelletMgr->setupSoundViewerAndBas(); onSetSoundScene(); - gameSystem->setFlag(GAMESYS_IsSoundFXActive); + gameSystem->setFlag(GAMESYS_IsSoundSceneActive); if (Farm::farmMgr) { Farm::farmMgr->setupSound(); } diff --git a/src/plugProjectKandoU/efxModelObjects.cpp b/src/plugProjectKandoU/efxModelObjects.cpp index 4c71496d6..91d0ffaf1 100644 --- a/src/plugProjectKandoU/efxModelObjects.cpp +++ b/src/plugProjectKandoU/efxModelObjects.cpp @@ -69,7 +69,7 @@ void OnyonSpotData::loadResources() void* file = JKRFileLoader::getGlbResource("onyonspot.bmd", nullptr); P2ASSERTLINE(95, file); - J3DModelData* model = J3DModelLoaderDataBase::load(file, J3DMLF_Material_PE_FogOff | 0x1020000); + J3DModelData* model = J3DModelLoaderDataBase::load(file, J3DMLF_Material_PE_FogOff | J3DMLF_Material_UseIndirect | J3DMLF_18); *mModelData = model; mTexAnimCount = 1; mTexAnims = new Sys::MatTexAnimation[mTexAnimCount]; diff --git a/src/plugProjectKandoU/fakePiki.cpp b/src/plugProjectKandoU/fakePiki.cpp index 68521396d..3b90be430 100644 --- a/src/plugProjectKandoU/fakePiki.cpp +++ b/src/plugProjectKandoU/fakePiki.cpp @@ -1078,7 +1078,7 @@ void FakePiki::turnTo(Vector3f& targetPos) { Vector3f diff = targetPos - mPosition; if (diff.z != 0.0f) { - mFaceDir = roundAng(JMath::atanTable_.atan2_(diff.x, diff.z)); + mFaceDir = roundAng(JMAAtan2Radian(diff.x, diff.z)); } } @@ -1160,7 +1160,7 @@ void FakePiki::moveRotation() f32 X = mTargetVelocity.x * mTargetVelocity.x; f32 Z = mTargetVelocity.z * mTargetVelocity.z; if (X + Z > 1.0f) { - f32 dist = angDist(JMath::atanTable_.atan2_(mTargetVelocity.x, mTargetVelocity.z), mFaceDir); + f32 dist = angDist(JMAAtan2Radian(mTargetVelocity.x, mTargetVelocity.z), mFaceDir); mFaceDir += 10.0f * (delta * (0.8f * dist)); mFaceDir = roundAng(mFaceDir); } diff --git a/src/plugProjectKandoU/gameChallenge2D.cpp b/src/plugProjectKandoU/gameChallenge2D.cpp index f1e0947fb..36e66c03a 100644 --- a/src/plugProjectKandoU/gameChallenge2D.cpp +++ b/src/plugProjectKandoU/gameChallenge2D.cpp @@ -54,7 +54,7 @@ Vs2D_TitleInfo::Vs2D_TitleInfo(int count) * @note Address: 0x80235214 * @note Size: 0xC */ -Vs2D_TitleInfo::Info::Info() { mInfo = 0; } +Vs2D_TitleInfo::Info::Info() { mIndex = 0; } /** * @note Address: 0x80235220 @@ -62,8 +62,7 @@ Vs2D_TitleInfo::Info::Info() { mInfo = 0; } */ Vs2D_TitleInfo::Info* Vs2D_TitleInfo::operator()(int infoIndex) { - bool amLegal = ((infoIndex >= 0)); - JUT_ASSERTLINE(52, (amLegal && (infoIndex < mInfoCount)), "ZANNEN\n"); + JUT_ASSERTLINE(52, infoIndex >= 0 && infoIndex < mInfoCount, "ZANNEN\n"); P2ASSERTBOUNDSLINE(54, 0, infoIndex, mInfoCount); return &pInfoArray[infoIndex]; } diff --git a/src/plugProjectKandoU/gameMapParts.cpp b/src/plugProjectKandoU/gameMapParts.cpp index 432891e59..12257f568 100644 --- a/src/plugProjectKandoU/gameMapParts.cpp +++ b/src/plugProjectKandoU/gameMapParts.cpp @@ -241,9 +241,8 @@ void MapUnitMgr::makeUnit(MapUnit* unit, char* folder) void* viewModelData = archive->getResource("view.bmd"); P2ASSERTLINE(657, viewModelData); - unit->mModelData = J3DModelLoaderDataBase::load(viewModelData, - 0x20000000); // 0x20000000 is some flag - unit->mModelData->newSharedDisplayList(0x40000); + unit->mModelData = J3DModelLoaderDataBase::load(viewModelData, J3DMLF_Material_PE_FogOff); + unit->mModelData->newSharedDisplayList(J3DMLF_UseSingleSharedDL); unit->mModelData->makeSharedDL(); void* textureData = archive->getResource("texture.bti"); @@ -554,7 +553,7 @@ void MapRoom::placeObjects(Cave::FloorInfo* floorInfo, bool isFinalFloor) } RoomDoorInfo* doorinfo = &mDoorInfos[doorIdx]; Vector3f birthPos = Vector3f(doorinfo->mWaypoint->mPosition); - f32 dir = JMath::atanTable_.atan2_(doorinfo->mLookAtPos.x, doorinfo->mLookAtPos.z); + f32 dir = JMAAtan2Radian(doorinfo->mLookAtPos.x, doorinfo->mLookAtPos.z); ItemGateInitArg gateArg; gateArg.mFaceDir = dir; @@ -803,8 +802,8 @@ void CaveVRBox::create(char* name) if (vrBoxArc) { void* res = vrBoxArc->getResource("model.bmd"); if (res) { - J3DModelData* model = J3DModelLoaderDataBase::load(res, 0x20000000); - model->newSharedDisplayList(0x40000); + J3DModelData* model = J3DModelLoaderDataBase::load(res, J3DMLF_Material_PE_FogOff); + model->newSharedDisplayList(J3DMLF_UseSingleSharedDL); model->makeSharedDL(); mModel = new SysShape::Model(model, 0, 2); Matrixf mtx; diff --git a/src/plugProjectKandoU/gameSeaMgr.cpp b/src/plugProjectKandoU/gameSeaMgr.cpp index 476ef905e..223a8c6fe 100644 --- a/src/plugProjectKandoU/gameSeaMgr.cpp +++ b/src/plugProjectKandoU/gameSeaMgr.cpp @@ -472,9 +472,10 @@ SeaMgr::SeaMgr() u32 flags; if (Game::gameSystem && Game::gameSystem->isMultiplayerMode()) { - flags = 0x20240010; + flags = J3DMLF_Material_PE_FogOff | J3DMLF_UseUniqueMaterials | J3DMLF_UseSingleSharedDL | J3DMLF_UseImmediateMtx; } else { - flags = 0x21240010; + flags = J3DMLF_Material_PE_FogOff | J3DMLF_Material_UseIndirect | J3DMLF_UseUniqueMaterials | J3DMLF_UseSingleSharedDL + | J3DMLF_UseImmediateMtx; } mModelData[0] = J3DModelLoaderDataBase::load(file, flags); diff --git a/src/plugProjectKandoU/interactPiki.cpp b/src/plugProjectKandoU/interactPiki.cpp index 6ee6fb887..602f0e6eb 100644 --- a/src/plugProjectKandoU/interactPiki.cpp +++ b/src/plugProjectKandoU/interactPiki.cpp @@ -639,7 +639,7 @@ bool InteractSwallow::actPiki(Game::Piki* piki) posDiff.z = pikiPos.z - enemyPos.z; posDiff.y = pikiPos.y - enemyPos.y; _normaliseXZ(posDiff); // nearly every normalize function works - f32 angle = JMath::atanTable_.atan2_(posDiff.x, posDiff.z); + f32 angle = JMAAtan2Radian(posDiff.x, posDiff.z); InteractFlick swallowFlick(mCreature, 50.0f, 0.0f, -angle); piki->stimulate(swallowFlick); return; diff --git a/src/plugProjectKandoU/itemBigFountain.cpp b/src/plugProjectKandoU/itemBigFountain.cpp index f781858a8..6ab7a6d81 100644 --- a/src/plugProjectKandoU/itemBigFountain.cpp +++ b/src/plugProjectKandoU/itemBigFountain.cpp @@ -146,7 +146,7 @@ void OutState::init(Item* item, StateArg* arg) item->mEfxGeyserSet->fade(); efx::Arg effectArg(item->mPosition); item->mEfxGeyserAct->create(&effectArg); - if (gameSystem->isFlag(GAMESYS_IsSoundFXActive)) { + if (gameSystem->isFlag(GAMESYS_IsSoundSceneActive)) { item->mSoundEvent.finish(); P2ASSERTLINE(248, item->mSoundObj->getCastType() == PSM::CCT_WorkItem); static_cast(item->mSoundObj)->eventFinish(); diff --git a/src/plugProjectKandoU/itemBridge.cpp b/src/plugProjectKandoU/itemBridge.cpp index cf49ce79d..6ff592a40 100644 --- a/src/plugProjectKandoU/itemBridge.cpp +++ b/src/plugProjectKandoU/itemBridge.cpp @@ -87,9 +87,9 @@ void Item::onInit(CreatureInitArg* settings) mStageHealths[i] = stageLength; } - mEndWP = nullptr; - mBridgeWP = nullptr; - _1F8 = 0; + mEndWP = nullptr; + mBridgeWP = nullptr; + mBreakDelay = 0; } /** @@ -274,9 +274,9 @@ void Item::doAI() break; } - if (_1F8 != 0) { - _1F8--; - if (_1F8 == 0) { + if (mBreakDelay != 0) { + mBreakDelay--; + if (mBreakDelay == 0) { setCurrStage(mCurrStageIdx + 1); if (mCurrStageIdx == mStageCount) { setAlive(false); @@ -1073,7 +1073,7 @@ bool Item::interactAttack(InteractAttack& attack) break; } - if (_1F8) { + if (mBreakDelay) { return true; } @@ -1104,7 +1104,7 @@ bool Item::interactAttack(InteractAttack& attack) nextSetFX.create(nullptr); mMabiki.mBuffer += 60; - _1F8 = 40; + mBreakDelay = 40; startSound(PSSE_EV_WORK_BRIDGE_EXTEND); } @@ -1118,7 +1118,7 @@ bool Item::interactAttack(InteractAttack& attack) */ bool Item::interactBreakBridge(InteractBreakBridge& breakBridge) { - if (_1F8 || mCurrStageIdx == 0) { + if (mBreakDelay || mCurrStageIdx == 0) { return false; } @@ -1193,7 +1193,7 @@ Mgr::Mgr() : TNodeItemMgr() { mItemName = "Bridge"; - setModelSize(3); + setModelSize(BRIDGETYPE_COUNT); mObjectPathComponent = "user/Kando/objects/bridge"; mParms = new BridgeParms(); DVDConvertPathToEntrynum("/user/Abe/item/bridgeParms.txt"); @@ -1362,7 +1362,7 @@ void Mgr::createBridgeInfo(int type) */ void Mgr::setupPlatInstanceAttacher(Item* bridge, PlatInstanceAttacher& attacher) { - P2ASSERTLINE(1186, bridge->mBridgeType < 3); + P2ASSERTLINE(1186, bridge->mBridgeType < BRIDGETYPE_COUNT); BridgeInfo* info = getBridgeInfo(bridge->mBridgeType); ID32 id('none'); attacher.addToMgr(bridge, id, mPlatAttachers[bridge->mBridgeType], false); diff --git a/src/plugProjectKandoU/itemGate.cpp b/src/plugProjectKandoU/itemGate.cpp index b7df6c81b..3ee57b3a6 100644 --- a/src/plugProjectKandoU/itemGate.cpp +++ b/src/plugProjectKandoU/itemGate.cpp @@ -286,18 +286,18 @@ bool ItemGate::getVectorField(Sys::Sphere& sphere, Vector3f& vectorField) { if (mPlanes[0].calcDist(sphere.mPosition) >= -sphere.mRadius) { if (mPlanes[2].calcDist(sphere.mPosition) >= -sphere.mRadius) { - vectorField = Vector3f(-_264.x, -_264.y, -_264.z); + vectorField = Vector3f(-mGateDirection.x, -mGateDirection.y, -mGateDirection.z); } else if (mPlanes[3].calcDist(sphere.mPosition) >= -sphere.mRadius) { - vectorField = _264; + vectorField = mGateDirection; } else { vectorField = Vector3f(-_270.x, -_270.y, -_270.z); } } else if (mPlanes[1].calcDist(sphere.mPosition) >= -sphere.mRadius) { if (mPlanes[2].calcDist(sphere.mPosition) >= -sphere.mRadius) { - vectorField = Vector3f(-_264.x, -_264.y, -_264.z); + vectorField = Vector3f(-mGateDirection.x, -mGateDirection.y, -mGateDirection.z); } else if (mPlanes[3].calcDist(sphere.mPosition) >= -sphere.mRadius) { - vectorField = _264; + vectorField = mGateDirection; } else { vectorField = _270; } @@ -442,8 +442,8 @@ f32 ItemGate::getWorkDistance(Sys::Sphere& sphere) */ void ItemGate::initPlanes() { - _270 = getDirection(mFaceDir); - _264 = getPerpDirection(mFaceDir); + _270 = getDirection(mFaceDir); + mGateDirection = getPerpDirection(mFaceDir); Vector3f pos = getPosition(); @@ -460,13 +460,13 @@ void ItemGate::initPlanes() mPlanes[1].mNormal.z = vec2.z; mPlanes[1].mOffset = vec2.dot(plane1vec); - Vector3f plane2vec = pos + (_264 * 76.5f); - mPlanes[2].mNormal.x = _264.x; - mPlanes[2].mNormal.y = _264.y; - mPlanes[2].mNormal.z = _264.z; - mPlanes[2].mOffset = _264.dot(plane2vec); + Vector3f plane2vec = pos + (mGateDirection * 76.5f); + mPlanes[2].mNormal.x = mGateDirection.x; + mPlanes[2].mNormal.y = mGateDirection.y; + mPlanes[2].mNormal.z = mGateDirection.z; + mPlanes[2].mOffset = mGateDirection.dot(plane2vec); - Vector3f vec3 = (-_264.x, -_264.y, _264.z); + Vector3f vec3 = (-mGateDirection.x, -mGateDirection.y, mGateDirection.z); Vector3f plane3vec = pos + (vec3 * 76.5f); mPlanes[3].mNormal.x = vec3.x; mPlanes[3].mNormal.y = vec3.y; diff --git a/src/plugProjectKandoU/itemPlant.cpp b/src/plugProjectKandoU/itemPlant.cpp index 4c477da12..4a54157f2 100644 --- a/src/plugProjectKandoU/itemPlant.cpp +++ b/src/plugProjectKandoU/itemPlant.cpp @@ -2041,7 +2041,7 @@ void Plant::doAI() { mFsm->exec(this); - if (gameSystem->isFlag(GAMESYS_IsPlaying) && gameSystem->isFlag(GAMESYS_IsSoundFXActive)) { + if (gameSystem->isFlag(GAMESYS_IsPlaying) && gameSystem->isFlag(GAMESYS_IsSoundSceneActive)) { if (mGrowState != PLANTGROW_Mold) { // if no mold, add "near spiderwort" sound mix static_cast(mSoundObj)->noukouFrameWork(true); @@ -2108,7 +2108,7 @@ void Plant::startMotion(int motionState) startColorMotion(PLANTCOLOR_Disappear); - if (gameSystem->isFlag(GAMESYS_IsSoundFXActive)) { + if (gameSystem->isFlag(GAMESYS_IsSoundSceneActive)) { mSoundObj->startSound(PSSE_EV_TSUYUKUSA_WITHER, 0); } break; diff --git a/src/plugProjectKandoU/mapMgr.cpp b/src/plugProjectKandoU/mapMgr.cpp index 750e10e04..aad834772 100644 --- a/src/plugProjectKandoU/mapMgr.cpp +++ b/src/plugProjectKandoU/mapMgr.cpp @@ -297,8 +297,8 @@ void ShapeMapMgr::load(LoadArg& arg) sys->heapStatusStart("map model", nullptr); void* file = JKRFileLoader::getGlbResource("model.bmd", nullptr); P2ASSERTBOOLLINE(729, file && arg.mFolder); - J3DModelData* model = J3DModelLoaderDataBase::load(file, 0x20040000); - model->newSharedDisplayList(0x40000); + J3DModelData* model = J3DModelLoaderDataBase::load(file, J3DMLF_Material_PE_FogOff | J3DMLF_UseSingleSharedDL); + model->newSharedDisplayList(J3DMLF_UseSingleSharedDL); model->makeSharedDL(); mMapModel = new SysShape::Model(model, J3DMODEL_CreateNewDL, 2); mMapModel->getJ3DModel()->newDifferedDisplayList(0x200); diff --git a/src/plugProjectKandoU/navi.cpp b/src/plugProjectKandoU/navi.cpp index 7abf6c2df..4306fc085 100644 --- a/src/plugProjectKandoU/navi.cpp +++ b/src/plugProjectKandoU/navi.cpp @@ -3900,7 +3900,7 @@ void Navi::updateThrowDisable() return; } - if (mController1 && mController1->getButton() & PAD_BUTTON_A) { + if (mController1 && mController1->getButton() & Controller::PRESS_A) { mThrowTimer = NAVI_THROWTIMER_LENGTH; } diff --git a/src/plugProjectKandoU/naviMgr.cpp b/src/plugProjectKandoU/naviMgr.cpp index 0e02cce70..1b9b315b7 100644 --- a/src/plugProjectKandoU/naviMgr.cpp +++ b/src/plugProjectKandoU/naviMgr.cpp @@ -197,9 +197,10 @@ void NaviMgr::load() JKRArchive* arc = JKRMountArchive("/user/Kando/piki/pikis.szs", JKRArchive::EMM_Mem, sys->mSysHeap, JKRArchive::EMD_Head); sys->heapStatusEnd("NaviMgr::Archive"); - J3DModelData* model = J3DModelLoaderDataBase::load(arc->getResource("orima_model/orima1.bmd"), 0x20000030); - for (u16 j = 0; j < model->getShapeNum(); j++) { - model->mShapeTable.mItems[j]->setTexMtxLoadType(0x2000); + J3DModelData* model = J3DModelLoaderDataBase::load(arc->getResource("orima_model/orima1.bmd"), + J3DMLF_Material_PE_FogOff | J3DMLF_UsePostTexMtx | J3DMLF_UseImmediateMtx); + for (u16 i = 0; i < model->getShapeNum(); i++) { + model->mShapeTable.mItems[i]->setTexMtxLoadType(0x2000); } mOlimarModel = model; @@ -209,9 +210,11 @@ void NaviMgr::load() } mCollData = CollPartFactory::load(texts, "naviColl.txt"); - mCursorModelData = J3DModelLoaderDataBase::load(arc->getResource("cursor/cursor.bmd"), 0x240000); - mMarkerModelData = J3DModelLoaderDataBase::load(arc->getResource("cursor/marker.bmd"), 0x240000); - mMarkerModelData->newSharedDisplayList(0x40000); + mCursorModelData + = J3DModelLoaderDataBase::load(arc->getResource("cursor/cursor.bmd"), J3DMLF_UseUniqueMaterials | J3DMLF_UseSingleSharedDL); + mMarkerModelData + = J3DModelLoaderDataBase::load(arc->getResource("cursor/marker.bmd"), J3DMLF_UseUniqueMaterials | J3DMLF_UseSingleSharedDL); + mMarkerModelData->newSharedDisplayList(J3DMLF_UseSingleSharedDL); SysShape::Model::enableMaterialAnim(mCursorModelData, 0); mCursorAnims[0].attachResource(arc->getResource("cursor/wakka_orima.brk"), mCursorModelData); @@ -241,10 +244,9 @@ void NaviMgr::loadResources_float() void* file = playData->isStoryFlag(STORY_DebtPaid) ? arc->getResource("orima_model/syatyou.bmd") : arc->getResource("orima_model/orima3.bmd"); - J3DModelData* model = J3DModelLoaderDataBase::load(file, 0x20000030); - for (u16 j = 0; j < model->getShapeNum(); j++) { - J3DShape* shape = model->mShapeTable.mItems[j]; - shape->setTexMtxLoadType(0x2000); + J3DModelData* model = J3DModelLoaderDataBase::load(file, J3DMLF_Material_PE_FogOff | J3DMLF_UsePostTexMtx | J3DMLF_UseImmediateMtx); + for (u16 i = 0; i < model->getShapeNum(); i++) { + model->getShapeNodePointer(i)->setTexMtxLoadType(0x2000); } mLouieModel = model; diff --git a/src/plugProjectKandoU/naviState.cpp b/src/plugProjectKandoU/naviState.cpp index 11e6f4813..2fb9159e5 100644 --- a/src/plugProjectKandoU/naviState.cpp +++ b/src/plugProjectKandoU/naviState.cpp @@ -319,7 +319,7 @@ void NaviStuckState::exec(Navi* navi) f32 knockback = 120.0f + 100.0f * randFloat(); f32 angle = FLICK_BACKWARD_ANGLE; if (randFloat() > 0.1f) { - angle = JMath::atanTable_.atan2_(stickVals.x, stickVals.z); + angle = JMAAtan2Radian(stickVals.x, stickVals.z); angle = roundAng(0.9424779f * (randFloat() - 0.5f) + angle); } @@ -3671,9 +3671,9 @@ void NaviFlickState::init(Navi* navi, StateArg* stateArg) mFlicker = flickArg->mCreature; } navi->startMotion(IPikiAnims::JHIT, IPikiAnims::JHIT, navi, nullptr); - _10 = 0; + mSubState = 0; navi->mVelocity.y = 0.0f; - navi->mFaceDir = roundAng(JMath::atanTable_.atan2_(mDirection.x, mDirection.z) + PI); + navi->mFaceDir = roundAng(JMAAtan2Radian(mDirection.x, mDirection.z) + PI); navi->mSoundObj->startSound(PSSE_PL_ORIMA_DAMAGE, 0); navi->mEffectsObj->createOrimadamage_(navi->mEffectsObj->mHeadMtx->mMatrix.mtxView); PSM::DamageDirector* director = PSMGetDamageD(); @@ -3688,7 +3688,7 @@ void NaviFlickState::init(Navi* navi, StateArg* stateArg) */ void NaviFlickState::exec(Navi* navi) { - switch (_10) { + switch (mSubState) { case 0: navi->mVelocity.x = mDirection.x; navi->mVelocity.z = mDirection.z; @@ -3720,8 +3720,8 @@ void NaviFlickState::cleanup(Navi* navi) { } */ void NaviFlickState::onKeyEvent(Navi* navi, SysShape::KeyEvent const& keyEvent) { - if (keyEvent.mType == KEYEVENT_END && _10 == 0) { - _10 = 1; + if (keyEvent.mType == KEYEVENT_END && mSubState == 0) { + mSubState = 1; navi->startMotion(IPikiAnims::JKOKE, IPikiAnims::JKOKE, nullptr, nullptr); } } diff --git a/src/plugProjectKandoU/navi_demoCheck.cpp b/src/plugProjectKandoU/navi_demoCheck.cpp index e3d56ee9e..f8674f7f3 100644 --- a/src/plugProjectKandoU/navi_demoCheck.cpp +++ b/src/plugProjectKandoU/navi_demoCheck.cpp @@ -257,7 +257,7 @@ bool Navi::demoCheck() Vector3f forwardVec; currentPellet->mBaseTrMatrix.getBasis(2, forwardVec); - arg.mAngle = JMath::atanTable_.atan2_(forwardVec.x, forwardVec.z); + arg.mAngle = JMAAtan2Radian(forwardVec.x, forwardVec.z); moviePlayer->mTargetObject = currentPellet; moviePlayer->play(arg); playData->setDemoFlag(DEMO_Discover_Treasure); @@ -303,7 +303,7 @@ bool Navi::demoCheck() Vector3f forwardVec; currentItem->mBaseTrMatrix.getBasis(2, forwardVec); - arg.mAngle = JMath::atanTable_.atan2_(forwardVec.x, forwardVec.z); + arg.mAngle = JMAAtan2Radian(forwardVec.x, forwardVec.z); moviePlayer->mTargetObject = currentItem; moviePlayer->play(arg); playData->setFindItemDemoFlag(itemIndex); diff --git a/src/plugProjectKandoU/onyonMgr.cpp b/src/plugProjectKandoU/onyonMgr.cpp index 462509595..9afc54bd1 100644 --- a/src/plugProjectKandoU/onyonMgr.cpp +++ b/src/plugProjectKandoU/onyonMgr.cpp @@ -1997,7 +1997,7 @@ Onyon* ItemOnyon::Mgr::birth(int objType, int onyonType) onyon->mObjectTypeID = OBJTYPE_Ufo; onyon->mModel = new SysShape::Model(mModelData[objType], J3DMODEL_ShareDL, 2); - onyon->mModel->mJ3dModel->newDifferedDisplayList(0x1000000); + onyon->mModel->mJ3dModel->newDifferedDisplayList(J3DMDF_DiffColorReg); onyon->mModel->mJ3dModel->calc(); onyon->mModel->mJ3dModel->calcMaterial(); onyon->mModel->mJ3dModel->makeDL(); @@ -2060,7 +2060,7 @@ void ItemOnyon::Mgr::load() void* file = JKRFileLoader::getGlbResource("goal.bmd", nullptr); JUT_ASSERTLINE(2966, file, "goal.bmd not found !!\n"); - mModelData[0] = J3DModelLoaderDataBase::load(file, 0x240000); + mModelData[0] = J3DModelLoaderDataBase::load(file, J3DMLF_UseUniqueMaterials | J3DMLF_UseSingleSharedDL); JKRArchive* podarc = nullptr; if ((gameSystem->isChallengeMode() || gameSystem->mIsInCave) && !gameSystem->isVersusMode()) { @@ -2075,13 +2075,12 @@ void ItemOnyon::Mgr::load() file = JKRFileLoader::getGlbResource("pot.bmd", nullptr); JUT_ASSERTLINE(2998, file, "pot.bmd not found !!\n"); - J3DModelData* modelDataPod = J3DModelLoaderDataBase::load(file, 0x00000030); + J3DModelData* modelDataPod = J3DModelLoaderDataBase::load(file, J3DMLF_UsePostTexMtx | J3DMLF_UseImmediateMtx); mModelData[1] = modelDataPod; - mModelData[1]->newSharedDisplayList(0x40000); + mModelData[1]->newSharedDisplayList(J3DMLF_UseSingleSharedDL); mModelData[1]->makeSharedDL(); - for (u16 i = 0; i < modelDataPod->mShapeTable.mCount; i++) { - u32 flags = modelDataPod->mShapeTable.mItems[i]->mFlags & 0xFFFF0FFF; - modelDataPod->mShapeTable.mItems[i]->mFlags = flags | 0x2000; + for (u16 i = 0; i < modelDataPod->getShapeNum(); i++) { + modelDataPod->getShapeNodePointer(i)->setTexMtxLoadType(0x2000); } } else { @@ -2131,13 +2130,14 @@ void ItemOnyon::Mgr::load() } file = JKRFileLoader::getGlbResource("ufo.bmd", nullptr); JUT_ASSERTLINE(3123, file, "ufo.bmd not found!\n"); - J3DModelData* modelDataUfo = J3DModelLoaderDataBase::load(file, 0x21020030); + J3DModelData* modelDataUfo = J3DModelLoaderDataBase::load(file, J3DMLF_Material_PE_FogOff | J3DMLF_Material_UseIndirect | J3DMLF_18 + | J3DMLF_UsePostTexMtx | J3DMLF_UseImmediateMtx); mModelData[2] = modelDataUfo; - mModelData[2]->newSharedDisplayList(0x40000); + mModelData[2]->newSharedDisplayList(J3DMLF_UseSingleSharedDL); mModelData[2]->makeSharedDL(); - for (u16 i = 0; i < modelDataUfo->mShapeTable.mCount; i++) { - u32 flags = modelDataUfo->mShapeTable.mItems[i]->mFlags & 0xFFFF0FFF; - modelDataUfo->mShapeTable.mItems[i]->mFlags = flags | 0x2000; + + for (u16 i = 0; i < modelDataUfo->getShapeNum(); i++) { + modelDataUfo->getShapeNodePointer(i)->setTexMtxLoadType(0x2000); } SysShape::Model::enableMaterialAnim(mModelData[2], 0); diff --git a/src/plugProjectKandoU/pelletFruit.cpp b/src/plugProjectKandoU/pelletFruit.cpp index ef4823a4d..a591a679d 100644 --- a/src/plugProjectKandoU/pelletFruit.cpp +++ b/src/plugProjectKandoU/pelletFruit.cpp @@ -104,7 +104,7 @@ void Mgr::setupResources() */ void Mgr::onCreateModel(SysShape::Model* model) { - model->mJ3dModel->newDifferedDisplayList(0x1000000); + model->mJ3dModel->newDifferedDisplayList(J3DMDF_DiffColorReg); model->mJ3dModel->calc(); model->mJ3dModel->calcMaterial(); model->mJ3dModel->makeDL(); diff --git a/src/plugProjectKandoU/pelletMgr.cpp b/src/plugProjectKandoU/pelletMgr.cpp index 4abc6083d..8731a3b27 100644 --- a/src/plugProjectKandoU/pelletMgr.cpp +++ b/src/plugProjectKandoU/pelletMgr.cpp @@ -3400,7 +3400,7 @@ void Pellet::updateTrMatrix() void Pellet::doAnimation() { if (!pelletMgr->mMovieDrawDisabled || isMovieActor()) { - if (gameSystem != nullptr && gameSystem->mFlags.isSet(0x20)) { + if (gameSystem != nullptr && gameSystem->isFlag(GAMESYS_IsGameWorldActive)) { update(); } else { if (mCollTree) { @@ -4673,16 +4673,15 @@ void BasePelletMgr::load() JUT_PANICLINE(4560, "meck ** %s : is not foun !\n", buffer2); } - u32 flags = 0x21020010; + u32 flags = J3DMLF_Material_PE_FogOff | J3DMLF_Material_UseIndirect | J3DMLF_18 | J3DMLF_UseImmediateMtx; if (config->mParams.mCode.mData & 2) { - flags |= 0x20; + flags |= J3DMLF_UsePostTexMtx; } - data = J3DModelLoaderDataBase::load(resource, flags); if (config->mParams.mCode.mData & 2) { - for (u16 i = 0; i < data->mShapeTable.mCount; i++) { - data->mShapeTable.mItems[i]->mFlags = data->mShapeTable.mItems[i]->mFlags & 0xFFFF0FFF | 0x2000; + for (u16 i = 0; i < data->getShapeNum(); i++) { + data->getShapeNodePointer(i)->setTexMtxLoadType(0x2000); } } @@ -4767,15 +4766,15 @@ void BasePelletMgr::load_texArc(char* filename) } if (config->mParams.mIndirectState != PelletConfig::Indirect_No) { - u32 flags = 0x21020010; + u32 flags = J3DMLF_Material_PE_FogOff | J3DMLF_Material_UseIndirect | J3DMLF_18 | J3DMLF_UseImmediateMtx; if (config->mParams.mCode.mData & 2) { - flags |= 0x20; + flags |= J3DMLF_UsePostTexMtx; } data = J3DModelLoaderDataBase::load(resource, flags); } else { - u32 flags = 0x20020010; + u32 flags = J3DMLF_Material_PE_FogOff | J3DMLF_18 | J3DMLF_UseImmediateMtx; if (config->mParams.mCode.mData & 2) { - flags |= 0x20; + flags |= J3DMLF_UsePostTexMtx; } data = J3DModelLoaderDataBase::load(resource, flags); } @@ -4783,8 +4782,8 @@ void BasePelletMgr::load_texArc(char* filename) mModelData[i] = data; if (config->mParams.mCode.mData & 2) { - for (u16 i = 0; i < data->mShapeTable.mCount; i++) { - data->mShapeTable.mItems[i]->mFlags = data->mShapeTable.mItems[i]->mFlags & 0xFFFF0FFF | 0x2000; + for (u16 i = 0; i < data->getShapeNum(); i++) { + data->getShapeNodePointer(i)->setTexMtxLoadType(0x2000); } } } diff --git a/src/plugProjectKandoU/pelletNumber.cpp b/src/plugProjectKandoU/pelletNumber.cpp index 210f9b2ea..8a85668f5 100644 --- a/src/plugProjectKandoU/pelletNumber.cpp +++ b/src/plugProjectKandoU/pelletNumber.cpp @@ -63,8 +63,8 @@ void Object::changeMaterial() break; } - u16 id = mModel->mJ3dModel->mModelData->mMaterialTable.mMaterialNames->getIndex("bpel1"); - J3DMaterial* mat = mModel->mJ3dModel->mModelData->mMaterialTable.mMaterials[id]; + u16 id = mModel->mJ3dModel->mModelData->getMaterialName()->getIndex("bpel1"); + J3DMaterial* mat = mModel->mJ3dModel->mModelData->getMaterialNodePointer(id); mat->mTevBlock->setTevColor(0, color); mModel->mJ3dModel->calcMaterial(); mModel->mJ3dModel->diff(); @@ -109,7 +109,7 @@ void Mgr::setupResources() void Mgr::onCreateModel(SysShape::Model* model) { model->mJ3dModel->newDifferedTexMtx(TEXDIFF_Material); - model->mJ3dModel->newDifferedDisplayList(0x1000200); + model->mJ3dModel->newDifferedDisplayList(J3DMDF_DiffColorReg | 0x200); model->mJ3dModel->calc(); model->mJ3dModel->calcMaterial(); model->mJ3dModel->makeDL(); diff --git a/src/plugProjectKandoU/pikiMgr.cpp b/src/plugProjectKandoU/pikiMgr.cpp index dff97fae1..538675093 100644 --- a/src/plugProjectKandoU/pikiMgr.cpp +++ b/src/plugProjectKandoU/pikiMgr.cpp @@ -193,12 +193,15 @@ void PikiMgr::load(int viewNum) loadBmd(Bulbmin, "piki_kochappy"); loadBmd(Carrot, "piki_ninjin"); - mHappaModel[Leaf] = J3DModelLoaderDataBase::load(arc->getResource("happa_model/leaf.bmd"), J3DMLF_Material_PE_FogOff); - mHappaModel[Bud] = J3DModelLoaderDataBase::load(arc->getResource("happa_model/bud.bmd"), J3DMLF_UseUniqueMaterials | J3DMLF_19); - mHappaModel[Flower] = J3DModelLoaderDataBase::load(arc->getResource("happa_model/flower.bmd"), J3DMLF_UseUniqueMaterials | J3DMLF_19); - mHappaModel[Bud_Red] = J3DModelLoaderDataBase::load(arc->getResource("happa_model/bud_red.bmd"), J3DMLF_UseUniqueMaterials | J3DMLF_19); - mHappaModel[Flower_Red] - = J3DModelLoaderDataBase::load(arc->getResource("happa_model/flower_red.bmd"), J3DMLF_UseUniqueMaterials | J3DMLF_19); + mHappaModel[Leaf] = J3DModelLoaderDataBase::load(arc->getResource("happa_model/leaf.bmd"), J3DMLF_Material_PE_FogOff); + mHappaModel[Bud] + = J3DModelLoaderDataBase::load(arc->getResource("happa_model/bud.bmd"), J3DMLF_UseUniqueMaterials | J3DMLF_UseSingleSharedDL); + mHappaModel[Flower] + = J3DModelLoaderDataBase::load(arc->getResource("happa_model/flower.bmd"), J3DMLF_UseUniqueMaterials | J3DMLF_UseSingleSharedDL); + mHappaModel[Bud_Red] + = J3DModelLoaderDataBase::load(arc->getResource("happa_model/bud_red.bmd"), J3DMLF_UseUniqueMaterials | J3DMLF_UseSingleSharedDL); + mHappaModel[Flower_Red] = J3DModelLoaderDataBase::load(arc->getResource("happa_model/flower_red.bmd"), + J3DMLF_UseUniqueMaterials | J3DMLF_UseSingleSharedDL); sys->heapStatusStart("pikmin-ModelMgr", nullptr); mModelMgr = new SysShape::ModelMgr(PikiColorCount, &mBluPikiModel, MAX_PIKI_COUNT, 0x20000, viewNum, @@ -227,7 +230,8 @@ void PikiMgr::loadBmd(int id, char* name) { char pathbuf[PATH_MAX]; sprintf(pathbuf, "piki_model/%s.bmd", name); - J3DModelData* data = J3DModelLoaderDataBase::load(mModelArchive->getResource(pathbuf), 0x60010); + J3DModelData* data + = J3DModelLoaderDataBase::load(mModelArchive->getResource(pathbuf), J3DMLF_UseSingleSharedDL | J3DMLF_18 | J3DMLF_UseImmediateMtx); { const u32 lightObjNum = 0; const u32 texGenNum = 0; diff --git a/src/plugProjectKandoU/pikiState.cpp b/src/plugProjectKandoU/pikiState.cpp index e561b2d8c..21f79dcc0 100644 --- a/src/plugProjectKandoU/pikiState.cpp +++ b/src/plugProjectKandoU/pikiState.cpp @@ -4423,7 +4423,7 @@ void PikiBlowState::init(Piki* piki, StateArg* stateArg) mState = 0; piki->mVelocity.y = mBlowDirection.y * (0.1f * randFloat() + 1.0f); - piki->mFaceDir = roundAng(JMath::atanTable_.atan2_(mBlowDirection.x, mBlowDirection.z) + PI); + piki->mFaceDir = roundAng(JMAAtan2Radian(mBlowDirection.x, mBlowDirection.z) + PI); if (mFlags & 0x4) { if (piki->getHappa() >= Bud) { @@ -4804,7 +4804,7 @@ void PikiDrownState::exec(Piki* piki) if (mNavi) { Vector3f naviPos = mNavi->getPosition(); Vector3f pikiPos = piki->getPosition(); - piki->mFaceDir = JMath::atanTable_.atan2_(naviPos.x - pikiPos.x, naviPos.z - pikiPos.z); + piki->mFaceDir = JMAAtan2Radian(naviPos.x - pikiPos.x, naviPos.z - pikiPos.z); } piki->mVelocity = Vector3f(100.0f * sinf(piki->mFaceDir), 160.0f, 100.0f * cosf(piki->mFaceDir)); diff --git a/src/plugProjectKandoU/singleGS_Movie.cpp b/src/plugProjectKandoU/singleGS_Movie.cpp index c7cf51443..1b8095fd8 100644 --- a/src/plugProjectKandoU/singleGS_Movie.cpp +++ b/src/plugProjectKandoU/singleGS_Movie.cpp @@ -124,7 +124,7 @@ void MovieState::exec(SingleGameSection* gs) } break; case true: - if ((mController->getButtonDown() & PAD_BUTTON_START) || mMoviePlayer->isFinishPlaying()) { // skip the movie with start + if ((mController->getButtonDown() & Controller::PRESS_START) || mMoviePlayer->isFinishPlaying()) { // skip the movie with start gs->mDisplayWiper = gs->mWipeInFader; gs->mWipeInFader->start(4.0f); gs->mCurrentCourseInfo = stageList->getCourseInfo(0); diff --git a/src/plugProjectKandoU/vsGS_Game.cpp b/src/plugProjectKandoU/vsGS_Game.cpp index bc6d38b9f..cf3c98159 100644 --- a/src/plugProjectKandoU/vsGS_Game.cpp +++ b/src/plugProjectKandoU/vsGS_Game.cpp @@ -399,7 +399,7 @@ void GameState::checkFindKeyDemo(VsGameSection* section) arg.mDelegateStart = section->mMovieStartCallback; arg.mOrigin = obj->getPosition(); - arg.mAngle = JMath::atanTable_.atan2_(obj->mBaseTrMatrix(0, 2), obj->mBaseTrMatrix(2, 2)); + arg.mAngle = JMAAtan2Radian(obj->mBaseTrMatrix(0, 2), obj->mBaseTrMatrix(2, 2)); moviePlayer->mTargetObject = obj; moviePlayer->play(arg); diff --git a/src/plugProjectKandoU/vsGS_Title.cpp b/src/plugProjectKandoU/vsGS_Title.cpp index e228b1db3..f16cc91a7 100644 --- a/src/plugProjectKandoU/vsGS_Title.cpp +++ b/src/plugProjectKandoU/vsGS_Title.cpp @@ -153,7 +153,7 @@ void TitleState::dvdload() Vs2D_TitleInfo::Info* displayData = (*mVsTitleInfo)(i); VsGame::StageData* fileData = mSection->mVsStageList->getStageData(i); if (fileData) { - displayData->mInfo = fileData->mIndex2D; + displayData->mIndex = fileData->mIndex2D; } } } diff --git a/src/plugProjectMorimuraU/blackManMgr.cpp b/src/plugProjectMorimuraU/blackManMgr.cpp index ab82d0f8e..e6360d197 100644 --- a/src/plugProjectMorimuraU/blackManMgr.cpp +++ b/src/plugProjectMorimuraU/blackManMgr.cpp @@ -68,7 +68,11 @@ void Mgr::loadTexData() * @note Address: 0x803A5A24 * @note Size: 0x2C */ -J3DModelData* Mgr::doLoadBmd(void* filename) { return J3DModelLoaderDataBase::load(filename, 0x21300030); } +J3DModelData* Mgr::doLoadBmd(void* filename) +{ + return J3DModelLoaderDataBase::load(filename, J3DMLF_Material_PE_FogOff | J3DMLF_Material_UseIndirect | J3DMLF_UseUniqueMaterials + | J3DMLF_21 | J3DMLF_UsePostTexMtx | J3DMLF_UseImmediateMtx); +} /** * @note Address: 0x803A5A50 diff --git a/src/plugProjectMorimuraU/challengeResult2D.cpp b/src/plugProjectMorimuraU/challengeResult2D.cpp index 3e7de24ff..712717ea5 100644 --- a/src/plugProjectMorimuraU/challengeResult2D.cpp +++ b/src/plugProjectMorimuraU/challengeResult2D.cpp @@ -403,7 +403,7 @@ f32 TMovePane::getAngDist() if (distY == 0.0f) { distY = 0.1f; } - f32 angle = JMath::atanTable_.atan2_(distX, -distY); + f32 angle = JMAAtan2Radian(distX, -distY); return angDist(roundAng(angle), mAngle); } diff --git a/src/plugProjectMorimuraU/enemyNestMgr.cpp b/src/plugProjectMorimuraU/enemyNestMgr.cpp index cf7405285..42159218f 100644 --- a/src/plugProjectMorimuraU/enemyNestMgr.cpp +++ b/src/plugProjectMorimuraU/enemyNestMgr.cpp @@ -46,8 +46,9 @@ J3DModelData* Mgr::loadModelData(JKRArchive* archive) void* enemyBMD = JKRFileLoader::getGlbResource("enemy.bmd", archive); if (enemyBMD) { - mModelData = J3DModelLoaderDataBase::load(enemyBMD, 0x20240010); - mModelData->newSharedDisplayList(0x40000); + mModelData = J3DModelLoaderDataBase::load(enemyBMD, J3DMLF_Material_PE_FogOff | J3DMLF_UseUniqueMaterials | J3DMLF_UseSingleSharedDL + | J3DMLF_UseImmediateMtx); + mModelData->newSharedDisplayList(J3DMLF_UseSingleSharedDL); mModelData->simpleCalcMaterial(0, *(Mtx*)(&j3dDefaultMtx)); mModelData->makeSharedDL(); } @@ -61,8 +62,9 @@ J3DModelData* Mgr::loadModelData(JKRArchive* archive) enemyBMD = JKRFileLoader::getGlbResource("enemy.bmd", jigumoArc); if (enemyBMD) { - mJigumoHouseData = J3DModelLoaderDataBase::load(enemyBMD, 0x20240010); - mJigumoHouseData->newSharedDisplayList(0x40000); + mJigumoHouseData = J3DModelLoaderDataBase::load(enemyBMD, J3DMLF_Material_PE_FogOff | J3DMLF_UseUniqueMaterials + | J3DMLF_UseSingleSharedDL | J3DMLF_UseImmediateMtx); + mJigumoHouseData->newSharedDisplayList(J3DMLF_UseSingleSharedDL); mJigumoHouseData->simpleCalcMaterial(0, *(Mtx*)(&j3dDefaultMtx)); mJigumoHouseData->makeSharedDL(); } diff --git a/src/plugProjectMorimuraU/panModokiMgr.cpp b/src/plugProjectMorimuraU/panModokiMgr.cpp index df0346f81..b40912474 100644 --- a/src/plugProjectMorimuraU/panModokiMgr.cpp +++ b/src/plugProjectMorimuraU/panModokiMgr.cpp @@ -58,7 +58,11 @@ EnemyBase* Mgr::birth(EnemyBirthArg& birthArg) { return EnemyMgrBase::birth(birt * @note Address: 0x8034EE48 * @note Size: 0x2C */ -J3DModelData* Mgr::doLoadBmd(void* filename) { return J3DModelLoaderDataBase::load(filename, 0x00240030); } +J3DModelData* Mgr::doLoadBmd(void* filename) +{ + return J3DModelLoaderDataBase::load(filename, J3DMLF_UseUniqueMaterials | J3DMLF_UseSingleSharedDL | J3DMLF_UsePostTexMtx + | J3DMLF_UseImmediateMtx); +} /** * @note Address: 0x8034EE74 diff --git a/src/plugProjectMorimuraU/tyreMgr.cpp b/src/plugProjectMorimuraU/tyreMgr.cpp index 0c957ac56..c23d08681 100644 --- a/src/plugProjectMorimuraU/tyreMgr.cpp +++ b/src/plugProjectMorimuraU/tyreMgr.cpp @@ -46,7 +46,8 @@ void Mgr::loadModelData() */ J3DModelData* Mgr::doLoadBmd(void* file) { - return J3DModelLoaderDataBase::load(file, 0x21240030); // flags should really be OR'd together + return J3DModelLoaderDataBase::load(file, J3DMLF_Material_PE_FogOff | J3DMLF_Material_UseIndirect | J3DMLF_UseUniqueMaterials + | J3DMLF_UseSingleSharedDL | J3DMLF_UsePostTexMtx | J3DMLF_UseImmediateMtx); } } // namespace Tyre diff --git a/src/plugProjectMorimuraU/vsSelect2D.cpp b/src/plugProjectMorimuraU/vsSelect2D.cpp index d02a190b8..410339f1f 100644 --- a/src/plugProjectMorimuraU/vsSelect2D.cpp +++ b/src/plugProjectMorimuraU/vsSelect2D.cpp @@ -558,7 +558,7 @@ f32 TVsSelectOnyon::getAngDist() y = 0.1f; } - f32 angle = JMath::atanTable_.atan2_(x, -y); + f32 angle = JMAAtan2Radian(x, -y); return angDist(roundAng(angle), mGoalAngle); } @@ -6741,8 +6741,7 @@ int TVsSelect::getIdMax() { return mStageCount; } int TVsSelect::getCourseID(int id) { if (!mIsSection) { - Game::Vs2D_TitleInfo::Info* info = (*mDispMember->mTitleInfo)(id); - id = info->mInfo; + id = (*mDispMember->mTitleInfo)(id)->mIndex; } return id; } diff --git a/src/plugProjectMorimuraU/zukan2D.cpp b/src/plugProjectMorimuraU/zukan2D.cpp index 24098a0aa..b0fd1ba71 100644 --- a/src/plugProjectMorimuraU/zukan2D.cpp +++ b/src/plugProjectMorimuraU/zukan2D.cpp @@ -4524,12 +4524,12 @@ void TCallbackScrollMsg::reset() P2JME::Window::TRenderingProcessor* proc = static_cast(mControl->mTextRenderProc); proc->setTextBoxInfo(mPane); - f32 space = TZukanBase::mLineSpace; - proc->_C0 = space; - proc->mLineHeight = space; - proc->mSpeed = TZukanBase::mWarpRadius; - mControl->_6C = TZukanBase::mScrollValueCoe; - mControl->mScrollSpeed = TZukanBase::mScrollSpeedCoe; + f32 space = TZukanBase::mLineSpace; + proc->mActiveLineHeight = space; + proc->mLineHeight = space; + proc->mSpeed = TZukanBase::mWarpRadius; + mControl->mScrollVal = TZukanBase::mScrollValueCoe; + mControl->mScrollSpeed = TZukanBase::mScrollSpeedCoe; } } diff --git a/src/plugProjectNishimuraU/Baby.cpp b/src/plugProjectNishimuraU/Baby.cpp index 9359c99af..7a5d7ed62 100644 --- a/src/plugProjectNishimuraU/Baby.cpp +++ b/src/plugProjectNishimuraU/Baby.cpp @@ -242,7 +242,7 @@ void Obj::moveNoTarget() if (gameSystem && gameSystem->isZukanMode()) { if (sqrDistanceXZ(mPosition, mTargetPos) < 500.0f) { f32 randomAngle = randWeightFloat(100.0f) + 50.0f; - f32 angleToHome = JMath::atanTable_.atan2_(mPosition.x - mHomePosition.x, mPosition.z - mHomePosition.z); + f32 angleToHome = JMAAtan2Radian(mPosition.x - mHomePosition.x, mPosition.z - mHomePosition.z); angleToHome = randWeightFloat(PI) + angleToHome + HALF_PI; mTargetPos.x = randomAngle * sinf(angleToHome) + mHomePosition.x; diff --git a/src/plugProjectNishimuraU/BigFoot.cpp b/src/plugProjectNishimuraU/BigFoot.cpp index ee378d325..141e2a192 100644 --- a/src/plugProjectNishimuraU/BigFoot.cpp +++ b/src/plugProjectNishimuraU/BigFoot.cpp @@ -330,7 +330,7 @@ void Obj::getTargetPosition() } else if (sqrDistanceXZ(mPosition, mTargetPosition) < 625.0f) { f32 range = (C_GENERALPARMS.mTerritoryRadius.mValue - C_GENERALPARMS.mHomeRadius.mValue); f32 randDist = C_GENERALPARMS.mHomeRadius.mValue + randWeightFloat(range); - f32 ang2 = JMath::atanTable_.atan2_(mPosition.x - mHomePosition.x, mPosition.z - mHomePosition.z); + f32 ang2 = JMAAtan2Radian(mPosition.x - mHomePosition.x, mPosition.z - mHomePosition.z); f32 ang1 = randWeightFloat(PI); f32 ang3 = HALF_PI; diff --git a/src/plugProjectNishimuraU/BigTreasure.cpp b/src/plugProjectNishimuraU/BigTreasure.cpp index bb9b52648..65718286c 100644 --- a/src/plugProjectNishimuraU/BigTreasure.cpp +++ b/src/plugProjectNishimuraU/BigTreasure.cpp @@ -389,7 +389,7 @@ void Obj::getTargetPosition() } else if (sqrDistanceXZ(mPosition, mTargetPosition) < 625.0f) { f32 range = (C_GENERALPARMS.mTerritoryRadius.mValue - C_GENERALPARMS.mHomeRadius.mValue); f32 randDist = C_GENERALPARMS.mHomeRadius.mValue + randWeightFloat(range); - f32 ang2 = JMath::atanTable_.atan2_(mPosition.x - mHomePosition.x, mPosition.z - mHomePosition.z); + f32 ang2 = JMAAtan2Radian(mPosition.x - mHomePosition.x, mPosition.z - mHomePosition.z); f32 ang1 = randWeightFloat(PI); f32 ang3 = HALF_PI; @@ -1036,7 +1036,7 @@ int Obj::getFireAttackAnimIndex() if (navi) { Vector3f naviPos = navi->getPosition(); - angle = JMath::atanTable_.atan2_(naviPos.x - mPosition.x, naviPos.z - mPosition.z); + angle = JMAAtan2Radian(naviPos.x - mPosition.x, naviPos.z - mPosition.z); clampAngle(angle); angle -= mFaceDir; diff --git a/src/plugProjectNishimuraU/Damagumo.cpp b/src/plugProjectNishimuraU/Damagumo.cpp index b432de225..a1c770bed 100644 --- a/src/plugProjectNishimuraU/Damagumo.cpp +++ b/src/plugProjectNishimuraU/Damagumo.cpp @@ -295,7 +295,7 @@ void Obj::getTargetPosition() } else if (sqrDistanceXZ(mPosition, mTargetPosition) < 625.0f) { f32 range = (C_GENERALPARMS.mTerritoryRadius.mValue - C_GENERALPARMS.mHomeRadius.mValue); f32 randDist = C_GENERALPARMS.mHomeRadius.mValue + randWeightFloat(range); - f32 angleToHome = JMath::atanTable_.atan2_(mPosition.x - mHomePosition.x, mPosition.z - mHomePosition.z); + f32 angleToHome = JMAAtan2Radian(mPosition.x - mHomePosition.x, mPosition.z - mHomePosition.z); f32 randomAngle = randWeightFloat(PI); f32 fixedAngle = HALF_PI; diff --git a/src/plugProjectNishimuraU/Fuefuki.cpp b/src/plugProjectNishimuraU/Fuefuki.cpp index dd1c7bf5e..0c3a6d678 100644 --- a/src/plugProjectNishimuraU/Fuefuki.cpp +++ b/src/plugProjectNishimuraU/Fuefuki.cpp @@ -405,7 +405,7 @@ void Obj::setTargetPosition(bool check) f32 range = (C_GENERALPARMS.mTerritoryRadius.mValue - C_GENERALPARMS.mHomeRadius.mValue); randDist = C_GENERALPARMS.mHomeRadius.mValue + randWeightFloat(range); f32 ang1 = randWeightFloat(PI); - f32 ang2 = JMath::atanTable_.atan2_(mPosition.x - mHomePosition.x, mPosition.z - mHomePosition.z); + f32 ang2 = JMAAtan2Radian(mPosition.x - mHomePosition.x, mPosition.z - mHomePosition.z); f32 ang3 = HALF_PI; randAngle = ang2 + ang1 + ang3; // dumb fix for regswap } diff --git a/src/plugProjectNishimuraU/Hanachirashi.cpp b/src/plugProjectNishimuraU/Hanachirashi.cpp index 900b5ab39..bab282d3e 100644 --- a/src/plugProjectNishimuraU/Hanachirashi.cpp +++ b/src/plugProjectNishimuraU/Hanachirashi.cpp @@ -279,7 +279,7 @@ void Obj::setRandTarget() Vector3f position = getPosition(); Vector3f homePos = mHomePosition; Vector3f atanInput = position - homePos; - f32 aboutTheta = JMath::atanTable_.atan2_(atanInput.x, atanInput.z); + f32 aboutTheta = JMAAtan2Radian(atanInput.x, atanInput.z); f32 theta = aboutTheta + randWeightFloat(PI) + HALF_PI; diff --git a/src/plugProjectNishimuraU/Houdai.cpp b/src/plugProjectNishimuraU/Houdai.cpp index 3f22ea5e2..6d902bbe9 100644 --- a/src/plugProjectNishimuraU/Houdai.cpp +++ b/src/plugProjectNishimuraU/Houdai.cpp @@ -315,7 +315,7 @@ void Obj::getTargetPosition() } else if (sqrDistanceXZ(mPosition, mTargetPosition) < 625.0f) { f32 range = (C_GENERALPARMS.mTerritoryRadius.mValue - C_GENERALPARMS.mHomeRadius.mValue); f32 randDist = C_GENERALPARMS.mHomeRadius.mValue + randWeightFloat(range); - f32 ang2 = JMath::atanTable_.atan2_(mPosition.x - mHomePosition.x, mPosition.z - mHomePosition.z); + f32 ang2 = JMAAtan2Radian(mPosition.x - mHomePosition.x, mPosition.z - mHomePosition.z); f32 ang1 = randWeightFloat(PI); f32 ang3 = HALF_PI; diff --git a/src/plugProjectNishimuraU/IKSystemMgr.cpp b/src/plugProjectNishimuraU/IKSystemMgr.cpp index 1fffd4e45..5dafd18ee 100644 --- a/src/plugProjectNishimuraU/IKSystemMgr.cpp +++ b/src/plugProjectNishimuraU/IKSystemMgr.cpp @@ -113,7 +113,7 @@ void IKSystemMgr::startProgramedIK() bottomJointPos = mIKSystems[i].getBottomJointPosition(); // Calculate difference in angle between the owner's position and the current foot's position - f32 diff = JMath::atanTable_.atan2_(bottomJointPos.x - objectPos.x, bottomJointPos.z - objectPos.z); + f32 diff = JMAAtan2Radian(bottomJointPos.x - objectPos.x, bottomJointPos.z - objectPos.z); mLegHeight[i] = diff - mOwner->getFaceDir(); } @@ -390,12 +390,11 @@ void IKSystemMgr::calcFaceDir() { if (mIsIKActive) { Vector3f pos0, pos1; - pos0 = mIKSystems[0].getBottomJointPosition(); - pos1 = mIKSystems[1].getBottomJointPosition(); - // this feels wrong - f32 angle = JMath::atanTable_.atan2_((pos0.x + pos1.x) / 2 - mCentrePosition.x, (pos0.z + pos1.z) / 2 - mCentrePosition.z); - mFaceDir = angle; - angle = mFaceDir; + pos0 = mIKSystems[0].getBottomJointPosition(); + pos1 = mIKSystems[1].getBottomJointPosition(); + mFaceDir = JMAAtan2Radian((pos0.x + pos1.x) / 2 - mCentrePosition.x, (pos0.z + pos1.z) / 2 - mCentrePosition.z); + + f32 angle = mFaceDir; clampAngle(angle); mFaceDir = angle; diff --git a/src/plugProjectNishimuraU/KumaChappy.cpp b/src/plugProjectNishimuraU/KumaChappy.cpp index 6fd236a81..a2dde477a 100644 --- a/src/plugProjectNishimuraU/KumaChappy.cpp +++ b/src/plugProjectNishimuraU/KumaChappy.cpp @@ -207,7 +207,7 @@ void Obj::doUpdateCarcass() f32 z = mBaseTrMatrix.mMatrix.structView.zz; EnemyBirthArg arg; arg.mPosition = mPosition; - arg.mFaceDir = JMath::atanTable_.atan2_(x, z); + arg.mFaceDir = JMAAtan2Radian(x, z); arg.mExistenceLength = mExistDuration; arg.mIsInPiklopedia = (u8)mInPiklopedia; EnemyBase* obj = generalEnemyMgr->birth(getEnemyTypeID(), arg); diff --git a/src/plugProjectNishimuraU/Mar.cpp b/src/plugProjectNishimuraU/Mar.cpp index d5f8f50f2..6a4b3be3e 100644 --- a/src/plugProjectNishimuraU/Mar.cpp +++ b/src/plugProjectNishimuraU/Mar.cpp @@ -278,7 +278,7 @@ void Obj::setRandTarget() Vector3f position = getPosition(); Vector3f homePos = mHomePosition; Vector3f atanInput = position - homePos; - f32 aboutTheta = JMath::atanTable_.atan2_(atanInput.x, atanInput.z); + f32 aboutTheta = JMAAtan2Radian(atanInput.x, atanInput.z); f32 theta = aboutTheta + randWeightFloat(PI) + HALF_PI; diff --git a/src/plugProjectNishimuraU/Sarai.cpp b/src/plugProjectNishimuraU/Sarai.cpp index 38ba7d670..7e866657a 100644 --- a/src/plugProjectNishimuraU/Sarai.cpp +++ b/src/plugProjectNishimuraU/Sarai.cpp @@ -204,7 +204,7 @@ void Obj::setRandTarget() } // Get the direction from the home position towards our position - f32 dirToSarai = JMath::atanTable_.atan2_(mPosition.x - mHomePosition.x, mPosition.z - mHomePosition.z); + f32 dirToSarai = JMAAtan2Radian(mPosition.x - mHomePosition.x, mPosition.z - mHomePosition.z); // Randomise the angle a bit and set the target position f32 rngAngle = HALF_PI + (dirToSarai + randWeightFloat(PI)); diff --git a/src/plugProjectNishimuraU/Tadpole.cpp b/src/plugProjectNishimuraU/Tadpole.cpp index 852598fad..32ad82f5b 100644 --- a/src/plugProjectNishimuraU/Tadpole.cpp +++ b/src/plugProjectNishimuraU/Tadpole.cpp @@ -116,7 +116,7 @@ void Obj::setRandTarget(bool check) f32 radius = randWeightFloat(p1) + C_GENERALPARMS.mHomeRadius.mValue; Vector3f tadpolePos = getPosition(); Vector3f homePos = mHomePosition; - f32 angle = JMath::atanTable_.atan2_(tadpolePos.x - homePos.x, tadpolePos.z - homePos.z); + f32 angle = JMAAtan2Radian(tadpolePos.x - homePos.x, tadpolePos.z - homePos.z); angle = randWeightFloat(PI) + angle + HALF_PI; mTargetPosition = Vector3f(radius * sinf(angle) + homePos.x, homePos.y, radius * cosf(angle) + homePos.z); diff --git a/src/plugProjectOgawaU/ogCallBackMessage.cpp b/src/plugProjectOgawaU/ogCallBackMessage.cpp index 68e78a16c..94c8a540f 100644 --- a/src/plugProjectOgawaU/ogCallBackMessage.cpp +++ b/src/plugProjectOgawaU/ogCallBackMessage.cpp @@ -69,8 +69,8 @@ void CallBack_Message::draw(Graphics& gfx, J2DGrafContext& graf) mWidth = x2; mHeight = y2; P2JME::TRenderingProcessor* proc = mMessage->mProcessor; - proc->_54 = -mWidth; - proc->_58 = -mHeight; + proc->mXOffset = -mWidth; + proc->mYOffset = -mHeight; proc->setTextBoxInfo(mPane); mMessage->mProcessor->mMesgBounds.set(mMinX, mMinY, mMaxX, mMaxY); diff --git a/src/plugProjectOgawaU/ogObjContena.cpp b/src/plugProjectOgawaU/ogObjContena.cpp index 6c36a6411..642379f26 100644 --- a/src/plugProjectOgawaU/ogObjContena.cpp +++ b/src/plugProjectOgawaU/ogObjContena.cpp @@ -162,10 +162,10 @@ void ObjContena::doCreate(JKRArchive* arc) mSpotX = mPaneSpot->mOffset.x; mSpotY = mPaneSpot->mOffset.y; og::Screen::setCallBackMessage(mContena); - - for (int i = 0; i < 10; i++) { - mAnimList[i] = nullptr; - }; + + for (int i = 0; i < 10; i++) { + mAnimList[i] = nullptr; + }; if (mContena->search('sh_color')) { og::Screen::setCallBackMessage(mContena); diff --git a/src/plugProjectOgawaU/ogObjKantei.cpp b/src/plugProjectOgawaU/ogObjKantei.cpp index 5eeaf0780..d2052cb7c 100644 --- a/src/plugProjectOgawaU/ogObjKantei.cpp +++ b/src/plugProjectOgawaU/ogObjKantei.cpp @@ -182,7 +182,7 @@ void ObjKantei::doCreate(JKRArchive* arc) mTControl = new P2JME::Movie::TControl; mTControl->init(); - mTControl->mFlags.dwordView &= 0xfffffffe; + mTControl->mFlags.unset(P2JME::Movie::TControl::ControlFlag_UnsuspendOnFinish); mInTextBox = false; og::Screen::CallBack_Picture* pic = og::Screen::setCallBack_3DStick(arc, mScreenButton, 'ota3dl'); diff --git a/src/plugProjectYamashitaU/enemyMgrBase.cpp b/src/plugProjectYamashitaU/enemyMgrBase.cpp index 75f05ad16..099321dc2 100644 --- a/src/plugProjectYamashitaU/enemyMgrBase.cpp +++ b/src/plugProjectYamashitaU/enemyMgrBase.cpp @@ -578,13 +578,16 @@ void EnemyMgrBase::loadTexData() * @note Address: 0x80130394 * @note Size: 0x2C */ -J3DModelData* EnemyMgrBase::doLoadBmd(void* bmd) { return J3DModelLoaderDataBase::load(bmd, 0x240010); } +J3DModelData* EnemyMgrBase::doLoadBmd(void* bmd) +{ + return J3DModelLoaderDataBase::load(bmd, J3DMLF_UseUniqueMaterials | J3DMLF_UseSingleSharedDL | J3DMLF_UseImmediateMtx); +} /** * @note Address: 0x801303C0 * @note Size: 0x28 */ -J3DModelData* EnemyMgrBase::doLoadBdl(void* bdl) { return J3DModelLoaderDataBase::loadBinaryDisplayList(bdl, 0x2000); } +J3DModelData* EnemyMgrBase::doLoadBdl(void* bdl) { return J3DModelLoaderDataBase::loadBinaryDisplayList(bdl, J3DMLF_DoBdlMaterialCalc); } /** * @note Address: 0x801303E8 diff --git a/src/plugProjectYamashitaU/enemyStoneMgr.cpp b/src/plugProjectYamashitaU/enemyStoneMgr.cpp index 21b8b1027..96479c8b1 100644 --- a/src/plugProjectYamashitaU/enemyStoneMgr.cpp +++ b/src/plugProjectYamashitaU/enemyStoneMgr.cpp @@ -50,7 +50,7 @@ void Mgr::loadResource() for (int i = 0; i < 2; i++) { modDat = (J3DModelData*)archive->getResource(sStoneMdlName[i]); - loadModDat = J3DModelLoaderDataBase::load(modDat, 0x240000 | 0x240000); + loadModDat = J3DModelLoaderDataBase::load(modDat, J3DMLF_UseUniqueMaterials | J3DMLF_UseSingleSharedDL); mModelData[i] = loadModDat; mModelData[i]->newSharedDisplayList(0x40000); mModelData[i]->simpleCalcMaterial(0, *(Mtx*)(&j3dDefaultMtx)); diff --git a/src/plugProjectYamashitaU/farm.cpp b/src/plugProjectYamashitaU/farm.cpp index d03f99ba6..c0a3c2197 100644 --- a/src/plugProjectYamashitaU/farm.cpp +++ b/src/plugProjectYamashitaU/farm.cpp @@ -111,7 +111,7 @@ void Farm::loadResource(u32 modelType, void* mdlData) { sys->heapStatusStart("Farm resource", nullptr); sys->heapStatusStart("mdlData", nullptr); - mModelData = J3DModelLoaderDataBase::load(mdlData, 0x20000000); + mModelData = J3DModelLoaderDataBase::load(mdlData, J3DMLF_Material_PE_FogOff); sys->heapStatusEnd("mdlData"); mPosition = Vector3f(0.0f); diff --git a/src/sysCommonU/sysMath.cpp b/src/sysCommonU/sysMath.cpp index a223b00f3..16ae667e5 100644 --- a/src/sysCommonU/sysMath.cpp +++ b/src/sysCommonU/sysMath.cpp @@ -69,7 +69,7 @@ const f32 pikmin2_asinf(f32 x) * @note Address: 0x804117DC * @note Size: 0x28 */ -f32 pikmin2_atan2f(f32 x, f32 y) { return JMath::atanTable_.atan2_(x, y); } +f32 pikmin2_atan2f(f32 x, f32 y) { return JMAAtan2Radian(x, y); } /** * @note Address: 0x80411804 diff --git a/src/sysGCU/JSTObjectActor.cpp b/src/sysGCU/JSTObjectActor.cpp index ff2b0dd7b..b9189b599 100644 --- a/src/sysGCU/JSTObjectActor.cpp +++ b/src/sysGCU/JSTObjectActor.cpp @@ -51,49 +51,22 @@ ObjectActor::~ObjectActor() { } */ void ObjectActor::reset() { + // this probably shouldnt be needed but it matches here (not in the ctor above) + u32 test = gu32NAN_.a; + mTranslation = govNAN_; mRotation = govNAN_; mScaling = govNAN_; - mShape = gu32NAN_.a; - mAnimation = gu32NAN_.a; + mShape = test; + mAnimation = test; mAnimFrame = gfNAN_; mAnimFrameMax = gfNAN_; - mModelFileId = gu32NAN_.a; - mAnimationFileId = gu32NAN_.a; + mModelFileId = test; + mAnimationFileId = test; mScaling.z = 1.0f; mScaling.y = 1.0f; mScaling.x = 1.0f; mAnimFrame = 0.0f; - /* - lis r4, lbl_804EC018@ha - lfsu f5, lbl_804EC018@l(r4) - lwz r0, lbl_805161D8@sda21(r13) - lfs f4, 4(r4) - stfs f5, 0x34(r3) - lfs f3, 8(r4) - stfs f4, 0x38(r3) - lfs f2, lbl_805161DC@sda21(r13) - stfs f3, 0x3c(r3) - lfs f1, lbl_80520678@sda21(r2) - stfs f5, 0x40(r3) - lfs f0, lbl_8052067C@sda21(r2) - stfs f4, 0x44(r3) - stfs f3, 0x48(r3) - stfs f5, 0x4c(r3) - stfs f4, 0x50(r3) - stfs f3, 0x54(r3) - stw r0, 0x58(r3) - stw r0, 0x5c(r3) - stfs f2, 0x60(r3) - stfs f2, 0x64(r3) - stw r0, 0x68(r3) - stw r0, 0x6c(r3) - stfs f1, 0x54(r3) - stfs f1, 0x50(r3) - stfs f1, 0x4c(r3) - stfs f0, 0x60(r3) - blr - */ } /** @@ -114,7 +87,7 @@ void ObjectActor::update() mtx.setTranslation(*(Vector3f*)&mTranslation); Matrixf mtx2; - f32 angle = mRotation.z * DEG2RAD; + f32 angle = MTXDegToRad(mRotation.z); f32 sinAngle = sin(angle); f32 cosAngle = cos(angle); mtx2.mMatrix.structView.xx = cosAngle; @@ -134,7 +107,7 @@ void ObjectActor::update() Mtx out; PSMTXConcat(mtx.mMatrix.mtxView, mtx2.mMatrix.mtxView, out); - angle = mRotation.y * DEG2RAD; + angle = MTXDegToRad(mRotation.y); sinAngle = sin(angle); cosAngle = cos(angle); mtx2.mMatrix.structView.xx = cosAngle; @@ -152,7 +125,7 @@ void ObjectActor::update() mtx2.setTranslation(pos2); PSMTXConcat(out, mtx2.mMatrix.mtxView, mtx.mMatrix.mtxView); - angle = mRotation.x * DEG2RAD; + angle = MTXDegToRad(mRotation.x); sinAngle = sin(angle); cosAngle = cos(angle); mtx2.mMatrix.structView.xx = cosAngle; @@ -170,37 +143,39 @@ void ObjectActor::update() mtx2.setTranslation(pos3); PSMTXConcat(mtx.mMatrix.mtxView, mtx2.mMatrix.mtxView, out); - if (mModel) { - PSMTXCopy(out, mModel->mPosMtx); - mModel->setBaseScale(mScaling.x, mScaling.y, mScaling.z); - if (mAnmTransform) { - mAnimFrame += 1.0f; - if (mAnimFrame > mAnimFrameMax) { - mAnimFrame = mAnimFrameMax; - } - mAnmTransform->setFrame(mAnimFrame); - } - SysShape::Model::setViewCalcModeInd(); - Viewport* vp = moviePlayer->mViewport; - if (vp) { - vp->setJ3DViewMtx(false); - vp->setViewport(); - vp->setProjection(); + if (!mModel) { + return; + } + + PSMTXCopy(out, mModel->mPosMtx); + mModel->setBaseScale(mScaling.x, mScaling.y, mScaling.z); + if (mAnmTransform) { + mAnimFrame += 1.0f; + if (mAnimFrame > mAnimFrameMax) { + mAnimFrame = mAnimFrameMax; } + mAnmTransform->setFrame(mAnimFrame); + } + SysShape::Model::setViewCalcModeInd(); + Viewport* vp = moviePlayer->mViewport; + if (vp) { + vp->setJ3DViewMtx(false); + vp->setViewport(); + vp->setProjection(); + } - Matrixf mtx; - Vector3f pos(mTranslation); - Vector3f rot(mRotation * DEG2RAD * PI); - mtx.makeTR(pos, rot); - PSMTXCopy(mtx.mMatrix.mtxView, mModel->mPosMtx); + Matrixf mtx3; + Vector3f pos4(mTranslation); + Vector3f rot(mRotation * PI * DEG2RAD); + mtx3.makeTR(pos4, rot); + PSMTXCopy(mtx3.mMatrix.mtxView, mModel->mPosMtx); - Vector3f scale(1.0f, 1.0f, 1.0f); - mModel->setBaseScale(scale); + Vector3f scale(1.0f, 1.0f, 1.0f); + mModel->setBaseScale(scale); - mModel->calc(); - mModel->mMtxBuffer->mCurrentViewNumber = 0; - mModel->viewCalc(); - } + mModel->calc(); + mModel->mMtxBuffer->mCurrentViewNumber = 0; + mModel->viewCalc(); /* stwu r1, -0x120(r1) @@ -465,43 +440,49 @@ void ObjectActor::entry() */ bool ObjectActor::setShape() { - if (!(moviePlayer->isFlag(MVP_IsFinished))) { - sys->startChangeCurrentHeap(moviePlayer->mMovieHeap); - int id = mShape; - if (id == gu32NAN_.a) { - sys->endChangeCurrentHeap(); - return false; - } else if (id == mModelFileId) { - sys->endChangeCurrentHeap(); - return true; - } else { - void* file = mArchive->getIdxResource(id); - if (!file) { - sys->endChangeCurrentHeap(); - return false; - } else { - u32 flag = 0x240000; - // use different flags for the day results background model (makes it ignore fog) - if (strcmp(mName, "bg")) { - flag |= 0x20000000; - } else { - flag |= 0x10000000; - } - mModelData = J3DModelLoaderDataBase::load(file, flag); - JUT_ASSERTLINE(281, mModelData, "ModelData null"); - if (!mModelData) { - sys->endChangeCurrentHeap(); - return false; - } else { - mModel = new J3DModel(mModelData, 0, 1); - JUT_ASSERTLINE(290, mModel, "pModel_ null"); - mModelFileId = mShape; - sys->endChangeCurrentHeap(); - return true; - } - } - } + if (moviePlayer->isFlag(MVP_IsFinished)) { + return; // doesnt specify true or false + } + + sys->startChangeCurrentHeap(moviePlayer->mMovieHeap); + + int id = mShape; + if (id == gu32NAN_.a) { + sys->endChangeCurrentHeap(); + return false; + } + + if (id == mModelFileId) { + sys->endChangeCurrentHeap(); + return true; } + + void* file = mArchive->getIdxResource(id); + if (!file) { + sys->endChangeCurrentHeap(); + return false; + } + + u32 flag = 0x240000; + // use different flags for the day results background model (makes it ignore fog) + if (strcmp(mName, "bg")) { + flag |= J3DMLF_Material_PE_FogOff; + } else { + flag |= J3DMLF_Material_PE_Full; + } + mModelData = J3DModelLoaderDataBase::load(file, flag); + JUT_ASSERTLINE(281, mModelData, "ModelData null"); + + if (!mModelData) { + sys->endChangeCurrentHeap(); + return false; + } + + mModel = new J3DModel(mModelData, 0, 1); + JUT_ASSERTLINE(290, mModel, "pModel_ null"); + mModelFileId = mShape; + sys->endChangeCurrentHeap(); + return true; } /** @@ -510,36 +491,41 @@ bool ObjectActor::setShape() */ bool ObjectActor::setAnim() { - if (!(moviePlayer->isFlag(MVP_IsFinished))) { - sys->startChangeCurrentHeap(moviePlayer->mMovieHeap); - int id = mAnimation; - if (id == gu32NAN_.a) { - sys->endChangeCurrentHeap(); - return false; - } else if (id == mAnimationFileId) { - sys->endChangeCurrentHeap(); - return true; - } else { - void* file = mArchive->getIdxResource(id); - if (!file) { - sys->endChangeCurrentHeap(); - return false; - } else { - mAnmTransform = static_cast(J3DAnmLoaderDataBase::load(file)); - if (!mAnmTransform) { - sys->endChangeCurrentHeap(); - return false; - } else { - mMtxCalcAnm = J3DNewMtxCalcAnm(mModelData->mJointTree.mFlags & J3DMLF_MtxTypeMask, mAnmTransform); - mModelData->mJointTree.mJoints[0]->mMtxCalc = mMtxCalcAnm; - mAnimFrameMax = mAnmTransform->mTotalFrameCount; - mAnimationFileId = mAnimation; - sys->endChangeCurrentHeap(); - return true; - } - } - } + if (moviePlayer->isFlag(MVP_IsFinished)) { + return; // doesnt specify true or false + } + + sys->startChangeCurrentHeap(moviePlayer->mMovieHeap); + + int id = mAnimation; + if (id == gu32NAN_.a) { + sys->endChangeCurrentHeap(); + return false; + } + + if (id == mAnimationFileId) { + sys->endChangeCurrentHeap(); + return true; + } + + void* file = mArchive->getIdxResource(id); + if (!file) { + sys->endChangeCurrentHeap(); + return false; + } + + mAnmTransform = static_cast(J3DAnmLoaderDataBase::load(file)); + if (!mAnmTransform) { + sys->endChangeCurrentHeap(); + return false; } + + mMtxCalcAnm = J3DNewMtxCalcAnm(mModelData->mJointTree.mFlags & J3DMLF_MtxTypeMask, mAnmTransform); + mModelData->getJointNodePointer(0)->setMtxCalc(mMtxCalcAnm); + mAnimFrameMax = mAnmTransform->getTotalFrameCount(); + mAnimationFileId = mAnimation; + sys->endChangeCurrentHeap(); + return true; } /** @@ -754,7 +740,7 @@ getData__Q47JStudio3stb4data22TParse_TParagraph_dataCFPQ57JStudio3stb4data22TPar int ObjectActor::JSGFindNodeID(char const* name) const { P2ASSERTLINE(428, mModelData); - return mModelData->mJointTree.mNametab->getIndex(name); + return mModelData->getJointName()->getIndex(name); } /** diff --git a/src/sysGCU/JSTObjectGameActor.cpp b/src/sysGCU/JSTObjectGameActor.cpp index e2a1c409f..1741b6217 100644 --- a/src/sysGCU/JSTObjectGameActor.cpp +++ b/src/sysGCU/JSTObjectGameActor.cpp @@ -88,7 +88,7 @@ void ObjectGameActor::update() SysShape::Joint* joint = mGameObject->mModel->mJoints; if (joint) { Matrixf* mtx = joint->getWorldMatrix(); - mObjectFaceDir = JMath::atanTable_.atan2_(mtx->mMatrix.structView.zx, mtx->mMatrix.structView.zz); + mObjectFaceDir = JMAAtan2Radian(mtx->mMatrix.structView.zx, mtx->mMatrix.structView.zz); if (mGameObject->isNavi()) { mGameObject->getCreatureID(); } diff --git a/src/sysGCU/captionMessage.cpp b/src/sysGCU/captionMessage.cpp index 3d66e9f2c..c135c8cfd 100644 --- a/src/sysGCU/captionMessage.cpp +++ b/src/sysGCU/captionMessage.cpp @@ -11,7 +11,7 @@ namespace Caption { TRenderingProcessor::TRenderingProcessor(JMessage::TReference* ref) : Window::TRenderingProcessor(ref) { - _144 = 1.0f; + mDrawAlphaLevel = 1.0f; } /** @@ -26,11 +26,11 @@ void TRenderingProcessor::doGetDrawInfo(Window::DrawInfo* info) { info->mTimeLim */ BOOL TRenderingProcessor::doDrawCommon(f32 x, f32 y, Matrixf* mtx1, Matrixf* mtx2) { - f32 ret = _144 * 255.0f; + f32 ret = mDrawAlphaLevel * 255.0f; Matrixf mtx; - Window::DrawInfo* info = mDrawInfo.searchDrawInfo(_40); + Window::DrawInfo* info = mDrawInfo.searchDrawInfo(mInfoIndex); if (!info) { - info = mDrawInfo.getDrawInfo(_40); + info = mDrawInfo.getDrawInfo(mInfoIndex); doGetDrawInfo(info); } @@ -46,10 +46,10 @@ BOOL TRenderingProcessor::doDrawCommon(f32 x, f32 y, Matrixf* mtx1, Matrixf* mtx if (mtx2) { PSMTXCopy(mtx.mMatrix.mtxView, mtx2->mMatrix.mtxView); - Vector3f translation = mtx2->getColumn(3); + Vector3f translation = mtx2->getTranslation(); translation.x += 10.0f; translation.y += 5.0f; - mtx2->setColumn(3, translation.x, translation.y, translation.z); + mtx2->setTranslation(translation); PSMTXConcat(mMtx1->mMatrix.mtxView, mtx2->mMatrix.mtxView, mtx2->mMatrix.mtxView); PSMTXConcat(mMtx2->mMatrix.mtxView, mtx2->mMatrix.mtxView, mtx2->mMatrix.mtxView); @@ -63,7 +63,7 @@ BOOL TRenderingProcessor::doDrawCommon(f32 x, f32 y, Matrixf* mtx1, Matrixf* mtx GXLoadPosMtxImm(mtx.mMatrix.mtxView, 0); } - return (u8)((ret >= 0.0f) ? ret + 0.5f : ret - 0.5f); + return (u8)(ROUND_F32_TO_U8(ret)); } /** @@ -72,10 +72,10 @@ BOOL TRenderingProcessor::doDrawCommon(f32 x, f32 y, Matrixf* mtx1, Matrixf* mtx */ TControl::TControl() { - mState = 0; - mStartFrame = 0; - mEndFrame = 0; - _68 = 6; + mState = 0; + mStartFrame = 0; + mEndFrame = 0; + mFadeoutFrameLength = 6; } /** @@ -88,7 +88,7 @@ bool TControl::onInit() setFont(gP2JMEMgr->mFont); setRubyFont(gP2JMEMgr->mFont); } - initRenderingProcessor(0x100); + initRenderingProcessor(256); // max 256 characters can be animated at once _50 = 3.0f; setLocate(0, 0); mTextRenderProc->mTextBoxWidth = sys->getRenderModeObj()->fbWidth; @@ -116,21 +116,22 @@ void TControl::reset() bool TControl::updateSetFrame(s32 frame) { bool ret = false; - if (mState == 0 && frame >= mStartFrame && frame <= mEndFrame + _68) { + if (mState == 0 && frame >= mStartFrame && frame <= mEndFrame + mFadeoutFrameLength) { mState = 1; } if (mState != 0) { - if (frame < mStartFrame || frame > mEndFrame + _68) { + if (frame < mStartFrame || frame > mEndFrame + mFadeoutFrameLength) { mState = 0; } else { ret = P2JME::TControl::update(); if (frame > mEndFrame) { - mState = 2; - static_cast(mTextRenderProc)->_144 = 1.0f - f32(frame - mEndFrame) / f32(_68); + mState = 2; + static_cast(mTextRenderProc)->mDrawAlphaLevel + = 1.0f - f32(frame - mEndFrame) / f32(mFadeoutFrameLength); } else { - static_cast(mTextRenderProc)->_144 = 1.0f; - mState = 1; + static_cast(mTextRenderProc)->mDrawAlphaLevel = 1.0f; + mState = 1; } } } diff --git a/src/sysGCU/captionMgr.cpp b/src/sysGCU/captionMgr.cpp index aa0df508a..c8420eda9 100644 --- a/src/sysGCU/captionMgr.cpp +++ b/src/sysGCU/captionMgr.cpp @@ -35,13 +35,8 @@ void Caption::Node::read(Stream& input) */ Caption::Mgr::Mgr() : CNode("キャプションマネージャ") + , mNode(nullptr) { - mNode = nullptr; - _20[0] = 0; - _20[1] = 0; - _20[2] = 0; - _20[3] = 0; - mControls = new P2JME::Caption::TControl[3]; for (u32 i = 0; i < 3; i++) { mControls[i].init(); @@ -165,7 +160,7 @@ P2JME::Caption::TControl* Caption::Mgr::getFreeMessage() { P2JME::Caption::TControl* ret = nullptr; for (u32 i = 0; i < 3; i++) { - if ((int)mControls[i].mState == 0) { + if (mControls[i].mState == 0) { ret = &mControls[i]; break; } diff --git a/src/sysGCU/commonSaveData.cpp b/src/sysGCU/commonSaveData.cpp index 790d75db0..1903b5e3d 100644 --- a/src/sysGCU/commonSaveData.cpp +++ b/src/sysGCU/commonSaveData.cpp @@ -31,7 +31,7 @@ void Mgr::setDefault() mIsRubyFont = true; mUseDeflicker = true; mRegion = (u8)sys->mRegion; - _18 = 0; + mSaveCount = 0; mTime = 0; mFileIndex = -1; mDoSaveOptions = false; @@ -45,7 +45,7 @@ void Mgr::setDefault() void Mgr::setCardSerialNo(u64 tag) { mCardSerialNo = tag; - mFlags.set(1); + mFlags.set(SaveFlag_SerialNoSet); } /** @@ -55,7 +55,7 @@ void Mgr::setCardSerialNo(u64 tag) void Mgr::resetCardSerialNo() { mCardSerialNo = 0xcdcdcdcdcdcdcdcd; - mFlags.unset(1); + mFlags.unset(SaveFlag_SerialNoSet); } /** @@ -138,7 +138,7 @@ void Mgr::resetPlayer(s8 fileIndex) { mFileIndex = fileIndex; mTime = 0; - _18 = 0; + mSaveCount = 0; } /** @@ -156,7 +156,7 @@ void Mgr::setDeflicker(bool deflicker) _GXRenderModeObj* obj = System::getRenderModeObj(); mUseDeflicker = deflicker; - if ((u32)OSGetProgressiveMode() == 1) { + if (OSGetProgressiveMode() == OS_PROGRESSIVE_MODE_ON) { obj->vfilter[0] = 0; obj->vfilter[1] = 0; obj->vfilter[2] = 21; @@ -193,7 +193,7 @@ void Mgr::setSoundModeMono() { mSoundMode = SM_Mono; JAIGlobalParameter::setParamSoundOutputMode(SM_Mono); - OSSetSoundMode(false); + OSSetSoundMode(OS_SOUND_MODE_MONO); } /** @@ -204,7 +204,7 @@ void Mgr::setSoundModeStereo() { mSoundMode = SM_Stereo; JAIGlobalParameter::setParamSoundOutputMode(SM_Stereo); - OSSetSoundMode(true); + OSSetSoundMode(OS_SOUND_MODE_STEREO); } /** @@ -215,7 +215,7 @@ void Mgr::setSoundModeSurround() { mSoundMode = SM_SurroundSound; JAIGlobalParameter::setParamSoundOutputMode(SM_SurroundSound); - OSSetSoundMode(true); + OSSetSoundMode(OS_SOUND_MODE_STEREO); } /** @@ -227,25 +227,14 @@ void Mgr::setBgmVolume(f32 volume) bool temp = OSDisableInterrupts(); OSDisableScheduler(); - bool volumeCheck = false; - if (volume >= 0.0f && volume <= 1.0f) { - volumeCheck = true; - } #if BUILDTARGET == USADEMO1 - P2ASSERTLINE(392, volumeCheck); + P2ASSERTBOOLLINE(392, volume >= 0.0f && volume <= 1.0f); #else - P2ASSERTLINE(389, volumeCheck); + P2ASSERTBOOLLINE(389, volume >= 0.0f && volume <= 1.0f); #endif if (PSSystem::spSysIF) { - f32 calc = volume * 255.0f; - f32 newCalc; - if (calc >= 0.0f) { - newCalc = 0.5f + calc; - } else { - newCalc = calc - 0.5f; - } - mMusicVol = newCalc; + mMusicVol = ROUND_F32_TO_U8(volume * 255.0f); PSGetSystemIFA()->setConfigVol_Bgm(volume); } OSEnableScheduler(); @@ -261,25 +250,14 @@ void Mgr::setSeVolume(f32 volume) bool temp = OSDisableInterrupts(); OSDisableScheduler(); - bool volumeCheck = false; - if (volume >= 0.0f && volume <= 1.0f) { - volumeCheck = true; - } #if BUILDTARGET == USADEMO1 - P2ASSERTLINE(410, volumeCheck); + P2ASSERTBOOLLINE(410, volume >= 0.0f && volume <= 1.0f); #else - P2ASSERTLINE(407, volumeCheck); + P2ASSERTBOOLLINE(407, volume >= 0.0f && volume <= 1.0f); #endif if (PSSystem::spSysIF) { - f32 calc = volume * 255.0f; - f32 newCalc; - if (calc >= 0.0f) { - newCalc = 0.5f + calc; - } else { - newCalc = calc - 0.5f; - } - mSeVol = newCalc; + mSeVol = ROUND_F32_TO_U8(volume * 255.0f); PSGetSystemIFA()->setConfigVol_Se(volume); } diff --git a/src/sysGCU/demoSection.cpp b/src/sysGCU/demoSection.cpp index 73b026085..7db5490bf 100644 --- a/src/sysGCU/demoSection.cpp +++ b/src/sysGCU/demoSection.cpp @@ -8,6 +8,7 @@ #include "JSystem/JFramework/JFWDisplay.h" #include "JSystem/J2D/J2DPicture.h" #include "JSystem/JUtility/JUTProcBar.h" +#include "PSM/Scene.h" static void _Print(char* format, ...) { OSReport(format, __FILE__); } @@ -23,8 +24,7 @@ struct LogoLocation { }; static LogoLocation sLogoLocate[] = { - { 0x0172, 0x000F }, { 0x0172, 0x000F }, { 0x0172, 0x000F }, { 0x0172, 0x0028 }, - { 0x0172, 0x000F }, { 0x0172, 0x000F }, { 0x0172, 0x000F }, { 0x0172, 0x0028 }, + { 370, 15 }, { 370, 15 }, { 370, 15 }, { 370, 40 }, { 370, 15 }, { 370, 15 }, { 370, 15 }, { 370, 40 }, }; } // namespace @@ -121,11 +121,10 @@ bool Section::doUpdate() */ void Section::doExit() { - PSSystem::SceneMgr* mgr = PSSystem::getSceneMgr(); - PSSystem::validateSceneMgr(mgr); - mgr->deleteCurrentScene(); + PSMGetSceneMgrCheck()->deleteCurrentScene(); - if ((s8)(++sMovieIndex) >= (u32)8) { + u32 max = 8; + if (++sMovieIndex >= max) { sMovieIndex = 0; } diff --git a/src/sysGCU/dvdStatus.cpp b/src/sysGCU/dvdStatus.cpp index f884a5264..7141d1c09 100644 --- a/src/sysGCU/dvdStatus.cpp +++ b/src/sysGCU/dvdStatus.cpp @@ -1,20 +1,11 @@ -#include "Dolphin/dvd.h" -#include "Dolphin/pad.h" #include "DvdStatus.h" -#include "JSystem/JUtility/JUTException.h" #include "JSystem/JFramework/JFWDisplay.h" -#include "System.h" -#include "types.h" -#include "Graphics.h" -#include "JSystem/JUtility/JUTVideo.h" #include "JSystem/J2D/J2DPrint.h" -#include "P2JME/P2JME.h" #include "Game/MemoryCard/Mgr.h" +#include "P2JME/P2JME.h" extern P2JME::Mgr* gP2JMEMgr; -enum LanguageID { LANG_ENGLISH = 0, LANG_FRENCH, LANG_GERMAN, LANG_HOL_UNUSED, LANG_ITALIAN, LANG_JAPANESE, LANG_SPANISH }; - const char* filler1 = "dvdStatus"; /** @@ -31,14 +22,7 @@ DvdStatus::DvdStatus() * @note Address: 0x8042A328 * @note Size: 0x2C */ -bool DvdStatus::isErrorOccured() -{ - bool retval = false; - if (!((mFader == nullptr) || (sys->mCardMgr->isFlag(Game::MemoryCard::MCMFLAG_IsWriting)))) { - retval = true; - } - return retval; -} +bool DvdStatus::isErrorOccured() { return mFader && !sys->mCardMgr->isFlag(Game::MemoryCard::MCMFLAG_IsWriting); } /** * @note Address: 0x8042A354 @@ -120,28 +104,28 @@ void DvdStatus::draw() } else if (sys->mRomFont) { print.setFont(sys->mRomFont); } else { - JUT_ASSERTLINE(279, false, "no ROM font\n"); + JUT_PANICLINE(279, "no ROM font\n"); } char** errorMsgSet; if (print.mFont) { switch (sys->mRegion) { - case LANG_ENGLISH: + case System::LANG_English: errorMsgSet = DvdError::gMessage_eng; break; - case LANG_FRENCH: + case System::LANG_French: errorMsgSet = DvdError::gMessage_fra; break; - case LANG_GERMAN: + case System::LANG_German: errorMsgSet = DvdError::gMessage_ger; break; - case LANG_ITALIAN: + case System::LANG_Italian: errorMsgSet = DvdError::gMessage_ita; break; - case LANG_JAPANESE: + case System::LANG_Japanese: errorMsgSet = DvdError::gMessage_jpn; break; - case LANG_SPANISH: + case System::LANG_Spanish: errorMsgSet = DvdError::gMessage_spa; break; default: diff --git a/src/sysGCU/dvdThread.cpp b/src/sysGCU/dvdThread.cpp index cd3dcd908..0a96fe5f5 100644 --- a/src/sysGCU/dvdThread.cpp +++ b/src/sysGCU/dvdThread.cpp @@ -150,8 +150,9 @@ void* DvdThread::run() void DvdThread::loadArchive(DvdThreadCommand* cmd) { JKRHeap* currentHeap = cmd->mHeap->becomeCurrentHeap(); - JKRArchive* arc = JKRMountArchive(cmd->mArcPath, JKRArchive::EMM_Mem, cmd->mHeap, - (cmd->mHeapDirection == 1 ? JKRArchive::EMD_Head : JKRArchive::EMD_Tail)); + JKRArchive* arc + = JKRMountArchive(cmd->mArcPath, JKRArchive::EMM_Mem, cmd->mHeap, + (cmd->mHeapDirection == DvdThreadCommand::EHD_Unknown1 ? JKRArchive::EMD_Head : JKRArchive::EMD_Tail)); P2ASSERTLINE(275, arc); cmd->mMountedArchive = arc; currentHeap->becomeCurrentHeap(); diff --git a/src/sysGCU/gameConfig.cpp b/src/sysGCU/gameConfig.cpp index c07b83778..b08444e20 100644 --- a/src/sysGCU/gameConfig.cpp +++ b/src/sysGCU/gameConfig.cpp @@ -98,62 +98,6 @@ GameConfig::GameConfig() mParms.mVsFifo.mData = 0; } -/** - * @note Address: 0x804322A0 - * @note Size: 0x70 - */ -// WEAK - in header. -// GameConfig::Parms::~Parms() { } - -/** - * __ct__Q34Game10GameConfig5ParmsFv - * @note Address: 0x80432310 - * @note Size: 0x460 - */ -// WEAK - in header. -// GameConfig::Parms::Parms() -// : TagParameters("GameConfig") -// , mGamePrint(this, "gamePrint") -// , mPrint(this, "Print") -// , mOgawaPrint(this, "ogawaPrint") -// , mShimizuPrint(this, "shimizuPrint") -// , mYamashitaPrint(this, "yamashitaPrint") -// , mKandoPrint(this, "kandoPrint") -// , mNishimuraPrint(this, "nishimuraPrint") -// , mEbisawaPrint(this, "ebisawaPrint") -// , mMorimuraPrint(this, "morimuraPrint") -// , mKonoPrint(this, "konoPrint") -// , mFujinoPrint(this, "fujinoPrint") -// , mPsoundPrint(this, "psoundPrint") -// , mShortCutUp(this, "shortCutUp") -// , mShortCutDown(this, "shortCutDown") -// , mShortCutLeft(this, "shortCutLeft") -// , mShortCutRight(this, "shortCutRight") -// , mAllocAllEnemy(this, "allocAllEnemy") -// , mMapparts_path(this, "mapparts_path") -// , mPublicity(this, "publicity") -// , mPelletMultiLang(this, "pelletMultiLang") -// , mAI(this, "AI") -// , mTimers(this, "timers") -// , mVsTest(this, "vsTest") -// , mVsDeathType(this, "vsDeathType") -// , mVsHiba(this, "vsHiba") -// , mVsY(this, "vsY") -// , mE3version(this, "E3version") -// , mMukki_cherry(this, "mukki_cherry") -// , mMarioClubDevelop(this, "marioClubDevelop") -// , mHeapStatusPrint(this, "heapStatusPrint") -// , mHeapFreeSize(this, "heapFreeSize") -// , mBaseGameNewCheck(this, "baseGameNewCheck") -// , mKFesVersion(this, "KFesVersion") -// , mNintendoVersion(this, "nintendoVersion") -// , mLanguage(this, "language") -// , mAutosaveOff(this, "autosaveOff") -// , mVsDebugSelectPattern(this, "vsDebugSelectPattern") -// , mVsFifo(this, "vsFifo") -// { -// } - /** * @note Address: 0x80432770 * @note Size: 0x128 diff --git a/src/sysGCU/gameflow.cpp b/src/sysGCU/gameflow.cpp index 281b93d87..3ce3f187a 100644 --- a/src/sysGCU/gameflow.cpp +++ b/src/sysGCU/gameflow.cpp @@ -75,8 +75,24 @@ GameFlow::~GameFlow() { } */ void GameFlow::run() { + JKRExpHeap* expHeap; + JKRHeap* parentHeap; + while (true) { - runGame(); + parentHeap = JKRGetCurrentHeap(); + + JKRHeap::TState state(parentHeap); + parentHeap->state_register(&state, -1); + expHeap = makeExpHeap(parentHeap->getFreeSize(), parentHeap, true); + + setSection(); + + mSection->init(); + mSection->run(); + mSection->exit(); + + expHeap->destroy(); + parentHeap->becomeCurrentHeap(); } } @@ -90,11 +106,11 @@ void GameFlow::setSection() switch (mActiveSectionFlag) { case SN_Boot: - mSection = new BootSection(JKRHeap::sCurrentHeap); + mSection = new BootSection(JKRGetCurrentHeap()); mActiveSectionFlag = SN_RootMenu; break; case SN_RootMenu: - mSection = new RootMenuSection(JKRHeap::sCurrentHeap); + mSection = new RootMenuSection(JKRGetCurrentHeap()); mActiveSectionFlag = SN_MainTitle; break; default: diff --git a/src/sysGCU/graphics.cpp b/src/sysGCU/graphics.cpp index 44233de71..e270d2b56 100644 --- a/src/sysGCU/graphics.cpp +++ b/src/sysGCU/graphics.cpp @@ -2868,13 +2868,13 @@ void Graphics::perspPrintf(PerspPrintfInfo& info, Vector3f& position, char* form case 2: { f32 width = printer.getWidth(buf); - f32 val = (width >= 0.0f) ? 0.5f + width : width - 0.5f; + f32 val = ROUND_F32_TO_U8(width); int x = info.mPerspectiveOffsetX - (int)val; printer.print(x, (f32)info.mPerspectiveOffsetY, buf); } break; default: { f32 width = 0.5f * printer.getWidth(buf); - f32 val = (width >= 0.0f) ? 0.5f + width : width - 0.5f; + f32 val = ROUND_F32_TO_U8(width); int x = info.mPerspectiveOffsetX - (int)val; printer.print(x, (f32)info.mPerspectiveOffsetY, buf); } break; diff --git a/src/sysGCU/illustratedBookMessage.cpp b/src/sysGCU/illustratedBookMessage.cpp index ffd712e45..1c1a4eef3 100644 --- a/src/sysGCU/illustratedBookMessage.cpp +++ b/src/sysGCU/illustratedBookMessage.cpp @@ -35,7 +35,7 @@ TControl::TControl() mCurrentScroll = 0.0f; mCurrentTextHeight = 0.0f; mTextBox = nullptr; - _6C = 3.5f; + mScrollVal = 3.5f; mScrollSpeed = 0.08f; } @@ -46,7 +46,7 @@ TControl::TControl() bool TControl::onInit() { Window::TControl::onInit(); - initRenderingProcessor(0x200); + initRenderingProcessor(512); // max 512 characters can be animated at once return true; } @@ -81,14 +81,14 @@ f32 TControl::getScrollPosition() void TControl::scroll(f32 rate) { if (rate != 0.0f) { - mCurrentScroll += rate * _6C * 60.0f * sys->getDeltaTime(); + mCurrentScroll += rate * mScrollVal * 60.0f * sys->getDeltaTime(); if (mCurrentScroll < mMaxScroll) { mCurrentScroll = mMaxScroll; } if (mCurrentScroll > 0.0f) { mCurrentScroll = 0.0f; } - f32 calc = mTextRenderProc->_C0; + f32 calc = mTextRenderProc->mActiveLineHeight; int dir; if (rate > 0.0f) { dir = 0; @@ -115,15 +115,15 @@ void TControl::scroll(f32 rate) bool TControl::update(Controller* control1, Controller* control2) { P2JME::TControl::update(); - mMaxScroll = mTextRenderProc->mTextBoxHeight - mTextRenderProc->_C0 * (f32)(mTextRenderProc->mCurrLine + 1); + mMaxScroll = mTextRenderProc->mTextBoxHeight - mTextRenderProc->mActiveLineHeight * (f32)(mTextRenderProc->mCurrLine + 1); - f32 calc = mTextRenderProc->_C0; + f32 calc = mTextRenderProc->mActiveLineHeight; f32 scroll = (int)(mMaxScroll / calc); mMaxScroll = scroll * calc; - f32 calc2 = mTextRenderProc->_58; - f32 val = mScrollSpeed * (mCurrentScroll - calc2) * 60.0f * sys->getDeltaTime(); - mTextRenderProc->_58 = val + mTextRenderProc->_58; + f32 calc2 = mTextRenderProc->mYOffset; + f32 val = mScrollSpeed * (mCurrentScroll - calc2) * 60.0f * sys->getDeltaTime(); + mTextRenderProc->mYOffset = val + mTextRenderProc->mYOffset; } /** diff --git a/src/sysGCU/loadResource.cpp b/src/sysGCU/loadResource.cpp index 6a10c7700..a3fe742bd 100644 --- a/src/sysGCU/loadResource.cpp +++ b/src/sysGCU/loadResource.cpp @@ -45,8 +45,8 @@ void Node::dump() { } * @note Address: 0x8044C5D8 * @note Size: 0x44 */ -Arg::Arg(char const* p1) - : mPath(p1) +Arg::Arg(char const* filePath) + : mPath(filePath) , mBuffer(nullptr) , mAddress(0) , mOffset(0) @@ -57,8 +57,8 @@ Arg::Arg(char const* p1) , mAramID(-1) , mDvdFileCompression(nullptr) , mNewSize(nullptr) - , mUseAram(1) - , mUseDVD(1) + , mUseAram(true) + , mUseDVD(true) { } @@ -67,10 +67,11 @@ Arg::Arg(char const* p1) * @note Address: 0x8044C61C * @note Size: 0x48 */ -ArgAramOnly::ArgAramOnly(char const* p1) - : Arg(p1) +ArgAramOnly::ArgAramOnly(char const* filePath) + : Arg(filePath) { - mUseDVD = 0; + // Disallow loading directly from the disc, file MUST be loaded into ARAM + mUseDVD = false; } /** diff --git a/src/sysGCU/memoryCard.cpp b/src/sysGCU/memoryCard.cpp index 2e12aa01b..dda164631 100644 --- a/src/sysGCU/memoryCard.cpp +++ b/src/sysGCU/memoryCard.cpp @@ -312,21 +312,14 @@ void MemoryCardMgr::update() { if (checkStatus() != 11 && !sys->isResetActive()) { if (CARDProbe(0) && checkStatus() == 0) { - bool check = false; - if ((int)mIsCard == 0 && checkStatus() != 11) { - check = true; - } - if (check) { + + if (isSaveInvalid()) { MemoryCardMgrCommand cmd(3); setCommand(&cmd); } } else if (!CARDProbe(0) && checkStatus()) { - bool check = false; - if ((int)mIsCard == 0 && checkStatus() != 11) { - check = true; - } - if (check) { + if (isSaveInvalid()) { MemoryCardMgrCommand cmd(4); setCommand(&cmd); } @@ -1366,18 +1359,18 @@ bool MemoryCardMgr::readCardSerialNo(u64* serial, ECardSlot cardSlot) bool result = false; s32 cardRes = CARDGetSerialNo(cardSlot, serial); switch (cardRes) { - case -2: + case CARD_RESULT_WRONGDEVICE: break; - case 0: + case CARD_RESULT_READY: result = true; break; - case -0x80: + case CARD_RESULT_FATAL_ERROR: setInsideStatusFlag(INSIDESTATUS_Unk10); break; - case -3: + case CARD_RESULT_NOCARD: setInsideStatusFlag(INSIDESTATUS_Unk); break; - case -1: + case CARD_RESULT_BUSY: P2ASSERTLINE(1234, false); break; } diff --git a/src/sysGCU/messageAnalyzer.cpp b/src/sysGCU/messageAnalyzer.cpp index 44e64b1da..41e815b26 100644 --- a/src/sysGCU/messageAnalyzer.cpp +++ b/src/sysGCU/messageAnalyzer.cpp @@ -32,9 +32,9 @@ void Analyzer::exec(char* msg) convertCharToMessageID(msg, &msgID1, &msgID2); setIDs(msgID1, msgID2, &beginID1, &beginID2); - reset_(0); + reset_(nullptr); setBegin_messageID(beginID1, beginID2, 0); - process(0); + process(nullptr); } /** diff --git a/src/sysGCU/messageRendering.cpp b/src/sysGCU/messageRendering.cpp index cb245f09f..16be2bf61 100644 --- a/src/sysGCU/messageRendering.cpp +++ b/src/sysGCU/messageRendering.cpp @@ -101,35 +101,35 @@ TRenderingProcessor::TRenderingProcessor(JMessage::TReference const* ref) , mMtx2(nullptr) , mMainFont(nullptr) , mRubyFont(nullptr) - , _54(0.0f) - , _58(0.0f) - , _5C(0) - , _60(0xFFFFFFFF) + , mXOffset(0.0f) + , mYOffset(0.0f) + , mImageColorA(0) + , mImageColorB(0xFFFFFFFF) , mColorData1(255, 255, 255, 255) , mColorData2(255, 255, 255, 255) , mColorData3(255, 255, 255, 255) , mColorData4(255, 255, 255, 255) , mColorData5(255, 255, 255, 255) - , _78(1.0f) + , mBaseAlphaModifier(1.0f) , mMesgBounds(1.0f, 1.0f, 1.0f, 1.0f) , mLocate(0.0f, 0.0f, 0.0f, 0.0f) , mCurrLine(0) , mParagraphNum(0) , mPageInfoNum(0) - , _BC(0.0f) - , _C0(42.0f) - , _C4(0.0f) + , mActiveCharWidth(0.0f) + , mActiveLineHeight(42.0f) + , mCharacterWidth(0.0f) , mLineHeight(42.0f) - , _CC(0, 0, 0, 0) - , _D0(255, 255, 255, 255) - , _D4(255, 255, 255, 255) - , _D8(255, 255, 255, 255) + , mDefaultWhite(0, 0, 0, 0) + , mDefaultBlack(255, 255, 255, 255) + , mDefaultCharColor(255, 255, 255, 255) + , mDefaultGradColor(255, 255, 255, 255) , mFontWidthAdjusted(1.0f) , mFontHeightAdjusted(1.0f) , mFontWidth(1.0f) , mFontHeight(1.0f) - , _F2(0) - , _10C(0.5f) + , mDoDrawRuby(false) + , mRubyWidthModifier(0.5f) { mFlags.clear(); mFlags.unset(0x70); @@ -142,7 +142,7 @@ TRenderingProcessor::TRenderingProcessor(JMessage::TReference const* ref) mOnePageLines = new u8[0x40]; resetOnePageLine(); mRubyBuffer = P2JME::sRubyDataBuffer; - mPageInfoCounts = new u8[0x14]; + mPageInfoCounts = new u8[20]; } /** @@ -201,24 +201,24 @@ void TRenderingProcessor::setDrawLocateY() */ void TRenderingProcessor::do_begin(const void* p1, char const* p2) { - mFontWidthAdjusted = mFontWidth; - mFontHeightAdjusted = mFontHeight; - _F0 = 0; - _F1 = 0; - mCharacterNum = 0; - _40 = 0; + mFontWidthAdjusted = mFontWidth; + mFontHeightAdjusted = mFontHeight; + mCurrColorIndex = 0; + mSecondaryColorIndex = 0; + mCharacterNum = 0; + mInfoIndex = 0; initRuby(); - f32 v1 = static_cast(p1)[4]; - _BC = v1; - _C4 = v1; - mLineHeight = _C0; + f32 wid = static_cast(p1)[4]; + mActiveCharWidth = wid; + mCharacterWidth = wid; + mLineHeight = mActiveLineHeight; mFlags.unset(0x10000000); mPageInfoNum = 0; mCurrLine = 0; mParagraphNum = 0; setDrawLocate(); mMatrixType = 0; - mMainFont->setGX(_CC, _D0); + mMainFont->setGX(mDefaultWhite, mDefaultBlack); } /** @@ -531,35 +531,35 @@ void TRenderingProcessor::do_character(int character) if (character == '\n') { newParagraph(); } else { - if (_F0 == 0) { - mColorData1 = _D4; + if (mCurrColorIndex == 0) { + mColorData1 = mDefaultCharColor; } else { - u32 f0 = _F0; + u32 f0 = mCurrColorIndex; JUtility::TColor* colorArray = (JUtility::TColor*)getResourceContainer()->getResourceColor()->mBlock.getRaw(); mColorData1.set(colorArray[f0 + 3]); } - mColorData1.a = f32(mColorData1.a) * _78; + mColorData1.a = f32(mColorData1.a) * mBaseAlphaModifier; - if (_F1 == 0) { - mColorData2 = _D8; + if (mSecondaryColorIndex == 0) { + mColorData2 = mDefaultGradColor; } else { - u32 f1 = _F1; + u32 f1 = mSecondaryColorIndex; JUtility::TColor* colorArray = (JUtility::TColor*)getResourceContainer()->getResourceColor()->mBlock.getRaw(); mColorData2.set(colorArray[f1 + 3]); } - mColorData2.a = f32(mColorData2.a) * _78; + mColorData2.a = f32(mColorData2.a) * mBaseAlphaModifier; f32 xScale = mFontWidthAdjusted * (f32)mMainFont->getWidth(); if (mFlags.isSet(1)) { mLocate.i.x += calcWidth(mMainFont, character, xScale, true); } else { - mLocate.i.x += doDrawLetter(mLocate.i.x + _54, mLocate.i.y + _58, xScale, mFontHeightAdjusted * (f32)mMainFont->getHeight(), - character, true); + mLocate.i.x += doDrawLetter(mLocate.i.x + mXOffset, mLocate.i.y + mYOffset, xScale, + mFontHeightAdjusted * (f32)mMainFont->getHeight(), character, true); } - mLocate.i.x += _C4; - _40++; + mLocate.i.x += mCharacterWidth; + mInfoIndex++; } if (sys->mPlayData->mIsRubyFont) { @@ -584,9 +584,9 @@ void TRenderingProcessor::mf() */ void TRenderingProcessor::do_select_begin(u32) { - _A0 = 0; - mLocate.i.x = mLocate.f.x + mMainFont->getWidth() * 3; - mLocate.i.y = mLocate.f.y + (mMainFont->getHeight() * int(_A0 + 3)); + mSelectSeparateNum = 0; + mLocate.i.x = mLocate.f.x + mMainFont->getWidth() * 3; + mLocate.i.y = mLocate.f.y + (mMainFont->getHeight() * int(mSelectSeparateNum + 3)); } /** @@ -605,9 +605,9 @@ void TRenderingProcessor::do_select_end() */ void TRenderingProcessor::do_select_separate() { - _A0++; + mSelectSeparateNum++; mLocate.i.x = mLocate.f.x + mMainFont->getWidth() * 3; - mLocate.i.y = mLocate.f.y + (mMainFont->getHeight() * int(_A0 + 3)); + mLocate.i.y = mLocate.f.y + (mMainFont->getHeight() * int(mSelectSeparateNum + 3)); } /** @@ -630,11 +630,11 @@ bool TRenderingProcessor::tagColor(const void* p1, u32 p2) { u8 v1 = *static_cast(p1); if (v1 == 0) { - _F0 = v1; - _F1 = v1; + mCurrColorIndex = v1; + mSecondaryColorIndex = v1; } else { - _F0 = v1; - _F1 = v1 + 1; + mCurrColorIndex = v1; + mSecondaryColorIndex = v1 + 1; } return true; } @@ -663,15 +663,15 @@ bool TRenderingProcessor::tagRuby(const void* data, u32 size) strncpy(mRubyBuffer, (char*)data + 1, size - 1); mRubyBuffer[size - 1] = 0; - _F2 = 1; - _F4 = mCharacterNum - 1; - _F8 = ((u8*)data)[0]; - _FC = size - 1; - _104 = mLocate.i.x; - - f32 y = mFontHeightAdjusted * mMainFont->getAscent(); - y = (y >= 0.0f) ? y + 0.5f : y - 0.5f; - _108 = mLocate.i.y - (int)y; + + mDoDrawRuby = true; + mRubyStartCharIndex = mCharacterNum - 1; + mRubyCurrentStringSize = ((u8*)data)[0]; + mRubyBufferCurrentSize = size - 1; + + mRubyCurrentXPos = mLocate.i.x; + f32 y = mFontHeightAdjusted * mMainFont->getAscent(); + mRubyCurrentYPos = mLocate.i.y - ROUND_F32_TO_U8(y); } return true; @@ -692,8 +692,8 @@ bool TRenderingProcessor::tagColorEX(u16 id, const void* p1, u32) u8* data = (u8*)p1; switch (id) { case 0: - _F0 = data[0]; - _F1 = data[1]; + mCurrColorIndex = data[0]; + mSecondaryColorIndex = data[1]; break; } return true; @@ -737,13 +737,13 @@ bool TRenderingProcessor::tagPosition(u16 type, const void* data, u32) { switch (type) { case 0: - _C4 = _BC; + mCharacterWidth = mActiveCharWidth; break; case 1: - _C4 = *(u8*)data; + mCharacterWidth = *(u8*)data; break; case 2: - mLineHeight = _C0; + mLineHeight = mActiveLineHeight; setDrawLocateY(); break; case 3: @@ -1255,10 +1255,10 @@ bool TRenderingProcessor::tagPosition(u16 type, const void* data, u32) */ void TRenderingProcessor::initRuby() { - _F2 = 0; - _F4 = 0; - _F8 = 0; - *mRubyBuffer = 0; + mDoDrawRuby = false; + mRubyStartCharIndex = 0; + mRubyCurrentStringSize = 0; + *mRubyBuffer = 0; } /** @@ -1267,33 +1267,33 @@ void TRenderingProcessor::initRuby() */ void TRenderingProcessor::drawRuby() { - if (!_F2) { + if (!mDoDrawRuby) { return; } if (mFlags.isSet(1)) { - _F2 = false; + mDoDrawRuby = false; return; } f32 height = mFontHeightAdjusted * f32(mMainFont->getAscent()); f32 scale = mLocate.i.y - (int)(f32(ROUND_F32_TO_U8(height))); - if (_108 > scale) { - _108 = scale; + if (mRubyCurrentYPos > scale) { + mRubyCurrentYPos = scale; } - if (mCharacterNum != (int)(_F4 + _F8)) { + if (mCharacterNum != (int)(mRubyStartCharIndex + mRubyCurrentStringSize)) { return; } int msgBuffer[33]; - f32 val31 = _10C; + f32 val31 = mRubyWidthModifier; f32 val30 = val31 * f32(mRubyFont->getWidth()); f32 val28 = 0.0f; - f32 val27 = (mLocate.i.x - _C4) - _104; + f32 val27 = (mLocate.i.x - mCharacterWidth) - mRubyCurrentXPos; int msgLen = 0; - for (int i = 0; i < _FC; i++, msgLen++) { + for (int i = 0; i < mRubyBufferCurrentSize; i++, msgLen++) { int byte = mRubyBuffer[i]; if (mRubyFont->isLeadByte(byte)) { byte >>= 4; @@ -1308,18 +1308,20 @@ void TRenderingProcessor::drawRuby() f32 len = f32(msgLen + 1); f32 val29 = (val27 - val28) / len; - if (val29 < _C4 * val31) { - val29 = _C4 * val31; + if (val29 < mCharacterWidth * val31) { + val29 = mCharacterWidth * val31; } - _104 += val29 + 0.5f * (val27 - (val29 * len + val28)); + mRubyCurrentXPos += val29 + 0.5f * (val27 - (val29 * len + val28)); for (int i = 0; i < msgLen; i++) { - _104 += doDrawRuby(_104 + _54, _108 + _58, val30, val31 * f32(mRubyFont->getHeight()), msgBuffer[i], true); - _104 += val29; - _40++; + mRubyCurrentXPos += doDrawRuby(mRubyCurrentXPos + mXOffset, mRubyCurrentYPos + mYOffset, val30, val31 * f32(mRubyFont->getHeight()), + msgBuffer[i], true); + mRubyCurrentXPos += val29; + mInfoIndex++; } - _F2 = false; + mDoDrawRuby = false; + /* stwu r1, -0x110(r1) mflr r0 @@ -1589,15 +1591,15 @@ bool TRenderingProcessor::tagImage(u16 p1, const void* p2, u32 p3) if (gP2JMEMgr) { JUTTexture* img = gP2JMEMgr->getImage(ImageGroup::ID0, firstByte); if (img && !mFlags.isSet(0x1)) { - JUtility::TColor color2(_60); - JUtility::TColor color1(_5C); + JUtility::TColor color2(mImageColorB); + JUtility::TColor color1(mImageColorA); switch (type) { case 0: GXColor* colorA = &cBtnIconColor[firstByte].a; GXColor* colorB = &cBtnIconColor[firstByte].b; if (firstByte < 8) { - _60.set(colorA->r, colorA->g, colorA->b, colorA->a); - _5C.set(colorB->r, colorB->g, colorB->b, colorB->a); + mImageColorB.set(colorA->r, colorA->g, colorA->b, colorA->a); + mImageColorA.set(colorB->r, colorB->g, colorB->b, colorB->a); mColorData4.set(255, 255, 255, 255); mColorData5.set(205, 205, 205, 255); } else { @@ -1606,39 +1608,39 @@ bool TRenderingProcessor::tagImage(u16 p1, const void* p2, u32 p3) } break; default: - if (_F0 == 0) { - mColorData4 = _D4; + if (mCurrColorIndex == 0) { + mColorData4 = mDefaultCharColor; } else { - u32 f0 = _F0; + u32 f0 = mCurrColorIndex; JUtility::TColor* colorArray = (JUtility::TColor*)getResourceContainer()->getResourceColor()->mBlock.getRaw(); mColorData4.set(colorArray[f0 + 3]); } - if (_F1 == 0) { - mColorData5 = _D8; + if (mSecondaryColorIndex == 0) { + mColorData5 = mDefaultGradColor; } else { - u32 f1 = _F1; + u32 f1 = mSecondaryColorIndex; JUtility::TColor* colorArray = (JUtility::TColor*)getResourceContainer()->getResourceColor()->mBlock.getRaw(); mColorData5.set(colorArray[f1 + 3]); } break; } - mColorData4.a = f32(mColorData4.a) * _78; - mColorData5.a = f32(mColorData5.a) * _78; - doDrawImage(img, mLocate.i.x + _54, mLocate.i.y + _58, width, height); + mColorData4.a = f32(mColorData4.a) * mBaseAlphaModifier; + mColorData5.a = f32(mColorData5.a) * mBaseAlphaModifier; + doDrawImage(img, mLocate.i.x + mXOffset, mLocate.i.y + mYOffset, width, height); switch (type) { case 0: - _60 = color2; - _5C = color1; + mImageColorB = color2; + mImageColorA = color1; break; } } } mLocate.i.x += width; - _40++; - mMainFont->setGX(_CC, _D0); + mInfoIndex++; + mMainFont->setGX(mDefaultWhite, mDefaultBlack); return true; } @@ -2025,7 +2027,7 @@ f32 TRenderingProcessor::doDrawLetter(f32 p1, f32 p2, f32 p3, f32 p4, int p5, bo f32 TRenderingProcessor::doDrawRuby(f32 p1, f32 p2, f32 p3, f32 p4, int p5, bool p6) { JUtility::TColor charColor; - mColorData3.a = 255.0f * _78; + mColorData3.a = 255.0f * mBaseAlphaModifier; calcColorCoe(mColorData3, &charColor); mRubyFont->setCharColor(charColor); mRubyFont->drawChar_scale(p1, p2, p3, p4, p5, p6); @@ -2240,7 +2242,7 @@ void TRenderingProcessor::doDrawImage(JUTTexture* texture, f32 p2, f32 p3, f32 p */ void TRenderingProcessor::setImageGX() { - if (*(u32*)&_5C == 0 && *(u32*)&_60 == -1) { + if (mImageColorA.toUInt32() == 0 && mImageColorB.toUInt32() == -1) { GXSetNumChans(1); GXSetChanCtrl(GX_COLOR0A0, GX_FALSE, GX_SRC_VTX, GX_SRC_VTX, 1, GX_DF_CLAMP, GX_AF_NONE); GXClearVtxDesc(); @@ -2266,8 +2268,8 @@ void TRenderingProcessor::setImageGX() GXSetNumTexGens(1); GXSetTevOrder(GX_TEVSTAGE0, GX_TEXCOORD0, GX_TEXMAP0, GX_COLOR_NULL); GXSetChanCtrl(GX_COLOR0A0, GX_FALSE, GX_SRC_REG, GX_SRC_VTX, 0, GX_DF_NONE, GX_AF_NONE); - GXSetTevColor(GX_TEVREG0, *(GXColor*)&_5C); - GXSetTevColor(GX_TEVREG1, *(GXColor*)&_60); + GXSetTevColor(GX_TEVREG0, *(GXColor*)&mImageColorA); + GXSetTevColor(GX_TEVREG1, *(GXColor*)&mImageColorB); GXSetTevColorIn(GX_TEVSTAGE0, GX_CC_C0, GX_CC_C2, GX_CC_TEXC, GX_CC_ZERO); GXSetTevAlphaIn(GX_TEVSTAGE0, GX_CA_A0, GX_CA_A1, GX_CA_TEXA, GX_CA_ZERO); GXSetTevColorOp(GX_TEVSTAGE0, GX_TEV_ADD, GX_TB_ZERO, GX_CS_SCALE_1, GX_TRUE, GX_TEVPREV); @@ -2697,8 +2699,8 @@ void TRenderingProcessor::drawImage(JUTTexture* img, f32 p2, f32 p3, f32 p4, f32 */ void TRenderingProcessor::reset() { - _54 = 0.0f; - _58 = 0.0f; + mXOffset = 0.0f; + mYOffset = 0.0f; } /** @@ -3474,20 +3476,20 @@ void TRenderingProcessor::setTextBoxInfo(J2DPane* pane) JUtility::TColor chrcolor = text->mCharColor; JUtility::TColor gradcolor = text->mGradientColor; - _78 = (f32)text->mColorAlpha / 255.0f; - _60 = black; - _5C = white; - _D4 = chrcolor; - _D8 = gradcolor; - _CC = white; - _D0 = black; - - _BC = text->mCharSpacing; - _C4 = text->mCharSpacing; - _C0 = text->mLineSpacing; - mLineHeight = text->mLineSpacing; - mTextBoxWidth = text->getWidth(); - mTextBoxHeight = text->getHeight(); + mBaseAlphaModifier = (f32)text->mColorAlpha / 255.0f; + mImageColorB = black; + mImageColorA = white; + mDefaultCharColor = chrcolor; + mDefaultGradColor = gradcolor; + mDefaultWhite = white; + mDefaultBlack = black; + + mActiveCharWidth = text->mCharSpacing; + mCharacterWidth = text->mCharSpacing; + mActiveLineHeight = text->mLineSpacing; + mLineHeight = text->mLineSpacing; + mTextBoxWidth = text->getWidth(); + mTextBoxHeight = text->getHeight(); mFontWidth = text->mFontSize.x / mMainFont->getWidth(); mFontHeight = text->mFontSize.y / mMainFont->getHeight(); diff --git a/src/sysGCU/messageSequence.cpp b/src/sysGCU/messageSequence.cpp index 12c0f2c2d..5bbc098ce 100644 --- a/src/sysGCU/messageSequence.cpp +++ b/src/sysGCU/messageSequence.cpp @@ -13,16 +13,16 @@ namespace P2JME { */ TSequenceProcessor::TSequenceProcessor(const JMessage::TReference* ref, JMessage::TControl* control) : JMessage::TSequenceProcessor(ref, control) - , _50(0.0f) - , mController1(0) - , mController2(0) - , _5C(0) - , _60(0) - , _64(0) + , mPageFinishWaitTimer(0.0f) + , mController1(nullptr) + , mController2(nullptr) + , mCharactersWritten(0) + , mUnused0(0) + , mUnused1(0) { mFlags.clear(); - _4C = 0.11f; + mPageFinishWaitDuration = 0.11f; } /** @@ -31,13 +31,13 @@ TSequenceProcessor::TSequenceProcessor(const JMessage::TReference* ref, JMessage */ void TSequenceProcessor::do_begin(const void* arg0, const char* arg1) { - mFlags.unset(8); - _4C = 0.11f; - _50 = _4C; - _5C = 0; - _60 = 0; - _64 = 0; - _6C = false; + resetFlag(SeqProc_IsForceFinish); + mPageFinishWaitDuration = 0.11f; + mPageFinishWaitTimer = mPageFinishWaitDuration; + mCharactersWritten = 0; + mUnused0 = 0; + mUnused1 = 0; + mFastSeType = false; } /** @@ -134,37 +134,37 @@ bool TSequenceProcessor::do_isReady() { bool check = false; - if (mFlags.isSet(1)) { + if (isFlag(SeqProc_IsActive)) { return false; } - if (mFlags.isSet(2)) { - _50 -= sys->mDeltaTime; - if (_50 <= 0.0f) { + if (isFlag(SeqProc_IsWaitingPressA)) { + mPageFinishWaitTimer -= sys->mDeltaTime; + if (mPageFinishWaitTimer <= 0.0f) { bool checkVars = (mController1 || mController2); P2ASSERTLINE(381, checkVars); - if ((mController1 && (mController1->getButtonDown() & PAD_BUTTON_A)) - || (mController2 && (mController2->getButtonDown() & PAD_BUTTON_A))) { + if ((mController1 && (mController1->getButtonDown() & Controller::PRESS_A)) + || (mController2 && (mController2->getButtonDown() & Controller::PRESS_A))) { resetAbtnWait(); - mFlags.unset(8); + resetFlag(SeqProc_IsForceFinish); } } } else { f32 frameCount = 1.0f; - if (mFlags.isSet(8)) { + if (isFlag(SeqProc_IsForceFinish)) { frameCount = 10.0f; - } else if ((mController1 && (mController1->getButtonDown() & PAD_BUTTON_B)) - || (mController2 && (mController2->getButtonDown() & PAD_BUTTON_B))) { + } else if ((mController1 && (mController1->getButtonDown() & Controller::PRESS_B)) + || (mController2 && (mController2->getButtonDown() & Controller::PRESS_B))) { doFastForwardSE(); - mFlags.set(8); - } else if ((mController1 && (mController1->getButton() & PAD_BUTTON_A)) - || (mController2 && (mController2->getButton() & PAD_BUTTON_A))) { + setFlag(SeqProc_IsForceFinish); + } else if ((mController1 && (mController1->getButton() & Controller::PRESS_A)) + || (mController2 && (mController2->getButton() & Controller::PRESS_A))) { frameCount = 2.5f; } - _50 = -((frameCount * sys->mDeltaTime) - _50); - if (_50 <= 0.0f) { + mPageFinishWaitTimer = -((frameCount * sys->mDeltaTime) - mPageFinishWaitTimer); + if (mPageFinishWaitTimer <= 0.0f) { check = true; } } @@ -181,7 +181,7 @@ bool TSequenceProcessor::do_jump_isReady() { return false; } * @note Address: 0x80437B90 * @note Size: 0xC */ -void TSequenceProcessor::do_jump(const void* arg0, const char* arg1) { _50 = _4C; } +void TSequenceProcessor::do_jump(const void* arg0, const char* arg1) { mPageFinishWaitTimer = mPageFinishWaitDuration; } /** * @note Address: 0x80437B9C @@ -199,7 +199,7 @@ int TSequenceProcessor::do_branch_queryResult() { return -1; } * @note Address: 0x80437BA8 * @note Size: 0xC */ -void TSequenceProcessor::do_branch(const void* arg0, const char* arg1) { _50 = _4C; } +void TSequenceProcessor::do_branch(const void* arg0, const char* arg1) { mPageFinishWaitTimer = mPageFinishWaitDuration; } /** * @note Address: 0x80437BB4 @@ -216,14 +216,14 @@ void TSequenceProcessor::do_character(int arg0) } } - _50 += _4C; + mPageFinishWaitTimer += mPageFinishWaitDuration; if (argCheck) { - if (_5C == 0) { + if (mCharactersWritten == 0) { doCharacterSEStart(); } else { doCharacterSE(arg0); } - _5C += 1; + mCharactersWritten++; } } @@ -241,17 +241,17 @@ bool TSequenceProcessor::tagControl(u16 arg0, const void* arg1, u32 arg2) case 1: u8 byte = (s8) * ((s8*)arg1); if (byte == 0xFF) { - _4C = 0.11f; + mPageFinishWaitDuration = 0.11f; } else { - _4C = (f32)byte / 100.0f; + mPageFinishWaitDuration = (f32)byte / 100.0f; } - _50 = _4C; + mPageFinishWaitTimer = mPageFinishWaitDuration; break; case 2: - _6C = *(s8*)arg1; + mFastSeType = *(s8*)arg1; break; default: - P2ASSERTLINE(633, 0); + P2ASSERTLINE(633, false); break; } @@ -264,9 +264,9 @@ bool TSequenceProcessor::tagControl(u16 arg0, const void* arg1, u32 arg2) */ void TSequenceProcessor::setAbtnWait() { - mFlags.set(2); - _50 = 0.5f; - mFlags.unset(4); + setFlag(SeqProc_IsWaitingPressA); + mPageFinishWaitTimer = 0.5f; + resetFlag(SeqProc_IsWriting); doCharacterSEEnd(); } @@ -277,10 +277,10 @@ void TSequenceProcessor::setAbtnWait() void TSequenceProcessor::resetAbtnWait() { doResetAbtnWaitSE(); - mFlags.unset(2); - _50 = _4C; - mFlags.set(4); - _5C = 0; + resetFlag(SeqProc_IsWaitingPressA); + mPageFinishWaitTimer = mPageFinishWaitDuration; + setFlag(SeqProc_IsWriting); + mCharactersWritten = 0; } /** @@ -293,11 +293,6 @@ void TSequenceProcessor::doResetAbtnWaitSE() { PSSystem::spSysIF->playSystemSe(P * @note Address: 0x80437E34 * @note Size: 0x18 */ -void TSequenceProcessor::reset() -{ - for (int i = 0; i < 4; i++) { - mFlags.byteView[i] = 0; - } -} +void TSequenceProcessor::reset() { mFlags.clear(); } } // namespace P2JME diff --git a/src/sysGCU/modelEffect.cpp b/src/sysGCU/modelEffect.cpp index 67d630d0f..757a07ced 100644 --- a/src/sysGCU/modelEffect.cpp +++ b/src/sysGCU/modelEffect.cpp @@ -53,7 +53,7 @@ void ParticleMgr::entryModelEffect(ModelEffectData* data) { mModelEffectDataRoot */ ModelEffectData* ParticleMgr::getModelEffectData(u64 id) { - FOREACH_NODE(ModelEffectData, mModelEffectDataRoot.mChild, node) + FOREACH_NODE(ModelEffectData, mModelEffectDataRoot.getChild(), node) { if (node->getID() == id) { return node; @@ -90,11 +90,11 @@ void ParticleMgr::testCreateModelEffect(int, int, Vector3f&) */ void ModelEffect::doAnimation() { - PSMTXCopy(mMtx.mMatrix.mtxView, mModel->mJ3dModel->mPosMtx); + PSMTXCopy(mMtx.mMatrix.mtxView, mModel->mJ3dModel->getBaseTRMtx()); mModel->mJ3dModel->calc(); if (mCulled) { - for (int i = 0; i < sys->mGfx->mActiveViewports; i++) { + for (int i = 0; i < sys->mGfx->getViewportNum(); i++) { mViewportVisibleFlag[i] = 0; } } else { @@ -102,7 +102,7 @@ void ModelEffect::doAnimation() getLODSphere(bounds); Graphics* gfx = sys->mGfx; - for (int i = 0; i < gfx->mActiveViewports; i++) { + for (int i = 0; i < gfx->getViewportNum(); i++) { Viewport* vp = gfx->getViewport(i); if (!vp->viewable()) { diff --git a/src/sysGCU/modelMgr.cpp b/src/sysGCU/modelMgr.cpp index f237d5ac1..1fb2b93b5 100644 --- a/src/sysGCU/modelMgr.cpp +++ b/src/sysGCU/modelMgr.cpp @@ -31,7 +31,7 @@ ModelMgr::ModelMgr(int modelDataLimit, J3DModelData** modelData, int heapLimit, mHeaps = new JKRSolidHeap*[heapLimit]; int maxSize = calcMaximumModelSize(); for (int i = 0; i < heapLimit; i++) { - mHeaps[i] = JKRSolidHeap::create((maxSize + 0x1FU) & ~0x1F, JKRHeap::sCurrentHeap, true); + mHeaps[i] = JKRSolidHeap::create(OSRoundUp32B(maxSize), JKRHeap::sCurrentHeap, true); JUT_ASSERTLINE(82, mHeaps[i] != nullptr, "solid heap creation failed !\n"); } } diff --git a/src/sysGCU/movieMessage.cpp b/src/sysGCU/movieMessage.cpp index 06ac1db91..37199f034 100644 --- a/src/sysGCU/movieMessage.cpp +++ b/src/sysGCU/movieMessage.cpp @@ -92,7 +92,7 @@ void WindowPane::moveWindow(bool flag) mPane->setOffset(mNewPosition.x, mNewPosition.y); - f32 newangle = JMath::atanTable_.atan2_(mNewPosition.x - startPosition.x, mNewPosition.y - startPosition.y); + f32 newangle = JMAAtan2Radian(mNewPosition.x - startPosition.x, mNewPosition.y - startPosition.y); f32 scale = roundAng(mCurrAngle); f64 newScale = fabs((scale - 270.0f) / 180.f); scale = (f32)newScale + 1.0f; @@ -133,10 +133,10 @@ void WindowPane::close(f32 duration) */ AbtnPane::AbtnPane(u8 state) { - mState = state; - mTimer1 = 0.0f; - mTimer2 = 0.0f; - mTimer1 = -0.0f; + mState = state; + mAnimAlpha = 0.0f; + mAppearAlpha = 0.0f; + mAnimAlpha = -0.0f; } /** @@ -157,31 +157,31 @@ void AbtnPane::doInit() void AbtnPane::update() { f32 one = 1.0f; - f32 alpha = (mTimer1 * TAU) / one; + f32 alpha = (mAnimAlpha * TAU) / one; alpha = cosf(alpha); alpha = (1.0f - alpha) * 0.5f; switch (mState) { case 0: - mTimer2 += -(sys->mDeltaTime * 2.0f); - if (mTimer2 < 0.0f) { - mTimer2 = 0.0f; + mAppearAlpha += -(sys->mDeltaTime * 2.0f); + if (mAppearAlpha < 0.0f) { + mAppearAlpha = 0.0f; } break; case 1: - mTimer2 += sys->mDeltaTime * 2.0f; - if (mTimer2 > 1.0f) { - mTimer2 = 1.0f; + mAppearAlpha += sys->mDeltaTime * 2.0f; + if (mAppearAlpha > 1.0f) { + mAppearAlpha = 1.0f; } break; } - mTimer1 += sys->mDeltaTime; - if (mTimer1 > 1.0f) { - mTimer1 = 0.0f; + mAnimAlpha += sys->mDeltaTime; + if (mAnimAlpha > 1.0f) { + mAnimAlpha = 0.0f; } J2DPane* pane = mPane; - alpha = alpha * 255.0f * mTimer2; + alpha = alpha * 255.0f * mAppearAlpha; pane->setAlphaFromFloat(alpha); } @@ -202,8 +202,7 @@ PodIconScreen::PodIconScreen() u16 x = sys->getRenderModeWidth(); mInitialPos.set(x * 0.75f, y, 100.0f); reset(); - - mIsVisible = false; + hide(); } /** @@ -672,21 +671,14 @@ void MessageWindowScreen::set(JKRArchive* arc) * @note Size: 0x80 */ TControl::TControl() + : mMessageWindow(nullptr) + , mPodIcon(nullptr) + , mPaneMgDemo(nullptr) + , mIsActive(false) + , mModeFlag(MODEFLAG_Inactive) { - mMessageWindow = nullptr; - mPodIcon = nullptr; - mPaneMgDemo = nullptr; - mIsActive = false; - mModeFlag = MODEFLAG_Inactive; - mFlags.bytesView[0] = 0; - mFlags.bytesView[1] = 0; - mFlags.bytesView[2] = 0; - mFlags.bytesView[3] = 0; - mFlags.bytesView[0] = 0; - mFlags.bytesView[1] = 0; - mFlags.bytesView[2] = 0; - mFlags.bytesView[3] = 0; - mFlags.dwordView |= 1; + mFlags.clear(); + mFlags.set(ControlFlag_UnsuspendOnFinish); } /** @@ -731,10 +723,10 @@ bool TControl::onInit() sys->heapStatusEnd("podIcon"); sys->heapStatusEnd("PMT_onInit_arc"); sys->heapStatusStart("PMT_onInit_initRenderingProcessor", nullptr); - initRenderingProcessor(0x400); + initRenderingProcessor(1024); // max 1024 characters can be animated at once sys->heapStatusEnd("PMT_onInit_initRenderingProcessor"); sys->heapStatusEnd("P2JME::Movie::TControl::onInit"); - // return 1; + return 1; /* stwu r1, -0x40(r1) mflr r0 @@ -1305,16 +1297,16 @@ TControl::EModeFlag TControl::setMode(EModeFlag mode) case MODEFLAG_Inactive: mIsActive = false; mMessageWindow->mWindowPane->mPane->hide(); - mSequenceProc->mFlags.set(1); + mSequenceProc->setFlag(TSequenceProcessor::SeqProc_IsActive); break; case MODEFLAG_Start: PSSystem::spSysIF->playSystemSe(PSSE_MP_SHIP_CALLING_01, 0); mMessageWindow->open(0.5f); mPodIcon->appear(); - mSequenceProc->mFlags.set(1); + mSequenceProc->setFlag(TSequenceProcessor::SeqProc_IsActive); break; case MODEFLAG_Writing: - mSequenceProc->mFlags.unset(1); + mSequenceProc->resetFlag(TSequenceProcessor::SeqProc_IsActive); break; case MODEFLAG_Finish: PSSystem::spSysIF->playSystemSe(PSSE_MP_SHIP_PERIOD_01, 0); @@ -1713,7 +1705,7 @@ void MessageWindowScreen::open(f32 duration) { mWindowPane->open(duration); } bool TControl::update(Controller* pad1, Controller* pad2) { bool ret = Window::TControl::update(pad1, pad2); // matching bs when this is bool - if (mFlags.dwordView & 1 && Game::moviePlayer && (Game::moviePlayer->mFlags.isSet(2))) { + if (mFlags.isSet(ControlFlag_UnsuspendOnFinish) && Game::moviePlayer && Game::moviePlayer->isFlag(Game::MVP_IsFinished)) { if (mIsActive) { reset(); Game::moviePlayer->unsuspend(1, false); @@ -1745,20 +1737,20 @@ bool TControl::update(Controller* pad1, Controller* pad2) } break; case MODEFLAG_Writing: - if (mStatus.typeView & 2) { + if (mStatus.isSet(2)) { setMode(MODEFLAG_Finish); } break; case MODEFLAG_Finish: if (mMessageWindow->mWindowPane->mState == 4 && mPodIcon->mState == 3) { reset(); - if ((mFlags.dwordView & 1) && Game::moviePlayer) { + if (mFlags.isSet(ControlFlag_UnsuspendOnFinish) && Game::moviePlayer) { Game::moviePlayer->unsuspend(1, true); } } } - if (mSequenceProc->mFlags.isSet(2)) { // done writing, can press A + if (mSequenceProc->isFlag(TSequenceProcessor::SeqProc_IsWaitingPressA)) { // done writing, can press A MessageWindowScreen* window = mMessageWindow; window->mAButton->mState = 1; window->mArrowPane->mState = 1; diff --git a/src/sysGCU/pikmin2MemoryCardMgr.cpp b/src/sysGCU/pikmin2MemoryCardMgr.cpp index ec703f12c..c0f22266b 100644 --- a/src/sysGCU/pikmin2MemoryCardMgr.cpp +++ b/src/sysGCU/pikmin2MemoryCardMgr.cpp @@ -859,7 +859,7 @@ void Mgr::readGameOption(Stream& stream) { sys->mPlayData->read(stream); } bool Mgr::checkSerialNo(bool param_1) { bool result = false; - if (!(sys->mPlayData->mFlags.isSet(1))) { + if (!(sys->mPlayData->mFlags.isSet(CommonSaveData::Mgr::SaveFlag_SerialNoSet))) { if (param_1) { mErrorCode = 3; } @@ -899,10 +899,10 @@ bool Mgr::commandSavePlayerNoCheckSerialNo(s8 fileIndex, bool param_2) if (readCardSerialNo(&serial, CARDSLOT_Unk0)) { u32* buffer = new (mHeap, -32) u32[0x3000]; P2ASSERTLINE(1939, buffer); - sys->mPlayData->_18++; + sys->mPlayData->mSaveCount++; buffer[0] = 'PlVa'; // Magic Word buffer[1] = '0003'; // Version - buffer[4] = sys->mPlayData->_18; + buffer[4] = sys->mPlayData->mSaveCount; ((u8*)buffer)[8] = fileIndex; // File Index ((u8*)buffer)[12] = 0; ((u8*)buffer)[13] = param_2; @@ -1067,7 +1067,7 @@ bool Mgr::commandLoadPlayer(s8 fileIndex) readPlayer(ramStream); CommonSaveData::Mgr* saveMgr = sys->mPlayData; saveMgr->mFileIndex = fileIndex; - saveMgr->_18 = buffer[4]; + saveMgr->mSaveCount = buffer[4]; saveMgr->mTime = buffer[0xF]; saveMgr->_22 = *(u16*)&((u8*)buffer)[0xE]; // hmm. } @@ -1180,7 +1180,7 @@ bool Mgr::savePlayerProc(s8 fileIndex, u8* param_2, bool param_3) bool Mgr::commandCheckSerialNo() { bool result = false; - if (!(sys->mPlayData->mFlags.isSet(1))) { + if (!(sys->mPlayData->mFlags.isSet(CommonSaveData::Mgr::SaveFlag_SerialNoSet))) { result = true; mErrorCode = 3; } else { diff --git a/src/sysGCU/pikmin2THPPlayer.cpp b/src/sysGCU/pikmin2THPPlayer.cpp index 03601db78..5236b7d7b 100644 --- a/src/sysGCU/pikmin2THPPlayer.cpp +++ b/src/sysGCU/pikmin2THPPlayer.cpp @@ -57,7 +57,7 @@ THPPlayer::THPPlayer() , mHeap(nullptr) , _C8(this, &loadResource) , mLoadResArg() - , _E4(0) + , mDrawPosType(0) , _E8(1) { mCaptionMgr = new Caption::Mgr; @@ -95,7 +95,7 @@ void THPPlayer::load(EMovieIndex movieIdx) const THPPlayerFileSettingTable* data = &sTHPPlayerFileSettingTable[movieIdx]; mLoadResArg.mThpFileName = data->mThpFilePath; mLoadResArg.mCaptionFileName = data->mIniFilePath; - _E4 = data->_08; + mDrawPosType = data->mDrawPosType; load(); @@ -342,7 +342,7 @@ void THPPlayer::update() */ void THPPlayer::draw(Graphics& gfx) { - switch (_E4) { + switch (mDrawPosType) { case 1: draw(gfx, (int)(System::getRenderModeObj()->fbWidth - mVideoInfo.mXSize) / 2, 20, mVideoInfo.mXSize, mVideoInfo.mYSize); break; diff --git a/src/sysGCU/reset.cpp b/src/sysGCU/reset.cpp index 8bb3af2df..7a2a6a176 100644 --- a/src/sysGCU/reset.cpp +++ b/src/sysGCU/reset.cpp @@ -155,7 +155,7 @@ void ResetManager::draw() graf.setPort(); f32 alpha = (mFadeTimer * 255.0f) / 0.25f; - alpha = (alpha >= 0.0f) ? alpha + 0.5f : alpha - 0.5f; + alpha = ROUND_F32_TO_U8(alpha); J2DFillBox(0.0f, 0.0f, (f32)JUTVideo::sManager->mRenderModeObj->fbWidth, (f32)JUTVideo::sManager->mRenderModeObj->efbHeight, JUtility::TColor(0, 0, 0, alpha)); diff --git a/src/sysGCU/section.cpp b/src/sysGCU/section.cpp index 87556ad1a..c52c17119 100644 --- a/src/sysGCU/section.cpp +++ b/src/sysGCU/section.cpp @@ -6,6 +6,7 @@ #include "JSystem/JFramework/JFWDisplay.h" #include "Game/MemoryCard/Mgr.h" #include "PSSystem/PSGame.h" +#include "PSM/Scene.h" #include "THP/THPRead.h" #include "System.h" #include "Graphics.h" @@ -105,18 +106,6 @@ Section::~Section() sys->mGfx = nullptr; } -inline f32 getX(f32 x) -{ - // 0.5 / (1 / 60) == 30 - f32 y = x / SINGLE_FRAME_LENGTH; - - if (y >= 0.0f) { - return y + 0.5f; - } else { - return y - 0.5f; - } -} - /** * @note Address: N/A * @note Size: 0x90 @@ -145,7 +134,7 @@ void Section::fadeIn() { drawInit(*mGraphics, Section::Zero); - s32 fadeTimer = getX(mTimeStep); + s32 fadeTimer = ROUND_F32_TO_U8(mTimeStep / SINGLE_FRAME_LENGTH); if (mDisplay->mFader) { mDisplay->mFader->startFadeIn(fadeTimer); } @@ -212,16 +201,8 @@ void Section::main() } while (!mIsLoadingDVD && mIsMainActive); // Don't draw or render while loading from DVD - s32 timer = getX(mTimeStep); - - PSSystem::SceneMgr* mgr = PSSystem::getSceneMgr(); - PSSystem::validateSceneMgr(mgr); - mgr->checkScene(); - - PSSystem::Scene* scene = mgr->mScenes->mChild; - if (scene) { - scene->stopMainSeq(timer); - } + s32 timer = ROUND_F32_TO_U8(mTimeStep / SINGLE_FRAME_LENGTH); + PSMGetSceneMgrCheck()->doStopMainSeqCheck(timer); if (mDisplay->mFader) { mDisplay->mFader->startFadeOut(timer); diff --git a/src/sysGCU/sysShapeModel.cpp b/src/sysGCU/sysShapeModel.cpp index cd1a79253..5ac7e811c 100644 --- a/src/sysGCU/sysShapeModel.cpp +++ b/src/sysGCU/sysShapeModel.cpp @@ -16,7 +16,7 @@ int Model::cullCount; Model::Model(J3DModelData* data, u32 flags, u32 viewNum) { mJ3dModel = new J3DModel(data, flags, viewNum); - mJointCount = mJ3dModel->mModelData->getJointNum(); + mJointCount = mJ3dModel->getModelData()->getJointNum(); initJoints(); _05 = 1; mIsAnimating = false; @@ -50,7 +50,7 @@ void Model::enableMaterialAnim(int type) { switch (type) { case 0: - J3DModelData* data = mJ3dModel->mModelData; + J3DModelData* data = mJ3dModel->getModelData(); for (u16 i = 0; i < data->getMaterialNum(); i++) { J3DMaterialAnm* anm = new J3DMaterialAnm; data->getMaterialNodePointer(i)->change(); @@ -280,7 +280,7 @@ void Model::entry(Sys::Sphere&) bool Model::isVisible(Sys::Sphere& sphere) { Graphics* gfx = sys->mGfx; - for (int i = 0; i < gfx->mActiveViewports; i++) { + for (int i = 0; i < gfx->getViewportNum(); i++) { Viewport* viewport = gfx->getViewport(i); if (viewport->viewable() && viewport->mCamera->isVisible(sphere)) { mIsVisible = true; @@ -298,14 +298,14 @@ bool Model::isVisible(Sys::Sphere& sphere) void Model::jointVisible(bool newVisibility, int jointIndex) { if (newVisibility != false) { - for (J3DMaterial* material = mJ3dModel->mModelData->mJointTree.mJoints[(u16)jointIndex]->mMaterial; material != nullptr; - material = material->mNext) { - RESET_FLAG(material->mShape->mFlags, J3DShape_Hide); + for (J3DMaterial* material = mJ3dModel->getModelData()->getJointNodePointer(jointIndex)->getMesh(); material != nullptr; + material = material->getNext()) { + material->getShape()->offFlag(J3DShape_Hide); } } else { - for (J3DMaterial* material = mJ3dModel->mModelData->mJointTree.mJoints[(u16)jointIndex]->mMaterial; material != nullptr; - material = material->mNext) { - SET_FLAG(material->mShape->mFlags, J3DShape_Hide); + for (J3DMaterial* material = mJ3dModel->getModelData()->getJointNodePointer(jointIndex)->getMesh(); material != nullptr; + material = material->getNext()) { + material->getShape()->onFlag(J3DShape_Hide); } } } @@ -317,9 +317,9 @@ void Model::jointVisible(bool newVisibility, int jointIndex) void Model::hide() { for (u16 i = 0; i < mJointCount; i++) { - for (J3DMaterial* material = mJ3dModel->mModelData->mJointTree.mJoints[i]->mMaterial; material != nullptr; - material = material->mNext) { - SET_FLAG(material->mShape->mFlags, J3DShape_Hide); + for (J3DMaterial* material = mJ3dModel->getModelData()->getJointNodePointer(i)->getMesh(); material != nullptr; + material = material->getNext()) { + material->getShape()->onFlag(J3DShape_Hide); } } } @@ -331,9 +331,9 @@ void Model::hide() void Model::show() { for (u16 i = 0; i < mJointCount; i++) { - for (J3DMaterial* material = mJ3dModel->mModelData->mJointTree.mJoints[i]->mMaterial; material != nullptr; + for (J3DMaterial* material = mJ3dModel->getModelData()->getJointNodePointer(i)->getMesh(); material != nullptr; material = material->mNext) { - RESET_FLAG(material->mShape->mFlags, J3DShape_Hide); + material->getShape()->offFlag(J3DShape_Hide); } } } @@ -345,7 +345,7 @@ void Model::show() void Model::hidePackets() { for (u16 i = 0; i < mJ3dModel->getModelData()->getShapeNum(); i++) { - mJ3dModel->mShapePackets[i].onFlag(J3DShape_Hidden); + mJ3dModel->getShapePacket(i)->onFlag(J3DShape_Hidden); } } @@ -633,7 +633,7 @@ void Model::initJointsRec(int id, Joint* jnt) * @note Address: 0x8043EFB4 * @note Size: 0x30 */ -u16 Model::getJointIndex(char* name) { return mJ3dModel->mModelData->mJointTree.mNametab->getIndex(name); } +u16 Model::getJointIndex(char* name) { return mJ3dModel->getModelData()->getJointName()->getIndex(name); } /** * @note Address: 0x8043EFE4 @@ -690,7 +690,6 @@ bool Model::needViewCalc() */ void Model::viewCalc() { - if (needViewCalc()) { mJ3dModel->viewCalc(); } @@ -703,7 +702,7 @@ void Model::viewCalc() void Model::setCurrentViewNo(u32 viewportNumber) { if (!isMtxImmediate()) { - mJ3dModel->mMtxBuffer->mCurrentViewNumber = viewportNumber; + mJ3dModel->getMtxBuffer()->mCurrentViewNumber = viewportNumber; } } @@ -711,7 +710,7 @@ void Model::setCurrentViewNo(u32 viewportNumber) * @note Address: 0x8043F10C * @note Size: 0x14 */ -bool Model::isMtxImmediate() { return mJ3dModel->mModelData->mModelLoaderFlags >> 4 & 1; } +bool Model::isMtxImmediate() { return mJ3dModel->getModelData()->getFlag() >> 4 & 1; } /** * @note Address: 0x8043F130 diff --git a/src/sysGCU/titleSection.cpp b/src/sysGCU/titleSection.cpp index 99f9695b3..9aa0ce99a 100644 --- a/src/sysGCU/titleSection.cpp +++ b/src/sysGCU/titleSection.cpp @@ -124,8 +124,9 @@ void Section::init() // this entire menu class seems to be for a scrapped debug menu mMenu = new Menu(mController1, JFWSystem::systemFont, false); mMenu->_48 = 260; - mMenu->addKeyEvent(Menu::KeyEvent::U6, PAD_BUTTON_B, new Delegate1(this, &menuCancel)); - mMenu->addKeyEvent(Menu::KeyEvent::INVOKE_ACTION_ON_BUTTON_PRESS, PAD_BUTTON_A, new Delegate1(this, &menuSelect)); + mMenu->addKeyEvent(Menu::KeyEvent::U6, Controller::PRESS_B, new Delegate1(this, &menuCancel)); + mMenu->addKeyEvent(Menu::KeyEvent::INVOKE_ACTION_ON_BUTTON_PRESS, Controller::PRESS_A, + new Delegate1(this, &menuSelect)); int sects = 0; for (int i = 0; i < GameFlow::SN_SECTION_COUNT; i++) { SectionInfo* data = GameFlow::getSectionInfo(i); @@ -295,8 +296,9 @@ void Section::doUpdateMainTitle() PSSystem::validateSceneMgr(mgr); mgr->checkScene(); PSSystem::SeqBase* seq = PSSystem::getSeqData(mgr, BGM_MainTheme); - f32 rate = (ebi::TMainTitleMgr::kFadeOutTime / sys->mDeltaTime); - rate = (rate >= 0.0f) ? rate + 0.5f : rate - 0.5f; + + f32 rate = (ebi::TMainTitleMgr::kFadeOutTime / sys->mDeltaTime); + rate = ROUND_F32_TO_U8(rate); seq->stopSeq((int)rate); } @@ -402,8 +404,8 @@ void Section::doUpdateOmake() PSSystem::validateSceneMgr(mgr); mgr->checkScene(); PSSystem::SeqBase* seq = PSSystem::getSeqData(mgr, BGM_Bonus); - f32 rate = ebi::E2DFader::kFadeTime / sys->mDeltaTime; - rate = (rate >= 0.0f) ? rate + 0.5f : rate - 0.5f; + f32 rate = (ebi::TMainTitleMgr::kFadeOutTime / sys->mDeltaTime); + rate = ROUND_F32_TO_U8(rate); seq->stopSeq((int)rate); } @@ -464,8 +466,8 @@ void Section::doUpdateOption() if (mOptionMgr.mIsFinished) { PSSystem::SeqBase* seq = PSSystemGetSeqCheck(BGM_Options); - f32 rate = ebi::E2DFader::kFadeTime / sys->mDeltaTime; - rate = (rate >= 0.0f) ? rate + 0.5f : rate - 0.5f; + f32 rate = (ebi::TMainTitleMgr::kFadeOutTime / sys->mDeltaTime); + rate = ROUND_F32_TO_U8(rate); seq->stopSeq((int)rate); } if (mOptionMgr.isFinish()) { diff --git a/src/sysGCU/windowMessage.cpp b/src/sysGCU/windowMessage.cpp index 2b8fc035d..291f55d3f 100644 --- a/src/sysGCU/windowMessage.cpp +++ b/src/sysGCU/windowMessage.cpp @@ -17,7 +17,7 @@ namespace Window { DrawInfo::DrawInfo() : CNode("") { - _18 = -1; + mIndex = -1; mTimer = 0.0f; mTimeLimit = 0.5f; } @@ -66,7 +66,7 @@ void DrawInfoMgr::reset() while (node) { DrawInfo* next = (DrawInfo*)node->mNext; P2ASSERTLINE(253, node); - node->_18 = -1; + node->mIndex = -1; node->mTimer = 0.0f; node->del(); mInfoList2.add(node); @@ -83,7 +83,7 @@ DrawInfo* DrawInfoMgr::searchDrawInfo(int id) DrawInfo* ret = nullptr; FOREACH_NODE(DrawInfo, mInfoList1.mChild, node) { - if (id == (int)node->_18) { + if (id == (int)node->mIndex) { ret = node; break; } @@ -99,7 +99,7 @@ DrawInfo* DrawInfoMgr::getDrawInfo(int id) { DrawInfo* node = static_cast(mInfoList2.mChild); if (node) { - node->_18 = id; + node->mIndex = id; node->mTimer = 0.0f; node->del(); mInfoList1.add(node); @@ -131,7 +131,7 @@ TSequenceProcessor::TSequenceProcessor(JMessage::TReference* ref, JMessage::TCon */ void TSequenceProcessor::doCharacterSE(int) { - if (((!Game::moviePlayer) || (Game::moviePlayer && !(Game::moviePlayer->isFlag(Game::MVP_IsFinished)))) && !mFlags.isSet(8)) { + if ((!Game::moviePlayer || (Game::moviePlayer && !Game::moviePlayer->isFlag(Game::MVP_IsFinished))) && !isFlag(SeqProc_IsForceFinish)) { bool isfast = isFastSE(); PSGame::SeMgr* mgr = PSSystem::getSeMgrInstance(); mgr->playMessageVoice(PSSE_MP_VOX_BODY_MN, isfast); @@ -144,7 +144,7 @@ void TSequenceProcessor::doCharacterSE(int) */ void TSequenceProcessor::doCharacterSEStart() { - if (((!Game::moviePlayer) || (Game::moviePlayer && !(Game::moviePlayer->isFlag(Game::MVP_IsFinished)))) && !mFlags.isSet(8)) { + if ((!Game::moviePlayer || (Game::moviePlayer && !Game::moviePlayer->isFlag(Game::MVP_IsFinished))) && !isFlag(SeqProc_IsForceFinish)) { PSGame::SeMgr* mgr = PSSystem::getSeMgrInstance(); mgr->playMessageVoice(PSSE_MP_VOX_HEAD_A_FLAT, false); } @@ -156,7 +156,7 @@ void TSequenceProcessor::doCharacterSEStart() */ void TSequenceProcessor::doCharacterSEEnd() { - if (((!Game::moviePlayer) || (Game::moviePlayer && !(Game::moviePlayer->isFlag(Game::MVP_IsFinished)))) && !mFlags.isSet(8)) { + if ((!Game::moviePlayer || (Game::moviePlayer && !Game::moviePlayer->isFlag(Game::MVP_IsFinished))) && !isFlag(SeqProc_IsForceFinish)) { PSGame::SeMgr* mgr = PSSystem::getSeMgrInstance(); mgr->playMessageVoice(PSSE_MP_VOX_FOOT_A_UP, false); } @@ -197,7 +197,7 @@ BOOL TRenderingProcessor::doDrawCommon(f32 a1, f32 a2, Matrixf* mtx1, Matrixf* m { u8 ret = 255; - DrawInfo* info = mDrawInfo.searchDrawInfo(_40); + DrawInfo* info = mDrawInfo.searchDrawInfo(mInfoIndex); f32 speed = mSpeed; if (-speed >= a2) { f32 speed2 = mTextBoxHeight; @@ -212,22 +212,21 @@ BOOL TRenderingProcessor::doDrawCommon(f32 a1, f32 a2, Matrixf* mtx1, Matrixf* m if (a2 > 0.0f) { calc2 = a2 - speed2; } - speed2 = 0.0f; - speed2 = speed * speed - calc2 * calc2; - speed2 = _sqrtf(speed2); - speed2 = -speed2; - speed = JMath::atanTable_.atan2_(speed2, calc2); - calc = speed + HALF_PI; - f32 what = calc2 / mSpeed * 255.0f; - calc = (what >= 0.0f) ? what + 0.5f : what - 0.5f; - ret = 255 - (u8)calc; - calc2 = speed2 + mSpeed; + speed2 = 0.0f; + speed2 = speed * speed - calc2 * calc2; + speed2 = _sqrtf(speed2); + speed2 = -speed2; + speed = JMAAtan2Radian(speed2, calc2); + calc = speed + HALF_PI; + calc = ROUND_F32_TO_U8(calc2 / mSpeed * 255.0f); + ret = 255 - (u8)calc; + calc2 = speed2 + mSpeed; } } if (!info) { info = (DrawInfo*)mDrawInfo.mInfoList1.mChild; if (info) { - info->_18 = _40; + info->mIndex = mInfoIndex; info->mTimer = 0.0f; info->del(); mDrawInfo.mInfoList1.add(info); @@ -264,7 +263,7 @@ BOOL TRenderingProcessor::doDrawCommon(f32 a1, f32 a2, Matrixf* mtx1, Matrixf* m ret = 0; } - return (int)(ret * _78); + return (int)(ret * mBaseAlphaModifier); /* stwu r1, -0xe0(r1) @@ -883,7 +882,7 @@ f32 TRenderingProcessor::doDrawRuby(f32 x0, f32 y0, f32 x, f32 y, int a1, bool f color.a = ret; mRubyFont->setCharColor(color); - GXColor col(_CC); + GXColor col(mDefaultWhite); col.r = col.r >> 1; col.g = col.g >> 1; col.b = col.b >> 1; @@ -891,7 +890,7 @@ f32 TRenderingProcessor::doDrawRuby(f32 x0, f32 y0, f32 x, f32 y, int a1, bool f GXSetTevColor(GX_TEVREG0, col); wid = mRubyFont->drawChar_scale(0.0f, 0.0f, x, y, a1, flag); - GXColor col2(_CC); + GXColor col2(mDefaultWhite); GXSetTevColor(GX_TEVREG0, col2); } else { wid = calcWidth(mRubyFont, a1, x, flag); @@ -1201,23 +1200,22 @@ bool TControl::update(Controller* control1, Controller* control2) P2JME::TSequenceProcessor* proc = mSequenceProc; if (proc) { u32 flag = proc->mFlags.typeView; - if (flag & 4) { - - if (!(flag & 1)) { - proc->mFlags.set(1); - mTimer1 = mTextRenderProc->_58; + if (flag & P2JME::TSequenceProcessor::SeqProc_IsWriting) { + if (!(flag & P2JME::TSequenceProcessor::SeqProc_IsActive)) { + proc->setFlag(P2JME::TSequenceProcessor::SeqProc_IsActive); + mTimer1 = mTextRenderProc->mYOffset; mTimer2 = mTimer1 - mTextRenderProc->mTextBoxHeight; mTimer = 0.0f; } else { f32 calc = 1.0f; f32 calc2 = mTimer / 0.5f; if (calc2 > 1.0f) { - proc->mFlags.unset(1); - mSequenceProc->mFlags.unset(4); + proc->resetFlag(P2JME::TSequenceProcessor::SeqProc_IsActive); + mSequenceProc->resetFlag(P2JME::TSequenceProcessor::SeqProc_IsWriting); } else { calc = (1.0f - cosf(calc2 * PI)) * 0.5f; } - mTextRenderProc->_58 = calc * (mTimer2 - mTimer1) + mTimer1; + mTextRenderProc->mYOffset = calc * (mTimer2 - mTimer1) + mTimer1; // I would imagine the second of these was supposed to be for controller 2, but very cool if ((control1 && control1->getButton() & Controller::PRESS_B)