From 6828656292bf2e7d71d4ffaa5dfe2012711d415d Mon Sep 17 00:00:00 2001 From: Henrique Gemignani Passos Lima Date: Tue, 8 Aug 2023 15:31:12 +0300 Subject: [PATCH] More progress for CMain --- config/G2ME01/symbols.txt | 58 +++++++-------- include/MetroidPrime/CAudioStateWin.hpp | 16 +++++ include/MetroidPrime/CConsoleOutputWindow.hpp | 29 ++++++++ include/MetroidPrime/CErrorOutputWindow.hpp | 32 +++++++++ .../MetroidPrime/CGameArchitectureSupport.hpp | 41 +++++------ include/MetroidPrime/CGuiSys/CGuiSys.hpp | 51 ++++++++++++++ include/MetroidPrime/CIOWin.hpp | 45 ++++++++++++ include/MetroidPrime/CInputGenerator.hpp | 29 ++++++++ include/MetroidPrime/CMain.hpp | 5 +- include/MetroidPrime/CMainFlow.hpp | 40 +++++++++++ include/MetroidPrime/Player/CGameOptions.hpp | 70 +++++++++++++++++++ include/MetroidPrime/Player/CGameState.hpp | 8 ++- include/MetroidPrime/Tweaks/CTweakGame.hpp | 1 + include/MetroidPrime/Tweaks/CTweakPlayer.hpp | 13 ++++ src/MetroidPrime/main.cpp | 62 ++++++++-------- 15 files changed, 418 insertions(+), 82 deletions(-) create mode 100644 include/MetroidPrime/CAudioStateWin.hpp create mode 100644 include/MetroidPrime/CConsoleOutputWindow.hpp create mode 100644 include/MetroidPrime/CErrorOutputWindow.hpp create mode 100644 include/MetroidPrime/CGuiSys/CGuiSys.hpp create mode 100644 include/MetroidPrime/CIOWin.hpp create mode 100644 include/MetroidPrime/CInputGenerator.hpp create mode 100644 include/MetroidPrime/CMainFlow.hpp create mode 100644 include/MetroidPrime/Player/CGameOptions.hpp create mode 100644 include/MetroidPrime/Tweaks/CTweakPlayer.hpp diff --git a/config/G2ME01/symbols.txt b/config/G2ME01/symbols.txt index efa7f14..ed3afc7 100644 --- a/config/G2ME01/symbols.txt +++ b/config/G2ME01/symbols.txt @@ -52,7 +52,7 @@ fn_80003858 = .text:0x80003858; // type:function size:0x24 fn_8000387C = .text:0x8000387C; // type:function size:0x148 align:0x4 fn_800039C4 = .text:0x800039C4; // type:function size:0x54 align:0x4 fn_80003A18 = .text:0x80003A18; // type:function size:0x30 -fn_80003A48 = .text:0x80003A48; // type:function size:0x1A0 +ResetGameState__5CMainFv = .text:0x80003A48; // type:function size:0x1A0 fn_80003BE8 = .text:0x80003BE8; // type:function size:0x5C fn_80003C44 = .text:0x80003C44; // type:function size:0xBC fn_80003D00 = .text:0x80003D00; // type:function size:0xA0 @@ -160,14 +160,14 @@ __ct__18CGameGlobalObjectsFR10COsContextR10CMemorySys = .text:0x8000848C; // typ ShutdownSubsystems__5CMainFv = .text:0x80008570; // type:function size:0x110 InitializeSubsystems__5CMainFv = .text:0x80008680; // type:function size:0x15C __dt__5CMainFv = .text:0x800087DC; // type:function size:0x3C -main = .text:0x80008818; // type:function size:0x80 +InvokeCMain = .text:0x80008818; // type:function size:0x80 __ct__5CMainFv = .text:0x80008898; // type:function size:0x114 fn_800089AC = .text:0x800089AC; // type:function size:0x10 align:0x4 -fn_800089BC = .text:0x800089BC; // type:function size:0x60 +SetMaxSpeed__5CMainFb = .text:0x800089BC; // type:function size:0x60 fn_80008A1C__5CMainFv = .text:0x80008A1C; // type:function size:0xC fn_80008A28 = .text:0x80008A28; // type:function size:0x20 fn_80008A48 = .text:0x80008A48; // type:function size:0x30 -fn_80008A78 = .text:0x80008A78; // type:function size:0x2C +__dl__38TOneStatic<24CGameArchitectureSupport>FPv = .text:0x80008A78; // type:function size:0x2C fn_80008AA4 = .text:0x80008AA4; // type:function size:0xC fn_80008AB0 = .text:0x80008AB0; // type:function size:0x24 fn_80008AD4 = .text:0x80008AD4; // type:function size:0x30 @@ -199,7 +199,7 @@ fn_800094B4 = .text:0x800094B4; // type:function size:0x54 fn_80009508 = .text:0x80009508; // type:function size:0x58 fn_80009560 = .text:0x80009560; // type:function size:0x84 fn_800095E4 = .text:0x800095E4; // type:function size:0x50 -fn_80009634 = .text:0x80009634; // type:function size:0x98 +__dt__Q24rstl55list<20CArchitectureMessage,Q24rstl17rmemory_allocator>Fv = .text:0x80009634; // type:function size:0x98 fn_800096CC = .text:0x800096CC; // type:function size:0x50 fn_8000971C = .text:0x8000971C; // type:function size:0xA4 fn_800097C0 = .text:0x800097C0; // type:function size:0x50 @@ -546,14 +546,14 @@ fn_8001D7D8 = .text:0x8001D7D8; // type:function size:0x8 align:0x4 fn_8001D7E0 = .text:0x8001D7E0; // type:function size:0x5C fn_8001D83C = .text:0x8001D83C; // type:function size:0x4C fn_8001D888 = .text:0x8001D888; // type:function size:0x1FC -fn_8001DA84 = .text:0x8001DA84; // type:function size:0x70 +__ct__15CInputGeneratorFP10COsContextff = .text:0x8001DA84; // type:function size:0x70 fn_8001DAF4 = .text:0x8001DAF4; // type:function size:0x60 align:0x4 fn_8001DB54 = .text:0x8001DB54; // type:function size:0x314 align:0x4 fn_8001DE68 = .text:0x8001DE68; // type:function size:0xE0 align:0x4 fn_8001DF48 = .text:0x8001DF48; // type:function size:0x4 align:0x4 fn_8001DF4C = .text:0x8001DF4C; // type:function size:0x8 align:0x4 fn_8001DF54 = .text:0x8001DF54; // type:function size:0xB4 align:0x4 -fn_8001E008 = .text:0x8001E008; // type:function size:0x68 +__ct__9CMainFlowFv = .text:0x8001E008; // type:function size:0x68 fn_8001E070 = .text:0x8001E070; // type:function size:0xC align:0x4 fn_8001E07C = .text:0x8001E07C; // type:function size:0x2EC align:0x4 fn_8001E368 = .text:0x8001E368; // type:function size:0x48 @@ -1392,12 +1392,12 @@ fn_800496A0 = .text:0x800496A0; // type:function size:0xC4 fn_80049764 = .text:0x80049764; // type:function size:0xF8 fn_8004985C = .text:0x8004985C; // type:function size:0x28 fn_80049884 = .text:0x80049884; // type:function size:0x194 -fn_80049A18 = .text:0x80049A18; // type:function size:0x80 +RemoveAllIOWins__13CIOWinManagerFv = .text:0x80049A18; // type:function size:0x80 scope:global fn_80049A98 = .text:0x80049A98; // type:function size:0x144 fn_80049BDC = .text:0x80049BDC; // type:function size:0x17C fn_80049D58 = .text:0x80049D58; // type:function size:0x2C -fn_80049D84 = .text:0x80049D84; // type:function size:0x64 -fn_80049DE8 = .text:0x80049DE8; // type:function size:0x28 +__dt__13CIOWinManagerFv = .text:0x80049D84; // type:function size:0x64 +__ct__13CIOWinManagerFv = .text:0x80049DE8; // type:function size:0x28 fn_80049E10 = .text:0x80049E10; // type:function size:0x4 align:0x4 fn_80049E14 = .text:0x80049E14; // type:function size:0x4 align:0x4 fn_80049E18 = .text:0x80049E18; // type:function size:0x8 align:0x4 @@ -5882,7 +5882,7 @@ fn_80161148 = .text:0x80161148; // type:function size:0x74 fn_801611BC = .text:0x801611BC; // type:function size:0x74 fn_80161230 = .text:0x80161230; // type:function size:0x44 fn_80161274 = .text:0x80161274; // type:function size:0x50 -fn_801612C4 = .text:0x801612C4; // type:function size:0x10C +EnsureOptions__12CGameOptionsFv = .text:0x801612C4; // type:function size:0x10C scope:global fn_801613D0 = .text:0x801613D0; // type:function size:0x6C align:0x4 fn_8016143C = .text:0x8016143C; // type:function size:0x4C align:0x4 fn_80161488 = .text:0x80161488; // type:function size:0x4C align:0x4 @@ -9415,8 +9415,8 @@ fn_80218434 = .text:0x80218434; // type:function size:0x40 fn_80218474 = .text:0x80218474; // type:function size:0x40 fn_802184B4 = .text:0x802184B4; // type:function size:0xC fn_802184C0 = .text:0x802184C0; // type:function size:0xC -fn_802184CC = .text:0x802184CC; // type:function size:0xC -fn_802184D8 = .text:0x802184D8; // type:function size:0xC +GetRightAnalogMax__12CTweakPlayerFv = .text:0x802184CC; // type:function size:0xC +GetLeftAnalogMax__12CTweakPlayerFv = .text:0x802184D8; // type:function size:0xC fn_802184E4 = .text:0x802184E4; // type:function size:0xC align:0x4 fn_802184F0 = .text:0x802184F0; // type:function size:0xC align:0x4 fn_802184FC = .text:0x802184FC; // type:function size:0xC align:0x4 @@ -12985,7 +12985,7 @@ fn_802CE104 = .text:0x802CE104; // type:function size:0xB4 fn_802CE1B8 = .text:0x802CE1B8; // type:function size:0x30 fn_802CE1E8 = .text:0x802CE1E8; // type:function size:0x3C fn_802CE224 = .text:0x802CE224; // type:function size:0x54 -fn_802CE278 = .text:0x802CE278; // type:function size:0x54 +__nw__FUlPCcPCc = .text:0x802CE278; // type:function size:0x54 fn_802CE2CC = .text:0x802CE2CC; // type:function size:0x34 fn_802CE300 = .text:0x802CE300; // type:function size:0x4C fn_802CE34C = .text:0x802CE34C; // type:function size:0x3C align:0x4 @@ -14042,9 +14042,9 @@ fn_80307724 = .text:0x80307724; // type:function size:0x9C fn_803077C0 = .text:0x803077C0; // type:function size:0x4C align:0x4 fn_8030780C = .text:0x8030780C; // type:function size:0x8 fn_80307814 = .text:0x80307814; // type:function size:0x50 -fn_80307864 = .text:0x80307864; // type:function size:0x8 -fn_8030786C = .text:0x8030786C; // type:function size:0x8 -fn_80307874 = .text:0x80307874; // type:function size:0x8 +GetDefaultVolumeScale__9CAudioSysFv = .text:0x80307864; // type:function size:0x8 +SetDefaultVolumeScale__9CAudioSysFs = .text:0x8030786C; // type:function size:0x8 +SetVolumeScale__9CAudioSysFs = .text:0x80307874; // type:function size:0x8 fn_8030787C = .text:0x8030787C; // type:function size:0x78 fn_803078F4 = .text:0x803078F4; // type:function size:0x8 align:0x4 fn_803078FC = .text:0x803078FC; // type:function size:0x48 @@ -14071,7 +14071,7 @@ fn_80308320 = .text:0x80308320; // type:function size:0x28 fn_80308348 = .text:0x80308348; // type:function size:0x20 fn_80308368 = .text:0x80308368; // type:function size:0x20 fn_80308388 = .text:0x80308388; // type:function size:0x20 -fn_803083A8 = .text:0x803083A8; // type:function size:0x20 +TrkSetSampleRate__9CAudioSysF14ETRKSampleRate = .text:0x803083A8; // type:function size:0x20 fn_803083C8 = .text:0x803083C8; // type:function size:0x68 fn_80308430 = .text:0x80308430; // type:function size:0x3C fn_8030846C = .text:0x8030846C; // type:function size:0x78 @@ -14086,11 +14086,11 @@ fn_80308798 = .text:0x80308798; // type:function size:0x20 align:0x4 fn_803087B8 = .text:0x803087B8; // type:function size:0x20 align:0x4 fn_803087D8 = .text:0x803087D8; // type:function size:0x68 align:0x4 fn_80308840 = .text:0x80308840; // type:function size:0x30 -fn_80308870 = .text:0x80308870; // type:function size:0x2C -fn_8030889C = .text:0x8030889C; // type:function size:0x94 +SysSetVolume__9CAudioSysFUcUiUc = .text:0x80308870; // type:function size:0x2C +__dt__9CAudioSysFv = .text:0x8030889C; // type:function size:0x94 scope:global fn_80308930 = .text:0x80308930; // type:function size:0x84 fn_803089B4 = .text:0x803089B4; // type:function size:0x74 -fn_80308A28 = .text:0x80308A28; // type:function size:0x200 +__ct__9CAudioSysFccccUi = .text:0x80308A28; // type:function size:0x200 fn_80308C28 = .text:0x80308C28; // type:function size:0xBC fn_80308CE4 = .text:0x80308CE4; // type:function size:0x28 align:0x4 fn_80308D0C = .text:0x80308D0C; // type:function size:0x2C align:0x4 @@ -14667,7 +14667,7 @@ fn_803215EC = .text:0x803215EC; // type:function size:0x44 fn_80321630 = .text:0x80321630; // type:function size:0xE0 align:0x4 fn_80321710 = .text:0x80321710; // type:function size:0x30 fn_80321740 = .text:0x80321740; // type:function size:0x18 -fn_80321758 = .text:0x80321758; // type:function size:0x38 +SetMusicVolume__19CStreamAudioManagerFUi = .text:0x80321758; // type:function size:0x38 fn_80321790 = .text:0x80321790; // type:function size:0x14C align:0x4 fn_803218DC = .text:0x803218DC; // type:function size:0x70 align:0x4 fn_8032194C = .text:0x8032194C; // type:function size:0x1D0 @@ -15559,8 +15559,8 @@ fn_80345938 = .text:0x80345938; // type:function size:0x10C align:0x4 fn_80345A44 = .text:0x80345A44; // type:function size:0x24 fn_80345A68 = .text:0x80345A68; // type:function size:0x24 fn_80345A8C = .text:0x80345A8C; // type:function size:0x28 -fn_80345AB4 = .text:0x80345AB4; // type:function size:0xB4 -fn_80345B68 = .text:0x80345B68; // type:function size:0xCC +__cvt_sll_flt = .text:0x80345AB4; // type:function size:0xB4 +__cvt_dbl_usll = .text:0x80345B68; // type:function size:0xCC __fini_cpp_exceptions = .text:0x80345C34; // type:function size:0x34 scope:global __init_cpp_exceptions = .text:0x80345C68; // type:function size:0x3C scope:global ExPPC_LongJump__FP12ThrowContextPvPv = .text:0x80345CA4; // type:function size:0x104 scope:local @@ -16190,8 +16190,8 @@ OSInitAlarm = .text:0x8036E3E4; // type:function size:0x58 scope:global OSCreateAlarm = .text:0x8036E43C; // type:function size:0x10 scope:global InsertAlarm = .text:0x8036E44C; // type:function size:0x250 scope:local OSSetAlarm = .text:0x8036E69C; // type:function size:0x68 scope:global -fn_8036E704 = .text:0x8036E704; // type:function size:0x7C -fn_8036E780 = .text:0x8036E780; // type:function size:0x11C +OSSetPeriodicAlarm = .text:0x8036E704; // type:function size:0x7C scope:global +OSCancelAlarm = .text:0x8036E780; // type:function size:0x11C DecrementerExceptionCallback = .text:0x8036E89C; // type:function size:0x230 scope:local DecrementerExceptionHandler = .text:0x8036EACC; // type:function size:0x50 scope:local fn_8036EB1C = .text:0x8036EB1C; // type:function size:0xA0 align:0x4 @@ -20154,7 +20154,7 @@ gpMemoryCard = .sbss:0x80418EBC; // type:object size:0x4 data:4byte gpTweakManager = .sbss:0x80418EC0; // type:object size:0x4 data:4byte lbl_80418EC4 = .sbss:0x80418EC4; // type:object size:0x4 data:4byte lbl_80418EC8 = .sbss:0x80418EC8; // type:object size:0x4 data:4byte -lbl_80418ECC = .sbss:0x80418ECC; // type:object size:0x4 data:float +sInfiniteLoopTime = .sbss:0x80418ECC; // type:object size:0x4 data:float lbl_80418ED0 = .sbss:0x80418ED0; // type:object size:0x4 data:4byte lbl_80418ED4 = .sbss:0x80418ED4; // type:object size:0x1 data:byte lbl_80418ED8 = .sbss:0x80418ED8; // type:object size:0x4 data:4byte @@ -20188,8 +20188,8 @@ lbl_80418F30 = .sbss:0x80418F30; // type:object size:0x4 data:4byte lbl_80418F34 = .sbss:0x80418F34; // type:object size:0x4 data:4byte lbl_80418F38 = .sbss:0x80418F38; // type:object size:0x4 data:4byte lbl_80418F3C = .sbss:0x80418F3C; // type:object size:0x4 data:4byte -lbl_80418F40 = .sbss:0x80418F40; // type:object size:0x4 data:4byte -lbl_80418F44 = .sbss:0x80418F44; // type:object size:0x4 data:4byte +gpTweakPlayerB = .sbss:0x80418F40; // type:object size:0x4 data:4byte +gpTweakPlayerA = .sbss:0x80418F44; // type:object size:0x4 data:4byte lbl_80418F48 = .sbss:0x80418F48; // type:object size:0x4 data:4byte lbl_80418F4C = .sbss:0x80418F4C; // type:object size:0x4 data:4byte lbl_80418F50 = .sbss:0x80418F50; // type:object size:0x4 data:4byte diff --git a/include/MetroidPrime/CAudioStateWin.hpp b/include/MetroidPrime/CAudioStateWin.hpp new file mode 100644 index 0000000..1516304 --- /dev/null +++ b/include/MetroidPrime/CAudioStateWin.hpp @@ -0,0 +1,16 @@ +#ifndef _CAUDIOSTATEWIN +#define _CAUDIOSTATEWIN + +#include "types.h" + +#include "MetroidPrime/CIOWin.hpp" + +class CAudioStateWin : public CIOWin { +public: + CAudioStateWin(); + + ~CAudioStateWin() override; + EMessageReturn OnMessage(const CArchitectureMessage&, CArchitectureQueue&) override; +}; + +#endif // _CAUDIOSTATEWIN diff --git a/include/MetroidPrime/CConsoleOutputWindow.hpp b/include/MetroidPrime/CConsoleOutputWindow.hpp new file mode 100644 index 0000000..6ff090f --- /dev/null +++ b/include/MetroidPrime/CConsoleOutputWindow.hpp @@ -0,0 +1,29 @@ +#ifndef _CCONSOLEOUTPUTWINDOW +#define _CCONSOLEOUTPUTWINDOW + +#include "MetroidPrime/CIOWin.hpp" + +#include "Kyoto/Text/CFont.hpp" + +#include + +class CConsoleOutputWindow : public CIOWin { + static CConsoleOutputWindow* mInstance; +public: + CConsoleOutputWindow(int, float, float); + + ~CConsoleOutputWindow() override; + EMessageReturn OnMessage(const CArchitectureMessage&, CArchitectureQueue&) override; + void Update(float); + void Draw() const; +private: + CFont mFont; + float mUnk; + rstl::vector mText; + rstl::vector mUnkFloats; + int x40_; + int x44_; + int x48_; +}; + +#endif // _CCONSOLEOUTPUTWINDOW diff --git a/include/MetroidPrime/CErrorOutputWindow.hpp b/include/MetroidPrime/CErrorOutputWindow.hpp new file mode 100644 index 0000000..9fb6863 --- /dev/null +++ b/include/MetroidPrime/CErrorOutputWindow.hpp @@ -0,0 +1,32 @@ +#ifndef _CERROROUTPUTWINDOW +#define _CERROROUTPUTWINDOW + +#include "types.h" + +#include "MetroidPrime/CIOWin.hpp" + +class CErrorOutputWindow : public CIOWin { +public: + CErrorOutputWindow(bool); + ~CErrorOutputWindow() override; + + EMessageReturn OnMessage(const CArchitectureMessage&, CArchitectureQueue&) override; + bool GetIsContinueDraw() const override; + void Draw() const override; + + void UpdateWindow(); + + void sub_802694c4(int); + void sub_802695f8() const; + +private: + int x14_state; + bool x18_24_ : 1; + bool x18_25_ : 1; + bool x18_26_ : 1; + bool x18_27_ : 1; + bool x18_28_ : 1; + const wchar_t* x1c_msg; +}; + +#endif // _CERROROUTPUTWINDOW diff --git a/include/MetroidPrime/CGameArchitectureSupport.hpp b/include/MetroidPrime/CGameArchitectureSupport.hpp index a6189a0..904116b 100644 --- a/include/MetroidPrime/CGameArchitectureSupport.hpp +++ b/include/MetroidPrime/CGameArchitectureSupport.hpp @@ -7,10 +7,11 @@ #include "Kyoto/Basics/COsContext.hpp" #include "Kyoto/Basics/CStopwatch.hpp" #include "Kyoto/TOneStatic.hpp" +#include "CGuiSys/CGuiSys.hpp" #include "MetroidPrime/CArchitectureQueue.hpp" #include "MetroidPrime/CIOWinManager.hpp" -// #include "MetroidPrime/CInputGenerator.hpp" +#include "MetroidPrime/CInputGenerator.hpp" #include "rstl/vector.hpp" @@ -26,27 +27,27 @@ public: void Update(); void UnloadAudio(); - inline CStopwatch& GetStopwatch1() { return x20_stopwatch1; } - inline CStopwatch& GetStopwatch2() { return x28_stopwatch2; } - inline CIOWinManager& GetIOWinManager() { return x58_ioWinMgr; } - inline int& GetFramesDrawn() { return x78_gameFrameCount; } + inline CStopwatch& GetStopwatch1() { return stopwatch1; } + inline CStopwatch& GetStopwatch2() { return stopwatch2; } + inline CIOWinManager& GetIOWinManager() { return ioWinMgr; } + inline int& GetFramesDrawn() { return gameFrameCount; } private: - CAudioSys x0_audioSys; - CArchitectureQueue x4_archQueue; - CStopwatch x20_stopwatch1; - CStopwatch x28_stopwatch2; - // CInputGenerator x30_inputGenerator; - // CGuiSys x44_guiSys; - CIOWinManager x58_ioWinMgr; - int x78_gameFrameCount; - float x7c_; - float x80_; - float x84_; - uint x88_; - rstl::vector< CToken > x90_; - OSAlarm xa0_infiniteLoopAlarm; - bool xc8_infiniteLoopAlarmSet; + CAudioSys audioSys; + CArchitectureQueue archQueue; + CStopwatch stopwatch1; + CStopwatch stopwatch2; + CInputGenerator inputGenerator; + CIOWinManager ioWinMgr; + // CGuiSys guiSys; + int gameFrameCount; + float x68_; + float x6c_; + float x70_; + uint x74_; + // rstl::vector< CToken > x90_; + OSAlarm infiniteLoopAlarm; + bool infiniteLoopAlarmSet; }; // CHECK_SIZEOF(CGameArchitectureSupport, 0xd0) diff --git a/include/MetroidPrime/CGuiSys/CGuiSys.hpp b/include/MetroidPrime/CGuiSys/CGuiSys.hpp new file mode 100644 index 0000000..efd3e0d --- /dev/null +++ b/include/MetroidPrime/CGuiSys/CGuiSys.hpp @@ -0,0 +1,51 @@ +#ifndef _CGUISYS +#define _CGUISYS + +#include "types.h" + +#include "rstl/rc_ptr.hpp" +#include "rstl/single_ptr.hpp" + +// #include "GuiSys/CGuiTextSupport.hpp" + +class IFactory; +class CSimplePool; +class CTextExecuteBuffer; +class CTextParser; +class CGuiWidget; + +class CGuiSys; +extern CGuiSys* gGuiSystem; + +class CGuiSys { + +public: + enum EUsageMode { + kUM_Zero, + kUM_One, + kUM_Two, + }; + + CGuiSys(IFactory*, CSimplePool*, EUsageMode); + ~CGuiSys(); + + static void SetGlobalGuiSys(CGuiSys* ptr) { + gGuiSystem = ptr; + // spGuiSys = ptr; + } + // static CGuiWidget* CreateWidgetInGame(uint type, CInputStream& in, CGuiFrame* parent); + + void AddFactories(EUsageMode mode); + +private: + // IFactory* x0_resFactory; + // CSimplePool* x4_resStore; + // EUsageMode x8_mode; + // rstl::single_ptr< CTextExecuteBuffer > xc_textExecuteBuffer; + // rstl::single_ptr< CTextParser > x10_textParser; + // static CGuiSys* spGuiSys; +}; + +// CHECK_SIZEOF(CGuiSys, 0x14); + +#endif // _CGUISYS diff --git a/include/MetroidPrime/CIOWin.hpp b/include/MetroidPrime/CIOWin.hpp new file mode 100644 index 0000000..a6f20cb --- /dev/null +++ b/include/MetroidPrime/CIOWin.hpp @@ -0,0 +1,45 @@ +#ifndef _CIOWIN +#define _CIOWIN + +#include "types.h" + +#include "rstl/string.hpp" + +class CArchitectureMessage; +class CArchitectureQueue; + +class CIOWin { +public: + enum EMessageReturn { + kMR_Normal = 0, + kMR_Exit = 1, + kMR_RemoveIOWinAndExit = 2, + kMR_RemoveIOWin = 3, + }; + + CIOWin(const rstl::string& name); + virtual ~CIOWin(); + + const rstl::string& GetName() const; + virtual EMessageReturn OnMessage(const CArchitectureMessage&, CArchitectureQueue&) = 0; + virtual bool GetIsContinueDraw() const; + virtual void Draw() const; + virtual void PreDraw() const; + +private: + rstl::string name; +}; + +#define kFrontEndUIMsgPriority 12 +#define kFrontEndUIDrawPriority 11 +#define kMFGameMsgPriority 10 +#define kMFGameDrawPriority 1000 + +// namespace IOWinPriorities { +// static int kFrontEndUIMsgPriority = 12; +// static int kFrontEndUIDrawPriority = 11; +// static int kMFGameMsgPriority = 10; +// static int kMFGameDrawPriority = 1000; +// } // namespace IOWinPriorities + +#endif // _CIOWIN diff --git a/include/MetroidPrime/CInputGenerator.hpp b/include/MetroidPrime/CInputGenerator.hpp new file mode 100644 index 0000000..35c1f58 --- /dev/null +++ b/include/MetroidPrime/CInputGenerator.hpp @@ -0,0 +1,29 @@ +#ifndef _CINPUTGENERATOR +#define _CINPUTGENERATOR + +#include "types.h" + +#include "rstl/single_ptr.hpp" + +#include "Kyoto/Input/IController.hpp" + +class COsContext; +class IController; +class CArchitectureQueue; + +class CInputGenerator { +public: + CInputGenerator(COsContext*, float leftDiv, float rightDiv); + bool Update(float dt, CArchitectureQueue& queue); + IController* GetController() const { return x4_controller.get(); } + +private: + COsContext* x0_context; + rstl::single_ptr< IController > x4_controller; + bool x8_connectedControllers[4]; + float xc_leftDiv; + float x10_rightDiv; +}; +CHECK_SIZEOF(CInputGenerator, 0x14) + +#endif // _CINPUTGENERATOR diff --git a/include/MetroidPrime/CMain.hpp b/include/MetroidPrime/CMain.hpp index 3be2fc0..c6a66d3 100644 --- a/include/MetroidPrime/CMain.hpp +++ b/include/MetroidPrime/CMain.hpp @@ -51,10 +51,7 @@ public: ERestartMode GetRestartMode() const { return restartMode; } // void SetCardBusy(bool v) { x160_31_cardBusy = v; } - void SetMaxSpeed(bool v) { - // ? - x160_26_screenFading = v; - } + void SetMaxSpeed(bool v); // {x160_26_screenFading = v; } bool fn_80008A1C(); diff --git a/include/MetroidPrime/CMainFlow.hpp b/include/MetroidPrime/CMainFlow.hpp new file mode 100644 index 0000000..9d2f547 --- /dev/null +++ b/include/MetroidPrime/CMainFlow.hpp @@ -0,0 +1,40 @@ +#ifndef _CMAINFLOW +#define _CMAINFLOW + +#include "types.h" + +#include "MetroidPrime/CIOWin.hpp" + +enum EClientFlowStates { + kCFS_Unspecified = -1, + kCFS_None = 0, + kCFS_WinBad = 1, + kCFS_WinGood = 2, + kCFS_WinBest = 3, + kCFS_LoseGame = 4, + kCFS_Default = 5, + kCFS_StateSetter = 6, + kCFS_PreFrontEnd = 7, + kCFS_FrontEnd = 8, + kCFS_Game = 14, + kCFS_GameExit = 15 +}; + +class CMainFlow : public CIOWin { +public: + CMainFlow(); + + ~CMainFlow() override; + EMessageReturn OnMessage(const CArchitectureMessage&, CArchitectureQueue&) override; + bool GetIsContinueDraw() const override; + void Draw() const override; + + void AdvanceGameState(CArchitectureQueue& queue); + void SetGameState(EClientFlowStates state, CArchitectureQueue& queue); +private: + EClientFlowStates x14_gameState; +}; + +CHECK_SIZEOF(CMainFlow, 0x18) + +#endif // _CMAINFLOW diff --git a/include/MetroidPrime/Player/CGameOptions.hpp b/include/MetroidPrime/Player/CGameOptions.hpp new file mode 100644 index 0000000..ce6de8b --- /dev/null +++ b/include/MetroidPrime/Player/CGameOptions.hpp @@ -0,0 +1,70 @@ +#ifndef _CGAMEOPTIONS_HPP +#define _CGAMEOPTIONS_HPP + +#include "types.h" + +#include "rstl/pair.hpp" +#include "rstl/reserved_vector.hpp" +#include "rstl/vector.hpp" + +#include "Kyoto/Audio/CAudioSys.hpp" +#include "Kyoto/SObjectTag.hpp" +#include "MetroidPrime/TGameTypes.hpp" + +class CInputStream; +class CMemoryStreamOut; + +class CGameOptions { +public: + CGameOptions(); + CGameOptions(CInputStream& in); + ~CGameOptions(); + + void PutTo(CMemoryStreamOut&); + + void InitSoundMode(); + void ResetToDefaults(); + void EnsureOptions(); + + void SetScreenBrightness(int, bool); + float TuneScreenBrightness(); + void SetScreenPositionX(int, bool); + void SetScreenPositionY(int, bool); + void SetScreenStretch(int, bool); + void SetSfxVolume(int, bool); + void SetMusicVolume(int, bool); + void SetSurroundMode(CAudioSys::ESurroundModes, bool); + + float GetHudAlpha() const; + float GetHelmetAlpha() const; + void SetHelmetAlpha(int); + void SetHUDLag(bool); + void SetIsHintSystemEnabled(bool); + void SetInvertYAxis(bool); + void ToggleControls(bool); + void ResetControllerAssets(int); + void SetControls(int); + + void SetIsRumbleEnabled(bool rumble); + bool GetIsRumbleEnabled() const { return rumble; } + +private: + int soundMode; + int screenBrightness; + int screenXOffset; + int screenYOffset; + int screenStretch; + uint sfxVol; + uint musicVol; + int hudAlpha; + int helmetAlpha; + bool hudLag : 1; + bool invertY : 1; + bool rumble : 1; + bool swapBeamsControls : 1; + bool hintSystem : 1; + char pad[28]; +}; +CHECK_SIZEOF(CGameOptions, 0x44) + +#endif // _CGAMEOPTIONS_HPP diff --git a/include/MetroidPrime/Player/CGameState.hpp b/include/MetroidPrime/Player/CGameState.hpp index b99f7f7..7e84a25 100644 --- a/include/MetroidPrime/Player/CGameState.hpp +++ b/include/MetroidPrime/Player/CGameState.hpp @@ -5,6 +5,8 @@ #include "MetroidPrime/TGameTypes.hpp" +#include "MetroidPrime/Player/CGameOptions.hpp" + class CGameState { public: CGameState(); @@ -14,8 +16,12 @@ public: void PutTo(COutputStream& out) const; void WriteSystemOptions(COutputStream& out); + CGameOptions& GameOptions() { return gameOptions; } + private: - char pad[0x2f0]; + char pad1[0x80]; + CGameOptions gameOptions; + char pad2[0x22c]; }; CHECK_SIZEOF(CGameState, 0x2f0) diff --git a/include/MetroidPrime/Tweaks/CTweakGame.hpp b/include/MetroidPrime/Tweaks/CTweakGame.hpp index bcfacb5..eca7491 100644 --- a/include/MetroidPrime/Tweaks/CTweakGame.hpp +++ b/include/MetroidPrime/Tweaks/CTweakGame.hpp @@ -6,6 +6,7 @@ class CTweakGame { public: const rstl::string& GetPakFile(); + bool GetSplashScreensDisabled(); }; extern CTweakGame* gpTweakGame; diff --git a/include/MetroidPrime/Tweaks/CTweakPlayer.hpp b/include/MetroidPrime/Tweaks/CTweakPlayer.hpp new file mode 100644 index 0000000..80e9395 --- /dev/null +++ b/include/MetroidPrime/Tweaks/CTweakPlayer.hpp @@ -0,0 +1,13 @@ +#ifndef _CTWEAKPLAYER +#define _CTWEAKPLAYER + +class CTweakPlayer { +public: + float GetLeftAnalogMax(); + float GetRightAnalogMax(); +}; + +extern CTweakPlayer* gpTweakPlayerA; +extern CTweakPlayer* gpTweakPlayerB; + +#endif // _CTWEAKPLAYER diff --git a/src/MetroidPrime/main.cpp b/src/MetroidPrime/main.cpp index c1ed927..1ae81b2 100644 --- a/src/MetroidPrime/main.cpp +++ b/src/MetroidPrime/main.cpp @@ -6,11 +6,14 @@ #include "Kyoto/CResFactory.hpp" #include "Kyoto/CSimplePool.hpp" #include "Kyoto/Text/CStringTable.hpp" +#include "Kyoto/Audio/CStreamAudioManager.hpp" #include "MetroidPrime/CGameArchitectureSupport.hpp" #include "MetroidPrime/CGameGlobalObjects.hpp" #include "MetroidPrime/Player/CGameState.hpp" #include "MetroidPrime/Tweaks/CTweakGame.hpp" +#include "MetroidPrime/Tweaks/CTweakPlayer.hpp" +#include "MetroidPrime/CMainFlow.hpp" class CCharacterFactoryBuilder; class CGameState; @@ -84,52 +87,55 @@ void CGameGlobalObjects::LoadStringTable() { void InfiniteLoopAlarm(OSAlarm* alarm, OSContext* context) { if (sInfiniteLoopTime >= 10.f) { + OSCancelAlarm(alarm); rs_debugger_printf("INFINITE LOOP"); } sInfiniteLoopTime += alarm->period / OS_TIMER_CLOCK; } +extern "C" void fn_8029EFCC(); +extern "C" void fn_8033CEE8(); + CGameArchitectureSupport::CGameArchitectureSupport(COsContext& osContext) -: x0_audioSys(0x30, 0x30, 0x30, 0x30, 0x5fc000) -// , x30_inputGenerator(&osContext, gpTweakPlayer->GetLeftAnalogMax(), -// gpTweakPlayer->GetRightAnalogMax()) -// , x44_guiSys(gpResourceFactory, gpSimplePool, CGuiSys::kUM_Zero) -, x78_gameFrameCount(0) -, x7c_(0.f) -, x80_(0.f) -, x84_(0.f) -, x88_(2) -, xc8_infiniteLoopAlarmSet(false) { +: audioSys(0x30, 0x30, 0x30, 0x30, 0x5fc000) +, inputGenerator(&osContext, gpTweakPlayerA->GetLeftAnalogMax(), + gpTweakPlayerA->GetRightAnalogMax()) +// , guiSys(gpResourceFactory, gpSimplePool, CGuiSys::kUM_Zero) +, gameFrameCount(0) +, x68_(0.f) +, x6c_(0.f) +, x70_(0.f) +// , x74_(2) +, infiniteLoopAlarmSet(false) { CAudioSys::SysSetVolume(0x7F, 0, 0xFF); CAudioSys::SetDefaultVolumeScale(0x75); CAudioSys::SetVolumeScale(CAudioSys::GetDefaultVolumeScale()); // CDSPStreamManager::Initialize(); - // CStreamAudioManager::SetMusicVolume(0x7F); + fn_8029EFCC(); + fn_8033CEE8(); + CStreamAudioManager::SetMusicVolume(0x7F); CAudioSys::TrkSetSampleRate(kTSR_One); gpMain->SetMaxSpeed(false); gpMain->ResetGameState(); - // if (!gpTweakGame->GetSplashScreensDisabled()) { - // x58_ioWinMgr.AddIOWin(new CSplashScreen(CSplashScreen::Nintendo), 1000, 10000); - // } - // x58_ioWinMgr.AddIOWin(new CMainFlow(), 0, 0); - // x58_ioWinMgr.AddIOWin(new CConsoleOutputWindow(8, 5.f, 0.75f), 100, 0); - // x58_ioWinMgr.AddIOWin(new CAudioStateWin(), 100, -1); - // x58_ioWinMgr.AddIOWin(new CErrorOutputWindow(false), 10000, 100000); - // InitializeApplicationUI(x44_guiSys); - // CGuiSys::SetGlobalGuiSys(&x44_guiSys); - // gpController = x30_inputGenerator.GetController(); - // gpGameState->GameOptions().EnsureOptions(); + ioWinMgr.AddIOWin(new CMainFlow(), 0, 0); + // ioWinMgr.AddIOWin(new CConsoleOutputWindow(8, 5.f, 0.75f), 100, 0); + // ioWinMgr.AddIOWin(new CAudioStateWin(), 100, -1); + // ioWinMgr.AddIOWin(new CErrorOutputWindow(false), 10000, 100000); + // InitializeApplicationUI(guiSys); + // CGuiSys::SetGlobalGuiSys(&guiSys); + gpController = inputGenerator.GetController(); + gpGameState->GameOptions().EnsureOptions(); sInfiniteLoopTime = 0.f; - OSSetPeriodicAlarm(&xa0_infiniteLoopAlarm, OSGetTime(), (float)OS_TIMER_CLOCK, InfiniteLoopAlarm); - xc8_infiniteLoopAlarmSet = true; + OSSetPeriodicAlarm(&infiniteLoopAlarm, OSGetTime(), (float)OS_TIMER_CLOCK, InfiniteLoopAlarm); + infiniteLoopAlarmSet = true; } CGameArchitectureSupport::~CGameArchitectureSupport() { - if (xc8_infiniteLoopAlarmSet) { - OSCancelAlarm(&xa0_infiniteLoopAlarm); - xc8_infiniteLoopAlarmSet = false; + if (infiniteLoopAlarmSet) { + OSCancelAlarm(&infiniteLoopAlarm); + infiniteLoopAlarmSet = false; } - x58_ioWinMgr.RemoveAllIOWins(); + ioWinMgr.RemoveAllIOWins(); UnloadAudio(); // CSfxManager::Shutdown(); // CDSPStreamManager::Shutdown();