applied falcobuster's long render distance fix

This commit is contained in:
Reonu
2021-04-27 11:54:51 +01:00
parent 960f695115
commit cbcba7b6f9
4 changed files with 151 additions and 29 deletions

View File

@@ -564,23 +564,17 @@ void mtxf_mul_vec3s(Mat4 mtx, Vec3s b) {
* and no crashes occur.
*/
void mtxf_to_mtx(Mtx *dest, Mat4 src) {
#ifdef AVOID_UB
// Avoid type-casting which is technically UB by calling the equivalent
// guMtxF2L function. This helps little-endian systems, as well.
guMtxF2L(src, dest);
#else
s32 asFixedPoint;
register s32 i;
register s16 *a3 = (s16 *) dest; // all integer parts stored in first 16 bytes
register s16 *t0 = (s16 *) dest + 16; // all fraction parts stored in last 16 bytes
register f32 *t1 = (f32 *) src;
Mat4 temp;
register s32 i, j;
for( i = 0; i < 4; i++ ) {
for( j = 0; j < 3; j++ ) {
temp[i][j] = src[i][j] / WORLD_SCALE;
}
temp[i][3] = src[i][3];
}
for (i = 0; i < 16; i++) {
asFixedPoint = *t1++ * (1 << 16); //! float-to-integer conversion responsible for PU crashes
*a3++ = GET_HIGH_S16_OF_32(asFixedPoint); // integer part
*t0++ = GET_LOW_S16_OF_32(asFixedPoint); // fraction part
}
#endif
guMtxF2L( temp, dest );
}
/**

View File

@@ -5,6 +5,14 @@
#include "types.h"
/* Scales the world down by this factor, increasing how far you can render on
* console in exchange for a slight loss in precision.
*
* For double extended boundary hacks, a value of 1.5f or 2.0f is good.
* For quadruple extended bounds, use 3.f or 4.f
*/
#define WORLD_SCALE 2.f
/*
* The sine and cosine tables overlap, but "#define gCosineTable (gSineTable +
* 0x400)" doesn't give expected codegen; gSineTable and gCosineTable need to