-
Notifications
You must be signed in to change notification settings - Fork 46
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
324 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
#ifndef JMATRIGONOMETRIC_H | ||
#define JMATRIGONOMETRIC_H | ||
|
||
#include "dolphin/types.h" | ||
#include "MSL_C/utility.h" | ||
|
||
struct TSinCosTable { | ||
std::pair<f32, f32> table[0x2000]; | ||
|
||
f32 sinShort(s16 v) const { return table[static_cast<u16>(v) >> 3].first; } | ||
f32 cosShort(s16 v) const { return table[static_cast<u16>(v) >> 3].second; } | ||
|
||
inline f32 sinLap(f32 v) { | ||
if (v < 0.0f) { | ||
return -table[(u16)(-8192.0f * v) & 0x1fff].first; | ||
} | ||
return table[(u16)(8192.0f * v) & 0x1fff].first; | ||
} | ||
|
||
inline f32 sinDegree(f32 degree) { | ||
if (degree < 0.0f) { | ||
return -table[(u16)(-22.755556106567383f * degree) & 0x1fffU].first; | ||
} | ||
return table[(u16)(22.755556106567383f * degree) & 0x1fffU].first; | ||
} | ||
|
||
inline f32 cosDegree(f32 degree) { | ||
if (degree < 0.0f) { | ||
degree = -degree; | ||
} | ||
return table[(u16)(22.755556106567383f * degree) & 0x1fffU].second; | ||
} | ||
}; | ||
|
||
struct TAtanTable { | ||
f32 table[1025]; | ||
u8 pad[0x1C]; | ||
}; | ||
|
||
struct TAsinAcosTable { | ||
f32 table[1025]; | ||
u8 pad[0x1C]; | ||
}; | ||
|
||
namespace JMath { | ||
extern TSinCosTable sincosTable_; | ||
extern TAtanTable atanTable_; | ||
extern TAsinAcosTable asinAcosTable_; | ||
}; // namespace JMath | ||
|
||
inline f32 JMASCosShort(s16 v) { | ||
return JMath::sincosTable_.cosShort(v); | ||
} | ||
inline f32 JMASinShort(s16 v) { | ||
return JMath::sincosTable_.sinShort(v); | ||
} | ||
|
||
inline f32 JMASCos(s16 v) { | ||
return JMASCosShort(v); | ||
} | ||
inline f32 JMASSin(s16 v) { | ||
return JMASinShort(v); | ||
} | ||
|
||
inline f32 JMASinLap(f32 v) { | ||
return JMath::sincosTable_.sinLap(v); | ||
} | ||
|
||
inline f32 JMASinDegree(f32 degree) { | ||
return JMath::sincosTable_.sinDegree(degree); | ||
} | ||
|
||
inline f32 JMACosDegree(f32 degree) { | ||
return JMath::sincosTable_.cosDegree(degree); | ||
} | ||
|
||
#endif /* JMATRIGONOMETRIC_H */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,120 @@ | ||
#ifndef JMATH_H | ||
#define JMATH_H | ||
|
||
#include "dolphin/mtx/mtx.h" | ||
|
||
void JMAMTXApplyScale(const Mtx, Mtx, f32, f32, f32); | ||
void JMAEulerToQuat(s16 param_0, s16 param_1, s16 param_2, Quaternion* param_3); | ||
|
||
inline f32 JMAFastReciprocal(f32 value) { | ||
return __fres(value); | ||
} | ||
|
||
inline float __frsqrtes(register double f) { | ||
register float out; | ||
// clang-format off | ||
asm { | ||
frsqrte out, f | ||
} | ||
// clang-format on | ||
return out; | ||
} | ||
|
||
inline f32 JMAFastSqrt(register f32 input) { | ||
if (input > 0.0f) { | ||
register f32 out; | ||
asm { | ||
frsqrte out, input | ||
} | ||
return out * input; | ||
} else { | ||
return input; | ||
} | ||
} | ||
|
||
namespace JMath { | ||
|
||
inline f32 fastReciprocal(f32 value) { | ||
return JMAFastReciprocal(value); | ||
} | ||
|
||
inline void gekko_ps_copy3(register void* dst, register const void* src) { | ||
register f32 src0; | ||
register f32 src1; | ||
asm { | ||
psq_l src0, 0(src), 0, 0 | ||
lfs src1, 8(src) | ||
psq_st src0, 0(dst), 0, 0 | ||
stfs src1, 8(dst) | ||
}; | ||
} | ||
|
||
inline void gekko_ps_copy6(register void* dst, register const void* src) { | ||
register f32 src0; | ||
register f32 src1; | ||
register f32 src2; | ||
asm { | ||
psq_l src0, 0(src), 0, 0 | ||
psq_l src1, 8(src), 0, 0 | ||
psq_l src2, 16(src), 0, 0 | ||
psq_st src0, 0(dst), 0, 0 | ||
psq_st src1, 8(dst), 0, 0 | ||
psq_st src2, 16(dst), 0, 0 | ||
}; | ||
} | ||
|
||
inline void gekko_ps_copy12(register void* dst, register const void* src) { | ||
register f32 src0; | ||
register f32 src1; | ||
register f32 src2; | ||
register f32 src3; | ||
register f32 src4; | ||
register f32 src5; | ||
asm { | ||
psq_l src0, 0(src), 0, 0 | ||
psq_l src1, 8(src), 0, 0 | ||
psq_l src2, 16(src), 0, 0 | ||
psq_l src3, 24(src), 0, 0 | ||
psq_l src4, 32(src), 0, 0 | ||
psq_l src5, 40(src), 0, 0 | ||
psq_st src0, 0(dst), 0, 0 | ||
psq_st src1, 8(dst), 0, 0 | ||
psq_st src2, 16(dst), 0, 0 | ||
psq_st src3, 24(dst), 0, 0 | ||
psq_st src4, 32(dst), 0, 0 | ||
psq_st src5, 40(dst), 0, 0 | ||
}; | ||
} | ||
|
||
inline void gekko_ps_copy16(register void* dst, register const void* src) { | ||
register f32 src0; | ||
register f32 src1; | ||
register f32 src2; | ||
register f32 src3; | ||
register f32 src4; | ||
register f32 src5; | ||
register f32 src6; | ||
register f32 src7; | ||
asm { | ||
psq_l src0, 0(src), 0, 0 | ||
psq_l src1, 8(src), 0, 0 | ||
psq_l src2, 16(src), 0, 0 | ||
psq_l src3, 24(src), 0, 0 | ||
psq_l src4, 32(src), 0, 0 | ||
psq_l src5, 40(src), 0, 0 | ||
psq_l src6, 48(src), 0, 0 | ||
psq_l src7, 56(src), 0, 0 | ||
psq_st src0, 0(dst), 0, 0 | ||
psq_st src1, 8(dst), 0, 0 | ||
psq_st src2, 16(dst), 0, 0 | ||
psq_st src3, 24(dst), 0, 0 | ||
psq_st src4, 32(dst), 0, 0 | ||
psq_st src5, 40(dst), 0, 0 | ||
psq_st src6, 48(dst), 0, 0 | ||
psq_st src7, 56(dst), 0, 0 | ||
}; | ||
} | ||
|
||
}; // namespace JMath | ||
|
||
#endif /* JMATH_H */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
#ifndef RANDOM_H | ||
#define RANDOM_H | ||
|
||
#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 */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
#ifndef F_AP_GAME_H | ||
#define F_AP_GAME_H | ||
|
||
#include "JSystem/JUtility/TColor.h" | ||
|
||
void fapGm_After(); | ||
void fapGm_Create(); | ||
void fapGm_Execute(); | ||
|
||
class fapGm_HIO_c { | ||
public: | ||
/* 80018944 */ fapGm_HIO_c(); | ||
/* 80018AE0 */ virtual ~fapGm_HIO_c(); | ||
|
||
u32 pad[0x58]; | ||
}; // Size: 0x40 | ||
|
||
extern fapGm_HIO_c g_HIO; | ||
|
||
#endif /* F_AP_GAME_H */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.