match some Z2Calc functions (#72)

* Z2Calc OK

* inline definitions in random.h and format

* set -enum int compiler flag and fix enum hacks

* note for get_ufloat_1 inline

* PR suggestions and UB note

Co-authored-by: Pheenoh <pheenoh@gmail.com>
This commit is contained in:
lepelog
2021-01-07 02:39:56 +01:00
committed by GitHub
parent a787699d14
commit 11e2bab926
19 changed files with 93 additions and 247 deletions
@@ -10,9 +10,6 @@ public:
enum EAllocMode {
HEAD = 0,
TAIL = 1,
__EALLOCMODE_FORCE_ENUM_S32 = INT32_MAX,
__EALLOCMODE_FORCE_ENUM_SIGNED = -1,
};
public:
@@ -74,17 +74,12 @@ public:
MOUNT_ARAM = 2,
MOUNT_DVD = 3,
MOUNT_COMP = 4,
__EMOUNT_MODE_FORCE_32BIT = UINT32_MAX,
};
enum EMountDirection {
UNKNOWN_MOUNT_DIRECTION = 0,
HEAD = 1,
TAIL = 2,
__EMOUNT_DIRECTION_FORCE_32BIT = INT32_MAX,
__EMOUNT_DIRECTION_FORCE_SIGNED = -1,
};
class CArcName {
@@ -120,7 +115,7 @@ public:
u32 countResource(void) const;
u32 getFileAttribute(u32) const;
EMountMode getMountMode() const { return (EMountMode)mMountMode; }
u32 getMountMode() const { return mMountMode; }
protected:
bool isSameName(CArcName&, u32, u16) const;
@@ -41,9 +41,6 @@ enum JKRCompression {
COMPRESSION_YAY0 = 1,
COMPRESSION_YAZ0 = 2,
COMPRESSION_ASR = 3,
__COMPRESSION_ENUM_FORCE_S32 = INT32_MAX,
__COMPRESSION_ENUM_FORCE_SIGNED = -1,
};
class JKRDecomp : public JKRThread {
@@ -8,7 +8,6 @@ enum JKRExpandSwitch {
EXPAND_SWITCH_UNKNOWN0 = 0,
EXPAND_SWITCH_UNKNOWN1 = 1,
EXPAND_SWITCH_UNKNOWN2 = 2,
__FORCE_EXPAND_SWITCH_32BIT = UINT32_MAX,
};
class JKRHeap;
@@ -19,8 +18,6 @@ public:
UNKNOWN_EALLOC_DIRECTION = 0,
FORWARD = 1,
BACKWARD = 2,
__FORCE_EALLOC_DIRECTION_32BIT = UINT32_MAX,
};
static void* loadToMainRAM(char const*, u8*, JKRExpandSwitch, u32, JKRHeap*, EAllocDirection,
@@ -7,7 +7,6 @@
enum JKRMemBreakFlag {
JKRMEMBREAK_FLAG_UNKNOWN0 = 0,
JKRMEMBREAK_FLAG_UNKNOWN1 = 1,
_JKRMemBreakFlag_PADDING_32BIT = 0xFFFFFFFF,
};
class JKRMemArchive : public JKRArchive {
+21
View File
@@ -8,6 +8,27 @@ 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