Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions configure.py
Original file line number Diff line number Diff line change
Expand Up @@ -556,7 +556,7 @@ def MatchingFor(*versions):
Object(Matching, "SB/Game/zNPCTypes.cpp"),
Object(NonMatching, "SB/Game/zNPCTypeCommon.cpp", extra_cflags=["-sym on"]),
Object(NonMatching, "SB/Game/zNPCTypeRobot.cpp"),
Object(NonMatching, "SB/Game/zNPCTypeVillager.cpp"),
Object(NonMatching, "SB/Game/zNPCTypeVillager.cpp", extra_cflags=["-sym on"]),
Object(NonMatching, "SB/Game/zNPCTypeAmbient.cpp"),
Object(NonMatching, "SB/Game/zNPCTypeTiki.cpp", extra_cflags=["-sym on"]),
Object(NonMatching, "SB/Core/x/xBehaveMgr.cpp", extra_cflags=["-sym on"]),
Expand All @@ -583,7 +583,7 @@ def MatchingFor(*versions):
Object(NonMatching, "SB/Game/zGoo.cpp"),
Object(NonMatching, "SB/Game/zGrid.cpp"),
Object(Matching, "SB/Game/zNPCGoalScript.cpp", extra_cflags=["-sym on"]),
Object(NonMatching, "SB/Game/zNPCSndTable.cpp"),
Object(NonMatching, "SB/Game/zNPCSndTable.cpp", extra_cflags=["-sym on"]),
Object(Matching, "SB/Game/zNPCSndLists.cpp"),
Object(NonMatching, "SB/Game/zNPCTypeDuplotron.cpp"),
Object(Equivalent, "SB/Core/x/xModelBucket.cpp"),
Expand Down
2 changes: 2 additions & 0 deletions src/SB/Core/x/xFX.h
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,8 @@ extern xFXStreak sStreakList[10];
extern xFXShine sShineList[2];
extern xFXRing ringlist[RING_COUNT];

extern RpAtomic* (*gAtomicRenderCallBack)(RpAtomic*);

void xFXInit();
U32 xFXShineStart(const xVec3*, F32, F32, F32, F32, U32, const iColor_tag*, const iColor_tag*, F32,
S32);
Expand Down
86 changes: 85 additions & 1 deletion src/SB/Core/x/xutil.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#ifndef XUTIL_H
#define XUTIL_H

#include "xMath.h"
#include <types.h>

S32 xUtilStartup();
Expand All @@ -11,6 +12,89 @@ U32 xUtil_crc_update(U32 crc_accum, char* data, S32 datasize);
S32 xUtil_yesno(F32 wt_yes);
void xUtil_wtadjust(F32* wts, S32 cnt, F32 arbref);

template <typename T> static T* xUtil_select(T** arg0, S32 arg1, const F32* arg3);
template <typename T> T* xUtil_select(T** data, S32 size, const F32* arg2)
{
T* selected = NULL;
S32 selectIdx = 0;
F32 tempValue;

if (data == NULL)
{
return NULL;
}
else if (size < 1)
{
return NULL;
}

F32 randOffset = xurand();
if (arg2 == NULL)
{
selectIdx = (S32)(randOffset * (F32)size);
}
else
{
F32* roundingData = (F32*)arg2;
F32 threshold = 0.0f;
S32 counter = 0;

for (S32 i = size; i > 0; i--)
{
tempValue = threshold;
threshold += *roundingData;
if (randOffset >= tempValue && randOffset <= threshold)
{
selectIdx = counter;
break;
}
roundingData++;
counter++;
}
}

if (selectIdx >= size)
{
selectIdx = size - 1;
}

if (selectIdx < 0)
{
selectIdx = 0;
}

return data[selectIdx];
}

template <typename T> T xUtil_choose(T const* list, S32 size, F32 const* float_list)
{
if (list == NULL)
return NULL;
if (size < 1)
return NULL;
S32 idx = 0;
F32 rand = xurand();
if (float_list == NULL)
idx = rand * size;
else
{
const F32* float_it = float_list;
F32 total = 0.0f;
for (S32 i = 0; i < size; float_it++, i++)
{
F32 prev_total = total;
total += *float_it;
if (rand >= prev_total && rand <= total)
{
idx = i;
break;
}
}
}
if (idx >= size)
idx = size - 1;
if (idx < 0)
idx = 0;
return list[idx];
}

#endif
2 changes: 0 additions & 2 deletions src/SB/Game/zEntCruiseBubble.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,6 @@ basic_rect<F32> default_adjust = { 0.0f, 0.0f, 1.0f, 1.0f };
extern iColor_tag zEntCruiseBubble_color_80_00_00_FF; // 128, 0, 0, 255
extern iColor_tag zEntCruiseBubble_color_FF_14_14_FF; // 255, 20, 20, 255

extern RpAtomic* (*gAtomicRenderCallBack)(RpAtomic*);

namespace cruise_bubble
{
namespace
Expand Down
48 changes: 1 addition & 47 deletions src/SB/Game/zGameExtras.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
#include "xSnd.h"
#include "xEnt.h"
#include "xCounter.h"
#include "xMath.h"
#include "xUtil.h"

#include "zGameExtras.h"
#include "zEntPlayer.h"
Expand Down Expand Up @@ -740,49 +740,3 @@ U32 zGame_HackIsGallery()
}
return 0;
}

