mirror of
https://github.com/encounter/tp.git
synced 2026-03-30 11:40:53 -07:00
a61e3491f7
* initial freezard actor struct + setActionMode OK * daE_FZ_Draw * setReflectAngle * mBoundSoundset * daE_FZ_Execute & execute * demoDelete * daE_FZ_Delete & _delete * CreateHeap * useHeapInit * cc_set * mtx_set * action WIP * way_gake_check * executeRollMove * executeMove * draw WIP * executeDamage * checkpoint * create * checkpoint * daE_FZ_c::executeWait * checkpoint * daE_FZ_c::damage_check almost done * rm asm * rm headers * setup_profile WIP + doxygen update * fix merge issues * docs fix? * fix2 * doxygen updates * setup g_profile_E_FZ, profile setup script WIP * update github actions * update progress.md
45 lines
937 B
C++
45 lines
937 B
C++
#ifndef RANDOM_H
|
|
#define RANDOM_H
|
|
|
|
#include "dolphin/types.h"
|
|
|
|
namespace JMath {
|
|
|
|
/**
|
|
* @ingroup jsystem-jmath
|
|
*
|
|
*/
|
|
struct TRandom_fast_ {
|
|
u32 value;
|
|
|
|
TRandom_fast_(u32 value);
|
|
u32 get(void) {
|
|
value = (value * 0x19660d) + 0x3c6ef35f;
|
|
return value;
|
|
}
|
|
|
|
u32 get_bit32(void) { return this->get(); }
|
|
|
|
s8 get_uint8(u8 param_0) {
|
|
return get_ufloat_1() * param_0;
|
|
}
|
|
|
|
// due to the float constant, having this function inlined adds that float to data,
|
|
// making it not match
|
|
float get_ufloat_1(void) {
|
|
// !@bug UB: in C++ it's not legal to read from an union member other
|
|
// than the last one that was written to.
|
|
union {
|
|
f32 f;
|
|
u32 s;
|
|
} out;
|
|
out.s = (this->get() >> 9) | 0x3f800000;
|
|
return out.f - 1;
|
|
}
|
|
|
|
void setSeed(u32 seed) { value = seed; }
|
|
};
|
|
} // namespace JMath
|
|
|
|
#endif /* RANDOM_H */
|