port; refactor widescreen PR a bit

abstract aspect into a video* function

re-add gun swivel, but make it slower on hi res
This commit is contained in:
fgsfds 2023-08-14 17:39:02 +02:00
parent 65115089af
commit c3fb50c358
5 changed files with 37 additions and 24 deletions

View File

@ -996,11 +996,8 @@ static float gfx_adjust_x_for_aspect_ratio(float x) {
if (fbActive) {
return x;
} else {
#ifdef PLATFORM_N64
return x * (4.0f / 3.0f) / ((float)gfx_current_dimensions.width / (float)gfx_current_dimensions.height);
#else
return x * ((float)gfx_current_window_dimensions.width / gfx_current_window_dimensions.height) / ((float)gfx_current_dimensions.width / (float)gfx_current_dimensions.height);
#endif
return x * ((float)gfx_current_window_dimensions.width / gfx_current_window_dimensions.height) /
((float)gfx_current_dimensions.width / (float)gfx_current_dimensions.height);
}
}
@ -2586,18 +2583,12 @@ extern "C" void gfx_start_frame(void) {
gfx_current_window_dimensions.height = 1;
}
#ifdef PLATFORM_N64
gfx_current_dimensions.aspect_ratio = 4.0f / 3.0f;
#else
// for now ensure that the game renders in a centered 4:3 window
// proper 16:9 support requires some fixes, namely the sky, fullscreen fades and room culling
gfx_current_dimensions.aspect_ratio = (float)gfx_current_window_dimensions.width / gfx_current_window_dimensions.height;
#endif
gfx_current_dimensions.height = gfx_current_window_dimensions.height;
gfx_current_dimensions.width = gfx_current_dimensions.height * gfx_current_dimensions.aspect_ratio;
gfx_current_window_dimensions.aspect_ratio = (float)gfx_current_window_dimensions.width / gfx_current_window_dimensions.height;
gfx_current_dimensions = gfx_current_window_dimensions;
gfx_current_game_window_viewport.width = gfx_current_dimensions.width;
gfx_current_game_window_viewport.height = gfx_current_dimensions.height;
gfx_current_game_window_viewport.x = (gfx_current_window_dimensions.width - gfx_current_dimensions.width) / 2;
if (gfx_current_dimensions.height != gfx_prev_dimensions.height) {
for (auto& fb : framebuffers) {

View File

@ -14,4 +14,8 @@ void *videoGetWindowHandle(void);
void videoUpdateNativeResolution(const int w, const int h);
s32 videoGetWidth(void);
s32 videoGetHeight(void);
f32 videoGetAspect(void);
#endif

View File

@ -90,3 +90,18 @@ void videoUpdateNativeResolution(const int w, const int h)
gfx_current_native_viewport.width = w;
gfx_current_native_viewport.height = h;
}
s32 videoGetWidth(void)
{
return gfx_current_dimensions.width;
}
s32 videoGetHeight(void)
{
return gfx_current_dimensions.height;
}
f32 videoGetAspect(void)
{
return gfx_current_dimensions.aspect_ratio;
}

View File

@ -40,6 +40,7 @@
#include "types.h"
#ifndef PLATFORM_N64
#include "input.h"
#include "video.h"
#endif
void bmoveSetControlDef(u32 controldef)
@ -1827,7 +1828,6 @@ void bmoveProcessInput(bool allowc1x, bool allowc1y, bool allowc1buttons, bool i
bgunSwivelWithDamp(x, y, g_Vars.currentplayer->autoaimdamp);
}
} else {
#ifdef PLATFORM_N64
// This code moves the crosshair as the player turns and makes
// it return to the centre when not affected by anything else.
if (g_Vars.currentplayer->autoaimdamp < (PAL ? 0.974f : 0.979f)) {
@ -1838,14 +1838,17 @@ void bmoveProcessInput(bool allowc1x, bool allowc1y, bool allowc1buttons, bool i
g_Vars.currentplayer->autoaimdamp = (PAL ? 0.974f : 0.979f);
}
#ifdef PLATFORM_N64
x = g_Vars.currentplayer->speedtheta * 0.3f + g_Vars.currentplayer->gunextraaimx;
y = -g_Vars.currentplayer->speedverta * 0.1f + g_Vars.currentplayer->gunextraaimy;
#else
const f32 xscale = 320.f / (f32)videoGetWidth();
const f32 yscale = 240.f / (f32)videoGetHeight();
x = g_Vars.currentplayer->speedtheta * 0.3f * xscale + g_Vars.currentplayer->gunextraaimx;
y = -g_Vars.currentplayer->speedverta * 0.1f * yscale + g_Vars.currentplayer->gunextraaimy;
#endif
bgunSwivelWithDamp(x, y, PAL ? 0.955f : 0.963f);
#else
bgunSetAimType(0);
bgunSwivelWithoutDamp((movedata.c1stickxraw * 0.65f) / 80.0f, (movedata.c1stickyraw * 0.65f) / 80.0f);
#endif
}
} else if (movedata.canmanualaim) {
// Adjust crosshair's position on screen

View File

@ -1,7 +1,4 @@
#include <ultra64.h>
#ifndef PLATFORM_N64
#include "../fast3d/gfx_api.h"
#endif
#include "constants.h"
#include "game/bondeyespy.h"
#include "game/bondmove.h"
@ -73,6 +70,9 @@
#include "lib/lib_317f0.h"
#include "data.h"
#include "types.h"
#ifndef PLATFORM_N64
#include "video.h"
#endif
s32 g_DefaultWeapons[2];
f32 g_MpSwirlRotateSpeed;
@ -3002,7 +3002,7 @@ f32 player0f0bd358(void)
#ifdef PLATFORM_N64
return result;
#else
return result * (((float)gfx_current_window_dimensions.width / gfx_current_window_dimensions.height) / (4.0f / 3.0f));
return result * (videoGetAspect() / (4.0f / 3.0f));
#endif
}