template <> U32 xUtil_choose<U32>(U32 const* list, S32 size, F32 const* float_list)
{
if (list == NULL)
{
return NULL;
}

if (size < 1)
{
return NULL;
}

S32 idx = 0;
F32 rand = xurand();

if (float_list == NULL)
{
idx = rand * size;
}
else
{
const F32* float_it = float_list;
F32 total = 0.0f;
for (S32 i = 0; i < size; float_it++, i++)
{
float prev_total = total;
total += *float_it;
if (rand >= prev_total && rand <= total)
{
idx = i;
break;
}
}
}

if (idx >= size)
{
idx = size - 1;
}
if (idx < 0)
{
idx = 0;
}
return list[idx];
}
2 changes: 0 additions & 2 deletions src/SB/Game/zGameExtras.h
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,4 @@ void GEC_cb_PanHandle();
void zGame_HackGalleryInit();
U32 zGame_HackIsGallery();

template <class T> T xUtil_choose(T const* list, S32 size, F32 const* c);

#endif
2 changes: 1 addition & 1 deletion src/SB/Game/zNPCGoalCommon.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ struct zNPCGoalCommon : xGoal
return 0;
}

virtual U8 CollReview(void*)
virtual S32 CollReview(void*)
{
return 0;
}
Expand Down
4 changes: 2 additions & 2 deletions src/SB/Game/zNPCGoalRobo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5037,12 +5037,12 @@ void zNPCGoalDogLaunch::SilentSwimout(xVec3* unk1, xVec3* unk2, zMovePoint* unk3
this->ViciousAttack(unk1, unk2, unk3, 1);
}

U8 zNPCGoalPatThrow::CollReview(void*)
S32 zNPCGoalPatThrow::CollReview(void*)
{
return 0;
}

U8 zNPCGoalDogLaunch::CollReview(void*)
S32 zNPCGoalDogLaunch::CollReview(void*)
{
return 0;
}
Expand Down
15 changes: 8 additions & 7 deletions src/SB/Game/zNPCGoalStd.h
Original file line number Diff line number Diff line change
Expand Up @@ -323,7 +323,7 @@ class zNPCGoalLassoThrow : public zNPCGoalCommon
S32 Enter(F32 dt, void* updCtxt);
S32 Exit(F32 dt, void* updCtxt);
S32 Process(en_trantype* trantype, F32 dt, void* updCtxt, xScene* xscn);
U8 CollReview(void*);
S32 CollReview(void*);
void ApplyYank(S32 left);
S32 flg_throw; // offset 0x4C, size 0x4
S32 floorBounce; // offset 0x50, size 0x4
Expand Down Expand Up @@ -635,7 +635,7 @@ struct zNPCGoalPatThrow : zNPCGoalCommon
}

S32 Enter(F32 dt, void* updCtxt);
U8 CollReview(void*);
S32 CollReview(void*);
};

enum en_alertchuk
Expand Down Expand Up @@ -771,7 +771,7 @@ class zNPCGoalAlertGlove : public zNPCGoalCommon
void FXWhirlwind();
void CalcAttackVector();
void CheckHandBones();
U8 CollReview(void*);
S32 CollReview(void*);
F32 tmr_attack; // offset 0x4C, size 0x4
F32 tmr_minAttack; // offset 0x50, size 0x4
xVec3 pos_began; // offset 0x54, size 0xC
Expand Down Expand Up @@ -1050,11 +1050,12 @@ struct zNPCGoalDogLaunch : zNPCGoalCommon
void ViciousAttack(xVec3* unk1, xVec3* unk2, zMovePoint* unk3, S32 unk4);
void PreCollide();
S32 BallisticUpdate(F32 dt);
void BubTrailCone(const xVec3* pos, S32 num, const xVec3* pos_rand, const xVec3* vel_rand, const xMat3x3* mat);
void BubTrailCone(const xVec3* pos, S32 num, const xVec3* pos_rand, const xVec3* vel_rand,
const xMat3x3* mat);
void FurryFlurry();

void SilentSwimout(xVec3* unk1, xVec3* unk2, zMovePoint* unk3);
U8 CollReview(void*);
S32 CollReview(void*);
};

class zNPCGoalDogBark : public zNPCGoalLoopAnim
Expand Down Expand Up @@ -1349,7 +1350,7 @@ class zNPCGoalKnock : public zNPCGoalCommon
S32 Exit(F32 dt, void* updCtxt);
S32 Process(en_trantype* trantype, F32 dt, void* updCtxt, xScene* xscn);
S32 InputInfo(NPCDamageInfo* info);
U8 CollReview(void*);
S32 CollReview(void*);
void StreakPrep();
void StreakDone();
void StreakUpdate();
Expand All @@ -1371,7 +1372,7 @@ class zNPCGoalWound : public zNPCGoalPushAnim

S32 Enter(F32, void*);
S32 Process(en_trantype* trantype, F32 dt, void* updCtxt, xScene* xscn);
U8 CollReview(void*);
S32 CollReview(void*);
S32 NPCMessage(NPCMsg*);
xVec3 dir_fling; // offset 0x54, size 0xC
S32 flg_knock; // offset 0x60, size 0x4
Expand Down
2 changes: 1 addition & 1 deletion src/SB/Game/zNPCGoalVillager.h
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ struct zNPCGoalBoyFall : zNPCGoalCommon
}

virtual S32 Process(en_trantype* trantype, F32 dt, void* updCtxt, xScene* scene);
virtual U8 CollReview(void*);
virtual S32 CollReview(void*);
};

struct zNPCGoalBoyWeep : zNPCGoalCommon
Expand Down
Loading
Loading