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/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/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/MiniHoudaiAnimator.cpp">plugProjectNishimuraU/MiniHoudaiAnimator.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 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
};
#endif // ifdef __cplusplus

View File

@ -10,15 +10,6 @@ namespace Game {
namespace Cave {
enum NodeType { Item = 1, Gate };
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 {
s32 _00; // _00
@ -33,29 +24,30 @@ struct AdjustNode : public CNode {
AdjustNode();
AdjustNode(Adjust*);
virtual ~AdjustNode();
};
struct Door {
s32 _00;
s32 _04;
int m_direction;
int m_offset;
Door();
};
struct DoorNode : public CNode {
Door m_node; // _18
DoorNode();
~DoorNode() {};
inline void reset()
{
m_node._00 = -1;
m_node._04 = -1;
m_node.m_direction = -1;
m_node.m_offset = -1;
}
DoorNode(Door&);
bool isDoorAdjust(DoorNode*);
Door m_node; // _18
};
struct GateUnit {
@ -102,6 +94,37 @@ struct ItemNode : public ObjectLayoutNode {
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 {
UnitInfo* m_unitInfo; // _18
@ -130,6 +153,16 @@ struct MapNode : public CNode {
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 {
EnemyNode();
EnemyNode(EnemyUnit*, BaseGen*, int);

View File

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

View File

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

View File

@ -629,7 +629,7 @@ NISHIMURA:=\
$(BUILD_DIR)/asm/plugProjectNishimuraU/ShadowCylinder.o\
$(BUILD_DIR)/asm/plugProjectNishimuraU/playCamera.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/EnemyUnit.o\
$(BUILD_DIR)/asm/plugProjectNishimuraU/RandMapMgr.o\

View File

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

View File

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