Skip to content

Commit

Permalink
c_rnd
Browse files Browse the repository at this point in the history
  • Loading branch information
magcius committed Jul 13, 2024
1 parent 3d8c73e commit 5f6ef2a
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 7 deletions.
8 changes: 2 additions & 6 deletions include/SSystem/SComponent/c_rnd.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,8 @@ struct cM_rnd_c {
/* 0x4 */ int m4;
/* 0x8 */ int m8;

void init(int a, int b, int c) {
m0 = a;
m4 = b;
m8 = c;
}
int get();
void init(int a, int b, int c);
f32 get();
f32 getF(f32);
f32 getFX(f32);
f32 getValue(f32 min, f32 max);
Expand Down
27 changes: 26 additions & 1 deletion src/d/d_drawlist.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -690,6 +690,31 @@ void dDlst_2D_c::draw() {
mPicture.draw(mX, mY, false, false, false);
}

void cM_rnd_c::init(int a, int b, int c) {
m0 = a;
m4 = b;
m8 = c;
}

f32 cM_rnd_c::get() {
m0 = (m0 * 171) % 30269;
m4 = (m4 * 172) % 30307;
m8 = (m8 * 170) % 30323;
return fabsf(fmod((m0 / 30269.0f) + (m4 / 30307.0f) + (m8 / 30323.0f), 1.0f));
}

f32 cM_rnd_c::getF(f32 m) {
return get() * m;
}

f32 cM_rnd_c::getFX(f32 m) {
return m * (get() - 0.5f) * 2.0f;
}

f32 cM_rnd_c::getValue(f32 min, f32 range) {
return min + getF(range);
}

/* 80082424-80082794 .text draw__18dDlst_effectLine_cFv */
void dDlst_effectLine_c::draw() {
GXSetVtxAttrFmt(GX_VTXFMT0, GX_VA_POS, GX_POS_XYZ, GX_F32, 0);
Expand Down Expand Up @@ -1518,7 +1543,7 @@ int psdRealCallBack(cBgS_ShdwDraw* shdw, cBgD_Vtx_t* pVtx, int v0, int v1, int v
const cXyz* normal = tri->GetNP();
if (shdwDrawPoly->getLightVec()->inprod(*normal) < -0.2f) {
cXyz* center = shdwDrawPoly->getCenter();
if (normal->x * center->x + normal->y * center->y + normal->z * center->z + tri->GetD() > -90.f) {
if (normal->x * center->x + normal->y * center->y + normal->z * center->z + tri->GetD() > -50.f) {
const cXyz* min = shdwDrawPoly->GetBndP()->GetMinP();
const cXyz* max = shdwDrawPoly->GetBndP()->GetMaxP();
cBgD_Vtx_t* vert1 = pVtx + v0;
Expand Down

0 comments on commit 5f6ef2a

Please sign in to comment.