From 875806538d48f3c80fb3228220004a9c8df5533c Mon Sep 17 00:00:00 2001 From: kiwi515 <49212064+kiwi515@users.noreply.github.com> Date: Sat, 6 Sep 2025 23:12:13 -0400 Subject: [PATCH 01/17] Lots of hacky things and bad code :) --- externals/NTSC_U.txt | 41 ++- externals/PAL.txt | 10 +- include/caddie/scene/glf/caddieGlfMenu.h | 3 + include/caddie/scene/glf/caddieGlfMessage.h | 1 + include/caddie/scene/glf/caddieGlfPostMenu.h | 34 ++ include/caddie/scene/glf/caddieGlfSceneHook.h | 21 +- include/caddie/ui/menu/caddieMenuMgr.h | 2 + include/lib/RP/RPGraphics/RPGrpRenderer.h | 65 ++++ include/lib/RevoSDK/SC.h | 12 + include/lib/RevoSDK/SC/scapi.h | 43 +++ include/lib/Sports2/Scene/Glf/RPGlfBall.h | 12 +- include/lib/Sports2/Scene/Glf/RPGlfClub.h | 24 ++ .../lib/Sports2/Scene/Glf/RPGlfClubManager.h | 30 ++ .../lib/Sports2/Scene/Glf/RPGlfFieldManager.h | 22 ++ .../lib/Sports2/Scene/Glf/RPGlfMapObjBase.h | 2 +- include/lib/Sports2/Scene/Glf/RPGlfPlayer.h | 28 +- .../Sports2/Scene/Glf/RPGlfPlayerManager.h | 11 +- .../lib/Sports2/Scene/Glf/RPGlfSimManager.h | 18 + include/lib/Sports2/Scene/Glf/RPGlfUtility.h | 17 + include/lib/Sports2/Scene/Glf/Sp2GlfConfig.h | 43 +++ include/lib/Sports2/Scene/Glf/Sp2GlfMain.h | 17 +- .../lib/Sports2/Scene/Glf/Sp2GlfSequenceMgr.h | 58 ++++ include/lib/egg/gfx.h | 6 + include/lib/egg/gfx/eggDrawGX.h | 210 ++++++++++++ include/lib/nw4r/math/math_triangular.h | 11 +- makeDolphin.bat | 10 +- src/caddie/scene/glf/caddieGlfMenu.cpp | 6 +- src/caddie/scene/glf/caddieGlfMessage.cpp | 3 + src/caddie/scene/glf/caddieGlfPostMenu.cpp | 83 +++++ src/caddie/scene/glf/caddieGlfSceneHook.cpp | 308 +++++++++++++++++- src/caddie/scene/glf/caddieGlfUtil.cpp | 10 +- src/caddie/ui/caddieBuildInfo.cpp | 10 +- src/caddie/ui/menu/caddieMenuMgr.cpp | 19 +- src/caddie/ui/menu/caddieMenuPage.cpp | 8 +- 34 files changed, 1130 insertions(+), 68 deletions(-) create mode 100644 include/caddie/scene/glf/caddieGlfPostMenu.h create mode 100644 include/lib/RP/RPGraphics/RPGrpRenderer.h create mode 100644 include/lib/RevoSDK/SC.h create mode 100644 include/lib/RevoSDK/SC/scapi.h create mode 100644 include/lib/Sports2/Scene/Glf/RPGlfClub.h create mode 100644 include/lib/Sports2/Scene/Glf/RPGlfClubManager.h create mode 100644 include/lib/Sports2/Scene/Glf/RPGlfFieldManager.h create mode 100644 include/lib/Sports2/Scene/Glf/RPGlfSimManager.h create mode 100644 include/lib/Sports2/Scene/Glf/RPGlfUtility.h create mode 100644 include/lib/Sports2/Scene/Glf/Sp2GlfConfig.h create mode 100644 include/lib/Sports2/Scene/Glf/Sp2GlfSequenceMgr.h create mode 100644 include/lib/egg/gfx.h create mode 100644 include/lib/egg/gfx/eggDrawGX.h create mode 100644 src/caddie/scene/glf/caddieGlfPostMenu.cpp diff --git a/externals/NTSC_U.txt b/externals/NTSC_U.txt index afbca32..6f9c05c 100644 --- a/externals/NTSC_U.txt +++ b/externals/NTSC_U.txt @@ -30,6 +30,8 @@ _restfpr_28=0x80007810 _savefpr_29=0x800077c8 _restfpr_29=0x80007814 +_savegpr_24=0x8000784c +_restgpr_24=0x80007898 _savegpr_25=0x80007850 _restgpr_25=0x8000789c _savegpr_26=0x80007854 @@ -93,10 +95,13 @@ setStaticVar__Q23Sp29StaticMemFiib=0x80269f08 sInstance__Q23Sp29StaticMem=0x806f4e98 # Sports2/Glf/Sp2GlfMain -choosePin__Q33Sp23Glf7GlfMainFi=0x804066e0 -sInstance__Q33Sp23Glf7GlfMain=0x806f5498 -__ct__Q33Sp23Glf7GlfMainFv=0x80406c50 -__dt__Q33Sp23Glf7GlfMainFv=0x80406c10 +sInstance__Q33Sp23Glf7GlfMain=0x806f5510 + +# Sports2/Glf/Sp2GlfConfig +choosePin__Q33Sp23Glf9GlfConfigFi=0x804066e0 +sInstance__Q33Sp23Glf9GlfConfig=0x806f5498 +__ct__Q33Sp23Glf9GlfConfigFv=0x80406c50 +__dt__Q33Sp23Glf9GlfConfigFv=0x80406c10 # Sports2/Sp2Util Rand__3Sp2Fv=0x8025c9b0 @@ -108,3 +113,31 @@ sFlags__9RPGlfBall=0x806fd91c # Sports2/Glf/RPGlfPlayerManager sInstance__18RPGlfPlayerManager=0x806f5468 + + +PSMTXIdentity=0x8003e730 +PSMTXScaleApply=0x8003ef40 +PSMTXTransApply=0x8003eec0 +BeginDrawSphere__Q23EGG6DrawGXFv=0x801a66c4 +DrawDLWorld__Q23EGG6DrawGXFQ33EGG6DrawGX2DLRCQ34nw4r4math5MTX348_GXColor=0x801a89d4 +sDrawPass__13RPGrpRenderer=0x806f0bf8 +sCurrentViewID__13RPGrpRenderer=0x807ceef0 +s_cameraMtx__Q23EGG6DrawGX=0x807cc980 +SCGetAspectRatio=0x80053f40 +GetPinPos__17RPGlfFieldManagerCFv=0x80402bd8 +GetDistFromPin__9RPGlfBallCFv=0x80411a08 +IsHoleOut__9RPGlfBallCFv=0x80411b5c +IsGreenOrCupAttr__9RPGlfBallCFv=0x80411ab8 +FrSqrt__Q24nw4r4mathFf=0x8013ba50 +sInstance__17RPGlfFieldManager=0x806f5480 +sInstance__16RPGlfClubManager=0x806f54a0 +IsHideUI__17RPGlfFieldManagerCFv=0x80402d78 +spSimBall__15RPGlfSimManager=0x806f54e8 +SetBlendMode__Q23EGG6DrawGXFQ33EGG6DrawGX5Blend=0x801a8810 +DrawLineStrip__Q23EGG6DrawGXFPCQ34nw4r4math4VEC3Us8_GXColorUc=0x801a6e00 +CalcDeltaXZ__12RPGlfUtilityFRQ34nw4r4math4VEC2RCQ34nw4r4math4VEC3RCQ34nw4r4math4VEC3=0x803edb2c +CalcDeltaAngle2D__12RPGlfUtilityFRCQ34nw4r4math4VEC2RCQ34nw4r4math4VEC2=0x803ed7ec +Calculate__Q33Sp23Glf11SequenceMgrFv=0x803f9934 +sInstance__Q33Sp23Glf11SequenceMgr=0x806f5460 +NextShot__Q33Sp23Glf12SequenceMainFv=0x803f7090 +Enter__Q33Sp23Glf5PhaseFv=0x803f999c diff --git a/externals/PAL.txt b/externals/PAL.txt index 1ce476e..67de766 100644 --- a/externals/PAL.txt +++ b/externals/PAL.txt @@ -60,11 +60,11 @@ getStaticVar__Q23Sp29StaticMemFib=0x8026a26c setStaticVar__Q23Sp29StaticMemFiib=0x8026a228 sInstance__Q23Sp29StaticMem=0x806f5538 -# Sports2/Glf/Sp2GlfMain -choosePin__Q33Sp23Glf7GlfMainFi=0x80406a00 -sInstance__Q33Sp23Glf7GlfMain=0x806f5b38 -__ct__Q33Sp23Glf7GlfMainFv=0x80406f70 -__dt__Q33Sp23Glf7GlfMainFv=0x80406f30 +# Sports2/Glf/Sp2GlfConfig +choosePin__Q33Sp23Glf9GlfConfigFi=0x80406a00 +sInstance__Q33Sp23Glf9GlfConfig=0x806f5b38 +__ct__Q33Sp23Glf9GlfConfigFv=0x80406f70 +__dt__Q33Sp23Glf9GlfConfigFv=0x80406f30 # Sports2/Sp2Util Rand__3Sp2Fv=0x8025ccd0 diff --git a/include/caddie/scene/glf/caddieGlfMenu.h b/include/caddie/scene/glf/caddieGlfMenu.h index 8ad255e..970ed62 100644 --- a/include/caddie/scene/glf/caddieGlfMenu.h +++ b/include/caddie/scene/glf/caddieGlfMenu.h @@ -34,6 +34,8 @@ class GlfMenu : public MenuBase { return static_cast(mWindSpdRange.GetSavedValue()); } + bool GetReplayInfo() const { return mReplayInfo.GetSavedValue(); } + private: MenuIntOption mHole; MenuBoolOption mRepeatHole; @@ -41,6 +43,7 @@ class GlfMenu : public MenuBase { MenuEnumOption mWindDir; MenuEnumOption mWindSpd; MenuEnumOption mWindSpdRange; + MenuBoolOption mReplayInfo; MenuActionOption mApplyRestart; MenuActionOption mQuitGame; diff --git a/include/caddie/scene/glf/caddieGlfMessage.h b/include/caddie/scene/glf/caddieGlfMessage.h index 62d5f12..336c235 100644 --- a/include/caddie/scene/glf/caddieGlfMessage.h +++ b/include/caddie/scene/glf/caddieGlfMessage.h @@ -13,6 +13,7 @@ extern const char* MSG_PIN_TYPE; extern const char* MSG_WIND_DIR; extern const char* MSG_WIND_SPD; extern const char* MSG_WIND_SPD_RANGE; +extern const char* MSG_REPLAY_INFO; extern const char* MSG_APPLY; extern const char* MSG_QUIT; diff --git a/include/caddie/scene/glf/caddieGlfPostMenu.h b/include/caddie/scene/glf/caddieGlfPostMenu.h new file mode 100644 index 0000000..8c60607 --- /dev/null +++ b/include/caddie/scene/glf/caddieGlfPostMenu.h @@ -0,0 +1,34 @@ +#ifndef CADDIE_SCENE_GLF_POST_MENU_H +#define CADDIE_SCENE_GLF_POST_MENU_H +#include "caddieGlfMessage.h" +#include "caddieMenuBase.h" +#include "caddieMenuOption.h" +#include "caddieMenuPage.h" +#include "types_caddie.h" + +namespace caddie { + +class GlfPostMenu : public MenuBase { +public: + GlfPostMenu(); + virtual ~GlfPostMenu(); + virtual void OnChange() {} + + static void Action_NextShot(void* menu); + static void Action_TryAgain(void* menu); + + static void ChangePhase(); + +private: + MenuActionOption mNextShot; + MenuActionOption mTryAgain; + + //! @brief Menu X screen position + static const f32 sMenuPosX; + //! @brief Menu Y screen position + static const f32 sMenuPosY; +}; + +} // namespace caddie + +#endif diff --git a/include/caddie/scene/glf/caddieGlfSceneHook.h b/include/caddie/scene/glf/caddieGlfSceneHook.h index c74b313..34c8f4b 100644 --- a/include/caddie/scene/glf/caddieGlfSceneHook.h +++ b/include/caddie/scene/glf/caddieGlfSceneHook.h @@ -2,8 +2,13 @@ #define CADDIE_SCENE_GLF_SCENE_HOOK_H #include "types_caddie.h" +#include + namespace caddie { +class GlfMenu; +class GlfPostMenu; + /** * @brief Golf scene hook */ @@ -11,8 +16,8 @@ class GlfSceneHook { public: static void OnConfigure(RPSysScene*); static void OnCalculate(RPSysScene*); - static void OnUserDraw(RPSysScene*); static void OnExit(RPSysScene*); + static void OnUserDraw(RPSysScene*); static void Apply_Hole(); static void Apply_RepeatHole(); @@ -20,18 +25,28 @@ class GlfSceneHook { static void Apply_Wind(); static void Apply_StaticMem(); - static void Apply_GlfMain(); + static void Apply_GlfConfig(); static void OnGlfBallCalc(RPGlfBall*, u32, u32); + static void OnPausedSeqMgrCalc(); + static void OnNextShot(); + static bool ShouldShowTutorial(); static bool CanPlayNextHole(); static u32 GetNumHolesPlayed(); static GlfMenu& GetMenu(); + static GlfPostMenu& GetPostMenu(); + + static void DrawReplaySphere(); + static void DrawPutterGuide(const nw4r::math::VEC3* pPoints, u16 num, + GXColor color, u8 width); private: - //! @brief Golf menu static GlfMenu* sGlfMenu; + static GlfPostMenu* sGlfPostMenu; + + static bool sDidStopShot; }; } // namespace caddie diff --git a/include/caddie/ui/menu/caddieMenuMgr.h b/include/caddie/ui/menu/caddieMenuMgr.h index 8e55a85..6d650df 100644 --- a/include/caddie/ui/menu/caddieMenuMgr.h +++ b/include/caddie/ui/menu/caddieMenuMgr.h @@ -20,6 +20,8 @@ class MenuMgr { virtual void Calc(); virtual void Draw() const; + MenuBase* GetMenu() const { return mMenu; } + void OpenMenu(MenuBase* menu) { CADDIE_ASSERT(menu != NULL); mMenu = menu; diff --git a/include/lib/RP/RPGraphics/RPGrpRenderer.h b/include/lib/RP/RPGraphics/RPGrpRenderer.h new file mode 100644 index 0000000..3cda1dd --- /dev/null +++ b/include/lib/RP/RPGraphics/RPGrpRenderer.h @@ -0,0 +1,65 @@ +#ifndef RP_GRAPHICS_RENDERER_H +#define RP_GRAPHICS_RENDERER_H +#include "types_RP.h" + +// Forward declarations +class IRPGrpDrawObject; +class RPGrpScreen; +class RPGrpCamera; +class RPGrpView; + +class RPGrpRenderer { +public: + enum EDrawPass { + EDrawPass_0, + EDrawPass_1, + EDrawPass_DrawBefore, + EDrawPass_Draw2D, + EDrawPass_4, + EDrawPass_5, + EDrawPass_DrawOPA, + EDrawPass_DrawXLU, + EDrawPass_8, + EDrawPass_9, + EDrawPass_10, + }; + +public: + static void Begin(); + static void End(); + + void AppendDrawObject(IRPGrpDrawObject*); + + void CreateView2D(u8 id, RPGrpScreen* pScreen); + void CreateView3D(u8 id, RPGrpCamera* pCamera, RPGrpScreen* pScreen); + + void CorrectView(); + + static void SetEfbClearColor(u8 r, u8 g, u8 b); + + static EDrawPass GetDrawPass() { return sDrawPass; } + static u8 GetViewID() { return sCurrentViewID; } + + static RPGrpRenderer* GetCurrent() { return spCurrent; } + static RPGrpScreen* GetActiveScreen() { return sActiveScreen; } + + static bool IsLytDraw() { return sDrawPass == EDrawPass_Draw2D; } + + RPGrpView* GetView(u32 no) const { return mDrawViews[no]; } + +private: + static const int MAX_VIEW = 32; + +private: + char UNK_0x0[0xC]; + IRPGrpDrawObject* mDrawObjects; // at 0xC + char _10[0x4]; + RPGrpView* mDrawViews[MAX_VIEW]; // at 0x14 + + static EDrawPass sDrawPass; + static u8 sCurrentViewID; + static RPGrpRenderer* spCurrent; + static RPGrpScreen* sActiveScreen; +}; + +#endif diff --git a/include/lib/RevoSDK/SC.h b/include/lib/RevoSDK/SC.h new file mode 100644 index 0000000..138e39e --- /dev/null +++ b/include/lib/RevoSDK/SC.h @@ -0,0 +1,12 @@ +#ifndef RVL_SDK_PUBLIC_SC_H +#define RVL_SDK_PUBLIC_SC_H +#ifdef __cplusplus +extern "C" { +#endif + +#include + +#ifdef __cplusplus +} +#endif +#endif diff --git a/include/lib/RevoSDK/SC/scapi.h b/include/lib/RevoSDK/SC/scapi.h new file mode 100644 index 0000000..ca2eb31 --- /dev/null +++ b/include/lib/RevoSDK/SC/scapi.h @@ -0,0 +1,43 @@ +#ifndef RVL_SDK_SC_SCAPI_H +#define RVL_SDK_SC_SCAPI_H +#include + +#ifdef __cplusplus +extern "C" { +#endif + +#define SC_MAX_DEV_ENTRY_FOR_STD 10 +#define SC_MAX_DEV_ENTRY_FOR_SMP 6 +#define SC_MAX_DEV_ENTRY (SC_MAX_DEV_ENTRY_FOR_STD + SC_MAX_DEV_ENTRY_FOR_SMP) + +typedef enum { SC_ASPECT_STD, SC_ASPECT_WIDE } SCAspectRatio; + +typedef enum { SC_EURGB_50_HZ, SC_EURGB_60_HZ } SCEuRgb60Mode; + +typedef enum { + SC_LANG_JP, + SC_LANG_EN, + SC_LANG_DE, + SC_LANG_FR, + SC_LANG_SP, + SC_LANG_IT, + SC_LANG_NL, + SC_LANG_ZH_S, + SC_LANG_ZH_T, + SC_LANG_KR, +} SCLanguage; + +typedef enum { SC_INTERLACED, SC_PROGRESSIVE } SCProgressiveMode; + +typedef enum { SC_MOTOR_OFF, SC_MOTOR_ON } SCMotorMode; + +typedef enum { SC_SND_MONO, SC_SND_STEREO, SC_SND_SURROUND } SCSoundMode; + +typedef enum { SC_SENSOR_BAR_BOTTOM, SC_SENSOR_BAR_TOP } SCSensorBarPos; + +u8 SCGetAspectRatio(void); + +#ifdef __cplusplus +} +#endif +#endif diff --git a/include/lib/Sports2/Scene/Glf/RPGlfBall.h b/include/lib/Sports2/Scene/Glf/RPGlfBall.h index 8409847..3fd993c 100644 --- a/include/lib/Sports2/Scene/Glf/RPGlfBall.h +++ b/include/lib/Sports2/Scene/Glf/RPGlfBall.h @@ -17,6 +17,9 @@ class RPGlfBall : public RPGlfMapObjBase { bool IsMoving() const { return mIsMoving; } void SetMoving(bool move) { mIsMoving = move; } + bool IsHitFlag() const { return mHitFlag; } + bool IsHitPole() const { return mHitPole; } + RPGlfCollisionModel::ECollision GetCollision() const { return (RPGlfCollisionModel::ECollision)mCollision; } @@ -29,12 +32,19 @@ class RPGlfBall : public RPGlfMapObjBase { mCollisionNoAir = col; } + bool IsHoleOut() const; + f32 GetDistFromPin() const; + bool IsGreenOrCupAttr() const; + private: char UNK_0x50[0x4]; u32 mLifetime; // at 0x54 char UNK_0x58[0x60 - 0x58]; bool mIsMoving; // at 0x60 - char UNK_0x61[0xB4 - 0x61]; + bool _61; // at 0x61 + bool mHitFlag; // at 0x62 + bool mHitPole; // at 0x63 + char UNK_0x64[0xB4 - 0x64]; u16 mCollision; // at 0xB4 u16 mCollisionNoAir; // at 0xB6 char UNK_0xB8[0x1E0 - 0xB8]; diff --git a/include/lib/Sports2/Scene/Glf/RPGlfClub.h b/include/lib/Sports2/Scene/Glf/RPGlfClub.h new file mode 100644 index 0000000..51557a3 --- /dev/null +++ b/include/lib/Sports2/Scene/Glf/RPGlfClub.h @@ -0,0 +1,24 @@ +#ifndef RP_SPORTS_GLF_CLUB_H +#define RP_SPORTS_GLF_CLUB_H +#include "types_RP.h" +#include "types_caddie.h" + +#include + +class RPGlfClub { +public: + enum EType { + EType_WD, + EType_IR, + EType_SW, + EType_PT, + }; + + EType GetType() const { return mType; } + +private: + char _00[0x4]; + EType mType; // at 0x4 +}; + +#endif diff --git a/include/lib/Sports2/Scene/Glf/RPGlfClubManager.h b/include/lib/Sports2/Scene/Glf/RPGlfClubManager.h new file mode 100644 index 0000000..5a0b9e0 --- /dev/null +++ b/include/lib/Sports2/Scene/Glf/RPGlfClubManager.h @@ -0,0 +1,30 @@ +#ifndef RP_SPORTS_GLF_CLUB_MANAGER_H +#define RP_SPORTS_GLF_CLUB_MANAGER_H +#include "types_RP.h" +#include "types_caddie.h" + +#include + +class RPGlfClub; + +class RPGlfClubManager { +public: + static RPGlfClubManager& getInstance() { + CADDIE_ASSERT(sInstance != NULL); + return *sInstance; + } + + RPGlfClub* GetActiveClub() const { + CADDIE_ASSERT(mClubNo < 8); + return mpClubs[mClubNo]; + } + +private: + char _00[0xC]; + RPGlfClub* mpClubs[8]; // at 0xC + u32 mClubNo; // at 0x2C + + static RPGlfClubManager* sInstance; +}; + +#endif diff --git a/include/lib/Sports2/Scene/Glf/RPGlfFieldManager.h b/include/lib/Sports2/Scene/Glf/RPGlfFieldManager.h new file mode 100644 index 0000000..1e71b3b --- /dev/null +++ b/include/lib/Sports2/Scene/Glf/RPGlfFieldManager.h @@ -0,0 +1,22 @@ +#ifndef RP_SPORTS_GLF_FIELD_MANAGER_H +#define RP_SPORTS_GLF_FIELD_MANAGER_H +#include "types_RP.h" +#include "types_caddie.h" + +#include + +class RPGlfFieldManager { +public: + static RPGlfFieldManager& getInstance() { + CADDIE_ASSERT(sInstance != NULL); + return *sInstance; + } + + const nw4r::math::VEC3& GetPinPos() const; + bool IsHideUI() const; + +private: + static RPGlfFieldManager* sInstance; +}; + +#endif diff --git a/include/lib/Sports2/Scene/Glf/RPGlfMapObjBase.h b/include/lib/Sports2/Scene/Glf/RPGlfMapObjBase.h index 815551b..8c4367b 100644 --- a/include/lib/Sports2/Scene/Glf/RPGlfMapObjBase.h +++ b/include/lib/Sports2/Scene/Glf/RPGlfMapObjBase.h @@ -12,7 +12,7 @@ class RPGlfMapObjBase { RPGlfMapObjBase(); virtual ~RPGlfMapObjBase(); -private: +protected: //! @brief Map object model RPGrpModelG3D* mModel; // at 0x4 //! @brief Binary map object diff --git a/include/lib/Sports2/Scene/Glf/RPGlfPlayer.h b/include/lib/Sports2/Scene/Glf/RPGlfPlayer.h index 5ee0e45..3ec20b5 100644 --- a/include/lib/Sports2/Scene/Glf/RPGlfPlayer.h +++ b/include/lib/Sports2/Scene/Glf/RPGlfPlayer.h @@ -1,7 +1,12 @@ #ifndef RP_SPORTS_GLF_PLAYER_H #define RP_SPORTS_GLF_PLAYER_H +#include "types_caddie.h" #include "types_sp2.h" +#include + +class RPGlfBall; + /** * @brief Golf player */ @@ -16,11 +21,30 @@ class RPGlfPlayer { u32 GetStrokeAfterPenalty() const { return mStrokeAfterPenalty; } void SetStrokeAfterPenalty(u32 stroke) { mStrokeAfterPenalty = stroke; } + const nw4r::math::VEC2& GetAvatarAngle() const { return mAvatarAngle; } + const nw4r::math::VEC3& GetAvatarPos() const { return mAvatarPos; } + + u16 GetPrevGndAttr() const { return mPrevGndAttr; } + + RPGlfBall* GetBall() const { return mpGlfBall; } + + u32 GetWord0x44() const { return WORD_0x44; } + private: - char UNK_0x4[0xC0 - 0x4]; + char UNK_0x4[0x44 - 0x4]; + u32 WORD_0x44; // at 0x44 + char UNK_0x48[0x84 - 0x48]; + nw4r::math::VEC2 mAvatarAngle; // at 0x84 + char UNK_0x8C[0x98 - 0x8C]; + nw4r::math::VEC3 mAvatarPos; // at 0x98 + char UNK_0xA4[0xB0 - 0xA4]; + u16 mPrevGndAttr; // at 0xB0 + char UNK_0xB2[0xC0 - 0xB2]; u32 mStroke; // at 0xC0 u32 mStrokeAfterPenalty; // at 0xC4 - char UNK_0xC8[0x198 - 0xC8]; + char UNK_0xC8[0xD0 - 0xC8]; + RPGlfBall* mpGlfBall; // at 0xD0 + char UNK_0xD4[0x198 - 0xD4]; }; #endif diff --git a/include/lib/Sports2/Scene/Glf/RPGlfPlayerManager.h b/include/lib/Sports2/Scene/Glf/RPGlfPlayerManager.h index 916e473..b3c1e81 100644 --- a/include/lib/Sports2/Scene/Glf/RPGlfPlayerManager.h +++ b/include/lib/Sports2/Scene/Glf/RPGlfPlayerManager.h @@ -26,10 +26,14 @@ class RPGlfPlayerManager { return mPlayers[i]; } - RPGlfPlayer& GetCurrentPlayer() { return mPlayers[mCurrentPlayerID]; } + RPGlfPlayer& GetCurrentPlayer() { + CADDIE_ASSERT(mCurrentPlayer); + return *mCurrentPlayer; + } const RPGlfPlayer& GetCurrentPlayer() const { - return mPlayers[mCurrentPlayerID]; + CADDIE_ASSERT(mCurrentPlayer); + return *mCurrentPlayer; } u32 GetCurrentPlayerID() const { return mCurrentPlayerID; } @@ -40,7 +44,8 @@ class RPGlfPlayerManager { public: RPGlfPlayer mPlayers[Sp2::Glf::PLAYER_MAX]; // at 0x4 - char UNK_0x664[0x690 - 0x664]; + RPGlfPlayer* mCurrentPlayer; // at 0x664 + char UNK_0x668[0x690 - 0x668]; u32 mCurrentPlayerID; // at 0x690 static RPGlfPlayerManager* sInstance; diff --git a/include/lib/Sports2/Scene/Glf/RPGlfSimManager.h b/include/lib/Sports2/Scene/Glf/RPGlfSimManager.h new file mode 100644 index 0000000..d1f1656 --- /dev/null +++ b/include/lib/Sports2/Scene/Glf/RPGlfSimManager.h @@ -0,0 +1,18 @@ +#ifndef RP_SPORTS_GLF_SIM_MANAGER_H +#define RP_SPORTS_GLF_SIM_MANAGER_H +#include "caddieAssert.h" +#include "types_Sp2.h" + +#include + +class RPGlfBall; + +class RPGlfSimManager { +public: + static RPGlfBall* GetSimBall() { return spSimBall; } + +public: + static RPGlfBall* spSimBall; +}; + +#endif diff --git a/include/lib/Sports2/Scene/Glf/RPGlfUtility.h b/include/lib/Sports2/Scene/Glf/RPGlfUtility.h new file mode 100644 index 0000000..1979786 --- /dev/null +++ b/include/lib/Sports2/Scene/Glf/RPGlfUtility.h @@ -0,0 +1,17 @@ +#ifndef RP_SPORTS_GLF_UTILITY_H +#define RP_SPORTS_GLF_UTILITY_H +#include "types_RP.h" +#include "types_caddie.h" + +#include + +class RPGlfUtility { +public: + static void CalcDeltaXZ(nw4r::math::VEC2& out, const nw4r::math::VEC3& v1, + const nw4r::math::VEC3& v2); + + static f32 CalcDeltaAngle2D(const nw4r::math::VEC2& v1, + const nw4r::math::VEC2& v2); +}; + +#endif diff --git a/include/lib/Sports2/Scene/Glf/Sp2GlfConfig.h b/include/lib/Sports2/Scene/Glf/Sp2GlfConfig.h new file mode 100644 index 0000000..c7e118e --- /dev/null +++ b/include/lib/Sports2/Scene/Glf/Sp2GlfConfig.h @@ -0,0 +1,43 @@ +#ifndef SP2_GLF_GLFCONFIG_H +#define SP2_GLF_GLFCONFIG_H +#include "types_caddie.h" + +#include + +namespace Sp2 { +namespace Glf { + +class GlfConfig { +public: + static GlfConfig& getInstance() { + CADDIE_ASSERT(sInstance != NULL); + return *sInstance; + } + + GameMode getGamemode() const { return (GameMode)mGamemode; } + void setGamemode(GameMode gm) { mGamemode = gm; } + + u32 getCurrentHole() const { return mCurrentHole; } + void setCurrentHole(u32 i) { mCurrentHole = i; } + + u32 getPin() const { return mPin; } + void setPin(u32 i) { mPin = i; } + +private: + GlfConfig(); + virtual ~GlfConfig(); + + u32 mGamemode; // at 0x4 + UNKWORD WORD_0x8; + u32 mCurrentHole; // at 0xC + char UNK_0x10[0x38 - 0x10]; + u32 mPin; // at 0x38 + char UNK_0x3C[0x1D70 - 0x3C]; + + static GlfConfig* sInstance; +}; + +} // namespace Glf +} // namespace Sp2 + +#endif diff --git a/include/lib/Sports2/Scene/Glf/Sp2GlfMain.h b/include/lib/Sports2/Scene/Glf/Sp2GlfMain.h index 5bc06b5..930f870 100644 --- a/include/lib/Sports2/Scene/Glf/Sp2GlfMain.h +++ b/include/lib/Sports2/Scene/Glf/Sp2GlfMain.h @@ -14,25 +14,14 @@ class GlfMain { return *sInstance; } - GameMode getGamemode() const { return (GameMode)mGamemode; } - void setGamemode(GameMode gm) { mGamemode = gm; } - - u32 getCurrentHole() const { return mCurrentHole; } - void setCurrentHole(u32 i) { mCurrentHole = i; } - - u32 getPin() const { return mPin; } - void setPin(u32 i) { mPin = i; } + void setPause(bool pause) { mIsPause = pause; } private: GlfMain(); virtual ~GlfMain(); - u32 mGamemode; // at 0x4 - UNKWORD WORD_0x8; - u32 mCurrentHole; // at 0xC - char UNK_0x10[0x38 - 0x10]; - u32 mPin; // at 0x38 - char UNK_0x3C[0x1D70 - 0x3C]; + char _04[0x18 - 0x4]; // at 0x4 + bool mIsPause; // at 0x18 static GlfMain* sInstance; }; diff --git a/include/lib/Sports2/Scene/Glf/Sp2GlfSequenceMgr.h b/include/lib/Sports2/Scene/Glf/Sp2GlfSequenceMgr.h new file mode 100644 index 0000000..8c8de54 --- /dev/null +++ b/include/lib/Sports2/Scene/Glf/Sp2GlfSequenceMgr.h @@ -0,0 +1,58 @@ +#ifndef SP2_GLF_SEQUENCE_MGR_H +#define SP2_GLF_SEQUENCE_MGR_H +#include "types_caddie.h" + +#include + +namespace Sp2 { +namespace Glf { + +class Phase { +public: + void Enter(); +}; + +class SequenceMain { +public: + void NextShot(); + +public: + class Phase_CupIn : public Phase { + char _00[0x14]; + }; + + class Phase_BallStop : public Phase { + char _00[0x14]; + }; + +public: + char _00[0x7C]; + Phase_CupIn CupIn; // at 0x7C + char _90[0xA4 - 0x90]; + Phase_BallStop BallStop; // at 0x90 +}; + +class SequenceMgr { +public: + static SequenceMgr& getInstance() { + CADDIE_ASSERT(sInstance != NULL); + return *sInstance; + } + + void Calculate(); + + SequenceMain* GetSequenceMain() const { return mpSequenceMain; } + +private: + virtual ~SequenceMgr(); + +private: + SequenceMain* mpSequenceMain; // at 0x4 + + static SequenceMgr* sInstance; +}; + +} // namespace Glf +} // namespace Sp2 + +#endif diff --git a/include/lib/egg/gfx.h b/include/lib/egg/gfx.h new file mode 100644 index 0000000..1497aca --- /dev/null +++ b/include/lib/egg/gfx.h @@ -0,0 +1,6 @@ +#ifndef EGG_PUBLIC_GFX_H +#define EGG_PUBLIC_GFX_H + +#include + +#endif diff --git a/include/lib/egg/gfx/eggDrawGX.h b/include/lib/egg/gfx/eggDrawGX.h new file mode 100644 index 0000000..422157f --- /dev/null +++ b/include/lib/egg/gfx/eggDrawGX.h @@ -0,0 +1,210 @@ +#ifndef EGG_GFX_DRAW_GX_H +#define EGG_GFX_DRAW_GX_H +#include +#include +#include + +namespace EGG { + +// Forward declarations +class Heap; + +class DrawGX { +public: + enum Blend { + BLEND_NORMAL, // Sc*Sa + Dc*(1-Sa) + BLEND_INVERSE, // Sc*(1-Sa) + Dc*Sa + BLEND_ADD, // Sc+Dc + BLEND_ADD_ALPHA, // Sc*Sa + Dc + BLEND_MUL_ADD, // Sc*Dc + Dc + BLEND_SUB, // Sc - Dc + BLEND_MUL, // Dc*Sc + BLEND_MUL_INV, // Dc*(1-Sc) + BLEND_REPLACE, // Sc + BLEND_NONE, // 1 + + BLEND_MAX + }; + + enum Circle { + CIRCLE_16, // Low detail (16 segments) + CIRCLE_32, // High detail (32 segments) + + CIRCLE_MAX, + }; + + enum ColorChannel { + COLORCHAN_LIGHT, + COLORCHAN_COLOR, + }; + + enum DL { + DL_LINE_AXIS, + DL_CUBE, + DL_CUBE_WIRE, + DL_SPHERE_4X8, + DL_SPHERE_8X16, + DL_LINE_CIRCLE_16, + DL_LINE_CIRCLE_32, + DL_CIRCLE_16, + DL_CIRCLE_32, + DL_CYLINDER_16, + DL_CYLINDER_32, + DL_CONE_16, + DL_CONE_32, + DL_QUAD_TEXTURE, + DL_QUAD, + DL_BOUNDBOX, + DL_SCREEN_TEXTURE, + DL_SCREEN, + + DL_MAX + }; + + enum TevSetting { + TEVSETTING_COLOR, + TEVSETTING_TEXTURE, + }; + + enum TexGen { + TEXGEN_DISABLE, + TEXGEN_ENABLE, + }; + + enum VtxType { + VTXTYPE_CUBE, + VTXTYPE_LINE, + VTXTYPE_SPHERE, + VTXTYPE_CYLINDER, + VTXTYPE_CIRCLE, + VTXTYPE_CONE, + VTXTYPE_POLYGON, + VTXTYPE_QUAD_TEXTURE, + VTXTYPE_QUAD, + VTXTYPE_QUAD_SHADOW, + VTX_TYPE_SCREEN_TEXTURE, + VTX_TYPE_SCREEN_TEXTURE_FLIP, + VTX_TYPE_SCREEN, + VTX_TYPE_SCREEN_FLIP + }; + + enum ZMode { + ZMODE_ALWAYS, // Always draw without updating the Z-buffer + ZMODE_OPA, // For opaque draw + ZMODE_XLU, // For translucent draw + ZMODE_CLEAR, // Always draw and update the Z-buffer + + ZMODE_MAX + }; + +public: + static void Initialize(Heap* pHeap = NULL); + // static GXLightID GetLightMaskDefault(); + // static GXTexMapID GetTexMapDefault(); + + static void BeginDrawCube(); + static void BeginDrawSphere(); + static void BeginDrawLine(ColorChannel chan, ZMode zMode); + static void BeginDrawCornY(); + static void BeginDrawCircleZ(ColorChannel chan, ZMode zMode); + static void BeginDrawPolygon(ColorChannel chan); + static void BeginDrawQuad(ColorChannel chan, ZMode zMode, Blend blendMode, + bool texture, bool alpha); + static void BeginDrawScreen(bool flip, bool texture, bool alpha); + static void BeginDrawShadowVolume(u8 alpha); + + static void DrawLine(const nw4r::math::VEC3* pPoints, u16 num, + GXColor color, u8 width); + static void DrawLineStrip(const nw4r::math::VEC3* pPoints, u16 num, + GXColor color, u8 width); + static void DrawCircle2D(Circle circle, f32 x, f32 y, f32 radius, + GXColor color); + static void DrawCornY(Circle circle, const nw4r::math::MTX34& rMtx, + GXColor color); + static void DrawPolygon(const nw4r::math::VEC3& rP0, + const nw4r::math::VEC3& rP1, + const nw4r::math::VEC3& rP2, GXColor color); + + static void BeginDrawShadowVolumeTexture(bool flip, GXColor color, + Blend blendMode); + + static void ClearEfb(const nw4r::math::MTX34& rMtx, bool colorUpdate, + bool alphaUpdate, bool texture, GXColor color, + bool flip); + + static void ResetMaterial(ColorChannel chan); + + static void SetMat_ColorChannel(ColorChannel chan); + static void SetMat_TexGen(TexGen texGen); + static void SetMat_Ind(); + static void SetMat_Tev(GXTevStageID stage, TevSetting setting); + static void SetMat_PE(ZMode zMode, Blend blendMode); + + // static void LoadTexture(const ResTIMG* pRes, GXTexMapID map); + static void SetVtxState(VtxType vtxType); + + static void DrawDL(DL dl, const nw4r::math::MTX34& rMtx); + static void DrawDL(DL dl, const nw4r::math::MTX34& rMtx, GXColor color); + + static void DrawDLWorld(DL dl, const nw4r::math::MTX34& rMtx, + GXColor color); + + static void SetZMode(ZMode zMode); + static void SetBlendMode(Blend blendMode); + + static void SetCameraMtx(const nw4r::math::MTX34& rMtx) { + s_cameraMtx = rMtx; + } + +public: + static const GXColor BLACK; + static const GXColor WHITE; + static const GXColor RED; + static const GXColor GREEN; + static const GXColor BLUE; + static const GXColor ORANGE; + +private: + struct DLEntry { + u8* m_list; // at 0x0 + u32 m_size; // at 0x4 + }; + + struct ZModeEntry { + u8 m_enableTest; // at 0x0 + GXCompare m_func; // at 0x4 + u8 m_enableUpdate; // at 0x8 + }; + + struct BlendEntry { + GXBlendMode m_blendMode; // at 0x0 + GXBlendFactor m_srcFactor; // at 0x4 + GXBlendFactor m_dstFactor; // at 0x8 + GXLogicOp m_op; // at 0xC + }; + + enum { FLAG_INITIALIZE_DISPLAY_LIST = 1 << 0 }; + +private: + static void InitClearTexObj(); + static void CreateDisplayList(Heap* pHeap); + +public: + static DLEntry s_DL[DL_MAX]; + static const DL s_circleDLTbl[CIRCLE_MAX]; + + static nw4r::math::MTX34 s_cameraMtx; + static u32 s_flag; + + static GXLightID s_lightMaskDefault; + static GXTexMapID s_texMapDefault; + + static f32 s_quadScale; + + static u8 s_clearTexObj[32]; + static u32 s_clearTex[4 * 4] ALIGN(32); +}; + +} // namespace EGG + +#endif diff --git a/include/lib/nw4r/math/math_triangular.h b/include/lib/nw4r/math/math_triangular.h index 760092d..2c7489f 100644 --- a/include/lib/nw4r/math/math_triangular.h +++ b/include/lib/nw4r/math/math_triangular.h @@ -6,14 +6,21 @@ #define NW4R_MATH_PI 3.14159265359f #define NW4R_MATH_LN_2 0.69314718056f -// Convert degrees to and from lookup-table index +// [0, 65535] -> [0.0, 256.0f] +#define NW4R_MATH_IDX_TO_FIDX(x) ((x) * (1.0f / 256.0f)) + +// Convert degrees <-> lookup-table index #define NW4R_MATH_DEG_TO_FIDX(x) ((x) * (256.0f / 360.0f)) #define NW4R_MATH_FIDX_TO_DEG(x) ((x) * (360.0f / 256.0f)) -// Convert radians to and from lookup-table index +// Convert radians <-> lookup-table index #define NW4R_MATH_RAD_TO_FIDX(x) ((x) * (128.0f / NW4R_MATH_PI)) #define NW4R_MATH_FIDX_TO_RAD(x) ((x) * (NW4R_MATH_PI / 128.0f)) +// Convert degrees <-> radians +#define NW4R_MATH_DEG_TO_RAD(x) ((x) * (NW4R_MATH_PI / 180.0f)) +#define NW4R_MATH_RAD_TO_DEG(x) ((x) * (180.0f / NW4R_MATH_PI)) + namespace nw4r { namespace math { diff --git a/makeDolphin.bat b/makeDolphin.bat index 8aec649..3931a4a 100644 --- a/makeDolphin.bat +++ b/makeDolphin.bat @@ -5,18 +5,18 @@ python make.py clean if [%1]==[] goto standard python make.py --region NTSC_U --flags=%1 -python make.py --region PAL --flags=%1 +@REM python make.py --region PAL --flags=%1 goto copy :standard python make.py --region NTSC_U -python make.py --region PAL +@REM python make.py --region PAL :copy xcopy "build/main_NTSC_U.dol" "romfs/NTSC_U/sys/main.dol" /y /f /i xcopy "build/modules/Caddie_NTSC_U.bin" "romfs/NTSC_U/files/modules/main_NTSC_U.bin" /y /f /i xcopy "build/modules/Caddie_NTSC_U.map" "romfs/NTSC_U/files/modules/main_NTSC_U.map" /y /f /i -xcopy "build/main_PAL.dol" "romfs/PAL/sys/main.dol" /y /f /i -xcopy "build/modules/Caddie_PAL.bin" "romfs/PAL/files/modules/main_PAL.bin" /y /f /i -xcopy "build/modules/Caddie_PAL.map" "romfs/PAL/files/modules/main_PAL.map" /y /f /i +@REM xcopy "build/main_PAL.dol" "romfs/PAL/sys/main.dol" /y /f /i +@REM xcopy "build/modules/Caddie_PAL.bin" "romfs/PAL/files/modules/main_PAL.bin" /y /f /i +@REM xcopy "build/modules/Caddie_PAL.map" "romfs/PAL/files/modules/main_PAL.map" /y /f /i diff --git a/src/caddie/scene/glf/caddieGlfMenu.cpp b/src/caddie/scene/glf/caddieGlfMenu.cpp index f5e6fb8..0eecd32 100644 --- a/src/caddie/scene/glf/caddieGlfMenu.cpp +++ b/src/caddie/scene/glf/caddieGlfMenu.cpp @@ -19,6 +19,7 @@ GlfMenu::GlfMenu() mWindSpd(MSG_WIND_SPD, ENUM_WIND_SPD, 0, WIND_SPD_RANDOM), mWindSpdRange(MSG_WIND_SPD_RANGE, ENUM_WIND_SPD_RANGE, 0, CADDIE_ENUM_MAX(ENUM_WIND_SPD_RANGE)), + mReplayInfo(MSG_REPLAY_INFO, false), mApplyRestart(MSG_APPLY, Action_ApplyRestart, this), mQuitGame(MSG_QUIT, Action_QuitGame, this) { // Build root page @@ -28,6 +29,7 @@ GlfMenu::GlfMenu() GetRootPage().AppendOption(&mWindDir); GetRootPage().AppendOption(&mWindSpd); GetRootPage().AppendOption(&mWindSpdRange); + GetRootPage().AppendOption(&mReplayInfo); GetRootPage().AppendOption(&mApplyRestart); GetRootPage().AppendOption(&mQuitGame); } @@ -38,6 +40,8 @@ GlfMenu::~GlfMenu() {} * @brief Option change callback */ void GlfMenu::OnChange() { + mReplayInfo.SaveChanges(); + // Hole 18 has one pin mPinType.SetEnabled(mHole.GetUnsavedValue() != 18); @@ -92,7 +96,7 @@ void GlfMenu::Action_QuitGame(void* menu) { // Ask scene not to apply settings thisx->SetAwaitingApply(false); // Delete menu when returning - thisx->SetCanDelete(true); + // thisx->SetCanDelete(true); // Return to title scene RPSysSceneCreator::getInstance().changeSceneAfterFade( diff --git a/src/caddie/scene/glf/caddieGlfMessage.cpp b/src/caddie/scene/glf/caddieGlfMessage.cpp index 40efb30..a381200 100644 --- a/src/caddie/scene/glf/caddieGlfMessage.cpp +++ b/src/caddie/scene/glf/caddieGlfMessage.cpp @@ -25,6 +25,9 @@ const char* MSG_WIND_SPD = //! @brief Text for Wind Speed Range option const char* MSG_WIND_SPD_RANGE = "Wind Speed Range"; +//! @brief Text for Replay Info option +const char* MSG_REPLAY_INFO = "Show Replay Info"; + //! @brief Text for Apply and Restart option const char* MSG_APPLY = "Apply and Restart"; diff --git a/src/caddie/scene/glf/caddieGlfPostMenu.cpp b/src/caddie/scene/glf/caddieGlfPostMenu.cpp new file mode 100644 index 0000000..0055067 --- /dev/null +++ b/src/caddie/scene/glf/caddieGlfPostMenu.cpp @@ -0,0 +1,83 @@ +#include "caddieGlfPostMenu.h" + +#include "caddieGlfMenu.h" +#include "caddieGlfMessage.h" +#include "caddieGlfPostMenu.h" +#include "caddieGlfSceneHook.h" +#include "caddieGlfUtil.h" +#include "caddieInputMgr.h" +#include "caddieMenuMgr.h" + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +namespace caddie { + +GlfPostMenu::GlfPostMenu() + : MenuBase("PostMenu", sMenuPosX, sMenuPosY), + mNextShot("Next Shot", Action_NextShot, this), + mTryAgain("Try Again", Action_TryAgain, this) { + + // Build root page + GetRootPage().AppendOption(&mNextShot); + GetRootPage().AppendOption(&mTryAgain); + + OSReport("MENU ADDR: %p\n", this); +} + +GlfPostMenu::~GlfPostMenu() {} + +void GlfPostMenu::Action_NextShot(void* menu) { + CADDIE_ASSERT(menu != NULL); + GlfPostMenu* thisx = reinterpret_cast(menu); + + Sp2::Glf::SequenceMgr::getInstance().GetSequenceMain()->NextShot(); + MenuMgr::GetInstance().SetVisible(false); + MenuMgr::GetInstance().CloseMenu(); + + ChangePhase(); +} + +void GlfPostMenu::Action_TryAgain(void* menu) { + CADDIE_ASSERT(menu != NULL); + GlfPostMenu* thisx = reinterpret_cast(menu); + + MenuMgr::GetInstance().SetVisible(false); + MenuMgr::GetInstance().CloseMenu(); + + ChangePhase(); +} + +void GlfPostMenu::ChangePhase() { + RPGlfPlayer& player = RPGlfPlayerManager::GetInstance().GetCurrentPlayer(); + + Sp2::Glf::SequenceMain* pMainSeq = + Sp2::Glf::SequenceMgr::getInstance().GetSequenceMain(); + CADDIE_ASSERT(pMainSeq); + + if (player.GetWord0x44() == 2) { + pMainSeq->CupIn.Enter(); + } else { + pMainSeq->BallStop.Enter(); + } +} + +const f32 GlfPostMenu::sMenuPosX = 275.0f; +const f32 GlfPostMenu::sMenuPosY = 200.0f; + +} // namespace caddie diff --git a/src/caddie/scene/glf/caddieGlfSceneHook.cpp b/src/caddie/scene/glf/caddieGlfSceneHook.cpp index a379f0c..694a77f 100644 --- a/src/caddie/scene/glf/caddieGlfSceneHook.cpp +++ b/src/caddie/scene/glf/caddieGlfSceneHook.cpp @@ -1,19 +1,54 @@ #include "caddieGlfSceneHook.h" #include "caddieGlfMenu.h" +#include "caddieGlfPostMenu.h" #include "caddieGlfUtil.h" #include "caddieInputMgr.h" #include "caddieMenuMgr.h" +#include +#include #include +#include +#include +#include #include +#include +#include +#include #include #include +#include #include #include +#include +#include + +// Calculate absolute value. +#define ABS(x) ((x) > 0.0f ? (x) : (-x)) + +// Take the maximum of two values. +#define MAX(x, y) ((x) > (y) ? (x) : (y)) +// Take the minimum of two values. +#define MIN(x, y) ((x) < (y) ? (x) : (y)) + +// Clamp a value to the specified range. +#undef CLAMP +#define CLAMP(low, high, x) \ + ((x) < (low) ? (low) : ((x) > (high) ? (high) : (x))) + +// Convert meters to world units. +#define M(X) ((f32)(X) * 10.0f) +// Convert yards to world units. +#define YD(X) ((f32)(X) * 10.0f / 1.094f) + +kmWrite32(0x803f8778, 0x60000000); +kmWrite32(0x803f878c, 0x60000000); namespace caddie { +bool GlfSceneHook::sDidStopShot = false; + /** * @brief Golf scene configure (enter) callback * @@ -25,6 +60,10 @@ void GlfSceneHook::OnConfigure(RPSysScene* scene) { sGlfMenu = new GlfMenu(); CADDIE_ASSERT(sGlfMenu != NULL); } + if (sGlfPostMenu == NULL) { + sGlfPostMenu = new GlfPostMenu(); + CADDIE_ASSERT(sGlfPostMenu != NULL); + } // Open menu root MenuMgr::GetInstance().OpenMenu(sGlfMenu); @@ -35,14 +74,243 @@ void GlfSceneHook::OnConfigure(RPSysScene* scene) { * * @param scene Current scene */ -void GlfSceneHook::OnCalculate(RPSysScene* scene) {} +void GlfSceneHook::OnCalculate(RPSysScene* scene) { + bool isMenuOpen = MenuMgr::GetInstance().IsVisible(); + Sp2::Glf::GlfMain::getInstance().setPause(isMenuOpen); -/** - * @brief Golf scene user draw callback - * - * @param scene Current scene - */ -void GlfSceneHook::OnUserDraw(RPSysScene* scene) {} + if (MenuMgr::GetInstance().GetMenu() == NULL) { + MenuMgr::GetInstance().OpenMenu(sGlfMenu); + } +} + +void GlfSceneHook::OnPausedSeqMgrCalc() { + if (MenuMgr::GetInstance().IsVisible()) { + return; + } + + Sp2::Glf::SequenceMgr::getInstance().Calculate(); +} +kmCall(0x804175e8, GlfSceneHook::OnPausedSeqMgrCalc); + +void GlfSceneHook::OnNextShot() { + if (sDidStopShot) { + Sp2::Glf::SequenceMgr::getInstance().GetSequenceMain()->NextShot(); + GlfPostMenu::ChangePhase(); + + sDidStopShot = false; + return; + } + + if (MenuMgr::GetInstance().IsVisible()) { + MenuMgr::GetInstance().CloseMenu(); + MenuMgr::GetInstance().SetVisible(false); + } + + MenuMgr::GetInstance().OpenMenu(sGlfPostMenu); + MenuMgr::GetInstance().SetVisible(true); +} +kmCall(0x803f8754, GlfSceneHook::OnNextShot); + +void GlfSceneHook::OnUserDraw(RPSysScene* scene) { + if (!MenuMgr::GetInstance().IsVisible()) { + return; + } + + if (MenuMgr::GetInstance().GetMenu() != sGlfMenu) { + return; + } + + char buffer[1024]; + + // Current pin display + { + u32 hole = Sp2::Glf::GlfConfig::getInstance().getCurrentHole(); + u32 pin = Sp2::Glf::GlfConfig::getInstance().getPin(); + + if (hole == 0) { + snprintf(buffer, sizeof(buffer), "Current Pin: %s", + ENUM_PIN_TYPE_HOLE1[pin]); + } else if (hole > 17) { + snprintf(buffer, sizeof(buffer), "Current Pin: %s", + ENUM_PIN_TYPE_SPECIAL[pin]); + } else { + snprintf(buffer, sizeof(buffer), "Current Pin: %s", + ENUM_PIN_TYPE[pin]); + } + + Sp2::PrintOutline(buffer, 0xFF00FFFF, 0xFF000000, false, 100.0f, + 180.0f); + } + + ; +} + +void GlfSceneHook::DrawPutterGuide(const nw4r::math::VEC3* pPoints, u16 num, + GXColor color, u8 width) { + + static const f32 sc_MinDistPutter = M(5.0); + static const f32 sc_MaxDistPutter = M(20.0); + + RPGlfPlayer& player = RPGlfPlayerManager::GetInstance().GetCurrentPlayer(); + + const nw4r::math::VEC3& pin_pos = + RPGlfFieldManager::getInstance().GetPinPos(); + + nw4r::math::VEC2 vd(player.GetAvatarPos().x - pin_pos.x, + player.GetAvatarPos().z - pin_pos.z); + + f32 pin_to_avatar_dist = nw4r::math::FSqrt(vd.x * vd.x + vd.y * vd.y); + + // Vector from the pin to the player position + nw4r::math::VEC2 pin_to_avatar; + RPGlfUtility::CalcDeltaXZ(pin_to_avatar, player.GetAvatarPos(), + RPGlfFieldManager::getInstance().GetPinPos()); + + f32 pin_avatar_angle_deg = + RPGlfUtility::CalcDeltaAngle2D(pin_to_avatar, player.GetAvatarAngle()); + pin_avatar_angle_deg = ABS(pin_avatar_angle_deg); + pin_avatar_angle_deg = NW4R_MATH_RAD_TO_DEG(pin_avatar_angle_deg); + + f32 dist_min = sc_MinDistPutter; + f32 dist_max = sc_MaxDistPutter; + CADDIE_ASSERT(dist_min < dist_max); + + // Putt distance clamped to the bounds + f32 dist_clamp = CLAMP(dist_min, dist_max, pin_to_avatar_dist); + + // Range of the distance bounds + f32 range = dist_max - dist_min; + + // Calculate angle threshold for a replay + f32 threshold; + if (range == 0.0f) { + threshold = 6.5f; + } else { + threshold = (dist_clamp - dist_min) * -6.5f / range + 6.5f; + } + + bool too_short = pin_to_avatar_dist < sc_MinDistPutter; + bool is_replay = pin_avatar_angle_deg >= threshold; + + // Putter guide line + { + if (too_short) { + color.r = 0; + color.g = 0; + color.b = 255; + } else if (is_replay) { + color.r = 0; + color.g = 255; + color.b = 0; + } else { + color.r = 255; + color.g = 0; + color.b = 0; + } + + if (!GetMenu().GetReplayInfo()) { + color.r = 32; + color.g = 64; + color.b = 255; + } + + EGG::DrawGX::DrawLineStrip(pPoints, num, color, width); + } +} +kmCall(0x803fab74, GlfSceneHook::DrawPutterGuide); + +void GlfSceneHook::DrawReplaySphere() { + if (RPGrpRenderer::GetDrawPass() != RPGrpRenderer::EDrawPass_DrawXLU) { + return; + } + + bool world_dl = RPGrpRenderer::GetViewID() == 1; + bool map_dl = RPGrpRenderer::GetViewID() == 5 && + !RPGlfFieldManager::getInstance().IsHideUI(); + + if (!world_dl && !map_dl) { + return; + } + + if (!GetMenu().GetReplayInfo()) { + return; + } + + if (RPGlfClubManager::getInstance().GetActiveClub()->GetType() == + RPGlfClub::EType_PT) { + return; + } + + RPGlfPlayer& player = RPGlfPlayerManager::GetInstance().GetCurrentPlayer(); + + const nw4r::math::VEC3& pin_pos = + RPGlfFieldManager::getInstance().GetPinPos(); + + nw4r::math::VEC2 vd(player.GetAvatarPos().x - pin_pos.x, + player.GetAvatarPos().z - pin_pos.z); + + f32 pin_to_avatar_dist = nw4r::math::FSqrt(vd.x * vd.x + vd.y * vd.y); + + bool bigger_range = + player.GetBall()->IsHitFlag() || player.GetBall()->IsHitPole(); + + f32 dist_min = YD(30); + f32 dist_max = YD(200); + CADDIE_ASSERT(dist_min < dist_max); + + f32 dist_clamp = CLAMP(dist_min, dist_max, pin_to_avatar_dist); + + f32 range = dist_max - dist_min; + CADDIE_ASSERT(range > 0.0f); + + f32 c0 = bigger_range ? M(3.0) : M(0.5); + f32 c1 = bigger_range ? M(10.0) : M(1.5); + f32 c2 = bigger_range ? M(3.0) : M(0.5); + f32 threshold = (c1 - c0) * (dist_clamp - dist_min) / range + c2; + + f32 ball_to_pin_dist = player.GetBall()->GetDistFromPin(); + bool in_range = ball_to_pin_dist <= threshold; + + nw4r::math::MTX34 old = EGG::DrawGX::s_cameraMtx; + { + nw4r::math::MTX34 mtx; + PSMTXIdentity(mtx); + PSMTXScaleApply(mtx, mtx, threshold, threshold, threshold); + PSMTXTransApply(mtx, mtx, pin_pos.x, pin_pos.y, pin_pos.z); + + nw4r::ut::Color color; + + if (in_range) { + color.r = 0; + color.g = 255; + color.b = 0; + } else { + if (bigger_range) { + color.r = 0; + color.g = 0; + color.b = 255; + } else { + color.r = 255; + color.g = 0; + color.b = 0; + } + } + + if (RPGrpRenderer::GetViewID() == 1) { + color.a = 100; + } else if (RPGrpRenderer::GetViewID() == 5) { + color.a = 255; + } else { + CADDIE_ASSERT(false); + } + + EGG::DrawGX::SetBlendMode(EGG::DrawGX::BLEND_NORMAL); + EGG::DrawGX::BeginDrawSphere(); + EGG::DrawGX::DrawDLWorld(EGG::DrawGX::DL_SPHERE_8X16, mtx, color); + } + EGG::DrawGX::s_cameraMtx = old; +} +kmBranch(0x80404b10, GlfSceneHook::DrawReplaySphere); /** * @brief Golf scene exit callback @@ -86,7 +354,7 @@ void GlfSceneHook::Apply_RepeatHole() { * @brief Apply pin settings from menu */ void GlfSceneHook::Apply_Pin() { - Sp2::Glf::GlfMain& main = Sp2::Glf::GlfMain::getInstance(); + Sp2::Glf::GlfConfig& main = Sp2::Glf::GlfConfig::getInstance(); // Next pin type int pin = GetMenu().GetPinType(); @@ -221,13 +489,13 @@ void GlfSceneHook::Apply_StaticMem() { } /** - * @brief Apply menu settings which require GlfMain + * @brief Apply menu settings which require GlfConfig */ -void GlfSceneHook::Apply_GlfMain() { +void GlfSceneHook::Apply_GlfConfig() { Apply_RepeatHole(); Apply_Pin(); } -kmBranch(0x8040680c, GlfSceneHook::Apply_GlfMain); +kmBranch(0x8040680c, GlfSceneHook::Apply_GlfConfig); /** * @brief Allow shot to be canceled by holding B + MINUS + 2 @@ -239,10 +507,12 @@ void GlfSceneHook::OnGlfBallCalc(RPGlfBall* ball, u32 frame, u32) { static const u32 scStopShotBtns = InputMgr::BTN_B | InputMgr::BTN_MINUS | InputMgr::BTN_2; - if (ball->IsMoving()) { - // Stop shot with B + MINUS + 2 - // TODO: Check input from current player's remote + RPGlfBall* pSimBall = RPGlfSimManager::GetSimBall(); + CADDIE_ASSERT(pSimBall); + + if (pSimBall->GetLifetime() > 0) { const u32 held = InputMgr::GetInstance().Held(InputMgr::PLAYER_1); + if ((held & scStopShotBtns) == scStopShotBtns) { // Remove OOB stroke penalty RPGlfPlayer& player = @@ -253,6 +523,8 @@ void GlfSceneHook::OnGlfBallCalc(RPGlfBall* ball, u32 frame, u32) { ball->SetCollision(RPGlfCollisionModel::COL_OB); ball->SetCollisionNoAir(RPGlfCollisionModel::COL_OB); ball->SetMoving(false); + + sDidStopShot = true; } } @@ -283,7 +555,7 @@ u32 GlfSceneHook::GetNumHolesPlayed() { // First hole of gamemode const u32 gmFirst = GlfUtil::GetGamemodeNthHoleInternal(0); // Current hole - const u32 gmCurrent = Sp2::Glf::GlfMain::getInstance().getCurrentHole(); + const u32 gmCurrent = Sp2::Glf::GlfConfig::getInstance().getCurrentHole(); // Avoid returning negative result // TODO: Figure out why this is even needed. Maybe abs(curr - first) is more @@ -305,6 +577,12 @@ GlfMenu& GlfSceneHook::GetMenu() { return *sGlfMenu; } +GlfPostMenu& GlfSceneHook::GetPostMenu() { + CADDIE_ASSERT(sGlfPostMenu != NULL); + return *sGlfPostMenu; +} + GlfMenu* GlfSceneHook::sGlfMenu = NULL; +GlfPostMenu* GlfSceneHook::sGlfPostMenu = NULL; } // namespace caddie diff --git a/src/caddie/scene/glf/caddieGlfUtil.cpp b/src/caddie/scene/glf/caddieGlfUtil.cpp index 1d012a1..4bf55b5 100644 --- a/src/caddie/scene/glf/caddieGlfUtil.cpp +++ b/src/caddie/scene/glf/caddieGlfUtil.cpp @@ -1,6 +1,6 @@ #include "caddieGlfUtil.h" -#include +#include namespace caddie { @@ -8,7 +8,7 @@ namespace caddie { * @brief Whether the current hole is the first hole of the gamemode */ bool GlfUtil::IsCurrentFirstHole() { - Sp2::Glf::GlfMain& main = Sp2::Glf::GlfMain::getInstance(); + Sp2::Glf::GlfConfig& main = Sp2::Glf::GlfConfig::getInstance(); return IsFirstHoleInternal(main.getGamemode(), main.getCurrentHole()); } @@ -57,7 +57,7 @@ bool GlfUtil::IsFirstHole(Sp2::Glf::GameMode gm, u32 hole) { * @brief Whether the current round is over (hole is past end of difficulty) */ bool GlfUtil::IsCurrentRoundOver() { - Sp2::Glf::GlfMain& main = Sp2::Glf::GlfMain::getInstance(); + Sp2::Glf::GlfConfig& main = Sp2::Glf::GlfConfig::getInstance(); return IsRoundOverInternal(main.getGamemode(), main.getCurrentHole()); } @@ -66,7 +66,7 @@ bool GlfUtil::IsCurrentRoundOver() { * difficulty) */ bool GlfUtil::IsNextRoundOver() { - Sp2::Glf::GlfMain& main = Sp2::Glf::GlfMain::getInstance(); + Sp2::Glf::GlfConfig& main = Sp2::Glf::GlfConfig::getInstance(); return IsRoundOverInternal(main.getGamemode(), main.getCurrentHole() + 1); } @@ -124,7 +124,7 @@ u32 GlfUtil::GetGamemodeNthHoleInternal(u32 n) { * @details Hole is one-indexed */ u32 GlfUtil::GetGamemodeNthHole(u32 n) { - switch (Sp2::Glf::GlfMain::getInstance().getGamemode()) { + switch (Sp2::Glf::GlfConfig::getInstance().getGamemode()) { case Sp2::Glf::GM_EIGHTEEN_HOLE: case Sp2::Glf::GM_RESORT_NINE: case Sp2::Glf::GM_RESORT_A: diff --git a/src/caddie/ui/caddieBuildInfo.cpp b/src/caddie/ui/caddieBuildInfo.cpp index 0dfc12d..ac630da 100644 --- a/src/caddie/ui/caddieBuildInfo.cpp +++ b/src/caddie/ui/caddieBuildInfo.cpp @@ -2,6 +2,8 @@ #include "types_caddie.h" +#include + using namespace nw4r; namespace caddie { @@ -33,7 +35,13 @@ BuildInfo::BuildInfo() { SetStroke(TextBox::STROKE_OUTLINE); SetCentered(true); SetTextColor(sBuildTextColor); - SetPosition(sBuildTextPos); + + if (SCGetAspectRatio() == SC_ASPECT_STD) { + nw4r::math::VEC2 posStd(305.0f, 20.0f); + SetPosition(posStd); + } else { + SetPosition(sBuildTextPos); + } const f32 heapFreeKb = MemManager::GetFreeSize() / KB_AS_B; SetTextFmt("Caddie (%s, %s): %s (%.1f KB free)", GetBuildTarget(), diff --git a/src/caddie/ui/menu/caddieMenuMgr.cpp b/src/caddie/ui/menu/caddieMenuMgr.cpp index ae3edf2..bf49204 100644 --- a/src/caddie/ui/menu/caddieMenuMgr.cpp +++ b/src/caddie/ui/menu/caddieMenuMgr.cpp @@ -2,6 +2,8 @@ #include "caddieInputMgr.h" +#include +#include #include using namespace nw4r; @@ -23,11 +25,13 @@ void MenuMgr::Calc() { // Toggle visibility if (trig & InputMgr::BTN_PLUS) { - SetVisible(!mIsVisible); + if (strcmp(mOpenPage->GetName(), "PostMenu") != 0) { + SetVisible(!mIsVisible); - // Delete changes on menu close - if (!IsVisible() && mOpenPage != NULL) { - mOpenPage->DeleteChanges(); + // Delete changes on menu close + if (!IsVisible() && mOpenPage != NULL) { + mOpenPage->DeleteChanges(); + } } } @@ -84,7 +88,12 @@ void MenuMgr::Calc() { // Update cursor screen position const math::VEC2 optionPos = mOpenPage->GetOption(mCursor).GetOptionPosition(); - const math::VEC2 cursorPos(optionPos.x - sCursorOffset, optionPos.y); + + math::VEC2 cursorPos(optionPos.x - sCursorOffset, optionPos.y); + if (SCGetAspectRatio() == SC_ASPECT_STD) { + cursorPos.x -= 3.0f; + } + mCursorText.SetPosition(cursorPos); } diff --git a/src/caddie/ui/menu/caddieMenuPage.cpp b/src/caddie/ui/menu/caddieMenuPage.cpp index 1784ed3..efc3f32 100644 --- a/src/caddie/ui/menu/caddieMenuPage.cpp +++ b/src/caddie/ui/menu/caddieMenuPage.cpp @@ -2,6 +2,8 @@ #include "caddieAlgorithm.h" +#include + using namespace nw4r; namespace caddie { @@ -55,7 +57,11 @@ void MenuPage::CalcWidth() { max = Max(nameLen, max); } - mWidth = max * sCharWidth; + if (SCGetAspectRatio() == SC_ASPECT_STD) { + mWidth = max * sCharWidth * 1.25f; + } else { + mWidth = max * sCharWidth; + } } /** From ad9234a2bc8967dc3e0dd69973372e42b682b65d Mon Sep 17 00:00:00 2001 From: vincenzo-sorcigli <57498723+vincenzo-sorcigli@users.noreply.github.com> Date: Fri, 26 Dec 2025 16:19:40 -0500 Subject: [PATCH 02/17] basic timer --- include/caddie/scene/glf/caddieGlfSceneHook.h | 5 ++ include/caddie/types_caddie.h | 2 + include/caddie/ui/timer/caddieTimer.h | 41 +++++++++++++ src/caddie/scene/glf/caddieGlfSceneHook.cpp | 27 ++++++++- src/caddie/ui/timer/caddieTimer.cpp | 59 +++++++++++++++++++ 5 files changed, 132 insertions(+), 2 deletions(-) create mode 100644 include/caddie/ui/timer/caddieTimer.h create mode 100644 src/caddie/ui/timer/caddieTimer.cpp diff --git a/include/caddie/scene/glf/caddieGlfSceneHook.h b/include/caddie/scene/glf/caddieGlfSceneHook.h index c74b313..8fbbcf4 100644 --- a/include/caddie/scene/glf/caddieGlfSceneHook.h +++ b/include/caddie/scene/glf/caddieGlfSceneHook.h @@ -1,5 +1,8 @@ #ifndef CADDIE_SCENE_GLF_SCENE_HOOK_H #define CADDIE_SCENE_GLF_SCENE_HOOK_H + +#include "caddieTimer.h" + #include "types_caddie.h" namespace caddie { @@ -32,6 +35,8 @@ class GlfSceneHook { private: //! @brief Golf menu static GlfMenu* sGlfMenu; + //! @brief timer + static Timer* sTimer; }; } // namespace caddie diff --git a/include/caddie/types_caddie.h b/include/caddie/types_caddie.h index 4d14779..c7755ac 100644 --- a/include/caddie/types_caddie.h +++ b/include/caddie/types_caddie.h @@ -39,6 +39,8 @@ struct BuildInfo; struct Pane; struct TextBox; +struct Timer; + // scene/glf struct GlfMenu; struct GlfSceneHook; diff --git a/include/caddie/ui/timer/caddieTimer.h b/include/caddie/ui/timer/caddieTimer.h new file mode 100644 index 0000000..839dcb3 --- /dev/null +++ b/include/caddie/ui/timer/caddieTimer.h @@ -0,0 +1,41 @@ +#ifndef CADDIE_SCENE_UI_TIMER_H +#define CADDIE_SCENE_UI_TIMER_H + +#include + +#include "types_caddie.h" + +#include + +namespace caddie { + + class Timer { + public: + Timer(); + ~Timer(); + + void Start(); + void Stop(); + void Reset(); + + void Freeze(u32 duration); + + virtual void Calc(); + virtual void Draw(); + + private: + bool mRunning; + u32 mTimerValue; + + u32 mFrozenValue; + u32 mFrozenDuration; + + TextBox mTextBox; + + // default timer position on screen + static const nw4r::math::VEC2 sTimerPos; + }; + +} + +#endif // CADDIE_SCENE_UI_TIMER_H \ No newline at end of file diff --git a/src/caddie/scene/glf/caddieGlfSceneHook.cpp b/src/caddie/scene/glf/caddieGlfSceneHook.cpp index a379f0c..971a006 100644 --- a/src/caddie/scene/glf/caddieGlfSceneHook.cpp +++ b/src/caddie/scene/glf/caddieGlfSceneHook.cpp @@ -26,6 +26,16 @@ void GlfSceneHook::OnConfigure(RPSysScene* scene) { CADDIE_ASSERT(sGlfMenu != NULL); } + // setup timer + if (sTimer == NULL) { + sTimer = new Timer(); + CADDIE_ASSERT(sTimer != NULL); + } + + // start timer + sTimer->Reset(); + sTimer->Start(); + // Open menu root MenuMgr::GetInstance().OpenMenu(sGlfMenu); } @@ -35,14 +45,22 @@ void GlfSceneHook::OnConfigure(RPSysScene* scene) { * * @param scene Current scene */ -void GlfSceneHook::OnCalculate(RPSysScene* scene) {} +void GlfSceneHook::OnCalculate(RPSysScene* scene) { + if (sTimer != NULL) { + sTimer->Calc(); + } +} /** * @brief Golf scene user draw callback * * @param scene Current scene */ -void GlfSceneHook::OnUserDraw(RPSysScene* scene) {} +void GlfSceneHook::OnUserDraw(RPSysScene* scene) { + if (sTimer != NULL) { + sTimer->Draw(); + } +} /** * @brief Golf scene exit callback @@ -59,6 +77,10 @@ void GlfSceneHook::OnExit(RPSysScene* scene) { else { Apply_StaticMem(); } + if (sTimer != NULL) { + delete sTimer; + sTimer = NULL; + } } /** @@ -306,5 +328,6 @@ GlfMenu& GlfSceneHook::GetMenu() { } GlfMenu* GlfSceneHook::sGlfMenu = NULL; +Timer* GlfSceneHook::sTimer = NULL; } // namespace caddie diff --git a/src/caddie/ui/timer/caddieTimer.cpp b/src/caddie/ui/timer/caddieTimer.cpp new file mode 100644 index 0000000..1a507dd --- /dev/null +++ b/src/caddie/ui/timer/caddieTimer.cpp @@ -0,0 +1,59 @@ +#include "caddie/ui/timer/caddieTimer.h" +#include +#include + +#include + +namespace caddie { + +Timer::Timer() + : mRunning(false), + mTimerValue(0), + mFrozenValue(0), + mFrozenDuration(0), + mTextBox() { + mTextBox.SetText("0.00"); + mTextBox.SetPosition(sTimerPos); + } + +const nw4r::math::VEC2 Timer::sTimerPos(8.0f, 8.0f); + +Timer::~Timer() {} + +void Timer::Start() { + mRunning = true; +} + +void Timer::Stop() { + mRunning = false; +} + +void Timer::Reset() { + mTimerValue = 0; + mFrozenValue = 0; + mFrozenDuration = 0; +} + +void Timer::Freeze(u32 duration) { + mFrozenValue = mTimerValue; + mFrozenDuration = duration; +} + +void Timer::Calc() { + if (mFrozenDuration > 0) { + --mFrozenDuration; + } + + if (mRunning) { + ++mTimerValue; + } + + u32 valueToDisplay = mFrozenDuration > 0 ? mFrozenValue : mTimerValue; + mTextBox.SetTextFmt("%.2f", valueToDisplay / 60.0f); +} + +void Timer::Draw() { + mTextBox.Draw(); +} + +} \ No newline at end of file From abb8ba5a1c9ac8cb95d65b5a8b7a4f21564a88a9 Mon Sep 17 00:00:00 2001 From: vincenzo-sorcigli <57498723+vincenzo-sorcigli@users.noreply.github.com> Date: Fri, 26 Dec 2025 16:55:55 -0500 Subject: [PATCH 03/17] timer doesn't just show when menu is up --- src/caddie/scene/glf/caddieGlfSceneHook.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/caddie/scene/glf/caddieGlfSceneHook.cpp b/src/caddie/scene/glf/caddieGlfSceneHook.cpp index 1e011ec..bca0e12 100644 --- a/src/caddie/scene/glf/caddieGlfSceneHook.cpp +++ b/src/caddie/scene/glf/caddieGlfSceneHook.cpp @@ -66,10 +66,10 @@ void GlfSceneHook::OnConfigure(RPSysScene* scene) { sTimer = new Timer(); CADDIE_ASSERT(sTimer != NULL); } - // start timer sTimer->Reset(); sTimer->Start(); + if (sGlfPostMenu == NULL) { sGlfPostMenu = new GlfPostMenu(); CADDIE_ASSERT(sGlfPostMenu != NULL); @@ -126,6 +126,10 @@ void GlfSceneHook::OnNextShot() { kmCall(0x803f8754, GlfSceneHook::OnNextShot); void GlfSceneHook::OnUserDraw(RPSysScene* scene) { + if (sTimer != NULL) { + sTimer->Draw(); + } + if (!MenuMgr::GetInstance().IsVisible()) { return; } @@ -155,8 +159,6 @@ void GlfSceneHook::OnUserDraw(RPSysScene* scene) { Sp2::PrintOutline(buffer, 0xFF00FFFF, 0xFF000000, false, 100.0f, 180.0f); } - - ; } void GlfSceneHook::DrawPutterGuide(const nw4r::math::VEC3* pPoints, u16 num, From 146bde47ebac22b5fd19d8343a520404b2240d33 Mon Sep 17 00:00:00 2001 From: vincenzo-sorcigli <57498723+vincenzo-sorcigli@users.noreply.github.com> Date: Fri, 26 Dec 2025 18:19:40 -0500 Subject: [PATCH 04/17] pause timer if game is paused --- include/lib/Sports2/Scene/Glf/Sp2GlfMain.h | 1 + src/caddie/scene/glf/caddieGlfSceneHook.cpp | 10 ++++++++++ 2 files changed, 11 insertions(+) diff --git a/include/lib/Sports2/Scene/Glf/Sp2GlfMain.h b/include/lib/Sports2/Scene/Glf/Sp2GlfMain.h index 930f870..a45d597 100644 --- a/include/lib/Sports2/Scene/Glf/Sp2GlfMain.h +++ b/include/lib/Sports2/Scene/Glf/Sp2GlfMain.h @@ -14,6 +14,7 @@ class GlfMain { return *sInstance; } + bool getPause() { return mIsPause; } void setPause(bool pause) { mIsPause = pause; } private: diff --git a/src/caddie/scene/glf/caddieGlfSceneHook.cpp b/src/caddie/scene/glf/caddieGlfSceneHook.cpp index bca0e12..9d28f78 100644 --- a/src/caddie/scene/glf/caddieGlfSceneHook.cpp +++ b/src/caddie/scene/glf/caddieGlfSceneHook.cpp @@ -92,6 +92,16 @@ void GlfSceneHook::OnCalculate(RPSysScene* scene) { MenuMgr::GetInstance().OpenMenu(sGlfMenu); } + // if game is paused, stop timer, else start it + bool paused = Sp2::Glf::GlfMain::getInstance().getPause(); + if (paused) { + sTimer->Stop(); + } + else { + sTimer->Start(); + } + + // change the timer if (sTimer != NULL) { sTimer->Calc(); } From 821573802fd7553a2daa4bdaf1ddefc57bf51c5a Mon Sep 17 00:00:00 2001 From: vincenzo-sorcigli <57498723+vincenzo-sorcigli@users.noreply.github.com> Date: Fri, 26 Dec 2025 18:43:33 -0500 Subject: [PATCH 05/17] retry shot menu option --- include/caddie/scene/glf/caddieGlfMenu.h | 2 ++ include/caddie/scene/glf/caddieGlfMessage.h | 1 + src/caddie/scene/glf/caddieGlfMenu.cpp | 7 +++++-- src/caddie/scene/glf/caddieGlfMessage.cpp | 2 ++ src/caddie/scene/glf/caddieGlfSceneHook.cpp | 2 +- 5 files changed, 11 insertions(+), 3 deletions(-) diff --git a/include/caddie/scene/glf/caddieGlfMenu.h b/include/caddie/scene/glf/caddieGlfMenu.h index 970ed62..8f1098d 100644 --- a/include/caddie/scene/glf/caddieGlfMenu.h +++ b/include/caddie/scene/glf/caddieGlfMenu.h @@ -35,6 +35,7 @@ class GlfMenu : public MenuBase { } bool GetReplayInfo() const { return mReplayInfo.GetSavedValue(); } + bool GetRetryShotMenu() const { return mRetryShotMenu.GetSavedValue(); } private: MenuIntOption mHole; @@ -44,6 +45,7 @@ class GlfMenu : public MenuBase { MenuEnumOption mWindSpd; MenuEnumOption mWindSpdRange; MenuBoolOption mReplayInfo; + MenuBoolOption mRetryShotMenu; MenuActionOption mApplyRestart; MenuActionOption mQuitGame; diff --git a/include/caddie/scene/glf/caddieGlfMessage.h b/include/caddie/scene/glf/caddieGlfMessage.h index 336c235..e6886a1 100644 --- a/include/caddie/scene/glf/caddieGlfMessage.h +++ b/include/caddie/scene/glf/caddieGlfMessage.h @@ -14,6 +14,7 @@ extern const char* MSG_WIND_DIR; extern const char* MSG_WIND_SPD; extern const char* MSG_WIND_SPD_RANGE; extern const char* MSG_REPLAY_INFO; +extern const char* MSG_RETRY_SHOT; extern const char* MSG_APPLY; extern const char* MSG_QUIT; diff --git a/src/caddie/scene/glf/caddieGlfMenu.cpp b/src/caddie/scene/glf/caddieGlfMenu.cpp index 0eecd32..bc19676 100644 --- a/src/caddie/scene/glf/caddieGlfMenu.cpp +++ b/src/caddie/scene/glf/caddieGlfMenu.cpp @@ -19,8 +19,9 @@ GlfMenu::GlfMenu() mWindSpd(MSG_WIND_SPD, ENUM_WIND_SPD, 0, WIND_SPD_RANDOM), mWindSpdRange(MSG_WIND_SPD_RANGE, ENUM_WIND_SPD_RANGE, 0, CADDIE_ENUM_MAX(ENUM_WIND_SPD_RANGE)), - mReplayInfo(MSG_REPLAY_INFO, false), - mApplyRestart(MSG_APPLY, Action_ApplyRestart, this), + mReplayInfo(MSG_REPLAY_INFO, false), + mRetryShotMenu(MSG_RETRY_SHOT, false), + mApplyRestart(MSG_APPLY, Action_ApplyRestart, this), mQuitGame(MSG_QUIT, Action_QuitGame, this) { // Build root page GetRootPage().AppendOption(&mHole); @@ -30,6 +31,7 @@ GlfMenu::GlfMenu() GetRootPage().AppendOption(&mWindSpd); GetRootPage().AppendOption(&mWindSpdRange); GetRootPage().AppendOption(&mReplayInfo); + GetRootPage().AppendOption(&mRetryShotMenu); GetRootPage().AppendOption(&mApplyRestart); GetRootPage().AppendOption(&mQuitGame); } @@ -41,6 +43,7 @@ GlfMenu::~GlfMenu() {} */ void GlfMenu::OnChange() { mReplayInfo.SaveChanges(); + mRetryShotMenu.SaveChanges(); // Hole 18 has one pin mPinType.SetEnabled(mHole.GetUnsavedValue() != 18); diff --git a/src/caddie/scene/glf/caddieGlfMessage.cpp b/src/caddie/scene/glf/caddieGlfMessage.cpp index a381200..14711c3 100644 --- a/src/caddie/scene/glf/caddieGlfMessage.cpp +++ b/src/caddie/scene/glf/caddieGlfMessage.cpp @@ -27,6 +27,8 @@ const char* MSG_WIND_SPD_RANGE = "Wind Speed Range"; //! @brief Text for Replay Info option const char* MSG_REPLAY_INFO = "Show Replay Info"; +//! @brief Text for Retry Shot Menu option +const char* MSG_RETRY_SHOT = "Enable Retry Shot Menu"; //! @brief Text for Apply and Restart option const char* MSG_APPLY = "Apply and Restart"; diff --git a/src/caddie/scene/glf/caddieGlfSceneHook.cpp b/src/caddie/scene/glf/caddieGlfSceneHook.cpp index 694a77f..0d64c38 100644 --- a/src/caddie/scene/glf/caddieGlfSceneHook.cpp +++ b/src/caddie/scene/glf/caddieGlfSceneHook.cpp @@ -93,7 +93,7 @@ void GlfSceneHook::OnPausedSeqMgrCalc() { kmCall(0x804175e8, GlfSceneHook::OnPausedSeqMgrCalc); void GlfSceneHook::OnNextShot() { - if (sDidStopShot) { + if (sDidStopShot || !GetMenu().GetRetryShotMenu()) { Sp2::Glf::SequenceMgr::getInstance().GetSequenceMain()->NextShot(); GlfPostMenu::ChangePhase(); From e6c6260841189161c60eb6c0bb59aca556989665 Mon Sep 17 00:00:00 2001 From: vincenzo-sorcigli <57498723+vincenzo-sorcigli@users.noreply.github.com> Date: Fri, 26 Dec 2025 19:18:53 -0500 Subject: [PATCH 06/17] timer freezes on next shot, and text color --- include/caddie/ui/timer/caddieTimer.h | 5 ++++ src/caddie/scene/glf/caddieGlfSceneHook.cpp | 19 +++++++------ src/caddie/ui/timer/caddieTimer.cpp | 31 ++++++++++++++++++--- 3 files changed, 43 insertions(+), 12 deletions(-) diff --git a/include/caddie/ui/timer/caddieTimer.h b/include/caddie/ui/timer/caddieTimer.h index 839dcb3..80910be 100644 --- a/include/caddie/ui/timer/caddieTimer.h +++ b/include/caddie/ui/timer/caddieTimer.h @@ -6,6 +6,7 @@ #include "types_caddie.h" #include +#include namespace caddie { @@ -34,6 +35,10 @@ namespace caddie { // default timer position on screen static const nw4r::math::VEC2 sTimerPos; + // default timer text colors + static const nw4r::ut::Color sTimerRunningColor; + static const nw4r::ut::Color sTimerFrozenColor; + static const nw4r::ut::Color sTimerStoppedColor; }; } diff --git a/src/caddie/scene/glf/caddieGlfSceneHook.cpp b/src/caddie/scene/glf/caddieGlfSceneHook.cpp index 9d28f78..a725f81 100644 --- a/src/caddie/scene/glf/caddieGlfSceneHook.cpp +++ b/src/caddie/scene/glf/caddieGlfSceneHook.cpp @@ -117,21 +117,24 @@ void GlfSceneHook::OnPausedSeqMgrCalc() { kmCall(0x804175e8, GlfSceneHook::OnPausedSeqMgrCalc); void GlfSceneHook::OnNextShot() { - if (sDidStopShot) { + + sTimer->Freeze(90); + + // if (sDidStopShot) { Sp2::Glf::SequenceMgr::getInstance().GetSequenceMain()->NextShot(); GlfPostMenu::ChangePhase(); sDidStopShot = false; return; - } + // } - if (MenuMgr::GetInstance().IsVisible()) { - MenuMgr::GetInstance().CloseMenu(); - MenuMgr::GetInstance().SetVisible(false); - } + // if (MenuMgr::GetInstance().IsVisible()) { + // MenuMgr::GetInstance().CloseMenu(); + // MenuMgr::GetInstance().SetVisible(false); + // } - MenuMgr::GetInstance().OpenMenu(sGlfPostMenu); - MenuMgr::GetInstance().SetVisible(true); + // MenuMgr::GetInstance().OpenMenu(sGlfPostMenu); + // MenuMgr::GetInstance().SetVisible(true); } kmCall(0x803f8754, GlfSceneHook::OnNextShot); diff --git a/src/caddie/ui/timer/caddieTimer.cpp b/src/caddie/ui/timer/caddieTimer.cpp index 1a507dd..e83fba6 100644 --- a/src/caddie/ui/timer/caddieTimer.cpp +++ b/src/caddie/ui/timer/caddieTimer.cpp @@ -1,4 +1,6 @@ #include "caddie/ui/timer/caddieTimer.h" +#include "caddie/ui/caddieTextBox.h" + #include #include @@ -14,9 +16,15 @@ Timer::Timer() mTextBox() { mTextBox.SetText("0.00"); mTextBox.SetPosition(sTimerPos); + mTextBox.SetStroke(TextBox::STROKE_OUTLINE); } -const nw4r::math::VEC2 Timer::sTimerPos(8.0f, 8.0f); +const nw4r::math::VEC2 Timer::sTimerPos(8.0f, 20.0f); + +const nw4r::ut::Color Timer::sTimerRunningColor(0, 255, 255, 255); +const nw4r::ut::Color Timer::sTimerFrozenColor(0, 180, 180, 255); +const nw4r::ut::Color Timer::sTimerStoppedColor(180, 180, 180, 255); + Timer::~Timer() {} @@ -40,13 +48,28 @@ void Timer::Freeze(u32 duration) { } void Timer::Calc() { - if (mFrozenDuration > 0) { - --mFrozenDuration; - } if (mRunning) { ++mTimerValue; + + if (mFrozenDuration > 0) { + --mFrozenDuration; + } + } + + // decide color + nw4r::ut::Color color; + if (mRunning) { + if (mFrozenDuration > 0) { + color = sTimerFrozenColor; + } + else { + color = sTimerRunningColor; + } + } else { + color = sTimerStoppedColor; } + mTextBox.SetTextColor(color); u32 valueToDisplay = mFrozenDuration > 0 ? mFrozenValue : mTimerValue; mTextBox.SetTextFmt("%.2f", valueToDisplay / 60.0f); From ce7983957546c9420323aacf7cff46470e5fe1d6 Mon Sep 17 00:00:00 2001 From: vincenzo-sorcigli <57498723+vincenzo-sorcigli@users.noreply.github.com> Date: Fri, 26 Dec 2025 19:21:45 -0500 Subject: [PATCH 07/17] i forgot i commented this for testing --- src/caddie/scene/glf/caddieGlfSceneHook.cpp | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/caddie/scene/glf/caddieGlfSceneHook.cpp b/src/caddie/scene/glf/caddieGlfSceneHook.cpp index a725f81..4ca3528 100644 --- a/src/caddie/scene/glf/caddieGlfSceneHook.cpp +++ b/src/caddie/scene/glf/caddieGlfSceneHook.cpp @@ -120,21 +120,21 @@ void GlfSceneHook::OnNextShot() { sTimer->Freeze(90); - // if (sDidStopShot) { + if (sDidStopShot) { Sp2::Glf::SequenceMgr::getInstance().GetSequenceMain()->NextShot(); GlfPostMenu::ChangePhase(); sDidStopShot = false; return; - // } + } - // if (MenuMgr::GetInstance().IsVisible()) { - // MenuMgr::GetInstance().CloseMenu(); - // MenuMgr::GetInstance().SetVisible(false); - // } + if (MenuMgr::GetInstance().IsVisible()) { + MenuMgr::GetInstance().CloseMenu(); + MenuMgr::GetInstance().SetVisible(false); + } - // MenuMgr::GetInstance().OpenMenu(sGlfPostMenu); - // MenuMgr::GetInstance().SetVisible(true); + MenuMgr::GetInstance().OpenMenu(sGlfPostMenu); + MenuMgr::GetInstance().SetVisible(true); } kmCall(0x803f8754, GlfSceneHook::OnNextShot); From ebafc2dfb21ecf2613cbded868e24444fc2d5816 Mon Sep 17 00:00:00 2001 From: Vincenzo Date: Sun, 28 Dec 2025 17:04:57 -0500 Subject: [PATCH 08/17] random wind fix --- src/caddie/scene/glf/caddieGlfSceneHook.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/caddie/scene/glf/caddieGlfSceneHook.cpp b/src/caddie/scene/glf/caddieGlfSceneHook.cpp index a379f0c..bd7cb09 100644 --- a/src/caddie/scene/glf/caddieGlfSceneHook.cpp +++ b/src/caddie/scene/glf/caddieGlfSceneHook.cpp @@ -194,7 +194,7 @@ void GlfSceneHook::Apply_Wind() { } // Generate random speed - spd = Sp2::Rand(min, max); + spd = Sp2::Rand(min, max + 1); } // Random direction From 8cfd343c08ecd61d02de09639b62f47dd3ec9637 Mon Sep 17 00:00:00 2001 From: Vincenzo Date: Tue, 30 Dec 2025 21:21:14 -0500 Subject: [PATCH 09/17] this might just make fg work --- src/main.cpp | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/main.cpp b/src/main.cpp index bcb2e51..378fa68 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -43,6 +43,13 @@ void main() { GlfSceneHook::OnUserDraw, GlfSceneHook::OnExit}); // Disable pausing in the Golf scene SceneHookMgr::GetInstance().AllowPause(RPSysSceneCreator::SCENE_GLF, false); + + SceneHookMgr::GetInstance().SetHook( + RPSysSceneCreator::SCENE_DGL, + (SceneHook){GlfSceneHook::OnConfigure, GlfSceneHook::OnCalculate, + GlfSceneHook::OnUserDraw, GlfSceneHook::OnExit}); + + SceneHookMgr::GetInstance().AllowPause(RPSysSceneCreator::SCENE_DGL, false); } kmBranch(0x80230b60, main); From 23abdb023b5c0337933ef943e3c133be2a568bcb Mon Sep 17 00:00:00 2001 From: vincenzo-sorcigli <57498723+vincenzo-sorcigli@users.noreply.github.com> Date: Tue, 30 Dec 2025 22:08:10 -0500 Subject: [PATCH 10/17] this made fg work --- src/caddie/scene/glf/caddieGlfSceneHook.cpp | 56 ++++++++++----------- src/caddie/scene/glf/caddieGlfUtil.cpp | 54 +++++++++++--------- 2 files changed, 57 insertions(+), 53 deletions(-) diff --git a/src/caddie/scene/glf/caddieGlfSceneHook.cpp b/src/caddie/scene/glf/caddieGlfSceneHook.cpp index caadacc..a07b7d6 100644 --- a/src/caddie/scene/glf/caddieGlfSceneHook.cpp +++ b/src/caddie/scene/glf/caddieGlfSceneHook.cpp @@ -86,20 +86,20 @@ void GlfSceneHook::OnConfigure(RPSysScene* scene) { */ void GlfSceneHook::OnCalculate(RPSysScene* scene) { bool isMenuOpen = MenuMgr::GetInstance().IsVisible(); - Sp2::Glf::GlfMain::getInstance().setPause(isMenuOpen); + // Sp2::Glf::GlfMain::getInstance().setPause(isMenuOpen); if (MenuMgr::GetInstance().GetMenu() == NULL) { MenuMgr::GetInstance().OpenMenu(sGlfMenu); } // if game is paused, stop timer, else start it - bool paused = Sp2::Glf::GlfMain::getInstance().getPause(); - if (paused) { - sTimer->Stop(); - } - else { - sTimer->Start(); - } + // bool paused = Sp2::Glf::GlfMain::getInstance().getPause(); + // if (paused) { + // sTimer->Stop(); + // } + // else { + // sTimer->Start(); + // } // change the timer if (sTimer != NULL) { @@ -153,25 +153,25 @@ void GlfSceneHook::OnUserDraw(RPSysScene* scene) { char buffer[1024]; - // Current pin display - { - u32 hole = Sp2::Glf::GlfConfig::getInstance().getCurrentHole(); - u32 pin = Sp2::Glf::GlfConfig::getInstance().getPin(); - - if (hole == 0) { - snprintf(buffer, sizeof(buffer), "Current Pin: %s", - ENUM_PIN_TYPE_HOLE1[pin]); - } else if (hole > 17) { - snprintf(buffer, sizeof(buffer), "Current Pin: %s", - ENUM_PIN_TYPE_SPECIAL[pin]); - } else { - snprintf(buffer, sizeof(buffer), "Current Pin: %s", - ENUM_PIN_TYPE[pin]); - } - - Sp2::PrintOutline(buffer, 0xFF00FFFF, 0xFF000000, false, 100.0f, - 180.0f); - } + // // Current pin display + // { + // u32 hole = Sp2::Glf::GlfConfig::getInstance().getCurrentHole(); + // u32 pin = Sp2::Glf::GlfConfig::getInstance().getPin(); + + // if (hole == 0) { + // snprintf(buffer, sizeof(buffer), "Current Pin: %s", + // ENUM_PIN_TYPE_HOLE1[pin]); + // } else if (hole > 17) { + // snprintf(buffer, sizeof(buffer), "Current Pin: %s", + // ENUM_PIN_TYPE_SPECIAL[pin]); + // } else { + // snprintf(buffer, sizeof(buffer), "Current Pin: %s", + // ENUM_PIN_TYPE[pin]); + // } + + // Sp2::PrintOutline(buffer, 0xFF00FFFF, 0xFF000000, false, 100.0f, + // 180.0f); + // } } void GlfSceneHook::DrawPutterGuide(const nw4r::math::VEC3* pPoints, u16 num, @@ -504,7 +504,7 @@ void GlfSceneHook::Apply_Wind() { } Sp2::StaticMem::getInstance().setStaticVar( - Sp2::Glf::VAR_WIND + GetMenu().GetHoleInternal(), + 9 + GetMenu().GetHoleInternal(), Sp2::Glf::PackWind(dir, spd), false); } diff --git a/src/caddie/scene/glf/caddieGlfUtil.cpp b/src/caddie/scene/glf/caddieGlfUtil.cpp index 4bf55b5..db0a822 100644 --- a/src/caddie/scene/glf/caddieGlfUtil.cpp +++ b/src/caddie/scene/glf/caddieGlfUtil.cpp @@ -8,8 +8,9 @@ namespace caddie { * @brief Whether the current hole is the first hole of the gamemode */ bool GlfUtil::IsCurrentFirstHole() { - Sp2::Glf::GlfConfig& main = Sp2::Glf::GlfConfig::getInstance(); - return IsFirstHoleInternal(main.getGamemode(), main.getCurrentHole()); + // Sp2::Glf::GlfConfig& main = Sp2::Glf::GlfConfig::getInstance(); + // return IsFirstHoleInternal(main.getGamemode(), main.getCurrentHole()); + return false; } /** @@ -57,8 +58,9 @@ bool GlfUtil::IsFirstHole(Sp2::Glf::GameMode gm, u32 hole) { * @brief Whether the current round is over (hole is past end of difficulty) */ bool GlfUtil::IsCurrentRoundOver() { - Sp2::Glf::GlfConfig& main = Sp2::Glf::GlfConfig::getInstance(); - return IsRoundOverInternal(main.getGamemode(), main.getCurrentHole()); + // Sp2::Glf::GlfConfig& main = Sp2::Glf::GlfConfig::getInstance(); + // return IsRoundOverInternal(main.getGamemode(), main.getCurrentHole()); + return false; } /** @@ -66,8 +68,9 @@ bool GlfUtil::IsCurrentRoundOver() { * difficulty) */ bool GlfUtil::IsNextRoundOver() { - Sp2::Glf::GlfConfig& main = Sp2::Glf::GlfConfig::getInstance(); - return IsRoundOverInternal(main.getGamemode(), main.getCurrentHole() + 1); + // Sp2::Glf::GlfConfig& main = Sp2::Glf::GlfConfig::getInstance(); + // return IsRoundOverInternal(main.getGamemode(), main.getCurrentHole() + 1); + return false; } /** @@ -124,25 +127,26 @@ u32 GlfUtil::GetGamemodeNthHoleInternal(u32 n) { * @details Hole is one-indexed */ u32 GlfUtil::GetGamemodeNthHole(u32 n) { - switch (Sp2::Glf::GlfConfig::getInstance().getGamemode()) { - case Sp2::Glf::GM_EIGHTEEN_HOLE: - case Sp2::Glf::GM_RESORT_NINE: - case Sp2::Glf::GM_RESORT_A: - return 1 + n; - case Sp2::Glf::GM_RESORT_B: - return 4 + n; - case Sp2::Glf::GM_RESORT_C: - return 7 + n; - case Sp2::Glf::GM_CLASSIC_NINE: - case Sp2::Glf::GM_CLASSIC_A: - return 10 + n; - case Sp2::Glf::GM_CLASSIC_B: - return 13 + n; - case Sp2::Glf::GM_CLASSIC_C: - return 16 + n; - case Sp2::Glf::GM_SPECIAL: - return 19 + n; - } + // switch (Sp2::Glf::GlfConfig::getInstance().getGamemode()) { + // case Sp2::Glf::GM_EIGHTEEN_HOLE: + // case Sp2::Glf::GM_RESORT_NINE: + // case Sp2::Glf::GM_RESORT_A: + // return 1 + n; + // case Sp2::Glf::GM_RESORT_B: + // return 4 + n; + // case Sp2::Glf::GM_RESORT_C: + // return 7 + n; + // case Sp2::Glf::GM_CLASSIC_NINE: + // case Sp2::Glf::GM_CLASSIC_A: + // return 10 + n; + // case Sp2::Glf::GM_CLASSIC_B: + // return 13 + n; + // case Sp2::Glf::GM_CLASSIC_C: + // return 16 + n; + // case Sp2::Glf::GM_SPECIAL: + // return 19 + n; + // } + return 1+n; } } // namespace caddie From c33135cf7c0ecc645ce787552254ccc405a645ce Mon Sep 17 00:00:00 2001 From: vincenzo-sorcigli <57498723+vincenzo-sorcigli@users.noreply.github.com> Date: Wed, 31 Dec 2025 05:27:48 -0500 Subject: [PATCH 11/17] it works on pal --- externals/NTSC_U.txt | 5 +- externals/PAL.txt | 79 +++++++++++++++++++-- include/loader/rzte.h | 2 +- src/caddie/core/caddieSceneHookMgr.cpp | 16 +++++ src/caddie/scene/glf/caddieGlfSceneHook.cpp | 2 +- src/caddie/scene/glf/caddieGlfUtil.cpp | 56 +++++++-------- src/main.cpp | 6 ++ 7 files changed, 128 insertions(+), 38 deletions(-) diff --git a/externals/NTSC_U.txt b/externals/NTSC_U.txt index 6f9c05c..2ee2bc9 100644 --- a/externals/NTSC_U.txt +++ b/externals/NTSC_U.txt @@ -74,10 +74,6 @@ loadToMainRAM__Q23EGG9DvdRipperFPCcPUcPQ23EGG4HeapQ33EGG9DvdRipper15EAllocDirect # RP/RPSystem/RPSysSceneMgr sInstance__13RPSysSceneMgr=0x806f4c98 -# RP/RPSystem/RPSysSysMsgWinMgr -update__17RPSysSysMsgWinMgrFv=0x802352d4 -sInstance__17RPSysSysMsgWinMgr=0x806f4ce0 - # RP/RPSystem/RPSysSceneCreator changeSceneAfterFade__17RPSysSceneCreatorFiQ34nw4r2ut5Color=0x8022edfc sInstance__17RPSysSceneCreator=0x806f4c88 @@ -86,6 +82,7 @@ sInstance__17RPSysSceneCreator=0x806f4c88 sInstance__13RPSysPauseMgr=0x806f4cd0 update__13RPSysPauseMgrFv=0x802352d4 + # RP/RPSystem/RPSysProjectLocal sInstance__17RPSysProjectLocal=0x806f4ca0 diff --git a/externals/PAL.txt b/externals/PAL.txt index 67de766..e34ce8a 100644 --- a/externals/PAL.txt +++ b/externals/PAL.txt @@ -11,10 +11,14 @@ OSReport=0x80061470 # STL/cstdio vprintf=0x8000ceec vsprintf=0x8000cff0 +vsnprintf=0x8000cf68 sprintf=0x8000d168 +snprintf=0x8000d074 # STL/string strcmp=0x8000e8b0 +strlen=0x800071c0 +strncpy=0x8000e7f4 # TRK/runtime _savefpr_25=0x800077b8 @@ -25,6 +29,20 @@ _savefpr_28=0x800077c4 _restfpr_28=0x80007810 _savefpr_29=0x800077c8 _restfpr_29=0x80007814 + +_savegpr_24=0x8000784c +_restgpr_24=0x80007898 +_savegpr_25=0x80007850 +_restgpr_25=0x8000789c +_savegpr_26=0x80007854 +_restgpr_26=0x800078a0 +_savegpr_27=0x80007858 +_restgpr_27=0x800078a4 +_savegpr_28=0x8000785c +_restgpr_28=0x800078a8 +_savegpr_29=0x80007860 +_restgpr_29=0x800078ac + __register_global_object=0x800072a4 __destroy_arr=0x800075bc @@ -33,33 +51,52 @@ List_Init__Q24nw4r2utFPQ34nw4r2ut4ListUs=0x8010b9e0 List_GetNth__Q24nw4r2utFPCQ34nw4r2ut4ListUs=0x8010bc40 List_Append__Q24nw4r2utFPQ34nw4r2ut4ListPv=0x8010ba00 List_GetNext__Q24nw4r2utFPCQ34nw4r2ut4ListPCv=0x8010bc00 +List_GetPrev__Q24nw4r2utFPCQ34nw4r2ut4ListPCv=0x8010bc20 + +# nw4r/db/db_exception +Exception_Printf___Q24nw4r2dbFPCce=0x80166a10 +ShowFloat___Q24nw4r2dbFPC9OSContext=0x80167230 # EGG/core/eggExpHeap create__Q23EGG7ExpHeapFUlPQ23EGG4HeapUs=0x801c0e58 # EGG/core/eggException -setUserCallback__Q23EGG9ExceptionFPUs=0x801cee38 +setUserCallback__Q23EGG9ExceptionFPCUs=0x801cee38 +create__Q23EGG9ExceptionFUsUsUsPQ23EGG4HeapUs=0x801ceda8 # EGG/core/eggController getNthController__Q23EGG17CoreControllerMgrFi=0x801c4ab8 sInstance__Q23EGG17CoreControllerMgr=0x806f50a8 +# EGG/core/eggDvdRipper +loadToMainRAM__Q23EGG9DvdRipperFPCcPUcPQ23EGG4HeapQ33EGG9DvdRipper15EAllocDirectionUlPUlPUl=0x801c7ce0 + # RP/RPSystem/RPSysSceneMgr sInstance__13RPSysSceneMgr=0x806f5338 # RP/RPSystem/RPSysSysMsgWinMgr -CheckInput__17RPSysSysMsgWinMgrFv=0x802355f4 -sInstance__17RPSysSysMsgWinMgr=0x806f5380 +update__17RPSysSysMsgWinMgrFv=0x802355f4 +sInstance__17RPSysSysMsgWinMgr=0x806f5370 # RP/RPSystem/RPSysSceneCreator -changeSceneAfterFade__17RPSysSceneCreatorFiPQ34nw4r2ut5Color=0x8022f074 +changeSceneAfterFade__17RPSysSceneCreatorFiQ34nw4r2ut5Color=0x8022f074 sInstance__17RPSysSceneCreator=0x806f5328 +# RP/RPSystem/RPSysPauseMgr +sInstance__13RPSysPauseMgr=0x806f5370 +update__13RPSysPauseMgrFv=0x802355f4 + +# RP/RPSystem/RPSysProjectLocal +sInstance__17RPSysProjectLocal=0x806f5340 + # Sports2/Sp2StaticMem getStaticVar__Q23Sp29StaticMemFib=0x8026a26c setStaticVar__Q23Sp29StaticMemFiib=0x8026a228 sInstance__Q23Sp29StaticMem=0x806f5538 +# Sports2/Glf/Sp2GlfMain +sInstance__Q33Sp23Glf7GlfMain=0x806f5bb0 + # Sports2/Glf/Sp2GlfConfig choosePin__Q33Sp23Glf9GlfConfigFi=0x80406a00 sInstance__Q33Sp23Glf9GlfConfig=0x806f5b38 @@ -77,5 +114,39 @@ func_802352d4__Q26caddie11Obj806f4cd0Fv=0x802355f4 # Sports2/Glf/Sp2GlfBall Stop__Q33Sp23Glf7GlfBallFb=0x80413e24 +# Sports2/Glf/RPGlfBall +Calc__9RPGlfBallFUl=0x80413e88 +sFlags__9RPGlfBall=0x806fdfbc + # Sports2/Glf/Sp2GlfBallMgr sGlfBalls__Q33Sp23Glf10GlfBallMgr=0x806f5b88 + +# Sports2/Glf/RPGlfPlayerManager +sInstance__18RPGlfPlayerManager=0x806f5b58 + +PSMTXIdentity=0x8003e730 +PSMTXScaleApply=0x8003ef40 +PSMTXTransApply=0x8003eec0 +BeginDrawSphere__Q23EGG6DrawGXFv=0x801a66c4 +DrawDLWorld__Q23EGG6DrawGXFQ33EGG6DrawGX2DLRCQ34nw4r4math5MTX348_GXColor=0x801a89d4 +sDrawPass__13RPGrpRenderer=0x806f129c +sCurrentViewID__13RPGrpRenderer=0x806f12a0 +s_cameraMtx__Q23EGG6DrawGX=0x807cd080 +SCGetAspectRatio=0x80053f40 +GetPinPos__17RPGlfFieldManagerCFv=0x80402ef8 +GetDistFromPin__9RPGlfBallCFv=0x80411d28 +IsHoleOut__9RPGlfBallCFv=0x80411e7c +IsGreenOrCupAttr__9RPGlfBallCFv=0x80411dd8 +FrSqrt__Q24nw4r4mathFf=0x8013ba50 +sInstance__17RPGlfFieldManager=0x806f5b40 +sInstance__16RPGlfClubManager=0x806f5b60 +IsHideUI__17RPGlfFieldManagerCFv=0x80403098 +spSimBall__15RPGlfSimManager=0x806f5b88 +SetBlendMode__Q23EGG6DrawGXFQ33EGG6DrawGX5Blend=0x801a8810 +DrawLineStrip__Q23EGG6DrawGXFPCQ34nw4r4math4VEC3Us8_GXColorUc=0x801a6e00 +CalcDeltaXZ__12RPGlfUtilityFRQ34nw4r4math4VEC2RCQ34nw4r4math4VEC3RCQ34nw4r4math4VEC3=0x803ede4c +CalcDeltaAngle2D__12RPGlfUtilityFRCQ34nw4r4math4VEC2RCQ34nw4r4math4VEC2=0x803edb0c +Calculate__Q33Sp23Glf11SequenceMgrFv=0x803f9c54 +sInstance__Q33Sp23Glf11SequenceMgr=0x806f5b00 +NextShot__Q33Sp23Glf12SequenceMainFv=0x803f73b0 +Enter__Q33Sp23Glf5PhaseFv=0x803f9cbc \ No newline at end of file diff --git a/include/loader/rzte.h b/include/loader/rzte.h index 3a399ed..f24ab7f 100644 --- a/include/loader/rzte.h +++ b/include/loader/rzte.h @@ -9,7 +9,7 @@ #ifdef CADDIE_REGION_NTSC_U const u32 CADDIE_ENTRYPOINT = 0x8022e2c0; #elif CADDIE_REGION_PAL -const u32 CADDIE_ENTRYPOINT = 0x80231230; +const u32 CADDIE_ENTRYPOINT = 0x8022e538; #else const u32 CADDIE_ENTRYPOINT = 0x00000000; #endif diff --git a/src/caddie/core/caddieSceneHookMgr.cpp b/src/caddie/core/caddieSceneHookMgr.cpp index a5fbee2..24ff374 100644 --- a/src/caddie/core/caddieSceneHookMgr.cpp +++ b/src/caddie/core/caddieSceneHookMgr.cpp @@ -54,7 +54,11 @@ void SceneHookMgr::DoCalculate() { hookMgr.mGlobalSceneHook.onCalculate(GetCurrentScene()); } } +#ifdef CADDIE_REGION_NTSC_U kmBranch(0x8022f8f8, SceneHookMgr::DoCalculate); +#elif CADDIE_REGION_PAL +kmBranch(0x80232c64, SceneHookMgr::DoCalculate); +#endif /** * @brief Dispatch scene hook UserDraw callback @@ -71,7 +75,11 @@ void SceneHookMgr::DoUserDraw() { hookMgr.mGlobalSceneHook.onUserDraw(GetCurrentScene()); } } +#if CADDIE_REGION_NTSC_U kmBranch(0x802542a8, SceneHookMgr::DoUserDraw); +#elif CADDIE_REGION_PAL +kmBranch(0x802545c8, SceneHookMgr::DoUserDraw); +#endif /** * @brief Dispatch scene hook Exit callback @@ -88,7 +96,11 @@ void SceneHookMgr::DoExit() { hookMgr.mGlobalSceneHook.onExit(GetCurrentScene()); } } +#ifdef CADDIE_REGION_NTSC_U kmBranch(0x8022f6f4, SceneHookMgr::DoExit); +#elif CADDIE_REGION_PAL +kmBranch(0x8022f96c, SceneHookMgr::DoExit); +#endif /** * @brief Update pause manager @@ -101,6 +113,10 @@ void SceneHookMgr::DoUpdatePause() { RPSysPauseMgr::getInstance().update(); } } +#ifdef CADDIE_REGION_NTSC_U kmCall(0x80232984, SceneHookMgr::DoUpdatePause); +#elif CADDIE_REGION_PAL +kmCall(0x80232b88, SceneHookMgr::DoUpdatePause); +#endif } // namespace caddie diff --git a/src/caddie/scene/glf/caddieGlfSceneHook.cpp b/src/caddie/scene/glf/caddieGlfSceneHook.cpp index a07b7d6..216aa25 100644 --- a/src/caddie/scene/glf/caddieGlfSceneHook.cpp +++ b/src/caddie/scene/glf/caddieGlfSceneHook.cpp @@ -92,7 +92,7 @@ void GlfSceneHook::OnCalculate(RPSysScene* scene) { MenuMgr::GetInstance().OpenMenu(sGlfMenu); } - // if game is paused, stop timer, else start it + // // if game is paused, stop timer, else start it // bool paused = Sp2::Glf::GlfMain::getInstance().getPause(); // if (paused) { // sTimer->Stop(); diff --git a/src/caddie/scene/glf/caddieGlfUtil.cpp b/src/caddie/scene/glf/caddieGlfUtil.cpp index db0a822..abe1b68 100644 --- a/src/caddie/scene/glf/caddieGlfUtil.cpp +++ b/src/caddie/scene/glf/caddieGlfUtil.cpp @@ -8,9 +8,9 @@ namespace caddie { * @brief Whether the current hole is the first hole of the gamemode */ bool GlfUtil::IsCurrentFirstHole() { - // Sp2::Glf::GlfConfig& main = Sp2::Glf::GlfConfig::getInstance(); - // return IsFirstHoleInternal(main.getGamemode(), main.getCurrentHole()); - return false; + Sp2::Glf::GlfConfig& main = Sp2::Glf::GlfConfig::getInstance(); + return IsFirstHoleInternal(main.getGamemode(), main.getCurrentHole()); + // return false; } /** @@ -58,9 +58,9 @@ bool GlfUtil::IsFirstHole(Sp2::Glf::GameMode gm, u32 hole) { * @brief Whether the current round is over (hole is past end of difficulty) */ bool GlfUtil::IsCurrentRoundOver() { - // Sp2::Glf::GlfConfig& main = Sp2::Glf::GlfConfig::getInstance(); - // return IsRoundOverInternal(main.getGamemode(), main.getCurrentHole()); - return false; + Sp2::Glf::GlfConfig& main = Sp2::Glf::GlfConfig::getInstance(); + return IsRoundOverInternal(main.getGamemode(), main.getCurrentHole()); + // return false; } /** @@ -68,9 +68,9 @@ bool GlfUtil::IsCurrentRoundOver() { * difficulty) */ bool GlfUtil::IsNextRoundOver() { - // Sp2::Glf::GlfConfig& main = Sp2::Glf::GlfConfig::getInstance(); - // return IsRoundOverInternal(main.getGamemode(), main.getCurrentHole() + 1); - return false; + Sp2::Glf::GlfConfig& main = Sp2::Glf::GlfConfig::getInstance(); + return IsRoundOverInternal(main.getGamemode(), main.getCurrentHole() + 1); + // return false; } /** @@ -127,25 +127,25 @@ u32 GlfUtil::GetGamemodeNthHoleInternal(u32 n) { * @details Hole is one-indexed */ u32 GlfUtil::GetGamemodeNthHole(u32 n) { - // switch (Sp2::Glf::GlfConfig::getInstance().getGamemode()) { - // case Sp2::Glf::GM_EIGHTEEN_HOLE: - // case Sp2::Glf::GM_RESORT_NINE: - // case Sp2::Glf::GM_RESORT_A: - // return 1 + n; - // case Sp2::Glf::GM_RESORT_B: - // return 4 + n; - // case Sp2::Glf::GM_RESORT_C: - // return 7 + n; - // case Sp2::Glf::GM_CLASSIC_NINE: - // case Sp2::Glf::GM_CLASSIC_A: - // return 10 + n; - // case Sp2::Glf::GM_CLASSIC_B: - // return 13 + n; - // case Sp2::Glf::GM_CLASSIC_C: - // return 16 + n; - // case Sp2::Glf::GM_SPECIAL: - // return 19 + n; - // } + switch (Sp2::Glf::GlfConfig::getInstance().getGamemode()) { + case Sp2::Glf::GM_EIGHTEEN_HOLE: + case Sp2::Glf::GM_RESORT_NINE: + case Sp2::Glf::GM_RESORT_A: + return 1 + n; + case Sp2::Glf::GM_RESORT_B: + return 4 + n; + case Sp2::Glf::GM_RESORT_C: + return 7 + n; + case Sp2::Glf::GM_CLASSIC_NINE: + case Sp2::Glf::GM_CLASSIC_A: + return 10 + n; + case Sp2::Glf::GM_CLASSIC_B: + return 13 + n; + case Sp2::Glf::GM_CLASSIC_C: + return 16 + n; + case Sp2::Glf::GM_SPECIAL: + return 19 + n; + } return 1+n; } diff --git a/src/main.cpp b/src/main.cpp index 378fa68..8feb6a6 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -51,6 +51,12 @@ void main() { SceneHookMgr::GetInstance().AllowPause(RPSysSceneCreator::SCENE_DGL, false); } +#ifdef CADDIE_REGION_NTSC_U kmBranch(0x80230b60, main); +#elif CADDIE_REGION_PAL +kmBranch(0x80230e2c, main); +#else +#error "No region defined!" +#endif } // namespace caddie From a9412ac505933812240549244a92b2ad8d84de90 Mon Sep 17 00:00:00 2001 From: vincenzo-sorcigli <57498723+vincenzo-sorcigli@users.noreply.github.com> Date: Wed, 7 Jan 2026 14:57:43 -0500 Subject: [PATCH 12/17] golf+fg supported in same build --- src/caddie/scene/glf/caddieGlfSceneHook.cpp | 46 +++++++++++++++++---- 1 file changed, 38 insertions(+), 8 deletions(-) diff --git a/src/caddie/scene/glf/caddieGlfSceneHook.cpp b/src/caddie/scene/glf/caddieGlfSceneHook.cpp index 702a1d9..c52ddff 100644 --- a/src/caddie/scene/glf/caddieGlfSceneHook.cpp +++ b/src/caddie/scene/glf/caddieGlfSceneHook.cpp @@ -6,6 +6,9 @@ #include "caddieInputMgr.h" #include "caddieMenuMgr.h" +#include "types_rp.h" +#include +#include #include #include #include @@ -86,19 +89,29 @@ void GlfSceneHook::OnConfigure(RPSysScene* scene) { */ void GlfSceneHook::OnCalculate(RPSysScene* scene) { bool isMenuOpen = MenuMgr::GetInstance().IsVisible(); - Sp2::Glf::GlfMain::getInstance().setPause(isMenuOpen); + + // pause game if menu is open + // only in glf scene for now + if (RPSysSceneMgr::getInstance().getCurrentSceneID() == + RPSysSceneCreator::SCENE_GLF) { + Sp2::Glf::GlfMain::getInstance().setPause(isMenuOpen); + } if (MenuMgr::GetInstance().GetMenu() == NULL) { MenuMgr::GetInstance().OpenMenu(sGlfMenu); } // if game is paused, stop timer, else start it - bool paused = Sp2::Glf::GlfMain::getInstance().getPause(); - if (paused) { - sTimer->Stop(); - } - else { - sTimer->Start(); + // only in glf scene for now + if (RPSysSceneMgr::getInstance().getCurrentSceneID() == + RPSysSceneCreator::SCENE_GLF) { + bool paused = Sp2::Glf::GlfMain::getInstance().getPause(); + if (paused) { + sTimer->Stop(); + } + else { + sTimer->Start(); + } } // change the timer @@ -153,6 +166,9 @@ void GlfSceneHook::OnUserDraw(RPSysScene* scene) { char buffer[1024]; // Current pin display + // only show in glf scene + if (RPSysSceneMgr::getInstance().getCurrentSceneID() == + RPSysSceneCreator::SCENE_GLF) { u32 hole = Sp2::Glf::GlfConfig::getInstance().getCurrentHole(); u32 pin = Sp2::Glf::GlfConfig::getInstance().getPin(); @@ -502,8 +518,22 @@ void GlfSceneHook::Apply_Wind() { dir = Sp2::Rand(Sp2::Glf::MAX_WIND_DIV); } + // golf and FG have different static mem indices for wind + // determine which index to use, then set wind for the current hole + int windStaticMemIdx; + switch (RPSysSceneMgr::getInstance().getCurrentSceneID()) { + case RPSysSceneCreator::SCENE_GLF: + windStaticMemIdx = Sp2::Glf::VAR_WIND; + break; + case RPSysSceneCreator::SCENE_DGL: + windStaticMemIdx = 9; + break; + default: + CADDIE_ASSERT(false); + return; + } Sp2::StaticMem::getInstance().setStaticVar( - 9 + GetMenu().GetHoleInternal(), + windStaticMemIdx + GetMenu().GetHoleInternal(), Sp2::Glf::PackWind(dir, spd), false); } From 8058d96f103aa176fcb8608d66bdb802c64625f4 Mon Sep 17 00:00:00 2001 From: vincenzo-sorcigli <57498723+vincenzo-sorcigli@users.noreply.github.com> Date: Wed, 7 Jan 2026 17:01:05 -0500 Subject: [PATCH 13/17] more pal support --- externals/PAL.txt | 18 +----- src/caddie/core/caddieSceneHookMgr.cpp | 9 +++ src/caddie/kernel/caddieException.cpp | 4 ++ src/caddie/scene/cmn/caddieCmnPatches.cpp | 5 ++ src/caddie/scene/glf/caddieGlfSceneHook.cpp | 61 +++++++++++++++++++++ 5 files changed, 82 insertions(+), 15 deletions(-) diff --git a/externals/PAL.txt b/externals/PAL.txt index e34ce8a..a11786c 100644 --- a/externals/PAL.txt +++ b/externals/PAL.txt @@ -74,10 +74,6 @@ loadToMainRAM__Q23EGG9DvdRipperFPCcPUcPQ23EGG4HeapQ33EGG9DvdRipper15EAllocDirect # RP/RPSystem/RPSysSceneMgr sInstance__13RPSysSceneMgr=0x806f5338 -# RP/RPSystem/RPSysSysMsgWinMgr -update__17RPSysSysMsgWinMgrFv=0x802355f4 -sInstance__17RPSysSysMsgWinMgr=0x806f5370 - # RP/RPSystem/RPSysSceneCreator changeSceneAfterFade__17RPSysSceneCreatorFiQ34nw4r2ut5Color=0x8022f074 sInstance__17RPSysSceneCreator=0x806f5328 @@ -86,6 +82,7 @@ sInstance__17RPSysSceneCreator=0x806f5328 sInstance__13RPSysPauseMgr=0x806f5370 update__13RPSysPauseMgrFv=0x802355f4 + # RP/RPSystem/RPSysProjectLocal sInstance__17RPSysProjectLocal=0x806f5340 @@ -107,23 +104,14 @@ __dt__Q33Sp23Glf9GlfConfigFv=0x80406f30 Rand__3Sp2Fv=0x8025ccd0 Print__3Sp2FPCcUlbfff=0x803733b8 -# Sports2/Obj806f4cd0 -sInstance__Q26caddie11Obj806f4cd0=0x806f5370 -func_802352d4__Q26caddie11Obj806f4cd0Fv=0x802355f4 - -# Sports2/Glf/Sp2GlfBall -Stop__Q33Sp23Glf7GlfBallFb=0x80413e24 - # Sports2/Glf/RPGlfBall Calc__9RPGlfBallFUl=0x80413e88 sFlags__9RPGlfBall=0x806fdfbc -# Sports2/Glf/Sp2GlfBallMgr -sGlfBalls__Q33Sp23Glf10GlfBallMgr=0x806f5b88 - # Sports2/Glf/RPGlfPlayerManager sInstance__18RPGlfPlayerManager=0x806f5b58 + PSMTXIdentity=0x8003e730 PSMTXScaleApply=0x8003ef40 PSMTXTransApply=0x8003eec0 @@ -149,4 +137,4 @@ CalcDeltaAngle2D__12RPGlfUtilityFRCQ34nw4r4math4VEC2RCQ34nw4r4math4VEC2=0x803edb Calculate__Q33Sp23Glf11SequenceMgrFv=0x803f9c54 sInstance__Q33Sp23Glf11SequenceMgr=0x806f5b00 NextShot__Q33Sp23Glf12SequenceMainFv=0x803f73b0 -Enter__Q33Sp23Glf5PhaseFv=0x803f9cbc \ No newline at end of file +Enter__Q33Sp23Glf5PhaseFv=0x803f9cbc diff --git a/src/caddie/core/caddieSceneHookMgr.cpp b/src/caddie/core/caddieSceneHookMgr.cpp index 24ff374..9584e64 100644 --- a/src/caddie/core/caddieSceneHookMgr.cpp +++ b/src/caddie/core/caddieSceneHookMgr.cpp @@ -26,6 +26,7 @@ RPSysScene* GetCurrentScene() { * @brief Dispatch scene hook Configure callback */ void SceneHookMgr::DoConfigure() { + OSReport("SceneHookMgr::DoConfigure called\n"); const s32 scene = GetCurrentSceneID(); const SceneHookMgr& hookMgr = SceneHookMgr::GetInstance(); @@ -43,6 +44,8 @@ kmBranch(0x801c389c, SceneHookMgr::DoConfigure); * @brief Dispatch scene hook Calculate callback */ void SceneHookMgr::DoCalculate() { + OSReport("SceneHookMgr::DoCalculate called\n"); + const s32 scene = GetCurrentSceneID(); const SceneHookMgr& hookMgr = SceneHookMgr::GetInstance(); @@ -64,6 +67,8 @@ kmBranch(0x80232c64, SceneHookMgr::DoCalculate); * @brief Dispatch scene hook UserDraw callback */ void SceneHookMgr::DoUserDraw() { + OSReport("SceneHookMgr::DoUserDraw called\n"); + const s32 scene = GetCurrentSceneID(); const SceneHookMgr& hookMgr = SceneHookMgr::GetInstance(); @@ -85,6 +90,8 @@ kmBranch(0x802545c8, SceneHookMgr::DoUserDraw); * @brief Dispatch scene hook Exit callback */ void SceneHookMgr::DoExit() { + OSReport("SceneHookMgr::DoExit called\n"); + const s32 scene = GetCurrentSceneID(); const SceneHookMgr& hookMgr = SceneHookMgr::GetInstance(); @@ -106,6 +113,8 @@ kmBranch(0x8022f96c, SceneHookMgr::DoExit); * @brief Update pause manager */ void SceneHookMgr::DoUpdatePause() { + OSReport("SceneHookMgr::DoUpdatePause called\n"); + const s32 scene = GetCurrentSceneID(); const SceneHookMgr& hookMgr = SceneHookMgr::GetInstance(); diff --git a/src/caddie/kernel/caddieException.cpp b/src/caddie/kernel/caddieException.cpp index 33f1e74..4184e4f 100644 --- a/src/caddie/kernel/caddieException.cpp +++ b/src/caddie/kernel/caddieException.cpp @@ -18,7 +18,11 @@ namespace caddie { void Exception::InitConsole() { EGG::Exception::create(128, sConsoleMaxLines, 4, NULL, 1); } +#if CADDIE_REGION_NTSC_U kmCall(0x8022e2d4, Exception::InitConsole); +#elif CADDIE_REGION_PAL +kmCall(0x8022e54c, Exception::InitConsole); +#endif /** * @brief Resolves address to a map symbol, and prints it to the exception diff --git a/src/caddie/scene/cmn/caddieCmnPatches.cpp b/src/caddie/scene/cmn/caddieCmnPatches.cpp index 9cfb3d0..0d47bc0 100644 --- a/src/caddie/scene/cmn/caddieCmnPatches.cpp +++ b/src/caddie/scene/cmn/caddieCmnPatches.cpp @@ -7,7 +7,12 @@ namespace { * @brief Remove AB check */ bool IsABCheckAll() { return true; } + +#if CADDIE_REGION_NTSC_U kmBranch(0x8026a298, IsABCheckAll); +#elif CADDIE_REGION_PAL +kmBranch(0x8026a5b8, IsABCheckAll); +#endif } // namespace } // namespace caddie diff --git a/src/caddie/scene/glf/caddieGlfSceneHook.cpp b/src/caddie/scene/glf/caddieGlfSceneHook.cpp index c52ddff..3b42389 100644 --- a/src/caddie/scene/glf/caddieGlfSceneHook.cpp +++ b/src/caddie/scene/glf/caddieGlfSceneHook.cpp @@ -45,8 +45,13 @@ // Convert yards to world units. #define YD(X) ((f32)(X) * 10.0f / 1.094f) +#if CADDIE_REGION_NTSC_U kmWrite32(0x803f8778, 0x60000000); kmWrite32(0x803f878c, 0x60000000); +#elif CADDIE_REGION_PAL +kmWrite32(0x803f8a98, 0x60000000); +kmWrite32(0x803f8aac, 0x60000000); +#endif namespace caddie { @@ -127,11 +132,17 @@ void GlfSceneHook::OnPausedSeqMgrCalc() { Sp2::Glf::SequenceMgr::getInstance().Calculate(); } + +#if CADDIE_REGION_NTSC_U kmCall(0x804175e8, GlfSceneHook::OnPausedSeqMgrCalc); +#elif CADDIE_REGION_PAL +kmCall(0x80417908, GlfSceneHook::OnPausedSeqMgrCalc); +#endif void GlfSceneHook::OnNextShot() { sTimer->Freeze(90); + OSReport("GetMenu at line %d\n", __LINE__); if (sDidStopShot || !GetMenu().GetRetryShotMenu()) { Sp2::Glf::SequenceMgr::getInstance().GetSequenceMain()->NextShot(); GlfPostMenu::ChangePhase(); @@ -148,7 +159,12 @@ void GlfSceneHook::OnNextShot() { MenuMgr::GetInstance().OpenMenu(sGlfPostMenu); MenuMgr::GetInstance().SetVisible(true); } + +#if CADDIE_REGION_NTSC_U kmCall(0x803f8754, GlfSceneHook::OnNextShot); +#elif CADDIE_REGION_PAL +kmCall(0x803f8a74, GlfSceneHook::OnNextShot); +#endif void GlfSceneHook::OnUserDraw(RPSysScene* scene) { if (sTimer != NULL) { @@ -252,6 +268,7 @@ void GlfSceneHook::DrawPutterGuide(const nw4r::math::VEC3* pPoints, u16 num, color.b = 0; } + OSReport("GetMenu at line %d\n", __LINE__); if (!GetMenu().GetReplayInfo()) { color.r = 32; color.g = 64; @@ -261,7 +278,12 @@ void GlfSceneHook::DrawPutterGuide(const nw4r::math::VEC3* pPoints, u16 num, EGG::DrawGX::DrawLineStrip(pPoints, num, color, width); } } + +#if CADDIE_REGION_NTSC_U kmCall(0x803fab74, GlfSceneHook::DrawPutterGuide); +#elif CADDIE_REGION_PAL +kmCall(0x803fae94, GlfSceneHook::DrawPutterGuide); +#endif void GlfSceneHook::DrawReplaySphere() { if (RPGrpRenderer::GetDrawPass() != RPGrpRenderer::EDrawPass_DrawXLU) { @@ -276,6 +298,7 @@ void GlfSceneHook::DrawReplaySphere() { return; } + OSReport("GetMenu at line %d\n", __LINE__); if (!GetMenu().GetReplayInfo()) { return; } @@ -354,7 +377,12 @@ void GlfSceneHook::DrawReplaySphere() { } EGG::DrawGX::s_cameraMtx = old; } + +#if CADDIE_REGION_NTSC_U kmBranch(0x80404b10, GlfSceneHook::DrawReplaySphere); +#elif CADDIE_REGION_PAL +kmBranch(0x80404e30, GlfSceneHook::DrawReplaySphere); +#endif /** * @brief Golf scene exit callback @@ -363,6 +391,7 @@ kmBranch(0x80404b10, GlfSceneHook::DrawReplaySphere); */ void GlfSceneHook::OnExit(RPSysScene* scene) { // Do not delete menu if settings are waiting to be applied + OSReport("GetMenu at line %d\n", __LINE__); if (GetMenu().CanDelete()) { delete sGlfMenu; sGlfMenu = NULL; @@ -382,6 +411,7 @@ void GlfSceneHook::OnExit(RPSysScene* scene) { */ void GlfSceneHook::Apply_Hole() { // Update hole + OSReport("GetMenu at line %d\n", __LINE__); Sp2::StaticMem::getInstance().setStaticVar( Sp2::Glf::VAR_NEXTHOLE, GetMenu().GetHoleInternal(), false); } @@ -392,6 +422,7 @@ void GlfSceneHook::Apply_Hole() { void GlfSceneHook::Apply_RepeatHole() { Sp2::StaticMem& mem = Sp2::StaticMem::getInstance(); + OSReport("GetMenu at line %d\n", __LINE__); if (GetMenu().GetRepeatHole()) { const int nextHole = mem.getStaticVar(Sp2::Glf::VAR_NEXTHOLE, false); mem.setStaticVar(Sp2::Glf::VAR_NEXTHOLE, nextHole - 1, false); @@ -405,10 +436,12 @@ void GlfSceneHook::Apply_Pin() { Sp2::Glf::GlfConfig& main = Sp2::Glf::GlfConfig::getInstance(); // Next pin type + OSReport("GetMenu at line %d\n", __LINE__); int pin = GetMenu().GetPinType(); // Next hole to be played determines how to interpret pin value int nextHole = 0; + OSReport("GetMenu at line %d\n", __LINE__); if (GetMenu().GetRepeatHole()) { // Value is internal hole num (zero indexed) nextHole = main.getCurrentHole() + 1; @@ -476,6 +509,7 @@ void GlfSceneHook::Apply_Pin() { * @brief Apply wind settings from menu */ void GlfSceneHook::Apply_Wind() { + OSReport("GetMenu at line %d\n", __LINE__); int spd = GetMenu().GetWindSpd(); int dir = GetMenu().GetWindDir(); @@ -485,6 +519,7 @@ void GlfSceneHook::Apply_Wind() { int min = 0; int max = Sp2::Glf::WIND_MAX; + OSReport("GetMenu at line %d\n", __LINE__); switch (GetMenu().GetWindSpdRange()) { // 0-10 m/s (0-20 mph) case RANGE_0_10: @@ -518,6 +553,7 @@ void GlfSceneHook::Apply_Wind() { dir = Sp2::Rand(Sp2::Glf::MAX_WIND_DIV); } + OSReport("GetMenu at line %d\n", __LINE__); // golf and FG have different static mem indices for wind // determine which index to use, then set wind for the current hole int windStaticMemIdx; @@ -544,6 +580,7 @@ void GlfSceneHook::Apply_StaticMem() { Apply_Wind(); // Hole option should not automatically be applied + OSReport("GetMenu at line %d\n", __LINE__); if (GetMenu().IsAwaitingApply()) { Apply_Hole(); GetMenu().SetAwaitingApply(false); @@ -557,7 +594,12 @@ void GlfSceneHook::Apply_GlfConfig() { Apply_RepeatHole(); Apply_Pin(); } + +#if CADDIE_REGION_NTSC_U kmBranch(0x8040680c, GlfSceneHook::Apply_GlfConfig); +#elif CADDIE_REGION_PAL +kmBranch(0x80406b2c, GlfSceneHook::Apply_GlfConfig); +#endif /** * @brief Allow shot to be canceled by holding B + MINUS + 2 @@ -592,22 +634,37 @@ void GlfSceneHook::OnGlfBallCalc(RPGlfBall* ball, u32 frame, u32) { ball->Calc(frame); } + +#if CADDIE_REGION_NTSC_U kmCall(0x80414754, GlfSceneHook::OnGlfBallCalc); +#elif CADDIE_REGION_PAL +kmCall(0x80414a74, GlfSceneHook::OnGlfBallCalc); +#endif /** * @brief Disable Golf tutorial */ bool GlfSceneHook::ShouldShowTutorial() { return false; } + +#if CADDIE_REGION_NTSC_U kmBranch(0x803fa370, GlfSceneHook::ShouldShowTutorial); +#elif CADDIE_REGION_PAL +kmBranch(0x803fa574, GlfSceneHook::ShouldShowTutorial); +#endif /** * @brief Check whether the next hole can be played * @note Repeat Hole option prevents game from ending */ bool GlfSceneHook::CanPlayNextHole() { + OSReport("GetMenu at line %d\n", __LINE__); return GetMenu().GetRepeatHole() ? true : !GlfUtil::IsNextRoundOver(); } +#if CADDIE_REGION_NTSC_U kmBranch(0x80406554, GlfSceneHook::CanPlayNextHole); +#elif CADDIE_REGION_PAL +kmBranch(0x80406874, GlfSceneHook::CanPlayNextHole); +#endif /** * @brief Number of holes played in the match @@ -629,7 +686,11 @@ u32 GlfSceneHook::GetNumHolesPlayed() { // Vanilla behavior return gmCurrent - gmFirst; } +#if CADDIE_REGION_NTSC_U kmBranch(0x80405f1c, GlfSceneHook::GetNumHolesPlayed); +#elif CADDIE_REGION_PAL +kmBranch(0x8040623c, GlfSceneHook::GetNumHolesPlayed); +#endif /** * @brief Access golf menu From 9aac3f37526e6f50c0adf13f670a552c1d41313d Mon Sep 17 00:00:00 2001 From: vincenzo-sorcigli <57498723+vincenzo-sorcigli@users.noreply.github.com> Date: Wed, 7 Jan 2026 17:49:39 -0500 Subject: [PATCH 14/17] fix incorrect address + remove debug prints --- src/caddie/core/caddieSceneHookMgr.cpp | 11 +---------- src/caddie/scene/glf/caddieGlfSceneHook.cpp | 15 +-------------- 2 files changed, 2 insertions(+), 24 deletions(-) diff --git a/src/caddie/core/caddieSceneHookMgr.cpp b/src/caddie/core/caddieSceneHookMgr.cpp index 9584e64..1170ff9 100644 --- a/src/caddie/core/caddieSceneHookMgr.cpp +++ b/src/caddie/core/caddieSceneHookMgr.cpp @@ -26,7 +26,6 @@ RPSysScene* GetCurrentScene() { * @brief Dispatch scene hook Configure callback */ void SceneHookMgr::DoConfigure() { - OSReport("SceneHookMgr::DoConfigure called\n"); const s32 scene = GetCurrentSceneID(); const SceneHookMgr& hookMgr = SceneHookMgr::GetInstance(); @@ -44,8 +43,6 @@ kmBranch(0x801c389c, SceneHookMgr::DoConfigure); * @brief Dispatch scene hook Calculate callback */ void SceneHookMgr::DoCalculate() { - OSReport("SceneHookMgr::DoCalculate called\n"); - const s32 scene = GetCurrentSceneID(); const SceneHookMgr& hookMgr = SceneHookMgr::GetInstance(); @@ -67,8 +64,6 @@ kmBranch(0x80232c64, SceneHookMgr::DoCalculate); * @brief Dispatch scene hook UserDraw callback */ void SceneHookMgr::DoUserDraw() { - OSReport("SceneHookMgr::DoUserDraw called\n"); - const s32 scene = GetCurrentSceneID(); const SceneHookMgr& hookMgr = SceneHookMgr::GetInstance(); @@ -90,8 +85,6 @@ kmBranch(0x802545c8, SceneHookMgr::DoUserDraw); * @brief Dispatch scene hook Exit callback */ void SceneHookMgr::DoExit() { - OSReport("SceneHookMgr::DoExit called\n"); - const s32 scene = GetCurrentSceneID(); const SceneHookMgr& hookMgr = SceneHookMgr::GetInstance(); @@ -113,8 +106,6 @@ kmBranch(0x8022f96c, SceneHookMgr::DoExit); * @brief Update pause manager */ void SceneHookMgr::DoUpdatePause() { - OSReport("SceneHookMgr::DoUpdatePause called\n"); - const s32 scene = GetCurrentSceneID(); const SceneHookMgr& hookMgr = SceneHookMgr::GetInstance(); @@ -125,7 +116,7 @@ void SceneHookMgr::DoUpdatePause() { #ifdef CADDIE_REGION_NTSC_U kmCall(0x80232984, SceneHookMgr::DoUpdatePause); #elif CADDIE_REGION_PAL -kmCall(0x80232b88, SceneHookMgr::DoUpdatePause); +kmCall(0x80232c50, SceneHookMgr::DoUpdatePause); #endif } // namespace caddie diff --git a/src/caddie/scene/glf/caddieGlfSceneHook.cpp b/src/caddie/scene/glf/caddieGlfSceneHook.cpp index 3b42389..8fecc67 100644 --- a/src/caddie/scene/glf/caddieGlfSceneHook.cpp +++ b/src/caddie/scene/glf/caddieGlfSceneHook.cpp @@ -142,7 +142,6 @@ kmCall(0x80417908, GlfSceneHook::OnPausedSeqMgrCalc); void GlfSceneHook::OnNextShot() { sTimer->Freeze(90); - OSReport("GetMenu at line %d\n", __LINE__); if (sDidStopShot || !GetMenu().GetRetryShotMenu()) { Sp2::Glf::SequenceMgr::getInstance().GetSequenceMain()->NextShot(); GlfPostMenu::ChangePhase(); @@ -268,7 +267,6 @@ void GlfSceneHook::DrawPutterGuide(const nw4r::math::VEC3* pPoints, u16 num, color.b = 0; } - OSReport("GetMenu at line %d\n", __LINE__); if (!GetMenu().GetReplayInfo()) { color.r = 32; color.g = 64; @@ -298,7 +296,6 @@ void GlfSceneHook::DrawReplaySphere() { return; } - OSReport("GetMenu at line %d\n", __LINE__); if (!GetMenu().GetReplayInfo()) { return; } @@ -391,7 +388,6 @@ kmBranch(0x80404e30, GlfSceneHook::DrawReplaySphere); */ void GlfSceneHook::OnExit(RPSysScene* scene) { // Do not delete menu if settings are waiting to be applied - OSReport("GetMenu at line %d\n", __LINE__); if (GetMenu().CanDelete()) { delete sGlfMenu; sGlfMenu = NULL; @@ -411,7 +407,6 @@ void GlfSceneHook::OnExit(RPSysScene* scene) { */ void GlfSceneHook::Apply_Hole() { // Update hole - OSReport("GetMenu at line %d\n", __LINE__); Sp2::StaticMem::getInstance().setStaticVar( Sp2::Glf::VAR_NEXTHOLE, GetMenu().GetHoleInternal(), false); } @@ -422,7 +417,6 @@ void GlfSceneHook::Apply_Hole() { void GlfSceneHook::Apply_RepeatHole() { Sp2::StaticMem& mem = Sp2::StaticMem::getInstance(); - OSReport("GetMenu at line %d\n", __LINE__); if (GetMenu().GetRepeatHole()) { const int nextHole = mem.getStaticVar(Sp2::Glf::VAR_NEXTHOLE, false); mem.setStaticVar(Sp2::Glf::VAR_NEXTHOLE, nextHole - 1, false); @@ -436,12 +430,10 @@ void GlfSceneHook::Apply_Pin() { Sp2::Glf::GlfConfig& main = Sp2::Glf::GlfConfig::getInstance(); // Next pin type - OSReport("GetMenu at line %d\n", __LINE__); int pin = GetMenu().GetPinType(); // Next hole to be played determines how to interpret pin value int nextHole = 0; - OSReport("GetMenu at line %d\n", __LINE__); if (GetMenu().GetRepeatHole()) { // Value is internal hole num (zero indexed) nextHole = main.getCurrentHole() + 1; @@ -509,7 +501,6 @@ void GlfSceneHook::Apply_Pin() { * @brief Apply wind settings from menu */ void GlfSceneHook::Apply_Wind() { - OSReport("GetMenu at line %d\n", __LINE__); int spd = GetMenu().GetWindSpd(); int dir = GetMenu().GetWindDir(); @@ -519,8 +510,7 @@ void GlfSceneHook::Apply_Wind() { int min = 0; int max = Sp2::Glf::WIND_MAX; - OSReport("GetMenu at line %d\n", __LINE__); - switch (GetMenu().GetWindSpdRange()) { + switch (GetMenu().GetWindSpdRange()) { // 0-10 m/s (0-20 mph) case RANGE_0_10: max = 10; @@ -553,7 +543,6 @@ void GlfSceneHook::Apply_Wind() { dir = Sp2::Rand(Sp2::Glf::MAX_WIND_DIV); } - OSReport("GetMenu at line %d\n", __LINE__); // golf and FG have different static mem indices for wind // determine which index to use, then set wind for the current hole int windStaticMemIdx; @@ -580,7 +569,6 @@ void GlfSceneHook::Apply_StaticMem() { Apply_Wind(); // Hole option should not automatically be applied - OSReport("GetMenu at line %d\n", __LINE__); if (GetMenu().IsAwaitingApply()) { Apply_Hole(); GetMenu().SetAwaitingApply(false); @@ -657,7 +645,6 @@ kmBranch(0x803fa574, GlfSceneHook::ShouldShowTutorial); * @note Repeat Hole option prevents game from ending */ bool GlfSceneHook::CanPlayNextHole() { - OSReport("GetMenu at line %d\n", __LINE__); return GetMenu().GetRepeatHole() ? true : !GlfUtil::IsNextRoundOver(); } #if CADDIE_REGION_NTSC_U From 9910514514b67bde21ba4a3107be6b5fc264c355 Mon Sep 17 00:00:00 2001 From: Vincenzo Date: Mon, 19 Jan 2026 22:44:27 -0500 Subject: [PATCH 15/17] changes from review --- externals/NTSC_U.txt | 4 ++++ externals/PAL.txt | 6 +++++- src/caddie/scene/glf/caddieGlfSceneHook.cpp | 12 ++++-------- src/caddie/scene/glf/caddieGlfUtil.cpp | 3 --- src/caddie/ui/menu/caddieMenuMgr.cpp | 5 +++++ src/main.cpp | 9 ++++++--- 6 files changed, 24 insertions(+), 15 deletions(-) diff --git a/externals/NTSC_U.txt b/externals/NTSC_U.txt index 2ee2bc9..ae92094 100644 --- a/externals/NTSC_U.txt +++ b/externals/NTSC_U.txt @@ -74,6 +74,10 @@ loadToMainRAM__Q23EGG9DvdRipperFPCcPUcPQ23EGG4HeapQ33EGG9DvdRipper15EAllocDirect # RP/RPSystem/RPSysSceneMgr sInstance__13RPSysSceneMgr=0x806f4c98 +# RP/RPSystem/RPSysSysMsgWinMgr +update__17RPSysSysMsgWinMgrFv=0x802352d4 +sInstance__17RPSysSysMsgWinMgr=0x806f4ce0 + # RP/RPSystem/RPSysSceneCreator changeSceneAfterFade__17RPSysSceneCreatorFiQ34nw4r2ut5Color=0x8022edfc sInstance__17RPSysSceneCreator=0x806f4c88 diff --git a/externals/PAL.txt b/externals/PAL.txt index a11786c..aeccb5a 100644 --- a/externals/PAL.txt +++ b/externals/PAL.txt @@ -74,6 +74,10 @@ loadToMainRAM__Q23EGG9DvdRipperFPCcPUcPQ23EGG4HeapQ33EGG9DvdRipper15EAllocDirect # RP/RPSystem/RPSysSceneMgr sInstance__13RPSysSceneMgr=0x806f5338 +# RP/RPSystem/RPSysSysMsgWinMgr +CheckInput__17RPSysSysMsgWinMgrFv=0x802355f4 +sInstance__17RPSysSysMsgWinMgr=0x806f5380 + # RP/RPSystem/RPSysSceneCreator changeSceneAfterFade__17RPSysSceneCreatorFiQ34nw4r2ut5Color=0x8022f074 sInstance__17RPSysSceneCreator=0x806f5328 @@ -109,7 +113,7 @@ Calc__9RPGlfBallFUl=0x80413e88 sFlags__9RPGlfBall=0x806fdfbc # Sports2/Glf/RPGlfPlayerManager -sInstance__18RPGlfPlayerManager=0x806f5b58 +sInstance__18RPGlfPlayerManager=0x806f5b08 PSMTXIdentity=0x8003e730 diff --git a/src/caddie/scene/glf/caddieGlfSceneHook.cpp b/src/caddie/scene/glf/caddieGlfSceneHook.cpp index 8fecc67..19e6ae4 100644 --- a/src/caddie/scene/glf/caddieGlfSceneHook.cpp +++ b/src/caddie/scene/glf/caddieGlfSceneHook.cpp @@ -6,7 +6,6 @@ #include "caddieInputMgr.h" #include "caddieMenuMgr.h" -#include "types_rp.h" #include #include #include @@ -97,8 +96,7 @@ void GlfSceneHook::OnCalculate(RPSysScene* scene) { // pause game if menu is open // only in glf scene for now - if (RPSysSceneMgr::getInstance().getCurrentSceneID() == - RPSysSceneCreator::SCENE_GLF) { + if (scene->getSceneID() == RPSysSceneCreator::SCENE_GLF) { Sp2::Glf::GlfMain::getInstance().setPause(isMenuOpen); } @@ -108,8 +106,7 @@ void GlfSceneHook::OnCalculate(RPSysScene* scene) { // if game is paused, stop timer, else start it // only in glf scene for now - if (RPSysSceneMgr::getInstance().getCurrentSceneID() == - RPSysSceneCreator::SCENE_GLF) { + if (scene->getSceneID() == RPSysSceneCreator::SCENE_GLF) { bool paused = Sp2::Glf::GlfMain::getInstance().getPause(); if (paused) { sTimer->Stop(); @@ -182,8 +179,7 @@ void GlfSceneHook::OnUserDraw(RPSysScene* scene) { // Current pin display // only show in glf scene - if (RPSysSceneMgr::getInstance().getCurrentSceneID() == - RPSysSceneCreator::SCENE_GLF) + if (scene->getSceneID() == RPSysSceneCreator::SCENE_GLF) { u32 hole = Sp2::Glf::GlfConfig::getInstance().getCurrentHole(); u32 pin = Sp2::Glf::GlfConfig::getInstance().getPin(); @@ -510,7 +506,7 @@ void GlfSceneHook::Apply_Wind() { int min = 0; int max = Sp2::Glf::WIND_MAX; - switch (GetMenu().GetWindSpdRange()) { + switch (GetMenu().GetWindSpdRange()) { // 0-10 m/s (0-20 mph) case RANGE_0_10: max = 10; diff --git a/src/caddie/scene/glf/caddieGlfUtil.cpp b/src/caddie/scene/glf/caddieGlfUtil.cpp index abe1b68..a209276 100644 --- a/src/caddie/scene/glf/caddieGlfUtil.cpp +++ b/src/caddie/scene/glf/caddieGlfUtil.cpp @@ -10,7 +10,6 @@ namespace caddie { bool GlfUtil::IsCurrentFirstHole() { Sp2::Glf::GlfConfig& main = Sp2::Glf::GlfConfig::getInstance(); return IsFirstHoleInternal(main.getGamemode(), main.getCurrentHole()); - // return false; } /** @@ -60,7 +59,6 @@ bool GlfUtil::IsFirstHole(Sp2::Glf::GameMode gm, u32 hole) { bool GlfUtil::IsCurrentRoundOver() { Sp2::Glf::GlfConfig& main = Sp2::Glf::GlfConfig::getInstance(); return IsRoundOverInternal(main.getGamemode(), main.getCurrentHole()); - // return false; } /** @@ -70,7 +68,6 @@ bool GlfUtil::IsCurrentRoundOver() { bool GlfUtil::IsNextRoundOver() { Sp2::Glf::GlfConfig& main = Sp2::Glf::GlfConfig::getInstance(); return IsRoundOverInternal(main.getGamemode(), main.getCurrentHole() + 1); - // return false; } /** diff --git a/src/caddie/ui/menu/caddieMenuMgr.cpp b/src/caddie/ui/menu/caddieMenuMgr.cpp index d015321..4569ef3 100644 --- a/src/caddie/ui/menu/caddieMenuMgr.cpp +++ b/src/caddie/ui/menu/caddieMenuMgr.cpp @@ -14,6 +14,11 @@ namespace caddie { * @brief Menu logic */ void MenuMgr::Calc() { + + if (mMenu == NULL || mOpenPage == NULL) { + return; + } + CalcInput(); // All players can control the menu diff --git a/src/main.cpp b/src/main.cpp index 8feb6a6..aa94a3a 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -22,9 +22,12 @@ void main() { static const u16 scEmptyCombo[] = {0}; EGG::Exception::setUserCallback(scEmptyCombo); - // Open symbol map - MapFile::GetInstance().LoadFromDVD("modules/main_NTSC_U.map", - MapFile::LINK_DYNAMIC); +#ifdef CADDIE_REGION_NTSC_U + MapFile::GetInstance().LoadFromDVD("modules/main_NTSC_U.map", + MapFile::LINK_DYNAMIC); +#elif CADDIE_REGION_PAL + MapFile::GetInstance().LoadFromDVD("modules/main_PAL.map", + MapFile::LINK_DYNAMIC); #endif // Skip MotionPlus video From bee4964c9f6bdc384c8ef537a66d1a086764ae15 Mon Sep 17 00:00:00 2001 From: vincenzo-sorcigli <57498723+vincenzo-sorcigli@users.noreply.github.com> Date: Mon, 19 Jan 2026 22:54:56 -0500 Subject: [PATCH 16/17] fix compilation errors --- src/caddie/scene/glf/caddieGlfSceneHook.cpp | 1 + src/main.cpp | 1 + 2 files changed, 2 insertions(+) diff --git a/src/caddie/scene/glf/caddieGlfSceneHook.cpp b/src/caddie/scene/glf/caddieGlfSceneHook.cpp index 19e6ae4..d6163af 100644 --- a/src/caddie/scene/glf/caddieGlfSceneHook.cpp +++ b/src/caddie/scene/glf/caddieGlfSceneHook.cpp @@ -6,6 +6,7 @@ #include "caddieInputMgr.h" #include "caddieMenuMgr.h" +#include #include #include #include diff --git a/src/main.cpp b/src/main.cpp index aa94a3a..f524957 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -21,6 +21,7 @@ void main() { // Always show exception handler static const u16 scEmptyCombo[] = {0}; EGG::Exception::setUserCallback(scEmptyCombo); +#endif #ifdef CADDIE_REGION_NTSC_U MapFile::GetInstance().LoadFromDVD("modules/main_NTSC_U.map", From 08b9ca8dc5f3c31fd40eaaa8ed98c4d1c95f89b5 Mon Sep 17 00:00:00 2001 From: vincenzo-sorcigli <57498723+vincenzo-sorcigli@users.noreply.github.com> Date: Mon, 19 Jan 2026 23:49:22 -0500 Subject: [PATCH 17/17] more incorrect addresses --- externals/PAL.txt | 2 +- src/caddie/scene/glf/caddieGlfSceneHook.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/externals/PAL.txt b/externals/PAL.txt index aeccb5a..b642d32 100644 --- a/externals/PAL.txt +++ b/externals/PAL.txt @@ -130,7 +130,7 @@ GetDistFromPin__9RPGlfBallCFv=0x80411d28 IsHoleOut__9RPGlfBallCFv=0x80411e7c IsGreenOrCupAttr__9RPGlfBallCFv=0x80411dd8 FrSqrt__Q24nw4r4mathFf=0x8013ba50 -sInstance__17RPGlfFieldManager=0x806f5b40 +sInstance__17RPGlfFieldManager=0x806f5b20 sInstance__16RPGlfClubManager=0x806f5b60 IsHideUI__17RPGlfFieldManagerCFv=0x80403098 spSimBall__15RPGlfSimManager=0x806f5b88 diff --git a/src/caddie/scene/glf/caddieGlfSceneHook.cpp b/src/caddie/scene/glf/caddieGlfSceneHook.cpp index d6163af..caaa641 100644 --- a/src/caddie/scene/glf/caddieGlfSceneHook.cpp +++ b/src/caddie/scene/glf/caddieGlfSceneHook.cpp @@ -634,7 +634,7 @@ bool GlfSceneHook::ShouldShowTutorial() { return false; } #if CADDIE_REGION_NTSC_U kmBranch(0x803fa370, GlfSceneHook::ShouldShowTutorial); #elif CADDIE_REGION_PAL -kmBranch(0x803fa574, GlfSceneHook::ShouldShowTutorial); +kmBranch(0x803fa690, GlfSceneHook::ShouldShowTutorial); #endif /**