Add CScriptAreaAttributes

Former-commit-id: 62e9ad1c54
This commit is contained in:
Henrique Gemignani Passos Lima 2022-10-14 19:03:05 +03:00
parent aa5ec0fac4
commit add73abd49
10 changed files with 109 additions and 17 deletions

View File

@ -167,8 +167,8 @@ lbl_8020FF34:
/* 8020FF54 0020CEB4 38 21 00 30 */ addi r1, r1, 0x30
/* 8020FF58 0020CEB8 4E 80 00 20 */ blr
.global SetFxDensity__13CEnvFxManagerFv
SetFxDensity__13CEnvFxManagerFv:
.global SetFxDensity__13CEnvFxManagerFif
SetFxDensity__13CEnvFxManagerFif:
/* 8020FF5C 0020CEBC 94 21 FF F0 */ stwu r1, -0x10(r1)
/* 8020FF60 0020CEC0 6C 84 80 00 */ xoris r4, r4, 0x8000
/* 8020FF64 0020CEC4 3C 00 43 30 */ lis r0, 0x4330

View File

@ -536,8 +536,8 @@ sub_8005e1fc:
/* 8005E208 0005B168 D0 43 11 24 */ stfs f2, 0x1124(r3)
/* 8005E20C 0005B16C 4E 80 00 20 */ blr
.global sub_8005e210
sub_8005e210:
.global SetAreaAttributes__9CGameAreaFPC21CScriptAreaAttributes
SetAreaAttributes__9CGameAreaFPC21CScriptAreaAttributes:
/* 8005E210 0005B170 80 A3 01 2C */ lwz r5, 0x12c(r3)
/* 8005E214 0005B174 28 04 00 00 */ cmplwi r4, 0
/* 8005E218 0005B178 90 85 10 D8 */ stw r4, 0x10d8(r5)

View File

@ -13037,7 +13037,7 @@ lbl_800D0E18:
/* 800D0ED8 000CDE38 7F E8 FB 78 */ mr r8, r31
/* 800D0EDC 000CDE3C 7F 69 DB 78 */ mr r9, r27
/* 800D0EE0 000CDE40 38 81 00 0C */ addi r4, r1, 0xc
/* 800D0EE4 000CDE44 48 0E C6 E5 */ bl __ct__21CScriptAreaAttributesF9TUniqueIdRC11CEntityInfob10EEnvFxTypeffffi11EPhazonType
/* 800D0EE4 000CDE44 48 0E C6 E5 */ bl __ct__21CScriptAreaAttributesF9TUniqueIdRC11CEntityInfob10EEnvFxTypeffffUi11EPhazonType
/* 800D0EE8 000CDE48 7C 7E 1B 78 */ mr r30, r3
lbl_800D0EEC:
/* 800D0EEC 000CDE4C 7F C3 F3 78 */ mr r3, r30

View File

