Merge pull request #21 from projectPiki/MapUnit.cpp

MapUnit.cpp
This commit is contained in:
intns 2022-07-11 23:19:37 -05:00 committed by GitHub
commit a80f018c53
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 347 additions and 545 deletions

View File

@ -141,6 +141,7 @@ pikmin2.usa.dol: `sha1: 90d328bf8f190c90472e8c19e7e53c6ad0fe0d1a`
- <a href="https://github.com/projectPiki/pikmin2/tree/main/src/plugProjectNishimuraU/KumaKochappyAnimator.cpp">plugProjectNishimuraU/KumaKochappyAnimator.cpp</a> - <a href="https://github.com/projectPiki/pikmin2/tree/main/src/plugProjectNishimuraU/KumaKochappyAnimator.cpp">plugProjectNishimuraU/KumaKochappyAnimator.cpp</a>
- <a href="https://github.com/projectPiki/pikmin2/tree/main/src/plugProjectNishimuraU/KurageAnimator.cpp">plugProjectNishimuraU/KurageAnimator.cpp</a> - <a href="https://github.com/projectPiki/pikmin2/tree/main/src/plugProjectNishimuraU/KurageAnimator.cpp">plugProjectNishimuraU/KurageAnimator.cpp</a>
- <a href="https://github.com/projectPiki/pikmin2/tree/main/src/plugProjectNishimuraU/MapCreator.cpp">plugProjectNishimuraU/MapCreator.cpp</a> - <a href="https://github.com/projectPiki/pikmin2/tree/main/src/plugProjectNishimuraU/MapCreator.cpp">plugProjectNishimuraU/MapCreator.cpp</a>
- <a href="https://github.com/projectPiki/pikmin2/tree/main/src/plugProjectNishimuraU/MapUnit.cpp">plugProjectNishimuraU/MapUnit.cpp</a>
- <a href="https://github.com/projectPiki/pikmin2/tree/main/src/plugProjectNishimuraU/MarAnimator.cpp">plugProjectNishimuraU/MarAnimator.cpp</a> - <a href="https://github.com/projectPiki/pikmin2/tree/main/src/plugProjectNishimuraU/MarAnimator.cpp">plugProjectNishimuraU/MarAnimator.cpp</a>
- <a href="https://github.com/projectPiki/pikmin2/tree/main/src/plugProjectNishimuraU/MiniHoudaiAnimator.cpp">plugProjectNishimuraU/MiniHoudaiAnimator.cpp</a> - <a href="https://github.com/projectPiki/pikmin2/tree/main/src/plugProjectNishimuraU/MiniHoudaiAnimator.cpp">plugProjectNishimuraU/MiniHoudaiAnimator.cpp</a>
- <a href="https://github.com/projectPiki/pikmin2/tree/main/src/plugProjectNishimuraU/ObjectLayout.cpp">plugProjectNishimuraU/ObjectLayout.cpp</a> - <a href="https://github.com/projectPiki/pikmin2/tree/main/src/plugProjectNishimuraU/ObjectLayout.cpp">plugProjectNishimuraU/ObjectLayout.cpp</a>

View File

@ -919,6 +919,81 @@ float GXGetYScaleFactor(u16, u16);
void GXSetViewport(float, float, float, float, float, float); void GXSetViewport(float, float, float, float, float, float);
void GXSetTevKColor(GXTevKColorID, GXColor); void GXSetTevKColor(GXTevKColorID, GXColor);
// added GXPosition and GXFifo from smb-decomp/GXVert.h, thanks to encounter for doing this!
// need to confirm these are the same for Pikmin 2 - currently used by plugProjectNishimuraU/MapUnit.cpp in UnitInfo::draw()
#define GXFIFO_ADDR 0xCC008000
typedef union {
u8 u8;
u16 u16;
u32 u32;
u64 u64;
s8 s8;
s16 s16;
s32 s32;
s64 s64;
f32 f32;
f64 f64;
} PPCWGPipe;
volatile PPCWGPipe GXWGFifo : GXFIFO_ADDR;
static inline void GXPosition2f32(const f32 x, const f32 y)
{
GXWGFifo.f32 = x;
GXWGFifo.f32 = y;
}
static inline void GXPosition3s16(const s16 x, const s16 y, const s16 z)
{
GXWGFifo.s16 = x;
GXWGFifo.s16 = y;
GXWGFifo.s16 = z;
}
static inline void GXPosition3f32(const f32 x, const f32 y, const f32 z)
{
GXWGFifo.f32 = x;
GXWGFifo.f32 = y;
GXWGFifo.f32 = z;
}
static inline void GXNormal3f32(const f32 x, const f32 y, const f32 z)
{
GXWGFifo.f32 = x;
GXWGFifo.f32 = y;
GXWGFifo.f32 = z;
}
static inline void GXColor4u8(const u8 r, const u8 g, const u8 b, const u8 a)
{
GXWGFifo.u8 = r;
GXWGFifo.u8 = g;
GXWGFifo.u8 = b;
GXWGFifo.u8 = a;
}
static inline void GXTexCoord2s8(const s8 u, const s8 v)
{
GXWGFifo.s8 = u;
GXWGFifo.s8 = v;
}
static inline void GXTexCoord2s16(const s16 u, const s16 v)
{
GXWGFifo.s16 = u;
GXWGFifo.s16 = v;
}
static inline void GXTexCoord2f32(const f32 u, const f32 v)
{
GXWGFifo.f32 = u;
GXWGFifo.f32 = v;
}
static inline void GXEnd(void) { }
#ifdef __cplusplus #ifdef __cplusplus
}; };
#endif // ifdef __cplusplus #endif // ifdef __cplusplus

