mirror of
https://github.com/perfect-dark-pc-port/perfect_dark.git
synced 2026-10-24 00:02:43 +02:00
port: implement screen shake
This commit is contained in:
1 parent
07c3a513ef
commit
840a2e73a5
7 files changed
+32
-3
No files matched your search
@@ -21,6 +21,8 @@ s32 videoGetHeight(void);
|
||||
f32 videoGetAspect(void);
|
||||
u32 videoGetTextureFilter2D(void);
|
||||
|
||||
void videoSetWindowOffset(s32 x, s32 y);
|
||||
|
||||
s32 videoCreateFramebuffer(u32 w, u32 h);
|
||||
void videoSetFramebuffer(s32 target);
|
||||
void videoResetFramebuffer(void);
|
||||
|
||||
@@ -72,6 +72,7 @@ static void gameLoadConfig(void)
|
||||
g_PlayerMouseAimMode = configGetIntClamped("Game.MouseAimMode", g_PlayerMouseAimMode, 0, 1);
|
||||
g_PlayerMouseAimSpeedX = configGetFloatClamped("Game.MouseAimSpeedX", g_PlayerMouseAimSpeedX, 0.f, 10.f);
|
||||
g_PlayerMouseAimSpeedY = configGetFloatClamped("Game.MouseAimSpeedY", g_PlayerMouseAimSpeedY, 0.f, 10.f);
|
||||
g_ViShakeIntensityMult = configGetFloatClamped("Game.ScreenShakeIntensity", 1.f, 0.f, 100.f);
|
||||
}
|
||||
|
||||
int main(int argc, const char **argv)
|
||||
|
||||
@@ -94,6 +94,7 @@ bool g_SchedViModesPending[NUM_GFXTASKS] = {false, false};
|
||||
s32 g_ViUnblackTimer = NUM_FRAMEBUFFERS + 1;
|
||||
s32 g_ViShakeDirection = 1;
|
||||
s32 g_ViShakeIntensity = 0;
|
||||
f32 g_ViShakeIntensityMult = 1.f;
|
||||
s32 g_ViShakeTimer = 0;
|
||||
u32 var8005cea0 = 0;
|
||||
u32 var8005cea4 = 0;
|
||||
|
||||
@@ -142,6 +142,12 @@ u32 videoGetTextureFilter2D(void)
|
||||
return texFilter2D;
|
||||
}
|
||||
|
||||
void videoSetWindowOffset(s32 x, s32 y)
|
||||
{
|
||||
gfx_current_game_window_viewport.x = x;
|
||||
gfx_current_game_window_viewport.y = y;
|
||||
}
|
||||
|
||||
s32 videoCreateFramebuffer(u32 w, u32 h)
|
||||
{
|
||||
return gfx_create_framebuffer(w, h);
|
||||
|
||||
@@ -28,6 +28,12 @@
|
||||
#include "data.h"
|
||||
#include "types.h"
|
||||
|
||||
#ifdef PLATFORM_N64
|
||||
#define SHAKE_TIME 6
|
||||
#else
|
||||
#define SHAKE_TIME 12
|
||||
#endif
|
||||
|
||||
struct explosion *g_Explosions;
|
||||
s32 g_MaxExplosions;
|
||||
|
||||
@@ -296,7 +302,7 @@ bool explosionCreate(struct prop *sourceprop, struct coord *exppos, RoomNum *exp
|
||||
struct prop *expprop = propAllocate();
|
||||
|
||||
if (type != EXPLOSIONTYPE_16 && type != EXPLOSIONTYPE_BULLETHOLE) {
|
||||
g_ExplosionShakeTotalTimer = 6;
|
||||
g_ExplosionShakeTotalTimer = SHAKE_TIME;
|
||||
}
|
||||
|
||||
if (expprop) {
|
||||
@@ -554,8 +560,8 @@ bool explosionCreate(struct prop *sourceprop, struct coord *exppos, RoomNum *exp
|
||||
*/
|
||||
void explosionShake(void)
|
||||
{
|
||||
g_ExplosionShakeTotalTimer = 6;
|
||||
g_ExplosionShakeIntensityTimer = 6;
|
||||
g_ExplosionShakeTotalTimer = SHAKE_TIME;
|
||||
g_ExplosionShakeIntensityTimer = SHAKE_TIME;
|
||||
}
|
||||
|
||||
void explosionsUpdateShake(struct coord *arg0, struct coord *arg1, struct coord *arg2)
|
||||
|
||||
@@ -536,6 +536,7 @@ extern f32 g_PlayerDefaultFovY;
|
||||
extern s32 g_PlayerMouseAimMode;
|
||||
extern f32 g_PlayerMouseAimSpeedX;
|
||||
extern f32 g_PlayerMouseAimSpeedY;
|
||||
extern f32 g_ViShakeIntensityMult;
|
||||
extern u32 g_TexFilter2D;
|
||||
|
||||
#define TEX_FILTER_2D g_TexFilter2D
|
||||
|
||||
@@ -14,6 +14,9 @@
|
||||
#include "lib/mtx.h"
|
||||
#include "data.h"
|
||||
#include "types.h"
|
||||
#ifndef PLATFORM_N64
|
||||
#include "video.h"
|
||||
#endif
|
||||
|
||||
#define TO_U16_A(x) ((u16)(x))
|
||||
#define TO_U16_B(x) ((x) & 0xffff)
|
||||
@@ -280,6 +283,10 @@ void viHandleRetrace(void)
|
||||
osSetIntMask(prevmask);
|
||||
#endif
|
||||
|
||||
#ifndef PLATFORM_N64
|
||||
videoSetWindowOffset(0, offset);
|
||||
#endif
|
||||
|
||||
osViSetMode(var8008dd60[1 - var8005ce74]);
|
||||
osViBlack(g_ViUnblackTimer);
|
||||
osViSetXScale(g_ViXScalesBySlot[1 - var8005ce74]);
|
||||
@@ -460,8 +467,13 @@ void viShake(f32 intensity)
|
||||
intensity = 0;
|
||||
}
|
||||
|
||||
#ifdef PLATFORM_N64
|
||||
g_ViShakeIntensity = intensity;
|
||||
g_ViShakeTimer = 10;
|
||||
#else
|
||||
g_ViShakeIntensity = intensity * g_ViShakeIntensityMult;
|
||||
g_ViShakeTimer = 20;
|
||||
#endif
|
||||
}
|
||||
|
||||
void viSetMode(s32 mode)
|
||||
|
||||
Reference in new issue
Block a user