@ -3,8 +3,8 @@
.section .data
.balign 8
.global lbl_803E52F8
lbl_803E52F8:
.global __vt__21CScriptAreaAttributes
__vt__21CScriptAreaAttributes:
# ROM: 0x3E22F8
.4byte 0
.4byte 0
@ -27,9 +27,9 @@ __dt__21CScriptAreaAttributesFv:
/* 801BD45C 001BA3BC 93 C1 00 08 */ stw r30, 8(r1)
/* 801BD460 001BA3C0 7C 7E 1B 79 */ or. r30, r3, r3
/* 801BD464 001BA3C4 41 82 00 28 */ beq lbl_801BD48C
/* 801BD468 001BA3C8 3C A0 80 3E */ lis r5, lbl_803E52F8@ha
/* 801BD468 001BA3C8 3C A0 80 3E */ lis r5, __vt__21CScriptAreaAttributes@ha
/* 801BD46C 001BA3CC 38 80 00 00 */ li r4, 0
/* 801BD470 001BA3D0 38 05 52 F8 */ addi r0, r5, lbl_803E52F8@l
/* 801BD470 001BA3D0 38 05 52 F8 */ addi r0, r5, __vt__21CScriptAreaAttributes@l
/* 801BD474 001BA3D4 90 1E 00 00 */ stw r0, 0(r30)
/* 801BD478 001BA3D8 4B E9 3D FD */ bl __dt__7CEntityFv
/* 801BD47C 001BA3DC 7F E0 07 35 */ extsh. r0, r31
@ -96,11 +96,11 @@ lbl_801BD53C:
/* 801BD550 001BA4B0 7F A4 EB 78 */ mr r4, r29
/* 801BD554 001BA4B4 90 A1 00 10 */ stw r5, 0x10(r1)
/* 801BD558 001BA4B8 7C 63 00 2E */ lwzx r3, r3, r0
/* 801BD55C 001BA4BC 4B EA 0C B5 */ bl sub_8005e210
/* 801BD55C 001BA4BC 4B EA 0C B5 */ bl SetAreaAttributes__9CGameAreaFPC21CScriptAreaAttributes
/* 801BD560 001BA4C0 80 7F 08 80 */ lwz r3, 0x880(r31)
/* 801BD564 001BA4C4 38 80 01 F4 */ li r4, 0x1f4
/* 801BD568 001BA4C8 C0 3D 00 3C */ lfs f1, 0x3c(r29)
/* 801BD56C 001BA4CC 48 05 29 F1 */ bl SetFxDensity__13CEnvFxManagerFv
/* 801BD56C 001BA4CC 48 05 29 F1 */ bl SetFxDensity__13CEnvFxManagerFif
/* 801BD570 001BA4D0 48 00 00 3C */ b lbl_801BD5AC
lbl_801BD574:
/* 801BD574 001BA4D4 80 9F 08 50 */ lwz r4, 0x850(r31)
@ -116,7 +116,7 @@ lbl_801BD574:
/* 801BD59C 001BA4FC 90 A1 00 14 */ stw r5, 0x14(r1)
/* 801BD5A0 001BA500 38 80 00 00 */ li r4, 0
/* 801BD5A4 001BA504 90 A1 00 0C */ stw r5, 0xc(r1)
/* 801BD5A8 001BA508 4B EA 0C 69 */ bl sub_8005e210
/* 801BD5A8 001BA508 4B EA 0C 69 */ bl SetAreaAttributes__9CGameAreaFPC21CScriptAreaAttributes
lbl_801BD5AC:
/* 801BD5AC 001BA50C 80 01 00 44 */ lwz r0, 0x44(r1)
/* 801BD5B0 001BA510 83 E1 00 3C */ lwz r31, 0x3c(r1)
@ -126,8 +126,8 @@ lbl_801BD5AC:
/* 801BD5C0 001BA520 38 21 00 40 */ addi r1, r1, 0x40
/* 801BD5C4 001BA524 4E 80 00 20 */ blr
.global __ct__21CScriptAreaAttributesF9TUniqueIdRC11CEntityInfob10EEnvFxTypeffffi11EPhazonType
__ct__21CScriptAreaAttributesF9TUniqueIdRC11CEntityInfob10EEnvFxTypeffffi11EPhazonType:
.global __ct__21CScriptAreaAttributesF9TUniqueIdRC11CEntityInfob10EEnvFxTypeffffUi11EPhazonType
__ct__21CScriptAreaAttributesF9TUniqueIdRC11CEntityInfob10EEnvFxTypeffffUi11EPhazonType:
/* 801BD5C8 001BA528 94 21 FF A0 */ stwu r1, -0x60(r1)
/* 801BD5CC 001BA52C 7C 08 02 A6 */ mflr r0
/* 801BD5D0 001BA530 90 01 00 64 */ stw r0, 0x64(r1)
@ -160,9 +160,9 @@ __ct__21CScriptAreaAttributesF9TUniqueIdRC11CEntityInfob10EEnvFxTypeffffi11EPhaz
/* 801BD63C 001BA59C 4B E9 3C E9 */ bl "__ct__7CEntityF9TUniqueIdRC11CEntityInfobRCQ24rstl66basic_string<c,Q24rstl14char_traits<c>,Q24rstl17rmemory_allocator>"
/* 801BD640 001BA5A0 38 61 00 0C */ addi r3, r1, 0xc
/* 801BD644 001BA5A4 48 18 04 9D */ bl "internal_dereference__Q24rstl66basic_string<c,Q24rstl14char_traits<c>,Q24rstl17rmemory_allocator>Fv"
/* 801BD648 001BA5A8 3C 60 80 3E */ lis r3, lbl_803E52F8@ha
/* 801BD648 001BA5A8 3C 60 80 3E */ lis r3, __vt__21CScriptAreaAttributes@ha
/* 801BD64C 001BA5AC 39 61 00 60 */ addi r11, r1, 0x60
/* 801BD650 001BA5B0 38 03 52 F8 */ addi r0, r3, lbl_803E52F8@l
/* 801BD650 001BA5B0 38 03 52 F8 */ addi r0, r3, __vt__21CScriptAreaAttributes@l
/* 801BD654 001BA5B4 90 19 00 00 */ stw r0, 0(r25)
/* 801BD658 001BA5B8 7F 23 CB 78 */ mr r3, r25
/* 801BD65C 001BA5BC 88 19 00 34 */ lbz r0, 0x34(r25)

View File

@ -3678,7 +3678,7 @@ lbl_80152324:
/* 80152338 0014F298 C0 3F 00 FC */ lfs f1, 0xfc(r31)
/* 8015233C 0014F29C D8 01 01 50 */ stfd f0, 0x150(r1)
/* 80152340 0014F2A0 80 81 01 54 */ lwz r4, 0x154(r1)
/* 80152344 0014F2A4 48 0B DC 19 */ bl SetFxDensity__13CEnvFxManagerFv
/* 80152344 0014F2A4 48 0B DC 19 */ bl SetFxDensity__13CEnvFxManagerFif
/* 80152348 0014F2A8 48 00 05 58 */ b lbl_801528A0
lbl_8015234C:
/* 8015234C 0014F2AC 2C 1C 00 13 */ cmpwi r28, 0x13

View File