View File

@ -10,15 +10,6 @@ namespace Game {
namespace Cave { namespace Cave {
enum NodeType { Item = 1, Gate }; enum NodeType { Item = 1, Gate };
struct RandMapScore; struct RandMapScore;
struct EnemyUnit {
TekiInfo* m_tekiInfo; // _00
RandMapScore* m_mapScore; // _04
int _08; // _08
int m_tekiMax; // _0C
// counts and max amounts for enemy types (A = easy, B = hard, C = seam hazards, F = special)
int m_typeCount[4]; // _10 (_10 A, _14 B, _18 C, _1C F)
int m_typeMax[4]; // _20 (_20 A, _24 B, _28 C, _2C F)
};
struct Adjust { struct Adjust {
s32 _00; // _00 s32 _00; // _00
@ -33,29 +24,30 @@ struct AdjustNode : public CNode {
AdjustNode(); AdjustNode();
AdjustNode(Adjust*); AdjustNode(Adjust*);
virtual ~AdjustNode();
}; };
struct Door { struct Door {
s32 _00; int m_direction;
s32 _04; int m_offset;
Door(); Door();
}; };
struct DoorNode : public CNode { struct DoorNode : public CNode {
Door m_node; // _18
DoorNode(); DoorNode();
~DoorNode() {}; ~DoorNode() {};
inline void reset() inline void reset()
{ {
m_node._00 = -1; m_node.m_direction = -1;
m_node._04 = -1; m_node.m_offset = -1;
} }
DoorNode(Door&); DoorNode(Door&);
bool isDoorAdjust(DoorNode*); bool isDoorAdjust(DoorNode*);
Door m_node; // _18
}; };
struct GateUnit { struct GateUnit {
@ -102,6 +94,37 @@ struct ItemNode : public ObjectLayoutNode {
Vector3f m_position; // _28 Vector3f m_position; // _28
}; };
struct MapUnits {
MapUnits(JUTTexture*);
void setDoorNum(int doorNum);
void setUnitName(char* name);
void setUnitIndex(int idx);
void setUnitKind(int kind);
void setUnitSize(int sizeX, int sizeY);
void setBaseGenPtr(BaseGen* baseGen);
void setUnitTexture(JUTTexture*);
// unused/inlined:
char* getUnitName();
int getUnitIndex();
int getUnitKind();
int getUnitSizeX();
int getUnitSizeY();
BaseGen* getBaseGen();
JUTTexture* getUnitTexture();
DoorNode* m_doorNode; // _00
AdjustNode* m_doorCounts; // _04
JUTTexture* m_texture; // _08
BaseGen* m_baseGen; // _0C
char* m_name; // _10
int m_index; // _14
int m_kind; // _18
int m_sizeX; // _1C
int m_sizeY; // _20
};
struct MapNode : public CNode { struct MapNode : public CNode {
UnitInfo* m_unitInfo; // _18 UnitInfo* m_unitInfo; // _18
@ -130,6 +153,16 @@ struct MapNode : public CNode {
f32 getBaseGenGlobalDirection(BaseGen*); f32 getBaseGenGlobalDirection(BaseGen*);
}; };
struct EnemyUnit {
TekiInfo* m_tekiInfo; // _00
RandMapScore* m_mapScore; // _04
int _08; // _08
int m_tekiMax; // _0C
// counts and max amounts for enemy types (A = easy, B = hard, C = seam hazards, F = special)
int m_typeCount[4]; // _10 (_10 A, _14 B, _18 C, _1C F)
int m_typeMax[4]; // _20 (_20 A, _24 B, _28 C, _2C F)
};
struct EnemyNode : public ObjectLayoutNode { struct EnemyNode : public ObjectLayoutNode {
EnemyNode(); EnemyNode();
EnemyNode(EnemyUnit*, BaseGen*, int); EnemyNode(EnemyUnit*, BaseGen*, int);

View File

@ -4,6 +4,7 @@
#include "types.h" #include "types.h"
#include "CNode.h" #include "CNode.h"
#include "Vector3.h" #include "Vector3.h"
#include "JSystem/JUT/JUTTexture.h"
namespace Game { namespace Game {
struct ObjectLayoutNode : public CNode { struct ObjectLayoutNode : public CNode {
@ -28,20 +29,29 @@ namespace Cave {
enum CardinalDirection { CD_UP, CD_RIGHT, CD_DOWN, CD_LEFT }; enum CardinalDirection { CD_UP, CD_RIGHT, CD_DOWN, CD_LEFT };
struct DoorNode; struct DoorNode;
struct BaseGen; struct BaseGen;
struct AdjustNode;
struct MapUnits;
struct UnitInfo { struct UnitInfo {
DoorNode* m_doorNode; // _00 UnitInfo(MapUnits* mapUnits);
struct AdjustNode* m_adjustNode; // _04
struct MapUnits* m_mapUnits; // _08
int m_unitRotation; // _0C
int m_unitSizeX; // _10
int m_unitSizeY; // _14
void setUnitTexture(JUTTexture*);
void setUnitRotation(int rot);
void create();
char* getUnitName();
int getUnitKind();
int getUnitSizeX(); int getUnitSizeX();
int getUnitSizeY(); int getUnitSizeY();
int getUnitKind();
int getUnitRotation(); int getUnitRotation();
DoorNode* getDoorNode(int doorNum);
BaseGen* getBaseGen(); BaseGen* getBaseGen();
void draw(); void draw(float, float, float, float);
DoorNode* m_doorNode; // _00
AdjustNode* m_doorCounts; // _04
MapUnits* m_mapUnits; // _08
int m_unitRotation; // _0C
int m_unitSizeX; // _10
int m_unitSizeY; // _14
}; };
struct BaseGen; struct BaseGen;

View File

@ -3,6 +3,7 @@
#include "Dolphin/gx.h" #include "Dolphin/gx.h"
#include "types.h" #include "types.h"
#include "JSystem/ResTIMG.h"
struct JUTPalette; struct JUTPalette;
struct ResTIMG; struct ResTIMG;

View File

@ -629,7 +629,7 @@ NISHIMURA:=\
$(BUILD_DIR)/asm/plugProjectNishimuraU/ShadowCylinder.o\ $(BUILD_DIR)/asm/plugProjectNishimuraU/ShadowCylinder.o\
$(BUILD_DIR)/asm/plugProjectNishimuraU/playCamera.o\ $(BUILD_DIR)/asm/plugProjectNishimuraU/playCamera.o\
$(BUILD_DIR)/asm/plugProjectNishimuraU/shadowMgr.o\ $(BUILD_DIR)/asm/plugProjectNishimuraU/shadowMgr.o\
$(BUILD_DIR)/asm/plugProjectNishimuraU/MapUnit.o\ $(BUILD_DIR)/src/plugProjectNishimuraU/MapUnit.o\
$(BUILD_DIR)/asm/plugProjectNishimuraU/MapNode.o\ $(BUILD_DIR)/asm/plugProjectNishimuraU/MapNode.o\
$(BUILD_DIR)/asm/plugProjectNishimuraU/EnemyUnit.o\ $(BUILD_DIR)/asm/plugProjectNishimuraU/EnemyUnit.o\
$(BUILD_DIR)/asm/plugProjectNishimuraU/RandMapMgr.o\ $(BUILD_DIR)/asm/plugProjectNishimuraU/RandMapMgr.o\

View File

@ -42,8 +42,8 @@ AdjustNode::AdjustNode(Adjust* node)
* Size: 000010 * Size: 000010
*/ */
Door::Door() Door::Door()
: _00(-1) : m_direction(-1)
, _04(-1) , m_offset(-1)
{ {
} }
@ -65,8 +65,8 @@ DoorNode::DoorNode()
*/ */
DoorNode::DoorNode(Door& door) DoorNode::DoorNode(Door& door)
{ {
m_node._00 = door._00; m_node.m_direction = door.m_direction;
m_node._04 = door._04; m_node.m_offset = door.m_offset;
} }
/* /*
@ -76,8 +76,8 @@ DoorNode::DoorNode(Door& door)
*/ */
bool DoorNode::isDoorAdjust(DoorNode* other) bool DoorNode::isDoorAdjust(DoorNode* other)
{ {
s32 x = m_node._00; s32 x = m_node.m_direction;
s32 y = other->m_node._00; s32 y = other->m_node.m_direction;
if (!x && y == 2) { if (!x && y == 2) {
return true; return true;

View File

@ -1,4 +1,6 @@
#include "types.h" #include "types.h"
#include "Game/Cave/RandMapMgr.h"
#include "Dolphin/gx.h"
/* /*
Generated from dpostproc Generated from dpostproc
@ -20,60 +22,33 @@
namespace Game { namespace Game {
namespace Cave {
/* /*
* --INFO-- * --INFO--
* Address: 802427A8 * Address: 802427A8
* Size: 0000A4 * Size: 0000A4
*/ */
Cave::MapUnits::MapUnits(JUTTexture*) MapUnits::MapUnits(JUTTexture* texture)
{ {
/* // Constructor for MapUnits struct
stwu r1, -0x10(r1) // - sets texture and unit sizes based on input texture
mflr r0 // - constructs a new DoorNode
stw r0, 0x14(r1) // - sets everything else to 0 or -1 (whichever 'null' should be)
li r0, -1 m_texture = texture;
stw r31, 0xc(r1) m_baseGen = 0;
mr r31, r3 m_name = 0;
li r3, 0 m_index = -1;
stw r4, 8(r31) m_kind = -1;
stw r3, 0xc(r31) m_sizeX = -1;
stw r3, 0x10(r31) m_sizeY = -1;
stw r0, 0x14(r31) if (m_texture) {
stw r0, 0x18(r31) m_sizeX = ((u32)m_texture->_20->m_sizeX) >> 3;
stw r0, 0x1c(r31) m_sizeY = ((u32)m_texture->_20->m_sizeY) >> 3;
stw r0, 0x20(r31) }
lwz r3, 8(r31)
cmplwi r3, 0
beq lbl_80242810
lwz r3, 0x20(r3)
lhz r0, 2(r3)
srwi r0, r0, 3
stw r0, 0x1c(r31)
lwz r3, 8(r31)
lwz r3, 0x20(r3)
lhz r0, 4(r3)
srwi r0, r0, 3
stw r0, 0x20(r31)
lbl_80242810: m_doorNode = new DoorNode();
li r3, 0x20 m_doorCounts = 0;
bl __nw__FUl
or. r0, r3, r3
beq lbl_80242828
bl __ct__Q34Game4Cave8DoorNodeFv
mr r0, r3
lbl_80242828:
stw r0, 0(r31)
li r0, 0
mr r3, r31
stw r0, 4(r31)
lwz r31, 0xc(r1)
lwz r0, 0x14(r1)
mtlr r0
addi r1, r1, 0x10
blr
*/
} }
/* /*
@ -81,34 +56,10 @@ lbl_80242828:
* Address: 8024284C * Address: 8024284C
* Size: 000060 * Size: 000060
*/ */
void Cave::MapUnits::setDoorNum(int) void MapUnits::setDoorNum(int doorNum)
{ {
/* // Construct new AdjustNode array for number of doors
stwu r1, -0x10(r1) m_doorCounts = new AdjustNode[doorNum];
mflr r0
stw r0, 0x14(r1)
stw r31, 0xc(r1)
mr r31, r4
stw r30, 8(r1)
mr r30, r3
mulli r3, r31, 0x1c
addi r3, r3, 0x10
bl __nwa__FUl
lis r4, __ct__Q34Game4Cave10AdjustNodeFv@ha
lis r5, __dt__Q34Game4Cave10AdjustNodeFv@ha
addi r4, r4, __ct__Q34Game4Cave10AdjustNodeFv@l
mr r7, r31
addi r5, r5, __dt__Q34Game4Cave10AdjustNodeFv@l
li r6, 0x1c
bl __construct_new_array
stw r3, 4(r30)
lwz r0, 0x14(r1)
lwz r31, 0xc(r1)
lwz r30, 8(r1)
mtlr r0
addi r1, r1, 0x10
blr
*/
} }
/* /*
@ -116,83 +67,38 @@ void Cave::MapUnits::setDoorNum(int)
* Address: 802428AC * Address: 802428AC
* Size: 000060 * Size: 000060
*/ */
Cave::AdjustNode::~AdjustNode(void) AdjustNode::~AdjustNode() { }
{
/*
stwu r1, -0x10(r1)
mflr r0
stw r0, 0x14(r1)
stw r31, 0xc(r1)
mr r31, r4
stw r30, 8(r1)
or. r30, r3, r3
beq lbl_802428F0
lis r5, __vt__Q34Game4Cave10AdjustNode@ha
li r4, 0
addi r0, r5, __vt__Q34Game4Cave10AdjustNode@l
stw r0, 0(r30)
bl __dt__5CNodeFv
extsh. r0, r31
ble lbl_802428F0
mr r3, r30
bl __dl__FPv
lbl_802428F0:
lwz r0, 0x14(r1)
mr r3, r30
lwz r31, 0xc(r1)
lwz r30, 8(r1)
mtlr r0
addi r1, r1, 0x10
blr
*/
}
/* /*
* --INFO-- * --INFO--
* Address: 8024290C * Address: 8024290C
* Size: 000008 * Size: 000008
*/ */
void Cave::MapUnits::setUnitName(char* a1) void MapUnits::setUnitName(char* name) { m_name = name; }
{
// Generated from stw r4, 0x10(r3)
_10 = a1;
}
/* /*
* --INFO-- * --INFO--
* Address: 80242914 * Address: 80242914
* Size: 000008 * Size: 000008
*/ */
void Cave::MapUnits::setUnitIndex(int a1) void MapUnits::setUnitIndex(int idx) { m_index = idx; }
{
// Generated from stw r4, 0x14(r3)
_14 = a1;
}
/* /*
* --INFO-- * --INFO--
* Address: 8024291C * Address: 8024291C
* Size: 000008 * Size: 000008
*/ */
void Cave::MapUnits::setUnitKind(int a1) void MapUnits::setUnitKind(int kind) { m_kind = kind; }
{
// Generated from stw r4, 0x18(r3)
_18 = a1;
}
/* /*
* --INFO-- * --INFO--
* Address: 80242924 * Address: 80242924
* Size: 00000C * Size: 00000C
*/ */
void Cave::MapUnits::setUnitSize(int, int) void MapUnits::setUnitSize(int sizeX, int sizeY)
{ {
/* m_sizeX = sizeX;
stw r4, 0x1c(r3) m_sizeY = sizeY;
stw r5, 0x20(r3)
blr
*/
} }
/* /*
@ -200,128 +106,106 @@ void Cave::MapUnits::setUnitSize(int, int)
* Address: 80242930 * Address: 80242930
* Size: 000008 * Size: 000008
*/ */
void Cave::MapUnits::setBaseGenPtr(Game::Cave::BaseGen* a1) void MapUnits::setBaseGenPtr(BaseGen* baseGen) { m_baseGen = baseGen; }
{
// Generated from stw r4, 0xC(r3)
_0C = a1;
}
/* /*
* --INFO-- * --INFO--
* Address: ........ * Address: ........
* Size: 000008 * Size: 000008
*/ */
void Cave::MapUnits::setUnitTexture(JUTTexture*) // void Cave::MapUnits::setUnitTexture(JUTTexture*)
{ // {
// UNUSED FUNCTION // // UNUSED FUNCTION
} // }
/* /*
* --INFO-- * --INFO--
* Address: ........ * Address: ........
* Size: 000008 * Size: 000008
*/ */
void Cave::MapUnits::getUnitName(void) // char* Cave::MapUnits::getUnitName(void)
{ // {
// UNUSED FUNCTION // // UNUSED FUNCTION
} // }
/* /*
* --INFO-- * --INFO--
* Address: ........ * Address: ........
* Size: 000008 * Size: 000008
*/ */
void Cave::MapUnits::getUnitIndex(void) // int Cave::MapUnits::getUnitIndex(void)
{ // {
// UNUSED FUNCTION // // UNUSED FUNCTION
} // }
/* /*
* --INFO-- * --INFO--
* Address: ........ * Address: ........
* Size: 000008 * Size: 000008
*/ */
void Cave::MapUnits::getUnitKind(void) // int Cave::MapUnits::getUnitKind(void)
{ // {
// UNUSED FUNCTION // // UNUSED FUNCTION
} // }
/* /*
* --INFO-- * --INFO--
* Address: ........ * Address: ........
* Size: 000008 * Size: 000008
*/ */
void Cave::MapUnits::getUnitSizeX(void) // int Cave::MapUnits::getUnitSizeX(void)
{ // {
// UNUSED FUNCTION // // UNUSED FUNCTION
} // }
/* /*
* --INFO-- * --INFO--
* Address: ........ * Address: ........
* Size: 000008 * Size: 000008
*/ */
void Cave::MapUnits::getUnitSizeY(void) // int Cave::MapUnits::getUnitSizeY(void)
{ // {
// UNUSED FUNCTION // // UNUSED FUNCTION
} // }
/* /*
* --INFO-- * --INFO--
* Address: ........ * Address: ........
* Size: 000008 * Size: 000008
*/ */
void Cave::MapUnits::getBaseGen(void) // BaseGen* Cave::MapUnits::getBaseGen(void)
{ // {
// UNUSED FUNCTION // // UNUSED FUNCTION
} // }
/* /*
* --INFO-- * --INFO--
* Address: ........ * Address: ........
* Size: 000008 * Size: 000008
*/ */
void Cave::MapUnits::getUnitTexture(void) // JUTTexture* Cave::MapUnits::getUnitTexture(void)
{ // {
// UNUSED FUNCTION // // UNUSED FUNCTION
} // }
/* /*
* --INFO-- * --INFO--
* Address: 80242938 * Address: 80242938
* Size: 000064 * Size: 000064
*/ */
Cave::UnitInfo::UnitInfo(Game::Cave::MapUnits*) UnitInfo::UnitInfo(MapUnits* mapUnits)
{ {
/* // Constructor for UnitInfo struct
stwu r1, -0x10(r1) // - sets m_mapUnits to input mapUnits
mflr r0 // - creates new DoorNode
stw r0, 0x14(r1) // - sets everything else to 'null' (0 or -1 depending)
li r0, -1
stw r31, 0xc(r1)
mr r31, r3
stw r4, 8(r3)
li r3, 0x20
stw r0, 0xc(r31)
stw r0, 0x10(r31)
stw r0, 0x14(r31)
bl __nw__FUl
or. r0, r3, r3
beq lbl_80242978
bl __ct__Q34Game4Cave8DoorNodeFv
mr r0, r3
lbl_80242978: m_mapUnits = mapUnits;
stw r0, 0(r31) m_unitRotation = -1;
li r0, 0 m_unitSizeX = -1;
mr r3, r31 m_unitSizeY = -1;
stw r0, 4(r31) m_doorNode = new DoorNode;
lwz r31, 0xc(r1) m_doorCounts = 0;
lwz r0, 0x14(r1)
mtlr r0
addi r1, r1, 0x10
blr
*/
} }
/* /*
@ -329,178 +213,76 @@ lbl_80242978:
* Address: 8024299C * Address: 8024299C
* Size: 00000C * Size: 00000C
*/ */
void Cave::UnitInfo::setUnitTexture(JUTTexture*) void UnitInfo::setUnitTexture(JUTTexture* texture) { m_mapUnits->m_texture = texture; }
{
/*
lwz r3, 8(r3)
stw r4, 8(r3)
blr
*/
}
/* /*
* --INFO-- * --INFO--
* Address: 802429A8 * Address: 802429A8
* Size: 000008 * Size: 000008
*/ */
void Cave::UnitInfo::setUnitRotation(int a1) void UnitInfo::setUnitRotation(int rot) { m_unitRotation = rot; }
{
// Generated from stw r4, 0xC(r3)
_0C = a1;
}
/* /*
* --INFO-- * --INFO--
* Address: 802429B0 * Address: 802429B0
* Size: 0001BC * Size: 0001BC
*/ */
void Cave::UnitInfo::create(void) void UnitInfo::create()
{ {
/* // sets up unit sizes + directions based on details in m_mapUnits + current rotation
stwu r1, -0x10(r1)
mflr r0
stw r0, 0x14(r1)
stw r31, 0xc(r1)
mr r31, r3
stw r30, 8(r1)
lwz r3, 8(r3)
lwz r3, 0(r3)
lwz r30, 0x10(r3)
b lbl_80242A0C
lbl_802429D8: // load all door nodes from m_mapUnits into m_doorNode
li r3, 0x20 DoorNode* mapDoorNode = (DoorNode*)m_mapUnits->m_doorNode->m_child;
bl __nw__FUl for (mapDoorNode; mapDoorNode; mapDoorNode = (DoorNode*)mapDoorNode->m_next) {
or. r4, r3, r3 DoorNode* newDoorNode = new DoorNode();
beq lbl_802429F0 newDoorNode->m_node.m_direction = mapDoorNode->m_node.m_direction;
bl __ct__Q34Game4Cave8DoorNodeFv newDoorNode->m_node.m_offset = mapDoorNode->m_node.m_offset;
mr r4, r3 m_doorNode->add(newDoorNode);
}
lbl_802429F0: // get AdjustInfo* from m_mapUnits
lwz r0, 0x18(r30) m_doorCounts = m_mapUnits->m_doorCounts;
stw r0, 0x18(r4)
lwz r0, 0x1c(r30)
stw r0, 0x1c(r4)
lwz r3, 0(r31)
bl add__5CNodeFP5CNode
lwz r30, 4(r30)
lbl_80242A0C: // if unit is facing up or down, use X and Y as normal
cmplwi r30, 0 if ((m_unitRotation == 0) || (m_unitRotation == 2)) {
bne lbl_802429D8 m_unitSizeX = m_mapUnits->m_sizeX;
lwz r3, 8(r31) m_unitSizeY = m_mapUnits->m_sizeY;
lwz r0, 4(r3) } else { // if unit is facing left or right, swap X and Y
stw r0, 4(r31) m_unitSizeX = m_mapUnits->m_sizeY;
lwz r0, 0xc(r31) m_unitSizeY = m_mapUnits->m_sizeX;
cmpwi r0, 0 }
beq lbl_80242A34
cmpwi r0, 2
bne lbl_80242A50
lbl_80242A34: // set defaults for door offsets
lwz r3, 8(r31) int X = m_mapUnits->m_sizeX - 1;
lwz r0, 0x1c(r3) int Y = m_mapUnits->m_sizeY - 1;
stw r0, 0x10(r31)
lwz r3, 8(r31)
lwz r0, 0x20(r3)
stw r0, 0x14(r31)
b lbl_80242A68
lbl_80242A50: // set all door offsets based on their directions
lwz r3, 8(r31) DoorNode* unitDoorNode = (DoorNode*)m_doorNode->m_child;
lwz r0, 0x20(r3) for (unitDoorNode; unitDoorNode; unitDoorNode = (DoorNode*)unitDoorNode->m_next) {
stw r0, 0x10(r31)
lwz r3, 8(r31)
lwz r0, 0x1c(r3)
stw r0, 0x14(r31)
lbl_80242A68: int doorDir = unitDoorNode->m_node.m_direction; // default direction
lwz r4, 8(r31) int newDirection = (doorDir + m_unitRotation) % 4; // rotate with unit
lwz r3, 0(r31)
lwz r5, 0x1c(r4)
lwz r4, 0x20(r4)
lwz r6, 0x10(r3)
addi r5, r5, -1
addi r4, r4, -1
b lbl_80242B4C
lbl_80242A88: unitDoorNode->m_node.m_direction = newDirection; // set as new door direction
lwz r7, 0x18(r6) // set offset based on new direction vs old direction
lwz r0, 0xc(r31) if (doorDir == 0) { // old = up
cmpwi r7, 0 if ((newDirection == 2) || (newDirection == 3)) { // new = down or left
add r3, r7, r0 unitDoorNode->m_node.m_offset = (X - unitDoorNode->m_node.m_offset);
slwi r0, r3, 0x1e }
srwi r3, r3, 0x1f } else if (doorDir == 1) { // old = right
subf r0, r3, r0 if ((newDirection == 2) || (newDirection == 3)) { // new = down or left
rotlwi r0, r0, 2 unitDoorNode->m_node.m_offset = (Y - unitDoorNode->m_node.m_offset);
add r0, r0, r3 }
stw r0, 0x18(r6) } else if (doorDir == 2) { // old = down
bne lbl_80242AD4 if ((newDirection == 0) || (newDirection == 1)) { // new = up or right
cmpwi r0, 2 unitDoorNode->m_node.m_offset = (X - unitDoorNode->m_node.m_offset);
beq lbl_80242AC4 }
cmpwi r0, 3 } else if (doorDir == 3) { // old = left
bne lbl_80242B48 if ((newDirection == 0) || (newDirection == 1)) { // new = up or right
unitDoorNode->m_node.m_offset = (Y - unitDoorNode->m_node.m_offset);
lbl_80242AC4: }
lwz r0, 0x1c(r6) }
subf r0, r0, r5 }
stw r0, 0x1c(r6)
b lbl_80242B48
lbl_80242AD4:
cmpwi r7, 1
bne lbl_80242AFC
cmpwi r0, 2
beq lbl_80242AEC
cmpwi r0, 3
bne lbl_80242B48
lbl_80242AEC:
lwz r0, 0x1c(r6)
subf r0, r0, r4
stw r0, 0x1c(r6)
b lbl_80242B48
lbl_80242AFC:
cmpwi r7, 2
bne lbl_80242B24
cmpwi r0, 0
beq lbl_80242B14
cmpwi r0, 1
bne lbl_80242B48
lbl_80242B14:
lwz r0, 0x1c(r6)
subf r0, r0, r5
stw r0, 0x1c(r6)
b lbl_80242B48
lbl_80242B24:
cmpwi r7, 3
bne lbl_80242B48
cmpwi r0, 0
beq lbl_80242B3C
cmpwi r0, 1
bne lbl_80242B48
lbl_80242B3C:
lwz r0, 0x1c(r6)
subf r0, r0, r4
stw r0, 0x1c(r6)
lbl_80242B48:
lwz r6, 4(r6)
lbl_80242B4C:
cmplwi r6, 0
bne lbl_80242A88
lwz r0, 0x14(r1)
lwz r31, 0xc(r1)
lwz r30, 8(r1)
mtlr r0
addi r1, r1, 0x10
blr
*/
} }
/* /*
@ -508,231 +290,131 @@ lbl_80242B4C:
* Address: 80242B6C * Address: 80242B6C
* Size: 00000C * Size: 00000C
*/ */
void Cave::UnitInfo::getUnitName(void) char* UnitInfo::getUnitName() { return m_mapUnits->m_name; }
{
/*
lwz r3, 8(r3)
lwz r3, 0x10(r3)
blr
*/
}
/* /*
* --INFO-- * --INFO--
* Address: ........ * Address: ........
* Size: 00000C * Size: 00000C
*/ */
void Cave::UnitInfo::getUnitIndex(void) // int Cave::UnitInfo::getUnitIndex(void)
{ // {
// UNUSED FUNCTION // // UNUSED FUNCTION
} // }
/* /*
* --INFO-- * --INFO--
* Address: 80242B78 * Address: 80242B78
* Size: 00000C * Size: 00000C
*/ */
void Cave::UnitInfo::getUnitKind(void) int UnitInfo::getUnitKind() { return m_mapUnits->m_kind; }
{
/*
lwz r3, 8(r3)
lwz r3, 0x18(r3)
blr
*/
}
/* /*
* --INFO-- * --INFO--
* Address: 80242B84 * Address: 80242B84
* Size: 000008 * Size: 000008
*/ */
void Cave::UnitInfo::getUnitSizeX(void) int UnitInfo::getUnitSizeX() { return m_unitSizeX; }
{
/*
lwz r3, 0x10(r3)
blr
*/
}
/* /*
* --INFO-- * --INFO--
* Address: 80242B8C * Address: 80242B8C
* Size: 000008 * Size: 000008
*/ */
void Cave::UnitInfo::getUnitSizeY(void) int UnitInfo::getUnitSizeY() { return m_unitSizeY; }
{
/*
lwz r3, 0x14(r3)
blr
*/
}
/* /*
* --INFO-- * --INFO--
* Address: 80242B94 * Address: 80242B94
* Size: 000008 * Size: 000008
*/ */
void Cave::UnitInfo::getUnitRotation(void) int UnitInfo::getUnitRotation() { return m_unitRotation; }
{
/*
lwz r3, 0xc(r3)
blr
*/
}
/* /*
* --INFO-- * --INFO--
* Address: 80242B9C * Address: 80242B9C
* Size: 000024 * Size: 000024
*/ */
void Cave::UnitInfo::getDoorNode(int) DoorNode* UnitInfo::getDoorNode(int doorNum) { return (DoorNode*)m_doorNode->getChildAt(doorNum); }
{
/*
stwu r1, -0x10(r1)
mflr r0
stw r0, 0x14(r1)
lwz r3, 0(r3)
bl getChildAt__5CNodeFi
lwz r0, 0x14(r1)
mtlr r0
addi r1, r1, 0x10
blr
*/
}
/* /*
* --INFO-- * --INFO--
* Address: 80242BC0 * Address: 80242BC0
* Size: 00000C * Size: 00000C
*/ */
void Cave::UnitInfo::getBaseGen(void) BaseGen* UnitInfo::getBaseGen() { return m_mapUnits->m_baseGen; }
{
/*
lwz r3, 8(r3)
lwz r3, 0xc(r3)
blr
*/
}
/* /*
* --INFO-- * --INFO--
* Address: 80242BCC * Address: 80242BCC
* Size: 00018C * Size: 00018C
*/ */
void Cave::UnitInfo::draw(float, float, float, float) // shout outs to encounter for adding the GXFifo stuff from SMB
void UnitInfo::draw(float p0, float p1, float p2, float p3)
{ {
/* // Draw texture for UnitInfo based on rotation and
stwu r1, -0x70(r1) // m_mapUnits->m_texture
mflr r0 JUTTexture* texture = m_mapUnits->m_texture;
stw r0, 0x74(r1) if (texture) {
stfd f31, 0x60(r1) // default first-input GX coords
psq_st f31, 104(r1), 0, qr0 s8 u0 = 0;
stfd f30, 0x50(r1) s8 u1 = 16;
psq_st f30, 88(r1), 0, qr0 s8 u2 = 16;
stfd f29, 0x40(r1) s8 u3 = 0;
psq_st f29, 72(r1), 0, qr0
stfd f28, 0x30(r1)
psq_st f28, 56(r1), 0, qr0
stmw r24, 0x10(r1)
lwz r4, 8(r3)
fmr f28, f1
fmr f29, f2
lwz r4, 8(r4)
fmr f30, f3
fmr f31, f4
cmplwi r4, 0
beq lbl_80242D24
lwz r0, 0xc(r3)
li r31, 0
li r30, 0x10
li r29, 0x10
cmpwi r0, 2
li r28, 0
li r27, 0
li r26, 0
li r25, 0x10
li r24, 0x10
beq lbl_80242C7C
bge lbl_80242C5C
cmpwi r0, 0
beq lbl_80242CB0
bge lbl_80242C68
b lbl_80242CB0
lbl_80242C5C: // default second-input GX coords
cmpwi r0, 4 s8 v0 = 0;
bge lbl_80242CB0 s8 v1 = 0;
b lbl_80242CA0 s8 v2 = 16;
s8 v3 = 16;
lbl_80242C68: // modify GX coords based on rotation of unit
li r30, 0 switch (m_unitRotation) {
li r28, 0x10 case 0: // facing up/default, no rotation
li r27, 0x10 break;
li r25, 0 case 1: // facing right
b lbl_80242CB0 u1 = 0;
u3 = 16;
lbl_80242C7C: v0 = 16;
li r31, 0x10 v2 = 0;
li r30, 0 break;
li r29, 0 case 2: // facing down
li r28, 0x10 u0 = 16;
li r27, 0x10 u1 = 0;
li r26, 0x10 u2 = 0;
li r25, 0 u3 = 16;
li r24, 0
b lbl_80242CB0
lbl_80242CA0: v0 = 16;
li r31, 0x10 v1 = 16;
li r29, 0 v2 = 0;
li r26, 0x10 v3 = 0;
li r24, 0 break;
case 3: // facing left
u0 = 16;
u2 = 0;
lbl_80242CB0: v1 = 16;
mr r3, r4 v3 = 0;
li r4, 0 break;
bl load__10JUTTextureF11_GXTexMapID }
li r3, 0x80 // set GX positions and coords
li r4, 0 texture->load(GX_TEXMAP0);
li r5, 4
bl GXBegin
lis r3, 0xCC008000@ha
lfs f0, lbl_8051A6D8@sda21(r2)
stfs f28, 0xCC008000@l(r3)
stfs f29, -0x8000(r3)
stfs f0, -0x8000(r3)
stb r31, -0x8000(r3)
stb r27, -0x8000(r3)
stfs f30, -0x8000(r3)
stfs f29, -0x8000(r3)
stfs f0, -0x8000(r3)
stb r30, -0x8000(r3)
stb r26, -0x8000(r3)
stfs f30, -0x8000(r3)
stfs f31, -0x8000(r3)
stfs f0, -0x8000(r3)
stb r29, -0x8000(r3)
stb r25, -0x8000(r3)
stfs f28, -0x8000(r3)
stfs f31, -0x8000(r3)
stfs f0, -0x8000(r3)
stb r28, -0x8000(r3)
stb r24, -0x8000(r3)
lbl_80242D24: GXBegin(GX_QUADS, GX_VTXFMT0, 4);
psq_l f31, 104(r1), 0, qr0 float z = 0;
lfd f31, 0x60(r1) GXPosition3f32(p0, p1, z);
psq_l f30, 88(r1), 0, qr0 GXTexCoord2s8(u0, v0);
lfd f30, 0x50(r1)
psq_l f29, 72(r1), 0, qr0 GXPosition3f32(p2, p1, z);
lfd f29, 0x40(r1) GXTexCoord2s8(u1, v1);
psq_l f28, 56(r1), 0, qr0
lfd f28, 0x30(r1) GXPosition3f32(p2, p3, z);
lmw r24, 0x10(r1) GXTexCoord2s8(u2, v2);
lwz r0, 0x74(r1)
mtlr r0 GXPosition3f32(p0, p3, z);
addi r1, r1, 0x70 GXTexCoord2s8(u3, v3);
blr }
*/
} }
} // namespace Cave
} // namespace Game } // namespace Game