Skip to content

Commit

Permalink
Link genEnemy.cpp
Browse files Browse the repository at this point in the history
TWENNY SIX BABY
  • Loading branch information
HeartPiece44 committed Sep 11, 2023
1 parent 8840c20 commit 0cf3bf5
Show file tree
Hide file tree
Showing 10 changed files with 525 additions and 4,844 deletions.
3,564 changes: 0 additions & 3,564 deletions asm/plugProjectYamashitaU/genEnemy.s

This file was deleted.

2 changes: 1 addition & 1 deletion configure.py
Original file line number Diff line number Diff line change
Expand Up @@ -846,7 +846,7 @@
["plugProjectYamashitaU/enemyInfo", True],
["plugProjectYamashitaU/farm", True],
["plugProjectYamashitaU/farmMgr", True],
"plugProjectYamashitaU/genEnemy",
["plugProjectYamashitaU/genEnemy", True],
["plugProjectYamashitaU/timeMgr", True],
["plugProjectYamashitaU/pelplantGenerator", True],
["plugProjectYamashitaU/enemyInteractActions", True],
Expand Down
4 changes: 2 additions & 2 deletions docs/recommended_todo.md
Original file line number Diff line number Diff line change
Expand Up @@ -165,8 +165,8 @@
| ---- | ---- | ---- | ---- |
| <a href="https://github.com/projectPiki/pikmin2/tree/main/src/plugProjectYamashitaU/lifeGaugeMgr.cpp">lifeGaugeMgr.cpp</a> | 18880 | <a href="https://github.com/projectPiki/pikmin2/tree/main/src/plugProjectYamashitaU/singleGS_ZukanParms.cpp">singleGS_ZukanParms.cpp</a> | 21445 |
| <a href="https://github.com/projectPiki/pikmin2/tree/main/src/plugProjectYamashitaU/enemyStoneDrawInfo.cpp">enemyStoneDrawInfo.cpp</a> | 21939 | <a href="https://github.com/projectPiki/pikmin2/tree/main/src/plugProjectYamashitaU/vtxAnm.cpp">vtxAnm.cpp</a> | 25420 |
| <a href="https://github.com/projectPiki/pikmin2/tree/main/src/plugProjectYamashitaU/carryInfoMgr.cpp">carryInfoMgr.cpp</a> | 47646 | <a href="https://github.com/projectPiki/pikmin2/tree/main/src/plugProjectYamashitaU/genEnemy.cpp">genEnemy.cpp</a> | 47838 |
| <a href="https://github.com/projectPiki/pikmin2/tree/main/src/plugProjectYamashitaU/enemyAction.cpp">enemyAction.cpp</a> | 55563 |
| <a href="https://github.com/projectPiki/pikmin2/tree/main/src/plugProjectYamashitaU/carryInfoMgr.cpp">carryInfoMgr.cpp</a> | 47646 | <a href="https://github.com/projectPiki/pikmin2/tree/main/src/plugProjectYamashitaU/generalEnemyMgr.cpp">generalEnemyMgr.cpp</a> | 55601 |
| <a href="https://github.com/projectPiki/pikmin2/tree/main/src/plugProjectYamashitaU/enemyAction.cpp">enemyAction.cpp</a> | 55613 |

