Add CScriptPlayerStateChange, one regswap away from matching

This commit is contained in:
Henrique Gemignani Passos Lima 2022-10-16 16:20:53 +03:00
parent 903d979c05
commit e9f0009c47
No known key found for this signature in database
GPG Key ID: E224F951761145F8
4 changed files with 157 additions and 6 deletions

View File

@ -2,8 +2,8 @@
.section .data
.balign 8
.global lbl_803E5CC0
lbl_803E5CC0:
.global __vt__24CScriptPlayerStateChange
__vt__24CScriptPlayerStateChange:
# ROM: 0x3E2CC0
.4byte 0
.4byte 0
@ -26,9 +26,9 @@ __dt__24CScriptPlayerStateChangeFv:
/* 801DA4B4 001D7414 93 C1 00 08 */ stw r30, 8(r1)
/* 801DA4B8 001D7418 7C 7E 1B 79 */ or. r30, r3, r3
/* 801DA4BC 001D741C 41 82 00 28 */ beq lbl_801DA4E4
/* 801DA4C0 001D7420 3C A0 80 3E */ lis r5, lbl_803E5CC0@ha
/* 801DA4C0 001D7420 3C A0 80 3E */ lis r5, __vt__24CScriptPlayerStateChange@ha
/* 801DA4C4 001D7424 38 80 00 00 */ li r4, 0
/* 801DA4C8 001D7428 38 05 5C C0 */ addi r0, r5, lbl_803E5CC0@l
/* 801DA4C8 001D7428 38 05 5C C0 */ addi r0, r5, __vt__24CScriptPlayerStateChange@l
/* 801DA4CC 001D742C 90 1E 00 00 */ stw r0, 0(r30)
/* 801DA4D0 001D7430 4B E7 6D A5 */ bl __dt__7CEntityFv
/* 801DA4D4 001D7434 7F E0 07 35 */ extsh. r0, r31
@ -158,9 +158,9 @@ Accept__24CScriptPlayerStateChangeFR8IVisitor:
/* 801DA694 001D75F4 7C 87 23 78 */ mr r7, r4
/* 801DA698 001D75F8 38 81 00 08 */ addi r4, r1, 8
/* 801DA69C 001D75FC 4B E7 6C 89 */ bl "__ct__7CEntityF9TUniqueIdRC11CEntityInfobRCQ24rstl66basic_string<c,Q24rstl14char_traits<c>,Q24rstl17rmemory_allocator>"
/* 801DA6A0 001D7600 3C 80 80 3E */ lis r4, lbl_803E5CC0@ha
/* 801DA6A0 001D7600 3C 80 80 3E */ lis r4, __vt__24CScriptPlayerStateChange@ha
/* 801DA6A4 001D7604 7F 43 D3 78 */ mr r3, r26
/* 801DA6A8 001D7608 38 04 5C C0 */ addi r0, r4, lbl_803E5CC0@l
/* 801DA6A8 001D7608 38 04 5C C0 */ addi r0, r4, __vt__24CScriptPlayerStateChange@l
/* 801DA6AC 001D760C 90 1A 00 00 */ stw r0, 0(r26)
/* 801DA6B0 001D7610 93 7A 00 34 */ stw r27, 0x34(r26)
/* 801DA6B4 001D7614 93 9A 00 38 */ stw r28, 0x38(r26)

View File

@ -0,0 +1,77 @@
#ifndef _CCONTROLMAPPER
#define _CCONTROLMAPPER
class ControlMapper {
public:
enum ECommands {
kC_Forward,
kC_Backward,
kC_TurnLeft,
kC_TurnRight,
kC_StrafeLeft,
kC_StrafeRight,
kC_LookLeft,
kC_LookRight,
kC_LookUp,
kC_LookDown,
kC_JumpOrBoost = 10,
kC_FireOrBomb = 11,
kC_MissileOrPowerBomb = 12,
kC_Morph,
kC_AimUp,
kC_AimDown,
kC_CycleBeamUp,
kC_CycleBeamDown,
kC_CycleItem,
kC_PowerBeam,
kC_IceBeam,
kC_WaveBeam,
kC_PlasmaBeam,
kC_ToggleHolster = 23,
kC_OrbitClose,
kC_OrbitFar,
kC_OrbitObject,
kC_OrbitSelect,
kC_OrbitConfirm,
kC_OrbitLeft,
kC_OrbitRight,
kC_OrbitUp,
kC_OrbitDown,
kC_LookHold1,
kC_LookHold2,
kC_LookZoomIn,
kC_LookZoomOut,
kC_AimHold,
kC_MapCircleUp,
kC_MapCircleDown,
kC_MapCircleLeft,
kC_MapCircleRight,
kC_MapMoveForward,
kC_MapMoveBack,
kC_MapMoveLeft,
kC_MapMoveRight,
kC_MapZoomIn,
kC_MapZoomOut,
kC_SpiderBall,
kC_ChaseCamera,
kC_XrayVisor = 50,
kC_ThermoVisor = 51,
kC_InviroVisor = 52,
kC_NoVisor = 53,
kC_VisorMenu,
kC_VisorUp,
kC_VisorDown,
kC_ShowCrosshairs,
kC_UseSheild = 0x3B,
kC_ScanItem = 0x3C,
kC_PreviousPauseScreen = 0x41,
kC_NextPauseScreen = 0x42,
kC_UNKNOWN,
kC_None,
kC_MAX
};
static void SetCommandFiltered(ECommands cmd, bool filtered);
};
#endif // _CCONTROLMAPPER

