Split CEntity

This commit is contained in:
Henrique Gemignani Passos Lima
2023-08-09 02:12:28 +03:00
parent 4707055a6e
commit 025c2abcf2
5 changed files with 283 additions and 26 deletions
+4
View File
@@ -2,6 +2,10 @@ MetroidPrime/main.cpp:
.text start:0x800053B8 end:0x80008B60
.sbss start:0x80418EA0 end:0x80418EC4
MetroidPrime/CEntity.cpp:
.text start:0x80047E5C end:0x800483A4
.data start:0x803B1B40 end:0x803B1B60
MetroidPrime/Player/CPlayerState.cpp:
.text start:0x80084864 end:0x80086410
+16 -16
View File
@@ -512,7 +512,7 @@ fn_8001C690 = .text:0x8001C690; // type:function size:0x54
fn_8001C6E4 = .text:0x8001C6E4; // type:function size:0x130
fn_8001C814 = .text:0x8001C814; // type:function size:0x68 align:0x4
fn_8001C87C = .text:0x8001C87C; // type:function size:0x58
fn_8001C8D4 = .text:0x8001C8D4; // type:function size:0x54
__dt__Q24rstl48vector<11SConnection,Q24rstl17rmemory_allocator>Fv = .text:0x8001C8D4; // type:function size:0x54
fn_8001C928 = .text:0x8001C928; // type:function size:0x34 align:0x4
fn_8001C95C = .text:0x8001C95C; // type:function size:0x178
fn_8001CAD4 = .text:0x8001CAD4; // type:function size:0x98
@@ -1338,19 +1338,19 @@ fn_800476F8 = .text:0x800476F8; // type:function size:0x108
fn_80047800 = .text:0x80047800; // type:function size:0xD8 align:0x4
fn_800478D8 = .text:0x800478D8; // type:function size:0x1D8 align:0x4
fn_80047AB0 = .text:0x80047AB0; // type:function size:0x100
fn_80047BB0 = .text:0x80047BB0; // type:function size:0x1A4
fn_80047D54 = .text:0x80047D54; // type:function size:0x108
fn_80047E5C = .text:0x80047E5C; // type:function size:0xD8
fn_80047F34 = .text:0x80047F34; // type:function size:0x24
fn_80047F58 = .text:0x80047F58; // type:function size:0x10 align:0x4
SetActive__7CEntityFb = .text:0x80047BB0; // type:function size:0x1A4 scope:global
GetAreaId__7CEntityCFv = .text:0x80047D54; // type:function size:0x108 scope:global
SearchForSomething__7CEntityFR13CStateManager18EScriptObjectState20EScriptObjectMessage = .text:0x80047E5C; // type:function size:0xD8
GetAreaId__7CEntityCFv = .text:0x80047F34; // type:function size:0x24
SetActive__7CEntityFb = .text:0x80047F58; // type:function size:0x10 align:0x4
fn_80047F68 = .text:0x80047F68; // type:function size:0x80 align:0x4
fn_80047FE8 = .text:0x80047FE8; // type:function size:0x4
fn_80047FEC = .text:0x80047FEC; // type:function size:0x4 align:0x4
fn_80047FF0 = .text:0x80047FF0; // type:function size:0x110
fn_80048100 = .text:0x80048100; // type:function size:0x174 align:0x4
fn_80048274 = .text:0x80048274; // type:function size:0x64
fn_800482D8 = .text:0x800482D8; // type:function size:0xCC
fn_800483A4 = .text:0x800483A4; // type:function size:0x130
Think__7CEntityFfR13CStateManager = .text:0x80047FE8; // type:function size:0x4 scope:global
PreThink__7CEntityFfR13CStateManager = .text:0x80047FEC; // type:function size:0x4 scope:global align:0x4
SendScriptMsgs__7CEntityF18EScriptObjectStateR13CStateManager20EScriptObjectMessage = .text:0x80047FF0; // type:function size:0x110 scope:global
AcceptScriptMsg__7CEntityFR13CStateManagerR10CScriptMsg = .text:0x80048100; // type:function size:0x174 scope:global align:0x4
__dt__7CEntityFv = .text:0x80048274; // type:function size:0x64 scope:global
__ct__7CEntityF9TUniqueIdRC11CEntityInfobRCQ24rstl66basic_string<c,Q24rstl14char_traits<c>,Q24rstl17rmemory_allocator> = .text:0x800482D8; // type:function size:0xCC scope:global
__ct__Q24rstl48vector<11SConnection,Q24rstl17rmemory_allocator>FRCQ24rstl48vector<11SConnection,Q24rstl17rmemory_allocator> = .text:0x800483A4; // type:function size:0x130 scope:weak
fn_800484D4 = .text:0x800484D4; // type:function size:0x88
fn_8004855C = .text:0x8004855C; // type:function size:0x88 align:0x4
fn_800485E4 = .text:0x800485E4; // type:function size:0x98
@@ -12989,7 +12989,7 @@ __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
fn_802CE388 = .text:0x802CE388; // type:function size:0x64
Free__7CMemoryFPCv = .text:0x802CE388; // type:function size:0x64
fn_802CE3EC = .text:0x802CE3EC; // type:function size:0xD0
fn_802CE4BC = .text:0x802CE4BC; // type:function size:0x94
fn_802CE550 = .text:0x802CE550; // type:function size:0x3C align:0x4
@@ -17933,7 +17933,7 @@ lbl_803B1A40 = .data:0x803B1A40; // type:object size:0x90
jumptable_803B1AD0 = .data:0x803B1AD0; // type:object size:0x54 scope:local
lbl_803B1B24 = .data:0x803B1B24; // type:object size:0xC
lbl_803B1B30 = .data:0x803B1B30; // type:object size:0x10
lbl_803B1B40 = .data:0x803B1B40; // type:object size:0x20
__vt__7CEntity = .data:0x803B1B40; // type:object size:0x20
lbl_803B1B60 = .data:0x803B1B60; // type:object size:0x10
lbl_803B1B70 = .data:0x803B1B70; // type:object size:0x10
lbl_803B1B80 = .data:0x803B1B80; // type:object size:0x10
@@ -20295,7 +20295,7 @@ lbl_80419118 = .sbss:0x80419118; // type:object size:0x4 data:4byte
lbl_8041911C = .sbss:0x8041911C; // type:object size:0x4 data:4byte
lbl_80419120 = .sbss:0x80419120; // type:object size:0x4 data:4byte
kInvalidUniqueId = .sbss:0x80419124; // type:object size:0x2 scope:global data:2byte
lbl_80419128 = .sbss:0x80419128; // type:object size:0x4 data:4byte
kInvalidAreaId = .sbss:0x80419128; // type:object size:0x4 scope:global data:4byte
lbl_8041912C = .sbss:0x8041912C; // type:object size:0x4 data:4byte
lbl_80419130 = .sbss:0x80419130; // type:object size:0x4 data:4byte
lbl_80419134 = .sbss:0x80419134; // type:object size:0x4 data:4byte
+2 -2
View File
@@ -50,14 +50,14 @@ public:
}
vector(int count, const T& v, const Alloc& alloc);
vector(const vector& other) : x4_count(other.x4_count), x8_capacity(other.x8_capacity) {
vector(const vector& other); /* : x4_count(other.x4_count), x8_capacity(other.x8_capacity) {
if (other.x4_count == 0 && other.x8_capacity == 0) {
xc_items = nullptr;
} else {
x0_allocator.allocate(xc_items, x8_capacity);
uninitialized_copy_n(other.xc_items, x4_count, xc_items);
}
}
}*/
vector(CInputStream& in, const Alloc& alloc = Alloc());
~vector(); /* {
destroy(begin(), end());
+7 -8
View File
@@ -12,8 +12,9 @@ CEntity::CEntity(TUniqueId id, const CEntityInfo& info, bool active, const rstl:
, conns(info.GetConnectionList())
, active(active)
, inGraveyard(false)
// , scriptingBlocked(false)
, notInArea(areaId == kInvalidAreaId) {}
, scriptingBlocked(false)
, notInArea(areaId == kInvalidAreaId)
{}
CEntity::~CEntity() {}
@@ -46,9 +47,9 @@ void CEntity::SendScriptMsgs(EScriptObjectState state, CStateManager& mgr,
EScriptObjectMessage skipMsg) {
rstl::vector< SConnection >::const_iterator it = conns.begin();
for (; it != conns.end(); ++it) {
// if (it->x0_state == state && it->x4_msg != skipMsg) {
// mgr.SendScriptMsg(GetUniqueId(), it->x8_objId, it->x4_msg, state);
// }
if (it->state == state && it->msg != skipMsg) {
// mgr.SendScriptMsg(GetUniqueId(), it->x8_objId, it->x4_msg, state);
}
}
}
@@ -60,6 +61,4 @@ void CEntity::SetActive(const bool active) { this->active = active; }
TAreaId CEntity::GetAreaId() const { return notInArea ? kInvalidAreaId : areaId; }
TUniqueId CEntity::SearchForSomething(CStateManager&, EScriptObjectState, EScriptObjectMessage) {
}
TUniqueId CEntity::SearchForSomething(CStateManager&, EScriptObjectState, EScriptObjectMessage) {}
+254
View File
@@ -0,0 +1,254 @@
#include "MetroidPrime/Player/CGameOptions.hpp"
#include "Kyoto/Audio/CStreamAudioManager.hpp"
#include "Kyoto/Graphics/CMoviePlayer.hpp"
#include "Kyoto/Graphics/CGraphics.hpp"
#include "Kyoto/Math/CMath.hpp"
#include "dolphin/os.h"
extern "C" void fn_8029AF00(int, uchar);
bool lbl_804191E0;
int CGameOptions_CalculateBits(uint v) {
int iVar1;
iVar1 = 0;
for (; v != 0; v >>= 1) {
iVar1 += 1;
}
return iVar1;
}
void CGameOptions::InitSoundMode() {
if (OSGetSoundMode() == 0) {
soundMode = CAudioSys::kSM_Mono;
} else {
soundMode = (soundMode != CAudioSys::kSM_Mono) ? soundMode : CAudioSys::kSM_Stereo;
}
}
bool CGameOptions::fn_80161C84() { return lbl_804191E0; }
void CGameOptions::fn_80161C7C(bool x) { lbl_804191E0 = x; }
CGameOptions::CGameOptions()
: soundMode(CAudioSys::kSM_Stereo)
, screenBrightness(4)
, screenXOffset(0)
, screenYOffset(0)
, screenStretch(0)
, sfxVol(0x69)
, musicVol(0x4f)
, hudAlpha(0xff)
, helmetAlpha(0xff)
, hudLag(true)
, invertY(false)
, rumble(true)
, swapBeamsControls(false)
, hintSystem(true)
, unk(false)
{
InitSoundMode();
}
CGameOptions::CGameOptions(CInputStream& in) {}
void CGameOptions::PutTo(CMemoryStreamOut& out) {}
void CGameOptions::ResetToDefaults() {
screenBrightness = 4;
screenXOffset = 0;
screenYOffset = 0;
screenStretch = 0;
sfxVol = 0x69;
musicVol = 0x4f;
soundMode = CAudioSys::kSM_Stereo;
hudAlpha = 0xff;
helmetAlpha = 0xff;
hudLag = true;
invertY = false;
rumble = true;
swapBeamsControls = false;
hintSystem = true;
unk = false;
InitSoundMode();
EnsureOptions();
}
void CGameOptions::ResetExtraFlagsToDefaults() {
invertY = false;
rumble = true;
swapBeamsControls = false;
InitSoundMode();
EnsureOptions();
}
void CGameOptions::ResetScreenToDefaults() {
screenBrightness = 4;
screenXOffset = 0;
screenYOffset = 0;
screenStretch = 0;
InitSoundMode();
EnsureOptions();
}
void CGameOptions::ResetSoundToDefaults() {
sfxVol = 0x69;
musicVol = 0x4f;
soundMode = CAudioSys::kSM_Stereo;
InitSoundMode();
EnsureOptions();
}
void CGameOptions::ResetVisorToDefaults() {
hudAlpha = 0xff;
helmetAlpha = 0xff;
hudLag = true;
hintSystem = true;
unk = false;
InitSoundMode();
EnsureOptions();
}
void CGameOptions::EnsureOptions() {
SetScreenBrightness(screenBrightness, true);
SetScreenPositionX(screenXOffset, true);
SetScreenPositionY(screenYOffset, true);
SetScreenStretch(screenStretch, true);
SetSfxVolume(sfxVol, true);
SetMusicVolume(musicVol, true);
SetSurroundMode(soundMode, true);
SetHudAlpha(hudAlpha);
SetHelmetAlpha(helmetAlpha);
SetHUDLag(hudLag);
SetInvertYAxis(invertY);
SetIsRumbleEnabled(rumble);
SetIsHintSystemEnabled(hintSystem);
ToggleControls(swapBeamsControls);
SetFlag3(unk);
}
void CGameOptions::SetScreenBrightness(int value, bool apply) {
screenBrightness = CMath::ClampI(0, value, 8);
if (apply) {
CGraphics::SetBrightness(TuneScreenBrightness());
}
}
float CGameOptions::TuneScreenBrightness() {
float f = screenBrightness - 4;
return f / 4.f * 0.375f + 1.f;
}
void CGameOptions::SetScreenPositionX(int position, bool apply) {
screenXOffset = CMath::ClampI(-30, position, 30);
if (apply) {
int a, b, c;
CGraphics::GetScreenPosition(&a, &b, &c);
CGraphics::SetScreenPosition(a, screenXOffset, c);
}
}
void CGameOptions::SetScreenPositionY(int position, bool apply) {
screenYOffset = CMath::ClampI(-19, position, 19);
if (apply) {
int a, b, c;
CGraphics::GetScreenPosition(&a, &b, &c);
CGraphics::SetScreenPosition(a, b, screenYOffset);
}
}
void CGameOptions::SetScreenStretch(int value, bool apply) {
screenStretch = CMath::ClampI(-10, value, 10);
if (apply) {
int a, b, c;
CGraphics::GetScreenPosition(&a, &b, &c);
CGraphics::SetScreenPosition(screenStretch, b, c);
}
}
void CGameOptions::SetSfxVolume(int value, bool apply) {
sfxVol = CMath::ClampI(0, value, 0x69);
if (apply) {
if (fn_80161C84()) {
fn_8029AF00(0, sfxVol);
} else {
CAudioSys::SysSetSfxVolume(sfxVol, 1, true, true);
CStreamAudioManager::SetSfxVolume(sfxVol);
CMoviePlayer::SetSfxVolume(sfxVol);
}
}
}
void CGameOptions::SetMusicVolume(int value, bool apply) {
musicVol = CMath::ClampI(0, value, 0x69);
if (apply) {
CStreamAudioManager::SetMusicVolume(musicVol);
}
}
void CGameOptions::SetSurroundMode(CAudioSys::ESurroundModes mode, bool apply) {
soundMode = CAudioSys::ESurroundModes(CMath::ClampI(0, mode, 2));
if (apply) {
CAudioSys::SetSurroundMode(soundMode);
}
}
int CGameOptions::GetHudAlphaRaw() const {
return hudAlpha;
}
void CGameOptions::SetHudAlpha(int alpha) {
hudAlpha = alpha;
}
float CGameOptions::GetHudAlpha() const {
return hudAlpha * 0.003921569f;
}
void CGameOptions::SetHelmetAlpha(int alpha) { helmetAlpha = alpha; }
int CGameOptions::GetHelmetAlphaRaw() const { return helmetAlpha; }
float CGameOptions::GetHelmetAlpha() const { return helmetAlpha * 0.003921569f; }
void CGameOptions::SetHUDLag(bool active) {
hudLag = active;
}
void CGameOptions::SetIsHintSystemEnabled(bool active) {
hintSystem = active;
}
void CGameOptions::SetFlag3(bool active) {
unk = active;
}
void CGameOptions::SetInvertYAxis(bool active) {
invertY = active;
}
void CGameOptions::SetIsRumbleEnabled(bool active) {
rumble = active;
}
void CGameOptions::ToggleControls(bool flag) {
swapBeamsControls = flag;
if (flag) {
SetControls(1);
} else {
SetControls(0);
}
}
void CGameOptions::ResetControllerAssets(int controls) {
}
void CGameOptions::SetControls(int controls) {
ResetControllerAssets(controls);
}