mirror of
https://github.com/zeldaret/tp
synced 2026-07-11 15:28:38 -04:00
move Z2Calc, c_math and f_op_draw_iter (#125)
* Z2Calc * port over c_math * fop_draw_iter Co-authored-by: Pheenoh <pheenoh@gmail.com>
This commit is contained in:
@@ -3,4 +3,33 @@
|
||||
|
||||
#include "dolphin/types.h"
|
||||
|
||||
namespace 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(); }
|
||||
|
||||
// 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 */
|
||||
|
||||
Reference in New Issue
Block a user