### <section id="sysBootupU">sysBootupU</section>
| File | Size (bytes) | File | Size (bytes) |
Expand Down
4 changes: 2 additions & 2 deletions include/Game/enemyInfo.h
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ enum EEnemyTypeID {//ID Common Name
EnemyID_Bomb = 36, // Bomb-rock
EnemyID_Egg = 37, // Egg
EnemyID_PanModoki = 38, // Breadbug
EnemyID_PanModokiNest = 39, // Unused ID, INVALID
EnemyID_PanModokiNest = 39, // Breadbug Nest
EnemyID_OoPanModoki = 40, // Giant Breadbug
EnemyID_Fuefuki = 41, // Antenna Beetle
EnemyID_BlueChappy = 42, // Orange Bulborb
Expand All @@ -103,7 +103,7 @@ enum EEnemyTypeID {//ID Common Name
EnemyID_GasOtakara = 61, // Munge Dweevil
EnemyID_ElecOtakara = 62, // Anode Dweevil
EnemyID_Jigumo = 63, // Hermit Crawmad
EnemyID_INVALID2 = 64, // Unused ID
EnemyID_JigumoNest = 64, // Hermit Crawmad Nest
EnemyID_Imomushi = 65, // Ravenous Whiskerpillar
EnemyID_Houdai = 66, // Man-at-Legs
EnemyID_LeafChappy = 67, // Bulbmin
Expand Down
41 changes: 21 additions & 20 deletions include/Game/gameGenerator.h
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ struct GenArg : public CreatureInitArg {

inline GenArg() { }

virtual const char* getName(); // _08 (weak)
virtual const char* getName() { return "GenArg"; } // _08 (weak)

// _00 VTBL
Vector3f mPosition; // _04
Expand All @@ -133,7 +133,7 @@ struct GenBase : public Parameters {
virtual void doWrite(Stream&); // _08 (weak)
virtual void ramSaveParameters(Stream&); // _0C
virtual void ramLoadParameters(Stream&); // _10
virtual void doEvent(u32); // _14 (weak)
virtual void doEvent(u32) { } // _14 (weak)
virtual void doRead(Stream&); // _18 (weak)
virtual void update(Generator*); // _1C (weak)
virtual void render(Graphics&, Generator*); // _20 (weak)
Expand Down Expand Up @@ -161,12 +161,12 @@ struct EnemyGeneratorBase : public CNode {
{
}

virtual ~EnemyGeneratorBase() {}; // _08 (weak)
virtual void doWrite(Stream&); // _10 (weak)
virtual void doRead(Stream&); // _14 (weak)
virtual u32 getLatestVersion(); // _18 (weak)
virtual void draw(Graphics&, Generator*); // _1C (weak)
virtual void* getInitialParam(); // _20 (weak)
virtual ~EnemyGeneratorBase() { } // _08 (weak)
virtual void doWrite(Stream&) { } // _10 (weak)
virtual void doRead(Stream&) { } // _14 (weak)
virtual u32 getLatestVersion() { return '????'; } // _18 (weak)
virtual void draw(Graphics&, Generator*) { } // _1C (weak)
virtual void* getInitialParam() { return nullptr; } // _20 (weak)

// _00 VTBL

Expand All @@ -179,14 +179,17 @@ struct GenObject : public GenBase {
{
}

virtual void update(Game::Generator*); // _1C (weak)
virtual void render(Graphics&, Generator*); // _20 (weak)
virtual u32 getLatestVersion(); // _24
virtual void updateUseList(Generator*, int); // _2C
virtual Creature* generate(Generator*); // _30 (weak)
virtual Creature* birth(GenArg*) = 0; // _34
virtual void generatorMakeMatrix(Matrixf& genMatrix, Vector3f& position); // _38 (weak)
virtual void getDebugInfo(char*); // _3C (weak)
virtual void update(Game::Generator*) { } // _1C (weak)
virtual void render(Graphics&, Generator*); // _20 (weak)
virtual u32 getLatestVersion(); // _24
virtual void updateUseList(Generator*, int); // _2C
virtual Creature* generate(Generator*); // _30 (weak)
virtual Creature* birth(GenArg*) = 0; // _34
virtual void generatorMakeMatrix(Matrixf& genMatrix, Vector3f& position) // _38 (weak)
{
genMatrix.makeT(position);
}
virtual void getDebugInfo(char*) { } // _3C (weak)

// _0C = VTBL
// _00-_24 = GenBase
Expand Down Expand Up @@ -298,9 +301,9 @@ struct GenObjectPiki : public GenObject {
struct GenObjectEnemy : public GenObject {
GenObjectEnemy();

virtual void doWrite(Stream&); // _08
virtual void ramSaveParameters(Stream&); // _0C
virtual void ramLoadParameters(Stream&); // _10
virtual void doWrite(Stream&); // _08
virtual void doRead(Stream&); // _18
virtual void render(Graphics&, Generator*); // _20
virtual J3DModelData* getShape(); // _28
Expand All @@ -309,7 +312,7 @@ struct GenObjectEnemy : public GenObject {
virtual Creature* birth(GenArg*); // _34

static void initialise();
void createEnemyGenerator();
EnemyGeneratorBase* createEnemyGenerator();
void doReadOldVersion(Stream&);

EnemyTypeID::EEnemyTypeID mEnemyID; // _24
Expand All @@ -325,8 +328,6 @@ struct GenObjectEnemy : public GenObject {
u8 _4C; // _4C
};

GenObject* makeObjectEnemy();

/**
* @size{0x10}
*/
Expand Down
97 changes: 97 additions & 0 deletions include/trigNoInline.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
#ifndef _TRIG_H
#define _TRIG_H

#include "types.h"
#include "Vector3.h"
#include "JSystem/JMath.h"

#define TAU 6.2831855f

inline bool checkASinCosBounds(f32 x) { return (x >= -1.0f) && (x <= 1.0f); }

inline f32 pikmin2_acos(f32 x)
{
if (x >= 1.0f) {
return 0.0f;
} else if (x <= -1.0f) {
return PI;
} else if (x < 0.0f) {
f32 dumb = HALF_PI;
f32 acos = JMath::asinAcosTable_.mTable[(u32)(-x * 1023.5f)];
return acos + dumb;
} else {
return HALF_PI - JMath::asinAcosTable_.mTable[(u32)(x * 1023.5f)];
}
}

inline f32 angXZ(Vector3f& vec1, Vector3f& vec2)
{
Vector3f pos = vec1 - vec2;
return roundAng(JMAAtan2Radian(pos.x, pos.z));
}

inline f32 angXZ(f32 x, f32 z, Vector3f& vec)
{
Vector3f pos = vec;
return roundAng(JMAAtan2Radian(x - pos.x, z - pos.z));
}

inline f32 _angXZ(f32 x1, f32 z1, f32 x2, f32 z2) { return roundAng(JMAAtan2Radian(x1 - x2, z1 - z2)); }

inline int GetTableIdxNeg(f32 x) { return x *= -325.9493f; }

inline int GetTableIdxPos(f32 x) { return x *= 325.9493f; }

inline f32 altSin(f32 x)
{
if (x < 0.0f) {
return -JMath::sincosTable_.mTable[GetTableIdxNeg(x) & 0x7ffU].first;
}
return JMath::sincosTable_.mTable[GetTableIdxPos(x) & 0x7ffU].first;
}

inline f32 absF(f32 val)
{
f64 newVal = fabs(val);
return (f32)newVal;
}

inline f32 scaledSin(f32 theta) { return altSin(theta * TAU); }

inline f32 absVal(f32 val) { return (val > 0.0f) ? val : -val; }

inline int absVal(int val) { return (val > 0) ? val : -val; }

inline f32 boundVal(f32 val, f32 limit) { return (val > 0.0f) ? limit : -limit; }

inline f32 adjustVal(f32 y, f32 x, f32 delta)
{
f32 diff = absVal(y - x);

return (diff < delta) ? x : (y < x) ? y + delta : y - delta;
}

inline int adjustValInt(int current, int dest, const int delta)
{
return (absVal(current - dest) < delta) ? dest : (current < dest ? current += delta : current -= delta);
}

inline Vector3f getRotationOffset(f32 scale, f32 y, f32 angle)
{
return Vector3f(scale * pikmin2_sinf(angle), y, scale * pikmin2_cosf(angle));
}

inline Vector3f getRotation(f32 angle) { return Vector3f(pikmin2_sinf(angle), 0.0f, pikmin2_cosf(angle)); }

inline f32 clamp(f32 val, f32 limit)
{
// f64 abs = fabs(val);
if (absF(val) > limit) {
val = (val > 0.0f) ? limit : -limit;
}
return val;
}

inline Vector3f getDirection(f32 angle) { return Vector3f(pikmin2_sinf(angle), 0.0f, pikmin2_cosf(angle)); }

#endif
2 changes: 1 addition & 1 deletion src/plugProjectYamashitaU/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ YAMASHITA_FILES:=\
$(BUILD_DIR)/src/plugProjectYamashitaU/enemyInfo.o\
$(BUILD_DIR)/src/plugProjectYamashitaU/farm.o\
$(BUILD_DIR)/src/plugProjectYamashitaU/farmMgr.o\
$(BUILD_DIR)/asm/plugProjectYamashitaU/genEnemy.o\
$(BUILD_DIR)/src/plugProjectYamashitaU/genEnemy.o\
$(BUILD_DIR)/src/plugProjectYamashitaU/timeMgr.o\
$(BUILD_DIR)/src/plugProjectYamashitaU/pelplantGenerator.o\
$(BUILD_DIR)/src/plugProjectYamashitaU/enemyInteractActions.o\
Expand Down
2 changes: 1 addition & 1 deletion src/plugProjectYamashitaU/enemyInfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ char* getEnemyResName(int enemyID, int enemyFlags)
break;
}

if (enemyID == EnemyTypeID::EnemyID_PanModokiNest || enemyID == EnemyTypeID::EnemyID_INVALID2) {
if (enemyID == EnemyTypeID::EnemyID_PanModokiNest || enemyID == EnemyTypeID::EnemyID_JigumoNest) {
enemyID = EnemyTypeID::EnemyID_PanHouse;
}

Expand Down
Loading

0 comments on commit 0cf3bf5

Please sign in to comment.