@ -18,6 +18,8 @@
class CGenDescription;
class CTexture;
enum EPhazonType { kPT_None, kPT_Blue, kPT_Orange };
class CVectorFixed8_8 {
private:
short x;

View File

@ -31,6 +31,7 @@ public:
class Dock;
class CToken;
class IDvdRequest;
class CScriptAreaAttributes;
class CGameArea : public IGameArea {
public:
@ -47,6 +48,8 @@ public:
bool IsLoaded() const { return xf0_24_postConstructed; }
bool IsActive() const { return xf0_25_active; }
void SetAreaAttributes(const CScriptAreaAttributes* areaAttributes);
private:
enum EPhase {
kP_LoadHeader,

View File

@ -11,6 +11,7 @@
#include "rstl/string.hpp"
class CMapWorld;
class CModel;
class IGameArea;
class IWorld {
@ -60,6 +61,7 @@ public:
const CGameArea& GetAreaAlways(TAreaId id) const { return *x18_areas[id.Value()]; }
const CGameArea* GetArea(TAreaId id) const { return x18_areas[id.Value()].get(); }
CGameArea* Area(TAreaId id) { return x18_areas[id.Value()].get(); }
bool IsAreaValid(TAreaId id) const { return x18_areas[id.Value()]->IsLoaded(); }
CAssetId GetWorldAssetId() const { return x8_mlvlId; }
TAreaId GetAreaIdForSaveId(int saveId) const;

View File

@ -0,0 +1,38 @@
#ifndef _CSCRIPTAREAATTRIBUTES
#define _CSCRIPTAREAATTRIBUTES
#include "MetroidPrime/CEntity.hpp"
#include "MetroidPrime/CEnvFxManager.hpp"
#include "MetroidPrime/CWorld.hpp"
class CScriptAreaAttributes : public CEntity {
bool x34_24_showSkybox : 1;
EEnvFxType x38_envFx;
float x3c_envFxDensity;
float x40_thermalHeat;
float x44_xrayFogDistance;
float x48_worldLightingLevel;
CAssetId x4c_skybox;
EPhazonType x50_phazon;
public:
CScriptAreaAttributes(TUniqueId uid, const CEntityInfo& info, bool showSkybox, EEnvFxType fxType, float envFxDensity,
float thermalHeat, float xrayFogDistance, float worldLightingLevel, CAssetId skybox,
EPhazonType phazonType);
void AcceptScriptMsg(EScriptObjectMessage msg, TUniqueId objId, CStateManager& stateMgr) override;
void Accept(IVisitor& visitor) override;
~CScriptAreaAttributes();
bool GetNeedsSky() const { return x34_24_showSkybox; }
bool GetNeedsEnvFx() const { return x38_envFx != kEFX_None; }
CAssetId GetSkyModel() const { return x4c_skybox; }
EEnvFxType GetEnvFxType() const { return x38_envFx; }
float GetEnvFxDensity() const { return x3c_envFxDensity; }
float GetThermalHeat() const { return x40_thermalHeat; }
float GetXRayFogDistance() const { return x44_xrayFogDistance; }
float GetWorldLightingLevel() const { return x48_worldLightingLevel; }
EPhazonType GetPhazonType() const { return x50_phazon; }
};
#endif // _CSCRIPTAREAATTRIBUTES

View File

@ -0,0 +1,47 @@
#include "MetroidPrime/ScriptObjects/CScriptAreaAttributes.hpp"
CScriptAreaAttributes::CScriptAreaAttributes(TUniqueId uid, const CEntityInfo& info,
bool showSkybox, EEnvFxType fxType, float envFxDensity,
float thermalHeat, float xrayFogDistance,
float worldLightingLevel, CAssetId skybox,
EPhazonType phazonType)
: CEntity(uid, info, true, rstl::string_l(""))
, x34_24_showSkybox(showSkybox)
, x38_envFx(fxType)
, x3c_envFxDensity(envFxDensity)
, x40_thermalHeat(thermalHeat)
, x44_xrayFogDistance(xrayFogDistance)
, x48_worldLightingLevel(worldLightingLevel)
, x4c_skybox(skybox)
, x50_phazon(phazonType) {}
void CScriptAreaAttributes::AcceptScriptMsg(EScriptObjectMessage msg, TUniqueId objId,
CStateManager& stateMgr) override {
CEntity::AcceptScriptMsg(msg, objId, stateMgr);
if (x4_areaId == kInvalidAreaId) {
return;
}
switch (msg) {
case kSM_InitializedInArea: {
TAreaId areaId = x4_areaId;
stateMgr.World()->Area(areaId)->SetAreaAttributes(this);
stateMgr.EnvFxManager()->SetFxDensity(500, x3c_envFxDensity);
break;
}
case kSM_Deleted: {
TAreaId areaId = x4_areaId;
CGameArea* area = stateMgr.World()->Area(areaId);
if (area->IsLoaded()) {
area->SetAreaAttributes(nullptr);
}
}
}
}
void CScriptAreaAttributes::Accept(IVisitor& visitor) override { visitor.Visit(*this); }
CScriptAreaAttributes::~CScriptAreaAttributes() {}