summaryrefslogtreecommitdiff
path: root/src/code/z_quake.c
diff options
context:
space:
mode:
authorengineer124 <47598039+engineer124@users.noreply.github.com>2022-09-30 22:01:39 -0400
committerGitHub <noreply@github.com>2022-09-30 23:01:39 -0300
commitab5fd663ccddc0670773a047f4a30bf014a7dad4 (patch)
tree37011a91071e4acd136aa2e587b2dcb0a2b6dfcd /src/code/z_quake.c
parentb080fb370032738769467242c7a1a7945f972836 (diff)
Quake & Distortion Cleanup (#1102)
* quake cleanup * cleanup * more cleanup * remove cast * q comes before r... * unname goron function, leave it to another PR * PR Suggestions
Diffstat (limited to 'src/code/z_quake.c')
-rw-r--r--src/code/z_quake.c298
1 files changed, 181 insertions, 117 deletions
diff --git a/src/code/z_quake.c b/src/code/z_quake.c
index 7caa0f426..2b66a39f8 100644
--- a/src/code/z_quake.c
+++ b/src/code/z_quake.c
@@ -1,7 +1,46 @@
#include "global.h"
+#include "z64quake.h"
+
+typedef struct {
+ /* 0x00 */ s16 randIndex;
+ /* 0x02 */ s16 countdownMax;
+ /* 0x04 */ Camera* camera;
+ /* 0x08 */ u32 type;
+ /* 0x0C */ s16 verticalMag;
+ /* 0x0E */ s16 horizontalMag;
+ /* 0x10 */ s16 zoom;
+ /* 0x12 */ s16 rollOffset;
+ /* 0x14 */ Vec3s shakePlaneOffset; // angle deviations from shaking in the perpendicular plane
+ /* 0x1A */ s16 speed;
+ /* 0x1C */ s16 isShakePerpendicular;
+ /* 0x1E */ s16 countdown;
+ /* 0x20 */ s16 camId;
+} QuakeRequest; // size = 0x24
+
+typedef struct {
+ /* 0x0 */ PlayState* play;
+ /* 0x4 */ s32 type; // bitfield, highest set bit determines type
+ /* 0x8 */ s16 countdown;
+ /* 0xA */ s16 state;
+} DistortionRequest; // size = 0xC
+
+typedef struct {
+ /* 0x00 */ Vec3f atOffset;
+ /* 0x0C */ Vec3f eyeOffset;
+ /* 0x18 */ s16 rollOffset;
+ /* 0x1A */ s16 zoom;
+} ShakeInfo; // size = 0x1C
+
+typedef s16 (*QuakeCallbackFunc)(QuakeRequest*, ShakeInfo*);
+
+typedef enum {
+ /* 0 */ DISTORTION_INACTIVE,
+ /* 1 */ DISTORTION_ACTIVE,
+ /* 2 */ DISTORTION_SETUP
+} DistortionState;
QuakeRequest sQuakeRequest[4];
-DistortionContext sDistortionContext;
+DistortionRequest sDistortionRequest;
static s16 sIsQuakeInitialized = true;
static s16 sQuakeRequestCount = 0;
@@ -51,7 +90,7 @@ void Quake_UpdateShakeInfo(QuakeRequest* req, ShakeInfo* shake, f32 verticalPert
shake->zoom = req->zoom * verticalPertubation;
}
-s16 Quake_Callback1(QuakeRequest* req, ShakeInfo* shake) {
+s16 Quake_CallbackType1(QuakeRequest* req, ShakeInfo* shake) {
if (req->countdown > 0) {
f32 perpendicularPertubation = Math_SinS(req->speed * req->countdown);
@@ -61,7 +100,7 @@ s16 Quake_Callback1(QuakeRequest* req, ShakeInfo* shake) {
return req->countdown;
}
-s16 Quake_Callback5(QuakeRequest* req, ShakeInfo* shake) {
+s16 Quake_CallbackType5(QuakeRequest* req, ShakeInfo* shake) {
if (req->countdown > 0) {
f32 perpendicularPertubation = Math_SinS(req->speed * req->countdown);
@@ -71,7 +110,7 @@ s16 Quake_Callback5(QuakeRequest* req, ShakeInfo* shake) {
return req->countdown;
}
-s16 Quake_Callback6(QuakeRequest* req, ShakeInfo* shake) {
+s16 Quake_CallbackType6(QuakeRequest* req, ShakeInfo* shake) {
f32 perpendicularPertubation;
req->countdown--;
@@ -80,7 +119,7 @@ s16 Quake_Callback6(QuakeRequest* req, ShakeInfo* shake) {
return 1;
}
-s16 Quake_Callback3(QuakeRequest* req, ShakeInfo* shake) {
+s16 Quake_CallbackType3(QuakeRequest* req, ShakeInfo* shake) {
if (req->countdown > 0) {
f32 perpendicularPertubation =
Math_SinS(req->speed * req->countdown) * ((f32)req->countdown / (f32)req->countdownMax);
@@ -91,7 +130,7 @@ s16 Quake_Callback3(QuakeRequest* req, ShakeInfo* shake) {
return req->countdown;
}
-s16 Quake_Callback2(QuakeRequest* req, ShakeInfo* shake) {
+s16 Quake_CallbackType2(QuakeRequest* req, ShakeInfo* shake) {
if (req->countdown > 0) {
f32 perpendicularPertubation = Quake_Random();
@@ -101,7 +140,7 @@ s16 Quake_Callback2(QuakeRequest* req, ShakeInfo* shake) {
return req->countdown;
}
-s16 Quake_Callback4(QuakeRequest* req, ShakeInfo* shake) {
+s16 Quake_CallbackType4(QuakeRequest* req, ShakeInfo* shake) {
if (req->countdown > 0) {
f32 perpendicularPertubation = Quake_Random() * ((f32)req->countdown / (f32)req->countdownMax);
@@ -117,7 +156,7 @@ s16 Quake_GetFreeIndex(void) {
s32 min = 0x10000;
for (i = 0; i < ARRAY_COUNT(sQuakeRequest); i++) {
- if (sQuakeRequest[i].callbackIdx == 0) {
+ if (sQuakeRequest[i].type == 0) {
ret = i;
break;
}
@@ -131,43 +170,43 @@ s16 Quake_GetFreeIndex(void) {
return ret;
}
-QuakeRequest* Quake_AddImpl(Camera* camera, u32 callbackIdx) {
- s16 idx = Quake_GetFreeIndex();
- QuakeRequest* req = &sQuakeRequest[idx];
+QuakeRequest* Quake_AddImpl(Camera* camera, u32 type) {
+ s16 index = Quake_GetFreeIndex();
+ QuakeRequest* req = &sQuakeRequest[index];
__osMemset(req, 0, sizeof(QuakeRequest));
req->camera = camera;
req->camId = camera->camId;
- req->callbackIdx = callbackIdx;
+ req->type = type;
req->isShakePerpendicular = true;
- req->randIdx = ((s16)(Rand_ZeroOne() * (f32)0x10000) & ~3) + idx;
+ req->randIndex = ((s16)(Rand_ZeroOne() * 0x10000) & ~3) + index;
sQuakeRequestCount++;
return req;
}
-void Quake_Remove(QuakeRequest* req) {
- req->callbackIdx = 0;
+void Quake_RemoveRequest(QuakeRequest* req) {
+ req->type = 0;
req->countdown = -1;
sQuakeRequestCount--;
}
-QuakeRequest* Quake_GetRequest(s16 idx) {
- QuakeRequest* req = &sQuakeRequest[idx & 3];
+QuakeRequest* Quake_GetRequest(s16 quakeIndex) {
+ QuakeRequest* req = &sQuakeRequest[quakeIndex & 3];
- if (req->callbackIdx == 0) {
+ if (req->type == 0) {
return NULL;
}
- if (idx != req->randIdx) {
+ if (quakeIndex != req->randIndex) {
return NULL;
}
return req;
}
-u32 Quake_SetValue(s16 idx, s16 valueType, s16 value) {
- QuakeRequest* req = Quake_GetRequest(idx);
+u32 Quake_SetValue(s16 quakeIndex, s16 valueType, s16 value) {
+ QuakeRequest* req = Quake_GetRequest(quakeIndex);
if (req == NULL) {
return false;
@@ -176,62 +215,75 @@ u32 Quake_SetValue(s16 idx, s16 valueType, s16 value) {
case QUAKE_SPEED:
req->speed = value;
break;
+
case QUAKE_VERTICAL_MAG:
req->verticalMag = value;
break;
+
case QUAKE_HORIZONTAL_MAG:
req->horizontalMag = value;
break;
+
case QUAKE_ZOOM:
req->zoom = value;
break;
+
case QUAKE_ROLL_OFFSET:
req->rollOffset = value;
break;
+
case QUAKE_SHAKE_PLANE_OFFSET_X:
req->shakePlaneOffset.x = value;
break;
+
case QUAKE_SHAKE_PLANE_OFFSET_Y:
req->shakePlaneOffset.y = value;
break;
+
case QUAKE_SHAKE_PLANE_OFFSET_Z:
req->shakePlaneOffset.z = value;
break;
+
case QUAKE_COUNTDOWN:
req->countdown = value;
req->countdownMax = req->countdown;
break;
+
case QUAKE_IS_SHAKE_PERPENDICULAR:
req->isShakePerpendicular = value;
break;
+
+ default:
+ break;
}
+
return true;
}
}
-u32 Quake_SetSpeed(s16 idx, s16 value) {
- QuakeRequest* req = Quake_GetRequest(idx);
+u32 Quake_SetSpeed(s16 quakeIndex, s16 speed) {
+ QuakeRequest* req = Quake_GetRequest(quakeIndex);
if (req != NULL) {
- req->speed = value;
+ req->speed = speed;
return true;
}
return false;
}
-u32 Quake_SetCountdown(s16 idx, s16 value) {
- QuakeRequest* req = Quake_GetRequest(idx);
+u32 Quake_SetCountdown(s16 quakeIndex, s16 countdown) {
+ QuakeRequest* req = Quake_GetRequest(quakeIndex);
if (req != NULL) {
- req->countdown = value;
+ req->countdown = countdown;
req->countdownMax = req->countdown;
return true;
}
return false;
}
-s16 Quake_GetCountdown(s16 idx) {
- QuakeRequest* req = Quake_GetRequest(idx);
+s16 Quake_GetCountdown(s16 quakeIndex) {
+ QuakeRequest* req = Quake_GetRequest(quakeIndex);
if (req != NULL) {
return req->countdown;
@@ -239,8 +291,8 @@ s16 Quake_GetCountdown(s16 idx) {
return 0;
}
-u32 Quake_SetQuakeValues(s16 idx, s16 verticalMag, s16 horizontalMag, s16 zoom, s16 rollOffset) {
- QuakeRequest* req = Quake_GetRequest(idx);
+u32 Quake_SetQuakeValues(s16 quakeIndex, s16 verticalMag, s16 horizontalMag, s16 zoom, s16 rollOffset) {
+ QuakeRequest* req = Quake_GetRequest(quakeIndex);
if (req != NULL) {
req->verticalMag = verticalMag;
@@ -252,8 +304,8 @@ u32 Quake_SetQuakeValues(s16 idx, s16 verticalMag, s16 horizontalMag, s16 zoom,
return false;
}
-u32 Quake_SetQuakeValues2(s16 idx, s16 isShakePerpendicular, Vec3s shakePlaneOffset) {
- QuakeRequest* req = Quake_GetRequest(idx);
+u32 Quake_SetQuakeValues2(s16 quakeIndex, s16 isShakePerpendicular, Vec3s shakePlaneOffset) {
+ QuakeRequest* req = Quake_GetRequest(quakeIndex);
if (req != NULL) {
req->isShakePerpendicular = isShakePerpendicular;
@@ -267,29 +319,35 @@ void Quake_Init(void) {
s16 i;
for (i = 0; i < ARRAY_COUNT(sQuakeRequest); i++) {
- sQuakeRequest[i].callbackIdx = 0;
+ sQuakeRequest[i].type = 0;
sQuakeRequest[i].countdown = 0;
}
sIsQuakeInitialized = true;
sQuakeRequestCount = 0;
}
-s16 Quake_Add(Camera* camera, u32 callbackIdx) {
- return Quake_AddImpl(camera, callbackIdx)->randIdx;
+s16 Quake_Add(Camera* camera, u32 type) {
+ return Quake_AddImpl(camera, type)->randIndex;
}
-u32 Quake_RemoveFromIdx(s16 idx) {
- QuakeRequest* req = Quake_GetRequest(idx);
+u32 Quake_Remove(s16 index) {
+ QuakeRequest* req = Quake_GetRequest(index);
if (req != NULL) {
- Quake_Remove(req);
+ Quake_RemoveRequest(req);
return true;
}
return false;
}
static QuakeCallbackFunc sQuakeCallbacks[] = {
- NULL, Quake_Callback1, Quake_Callback2, Quake_Callback3, Quake_Callback4, Quake_Callback5, Quake_Callback6,
+ NULL,
+ Quake_CallbackType1,
+ Quake_CallbackType2,
+ Quake_CallbackType3,
+ Quake_CallbackType4,
+ Quake_CallbackType5,
+ Quake_CallbackType6,
};
s16 Quake_Calc(Camera* camera, QuakeCamCalc* camData) {
@@ -299,7 +357,7 @@ s16 Quake_Calc(Camera* camera, QuakeCamCalc* camData) {
f32 absSpeedDiv;
f32 maxCurr;
f32 maxNext;
- s32 idx;
+ s32 index;
s32 ret;
u32 eq;
Vec3f originVec;
@@ -323,16 +381,16 @@ s16 Quake_Calc(Camera* camera, QuakeCamCalc* camData) {
}
ret = 0;
- for (idx = 0; idx < ARRAY_COUNT(sQuakeRequest); idx++) {
- req = &sQuakeRequest[idx];
- if (req->callbackIdx != 0) {
+ for (index = 0; index < ARRAY_COUNT(sQuakeRequest); index++) {
+ req = &sQuakeRequest[index];
+ if (req->type != 0) {
if (play->cameraPtrs[req->camId] == NULL) {
- Quake_Remove(req);
+ Quake_RemoveRequest(req);
} else {
eq = (camera->camId != req->camera->camId);
absSpeedDiv = ABS(req->speed) / (f32)0x8000;
- if (sQuakeCallbacks[req->callbackIdx](req, &shake) == 0) {
- Quake_Remove(req);
+ if (sQuakeCallbacks[req->type](req, &shake) == 0) {
+ Quake_RemoveRequest(req);
} else if (eq == 0) {
if (fabsf(camData->atOffset.x) < fabsf(shake.atOffset.x)) {
camData->atOffset.x = shake.atOffset.x;
@@ -383,35 +441,35 @@ s16 Quake_Calc(Camera* camera, QuakeCamCalc* camData) {
}
void Distortion_Init(PlayState* play) {
- sDistortionContext.play = play;
+ sDistortionRequest.play = play;
View_ClearDistortion(&play->view);
- sDistortionContext.type = 0;
- sDistortionContext.countdown = 0;
- sDistortionContext.state = DISTORTION_INACTIVE;
+ sDistortionRequest.type = 0;
+ sDistortionRequest.countdown = 0;
+ sDistortionRequest.state = DISTORTION_INACTIVE;
}
void Distortion_SetCountdown(s16 countdown) {
- sDistortionContext.countdown = countdown;
- sDistortionContext.state = DISTORTION_SETUP;
+ sDistortionRequest.countdown = countdown;
+ sDistortionRequest.state = DISTORTION_SETUP;
}
s16 Distortion_GetCountdown(void) {
- return sDistortionContext.countdown;
+ return sDistortionRequest.countdown;
}
s16 Distortion_GetType(void) {
- return sDistortionContext.type;
+ return sDistortionRequest.type;
}
void Distortion_SetType(s32 type) {
- if (sDistortionContext.type < type) {
- sDistortionContext.type = type;
+ if (sDistortionRequest.type < type) {
+ sDistortionRequest.type = type;
}
}
void Distortion_ClearType(s32 type) {
- if (sDistortionContext.type == type) {
- sDistortionContext.type = 0;
+ if (sDistortionRequest.type == type) {
+ sDistortionRequest.type = 0;
}
}
@@ -419,9 +477,9 @@ void Distortion_ClearType(s32 type) {
* Checks that the bg surface is an underwater conveyor type and if so, returns the conveyor speed
*/
s32 Distortion_GetUnderwaterCurrentSpeed(Player* player) {
- if (SurfaceType_GetConveyorType(&sDistortionContext.play->colCtx, player->actor.floorPoly,
- player->actor.floorBgId) == CONVEYOR_WATER) {
- return SurfaceType_GetConveyorSpeed(&sDistortionContext.play->colCtx, player->actor.floorPoly,
+ if (!SurfaceType_IsFloorConveyor(&sDistortionRequest.play->colCtx, player->actor.floorPoly,
+ player->actor.floorBgId)) {
+ return SurfaceType_GetConveyorSpeed(&sDistortionRequest.play->colCtx, player->actor.floorPoly,
player->actor.floorBgId);
}
return 0;
@@ -446,14 +504,14 @@ void Distortion_Update(void) {
f32 zScale;
f32 speed;
Player* player;
- PlayState* play = sDistortionContext.play;
+ PlayState* play = sDistortionRequest.play;
PosRot playerPosRot;
Camera* camera = GET_ACTIVE_CAM(play);
f32 speedRatio = CLAMP_MAX(camera->speedRatio, 1.0f);
- if (sDistortionContext.type != 0) {
- if (sDistortionContext.type & 0x800) {
- sDistortionContext.countdown = 2;
+ if (sDistortionRequest.type != 0) {
+ if (sDistortionRequest.type & DISTORTION_TYPE_B) {
+ sDistortionRequest.countdown = 2;
depthPhase = 0x3F0;
screenPlanePhase = 0x156;
@@ -469,11 +527,11 @@ void Distortion_Update(void) {
zScale = 0.0f;
speed = 0.6f;
- xyScaleFactor = zScaleFactor = sDistortionContext.countdown / 60.0f;
+ xyScaleFactor = zScaleFactor = sDistortionRequest.countdown / 60.0f;
speedScaleFactor = 1.0f;
- } else if (sDistortionContext.type & 0x400) {
- if (sDistortionContext.state == DISTORTION_SETUP) {
- countdownMax = sDistortionContext.countdown;
+ } else if (sDistortionRequest.type & DISTORTION_TYPE_A) {
+ if (sDistortionRequest.state == DISTORTION_SETUP) {
+ countdownMax = sDistortionRequest.countdown;
depthPhase = 0x3F0;
screenPlanePhase = 0x156;
}
@@ -490,11 +548,11 @@ void Distortion_Update(void) {
zScale = 0.0f;
speed = 0.4f;
- xyScaleFactor = zScaleFactor = ((f32)countdownMax - sDistortionContext.countdown) / (f32)countdownMax;
+ xyScaleFactor = zScaleFactor = ((f32)countdownMax - sDistortionRequest.countdown) / (f32)countdownMax;
speedScaleFactor = 0.5f;
- } else if (sDistortionContext.type & 0x200) {
- if (sDistortionContext.state == DISTORTION_SETUP) {
- countdownMax = sDistortionContext.countdown;
+ } else if (sDistortionRequest.type & DISTORTION_TYPE_9) {
+ if (sDistortionRequest.state == DISTORTION_SETUP) {
+ countdownMax = sDistortionRequest.countdown;
depthPhase = 0x1FC;
screenPlanePhase = 0x156;
}
@@ -511,11 +569,11 @@ void Distortion_Update(void) {
zScale = 0.0f;
speed = 0.1f;
- xyScaleFactor = zScaleFactor = ((f32)countdownMax - sDistortionContext.countdown) / (f32)countdownMax;
+ xyScaleFactor = zScaleFactor = ((f32)countdownMax - sDistortionRequest.countdown) / (f32)countdownMax;
speedScaleFactor = 1.0f;
- } else if (sDistortionContext.type & 0x100) {
- if (sDistortionContext.state == DISTORTION_SETUP) {
- countdownMax = sDistortionContext.countdown;
+ } else if (sDistortionRequest.type & DISTORTION_TYPE_8) {
+ if (sDistortionRequest.state == DISTORTION_SETUP) {
+ countdownMax = sDistortionRequest.countdown;
depthPhase = 0x2710;
screenPlanePhase = 0x3E8;
}
@@ -532,15 +590,15 @@ void Distortion_Update(void) {
zScale = 0.01f;
speed = 1.5f;
- if (sDistortionContext.countdown < 5) {
- xyScaleFactor = zScaleFactor = ((f32)countdownMax - sDistortionContext.countdown) / (f32)countdownMax;
+ if (sDistortionRequest.countdown < 5) {
+ xyScaleFactor = zScaleFactor = ((f32)countdownMax - sDistortionRequest.countdown) / (f32)countdownMax;
} else {
xyScaleFactor = zScaleFactor = 0.0f;
}
speedScaleFactor = 1.0f;
- } else if (sDistortionContext.type & 0x80) {
- if (sDistortionContext.state == DISTORTION_SETUP) {
- countdownMax = sDistortionContext.countdown;
+ } else if (sDistortionRequest.type & DISTORTION_TYPE_7) {
+ if (sDistortionRequest.state == DISTORTION_SETUP) {
+ countdownMax = sDistortionRequest.countdown;
depthPhase = 0x4B0;
screenPlanePhase = 0x7D0;
}
@@ -557,11 +615,11 @@ void Distortion_Update(void) {
zScale = 0.01f;
speed = 1.5f;
- xyScaleFactor = zScaleFactor = sDistortionContext.countdown / (f32)countdownMax;
+ xyScaleFactor = zScaleFactor = sDistortionRequest.countdown / (f32)countdownMax;
speedScaleFactor = 1.0f;
- } else if (sDistortionContext.type & 0x40) {
- if (sDistortionContext.state == DISTORTION_SETUP) {
- countdownMax = sDistortionContext.countdown;
+ } else if (sDistortionRequest.type & DISTORTION_TYPE_6) {
+ if (sDistortionRequest.state == DISTORTION_SETUP) {
+ countdownMax = sDistortionRequest.countdown;
depthPhase = 0x9C4;
screenPlanePhase = 0xBB8;
}
@@ -578,15 +636,15 @@ void Distortion_Update(void) {
zScale = 0.01f;
speed = 1.3f;
- if (sDistortionContext.countdown < 4) {
- xyScaleFactor = zScaleFactor = sDistortionContext.countdown / (f32)countdownMax;
+ if (sDistortionRequest.countdown < 4) {
+ xyScaleFactor = zScaleFactor = sDistortionRequest.countdown / (f32)countdownMax;
} else {
xyScaleFactor = zScaleFactor = 0.0f;
}
speedScaleFactor = 1.0f;
- } else if (sDistortionContext.type & 0x20) {
- sDistortionContext.countdown = 2;
- if (sDistortionContext.state == DISTORTION_SETUP) {
+ } else if (sDistortionRequest.type & DISTORTION_TYPE_5) {
+ sDistortionRequest.countdown = 2;
+ if (sDistortionRequest.state == DISTORTION_SETUP) {
depthPhase = 0x9C4;
screenPlanePhase = 0xBB8;
}
@@ -609,9 +667,9 @@ void Distortion_Update(void) {
zScaleFactor = 1.0f;
xyScaleFactor = 1.0f;
speedScaleFactor = 1.0f;
- } else if (sDistortionContext.type & 0x10) {
- if (sDistortionContext.state == DISTORTION_SETUP) {
- countdownMax = sDistortionContext.countdown;
+ } else if (sDistortionRequest.type & DISTORTION_TYPE_4) {
+ if (sDistortionRequest.state == DISTORTION_SETUP) {
+ countdownMax = sDistortionRequest.countdown;
depthPhase = 0x760;
screenPlanePhase = 0x1BC;
}
@@ -628,14 +686,14 @@ void Distortion_Update(void) {
zScale = 0.2f;
speed = 0.25f;
- countdownRatio = sDistortionContext.countdown / (f32)countdownMax;
+ countdownRatio = sDistortionRequest.countdown / (f32)countdownMax;
zScaleFactor = xyScaleFactor = countdownRatio;
speedScaleFactor = 1.0f;
- } else if (sDistortionContext.type & 8) {
+ } else if (sDistortionRequest.type & DISTORTION_TYPE_3) {
depthPhase = 0x3F0;
screenPlanePhase = 0x156;
- sDistortionContext.countdown = 2;
+ sDistortionRequest.countdown = 2;
player = GET_PLAYER(play);
if (player != NULL) {
@@ -656,18 +714,21 @@ void Distortion_Update(void) {
zScale = 0.03f;
speed = 0.33f;
break;
+
case 2:
xScale = -0.06f;
yScale = 0.1f;
zScale = 0.03f;
speed = 0.33f;
break;
+
case 1:
xScale = -0.06f;
yScale = 0.1f;
zScale = 0.03f;
speed = 0.33f;
break;
+
default:
xScale = -0.06f;
yScale = 0.1f;
@@ -683,11 +744,11 @@ void Distortion_Update(void) {
}
zScaleFactor = -xyScaleFactor;
speedScaleFactor = 1.0f;
- } else if (sDistortionContext.type & 4) {
+ } else if (sDistortionRequest.type & DISTORTION_TYPE_2) {
depthPhase = 0x3F0;
screenPlanePhase = 0x156;
- sDistortionContext.countdown = 2;
+ sDistortionRequest.countdown = 2;
player = GET_PLAYER(play);
depthPhaseStep = 359.2f;
@@ -703,18 +764,21 @@ void Distortion_Update(void) {
zScale = 0.08f;
speed = 0.18f;
break;
+
case 2:
xScale = 0.12f;
yScale = 0.12f;
zScale = 0.08f;
speed = 0.12f;
break;
+
case 1:
xScale = 0.12f;
yScale = 0.12f;
zScale = 0.08f;
speed = 0.08f;
break;
+
default:
xScale = 0.12f;
yScale = 0.12f;
@@ -731,12 +795,12 @@ void Distortion_Update(void) {
xyScaleFactor = speedScaleFactor = (waterYScaleFactor * 0.15f) + 0.35f + (speedRatio * 0.4f);
zScaleFactor = 0.9f - xyScaleFactor;
- } else if (sDistortionContext.type & 1) {
+ } else if (sDistortionRequest.type & DISTORTION_TYPE_0) {
// Gives a small mirage-like appearance
depthPhase = 0x3F0;
screenPlanePhase = 0x156;
- sDistortionContext.countdown = 2;
+ sDistortionRequest.countdown = 2;
depthPhaseStep = 0.0f;
screenPlanePhaseStep = 150.0f;
@@ -759,29 +823,29 @@ void Distortion_Update(void) {
depthPhase += CAM_DEG_TO_BINANG(depthPhaseStep);
screenPlanePhase += CAM_DEG_TO_BINANG(screenPlanePhaseStep);
- View_SetDistortionDirRot(&sDistortionContext.play->view,
+ View_SetDistortionDirRot(&sDistortionRequest.play->view,
Math_CosS(depthPhase) * (DEGF_TO_RADF(rotX) * xyScaleFactor),
Math_SinS(depthPhase) * (DEGF_TO_RADF(rotY) * xyScaleFactor),
Math_SinS(screenPlanePhase) * (DEGF_TO_RADF(rotZ) * zScaleFactor));
- View_SetDistortionScale(&sDistortionContext.play->view,
+ View_SetDistortionScale(&sDistortionRequest.play->view,
(Math_SinS(screenPlanePhase) * (xScale * xyScaleFactor)) + 1.0f,
(Math_CosS(screenPlanePhase) * (yScale * xyScaleFactor)) + 1.0f,
(Math_CosS(depthPhase) * (zScale * zScaleFactor)) + 1.0f);
- View_SetDistortionSpeed(&sDistortionContext.play->view, speed * speedScaleFactor);
+ View_SetDistortionSpeed(&sDistortionRequest.play->view, speed * speedScaleFactor);
- sDistortionContext.state = DISTORTION_ACTIVE;
+ sDistortionRequest.state = DISTORTION_ACTIVE;
- } else if (sDistortionContext.state != DISTORTION_INACTIVE) {
+ } else if (sDistortionRequest.state != DISTORTION_INACTIVE) {
View_ClearDistortion(&play->view);
- sDistortionContext.state = DISTORTION_INACTIVE;
- sDistortionContext.countdown = 0;
+ sDistortionRequest.state = DISTORTION_INACTIVE;
+ sDistortionRequest.countdown = 0;
}
- if (sDistortionContext.countdown != 0) {
- sDistortionContext.countdown--;
- if (sDistortionContext.countdown == 0) {
- sDistortionContext.type = 0;
+ if (sDistortionRequest.countdown != 0) {
+ sDistortionRequest.countdown--;
+ if (sDistortionRequest.countdown == 0) {
+ sDistortionRequest.type = 0;
}
}
}
@@ -790,16 +854,16 @@ s32 Quake_NumActiveQuakes(void) {
QuakeRequest* req = sQuakeRequest;
s32 numActiveQuakes = 0;
- if (req[0].callbackIdx != 0) {
+ if (req[0].type != 0) {
numActiveQuakes++;
}
- if (req[1].callbackIdx != 0) {
+ if (req[1].type != 0) {
numActiveQuakes++;
}
- if (req[2].callbackIdx != 0) {
+ if (req[2].type != 0) {
numActiveQuakes++;
}
- if (req[3].callbackIdx != 0) {
+ if (req[3].type != 0) {
numActiveQuakes++;
}