Merge branch 'port' of https://github.com/Phnod/perfect_dark into zoom-hud-fov

# Conflicts:
#	src/include/data.h
This commit is contained in:
Phnod committed 2023-09-02 19:05:12 -04:00
commit d033a7fa02
27 files changed
+638 -170

No files matched your search

+11 -4
View File
@@ -1295,12 +1295,19 @@ void bmoveProcessInput(bool allowc1x, bool allowc1y, bool allowc1buttons, bool i
movedata.aimturnleftspeed = (g_Vars.currentplayer->swivelpos[0] - -0.9f) / -0.1f;
movedata.aimturnrightspeed = 0.f;
}
f32 vertaup = 0.f, vertadown = 0.f;
if (g_Vars.currentplayer->swivelpos[1] > 0.9f) {
movedata.speedvertaup = (g_Vars.currentplayer->swivelpos[1] - 0.9f) / 0.1f;
movedata.speedvertadown = 0.f;
vertaup = (g_Vars.currentplayer->swivelpos[1] - 0.9f) / 0.1f;
} else if (g_Vars.currentplayer->swivelpos[1] < -0.9f) {
movedata.speedvertadown = (g_Vars.currentplayer->swivelpos[1] - -0.9f) / -0.1f;
movedata.speedvertaup = 0.f;
vertadown = (g_Vars.currentplayer->swivelpos[1] - -0.9f) / -0.1f;
}
// Uninvert pitch if needed
if (movedata.invertpitch) {
movedata.speedvertaup = vertadown;
movedata.speedvertadown = vertaup;
} else {
movedata.speedvertaup = vertaup;
movedata.speedvertadown = vertadown;
}
} else {
// Reset mouse aim position when not mouse aiming
+20 -2
View File
@@ -211,7 +211,7 @@ Gfx *bviewPrepareStaticRgba16(Gfx *gdl, u32 colour, u32 alpha)
gDPSetTexturePersp(gdl++, G_TP_NONE);
gDPSetColorDither(gdl++, G_CD_DISABLE);
gDPSetAlphaDither(gdl++, G_AD_NOISE);
gDPSetRenderMode(gdl++, G_RM_CLD_SURF, G_RM_NOOP2);
gDPSetRenderMode(gdl++, G_RM_CLD_SURF, G_RM_CLD_SURF2);
return gdl;
}
@@ -245,7 +245,7 @@ Gfx *bviewPrepareStaticI8(Gfx *gdl, u32 colour, u32 alpha)
gDPSetTexturePersp(gdl++, G_TP_NONE);
gDPSetColorDither(gdl++, G_CD_DISABLE);
gDPSetAlphaDither(gdl++, G_AD_NOISE);
gDPSetRenderMode(gdl++, G_RM_CLD_SURF, G_RM_NOOP2);
gDPSetRenderMode(gdl++, G_RM_CLD_SURF, G_RM_CLD_SURF2);
return gdl;
}
@@ -1952,6 +1952,9 @@ Gfx *bviewDrawNvLens(Gfx *gdl)
s32 viewbottom = viewtop + viewheight;
s32 brightness;
s32 y;
#ifdef AVOID_UB
u32 mpindex = g_Vars.currentplayerstats->mpindex % MAX_PLAYERS;
#endif
var8007f840++;
@@ -1973,9 +1976,15 @@ Gfx *bviewDrawNvLens(Gfx *gdl)
skySetOverexposure(brightness, brightness, brightness);
}
#ifdef AVOID_UB
if (g_Menus[mpindex].curdialog == NULL) {
gdl = bviewDrawMotionBlur(gdl, 0x00ff0000, 0x60);
}
#else
if (g_Menus[g_Vars.currentplayerstats->mpindex].curdialog == NULL) {
gdl = bviewDrawMotionBlur(gdl, 0x00ff0000, 0x60);
}
#endif
gDPPipeSync(gdl++);
@@ -2034,6 +2043,9 @@ Gfx *bviewDrawIrLens(Gfx *gdl)
s32 viewcentrey;
f32 viewheightf;
s32 a0;
#ifdef AVOID_UB
u32 mpindex = g_Vars.currentplayerstats->mpindex % MAX_PLAYERS;
#endif
#if VERSION < VERSION_NTSC_1_0
static s32 fsscanline = 0;
@@ -2198,9 +2210,15 @@ Gfx *bviewDrawIrLens(Gfx *gdl)
#endif
}
#ifdef AVOID_UB
if (g_Menus[mpindex].curdialog == NULL) {
gdl = bviewDrawMotionBlur(gdl, 0xff000000, 0x40);
}
#else
if (g_Menus[g_Vars.currentplayerstats->mpindex].curdialog == NULL) {
gdl = bviewDrawMotionBlur(gdl, 0xff000000, 0x40);
}
#endif
return gdl;
}
+9
View File
@@ -1,4 +1,5 @@
#include <ultra64.h>
#include <string.h>
#include "constants.h"
#include "game/atan2f.h"
#include "game/camera.h"
@@ -600,6 +601,9 @@ bool camIsPosInFovAndVisibleRoom(RoomNum *rooms, struct coord *pos, f32 arg2)
RoomNum room;
bool hasdata = false;
struct drawslot *thisthing;
#ifdef AVOID_UB
static struct drawslot dslot;
#endif
struct screenbox box;
for (i = 0, room = rooms[i]; room != -1; i++, room = rooms[i]) {
@@ -637,5 +641,10 @@ bool camIsPosInFovAndVisibleRoom(RoomNum *rooms, struct coord *pos, f32 arg2)
return false;
}
#ifdef AVOID_UB
memcpy(&dslot.box, &box, sizeof(box));
return camIsPosInScreenBox(pos, arg2, &dslot);
#else
return camIsPosInScreenBox(pos, arg2, (struct drawslot *) &(((u8 *) &box)[-((uintptr_t) &(((struct drawslot *)0)->box))]));
#endif
}
+10
View File
@@ -585,6 +585,16 @@ struct menuitem g_MainMenu4MbMenuItems[] = {
0,
(void *)&g_ChangeAgentMenuDialog,
},
#ifndef PLATFORM_N64
{
MENUITEMTYPE_SELECTABLE,
0,
MENUITEMFLAG_SELECTABLE_OPENSDIALOG | MENUITEMFLAG_BIGFONT,
L_OPTIONS_110, // "Exit Game"
0x00000007,
(void *)&g_ExitGameMenuDialog,
},
#endif
{ MENUITEMTYPE_END },
};
+2 -2
View File
@@ -394,7 +394,7 @@ Gfx *text0f153628(Gfx *gdl)
}
#endif
else {
gDPSetTextureFilter(gdl++, G_TF_BILERP);
gDPSetTextureFilter(gdl++, TEX_FILTER_2D);
}
return gdl;
@@ -1790,7 +1790,7 @@ Gfx *text0f15568c(Gfx *gdl, s32 *x, s32 *y, struct fontchar *curchar, struct fon
(*x + curchar->width) * 4 + var8007fadc,
G_TX_RENDERTILE,
var8007fae8 + 32,
((curchar->height - 1) << 5) + var8007fae4 + 32,
((curchar->height) << 5) + var8007fae4 + 32,
1024,
65536 - 1024 / var8007fad0);
} else {
+4
View File
@@ -329,7 +329,11 @@ void gfxReplaceGbiCommands(Gfx *startgdl, Gfx *endgdl, s32 type)
void gfxReplaceGbiCommandsRecursively(struct roomblock *block, s32 type)
{
#ifndef AVOID_UB
// Sometimes block is NULL when this is called.
// If UBSan is being used, this will crash in this instance.
if (block->type == ROOMBLOCKTYPE_PARENT);
#endif
while (true) {
if (!block) {
+4
View File
@@ -2525,6 +2525,7 @@ struct menuitem g_VideoOptionsMenuItems[] = {
0,
menuhandlerScreenSize,
},
#ifdef PLATFORM_N64
{
MENUITEMTYPE_DROPDOWN,
0,
@@ -2541,6 +2542,7 @@ struct menuitem g_VideoOptionsMenuItems[] = {
0,
menuhandlerHiRes,
},
#endif
#if PAL
{
MENUITEMTYPE_DROPDOWN,
@@ -2587,6 +2589,7 @@ struct menuitem g_VideoOptionsMenuItems[] = {
};
struct menuitem g_2PMissionVideoOptionsMenuItems[] = {
#ifdef PLATFORM_N64
{
MENUITEMTYPE_DROPDOWN,
0,
@@ -2603,6 +2606,7 @@ struct menuitem g_2PMissionVideoOptionsMenuItems[] = {
0,
menuhandlerHiRes,
},
#endif
#if PAL
{
MENUITEMTYPE_DROPDOWN,
+25 -4
View File
@@ -3011,7 +3011,7 @@ Gfx *dialogRender(Gfx *gdl, struct menudialog *dialog, struct menu *menu, bool l
textMeasure(&textheight, &textwidth, title, g_CharsHandelGothicXs, g_FontHandelGothicXs, 0);
x = dialogleft - 1;
x = dialogleft - 2;
y = (dialogtop + dialogbottom) / 2 - textwidth - 3;
if (y < dialogtop) {
@@ -3411,8 +3411,14 @@ void menuClose(void)
void func0f0f8120(void)
{
#ifdef AVOID_UB
u32 mpindex = g_MpPlayerNum % MAX_PLAYERS;
struct menudialog *prev = g_Menus[mpindex].curdialog;
s32 i;
#else
struct menudialog *prev = g_Menus[g_MpPlayerNum].curdialog;
s32 i;
#endif
if (g_MenuData.unk66e > 0) {
for (i = g_MenuData.unk66e; i >= 0; i--) {
@@ -3420,11 +3426,22 @@ void func0f0f8120(void)
}
}
#ifdef AVOID_UB
mpindex = g_MpPlayerNum;
if (mpindex >= MAX_PLAYERS)
mpindex -= MAX_PLAYERS;
if (g_Menus[mpindex].curdialog == prev) {
while (g_Menus[mpindex].depth > 0) {
menuPopDialog();
}
}
#else
if (g_Menus[g_MpPlayerNum].curdialog == prev) {
while (g_Menus[g_MpPlayerNum].depth > 0) {
menuPopDialog();
}
}
#endif
}
void func0f0f820c(struct menudialogdef *dialogdef, s32 root)
@@ -4338,7 +4355,11 @@ void dialogTick(struct menudialog *dialog, struct menuinputs *inputs, u32 tickfl
}
// Apply default navigational behaviour if requested
#ifdef AVOID_UB
if (usedefaultbehaviour && (tickflags & MENUTICKFLAG_DIALOGISCURRENT) && !dialog->dimmed && g_Menus[g_MpPlayerNum].depth >= 1) {
#else
if (usedefaultbehaviour && (tickflags & MENUTICKFLAG_DIALOGISCURRENT) && !dialog->dimmed) {
#endif
struct menulayer *layer = &g_Menus[g_MpPlayerNum].layers[g_Menus[g_MpPlayerNum].depth - 1];
if (layer->numsiblings <= 1) {
@@ -4603,11 +4624,11 @@ void menuProcessInput(void)
if (buttonsnow & BUTTON_RADIAL) {
inputs.select = 1;
}
// this will naturally feel nice w/ a switch layout
// with the default mapping for weapon-back
if (buttonsnow & BUTTON_WPNBACK) {
inputs.select = 1;
inputs.back = 1;
}
#endif
if (buttonsnow & B_BUTTON) {
inputs.back = 1;
+4
View File
@@ -296,7 +296,11 @@ s32 optionsGetScreenRatio(void)
void optionsSetScreenRatio(s32 ratio)
{
#ifdef PLATFORM_N64
g_ScreenRatio = ratio;
#else
g_ScreenRatio = SCREENRATIO_NORMAL;
#endif
}
u8 optionsGetScreenSplit(void)
+4
View File
@@ -2794,7 +2794,11 @@ void playerResetLoResIf4Mb(void)
void playerSetHiResEnabled(bool enable)
{
#ifdef PLATFORM_N64
g_HiResEnabled = enable;
#else
g_HiResEnabled = false;
#endif
}
s16 playerGetFbWidth(void)
+75
View File
@@ -15,6 +15,7 @@
#include "data.h"
#include "types.h"
#ifndef PLATFORM_N64
#include "game/gfxmemory.h"
#include "game/game_13c510.h"
#include "game/player.h"
#endif
@@ -826,6 +827,7 @@ Gfx *skyRender(Gfx *gdl)
gDPSetRenderMode(gdl++, G_RM_OPA_SURF, G_RM_OPA_SURF2);
#ifdef PLATFORM_N64
if (numvertices == 4) {
gdl = skyRenderTri(gdl, &watervertices2d[0], &watervertices2d[1], &watervertices2d[3], 130.0f, true);
@@ -846,6 +848,42 @@ Gfx *skyRender(Gfx *gdl)
// 1 corner is on the ground
gdl = skyRenderTri(gdl, &watervertices2d[0], &watervertices2d[1], &watervertices2d[2], 130.0f, true);
}
#else
Vtx *verts = gfxAllocateVertices(5);
Col *cols = gfxAllocateColours(5);
Mtxf *mtx = gfxAllocateMatrix();
mtx4MultMtx4(camGetWorldToScreenMtxf(), &g_SkyMtx, mtx);
mtxF2L(mtx, mtx);
gSPSetExtraGeometryModeEXT(gdl++, G_NO_CLIPPING_EXT);
gSPMatrix(gdl++, osVirtualToPhysical(mtx), G_MTX_MODELVIEW | G_MTX_LOAD | G_MTX_PUSH);
gSPColor(gdl++, osVirtualToPhysical(cols), numvertices);
gSPVertex(gdl++, osVirtualToPhysical(verts), numvertices, 0);
for (s32 i = 0; i < numvertices; ++i) {
verts[i].x = watervertices3d[i].x;
verts[i].y = watervertices3d[i].y;
verts[i].z = watervertices3d[i].z;
verts[i].s = skyClamp(watervertices3d[i].s, -32768.f, 32767.f);
verts[i].t = skyClamp(watervertices3d[i].t, -32768.f, 32767.f);
verts[i].colour = i * 4;
cols[i].r = watervertices3d[i].r;
cols[i].g = watervertices3d[i].g;
cols[i].b = watervertices3d[i].b;
cols[i].a = watervertices3d[i].a;
}
if (numvertices == 4) {
gSPTri2(gdl++, 0, 1, 3, 3, 2, 0);
} else if (numvertices == 5) {
gSPTri3(gdl++, 0, 1, 2, 0, 2, 3, 0, 3, 4);
} else if (numvertices == 3) {
gSPTri1(gdl++, 0, 1, 2);
}
gSPPopMatrix(gdl++, G_MTX_MODELVIEW);
gSPClearExtraGeometryModeEXT(gdl++, G_NO_CLIPPING_EXT);
#endif
}
}
@@ -1252,6 +1290,7 @@ Gfx *skyRender(Gfx *gdl)
skyvertices2d[i].y = skyClamp(skyvertices2d[i].y, camGetScreenTop() * 4.0f, (camGetScreenTop() + camGetScreenHeight()) * 4.0f - 1.0f);
}
#ifdef PLATFORM_N64
if (numvertices == 4) {
if (cornerstate == CORNERSTATE_TOP) {
if (sp548 < sp54c) {
@@ -1292,6 +1331,42 @@ Gfx *skyRender(Gfx *gdl)
// One corner is in the sky
gdl = skyRenderTri(gdl, &skyvertices2d[0], &skyvertices2d[1], &skyvertices2d[2], 130.0f, true);
}
#else
Vtx *verts = gfxAllocateVertices(5);
Col *cols = gfxAllocateColours(5);
Mtxf *mtx = gfxAllocateMatrix();
mtx4MultMtx4(camGetWorldToScreenMtxf(), &g_SkyMtx, mtx);
mtxF2L(mtx, mtx);
gSPSetExtraGeometryModeEXT(gdl++, G_NO_CLIPPING_EXT);
gSPMatrix(gdl++, osVirtualToPhysical(mtx), G_MTX_MODELVIEW | G_MTX_LOAD | G_MTX_PUSH);
gSPColor(gdl++, osVirtualToPhysical(cols), numvertices);
gSPVertex(gdl++, osVirtualToPhysical(verts), numvertices, 0);
for (s32 i = 0; i < numvertices; ++i) {
verts[i].x = skyvertices3d[i].x;
verts[i].y = skyvertices3d[i].y;
verts[i].z = skyvertices3d[i].z;
verts[i].s = skyClamp(skyvertices3d[i].s, -32768.f, 32767.f);
verts[i].t = skyClamp(skyvertices3d[i].t, -32768.f, 32767.f);
verts[i].colour = i * 4;
cols[i].r = skyvertices3d[i].r;
cols[i].g = skyvertices3d[i].g;
cols[i].b = skyvertices3d[i].b;
cols[i].a = skyvertices3d[i].a;
}
if (numvertices == 4) {
gSPTri2(gdl++, 0, 1, 3, 3, 2, 0);
} else if (numvertices == 5) {
gSPTri3(gdl++, 0, 1, 2, 0, 2, 3, 0, 3, 4);
} else if (numvertices == 3) {
gSPTri1(gdl++, 0, 1, 2);
}
gSPPopMatrix(gdl++, G_MTX_MODELVIEW);
gSPClearExtraGeometryModeEXT(gdl++, G_NO_CLIPPING_EXT);
#endif
}
return gdl;
+1 -1
View File
@@ -335,7 +335,7 @@ Gfx *sparksRender(Gfx *gdl)
gDPSetCycleType(gdl++, G_CYC_1CYCLE);
gDPSetColorDither(gdl++, G_CD_DISABLE);
gDPSetRenderMode(gdl++, G_RM_AA_ZB_XLU_SURF, G_RM_NOOP2);
gDPSetRenderMode(gdl++, G_RM_AA_ZB_XLU_SURF, G_RM_AA_ZB_XLU_SURF2);
gDPSetAlphaCompare(gdl++, G_AC_NONE);
gDPSetTextureLOD(gdl++, G_TL_TILE);
gDPSetTextureConvert(gdl++, G_TC_FILT);
+3
View File
@@ -39,6 +39,9 @@ s32 g_TexLutMode;
u32 var800ab5b4;
struct tilestate g_TexTileStates[8];
struct tilesize g_TexTileSizes[8];
#ifndef PLATFORM_N64
u32 g_TexFilter2D = G_TF_BILERP;
#endif
// Default
u16 g_SurfaceTypeDefaultSounds[] = { SFX_HIT_STONE_8087, SFX_HIT_STONE_8088 };
+3
View File
@@ -136,6 +136,9 @@ void texReset(void)
// reset backend texture cache
videoResetTextureCache();
// get backend texture settings
g_TexFilter2D = videoGetTextureFilter2D() ? G_TF_BILERP : G_TF_POINT;
#endif
g_TexWords = mempAlloc(ALIGN16(g_TexNumConfigs * 4), MEMPOOL_STAGE);
+2 -2
View File
@@ -823,7 +823,7 @@ Gfx *weatherRenderRain(Gfx *gdl, struct weatherdata *weather, s32 arg2)
gDPSetCycleType(gdl++, G_CYC_1CYCLE);
gDPSetColorDither(gdl++, G_CD_DISABLE);
gDPSetRenderMode(gdl++, G_RM_AA_ZB_XLU_SURF, G_RM_NOOP2);
gDPSetRenderMode(gdl++, G_RM_AA_ZB_XLU_SURF, G_RM_AA_ZB_XLU_SURF2);
gDPSetAlphaCompare(gdl++, G_AC_NONE);
gDPSetTextureLOD(gdl++, G_TL_TILE);
gDPSetTextureConvert(gdl++, G_TC_FILT);
@@ -2902,7 +2902,7 @@ Gfx *weatherRenderSnow(Gfx *gdl, struct weatherdata *weather, s32 arg2)
gDPSetCycleType(gdl++, G_CYC_1CYCLE);
gDPSetColorDither(gdl++, G_CD_DISABLE);
gDPSetRenderMode(gdl++, G_RM_AA_ZB_XLU_SURF, G_RM_NOOP2);
gDPSetRenderMode(gdl++, G_RM_AA_ZB_XLU_SURF, G_RM_AA_ZB_XLU_SURF2);
gDPSetAlphaCompare(gdl++, G_AC_NONE);
gDPSetTextureLOD(gdl++, G_TL_TILE);
gDPSetTextureConvert(gdl++, G_TC_FILT);
+10
View File
@@ -528,7 +528,9 @@ extern struct menudialogdef g_HtDetailsMenuDialog;
extern struct menudialogdef g_HtFailedMenuDialog;
extern struct menudialogdef g_HtCompletedMenuDialog;
extern struct menudialogdef g_HangarListMenuDialog;
#ifndef PLATFORM_N64
extern f32 g_PlayerCrosshairSway;
extern f32 g_PlayerDefaultFovY;
extern s32 g_PlayerMouseAimMode;
@@ -536,6 +538,14 @@ extern f32 g_PlayerMouseAimSpeedX;
extern f32 g_PlayerMouseAimSpeedY;
extern s32 g_PlayerFovAffectsZoom;
extern f32 g_PlayerFovZoomMultiplier;
extern u32 g_TexFilter2D;
#define TEX_FILTER_2D g_TexFilter2D
#else
#define TEX_FILTER_2D G_TF_BILERP
#endif
#ifdef PLATFORM_N64
+3
View File
@@ -10,6 +10,9 @@ extern struct menudialogdef g_AcceptMissionMenuDialog;
extern struct menudialogdef g_PreAndPostMissionBriefingMenuDialog;
extern struct menudialogdef g_RetryMissionMenuDialog;
extern struct menudialogdef g_NextMissionMenuDialog;
#ifndef PLATFORM_N64
extern struct menudialogdef g_ExitGameMenuDialog;
#endif
char *menuTextCurrentStageName(struct menuitem *item);
char *soloMenuTextDifficulty(struct menuitem *item);
+1
View File
@@ -201,6 +201,7 @@
#define G_ASPECT_RIGHT_EXT 0x00000020
#define G_ASPECT_CENTER_EXT (G_ASPECT_LEFT_EXT | G_ASPECT_RIGHT_EXT)
#define G_ASPECT_MODE_EXT G_ASPECT_CENTER_EXT
#define G_NO_CLIPPING_EXT 0x00000040
/* Extended command macros */