View File

@ -0,0 +1,26 @@
#ifndef _CSCRIPTPLAYERSTATECHANGE
#define _CSCRIPTPLAYERSTATECHANGE
#include "MetroidPrime/CEntity.hpp"
class CScriptPlayerStateChange : public CEntity {
public:
enum EControl { kC_Unfiltered, kC_Filtered };
enum EControlCommandOption { kCCO_Unfiltered, kCCO_Filtered };
private:
int x34_itemType;
int x38_itemCount;
int x3c_itemCapacity;
EControl x40_ctrl;
EControlCommandOption x44_ctrlCmdOpt;
public:
CScriptPlayerStateChange(TUniqueId, const rstl::string&, const CEntityInfo&, bool, int, int, int, EControl,
EControlCommandOption);
void Accept(IVisitor& visit) override;
void AcceptScriptMsg(EScriptObjectMessage, TUniqueId, CStateManager&) override;
~CScriptPlayerStateChange();
};
#endif // _CSCRIPTPLAYERSTATECHANGE

View File

@ -0,0 +1,48 @@
#include "MetroidPrime/ScriptObjects/CScriptPlayerStateChange.hpp"
#include "MetroidPrime/CControlMapper.hpp"
#include "MetroidPrime/CStateManager.hpp"
#include "MetroidPrime/Player/CPlayerState.hpp"
CScriptPlayerStateChange::CScriptPlayerStateChange(TUniqueId uid, const rstl::string& name,
const CEntityInfo& info, bool active,
int itemType, int itemCount, int itemCapacity,
EControl control,
EControlCommandOption controlCmdOpt)
: CEntity(uid, info, active, name)
, x34_itemType(itemType)
, x38_itemCount(itemCount)
, x3c_itemCapacity(itemCapacity)
, x40_ctrl(control)
, x44_ctrlCmdOpt(controlCmdOpt) {}
void CScriptPlayerStateChange::Accept(IVisitor& visitor) { visitor.Visit(*this); }
void CScriptPlayerStateChange::AcceptScriptMsg(EScriptObjectMessage msg, TUniqueId objId,
CStateManager& stateMgr) override {
if (GetActive() && msg == kSM_SetToZero) {
stateMgr.PlayerState()->InitializePowerUp(CPlayerState::EItemType(x34_itemType),
x3c_itemCapacity);
stateMgr.PlayerState()->IncrPickUp(CPlayerState::EItemType(x34_itemType), x38_itemCount);
if (x44_ctrlCmdOpt != kCCO_Unfiltered) {
switch (x40_ctrl) {
case kC_Filtered:
bool filtered = !(1 - x44_ctrlCmdOpt);
ControlMapper::SetCommandFiltered(ControlMapper::kC_OrbitClose, filtered);
ControlMapper::SetCommandFiltered(ControlMapper::kC_OrbitConfirm, filtered);
ControlMapper::SetCommandFiltered(ControlMapper::kC_OrbitDown, filtered);
ControlMapper::SetCommandFiltered(ControlMapper::kC_OrbitFar, filtered);
ControlMapper::SetCommandFiltered(ControlMapper::kC_OrbitLeft, filtered);
ControlMapper::SetCommandFiltered(ControlMapper::kC_OrbitObject, filtered);
ControlMapper::SetCommandFiltered(ControlMapper::kC_OrbitRight, filtered);
ControlMapper::SetCommandFiltered(ControlMapper::kC_OrbitSelect, filtered);
ControlMapper::SetCommandFiltered(ControlMapper::kC_OrbitUp, filtered);
}
}
}
CEntity::AcceptScriptMsg(msg, objId, stateMgr);
}
CScriptPlayerStateChange::~CScriptPlayerStateChange() {}