From 6edc8681dadbb5a7270b16c1cfcbd9408a2bed08 Mon Sep 17 00:00:00 2001 From: Ryan Dwyer Date: Wed, 10 May 2023 21:24:13 +1000 Subject: [PATCH] Remove a heap of one-liner functions --- ld/pd.ld | 2 - src/game/activemenu.c | 48 ++-- src/game/activemenutick.c | 6 +- src/game/bg.c | 53 ++--- src/game/bgbss.c | 2 +- src/game/body.c | 8 +- src/game/bondbike.c | 30 ++- src/game/bondeyespy.c | 41 +--- src/game/bondgrab.c | 24 +- src/game/bondgun.c | 186 ++++++---------- src/game/bondgunreset.c | 1 - src/game/bondhead.c | 6 +- src/game/bondheadreset.c | 2 +- src/game/bondmove.c | 63 +++--- src/game/bondview.c | 156 ++++++------- src/game/bondwalk.c | 30 ++- src/game/bot.c | 2 +- src/game/botact.c | 2 +- src/game/camera.c | 132 ----------- src/game/chr.c | 103 ++++----- src/game/chraction.c | 116 ++++------ src/game/chraicommands.c | 22 +- src/game/credits.c | 4 +- src/game/dlights.c | 15 +- src/game/dyntex.c | 16 +- src/game/endscreen.c | 20 +- src/game/env.c | 27 +-- src/game/explosions.c | 10 +- src/game/filemgr.c | 20 +- src/game/game_0b0fd0.c | 11 +- src/game/game_0b2150.c | 4 +- src/game/game_13c510.c | 28 +-- src/game/game_1531a0.c | 6 +- src/game/game_176080.c | 29 ++- src/game/gamefile.c | 37 ++-- src/game/gunfx.c | 28 +-- src/game/hudmsg.c | 80 +++---- src/game/inv.c | 14 +- src/game/lv.c | 101 ++++----- src/game/mainmenu.c | 39 ++-- src/game/menu.c | 156 ++++++------- src/game/menugfx.c | 16 +- src/game/menuitem.c | 100 ++++----- src/game/menutick.c | 6 +- src/game/mplayer/ingame.c | 8 +- src/game/mplayer/mplayer.c | 22 +- src/game/mplayer/scenarios.c | 8 +- src/game/mplayer/scenarios/hackthatmac.inc | 8 +- .../mplayer/scenarios/holdthebriefcase.inc | 6 +- src/game/mplayer/scenarios/kingofthehill.inc | 6 +- src/game/mplayer/scenarios/popacap.inc | 6 +- src/game/mplayer/setup.c | 6 +- src/game/music.c | 2 +- src/game/nbomb.c | 18 +- src/game/objectives.c | 29 +-- src/game/objectivesreset.c | 2 +- src/game/options.c | 140 ------------ src/game/padhalllv.c | 3 +- src/game/player.c | 159 ++++++-------- src/game/playermgr.c | 13 +- src/game/playerreset.c | 2 +- src/game/prop.c | 80 +++---- src/game/propobj.c | 205 ++++++++---------- src/game/propsnd.c | 6 +- src/game/raceinit.c | 2 +- src/game/radar.c | 8 +- src/game/savebuffer.c | 22 +- src/game/setup.c | 27 ++- src/game/shards.c | 12 +- src/game/sight.c | 46 ++-- src/game/sky.c | 168 +++++++------- src/game/smoke.c | 8 +- src/game/sparks.c | 4 +- src/game/stars.c | 12 +- src/game/tex.c | 2 +- src/game/texreset.c | 3 - src/game/title.c | 38 ++-- src/game/titleclear.c | 4 +- src/game/training.c | 18 +- src/game/trainingmenus.c | 48 ++-- src/game/vtxstore.c | 2 +- src/game/weather.c | 6 +- src/include/bss.h | 2 +- src/include/game/bg.h | 1 - src/include/game/bondgun.h | 16 +- src/include/game/bondmove.h | 1 - src/include/game/camera.h | 23 -- src/include/game/chr.h | 7 +- src/include/game/chraction.h | 3 - src/include/game/dlights.h | 1 - src/include/game/dyntex.h | 2 + src/include/game/env.h | 6 +- src/include/game/game_0b0fd0.h | 1 - src/include/game/lv.h | 5 +- src/include/game/objectives.h | 1 - src/include/game/options.h | 99 ++++++--- src/include/game/player.h | 5 +- src/include/game/playermgr.h | 2 - src/include/game/prop.h | 6 +- src/include/game/propobj.h | 1 - src/include/lib/anim.h | 12 +- src/include/lib/audiomgr.h | 1 - src/include/lib/boot.h | 3 +- src/include/lib/collision.h | 17 +- src/include/lib/main.h | 2 +- src/include/lib/model.h | 6 +- src/include/lib/mp3.h | 1 - src/include/lib/mtx.h | 2 - src/include/lib/snd.h | 16 +- src/include/lib/vi.h | 20 +- src/lib/anim.c | 10 - src/lib/audiomgr.c | 5 - src/lib/boot.c | 5 - src/lib/collision.c | 71 ++---- src/lib/lib_04f60nb.c | 7 - src/lib/main.c | 26 +-- src/lib/memp.c | 2 +- src/lib/model.c | 27 +-- src/lib/mp3.c | 5 - src/lib/mtx.c | 10 - src/lib/profile.c | 18 +- src/lib/sched.c | 2 +- src/lib/snd.c | 24 +- src/lib/vi.c | 138 ++++-------- src/lib/vm.c | 45 ++-- tools/ai2asm/ai2asm.py | 12 +- 126 files changed, 1448 insertions(+), 2182 deletions(-) delete mode 100644 src/lib/lib_04f60nb.c diff --git a/ld/pd.ld b/ld/pd.ld index 4dc4d4ab3..70b475cef 100644 --- a/ld/pd.ld +++ b/ld/pd.ld @@ -107,8 +107,6 @@ SECTIONS osMemSize = 0x80000318; osAppNMIBuffer = 0x8000031c; - viGetHeight_hack = viGetHeight; - /*************************************************************************** * romheader * ------------------------------------------------------------------------- diff --git a/src/game/activemenu.c b/src/game/activemenu.c index 37cfd4fa6..65df117e1 100644 --- a/src/game/activemenu.c +++ b/src/game/activemenu.c @@ -189,7 +189,7 @@ static s32 amPickTargetMenuList(s32 operation, struct menuitem *item, union hand y = renderdata->y + 1; gdl = text0f153628(gdl); - gdl = textRenderProjected(gdl, &x, &y, g_MpAllChrConfigPtrs[chrindex]->name, g_CharsHandelGothicSm, g_FontHandelGothicSm, colour, viGetWidth(), viGetHeight(), 0, 0); + gdl = textRenderProjected(gdl, &x, &y, g_MpAllChrConfigPtrs[chrindex]->name, g_CharsHandelGothicSm, g_FontHandelGothicSm, colour, g_ViBackData->x, g_ViBackData->y, 0, 0); gdl = text0f153780(gdl); return (s32)gdl; } @@ -759,7 +759,7 @@ void amClose(void) static bool amIsCramped(void) { return (g_AmMenus[g_AmIndex].screenindex == 0 && PLAYERCOUNT() >= 3) - || (PLAYERCOUNT() == 2 && optionsGetScreenSplit() == SCREENSPLIT_VERTICAL); + || (PLAYERCOUNT() == 2 && g_ScreenSplit == SCREENSPLIT_VERTICAL); } static void amCalculateSlotPosition(s16 column, s16 row, s16 *x, s16 *y) @@ -804,10 +804,10 @@ static void amCalculateSlotPosition(s16 column, s16 row, s16 *x, s16 *y) *y = (*y * 3) / 5; } - *x += viGetViewLeft() + viGetViewWidth() / 2; - *y += viGetViewTop() + viGetViewHeight() / 2; + *x += g_ViBackData->viewleft + g_ViBackData->viewx / 2; + *y += g_ViBackData->viewtop + g_ViBackData->viewy / 2; - if ((playercount == 2 && optionsGetScreenSplit() == SCREENSPLIT_VERTICAL) || playercount >= 3) { + if ((playercount == 2 && g_ScreenSplit == SCREENSPLIT_VERTICAL) || playercount >= 3) { if ((g_Vars.currentplayernum % 2) == 0) { *x += 8; } else { @@ -848,7 +848,7 @@ static Gfx *amRenderAibotInfo(Gfx *gdl, s32 buddynum) wide = true; } - if ((PLAYERCOUNT() == 2 && optionsGetScreenSplit() == SCREENSPLIT_VERTICAL) || PLAYERCOUNT() >= 3) { + if ((PLAYERCOUNT() == 2 && g_ScreenSplit == SCREENSPLIT_VERTICAL) || PLAYERCOUNT() >= 3) { if ((g_Vars.currentplayernum % 2) == 0) { offset = 8; } else { @@ -874,19 +874,19 @@ static Gfx *amRenderAibotInfo(Gfx *gdl, s32 buddynum) textMeasure(&textheight, &textwidth, aibotname, g_AmFont1, g_AmFont2, 0); - x = viGetViewLeft() - + (s32)(viGetViewWidth() * 0.5f) + x = g_ViBackData->viewleft + + (s32)(g_ViBackData->viewx * 0.5f) - (s32)(textwidth * 0.5f) + offset; if (PLAYERCOUNT() >= 2) { - y = viGetViewTop() + 5; + y = g_ViBackData->viewtop + 5; } else { - y = viGetViewTop() + 10; + y = g_ViBackData->viewtop + 10; } if (wide) { - x = viGetViewLeft() + 32; + x = g_ViBackData->viewleft + 32; } gdl = textRender(gdl, &x, &y, aibotname, g_AmFont1, g_AmFont2, -1, @@ -895,13 +895,13 @@ static Gfx *amRenderAibotInfo(Gfx *gdl, s32 buddynum) y += (PLAYERCOUNT() >= 2) ? 0 : (s32)(textheight * 1.1f); textMeasure(&textheight, &textwidth, weaponname, g_AmFont1, g_AmFont2, 0); - x = viGetViewLeft() - + (s32)(viGetViewWidth() * 0.5f) + x = g_ViBackData->viewleft + + (s32)(g_ViBackData->viewx * 0.5f) - (s32)(textwidth * 0.5f) + offset; if (wide) { - x = viGetViewLeft() + 32; + x = g_ViBackData->viewleft + 32; } gdl = textRender(gdl, &x, &y, weaponname, g_AmFont1, g_AmFont2, -1, @@ -913,19 +913,19 @@ static Gfx *amRenderAibotInfo(Gfx *gdl, s32 buddynum) textMeasure(&textheight, &textwidth, title, g_AmFont1, g_AmFont2, 0); - x = viGetViewLeft() - + (s32)(viGetViewWidth() * 0.5f) + x = g_ViBackData->viewleft + + (s32)(g_ViBackData->viewx * 0.5f) - (s32)(textwidth * 0.5f) + offset; if (PLAYERCOUNT() >= 2) { - y = viGetViewTop() + 5; + y = g_ViBackData->viewtop + 5; } else { - y = viGetViewTop() + 10; + y = g_ViBackData->viewtop + 10; } if (wide) { - x = viGetViewLeft() + 32; + x = g_ViBackData->viewleft + 32; } gdl = textRender(gdl, &x, &y, title, g_AmFont1, g_AmFont2, -1, @@ -1366,15 +1366,15 @@ Gfx *amRender(Gfx *gdl) barheight = PLAYERCOUNT() >= 2 ? 7 : 11; xoffset = 0; - if ((PLAYERCOUNT() == 2 && optionsGetScreenSplit() == SCREENSPLIT_VERTICAL) || PLAYERCOUNT() >= 3) { + if ((PLAYERCOUNT() == 2 && g_ScreenSplit == SCREENSPLIT_VERTICAL) || PLAYERCOUNT() >= 3) { xoffset = (g_Vars.currentplayernum & 1) == 0 ? 8 : -8; } if (PLAYERCOUNT() == 1 && optionsGetEffectiveScreenSize() != SCREENSIZE_FULL) { - part1left = viGetViewLeft() + 32; + part1left = g_ViBackData->viewleft + 32; } else { - part1left = (s32) (viGetViewWidth() * 0.5f) - + (s32) (viGetViewLeft()) + part1left = (s32) (g_ViBackData->viewx * 0.5f) + + (s32) (g_ViBackData->viewleft) - (s32) (barwidth * 0.5f) + xoffset; } @@ -1392,7 +1392,7 @@ Gfx *amRender(Gfx *gdl) gDPSetRenderMode(gdl++, G_RM_XLU_SURF, G_RM_XLU_SURF2); gDPSetCombineMode(gdl++, G_CC_PRIMITIVE, G_CC_PRIMITIVE); - y = viGetViewTop() + viGetViewHeight() - (PLAYERCOUNT() >= 2 ? 19 : 34); + y = g_ViBackData->viewtop + g_ViBackData->viewy - (PLAYERCOUNT() >= 2 ? 19 : 34); if (redhealth) { a2 = part1left + part1width - (s32) (part1width * (0.25f - healthfrac) * 4.0f); diff --git a/src/game/activemenutick.c b/src/game/activemenutick.c index 09f9a56b9..c19a0945d 100644 --- a/src/game/activemenutick.c +++ b/src/game/activemenutick.c @@ -36,8 +36,8 @@ void amTick(void) } if (g_Vars.currentplayer->activemenumode != AMMODE_CLOSED) { - s32 controlmode = optionsGetControlMode(g_Vars.currentplayerstats->mpindex); - s8 contpadnum = optionsGetContpadNum1(g_Vars.currentplayerstats->mpindex); + s32 controlmode = g_PlayerConfigsArray[g_Vars.currentplayerstats->mpindex].controlmode; + s8 contpadnum = g_PlayerConfigsArray[g_Vars.currentplayerstats->mpindex].contpad1; s32 numsamples = joyGetNumSamples(); s32 j; @@ -143,7 +143,7 @@ void amTick(void) || controlmode == CONTROLMODE_24 || controlmode == CONTROLMODE_22 || controlmode == CONTROLMODE_21) { - s8 contpadnum2 = optionsGetContpadNum2(g_Vars.currentplayerstats->mpindex); + s8 contpadnum2 = g_PlayerConfigsArray[g_Vars.currentplayerstats->mpindex].contpad2; s8 cstickx2 = joyGetStickXOnSample(j, contpadnum2); s8 csticky2 = joyGetStickYOnSample(j, contpadnum2); u16 buttonsstate2 = joyGetButtonsOnSample(j, contpadnum2, 0xffff); diff --git a/src/game/bg.c b/src/game/bg.c index 6cb896fee..8e55d9127 100644 --- a/src/game/bg.c +++ b/src/game/bg.c @@ -896,7 +896,7 @@ Gfx *bgRenderSceneInXray(Gfx *gdl) gDPSetTextureFilter(gdl++, G_TF_BILERP); gDPSetCycleType(gdl++, G_CYC_1CYCLE); gDPSetRenderMode(gdl++, G_RM_AA_XLU_SURF, G_RM_AA_XLU_SURF2); - gSPMatrix(gdl++, osVirtualToPhysical(camGetOrthogonalMtxL()), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_PROJECTION); + gSPMatrix(gdl++, osVirtualToPhysical(g_Vars.currentplayer->orthomtxl), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_PROJECTION); texSelect(&gdl, NULL, 2, 0, 2, 1, NULL); @@ -918,7 +918,7 @@ Gfx *bgRenderSceneInXray(Gfx *gdl) // Render props gdl = currentPlayerScissorToViewport(gdl); - gSPMatrix(gdl++, osVirtualToPhysical(camGetOrthogonalMtxL()), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_PROJECTION); + gSPMatrix(gdl++, osVirtualToPhysical(g_Vars.currentplayer->orthomtxl), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_PROJECTION); if (var800a4ce4); \ if (var8007fc2c); \ @@ -927,11 +927,11 @@ Gfx *bgRenderSceneInXray(Gfx *gdl) struct var800a4640_00 *thing = &var800a4640.unk000[k]; if (thing->draworder == i) { - gSPMatrix(gdl++, osVirtualToPhysical(camGetOrthogonalMtxL()), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_PROJECTION); + gSPMatrix(gdl++, osVirtualToPhysical(g_Vars.currentplayer->orthomtxl), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_PROJECTION); gdl = currentPlayerScissorWithinViewportF(gdl, thing->box.xmin, thing->box.ymin, thing->box.xmax, thing->box.ymax); - gSPMatrix(gdl++, osVirtualToPhysical(camGetPerspectiveMtxL()), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_PROJECTION); + gSPMatrix(gdl++, osVirtualToPhysical(g_Vars.currentplayer->perspmtxl), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_PROJECTION); if (thing->roomnum == -1) { gdl = propsRender(gdl, 0, RENDERPASS_XLU, roomnumsbyprop); @@ -1009,7 +1009,7 @@ static Gfx *bgRenderScene(Gfx *gdl) if (g_StarsActive) { gdl = text0f153628(gdl); - gSPMatrix(gdl++, osVirtualToPhysical(camGetOrthogonalMtxL()), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_PROJECTION); + gSPMatrix(gdl++, osVirtualToPhysical(g_Vars.currentplayer->orthomtxl), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_PROJECTION); gdl = playerLoadMatrix(gdl); gdl = envStopFog(gdl); @@ -1024,7 +1024,7 @@ static Gfx *bgRenderScene(Gfx *gdl) gdl = bgRenderRoomOpaque(gdl, g_BgAlwaysRoom); - gSPPerspNormalize(gdl++, viGetPerspScale()); + gSPPerspNormalize(gdl++, g_ViPerspScale); } gdl = skyRenderSuns(gdl, false); @@ -1065,7 +1065,7 @@ static Gfx *bgRenderScene(Gfx *gdl) thing = &var800a4640.unk000[roomnum]; // Render prop opaque components - pre BG pass - gSPMatrix(gdl++, osVirtualToPhysical(camGetPerspectiveMtxL()), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_PROJECTION); + gSPMatrix(gdl++, osVirtualToPhysical(g_Vars.currentplayer->perspmtxl), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_PROJECTION); gdl = envStopFog(gdl); if (firstroomnum == thing->roomnum) { @@ -1075,7 +1075,7 @@ static Gfx *bgRenderScene(Gfx *gdl) gdl = propsRender(gdl, thing->roomnum, RENDERPASS_OPA_PREBG, roomnumsbyprop); // Render BG opaque components - gSPMatrix(gdl++, osVirtualToPhysical(camGetOrthogonalMtxL()), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_PROJECTION); + gSPMatrix(gdl++, osVirtualToPhysical(g_Vars.currentplayer->orthomtxl), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_PROJECTION); gdl = currentPlayerScissorWithinViewportF(gdl, thing->box.xmin, thing->box.ymin, thing->box.xmax, thing->box.ymax); gdl = envStartFog(gdl, false); @@ -1083,7 +1083,7 @@ static Gfx *bgRenderScene(Gfx *gdl) gdl = bgRenderRoomOpaque(gdl, thing->roomnum); // Render prop opaque components - post BG pass - gSPMatrix(gdl++, osVirtualToPhysical(camGetPerspectiveMtxL()), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_PROJECTION); + gSPMatrix(gdl++, osVirtualToPhysical(g_Vars.currentplayer->perspmtxl), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_PROJECTION); gdl = envStopFog(gdl); @@ -1098,7 +1098,7 @@ static Gfx *bgRenderScene(Gfx *gdl) gdl = currentPlayerScissorToViewport(gdl); // Render wall hits - gSPMatrix(gdl++, osVirtualToPhysical(camGetOrthogonalMtxL()), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_PROJECTION); + gSPMatrix(gdl++, osVirtualToPhysical(g_Vars.currentplayer->orthomtxl), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_PROJECTION); if (g_Vars.currentplayer->visionmode != VISIONMODE_XRAY) { for (i = 0; i < var8007fc2c; i++) { @@ -1114,7 +1114,7 @@ static Gfx *bgRenderScene(Gfx *gdl) for (i = var8007fc2c - 1; i >= 0; i--) { roomnum = roomnums[i]; - gSPMatrix(gdl++, osVirtualToPhysical(camGetOrthogonalMtxL()), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_PROJECTION); + gSPMatrix(gdl++, osVirtualToPhysical(g_Vars.currentplayer->orthomtxl), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_PROJECTION); thing = &var800a4640.unk000[roomnum]; @@ -1124,7 +1124,7 @@ static Gfx *bgRenderScene(Gfx *gdl) gdl = bgRenderRoomXlu(gdl, thing->roomnum); - gSPMatrix(gdl++, osVirtualToPhysical(camGetPerspectiveMtxL()), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_PROJECTION); + gSPMatrix(gdl++, osVirtualToPhysical(g_Vars.currentplayer->perspmtxl), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_PROJECTION); gdl = envStopFog(gdl); @@ -1453,7 +1453,7 @@ void bgBuildTables(s32 stagenum) g_Vars.playerstats[i].scale_bg2gfx = g_Stages[g_StageIndex].unk18; } - mtx00016748(1); + var8005ef10[0] = 65536; if (var800a4920 == 0) { numportals = 0; @@ -1772,7 +1772,7 @@ void bgBuildTables(s32 stagenum) void bgStop(void) { bgUnloadAllRooms(); - mtx00016748(1); + var8005ef10[0] = 65536; } f32 func0f15c888(void) @@ -1780,15 +1780,10 @@ f32 func0f15c888(void) return g_Stages[g_StageIndex].unk1c / g_Stages[g_StageIndex].unk14; } -f32 currentPlayerGetScaleBg2Gfx(void) -{ - return g_Vars.currentplayerstats->scale_bg2gfx; -} - void currentPlayerSetScaleBg2Gfx(f32 scale) { g_Vars.currentplayerstats->scale_bg2gfx = g_Stages[g_StageIndex].unk18 * scale; - mtx00016748(g_Vars.currentplayerstats->scale_bg2gfx); + var8005ef10[0] = 65536 * g_Vars.currentplayerstats->scale_bg2gfx; } void func0f15c920(void) @@ -1990,7 +1985,7 @@ static bool func0f15cd90(u32 room, struct screenbox *screen) static bool func0f15d08c(struct coord *a, struct coord *b) { - Mtxf *matrix = camGetWorldToScreenMtxf(); + Mtxf *matrix = g_Vars.currentplayer->worldtoscreenmtx; *b = *a; @@ -5272,7 +5267,7 @@ static void bgTickPortalsXray(void) ymax = player->screenymaxf; if (bgunGetWeaponNum(HAND_RIGHT) == WEAPON_FARSIGHT && player->gunsightoff == 0) { - player->eraserdepth = -500.0f / camGetLodScaleZ(); + player->eraserdepth = -500.0f / g_Vars.currentplayer->c_lodscalez; } else { player->eraserdepth = -500.0f; } @@ -5281,7 +5276,7 @@ static void bgTickPortalsXray(void) eraserpos.f[1] = 0.0f; eraserpos.f[2] = player->eraserdepth; - mtx4TransformVecInPlace(camGetProjectionMtxF(), &eraserpos); + mtx4TransformVecInPlace(g_Vars.currentplayer->projectionmtx, &eraserpos); player->eraserpos.f[0] = eraserpos.f[0]; player->eraserpos.f[1] = eraserpos.f[1]; @@ -5915,12 +5910,12 @@ bool roomsAreNeighbours(s32 roomnum1, s32 roomnum2) static void currentPlayerCalculateScreenProperties(void) { struct player *player = g_Vars.currentplayer; - f32 width = viGetWidth(); + f32 width = g_ViBackData->x; u32 stack; - f32 height = viGetHeight(); + f32 height = g_ViBackData->y; u32 stack2; - player->screenxminf = viGetViewLeft(); + player->screenxminf = g_ViBackData->viewleft; if (player->screenxminf < 0) { player->screenxminf = 0; @@ -5930,7 +5925,7 @@ static void currentPlayerCalculateScreenProperties(void) player->screenxminf = width; } - player->screenyminf = viGetViewTop(); + player->screenyminf = g_ViBackData->viewtop; if (player->screenyminf < 0) { player->screenyminf = 0; @@ -5940,7 +5935,7 @@ static void currentPlayerCalculateScreenProperties(void) player->screenyminf = height; } - player->screenxmaxf = viGetViewLeft() + viGetViewWidth(); + player->screenxmaxf = g_ViBackData->viewleft + g_ViBackData->viewx; if (player->screenxmaxf < 0) { player->screenxmaxf = 0; @@ -5950,7 +5945,7 @@ static void currentPlayerCalculateScreenProperties(void) player->screenxmaxf = width; } - player->screenymaxf = viGetViewTop() + viGetViewHeight(); + player->screenymaxf = g_ViBackData->viewtop + g_ViBackData->viewy; if (player->screenymaxf < 0) { player->screenymaxf = 0; diff --git a/src/game/bgbss.c b/src/game/bgbss.c index f1eb3918b..980c0c772 100644 --- a/src/game/bgbss.c +++ b/src/game/bgbss.c @@ -11,4 +11,4 @@ struct screenbox var800a65c0; struct screenbox g_PortalScreenBbox; u32 g_FogEnabled; u32 var800a65e4; -struct coord *var800a65e8; +struct coord *g_Env800a65e8; diff --git a/src/game/body.c b/src/game/body.c index 5689f04e1..dc139b592 100644 --- a/src/game/body.c +++ b/src/game/body.c @@ -240,7 +240,7 @@ struct model *body0f02ce8c(s32 bodynum, s32 headnum, struct modelfiledata *bodyf } if (model) { - modelSetScale(model, scale); + model->scale = scale; modelSetAnimScale(model, animscale); if (headfiledata && !g_HeadsAndBodies[bodynum].unk00_01) { @@ -354,9 +354,9 @@ void bodyAllocateChr(s32 stagenum, struct packedchr *packed, s32 cmdindex) return; } - if (((packed->spawnflags & SPAWNFLAG_ONLYONA) && lvGetDifficulty() == DIFF_A) - || ((packed->spawnflags & SPAWNFLAG_ONLYONSA) && lvGetDifficulty() == DIFF_SA) - || ((packed->spawnflags & SPAWNFLAG_ONLYONPA) && lvGetDifficulty() == DIFF_PA)) { + if (((packed->spawnflags & SPAWNFLAG_ONLYONA) && g_Difficulty == DIFF_A) + || ((packed->spawnflags & SPAWNFLAG_ONLYONSA) && g_Difficulty == DIFF_SA) + || ((packed->spawnflags & SPAWNFLAG_ONLYONPA) && g_Difficulty == DIFF_PA)) { // ok } else { return; diff --git a/src/game/bondbike.c b/src/game/bondbike.c index b7c7abee5..e80b4a06f 100644 --- a/src/game/bondbike.c +++ b/src/game/bondbike.c @@ -188,15 +188,13 @@ void bbikeHandleActivate(void) void bbikeApplyMoveData(struct movedata *data) { struct hoverbikeobj *bike = (struct hoverbikeobj *)g_Vars.currentplayer->hoverbike->obj; - s8 contnum = optionsGetContpadNum1(g_Vars.currentplayerstats->mpindex); + s8 contnum = g_PlayerConfigsArray[g_Vars.currentplayerstats->mpindex].contpad1; f32 value1; f32 tmp; - if ((optionsGetControlMode(g_Vars.currentplayerstats->mpindex) == CONTROLMODE_12 - || optionsGetControlMode(g_Vars.currentplayerstats->mpindex) == CONTROLMODE_14 - || optionsGetControlMode(g_Vars.currentplayerstats->mpindex) == CONTROLMODE_13 - || optionsGetControlMode(g_Vars.currentplayerstats->mpindex) == CONTROLMODE_11) - && !lvIsPaused()) { + if ((g_PlayerConfigsArray[g_Vars.currentplayerstats->mpindex].controlmode >= CONTROLMODE_11 + && g_PlayerConfigsArray[g_Vars.currentplayerstats->mpindex].controlmode <= CONTROLMODE_14) + && !g_LvIsPaused) { data->digitalstepleft = joyCountButtonsOnSpecificSamples(0, contnum, 0 | L_CBUTTONS); data->digitalstepright = joyCountButtonsOnSpecificSamples(0, contnum, 0 | R_CBUTTONS); } @@ -288,7 +286,7 @@ void bbikeApplyMoveData(struct movedata *data) cam0f0b4d04(&sp30, sp28); - g_Vars.currentplayer->gunextraaimy = -((sp28[1] - camGetScreenTop()) * 2.0f / camGetScreenHeight() - 1.0f) * 0.75f; + g_Vars.currentplayer->gunextraaimy = -((sp28[1] - g_Vars.currentplayer->c_screentop) * 2.0f / g_Vars.currentplayer->c_screenheight - 1.0f) * 0.75f; } } @@ -297,20 +295,16 @@ static void bbike0f0d2b40(struct defaultobj *bike, struct coord *arg1, f32 arg2, struct coord sp9c; struct coord sp90; struct coord sp84 = {0, 0, 0}; - struct coord sp78; - struct coord sp6c; struct coord sp60; struct coord sp54; - cdGetEdge(&sp78, &sp6c); - sp60 = bike->prop->pos; sp54.x = obstacle->prop->pos.x - bike->prop->pos.x; sp54.y = obstacle->prop->pos.y - bike->prop->pos.y; sp54.z = obstacle->prop->pos.z - bike->prop->pos.z; - func0f02e3dc(&sp78, &sp6c, &sp60, &sp54, &sp9c); + func0f02e3dc(&g_CdEdgeVtx1, &g_CdEdgeVtx2, &sp60, &sp54, &sp9c); sp90.x = arg1->f[0]; sp90.y = 0; @@ -458,7 +452,7 @@ static s32 bbikeCalculateNewPositionWithPush(struct coord *arg0, f32 arg1) s32 result = bbikeCalculateNewPosition(arg0, arg1); if (result != CDRESULT_NOCOLLISION) { - struct prop *obstacle = cdGetObstacleProp(); + struct prop *obstacle = g_CdObstacleProp; if (obstacle && g_Vars.lvupdate240 > 0) { if (obstacle->type == PROPTYPE_CHR) { @@ -586,7 +580,8 @@ static s32 bbike0f0d3680(struct coord *arg0, struct coord *arg1, struct coord *a s32 result = bbikeCalculateNewPositionWithPush(arg0, 0); if (!result) { - cdGetEdge(arg1, arg2); + *arg1 = g_CdEdgeVtx1; + *arg2 = g_CdEdgeVtx2; } return result; @@ -594,9 +589,9 @@ static s32 bbike0f0d3680(struct coord *arg0, struct coord *arg1, struct coord *a static s32 bbike0f0d36d4(struct coord *arg0, struct coord *arg1, struct coord *arg2, struct coord *arg3, struct coord *arg4) { - if (cd00024ea4()) { + if (g_Cd8009a8ac) { struct coord sp24; - f32 somefloat = cd00024e98(); + f32 somefloat = g_Cd8009a8b0; s32 someint; sp24.x = arg0->x * somefloat * 0.25f; @@ -610,7 +605,8 @@ static s32 bbike0f0d36d4(struct coord *arg0, struct coord *arg1, struct coord *a } if (someint == 0) { - cdGetEdge(arg3, arg4); + *arg3 = g_CdEdgeVtx1; + *arg4 = g_CdEdgeVtx2; if (arg3->f[0] != arg1->f[0] || arg3->f[1] != arg1->f[1] diff --git a/src/game/bondeyespy.c b/src/game/bondeyespy.c index dc54ff23b..9a194b186 100644 --- a/src/game/bondeyespy.c +++ b/src/game/bondeyespy.c @@ -184,7 +184,7 @@ static s32 eyespyCalculateNewPosition(struct coord *vel) } if (result == CDRESULT_COLLISION) { - prop = cdGetObstacleProp(); + prop = g_CdObstacleProp; if (prop && prop->type == PROPTYPE_PLAYER) { playernum = g_Vars.currentplayernum; @@ -218,7 +218,7 @@ static bool eyespyCalculateNewPositionWithPush(struct coord *vel) if (result != CDRESULT_NOCOLLISION) { g_EyespyHit = EYESPYHIT_BG; - prop = cdGetObstacleProp(); + prop = g_CdObstacleProp; if (prop && g_Vars.lvupdate240 > 0) { if (prop->type == PROPTYPE_DOOR) { @@ -227,27 +227,6 @@ static bool eyespyCalculateNewPositionWithPush(struct coord *vel) g_EyespyHit = EYESPYHIT_DOOR; if (door->doorflags & DOORFLAG_DAMAGEONCONTACT) { - f32 sp38[3]; - struct coord sp2c; - struct coord sp20; - - cdGetEdge(&sp2c, &sp20); - - // Nothing is actually done with these coordinates... - // This code was likely copied from bondwalk then the bounce - // feature removed - sp38[0] = sp20.z - sp2c.z; - sp38[1] = 0; - sp38[2] = sp2c.x - sp20.x; - - if (sp38[0] || sp38[2]) { - guNormalize(&sp38[0], &sp38[1], &sp38[2]); - } else { - sp38[2] = 1; - } - - if (prop); - g_EyespyHit = EYESPYHIT_DAMAGE; } } @@ -267,10 +246,10 @@ static bool eyespyCalculateNewPositionWithPush(struct coord *vel) static s32 eyespy0f0cf890(struct coord *arg0, struct coord *arg1, struct coord *arg2, struct coord *arg3, struct coord *arg4) { - if (cd00024ea4()) { + if (g_Cd8009a8ac) { struct coord sp24; s32 someint; - f32 somefloat = cd00024e98(); + f32 somefloat = g_Cd8009a8b0; sp24.x = arg0->x * somefloat * 0.25f; sp24.y = arg0->y * somefloat * 0.25f; sp24.z = arg0->z * somefloat * 0.25f; @@ -282,7 +261,8 @@ static s32 eyespy0f0cf890(struct coord *arg0, struct coord *arg1, struct coord * } if (someint == 0) { - cdGetEdge(arg3, arg4); + *arg3 = g_CdEdgeVtx1; + *arg4 = g_CdEdgeVtx2; if (arg3->f[0] != arg1->f[0] || arg3->f[1] != arg1->f[1] @@ -401,7 +381,8 @@ static s32 eyespy0f0cfdd0(struct coord *vel, struct coord *arg1, struct coord *a bool result = eyespyCalculateNewPositionWithPush(vel); if (result != CDRESULT_NOCOLLISION) { - cdGetEdge(arg1, arg2); + *arg1 = g_CdEdgeVtx1; + *arg2 = g_CdEdgeVtx2; } return result; @@ -677,7 +658,7 @@ void eyespyProcessInput(bool allowbuttons) f32 spcc; f32 spc8; f32 spc4; - s8 contpad1 = optionsGetContpadNum1(g_Vars.currentplayerstats->mpindex); + s8 contpad1 = g_PlayerConfigsArray[g_Vars.currentplayerstats->mpindex].contpad1; s8 c1stickx = joyGetStickX(contpad1); s8 c2stickx; s8 c1sticky = joyGetStickY(contpad1); @@ -685,7 +666,7 @@ void eyespyProcessInput(bool allowbuttons) u16 c1buttons = allowbuttons ? joyGetButtons(contpad1, 0xffff) : 0; u16 c2buttons; bool domovecentre = true; - s32 controlmode = optionsGetControlMode(g_Vars.currentplayerstats->mpindex); + s32 controlmode = g_PlayerConfigsArray[g_Vars.currentplayerstats->mpindex].controlmode; bool aimpressed; bool shootpressed; @@ -703,7 +684,7 @@ void eyespyProcessInput(bool allowbuttons) f32 tmp; if (controlmode >= CONTROLMODE_21) { - contpad2 = (s8) optionsGetContpadNum2(g_Vars.currentplayerstats->mpindex); + contpad2 = g_PlayerConfigsArray[g_Vars.currentplayerstats->mpindex].contpad2; c2stickx = joyGetStickX(contpad2); c2sticky = joyGetStickY(contpad2); diff --git a/src/game/bondgrab.c b/src/game/bondgrab.c index 99281ec18..411ced232 100644 --- a/src/game/bondgrab.c +++ b/src/game/bondgrab.c @@ -169,8 +169,6 @@ static void bgrab0f0ccbf0(struct coord *delta, f32 angle, struct defaultobj *obj struct coord spd4; struct coord spc8; struct coord spbc; - struct coord spb0; - struct coord spa4; struct coord sp98; if (g_Vars.lvupdate240 > 0) { @@ -179,11 +177,9 @@ static void bgrab0f0ccbf0(struct coord *delta, f32 angle, struct defaultobj *obj sp98.y = g_Vars.currentplayer->prop->pos.y; sp98.z = delta->z + g_Vars.currentplayer->prop->pos.z; - cdGetEdge(&spb0, &spa4); - - spc8.x = spa4.z - spb0.z; + spc8.x = g_CdEdgeVtx2.z - g_CdEdgeVtx1.z; spc8.y = 0.0f; - spc8.z = spb0.x - spa4.x; + spc8.z = g_CdEdgeVtx1.x - g_CdEdgeVtx2.x; if (spc8.f[0] != 0.0f || spc8.f[2] != 0.0f) { guNormalize(&spc8.x, &spc8.y, &spc8.z); @@ -191,7 +187,7 @@ static void bgrab0f0ccbf0(struct coord *delta, f32 angle, struct defaultobj *obj spc8.z = 1.0f; } - func0f02e3dc(&spb0, &spa4, &sp98, &spc8, &spd4); + func0f02e3dc(&g_CdEdgeVtx1, &g_CdEdgeVtx2, &sp98, &spc8, &spd4); spbc.x = (sp98.x - g_Vars.currentplayer->prop->pos.x) / g_Vars.lvupdate60freal; spbc.y = 0.0f; @@ -202,13 +198,9 @@ static void bgrab0f0ccbf0(struct coord *delta, f32 angle, struct defaultobj *obj struct coord sp8c; struct coord sp80; struct coord sp74 = {0, 0, 0}; - struct coord sp68; - struct coord sp5c; struct coord sp50; struct coord sp44; - cdGetEdge(&sp68, &sp5c); - if (cdGetSavedPos(&sp50, &sp44)) { sp44.x -= sp50.x; sp44.y -= sp50.y; @@ -221,7 +213,7 @@ static void bgrab0f0ccbf0(struct coord *delta, f32 angle, struct defaultobj *obj sp44.z = obj->prop->pos.z - var8009de70->pos.z; } - func0f02e3dc(&sp68, &sp5c, &sp50, &sp44, &sp8c); + func0f02e3dc(&g_CdEdgeVtx1, &g_CdEdgeVtx2, &sp50, &sp44, &sp8c); sp80.x = delta->x; sp80.y = 0.0f; @@ -504,7 +496,7 @@ static bool bgrabCalculateNewPositiontWithPush(struct coord *delta, f32 angle, b s32 result = bgrabCalculateNewPosition(delta, angle, arg2); if (result != CDRESULT_NOCOLLISION) { - struct prop *obstacle = cdGetObstacleProp(); + struct prop *obstacle = g_CdObstacleProp; if (obstacle && g_Vars.lvupdate240 > 0) { if (obstacle->type == PROPTYPE_CHR) { @@ -590,7 +582,8 @@ static bool bgrab0f0cdb68(f32 angle) f32 ymax; f32 ymin; - cdGetEdge(&spa4, &sp98); + spa4 = g_CdEdgeVtx1; + sp98 = g_CdEdgeVtx2; sp7c = sp98.f[0] - spa4.f[0]; sp78 = sp98.f[2] - spa4.f[2]; @@ -690,7 +683,8 @@ static bool bgrab0f0cdf64(struct coord *delta, struct coord *arg1, struct coord bool result = bgrabCalculateNewPositiontWithPush(delta, 0, true); if (!result) { - cdGetEdge(arg1, arg2); + *arg1 = g_CdEdgeVtx1; + *arg2 = g_CdEdgeVtx2; } return result; diff --git a/src/game/bondgun.c b/src/game/bondgun.c index 34d7c615b..41eccf5f2 100644 --- a/src/game/bondgun.c +++ b/src/game/bondgun.c @@ -266,7 +266,7 @@ static void bgunRumble(s32 handnum, s32 weaponnum) joyGetContpadNumsForPlayer(g_Vars.currentplayernum, &contpad1, &contpad2); - if (optionsGetControlMode(g_Vars.currentplayerstats->mpindex) >= CONTROLMODE_21 + if (g_PlayerConfigsArray[g_Vars.currentplayerstats->mpindex].controlmode >= CONTROLMODE_21 && contpad1 >= 0 && contpad2 >= 0) { contpad1hasrumble = pakGetType(contpad1) == PAKTYPE_RUMBLE; contpad2hasrumble = pakGetType(contpad2) == PAKTYPE_RUMBLE; @@ -2927,11 +2927,6 @@ void bgunInitHandAnims(void) } } -f32 bgunGetNoiseRadius(s32 handnum) -{ - return g_Vars.currentplayer->hands[handnum].noiseradius; -} - static void bgunDecreaseNoiseRadius(void) { struct player *player = g_Vars.currentplayer; @@ -2949,7 +2944,7 @@ static void bgunDecreaseNoiseRadius(void) gsetGetNoiseSettings(&gsetright, &noisesettingsright); // Right hand - if (bgunIsFiring(HAND_RIGHT)) { + if (g_Vars.currentplayer->hands[HAND_RIGHT].firing) { player->hands[HAND_RIGHT].noiseradius += noisesettingsright.incradius; if (player->hands[HAND_RIGHT].noiseradius > noisesettingsright.maxradius) { @@ -2971,7 +2966,7 @@ static void bgunDecreaseNoiseRadius(void) } // Left hand - if (bgunIsFiring(HAND_LEFT)) { + if (g_Vars.currentplayer->hands[HAND_LEFT].firing) { player->hands[HAND_LEFT].noiseradius += noisesettingsleft.incradius; if (player->hands[HAND_LEFT].noiseradius > noisesettingsleft.maxradius) { @@ -3057,7 +3052,7 @@ static void bgunUpdateBlend(struct hand *hand, s32 handnum) sp5c.x += hand->adjustdamp.x; sp5c.y += hand->adjustdamp.y; - sp5c.x += handGetXShift(handnum); + sp5c.x += g_Vars.currentplayer->hands[handnum].xshift; for (i = 0; i < g_Vars.lvupdate240; i++) { hand->damppossum.x = (PAL ? 0.9847f : 0.9872f) * hand->damppossum.x + sp5c.f[0]; @@ -3200,11 +3195,6 @@ static u32 bgunGetGunMemType(void) return g_Vars.currentplayer->gunctrl.gunmemtype; } -u8 *bgunGetGunMem(void) -{ - return g_Vars.currentplayer->gunctrl.gunmem; -} - u32 bgunCalculateGunMemCapacity(void) { if (PLAYERCOUNT() == 1) { @@ -3221,11 +3211,6 @@ u32 bgunCalculateGunMemCapacity(void) return 0x25800; } -void bgunFreeGunMem(void) -{ - g_Vars.currentplayer->gunctrl.gunmemowner = GUNMEMOWNER_FREE; -} - static void bgunSetGunMemWeapon(s32 weaponnum) { struct player *player = g_Vars.currentplayer; @@ -3538,7 +3523,7 @@ static void bgunTickMasterLoad(void) player->gunctrl.handmodeldef = NULL; } - player->gunctrl.unk15a0 = bgunGetGunMem(); + player->gunctrl.unk15a0 = g_Vars.currentplayer->gunctrl.gunmem; player->gunctrl.unk15a4 = bgunCalculateGunMemCapacity(); player->gunctrl.masterloadstate = MASTERLOADSTATE_GUN; @@ -3560,7 +3545,7 @@ static void bgunTickMasterLoad(void) player->gunctrl.masterloadstate = MASTERLOADSTATE_CARTS; player->gunctrl.gunloadstate = GUNLOADSTATE_FLUX; - player->gunctrl.unk15a8 = bgunGetGunMem(); + player->gunctrl.unk15a8 = g_Vars.currentplayer->gunctrl.gunmem; player->gunctrl.unk15ac = bgunCalculateGunMemCapacity(); } else { // Not preloaded @@ -3722,11 +3707,6 @@ bool bgun0f09eae4(void) return false; } -struct modelfiledata *bgunGetCartModeldef(void) -{ - return g_Vars.currentplayer->gunctrl.cartmodeldef; -} - void bgun0f09ebcc(struct defaultobj *obj, struct coord *coord, s16 *rooms, Mtxf *matrix1, struct coord *velocity, Mtxf *matrix2, struct prop *prop, struct coord *pos) { struct prop *objprop = obj->prop; @@ -3956,7 +3936,7 @@ void bgunCreateThrownProjectile(s32 handnum, struct gset *gset) playerSetPerimEnabled(playerprop, true); bgunCalculatePlayerShotSpread(&sp1e8, &sp1dc, handnum, true); - mtx4RotateVecInPlace(camGetProjectionMtxF(), &sp1dc); + mtx4RotateVecInPlace(g_Vars.currentplayer->projectionmtx, &sp1dc); if (droppinggrenade) { // Dropping a grenade because player is in an nbomb storm @@ -4183,7 +4163,7 @@ void bgunCreateFiredProjectile(s32 handnum) mtx4LoadIdentity(&sp270); bgunCalculatePlayerShotSpread(&sp204, &sp1f8, handnum, true); - mtx4RotateVecInPlace(camGetProjectionMtxF(), &sp1f8); + mtx4RotateVecInPlace(g_Vars.currentplayer->projectionmtx, &sp1f8); spawnpos = hand->muzzlepos; @@ -4377,8 +4357,8 @@ void bgunCreateFiredProjectile(s32 handnum) void bgunSwivel(f32 screenx, f32 screeny, f32 crossdamp, f32 aimdamp) { - f32 screenwidth = camGetScreenWidth(); - f32 screenheight = camGetScreenHeight(); + f32 screenwidth = g_Vars.currentplayer->c_screenwidth; + f32 screenheight = g_Vars.currentplayer->c_screenheight; struct player *player = g_Vars.currentplayer; struct coord aimpos; s32 l; @@ -4439,7 +4419,7 @@ void bgunSwivel(f32 screenx, f32 screeny, f32 crossdamp, f32 aimdamp) if (hand->hasdotinfo && !g_Vars.mplayerisrunning) { sp94 = hand->dotpos; - mtx4TransformVecInPlace(camGetWorldToScreenMtxf(), &sp94); + mtx4TransformVecInPlace(g_Vars.currentplayer->worldtoscreenmtx, &sp94); if (!(sp94.z < 0.0000001f) || !(sp94.z > -0.0000001f)) { if (sp94.z > -6000.0f) { @@ -4448,8 +4428,8 @@ void bgunSwivel(f32 screenx, f32 screeny, f32 crossdamp, f32 aimdamp) x[h] = sp8c[0]; y[h] = sp8c[1]; - x[h] = 2.0f * (x[h] / viGetViewWidth()) - 1.0f; - y[h] = 2.0f * (y[h] / viGetViewHeight()) - 1.0f; + x[h] = 2.0f * (x[h] / g_ViBackData->viewx) - 1.0f; + y[h] = 2.0f * (y[h] / g_ViBackData->viewy) - 1.0f; } } } @@ -4497,8 +4477,8 @@ void bgunSwivel(f32 screenx, f32 screeny, f32 crossdamp, f32 aimdamp) player->crosspos[1] = screenheight - 4.0f; } - player->crosspos[0] += camGetScreenLeft(); - player->crosspos[1] += camGetScreenTop(); + player->crosspos[0] += g_Vars.currentplayer->c_screenleft; + player->crosspos[1] += g_Vars.currentplayer->c_screentop; for (h = 0; h < 2; h++) { player->hands[h].crosspos[0] = player->hands[h].guncrosspossum[0] * (PAL ? 0.08700001f : 0.07303029f) * screenwidth * 0.5f + screenwidth * 0.5f; @@ -4516,8 +4496,8 @@ void bgunSwivel(f32 screenx, f32 screeny, f32 crossdamp, f32 aimdamp) player->hands[h].crosspos[1] = screenheight - 4.0f; } - player->hands[h].crosspos[0] += camGetScreenLeft(); - player->hands[h].crosspos[1] += camGetScreenTop(); + player->hands[h].crosspos[0] += g_Vars.currentplayer->c_screenleft; + player->hands[h].crosspos[1] += g_Vars.currentplayer->c_screentop; } for (l = 0; l < g_Vars.lvupdate240; l++) { @@ -4527,16 +4507,16 @@ void bgunSwivel(f32 screenx, f32 screeny, f32 crossdamp, f32 aimdamp) player->crosspos2[0] = player->crosssum2[0] * (1.0f - aimdamp) * screenwidth * 0.5f + screenwidth * 0.5f; player->crosspos2[1] = player->crosssum2[1] * (1.0f - aimdamp) * screenheight * 0.5f + screenheight * 0.5f; - player->crosspos2[0] += camGetScreenLeft(); - player->crosspos2[1] += camGetScreenTop(); + player->crosspos2[0] += g_Vars.currentplayer->c_screenleft; + player->crosspos2[1] += g_Vars.currentplayer->c_screentop; cam0f0b4c3c(player->crosspos2, &aimpos, 1000); - player->hands[HAND_RIGHT].aimpos.x = handGetXShift(HAND_RIGHT) + aimpos.x; + player->hands[HAND_RIGHT].aimpos.x = aimpos.x + g_Vars.currentplayer->hands[HAND_RIGHT].xshift; player->hands[HAND_RIGHT].aimpos.y = aimpos.y; player->hands[HAND_RIGHT].aimpos.z = aimpos.z; - player->hands[HAND_LEFT].aimpos.x = handGetXShift(HAND_LEFT) + aimpos.x; + player->hands[HAND_LEFT].aimpos.x = aimpos.x + g_Vars.currentplayer->hands[HAND_LEFT].xshift; player->hands[HAND_LEFT].aimpos.y = aimpos.y; player->hands[HAND_LEFT].aimpos.z = aimpos.z; } @@ -4629,7 +4609,7 @@ void bgunCalculatePlayerShotSpread(struct coord *arg0, struct coord *arg1, s32 h spread *= 1.5f; } - scaledspread = 120.0f * spread / viGetFovY(); + scaledspread = 120.0f * spread / g_ViBackData->fovy; if (dorandom) { randfactor = (RANDOMFRAC() - 0.5f) * RANDOMFRAC(); @@ -4637,8 +4617,8 @@ void bgunCalculatePlayerShotSpread(struct coord *arg0, struct coord *arg1, s32 h randfactor = 0; } - crosspos[0] = player->crosspos[0] + randfactor * scaledspread * camGetScreenWidth() - / (viGetHeight() * camGetPerspAspect()); + crosspos[0] = player->crosspos[0] + randfactor * scaledspread * g_Vars.currentplayer->c_screenwidth + / (g_ViBackData->y * g_Vars.currentplayer->c_perspaspect); if (dorandom) { randfactor = (RANDOMFRAC() - 0.5f) * RANDOMFRAC(); @@ -4646,8 +4626,8 @@ void bgunCalculatePlayerShotSpread(struct coord *arg0, struct coord *arg1, s32 h randfactor = 0; } - crosspos[1] = player->crosspos[1] + (randfactor * scaledspread * camGetScreenHeight()) - / viGetHeight(); + crosspos[1] = player->crosspos[1] + (randfactor * scaledspread * g_Vars.currentplayer->c_screenheight) + / g_ViBackData->y; arg0->x = 0; arg0->y = 0; @@ -4688,7 +4668,7 @@ void bgunCalculateBotShotSpread(struct coord *arg0, s32 weaponnum, s32 funcnum, spread *= 1.5f; } - radius = 120.0f * spread / viGetFovY(); + radius = 120.0f * spread / g_ViBackData->fovy; x = (RANDOMFRAC() - 0.5f) * RANDOMFRAC() * radius; y = (RANDOMFRAC() - 0.5f) * RANDOMFRAC() * radius; @@ -5279,50 +5259,16 @@ void bgunEquipWeapon2(s32 handnum, s32 weaponnum) } } -s32 bgunIsFiring(s32 handnum) -{ - return g_Vars.currentplayer->hands[handnum].firing; -} - -s32 bgunGetAttackType(s32 handnum) -{ - return g_Vars.currentplayer->hands[handnum].attacktype; -} - char *bgunGetName(s32 weaponnum) { - struct weapon *weapon = g_Weapons[weaponnum]; - - if (weapon) { - return langGet(weapon->name); - } - - return "** error\n"; -} - -u16 bgunGetNameId(s32 weaponnum) -{ - struct weapon *weapon = g_Weapons[weaponnum]; - - if (weapon) { - return weapon->name; - } - - return 0; + return langGet(g_Weapons[weaponnum]->name); } char *bgunGetShortName(s32 weaponnum) { - struct weapon *weapon = g_Weapons[weaponnum]; - - if (weapon) { - return langGet(weapon->shortname); - } - - return "** error\n"; + return langGet(g_Weapons[weaponnum]->shortname); } - void bgunReloadIfPossible(s32 handnum) { struct player *player = g_Vars.currentplayer; @@ -6075,7 +6021,7 @@ static void bgunUpdateLasersight(struct hand *hand, struct modelfiledata *modeld beamnear.y = ((Mtxf *)((u32)allocation + mtxindex * sizeof(Mtxf)))->m[3][1]; beamnear.z = ((Mtxf *)((u32)allocation + mtxindex * sizeof(Mtxf)))->m[3][2]; - mtx4TransformVecInPlace(camGetProjectionMtxF(), &beamnear); + mtx4TransformVecInPlace(g_Vars.currentplayer->projectionmtx, &beamnear); if (hand->useposrot || (g_Vars.currentplayer->devicesactive & ~g_Vars.currentplayer->devicesinhibit & DEVICE_XRAYSCANNER)) { @@ -6089,14 +6035,14 @@ static void bgunUpdateLasersight(struct hand *hand, struct modelfiledata *modeld sp3c = beamnear; - mtx4TransformVec(camGetWorldToScreenMtxf(), &sp3c, &sp54); - mtx4RotateVec(camGetProjectionMtxF(), &sp48, &sp30); + mtx4TransformVec(g_Vars.currentplayer->worldtoscreenmtx, &sp3c, &sp54); + mtx4RotateVec(g_Vars.currentplayer->projectionmtx, &sp48, &sp30); beamfar.x *= 500.0f; beamfar.y *= 500.0f; beamfar.z *= 500.0f; - mtx4RotateVecInPlace(camGetProjectionMtxF(), &beamfar); + mtx4RotateVecInPlace(g_Vars.currentplayer->projectionmtx, &beamfar); beamfar.x += beamnear.x; beamfar.y += beamnear.y; @@ -6128,7 +6074,7 @@ static void bgunUpdateLasersight(struct hand *hand, struct modelfiledata *modeld beamfar.z *= 500.0f; } - mtx4TransformVecInPlace(camGetProjectionMtxF(), &beamfar); + mtx4TransformVecInPlace(g_Vars.currentplayer->projectionmtx, &beamfar); lasersightSetBeam(handnum, 1, &beamnear, &beamfar); if (handnum == HAND_RIGHT && hand->hasdotinfo && !busy) { @@ -6388,7 +6334,7 @@ static void bgunUpdateMagnum(struct hand *hand, s32 handnum, struct modelfiledat mtx4Copy(tmp, &sp4c); mtx00015f04(9.999999f, &sp4c); - mtx4MultMtx4InPlace(camGetProjectionMtxF(), &sp4c); + mtx4MultMtx4InPlace(g_Vars.currentplayer->projectionmtx, &sp4c); casingCreateForHand(handnum, ground, &sp4c); } @@ -6651,7 +6597,7 @@ static void bgunCreateFx(struct hand *hand, s32 handnum, struct weaponfunc *func mtx4Copy(mtx, &sp24); mtx00015f04(9.999999f, &sp24); - mtx4MultMtx4InPlace(camGetProjectionMtxF(), &sp24); + mtx4MultMtx4InPlace(g_Vars.currentplayer->projectionmtx, &sp24); casingCreateForHand(handnum, ground, &sp24); } else { @@ -6822,12 +6768,12 @@ static void bgun0f0a5550(s32 handnum) sp274.z += (RANDOMFRAC() - 0.5f) * shootfunc->recoilsettings->zrange * hand->finalmult[0]; } - hand->fspare1 = (player->crosspos2[0] - camGetScreenLeft() - camGetScreenWidth() * 0.5f) * weapondef->aimsettings->guntransside / (camGetScreenWidth() * 0.5f); + hand->fspare1 = (player->crosspos2[0] - g_Vars.currentplayer->c_screenleft - g_Vars.currentplayer->c_screenwidth * 0.5f) * weapondef->aimsettings->guntransside / (g_Vars.currentplayer->c_screenwidth * 0.5f); - if (player->crosspos2[1] - camGetScreenTop() > camGetScreenHeight() * 0.5f) { - hand->fspare2 = (player->crosspos2[1] - camGetScreenTop() - camGetScreenHeight() * 0.5f) * weapondef->aimsettings->guntransdown / (camGetScreenHeight() * 0.5f); + if (player->crosspos2[1] - g_Vars.currentplayer->c_screentop > g_Vars.currentplayer->c_screenheight * 0.5f) { + hand->fspare2 = (player->crosspos2[1] - g_Vars.currentplayer->c_screentop - g_Vars.currentplayer->c_screenheight * 0.5f) * weapondef->aimsettings->guntransdown / (g_Vars.currentplayer->c_screenheight * 0.5f); } else { - hand->fspare2 = (player->crosspos2[1] - camGetScreenTop() - camGetScreenHeight() * 0.5f) * weapondef->aimsettings->guntransup / (camGetScreenHeight() * 0.5f); + hand->fspare2 = (player->crosspos2[1] - g_Vars.currentplayer->c_screentop - g_Vars.currentplayer->c_screenheight * 0.5f) * weapondef->aimsettings->guntransup / (g_Vars.currentplayer->c_screenheight * 0.5f); } fspare1 = hand->fspare1; @@ -6927,7 +6873,7 @@ static void bgun0f0a5550(s32 handnum) mtx4Copy(&sp2c4, &hand->cammtx); mtx4Copy(&hand->posmtx, &hand->prevmtx); - mtx00015be4(camGetProjectionMtxF(), &hand->cammtx, &hand->posmtx); + mtx00015be4(g_Vars.currentplayer->projectionmtx, &hand->cammtx, &hand->posmtx); if (hand->visible) { for (j = 0x5a; j < 0x5d; j++) { @@ -7137,7 +7083,7 @@ static void bgun0f0a5550(s32 handnum) hand->muzzlepos.f[2] = mtx->m[3][2]; mtx4Copy(mtx, &hand->muzzlemat); - mtx4TransformVecInPlace(camGetProjectionMtxF(), &hand->muzzlepos); + mtx4TransformVecInPlace(g_Vars.currentplayer->projectionmtx, &hand->muzzlepos); hand->muzzlez = -((Mtxf *)((u32)mtxallocation + sp6c * sizeof(Mtxf)))->m[3][2]; @@ -7159,7 +7105,7 @@ static void bgun0f0a5550(s32 handnum) hand->muzzlepos.z = mtx->m[3][2]; mtx4Copy(mtx, &hand->muzzlemat); - mtx4TransformVecInPlace(camGetProjectionMtxF(), &hand->muzzlepos); + mtx4TransformVecInPlace(g_Vars.currentplayer->projectionmtx, &hand->muzzlepos); hand->muzzlez = -((Mtxf *)((u32)mtxallocation + sp6c * sizeof(Mtxf)))->m[3][2]; } else { @@ -7503,15 +7449,15 @@ void bgunRender(Gfx **gdlptr) gdl = vi0000b280(gdl); gdl = vi0000b1d0(gdl); - gDPSetScissor(gdl++, G_SC_NON_INTERLACE, viGetViewLeft(), viGetViewTop(), - viGetViewLeft() + viGetViewWidth(), viGetViewTop() + viGetViewHeight()); + gDPSetScissor(gdl++, G_SC_NON_INTERLACE, g_ViBackData->viewleft, g_ViBackData->viewtop, + g_ViBackData->viewleft + g_ViBackData->viewx, g_ViBackData->viewtop + g_ViBackData->viewy); gdl = vi0000aca4(gdl, 1.5, 1000); if (g_Vars.currentplayer->teleportstate != TELEPORTSTATE_INACTIVE) { f32 f2; - if (optionsGetScreenRatio() == SCREENRATIO_16_9) { + if (g_ScreenRatio == SCREENRATIO_16_9) { f2 = player0f0bd358() * 1.3333334f; } else { f2 = player0f0bd358(); @@ -7541,7 +7487,7 @@ void bgunRender(Gfx **gdlptr) if (weaponHasFlag(hand->gset.weaponnum, WEAPONFLAG_00008000)) { gSPSetLights1(gdl++, var80070090); - gSPLookAt(gdl++, camGetLookAt()); + gSPLookAt(gdl++, g_Vars.currentplayer->lookat); } gSPPerspNormalize(gdl++, mtx00016dcc(0, 300)); @@ -7687,9 +7633,9 @@ void bgunRender(Gfx **gdlptr) } func0f0c33f0(hand->gunmodel.matrices, hand->gunmodel.filedata->nummatrices); - mtx00016784(); + var8005ef10[0] = g_Vars.unk000510; - gSPPerspNormalize(gdl++, viGetPerspScale()); + gSPPerspNormalize(gdl++, g_ViPerspScale); } } @@ -7699,8 +7645,8 @@ void bgunRender(Gfx **gdlptr) gdl = mblur0f1762ac(gdl); gdl = vi0000b1d0(gdl); - gDPSetScissor(gdl++, G_SC_NON_INTERLACE, viGetViewLeft(), viGetViewTop(), - viGetViewLeft() + viGetViewWidth(), viGetViewTop() + viGetViewHeight()); + gDPSetScissor(gdl++, G_SC_NON_INTERLACE, g_ViBackData->viewleft, g_ViBackData->viewtop, + g_ViBackData->viewleft + g_ViBackData->viewx, g_ViBackData->viewtop + g_ViBackData->viewy); *gdlptr = gdl; } @@ -7757,7 +7703,7 @@ void bgunPlayPropHitSound(struct gset *gset, struct prop *prop, s32 texturenum) s32 spac; s32 spa8; - if (chrGetShield(chr) > 0) { + if (chr->cshield > 0) { soundnum = SFX_SHIELD_DAMAGE; } else if (gset->weaponnum == WEAPON_COMBATKNIFE || gset->weaponnum == WEAPON_COMBATKNIFE // duplicate @@ -8291,11 +8237,6 @@ void bgunSetPassiveMode(bool enable) } } -void bgunSetAimType(u32 aimtype) -{ - g_Vars.currentplayer->aimtype = aimtype; -} - void bgunSetHitPos(struct coord *coord) { struct player *player = g_Vars.currentplayer; @@ -8472,11 +8413,6 @@ s32 bgunGetAmmoCount(s32 ammotype) return total; } -s32 bgunGetCapacityByAmmotype(s32 ammotype) -{ - return g_AmmoTypes[ammotype].capacity; -} - static bool bgunAmmotypeAllowsUnlimitedAmmo(u32 ammotype) { switch (ammotype) { @@ -8616,7 +8552,7 @@ Gfx *bgunDrawHudString(Gfx *gdl, char *text, s32 x, bool halign, s32 y, s32 vali } gdl = text0f153858(gdl, &x1, &y1, &x2, &y2); - gdl = textRender(gdl, &x1, &y1, text, g_CharsNumeric, g_FontNumeric, colour, 0x000000a0, viGetWidth(), viGetHeight(), 0, 0); + gdl = textRender(gdl, &x1, &y1, text, g_CharsNumeric, g_FontNumeric, colour, 0x000000a0, g_ViBackData->x, g_ViBackData->y, 0, 0); return gdl; } @@ -8960,7 +8896,7 @@ static Gfx *bgunDrawHudGauge(Gfx *gdl, s32 x1, s32 y1, s32 x2, s32 y2, struct ab Gfx *bgunDrawHud(Gfx *gdl) { struct player *player = g_Vars.currentplayer; - s32 bottom = viGetViewTop() + viGetViewHeight() - 13; + s32 bottom = g_ViBackData->viewtop + g_ViBackData->viewy - 13; s32 playercount = PLAYERCOUNT(); s32 playernum = g_Vars.currentplayernum; struct gunctrl *ctrl; @@ -9011,7 +8947,7 @@ Gfx *bgunDrawHud(Gfx *gdl) clipheight = 47; if (playercount == 2) { - if (optionsGetScreenSplit() != SCREENSPLIT_VERTICAL && playernum == 0) { + if (g_ScreenSplit != SCREENSPLIT_VERTICAL && playernum == 0) { bottom += 10; } else { bottom += 2; @@ -9038,9 +8974,9 @@ Gfx *bgunDrawHud(Gfx *gdl) funcnum = tmpfuncnum; } - xpos = (viGetViewLeft() + viGetViewWidth()) - barwidth - 24; + xpos = (g_ViBackData->viewleft + g_ViBackData->viewx) - barwidth - 24; - if (playercount == 2 && optionsGetScreenSplit() == SCREENSPLIT_VERTICAL && playernum == 0) { + if (playercount == 2 && g_ScreenSplit == SCREENSPLIT_VERTICAL && playernum == 0) { xpos += 15; } else if (playercount >= 3 && (playernum % 2) == 0) { xpos += 15; @@ -9217,9 +9153,9 @@ Gfx *bgunDrawHud(Gfx *gdl) if (lefthand->inuse && weapon->ammos[ammoindex] != NULL && lefthand->gset.weaponnum != WEAPON_REMOTEMINE) { - xpos = viGetViewLeft() + 24; + xpos = g_ViBackData->viewleft + 24; - if (playercount == 2 && optionsGetScreenSplit() == SCREENSPLIT_VERTICAL && playernum == 1) { + if (playercount == 2 && g_ScreenSplit == SCREENSPLIT_VERTICAL && playernum == 1) { xpos -= 14; } else if (playercount >= 3 && (playernum & 1) == 1) { xpos -= 14; @@ -9243,9 +9179,9 @@ Gfx *bgunDrawHud(Gfx *gdl) ammotype = player->gunctrl.ammotypes[ammoindex]; - xpos = (viGetViewLeft() + viGetViewWidth()) - barwidth - 24; + xpos = (g_ViBackData->viewleft + g_ViBackData->viewx) - barwidth - 24; - if (playercount == 2 && optionsGetScreenSplit() == SCREENSPLIT_VERTICAL && playernum == 0) { + if (playercount == 2 && g_ScreenSplit == SCREENSPLIT_VERTICAL && playernum == 0) { xpos += 15; } else if (playercount >= 3 && (playernum % 2) == 0) { xpos += 15; diff --git a/src/game/bondgunreset.c b/src/game/bondgunreset.c index b256d3eeb..7c4d76297 100644 --- a/src/game/bondgunreset.c +++ b/src/game/bondgunreset.c @@ -202,7 +202,6 @@ void bgunReset(void) g_Vars.currentplayer->gunshadecol[2] = 0xff; g_Vars.currentplayer->gunshadecol[3] = 0; g_Vars.currentplayer->resetshadecol = 1; - g_Vars.currentplayer->aimtype = 0; g_Vars.currentplayer->crosspos[0] = 0; g_Vars.currentplayer->crosspos[1] = 0; g_Vars.currentplayer->crosspossum[0] = 0; diff --git a/src/game/bondhead.c b/src/game/bondhead.c index cd04d4143..8acf7c67a 100644 --- a/src/game/bondhead.c +++ b/src/game/bondhead.c @@ -144,13 +144,13 @@ void bheadUpdate(f32 arg0, f32 arg1) struct modelrenderdata sp80 = {NULL, 1, 3}; Mtxf sp40; struct coord modelpos = {0, 0, 0}; - bool somebool = model0001e2a8(); + bool somebool = var8005efdc; g_Vars.currentplayer->resetheadtick = false; - model0001e29c(false); + var8005efdc = false; model0001ee18(&g_Vars.currentplayer->model, g_Vars.lvupdate240, true); - model0001e29c(somebool); + var8005efdc = somebool; model0001b3bc(&g_Vars.currentplayer->model); mtx4LoadIdentity(&sp40); diff --git a/src/game/bondheadreset.c b/src/game/bondheadreset.c index 6c034a1b9..15e327a58 100644 --- a/src/game/bondheadreset.c +++ b/src/game/bondheadreset.c @@ -36,7 +36,7 @@ void bheadReset(void) modelInit(&g_Vars.currentplayer->model, &g_PlayerModelFileData, g_Vars.currentplayer->bondheadsave, false); animInit(g_Vars.currentplayer->model.anim); - modelSetScale(&g_Vars.currentplayer->model, 0.1000000089407f); + g_Vars.currentplayer->model.scale = 0.1000000089407f; modelSetAnimPlaySpeed(&g_Vars.currentplayer->model, (PAL ? 1.2f : 1), 0); g_Vars.currentplayer->headanim = 0; diff --git a/src/game/bondmove.c b/src/game/bondmove.c index 057c4267a..fcde09481 100644 --- a/src/game/bondmove.c +++ b/src/game/bondmove.c @@ -83,11 +83,6 @@ bool bmoveIsAutoAimEnabledForCurrentWeapon(void) return bmoveIsAutoAimEnabled(); } -bool bmoveIsInSightAimMode(void) -{ - return g_Vars.currentplayer->insightaimmode; -} - void bmoveUpdateAutoAimProp(struct prop *prop, f32 x, f32 y) { if (g_Vars.currentplayer->autoaimtime60 >= 0) { @@ -203,11 +198,11 @@ static void bmoveUpdateSpeedTheta(void) static f32 bmoveGetSpeedVertaLimit(f32 value) { if (value > 0) { - return (viGetFovY() * value * -0.7f) / 60.0f; + return (g_ViBackData->fovy * value * -0.7f) / 60.0f; } if (value < 0) { - return (viGetFovY() * -value * 0.7f) / 60.0f; + return (g_ViBackData->fovy * -value * 0.7f) / 60.0f; } return 0; @@ -215,7 +210,7 @@ static f32 bmoveGetSpeedVertaLimit(f32 value) static void bmoveUpdateSpeedVerta(f32 value) { - f32 mult = viGetFovY() / 60.0f; + f32 mult = g_ViBackData->fovy / 60.0f; f32 limit = bmoveGetSpeedVertaLimit(value); if (value > 0) { @@ -258,11 +253,11 @@ static void bmoveUpdateSpeedVerta(f32 value) static f32 bmoveGetSpeedThetaControlLimit(f32 value) { if (value > 0) { - return (viGetFovY() * value * -0.7f) / 60.0f; + return (g_ViBackData->fovy * value * -0.7f) / 60.0f; } if (value < 0) { - return (viGetFovY() * -value * 0.7f) / 60.0f; + return (g_ViBackData->fovy * -value * 0.7f) / 60.0f; } return 0; @@ -270,7 +265,7 @@ static f32 bmoveGetSpeedThetaControlLimit(f32 value) static void bmoveUpdateSpeedThetaControl(f32 value) { - f32 mult = viGetFovY() / 60.0f; + f32 mult = g_ViBackData->fovy / 60.0f; f32 limit = bmoveGetSpeedThetaControlLimit(value); if (value > 0) { @@ -375,12 +370,11 @@ static f32 bmoveCalculateLookahead(void) if (cdExamLos08(&spf0, spe0, &sp150, CDTYPE_BG | CDTYPE_CLOSEDDOORS, GEOFLAG_FLOOR1 | GEOFLAG_FLOOR2 | GEOFLAG_WALL | GEOFLAG_BLOCK_SIGHT) == CDRESULT_COLLISION) { - cdGetPos(&sp150); flags = cdGetGeoFlags(); - sp160 = sqrtf((sp150.x - spf0.x) * (sp150.x - spf0.x) - + (sp150.y - spf0.y) * (sp150.y - spf0.y) - + (sp150.z - spf0.z) * (sp150.z - spf0.z)); + sp160 = sqrtf((g_CdObstaclePos.x - spf0.x) * (g_CdObstaclePos.x - spf0.x) + + (g_CdObstaclePos.y - spf0.y) * (g_CdObstaclePos.y - spf0.y) + + (g_CdObstaclePos.z - spf0.z) * (g_CdObstaclePos.z - spf0.z)); } if (sp160 > 60.0f || (flags & GEOFLAG_FLOOR1)) { @@ -573,10 +567,10 @@ static void bmoveProcessInput(bool allowc1x, bool allowc1y, bool allowc1buttons, f32 increment2; f32 newverta; - controlmode = optionsGetControlMode(g_Vars.currentplayerstats->mpindex); + controlmode = g_PlayerConfigsArray[g_Vars.currentplayerstats->mpindex].controlmode; weaponnum = bgunGetWeaponNum(HAND_RIGHT); canmanualzoom = weaponHasAimFlag(weaponnum, INVAIMFLAG_MANUALZOOM); - contpad1 = optionsGetContpadNum1(g_Vars.currentplayerstats->mpindex); + contpad1 = g_PlayerConfigsArray[g_Vars.currentplayerstats->mpindex].contpad1; c1stickx = allowc1x ? joyGetStickX(contpad1) : 0; c1sticky = allowc1y ? joyGetStickY(contpad1) : 0; @@ -650,12 +644,12 @@ static void bmoveProcessInput(bool allowc1x, bool allowc1y, bool allowc1buttons, if (g_Vars.currentplayer->pausemode == PAUSEMODE_UNPAUSED) { if (g_Vars.currentplayer->isdead == false) { - if (controlmode == CONTROLMODE_23 || controlmode == CONTROLMODE_24 || controlmode == CONTROLMODE_22 || controlmode == CONTROLMODE_21) { + if (controlmode >= CONTROLMODE_21) { // 2.1: ctrl1 stick = walk/turn, z = fire, ctrl2 stick = look/strafe, z = aim // 2.2: ctrl1 stick = look, z = fire, ctrl2 stick = walk/strafe, z = aim // 2.3: ctrl1 stick = walk/turn, z = aim, ctrl2 stick = look/strafe, z = fire // 2.4: ctrl1 stick = look, z = aim, ctrl2 stick = walk/strafe, z = fire - contpad2 = (s8) optionsGetContpadNum2(g_Vars.currentplayerstats->mpindex); + contpad2 = g_PlayerConfigsArray[g_Vars.currentplayerstats->mpindex].contpad2; c2stickx = (s8) joyGetStickX(contpad2); c2sticky = (joyGetStickY(contpad2) << 24) >> 24; c2buttons = joyGetButtons(contpad2, 0xffff); @@ -741,7 +735,7 @@ static void bmoveProcessInput(bool allowc1x, bool allowc1y, bool allowc1buttons, } } - if (!lvIsPaused()) { + if (!g_LvIsPaused) { // Handle aiming if (optionsGetAimControl(g_Vars.currentplayerstats->mpindex) != AIMCONTROL_HOLD) { for (i = 0; i < numsamples; i++) { @@ -1046,7 +1040,7 @@ static void bmoveProcessInput(bool allowc1x, bool allowc1y, bool allowc1buttons, } } - if (!lvIsPaused()) { + if (!g_LvIsPaused) { // Handle aiming if (optionsGetAimControl(g_Vars.currentplayerstats->mpindex) != AIMCONTROL_HOLD) { for (i = 0; i < numsamples; i++) { @@ -1400,15 +1394,15 @@ static void bmoveProcessInput(bool allowc1x, bool allowc1y, bool allowc1buttons, bgunTickGameplay(movedata.triggeron); - if (g_Vars.bondvisible && (bgunIsFiring(HAND_RIGHT) || bgunIsFiring(HAND_LEFT))) { + if (g_Vars.bondvisible && (g_Vars.currentplayer->hands[HAND_RIGHT].firing || g_Vars.currentplayer->hands[HAND_LEFT].firing)) { noiseradius = 0; - if (bgunIsFiring(HAND_RIGHT) && bgunGetNoiseRadius(HAND_RIGHT) > noiseradius) { - noiseradius = bgunGetNoiseRadius(HAND_RIGHT); + if (g_Vars.currentplayer->hands[HAND_RIGHT].firing && g_Vars.currentplayer->hands[HAND_RIGHT].noiseradius > noiseradius) { + noiseradius = g_Vars.currentplayer->hands[HAND_RIGHT].noiseradius; } - if (bgunIsFiring(HAND_LEFT) && bgunGetNoiseRadius(HAND_LEFT) > noiseradius) { - noiseradius = bgunGetNoiseRadius(HAND_LEFT); + if (g_Vars.currentplayer->hands[HAND_LEFT].firing && g_Vars.currentplayer->hands[HAND_LEFT].noiseradius > noiseradius) { + noiseradius = g_Vars.currentplayer->hands[HAND_LEFT].noiseradius; } chrsCheckForNoise(noiseradius); @@ -1444,19 +1438,19 @@ static void bmoveProcessInput(bool allowc1x, bool allowc1y, bool allowc1buttons, g_Vars.currentplayer->gunzoomfovs[1] = eraserfov; - mtx4TransformVec(camGetWorldToScreenMtxf(), &g_Vars.currentplayer->autoerasertarget->pos, &spa0); + mtx4TransformVec(g_Vars.currentplayer->worldtoscreenmtx, &g_Vars.currentplayer->autoerasertarget->pos, &spa0); cam0f0b4eb8(&spa0, crosspos, eraserfov, g_Vars.currentplayer->c_perspaspect); - if (crosspos[0] < (camGetScreenLeft() + camGetScreenWidth() * 0.5f) - 20.0f) { + if (crosspos[0] < (g_Vars.currentplayer->c_screenleft + g_Vars.currentplayer->c_screenwidth * 0.5f) - 20.0f) { movedata.aimturnleftspeed = 0.25f; - } else if (crosspos[0] > camGetScreenLeft() + camGetScreenWidth() * 0.5f + 20.0f) { + } else if (crosspos[0] > g_Vars.currentplayer->c_screenleft + g_Vars.currentplayer->c_screenwidth * 0.5f + 20.0f) { movedata.aimturnrightspeed = 0.25f; } - if (crosspos[1] < (camGetScreenTop() + camGetScreenHeight() * 0.5f) - 20.0f) { + if (crosspos[1] < (g_Vars.currentplayer->c_screentop + g_Vars.currentplayer->c_screenheight * 0.5f) - 20.0f) { movedata.speedvertaup = 0.25f; - } else if (crosspos[1] > camGetScreenTop() + camGetScreenHeight() * 0.5f + 20.0f) { + } else if (crosspos[1] > g_Vars.currentplayer->c_screentop + g_Vars.currentplayer->c_screenheight * 0.5f + 20.0f) { movedata.speedvertadown = 0.25f; } } @@ -1587,7 +1581,7 @@ static void bmoveProcessInput(bool allowc1x, bool allowc1y, bool allowc1buttons, } } else { if (movedata.cannaturalpitch) { - tmp = viGetFovY() / 60.0f; + tmp = g_ViBackData->fovy / 60.0f; fVar25 = movedata.analogpitch / 70.0f; if (fVar25 > 1) { @@ -1624,7 +1618,7 @@ static void bmoveProcessInput(bool allowc1x, bool allowc1y, bool allowc1buttons, } if (movedata.cannaturalturn) { - tmp = viGetFovY() / 60.0f; + tmp = g_ViBackData->fovy / 60.0f; fVar25 = movedata.analogturn / 70.0f; if (fVar25 > 1) { @@ -1683,8 +1677,6 @@ static void bmoveProcessInput(bool allowc1x, bool allowc1y, bool allowc1buttons, f32 x; f32 y; - bgunSetAimType(0); - if ( ( movedata.canautoaim @@ -1736,7 +1728,6 @@ static void bmoveProcessInput(bool allowc1x, bool allowc1y, bool allowc1buttons, } else if (movedata.canmanualaim) { // Adjust crosshair's position on screen // when holding aim and moving stick - bgunSetAimType(0); bgunSwivelWithoutDamp((movedata.c1stickxraw * 0.65f) / 80.0f, (movedata.c1stickyraw * 0.65f) / 80.0f); } } diff --git a/src/game/bondview.c b/src/game/bondview.c index 47f62ea69..9e3bbb528 100644 --- a/src/game/bondview.c +++ b/src/game/bondview.c @@ -47,7 +47,7 @@ static Gfx *bviewCopyPixels(Gfx *gdl, u16 *fb, s32 top, u32 tile, s32 arg4, f32 numparts = 2; lrs[0] = width / numparts; - image = (u32) &fb[viGetWidth() * top + left] & 0x00ffffff; + image = (u32) &fb[g_ViBackData->x * top + left] & 0x00ffffff; gDPSetTextureImage(gdl++, G_IM_FMT_RGBA, G_IM_SIZ_16b, 320, image); gDPLoadBlock(gdl++, tile, 0, 0, width / numparts - 1, 0); @@ -64,7 +64,7 @@ static Gfx *bviewCopyPixels(Gfx *gdl, u16 *fb, s32 top, u32 tile, s32 arg4, f32 left += lrs[0]; - image = (u32) &fb[viGetWidth() * top + left] & 0x00ffffff; + image = (u32) &fb[g_ViBackData->x * top + left] & 0x00ffffff; gDPSetTextureImage(gdl++, G_IM_FMT_RGBA, G_IM_SIZ_16b, 320, image); gDPLoadBlock(gdl++, tile, 0, 0, lrs[0] - 1, 0); @@ -82,7 +82,7 @@ static Gfx *bviewCopyPixels(Gfx *gdl, u16 *fb, s32 top, u32 tile, s32 arg4, f32 } else { width2 = width; - image = (u32) &fb[viGetWidth() * top + left] & 0x00ffffff; + image = (u32) &fb[g_ViBackData->x * top + left] & 0x00ffffff; gDPSetTextureImage(gdl++, G_IM_FMT_RGBA, G_IM_SIZ_16b, 320, image); gDPLoadBlock(gdl++, tile, 0, 0, width2 - 1, 0); @@ -176,13 +176,13 @@ static Gfx *bviewPrepareStaticI8(Gfx *gdl, u32 colour, u32 alpha) Gfx *bviewDrawMotionBlur(Gfx *gdl, u32 colour, u32 alpha) { - u16 *fb = viGetFrontBuffer(); - s32 viewtop = viGetViewTop(); - s32 viewheight = viGetViewHeight(); + u16 *fb = g_ViFrontData->fb; + s32 viewtop = g_ViBackData->viewtop; + s32 viewheight = g_ViBackData->viewy; f32 fxxx; f32 fyyy; - s32 viewwidth = viGetViewWidth(); - s32 viewleft = viGetViewLeft(); + s32 viewwidth = g_ViBackData->viewx; + s32 viewleft = g_ViBackData->viewleft; f32 somefloat; s32 newalpha; s32 i; @@ -220,11 +220,11 @@ Gfx *bviewDrawMotionBlur(Gfx *gdl, u32 colour, u32 alpha) */ Gfx *bviewDrawStatic(Gfx *gdl, u32 arg1, s32 arg2) { - u16 *fb = viGetFrontBuffer(); - s32 viewtop = viGetViewTop(); - s32 viewheight = viGetViewHeight(); - s32 viewwidth = viGetViewWidth(); - s32 viewleft = viGetViewLeft(); + u16 *fb = g_ViFrontData->fb; + s32 viewtop = g_ViBackData->viewtop; + s32 viewheight = g_ViBackData->viewy; + s32 viewwidth = g_ViBackData->viewx; + s32 viewleft = g_ViBackData->viewleft; u16 *fb2 = (u16 *) PHYS_TO_K0(random() & 0xfff00); s32 y; @@ -248,12 +248,12 @@ Gfx *bviewDrawStatic(Gfx *gdl, u32 arg1, s32 arg2) */ Gfx *bviewDrawSlayerRocketInterlace(Gfx *gdl, u32 colour, u32 alpha) { - u16 *fb = viGetBackBuffer(); - s32 viewtop = viGetViewTop(); - s32 viewheight = viGetViewHeight(); - s32 viewwidth = viGetViewWidth(); + u16 *fb = g_ViBackData->fb; + s32 viewtop = g_ViBackData->viewtop; + s32 viewheight = g_ViBackData->viewy; + s32 viewwidth = g_ViBackData->viewx; s32 y; - s32 viewleft = viGetViewLeft(); + s32 viewleft = g_ViBackData->viewleft; f32 angle = 0.52359879016876f; s32 offset = (s32)(g_20SecIntervalFrac * 600.0f) % 12; f32 increment; @@ -294,12 +294,12 @@ Gfx *bviewDrawSlayerRocketInterlace(Gfx *gdl, u32 colour, u32 alpha) */ Gfx *bviewDrawFilmInterlace(Gfx *gdl, u32 colour, u32 alpha) { - u16 *fb = viGetBackBuffer(); - s32 viewtop = viGetViewTop(); - s32 viewheight = viGetViewHeight(); + u16 *fb = g_ViBackData->fb; + s32 viewtop = g_ViBackData->viewtop; + s32 viewheight = g_ViBackData->viewy; s32 y; - s32 viewwidth = viGetViewWidth(); - s32 viewleft = viGetViewLeft(); + s32 viewwidth = g_ViBackData->viewx; + s32 viewleft = g_ViBackData->viewleft; s32 offset = (s32)(g_20SecIntervalFrac * 600.0f) % 12; u32 stack; @@ -342,11 +342,11 @@ Gfx *bviewDrawFilmInterlace(Gfx *gdl, u32 colour, u32 alpha) */ Gfx *bviewDrawZoomBlur(Gfx *gdl, u32 colour, s32 alpha, f32 arg3, f32 arg4) { - u16 *fb = viGetFrontBuffer(); - s32 viewtop = viGetViewTop(); - s32 viewheight = viGetViewHeight(); - s32 viewwidth = viGetViewWidth(); - s32 viewleft = viGetViewLeft(); + u16 *fb = g_ViFrontData->fb; + s32 viewtop = g_ViBackData->viewtop; + s32 viewheight = g_ViBackData->viewy; + s32 viewwidth = g_ViBackData->viewx; + s32 viewleft = g_ViBackData->viewleft; f32 somefloat; s32 i; @@ -404,7 +404,7 @@ static f32 bview0f142d74(s32 arg0, f32 arg1, f32 arg2, f32 arg3) */ Gfx *bviewDrawFisheye(Gfx *gdl, u32 colour, u32 alpha, s32 shuttertime60, s8 startuptimer60, u8 hit) { - u16 *fb = viGetBackBuffer(); + u16 *fb = g_ViBackData->fb; s32 viewtop; s32 viewheight; f32 f26; @@ -425,13 +425,13 @@ Gfx *bviewDrawFisheye(Gfx *gdl, u32 colour, u32 alpha, s32 shuttertime60, s8 sta f32 tmp; - viewtop = viGetViewTop(); - viewheight = viGetViewHeight(); + viewtop = g_ViBackData->viewtop; + viewheight = g_ViBackData->viewy; halfheight = viewheight * 0.5f; sqhalfheight = halfheight * halfheight; f26 = -(halfheight + halfheight) / viewheight; - viewwidth = viGetViewWidth(); - viewleft = viGetViewLeft(); + viewwidth = g_ViBackData->viewx; + viewleft = g_ViBackData->viewleft; startupfrac = 1.0f; s2 = 0; @@ -652,10 +652,10 @@ static Gfx *bviewDrawEyespySideRect(Gfx *gdl, s32 *points, u8 r, u8 g, u8 b, u8 Gfx *bviewDrawEyespyMetrics(Gfx *gdl) { char text[256]; - s32 viewleft = viGetViewLeft(); - s32 viewtop = viGetViewTop(); - s32 viewwidth = viGetViewWidth(); - s32 viewheight = viGetViewHeight(); + s32 viewleft = g_ViBackData->viewleft; + s32 viewtop = g_ViBackData->viewtop; + s32 viewwidth = g_ViBackData->viewx; + s32 viewheight = g_ViBackData->viewy; s32 viewright = viewleft + viewwidth - 1; s32 viewbottom = viewtop + viewheight - 1; s32 x; @@ -690,7 +690,7 @@ Gfx *bviewDrawEyespyMetrics(Gfx *gdl) chr = g_Vars.currentplayer->eyespy->prop->chr; - if (optionsGetScreenSplit() == SCREENSPLIT_VERTICAL && PLAYERCOUNT() >= 2) { + if (g_ScreenSplit == SCREENSPLIT_VERTICAL && PLAYERCOUNT() >= 2) { vsplit = true; } @@ -770,7 +770,7 @@ Gfx *bviewDrawEyespyMetrics(Gfx *gdl) gdl = text0f153858(gdl, &x, &y, &x2, &y2); gdl = textRender(gdl, &x, &y, text, g_CharsHandelGothicXs, g_FontHandelGothicXs, - colourtextbright, colourglow, viGetWidth(), viGetHeight(), 0, 0); + colourtextbright, colourglow, g_ViBackData->x, g_ViBackData->y, 0, 0); // "H/M" sprintf(text, "%s %s%4.2f", langGet(L_MISC_074), "", g_Vars.currentplayer->eyespy->height * 0.01f); @@ -782,7 +782,7 @@ Gfx *bviewDrawEyespyMetrics(Gfx *gdl) y2 = y + textheight; \ gdl = text0f153858(gdl, &x, &y, &x2, &y2); gdl = textRender(gdl, &x, &y, text, g_CharsHandelGothicXs, g_FontHandelGothicXs, - colourtextbright, colourglow, viGetWidth(), viGetHeight(), 0, 0); + colourtextbright, colourglow, g_ViBackData->x, g_ViBackData->y, 0, 0); // "Y/D" sprintf(text, "%s %d", langGet(L_MISC_075), (s32)g_Vars.currentplayer->eyespy->theta); @@ -794,7 +794,7 @@ Gfx *bviewDrawEyespyMetrics(Gfx *gdl) y2 = y + textheight; \ gdl = text0f153858(gdl, &x, &y, &x2, &y2); gdl = textRender(gdl, &x, &y, text, g_CharsHandelGothicXs, g_FontHandelGothicXs, - colourtextbright, colourglow, viGetWidth(), viGetHeight(), 0, 0); + colourtextbright, colourglow, g_ViBackData->x, g_ViBackData->y, 0, 0); // "P/D" sprintf(text, "%s %d", langGet(L_MISC_076), (s32)g_Vars.currentplayer->eyespy->verta); @@ -806,7 +806,7 @@ Gfx *bviewDrawEyespyMetrics(Gfx *gdl) y2 = y + textheight; \ gdl = text0f153858(gdl, &x, &y, &x2, &y2); gdl = textRender(gdl, &x, &y, text, g_CharsHandelGothicXs, g_FontHandelGothicXs, - colourtextbright, colourglow, viGetWidth(), viGetHeight(), 0, 0); + colourtextbright, colourglow, g_ViBackData->x, g_ViBackData->y, 0, 0); // "CI 2023" sprintf(text, "%s", langGet(L_MISC_077)); @@ -818,7 +818,7 @@ Gfx *bviewDrawEyespyMetrics(Gfx *gdl) y2 = y + textheight; \ gdl = text0f153858(gdl, &x, &y, &x2, &y2); gdl = textRender(gdl, &x, &y, text, g_CharsHandelGothicXs, g_FontHandelGothicXs, - colourtextdull, colourglow, viGetWidth(), viGetHeight(), 0, 0); + colourtextdull, colourglow, g_ViBackData->x, g_ViBackData->y, 0, 0); if (g_Vars.currentplayer->eyespy->mode == EYESPYMODE_CAMSPY) { sprintf(text, "%s", langGet(L_MISC_078)); // "YKK: 95935" @@ -837,7 +837,7 @@ Gfx *bviewDrawEyespyMetrics(Gfx *gdl) y2 = y + textheight; \ gdl = text0f153858(gdl, &x, &y, &x2, &y2); gdl = textRender(gdl, &x, &y, text, g_CharsHandelGothicXs, g_FontHandelGothicXs, - colourtextdull, colourglow, viGetWidth(), viGetHeight(), 0, 0); + colourtextdull, colourglow, g_ViBackData->x, g_ViBackData->y, 0, 0); if (g_Vars.currentplayer->eyespy->mode == EYESPYMODE_CAMSPY) { // "CAMSPY" @@ -850,7 +850,7 @@ Gfx *bviewDrawEyespyMetrics(Gfx *gdl) y2 = y + textheight; \ gdl = text0f153858(gdl, &x, &y, &x2, &y2); gdl = textRender(gdl, &x, &y, text, g_CharsHandelGothicXs, g_FontHandelGothicXs, - colourtextdull, colourglow, viGetWidth(), viGetHeight(), 0, 0); + colourtextdull, colourglow, g_ViBackData->x, g_ViBackData->y, 0, 0); } else if (g_Vars.currentplayer->eyespy->mode == EYESPYMODE_DRUGSPY) { // "DRUGSPY" sprintf(text, " %s", langGet(L_MISC_468)); @@ -862,7 +862,7 @@ Gfx *bviewDrawEyespyMetrics(Gfx *gdl) y2 = y + textheight; \ gdl = text0f153858(gdl, &x, &y, &x2, &y2); gdl = textRender(gdl, &x, &y, text, g_CharsHandelGothicXs, g_FontHandelGothicXs, - colourtextdull, colourglow, viGetWidth(), viGetHeight(), 0, 0); + colourtextdull, colourglow, g_ViBackData->x, g_ViBackData->y, 0, 0); } else { // "BOMBSPY" sprintf(text, " %s", langGet(L_MISC_469)); @@ -874,7 +874,7 @@ Gfx *bviewDrawEyespyMetrics(Gfx *gdl) y2 = y + textheight; \ gdl = text0f153858(gdl, &x, &y, &x2, &y2); gdl = textRender(gdl, &x, &y, text, g_CharsHandelGothicXs, g_FontHandelGothicXs, - colourtextdull, colourglow, viGetWidth(), viGetHeight(), 0, 0); + colourtextdull, colourglow, g_ViBackData->x, g_ViBackData->y, 0, 0); } // Model number @@ -893,7 +893,7 @@ Gfx *bviewDrawEyespyMetrics(Gfx *gdl) y2 = y + textheight; \ gdl = text0f153858(gdl, &x, &y, &x2, &y2); gdl = textRender(gdl, &x, &y, text, g_CharsHandelGothicXs, g_FontHandelGothicXs, - colourtextdull, colourglow, viGetWidth(), viGetHeight(), 0, 0); + colourtextdull, colourglow, g_ViBackData->x, g_ViBackData->y, 0, 0); // Gyrostat/dartammo text if (g_Vars.currentplayer->eyespy->mode == EYESPYMODE_CAMSPY @@ -910,15 +910,15 @@ Gfx *bviewDrawEyespyMetrics(Gfx *gdl) y2 = y + textheight; \ gdl = text0f153858(gdl, &x, &y, &x2, &y2); gdl = textRender(gdl, &x, &y, text, g_CharsHandelGothicXs, g_FontHandelGothicXs, - colourtextdull, colourglow, viGetWidth(), viGetHeight(), 0, 0); + colourtextdull, colourglow, g_ViBackData->x, g_ViBackData->y, 0, 0); gdl = text0f153838(gdl); { - s8 contpadnum = optionsGetContpadNum1(g_Vars.currentplayerstats->mpindex); - u16 buttonsdown = joyGetButtons(contpadnum, 0xffff); \ + s8 contpadnum = g_PlayerConfigsArray[g_Vars.currentplayerstats->mpindex].contpad1; + u16 buttonsdown = joyGetButtons(contpadnum, 0xffff); u16 buttonsthisframe = joyGetButtonsPressedThisFrame(contpadnum, 0xffff); - s8 cstickx = joyGetStickX(contpadnum); \ + s8 cstickx = joyGetStickX(contpadnum); s8 csticky = joyGetStickY(contpadnum); s32 xpos; s32 tmpval; @@ -1568,11 +1568,11 @@ u8 var8007f878 = 0; Gfx *bviewDrawNvLens(Gfx *gdl) { - u16 *fb = viGetBackBuffer(); - s32 viewheight = viGetViewHeight(); - s32 viewwidth = viGetViewWidth(); - s32 viewtop = viGetViewTop(); - s32 viewleft = viGetViewLeft(); + u16 *fb = g_ViBackData->fb; + s32 viewheight = g_ViBackData->viewy; + s32 viewwidth = g_ViBackData->viewx; + s32 viewtop = g_ViBackData->viewtop; + s32 viewleft = g_ViBackData->viewleft; s32 viewbottom = viewtop + viewheight; s32 roomvalue; s32 y; @@ -1627,11 +1627,11 @@ Gfx *bviewDrawIrLens(Gfx *gdl) { s32 i; s32 fadeincrement; - u16 *fb = viGetBackBuffer(); - s32 viewheight = viGetViewHeight(); - s32 viewwidth = viGetViewWidth(); - s32 viewtop = viGetViewTop(); - s32 viewleft = viGetViewLeft(); + u16 *fb = g_ViBackData->fb; + s32 viewheight = g_ViBackData->viewy; + s32 viewwidth = g_ViBackData->viewx; + s32 viewtop = g_ViBackData->viewtop; + s32 viewleft = g_ViBackData->viewleft; s32 viewright; s32 viewbottom; s32 viewcentrex; @@ -1766,11 +1766,11 @@ Gfx *bviewDrawIrLens(Gfx *gdl) Gfx *bviewDrawHorizonScanner(Gfx *gdl) { - u16 *fb = viGetBackBuffer(); - s32 viewtop = viGetViewTop(); - s32 viewheight = viGetViewHeight(); - s32 viewwidth = viGetViewWidth(); - s32 viewleft = viGetViewLeft(); + u16 *fb = g_ViBackData->fb; + s32 viewtop = g_ViBackData->viewtop; + s32 viewheight = g_ViBackData->viewy; + s32 viewwidth = g_ViBackData->viewx; + s32 viewleft = g_ViBackData->viewleft; char directiontext[32]; char hertztext[24]; char zoomtext[24]; @@ -1810,7 +1810,7 @@ Gfx *bviewDrawHorizonScanner(Gfx *gdl) return gdl; } - if (optionsGetScreenSplit() == SCREENSPLIT_VERTICAL && PLAYERCOUNT() >= 2) { + if (g_ScreenSplit == SCREENSPLIT_VERTICAL && PLAYERCOUNT() >= 2) { vsplit = true; } @@ -1839,7 +1839,7 @@ Gfx *bviewDrawHorizonScanner(Gfx *gdl) sprintf(directiontext, "%s %s:%03d", arrows, &directions[(turnangle + 22) / 45], turnangle); sprintf(hertztext, "%s %s%s%4.2fh", arrows, "", "", menuGetCosOscFrac(4) * 4.6f + 917.4f); - fovy = viGetFovY(); + fovy = g_ViBackData->fovy; if (fovy == 0 || fovy == 60.0f) { fovy = 1; @@ -1860,7 +1860,7 @@ Gfx *bviewDrawHorizonScanner(Gfx *gdl) y = lenstop - 7; gdl = textRenderProjected(gdl, &x, &y, arrows, - g_CharsHandelGothicXs, g_FontHandelGothicXs, 0xffffff7f, viGetWidth(), viGetHeight(), 0, 0); + g_CharsHandelGothicXs, g_FontHandelGothicXs, 0xffffff7f, g_ViBackData->x, g_ViBackData->y, 0, 0); // Product name strcpy(nametext, " JMBC"); @@ -1872,13 +1872,13 @@ Gfx *bviewDrawHorizonScanner(Gfx *gdl) strcat(nametext, " SCANNER\n"); gdl = textRenderProjected(gdl, &x, &y, nametext, - g_CharsHandelGothicXs, g_FontHandelGothicXs, 0xffffff7f, viGetWidth(), viGetHeight(), 0, 0); + g_CharsHandelGothicXs, g_FontHandelGothicXs, 0xffffff7f, g_ViBackData->x, g_ViBackData->y, 0, 0); // Hertz x = viewleft + 75 * scale; y = lenstop + lensheight + 1; gdl = textRenderProjected(gdl, &x, &y, hertztext, - g_CharsHandelGothicXs, g_FontHandelGothicXs, 0xffffff7f, viGetWidth(), viGetHeight(), 0, 0); + g_CharsHandelGothicXs, g_FontHandelGothicXs, 0xffffff7f, g_ViBackData->x, g_ViBackData->y, 0, 0); // Zoom level if (vsplit) { @@ -1890,7 +1890,7 @@ Gfx *bviewDrawHorizonScanner(Gfx *gdl) } gdl = textRenderProjected(gdl, &x, &y, zoomtext, - g_CharsHandelGothicXs, g_FontHandelGothicXs, 0xffffff7f, viGetWidth(), viGetHeight(), 0, 0); + g_CharsHandelGothicXs, g_FontHandelGothicXs, 0xffffff7f, g_ViBackData->x, g_ViBackData->y, 0, 0); // Direction if (vsplit) { @@ -1902,7 +1902,7 @@ Gfx *bviewDrawHorizonScanner(Gfx *gdl) } gdl = textRenderProjected(gdl, &x, &y, directiontext, - g_CharsHandelGothicXs, g_FontHandelGothicXs, 0xffffff7f, viGetWidth(), viGetHeight(), 0, 0); + g_CharsHandelGothicXs, g_FontHandelGothicXs, 0xffffff7f, g_ViBackData->x, g_ViBackData->y, 0, 0); gdl = text0f153780(gdl); gDPPipeSync(gdl++); @@ -1976,10 +1976,10 @@ Gfx *bviewDrawHorizonScanner(Gfx *gdl) */ Gfx *bviewDrawIrBinoculars(Gfx *gdl) { - s32 viewheight = viGetViewHeight(); - s32 viewwidth = viGetViewWidth(); - s32 viewtop = viGetViewTop(); - s32 viewleft = viGetViewLeft(); + s32 viewheight = g_ViBackData->viewy; + s32 viewwidth = g_ViBackData->viewx; + s32 viewtop = g_ViBackData->viewtop; + s32 viewleft = g_ViBackData->viewleft; s32 viewright = viewleft + viewwidth; s32 viewbottom = viewtop + viewheight; s32 leftx = viewleft + viewwidth / 3; diff --git a/src/game/bondwalk.c b/src/game/bondwalk.c index 2654c1c40..77960f583 100644 --- a/src/game/bondwalk.c +++ b/src/game/bondwalk.c @@ -143,11 +143,9 @@ static void bwalk0f0c3b38(struct coord *reltarget, struct defaultobj *obj) abstarget.y = g_Vars.currentplayer->prop->pos.y; abstarget.z = reltarget->z + g_Vars.currentplayer->prop->pos.z; - cdGetEdge(&globalthinga, &globalthingb); - - vector.x = globalthingb.z - globalthinga.z; + vector.x = g_CdEdgeVtx2.z - g_CdEdgeVtx1.z; vector.y = 0; - vector.z = globalthinga.x - globalthingb.x; + vector.z = g_CdEdgeVtx1.x - g_CdEdgeVtx2.x; if (vector.f[0] != 0 || vector.f[2] != 0) { guNormalize(&vector.x, &vector.y, &vector.z); @@ -155,7 +153,7 @@ static void bwalk0f0c3b38(struct coord *reltarget, struct defaultobj *obj) vector.z = 1; } - func0f02e3dc(&globalthinga, &globalthingb, &abstarget, &vector, &posunk); + func0f02e3dc(&g_CdEdgeVtx1, &g_CdEdgeVtx2, &abstarget, &vector, &posunk); tween.x = (abstarget.x - g_Vars.currentplayer->prop->pos.x) / g_Vars.lvupdate60freal; tween.y = 0; @@ -332,7 +330,7 @@ static bool bwalkCalculateNewPositionWithPush(struct coord *delta, f32 rotateamo s32 result = bwalkCalculateNewPosition(delta, rotateamount, apply, extrawidth, types); if (result != CDRESULT_NOCOLLISION) { - struct prop *obstacle = cdGetObstacleProp(); + struct prop *obstacle = g_CdObstacleProp; if (obstacle && g_Vars.lvupdate240 > 0) { if (obstacle->type == PROPTYPE_DOOR) { @@ -343,11 +341,9 @@ static bool bwalkCalculateNewPositionWithPush(struct coord *delta, f32 rotateamo if (door->doorflags & DOORFLAG_DAMAGEONCONTACT) { if (!g_Vars.currentplayer->isdead) { - cdGetEdge(&sp84, &sp78); - - sp90.x = sp78.f[2] - sp84.f[2]; + sp90.x = g_CdEdgeVtx2.f[2] - g_CdEdgeVtx1.f[2]; sp90.y = 0; - sp90.z = sp84.f[0] - sp78.f[0]; + sp90.z = g_CdEdgeVtx1.f[0] - g_CdEdgeVtx2.f[0]; if (sp90.f[0] || sp90.f[2]) { guNormalize(&sp90.x, &sp90.y, &sp90.z); @@ -473,7 +469,8 @@ static s32 bwalk0f0c4764(struct coord *delta, struct coord *arg1, struct coord * s32 result = bwalkCalculateNewPositionWithPush(delta, 0, true, 0, types); if (result == CDRESULT_COLLISION) { - cdGetEdge(arg1, arg2); + *arg1 = g_CdEdgeVtx1; + *arg2 = g_CdEdgeVtx2; } return result; @@ -485,8 +482,8 @@ static s32 bwalk0f0c47d0(struct coord *a, struct coord *b, struct coord *c, struct coord quarter; bool result; - if (cd00024ea4()) { - f32 mult = cd00024e98(); + if (g_Cd8009a8ac) { + f32 mult = g_Cd8009a8b0; quarter.x = a->x * mult * 0.25f; quarter.y = a->y * mult * 0.25f; quarter.z = a->z * mult * 0.25f; @@ -497,7 +494,8 @@ static s32 bwalk0f0c47d0(struct coord *a, struct coord *b, struct coord *c, } if (result == CDRESULT_COLLISION) { - cdGetEdge(d, e); + *d = g_CdEdgeVtx1; + *e = g_CdEdgeVtx2; if (b->x != d->x || b->y != d->y @@ -827,7 +825,7 @@ static void bwalkUpdateVertical(void) g_Vars.currentplayer->vv_manground = sumground; } else { // Not enough room above. If on a hoverbike, blow it up - prop = cdGetObstacleProp(); + prop = g_CdObstacleProp; if (prop && g_Vars.currentplayer->prop->pos.y < prop->pos.y @@ -894,7 +892,7 @@ static void bwalkUpdateVertical(void) && g_Vars.currentplayer->vv_ground < g_Vars.currentplayer->vv_manground - 30) { // Not falling - but still at least 30 units off the ground. // Must be something in the way... - prop = cdGetObstacleProp(); + prop = g_CdObstacleProp; if (prop) { if (prop->type == PROPTYPE_CHR) { diff --git a/src/game/bot.c b/src/game/bot.c index a8e8f3316..f0639288d 100644 --- a/src/game/bot.c +++ b/src/game/bot.c @@ -498,7 +498,7 @@ static bool botTestPropForPickup(struct prop *prop, struct chrdata *chr) shield = (struct shieldobj *)prop->obj; ignore2 = false; - if (shield->amount <= chrGetShield(chr) * 0.125f) { + if (shield->amount <= chr->cshield * 0.125f) { ignore2 = true; } else if (g_MpSetup.scenario == MPSCENARIO_HOLDTHEBRIEFCASE && chr->aibot->hasbriefcase) { ignore2 = true; diff --git a/src/game/botact.c b/src/game/botact.c index 939ef39cb..5c4e0bfb4 100644 --- a/src/game/botact.c +++ b/src/game/botact.c @@ -248,7 +248,7 @@ bool botactShootFarsight(struct chrdata *chr, s32 arg1, struct coord *vector, st && func0f06b39c(arg3, vector, &oppprop->pos, chr0f0278a4(oppchr))) { bgunPlayPropHitSound(&gset, oppprop, -1); - if (oppchr->model && chrGetShield(oppchr) > 0) { + if (oppchr->model && oppchr->cshield > 0) { chrCalculateShieldHit(oppchr, &oppprop->pos, vector, &node, &hitpart, &model, &side); } diff --git a/src/game/camera.c b/src/game/camera.c index 3941a3d20..74b4c6242 100644 --- a/src/game/camera.c +++ b/src/game/camera.c @@ -21,33 +21,6 @@ struct coord var8009dd50; f32 var8009dd5c; f32 var8009dd6c; -void camSetScreenSize(f32 width, f32 height) -{ - struct player *player = g_Vars.currentplayer; - - player->c_screenwidth = width; - player->c_screenheight = height; - player->c_halfwidth = width * 0.5f; - player->c_halfheight = height * 0.5f; -} - -void camSetScreenPosition(f32 left, f32 top) -{ - struct player *player = g_Vars.currentplayer; - - player->c_screenleft = left; - player->c_screentop = top; -} - -void camSetPerspective(f32 near, f32 fovy, f32 aspect) -{ - struct player *player = g_Vars.currentplayer; - - player->c_perspnear = near; - player->c_perspfovy = fovy; - player->c_perspaspect = aspect; -} - f32 cam0f0b49b8(f32 arg0) { f32 result = atan2f(g_Vars.currentplayer->c_scalelod60 * arg0 * g_Vars.currentplayer->c_halfheight, 1.0f); @@ -176,51 +149,6 @@ void cam0f0b4eb8(struct coord *arg0, f32 arg1[2], f32 zoom, f32 aspect) arg1[0] = player->c_screenleft + player->c_halfwidth - f14 * arg0->f[0]; } -void camSetMtxL1738(Mtx *mtx) -{ - g_Vars.currentplayer->mtxl1738 = mtx; -} - -void camSetMtxL173c(Mtx *mtx) -{ - g_Vars.currentplayer->mtxl173c = mtx; -} - -Mtx *camGetMtxL173c(void) -{ - return g_Vars.currentplayer->mtxl173c; -} - -void camSetMtxF006c(Mtxf *mtx) -{ - g_Vars.currentplayer->mtxf006c = mtx; -} - -Mtxf *camGetMtxF006c(void) -{ - return g_Vars.currentplayer->mtxf006c; -} - -void camSetPerspectiveMtxL(Mtx *mtx) -{ - g_Vars.currentplayer->perspmtxl = mtx; -} - -Mtx *camGetPerspectiveMtxL(void) -{ - return g_Vars.currentplayer->perspmtxl; -} - -void camSetOrthogonalMtxL(Mtx *mtx) -{ - g_Vars.currentplayer->orthomtxl = mtx; -} - -Mtx *camGetOrthogonalMtxL(void) -{ - return g_Vars.currentplayer->orthomtxl; -} - void camSetWorldToScreenMtxf(Mtxf *mtx) { struct player *player = g_Vars.currentplayer; @@ -304,21 +232,6 @@ Mtxf *cam0f0b53a4(u8 *arg0) return result; } -Mtxf *camGetWorldToScreenMtxf(void) -{ - return g_Vars.currentplayer->worldtoscreenmtx; -} - -void camSetMtxF1754(Mtxf *mtx) -{ - g_Vars.currentplayer->mtxf1754 = mtx; -} - -Mtxf *camGetMtxF1754(void) -{ - return g_Vars.currentplayer->mtxf1754; -} - void camSetProjectionMtxF(Mtxf *mtx) { struct player *player = g_Vars.currentplayer; @@ -328,51 +241,6 @@ void camSetProjectionMtxF(Mtxf *mtx) player->projectionmtx = mtx; } -Mtxf *camGetProjectionMtxF(void) -{ - return g_Vars.currentplayer->projectionmtx; -} - -void camSetLookAt(LookAt *lookat) -{ - g_Vars.currentplayer->lookat = lookat; -} - -LookAt *camGetLookAt(void) -{ - return g_Vars.currentplayer->lookat; -} - -f32 camGetLodScaleZ(void) -{ - return g_Vars.currentplayer->c_lodscalez; -} - -f32 camGetScreenWidth(void) -{ - return g_Vars.currentplayer->c_screenwidth; -} - -f32 camGetScreenHeight(void) -{ - return g_Vars.currentplayer->c_screenheight; -} - -f32 camGetScreenLeft(void) -{ - return g_Vars.currentplayer->c_screenleft; -} - -f32 camGetScreenTop(void) -{ - return g_Vars.currentplayer->c_screentop; -} - -f32 camGetPerspAspect(void) -{ - return g_Vars.currentplayer->c_perspaspect; -} - void cam0f0b5838(void) { f32 sp2c; diff --git a/src/game/chr.c b/src/game/chr.c index 9d59b117e..3e9e20f77 100644 --- a/src/game/chr.c +++ b/src/game/chr.c @@ -64,11 +64,6 @@ struct chrdata *g_ChrSlots = NULL; s32 g_NumChrSlots = 0; -s32 chrsGetNumSlots(void) -{ - return g_NumChrSlots; -} - void chrSetChrnum(struct chrdata *chr, s16 newnum) { s16 oldnum = chr->chrnum; @@ -170,7 +165,8 @@ void chrCalculatePushPos(struct chrdata *chr, struct coord *dstpos, s16 *dstroom moveok = true; } else { - cdGetEdge(&sp78, &sp6c); + sp78 = g_CdEdgeVtx1; + sp6c = g_CdEdgeVtx2; // Attempt to find a valid position - method #1 sp60.x = dstpos->x - prop->pos.x; @@ -1364,7 +1360,7 @@ static void chrHandleJointPositioned(s32 joint, Mtxf *mtx) return; } - mtx00015be0(camGetProjectionMtxF(), mtx); + mtx00015be0(g_Vars.currentplayer->projectionmtx, mtx); sp138.x = mtx->m[3][0]; sp138.y = mtx->m[3][1]; @@ -1410,7 +1406,7 @@ static void chrHandleJointPositioned(s32 joint, Mtxf *mtx) mtx->m[3][1] = sp138.y; mtx->m[3][2] = sp138.z; - mtx00015be0(camGetWorldToScreenMtxf(), mtx); + mtx00015be0(g_Vars.currentplayer->worldtoscreenmtx, mtx); } else { if (g_CurModelChr->model->filedata->skel == &g_SkelChr) { lshoulderjoint = 2; @@ -1573,7 +1569,7 @@ static void chrHandleJointPositioned(s32 joint, Mtxf *mtx) yrot += M_BADTAU; } - mtx00015be0(camGetProjectionMtxF(), mtx); + mtx00015be0(g_Vars.currentplayer->projectionmtx, mtx); sp70.x = mtx->m[3][0]; sp70.y = mtx->m[3][1]; @@ -1618,7 +1614,7 @@ static void chrHandleJointPositioned(s32 joint, Mtxf *mtx) mtx->m[3][1] = sp70.y; mtx->m[3][2] = sp70.z; - mtx00015be0(camGetWorldToScreenMtxf(), mtx); + mtx00015be0(g_Vars.currentplayer->worldtoscreenmtx, mtx); } } } @@ -2332,7 +2328,7 @@ s32 chrTick(struct prop *prop) } if (cheatIsActive(CHEAT_DKMODE)) { - modelSetDistanceScale(0.3125f); + g_ModelDistanceScale = 0.3125f; } g_ModelJointPositionedFunc = &chrHandleJointPositioned; @@ -2346,7 +2342,7 @@ s32 chrTick(struct prop *prop) sp190.z = cosf(angle) * 19; mtx4LoadTranslation(&sp190, &sp1a8); - mtx4MultMtx4InPlace(camGetWorldToScreenMtxf(), &sp1a8); + mtx4MultMtx4InPlace(g_Vars.currentplayer->worldtoscreenmtx, &sp1a8); sp210.unk00 = &sp1a8; } else if (prop->type == PROPTYPE_PLAYER) { u8 stack[0x14]; @@ -2363,13 +2359,13 @@ s32 chrTick(struct prop *prop) sp17c.z = sinf(-sp178) * sp130; mtx4LoadTranslation(&sp17c, &sp1a8); - mtx4MultMtx4InPlace(camGetWorldToScreenMtxf(), &sp1a8); + mtx4MultMtx4InPlace(g_Vars.currentplayer->worldtoscreenmtx, &sp1a8); sp210.unk00 = &sp1a8; } else { - sp210.unk00 = camGetWorldToScreenMtxf(); + sp210.unk00 = g_Vars.currentplayer->worldtoscreenmtx; } } else { - sp210.unk00 = camGetWorldToScreenMtxf(); + sp210.unk00 = g_Vars.currentplayer->worldtoscreenmtx; } sp210.unk10 = gfxAllocate(model->filedata->nummatrices * sizeof(Mtxf)); @@ -2389,7 +2385,7 @@ s32 chrTick(struct prop *prop) f32 xdiff; f32 ydiff; f32 zdiff; - f32 sp114 = camGetLodScaleZ(); + f32 sp114 = g_Vars.currentplayer->c_lodscalez; bool restore = false; f32 prevfrac; s32 prevframea; @@ -2448,7 +2444,7 @@ s32 chrTick(struct prop *prop) } g_ModelJointPositionedFunc = NULL; - modelSetDistanceScale(1); + g_ModelDistanceScale = 1; if (fulltick) { colourTween(chr->shadecol, chr->nextcol); @@ -2633,7 +2629,7 @@ static bool chr0f024738(struct chrdata *chr) + thing->unk06c.m[1][2] * campos->f[1] + thing->unk06c.m[2][2] * campos->f[2]) + thing->unk06c.m[3][2]; - mtx00015be4(&thing->unk06c, camGetProjectionMtxF(), &thing->unk0ac); + mtx00015be4(&thing->unk06c, g_Vars.currentplayer->projectionmtx, &thing->unk0ac); thing->unk00c = true; } @@ -2741,7 +2737,7 @@ static bool chr0f024b18(struct model *model, struct modelnode *node) sp88.z = thing->bbox.zmin; } - mtx00015be4(camGetWorldToScreenMtxf(), &thing->unk02c, &thing->unk0ec); + mtx00015be4(g_Vars.currentplayer->worldtoscreenmtx, &thing->unk02c, &thing->unk0ec); mtx4TransformVec(&thing->unk0ec, &spa0, &sp70); cam0f0b4dec(&sp70, thing->unk134); mtx4TransformVec(&thing->unk0ec, &sp94, &sp70); @@ -3243,7 +3239,7 @@ void chrEmitSparks(struct chrdata *chr, struct prop *prop, s32 hitpart, struct c return; } - if (chrGetShield(chr) > 0.0f) { + if (chr->cshield > 0.0f) { sparksCreate(chrprop->rooms[0], chrprop, coord, coord2, 0, SPARKTYPE_DEFAULT); return; } @@ -4070,7 +4066,7 @@ f32 chr0f0278a4(struct chrdata *chr) result += highest; - if (chrGetShield(chr) > 0) { + if (chr->cshield > 0) { result += 10; } } else { @@ -4110,7 +4106,7 @@ void chr0f027994(struct prop *prop, struct shotdata *shotdata, bool arg2, bool a } if (spc0) { - if (chrGetShield(chr) > 0.0f) { + if (chr->cshield > 0.0f) { var8005efc0 = 10.0f / model->scale; } @@ -4128,9 +4124,9 @@ void chr0f027994(struct prop *prop, struct shotdata *shotdata, bool arg2, bool a while (spc0 > 0) { if (func0f084594(model, node, &shotdata->unk00, &shotdata->unk0c, &sp88, &sp84, &sp80)) { mtx4TransformVec(&model->matrices[sp84], &sp88.unk00, &spdc); - mtx4TransformVecInPlace(camGetProjectionMtxF(), &spdc); + mtx4TransformVecInPlace(g_Vars.currentplayer->projectionmtx, &spdc); mtx4RotateVec(&model->matrices[sp84], &sp88.unk0c, &spd0); - mtx4RotateVecInPlace(camGetProjectionMtxF(), &spd0); + mtx4RotateVecInPlace(g_Vars.currentplayer->projectionmtx, &spd0); break; } @@ -4142,8 +4138,8 @@ void chr0f027994(struct prop *prop, struct shotdata *shotdata, bool arg2, bool a if (spc0 > 0) { if (func0f06bea0(model, model->filedata->rootnode, model->filedata->rootnode, &shotdata->unk00, &shotdata->unk0c, &sp88.unk00, &sp70, &node, &spc0, &sp84, &sp80)) { - mtx4TransformVec(camGetProjectionMtxF(), &sp88.unk00, &spdc); - mtx4RotateVec(camGetProjectionMtxF(), &sp88.unk0c, &spd0); + mtx4TransformVec(g_Vars.currentplayer->projectionmtx, &sp88.unk00, &spdc); + mtx4RotateVec(g_Vars.currentplayer->projectionmtx, &sp88.unk0c, &spd0); } else { spc0 = 0; } @@ -4156,12 +4152,12 @@ void chr0f027994(struct prop *prop, struct shotdata *shotdata, bool arg2, bool a } if (spc0 > 0) { - mtx = camGetWorldToScreenMtxf(); + mtx = g_Vars.currentplayer->worldtoscreenmtx; sp68 = spdc.x * mtx->m[0][2] + spdc.y * mtx->m[1][2] + spdc.z * mtx->m[2][2] + mtx->m[3][2]; sp68 = -sp68; if (sp68 < shotdata->unk34) { - func0f061fa8(shotdata, prop, sp68, spc0, node, &sp88, sp84, sp80, model, 1, chrGetShield(chr) > 0.0f, &spdc, &spd0); + func0f061fa8(shotdata, prop, sp68, spc0, node, &sp88, sp84, sp80, model, 1, chr->cshield > 0.0f, &spdc, &spd0); } } @@ -4210,7 +4206,7 @@ void chrHit(struct shotdata *shotdata, struct hit *hit) sp98.y = shotdata->unk00.y - (hit->distance * shotdata->unk0c.y) / shotdata->unk0c.z; sp98.z = shotdata->unk00.z - hit->distance; - mtx4TransformVec(camGetProjectionMtxF(), &sp98, &hitpos); + mtx4TransformVec(g_Vars.currentplayer->projectionmtx, &sp98, &hitpos); bgunSetHitPos(&hitpos); bgunPlayPropHitSound(&shotdata->gset, hit->prop, -1); @@ -4220,7 +4216,7 @@ void chrHit(struct shotdata *shotdata, struct hit *hit) sp90[1] = hit->hitthing.unk00.y; sp90[2] = hit->hitthing.unk00.z; - shield = chrGetShield(chr); + shield = chr->cshield; func0f0341dc(chr, gsetGetDamage(&shotdata->gset), &shotdata->dir, &shotdata->gset, g_Vars.currentplayer->prop, hit->hitpart, hit->prop, hit->node, @@ -4372,11 +4368,6 @@ struct chrdata *chrFindByLiteralId(s32 chrnum) return NULL; } -struct prop *chrGetHeldProp(struct chrdata *chr, s32 hand) -{ - return chr->weapons_held[hand]; -} - struct prop *chrGetHeldUsableProp(struct chrdata *chr, s32 hand) { struct prop *prop = chr->weapons_held[hand]; @@ -4864,7 +4855,7 @@ static f32 propGetShieldThing(struct prop **propptr) struct prop *prop = *propptr; if (prop->type & (PROPTYPE_CHR | PROPTYPE_PLAYER)) { - return chrGetShield(prop->chr); + return prop->chr->cshield; } if (prop->type & (PROPTYPE_OBJ | PROPTYPE_WEAPON | PROPTYPE_DOOR)) { @@ -4934,7 +4925,7 @@ static Gfx *chrRenderShieldComponent(Gfx *gdl, struct shieldhit *hit, struct pro if (prop->type & (PROPTYPE_CHR | PROPTYPE_PLAYER)) { struct chrdata *chr = prop->chr; gap = 10.0f / chr->model->scale; - shieldamount = chrGetShield(chr); + shieldamount = chr->cshield; cloakfade = chr->cloakfadefrac; cmcount = chr->cmcount; } else { @@ -5809,35 +5800,35 @@ static Gfx *chrRenderCloak(Gfx *gdl, struct prop *chrprop, struct prop *thisprop screenpos[0] = 0.0f; } - if (screenpos[0] > viGetWidth()) { - screenpos[0] = viGetWidth(); + if (screenpos[0] > g_ViBackData->x) { + screenpos[0] = g_ViBackData->x; } if (screenpos[1] < 0.0f) { screenpos[1] = 0.0f; } - if (screenpos[1] > viGetHeight()) { - screenpos[1] = viGetHeight(); + if (screenpos[1] > g_ViBackData->y) { + screenpos[1] = g_ViBackData->y; } uls = (s32)screenpos[0] - 8; ult = (s32)screenpos[1] - 8; - if (uls < viGetViewLeft()) { - uls = viGetViewLeft(); + if (uls < g_ViBackData->viewleft) { + uls = g_ViBackData->viewleft; } - if (uls > viGetViewLeft() + viGetViewWidth() - 16) { - uls = viGetViewLeft() + viGetViewWidth() - 16; + if (uls > g_ViBackData->viewleft + g_ViBackData->viewx - 16) { + uls = g_ViBackData->viewleft + g_ViBackData->viewx - 16; } - if (ult < viGetViewTop()) { - ult = viGetViewTop(); + if (ult < g_ViBackData->viewtop) { + ult = g_ViBackData->viewtop; } - if (ult > viGetViewTop() + viGetViewHeight() - 16) { - ult = viGetViewTop() + viGetViewHeight() - 16; + if (ult > g_ViBackData->viewtop + g_ViBackData->viewy - 16) { + ult = g_ViBackData->viewtop + g_ViBackData->viewy - 16; } lrs = uls + 15; @@ -5846,8 +5837,8 @@ static Gfx *chrRenderCloak(Gfx *gdl, struct prop *chrprop, struct prop *thisprop gDPSetColorImage(gdl++, G_IM_FMT_RGBA, G_IM_SIZ_16b, 16, OS_K0_TO_PHYSICAL(var8009ccc0[index])); gDPTileSync(gdl++); - gDPLoadTextureTile(gdl++, viGetBackBuffer(), G_IM_FMT_RGBA, G_IM_SIZ_16b, - viGetWidth(), 0, uls, ult, lrs, lrt, + gDPLoadTextureTile(gdl++, g_ViBackData->fb, G_IM_FMT_RGBA, G_IM_SIZ_16b, + g_ViBackData->x, 0, uls, ult, lrs, lrt, 0, G_TX_NOMIRROR | G_TX_WRAP, G_TX_NOMIRROR | G_TX_WRAP, 4, 4, G_TX_NOLOD, G_TX_NOLOD); @@ -5885,8 +5876,8 @@ static Gfx *chrRenderCloak(Gfx *gdl, struct prop *chrprop, struct prop *thisprop gDPPipeSync(gdl++); gDPLoadSync(gdl++); gDPTileSync(gdl++); - gDPSetColorImage(gdl++, G_IM_FMT_RGBA, G_IM_SIZ_16b, viGetBufWidth(), OS_K0_TO_PHYSICAL(viGetBackBuffer())); - gDPSetScissor(gdl++, G_SC_NON_INTERLACE, 0, 0, viGetWidth(), viGetHeight()); + gDPSetColorImage(gdl++, G_IM_FMT_RGBA, G_IM_SIZ_16b, g_ViBackData->bufx, OS_K0_TO_PHYSICAL(g_ViBackData->fb)); + gDPSetScissor(gdl++, G_SC_NON_INTERLACE, 0, 0, g_ViBackData->x, g_ViBackData->y); gDPSetCycleType(gdl++, G_CYC_1CYCLE); gDPSetRenderMode(gdl++, G_RM_AA_ZB_OPA_SURF, G_RM_AA_ZB_OPA_SURF2); gDPSetCombineMode(gdl++, G_CC_MODULATEI, G_CC_MODULATEI); @@ -5901,7 +5892,7 @@ static Gfx *chrRenderCloak(Gfx *gdl, struct prop *chrprop, struct prop *thisprop static Gfx *chrRenderShield(Gfx *gdl, struct chrdata *chr, u32 alpha) { - if (chrGetShield(chr) > 0 && g_Vars.lvupdate240 > 0) { + if (chr->cshield > 0 && g_Vars.lvupdate240 > 0) { chr->cmcount++; if (chr->cmcount > 300) { @@ -5910,9 +5901,9 @@ static Gfx *chrRenderShield(Gfx *gdl, struct chrdata *chr, u32 alpha) } if ((chr->hidden2 & CHRH2FLAG_SHIELDHIT) - || (chrGetShield(chr) > 0 && chr->cmcount < 10) + || (chr->cshield > 0 && chr->cmcount < 10) || (chr->cloakfadefrac > 0 && !chr->cloakfadefinished)) { - if (chrGetShield(chr) > 0 && g_Vars.lvupdate240 > 0) { + if (chr->cshield > 0 && g_Vars.lvupdate240 > 0) { s32 numiterations = (random() % 4) + 1; s32 newcmnum = chr->cmnum2; s32 candidate; diff --git a/src/game/chraction.c b/src/game/chraction.c index 4d61aa6e7..66789f746 100644 --- a/src/game/chraction.c +++ b/src/game/chraction.c @@ -1414,12 +1414,7 @@ void func0f02e3dc(struct coord *a, struct coord *b,struct coord *c, struct coord void func0f02e4f8(struct coord *arg0, struct coord *arg1, struct coord *dst) { - struct coord sp2c; - struct coord sp20; - - cdGetEdge(&sp2c, &sp20); - - func0f02e3dc(&sp2c, &sp20, arg0, arg1, dst); + func0f02e3dc(&g_CdEdgeVtx1, &g_CdEdgeVtx2, arg0, arg1, dst); } static f32 func0f02e550(struct prop *prop, f32 arg1, f32 arg2, u32 cdtypes, f32 ymax, f32 ymin) @@ -1428,7 +1423,6 @@ static f32 func0f02e550(struct prop *prop, f32 arg1, f32 arg2, u32 cdtypes, f32 struct coord sp50; struct chrdata *chr = prop->chr; f32 result; - struct coord sp3c; f32 xdiff; f32 zdiff; @@ -1445,10 +1439,8 @@ static f32 func0f02e550(struct prop *prop, f32 arg1, f32 arg2, u32 cdtypes, f32 if (cdExamCylMove03(&prop->pos, prop->rooms, &sp50, cdtypes, 1, ymax - prop->pos.y, ymin - prop->pos.y) != CDRESULT_COLLISION) { result = arg2; } else { - cdGetPos(&sp3c); - - xdiff = sp3c.x - prop->pos.x; - zdiff = sp3c.z - prop->pos.z; + xdiff = g_CdObstaclePos.x - prop->pos.x; + zdiff = g_CdObstaclePos.z - prop->pos.z; result = sqrtf(xdiff * xdiff + zdiff * zdiff); } @@ -3744,11 +3736,6 @@ static void chrChoke(struct chrdata *chr, s32 choketype) } } -f32 chrGetShield(struct chrdata *chr) -{ - return chr->cshield; -} - void chrSetShield(struct chrdata *chr, f32 amount) { if (amount < 0) { @@ -3776,9 +3763,9 @@ void chrSetShield(struct chrdata *chr, f32 amount) bool func0f034080(struct chrdata *chr, struct modelnode *node, struct prop *prop, struct model *model, s32 side, s16 *arg5) { - if (chrGetShield(chr) > 0) { + if (chr->cshield > 0) { if (node && (node->type & 0xff) == MODELNODETYPE_BBOX) { - shieldhitCreate(chr->prop, chrGetShield(chr), prop, node, model, side, arg5); + shieldhitCreate(chr->prop, chr->cshield, prop, node, model, side, arg5); } return true; @@ -3840,7 +3827,7 @@ void chrDamageByImpact(struct chrdata *chr, f32 damage, struct coord *vector, st struct model *model = NULL; s32 side = 0; - if (chrGetShield(chr) >= 0 && chr->model) { + if (chr->cshield >= 0 && chr->model) { chrCalculateShieldHit(chr, &chr->prop->pos, vector, &node, &hitpart, &model, &side); } @@ -3963,7 +3950,7 @@ static void chrDamage(struct chrdata *chr, f32 damage, struct coord *vector, str // Don't damage if in CI training outside of training session if (chr->prop == g_Vars.currentplayer->prop && g_Vars.currentplayer->training == false - && mainGetStageNum() == STAGE_CITRAINING) { + && g_StageNum == STAGE_CITRAINING) { return; } @@ -4185,7 +4172,7 @@ static void chrDamage(struct chrdata *chr, f32 damage, struct coord *vector, str // Handle shield damage if (damageshield) { - shield = chrGetShield(chr); + shield = chr->cshield; if (chr->aibot && chr->aibot->config->type == BOTTYPE_TURTLE) { armourscale = 4; @@ -4201,7 +4188,7 @@ static void chrDamage(struct chrdata *chr, f32 damage, struct coord *vector, str if (prop2 && node && chr->model) { func0f034080(chr, node, prop2, model, side, arg11); } else { - shieldhitCreate(chr->prop, chrGetShield(chr), NULL, NULL, NULL, 0, 0); + shieldhitCreate(chr->prop, chr->cshield, NULL, NULL, NULL, 0, 0); } if (g_Vars.normmplayerisrunning && (g_MpSetup.options & MPOPTION_ONEHITKILLS)) { @@ -4440,7 +4427,7 @@ static void chrDamage(struct chrdata *chr, f32 damage, struct coord *vector, str chr->blurnumtimesdied++; } - if (!lvIsPaused() && canchoke) { + if (!g_LvIsPaused && canchoke) { chrChoke(chr, choketype); } @@ -6253,7 +6240,7 @@ bool chrCheckTargetInSight(struct chrdata *chr) || (sqdistance < 40000.0f && (angle < 1.9195564985275f || angle > 4.3626284599304f))) { result = false; - if (sqdistance < env0f1657e4()) { + if (sqdistance < var80081050 * var80081050) { f32 tmp; s32 iVar8 = (sqrtf(sqdistance) * 0.0018749999580905f); s32 tmp2; @@ -7468,7 +7455,7 @@ static void chrAlertOthersOfInjury(struct chrdata *chr, bool dying) { s32 index = 0; s32 numinrange = 0; - s32 numchrs = chrsGetNumSlots(); + s32 numchrs = g_NumChrSlots; if (g_Vars.antiplayernum >= 0 && chr->prop == g_Vars.anti->prop) { return; @@ -8724,13 +8711,13 @@ bool chrGetGunPos(struct chrdata *chr, s32 handnum, struct coord *gunpos) *gunpos = rodata->pos; - mtx00015be4(camGetProjectionMtxF(), spac, &sp6c); + mtx00015be4(g_Vars.currentplayer->projectionmtx, spac, &sp6c); mtx4TransformVecInPlace(&sp6c, gunpos); result = true; } else if ((part1 = modelGetPart(model->filedata, MODELPART_0001))) { sp64 = model0001a5cc(model, part1, 0); - mtx00015be4(camGetProjectionMtxF(), sp64, &sp24); + mtx00015be4(g_Vars.currentplayer->projectionmtx, sp64, &sp24); gunpos->x = sp24.m[3][0]; gunpos->y = sp24.m[3][1]; @@ -8782,7 +8769,7 @@ void chrCalculateShieldHit(struct chrdata *chr, struct coord *pos, struct coord f32 sides[6]; u32 stack3; - if (prop->type != PROPTYPE_PLAYER || g_Vars.normmplayerisrunning || chrGetShield(chr) > 0) { + if (prop->type != PROPTYPE_PLAYER || g_Vars.normmplayerisrunning || chr->cshield > 0) { if (prop->flags & (PROPFLAG_ONTHISSCREENTHISTICK | PROPFLAG_ONANYSCREENTHISTICK | PROPFLAG_ONANYSCREENPREVTICK)) { bestnode = NULL; bestvolume = MAXFLOAT; @@ -8792,7 +8779,7 @@ void chrCalculateShieldHit(struct chrdata *chr, struct coord *pos, struct coord mtx4TransformVec(worldtoscreenmtx, pos, &sp124); mtx4RotateVec(worldtoscreenmtx, vector, &sp118); - isdifferentmtx = (camGetWorldToScreenMtxf() != worldtoscreenmtx); + isdifferentmtx = (g_Vars.currentplayer->worldtoscreenmtx != worldtoscreenmtx); node = chr->model->filedata->rootnode; while (node) { @@ -9148,8 +9135,8 @@ static void chrTickShoot(struct chrdata *chr, s32 handnum) if (cdExamLos08(&gunpos, gunrooms, &hitpos, cdtypes, GEOFLAG_BLOCK_SHOOT) == CDRESULT_COLLISION) { hitsomething = true; - cdGetPos(&hitpos); - hitprop = cdGetObstacleProp(); + hitpos = g_CdObstaclePos; + hitprop = g_CdObstacleProp; } chrSetPerimEnabled(chr, true); @@ -9417,7 +9404,7 @@ static void chrTickShoot(struct chrdata *chr, s32 handnum) bgunPlayPropHitSound(&gset, targetprop, -1); - if (targetchr->model && chrGetShield(targetchr) > 0) { + if (targetchr->model && targetchr->cshield > 0) { chrCalculateShieldHit(targetchr, &hitpos, &vector, &node, &hitpart, &model, &side); } @@ -9448,7 +9435,7 @@ static void chrTickShoot(struct chrdata *chr, s32 handnum) bgunPlayPropHitSound(&gset, hitprop, -1); - if (hitchr->model && chrGetShield(hitchr) > 0) { + if (hitchr->model && hitchr->cshield > 0) { chrCalculateShieldHit(hitchr, &hitpos, &vector, &node, &hitpart, &model, &side); } @@ -9917,7 +9904,7 @@ static void robotAttack(struct chrdata *chr) chr->unk348[0]->unk08 = -1; chr->unk348[0]->unk0c = 0.85f; - if ((lvGetDifficulty() == DIFF_PA) * 0.2f) { + if ((g_Difficulty == DIFF_PA) * 0.2f) { chr->unk348[0]->unk10 = 2.0f; } else { chr->unk348[0]->unk10 = 1.0f; @@ -10861,7 +10848,8 @@ static bool chrNavCanSeeNextPos(struct chrdata *chr, struct coord *chrpos, s16 * if (cdExamCylMove07(chrpos, chrrooms, &sp6c, sp50, cdtypes, 1, ymax - prop->pos.y, ymin - prop->pos.y) == CDRESULT_COLLISION || cdExamCylMove03(&sp6c, sp50, &sp60, cdtypes, 1, ymax - prop->pos.y, ymin - prop->pos.y) == CDRESULT_COLLISION) { spbc = true; - cdGetEdge(&spac, &spa0); + spac = g_CdEdgeVtx1; + spa0 = g_CdEdgeVtx2; func0f044b68(&spac, &spa0, &spd4); } @@ -10876,7 +10864,8 @@ static bool chrNavCanSeeNextPos(struct chrdata *chr, struct coord *chrpos, s16 * if (cdExamCylMove07(chrpos, chrrooms, &sp6c, sp50, cdtypes, 1, ymax - prop->pos.y, ymin - prop->pos.y) == CDRESULT_COLLISION || cdExamCylMove03(&sp6c, chrrooms, &sp60, cdtypes, 1, ymax - prop->pos.y, ymin - prop->pos.y) == CDRESULT_COLLISION) { spb8 = true; - cdGetEdge(&sp94, &sp88); + sp94 = g_CdEdgeVtx1; + sp88 = g_CdEdgeVtx2; func0f044b68(&sp94, &sp88, &spd4); } @@ -10885,21 +10874,19 @@ static bool chrNavCanSeeNextPos(struct chrdata *chr, struct coord *chrpos, s16 * func0f044b68(&spa0, &sp88, &spd4); *leftpos = spac; - *rightpos = sp88; } else if (spbc) { *leftpos = spac; - *rightpos = spa0; } else if (spb8) { *leftpos = sp94; - *rightpos = sp88; } else if (cdExamCylMove07(chrpos, chrrooms, aimpos, sp40, cdtypes, 1, ymax - prop->pos.y, ymin - prop->pos.y) != CDRESULT_COLLISION && (!arg9 || cdExamCylMove01(chrpos, aimpos, chrradius, sp40, cdtypes, CHECKVERTICAL_YES, ymax - prop->pos.y, ymin - prop->pos.y) != CDRESULT_COLLISION)) { result = true; } else { - cdGetEdge(leftpos, rightpos); + *leftpos = g_CdEdgeVtx1; + *rightpos = g_CdEdgeVtx2; func0f044b68(leftpos, rightpos, &spd4); } @@ -10978,9 +10965,10 @@ static bool chrNavCheckForObstacle(struct chrdata *chr, struct coord *chrpos, s1 if (cdExamCylMove07(chrpos, chrrooms, &sp6c, sp50, cdtypes, 1, ymax - prop->pos.y, ymin - prop->pos.y) == CDRESULT_COLLISION || cdExamCylMove03(&sp6c, sp50, &sp60, cdtypes, 1, ymax - prop->pos.y, ymin - prop->pos.y) == CDRESULT_COLLISION) { spbc = true; - cdGetEdge(&spac, &spa0); + spac = g_CdEdgeVtx1; + spa0 = g_CdEdgeVtx2; func0f044b68(&spac, &spa0, &spd4); - value1 = cd00024e40(); + value1 = g_Cd8009a8f0; } sp6c.x = chrpos->x - spcc; @@ -10994,34 +10982,32 @@ static bool chrNavCheckForObstacle(struct chrdata *chr, struct coord *chrpos, s1 if (cdExamCylMove07(chrpos, chrrooms, &sp6c, sp50, cdtypes, 1, ymax - prop->pos.y, ymin - prop->pos.y) == CDRESULT_COLLISION || cdExamCylMove03(&sp6c, chrrooms, &sp60, cdtypes, 1, ymax - prop->pos.y, ymin - prop->pos.y) == CDRESULT_COLLISION) { spb8 = true; - cdGetEdge(&sp94, &sp88); + sp94 = g_CdEdgeVtx1; + sp88 = g_CdEdgeVtx2; func0f044b68(&sp94, &sp88, &spd4); - value2 = cd00024e40(); + value2 = g_Cd8009a8f0; } if (spbc && spb8) { if (value1 < value2) { *leftpos = spac; - *rightpos = spa0; } else { *leftpos = sp94; - *rightpos = sp88; } } else if (spbc) { *leftpos = spac; - *rightpos = spa0; } else if (spb8) { *leftpos = sp94; - *rightpos = sp88; } else if (cdExamCylMove07(chrpos, chrrooms, aimpos, sp40, cdtypes, 1, ymax - prop->pos.y, ymin - prop->pos.y) != CDRESULT_COLLISION && (!hasobstacle || cdExamCylMove01(chrpos, aimpos, chrradius, sp40, cdtypes, CHECKVERTICAL_YES, ymax - prop->pos.y, ymin - prop->pos.y) != CDRESULT_COLLISION)) { result = true; } else { - cdGetEdge(leftpos, rightpos); + *leftpos = g_CdEdgeVtx1; + *rightpos = g_CdEdgeVtx2; func0f044b68(leftpos, rightpos, &spd4); } @@ -11123,7 +11109,7 @@ static struct prop *chrOpenDoor(struct chrdata *chr, struct coord *rangepos) if (cdExamCylMove03(&chr->prop->pos, chr->prop->rooms, rangepos, CDTYPE_BG | CDTYPE_CLOSEDDOORS | CDTYPE_AJARDOORS, 1, 0, 0) == CDRESULT_COLLISION) { - doorprop = cdGetObstacleProp(); + doorprop = g_CdObstacleProp; } if (doorprop) { @@ -12173,7 +12159,7 @@ void chraTick(struct chrdata *chr) // Consider setting darkroomlist if (chr->aidarkroomlist != NULL - && roomGetBrightness(chr->prop->rooms[0]) < 25 + && g_Rooms[chr->prop->rooms[0]].brightness < 25 && chr->ailist != chr->aidarkroomlist) { chr->darkroomthing = true; } @@ -12323,7 +12309,7 @@ void chraTickBg(void) return; } - numchrs = chrsGetNumSlots(); + numchrs = g_NumChrSlots; // Calculate alive/dead counters. For *spawned* chrs that have died, // allow 10 corpses and start fading if there's more. @@ -12820,7 +12806,7 @@ void chrsClearRefsToPlayer(s32 playernum) playerpropnum = g_Vars.coop->prop - g_Vars.props; } - for (i = 0; i < chrsGetNumSlots(); i++) { + for (i = 0; i < g_NumChrSlots; i++) { if (g_ChrSlots[i].p1p2 == playernum) { g_ChrSlots[i].p1p2 = otherplayernum; } @@ -13109,11 +13095,6 @@ void chrRestartTimer(struct chrdata *chr) chr->hidden |= CHRHFLAG_TIMER_RUNNING; } -s32 chrGetTimer(struct chrdata *chr) -{ - return chr->timer60; -} - bool chrCanSeeTargetWithExtraCheck(struct chrdata *chr) { struct prop *target = chrGetTargetProp(chr); @@ -13140,7 +13121,7 @@ bool chrCanSeeTargetWithExtraCheck(struct chrdata *chr) bgun0f0a0c08(&sp68, &sp56); modelGetRootPosition(model, &sp44); - mtx4TransformVecInPlace(camGetWorldToScreenMtxf(), &sp44); + mtx4TransformVecInPlace(g_Vars.currentplayer->worldtoscreenmtx, &sp44); if (func0f06b39c(&sp68, &sp56, &sp44, somefloat)) { return true; @@ -13160,11 +13141,6 @@ bool chrResetNearMiss(struct chrdata *chr) return has_flag; } -s32 chrGetNumArghs(struct chrdata *chr) -{ - return chr->numarghs; -} - bool chrSawInjury(struct chrdata *chr, u8 arg1) { bool saw_injury = chr->chrseeshot >= 0; @@ -14068,7 +14044,7 @@ bool chrRunFromPos(struct chrdata *chr, u32 goposflags, f32 rundist, struct coor chrSetPerimEnabled(chr, false); if (cdExamLos08(&chr->prop->pos, chr->prop->rooms, &delta, CDTYPE_ALL, GEOFLAG_WALL) == CDRESULT_COLLISION) { - cdGetPos(&delta); + delta = g_CdObstaclePos; } chrSetPerimEnabled(chr, true); @@ -14202,10 +14178,8 @@ bool chr0f04c874(struct chrdata *chr, u32 angle360, struct coord *pos, u8 arg3, f32 zdiff; f32 tmp; - cdGetPos(pos); - - xdiff = pos->x - chrpos.x; - zdiff = pos->z - chrpos.z; + xdiff = g_CdObstaclePos.x - chrpos.x; + zdiff = g_CdObstaclePos.z - chrpos.z; tmp = sqrtf(xdiff * xdiff + zdiff * zdiff); scale = (tmp - 50.0f) / tmp; @@ -14274,7 +14248,7 @@ bool chr0f04c874(struct chrdata *chr, u32 angle360, struct coord *pos, u8 arg3, */ void rebuildTeams(void) { - s32 numchrs = chrsGetNumSlots(); + s32 numchrs = g_NumChrSlots; s16 index = 7; s32 team; s32 i; @@ -14315,7 +14289,7 @@ void rebuildTeams(void) */ void rebuildSquadrons(void) { - s32 numchrs = chrsGetNumSlots(); + s32 numchrs = g_NumChrSlots; s16 index = 15; s32 squadron; s32 i; diff --git a/src/game/chraicommands.c b/src/game/chraicommands.c index 7015445ff..08313d893 100644 --- a/src/game/chraicommands.c +++ b/src/game/chraicommands.c @@ -1116,7 +1116,7 @@ f32 aiGetChrShield(s32 chrref) { struct chrdata *chr = chrFindById(g_Vars.chrdata, chrref); - return chrGetShield(chr); + return chr->cshield; } bool aiIfRoomIsOnScreen(s32 padnum) @@ -1186,7 +1186,7 @@ s32 aiGetNumPlayers(void) s32 aiGetNumTimesShot(void) { - return chrGetNumArghs(g_Vars.chrdata); + return g_Vars.chrdata->numarghs; } s32 aiGetObjDamage(s32 tagnum) @@ -1208,7 +1208,7 @@ s32 aiGetSoundTimer(void) s32 aiGetTimer(void) { if (g_Vars.chrdata) { - return chrGetTimer(g_Vars.chrdata); + return g_Vars.chrdata->timer60; } if (g_Vars.hovercar) { @@ -1313,7 +1313,7 @@ void aiHideCutsceneChrs(void) { s32 i; - for (i = chrsGetNumSlots() - 1; i >= 0; i--) { + for (i = g_NumChrSlots - 1; i >= 0; i--) { if (g_ChrSlots[i].chrnum >= 0 && g_ChrSlots[i].prop && (g_ChrSlots[i].chrflags & (CHRCFLAG_UNPLAYABLE | CHRCFLAG_HIDDEN)) == 0) { g_ChrSlots[i].hidden2 |= CHRH2FLAG_HIDDENFORCUTSCENE; @@ -1950,16 +1950,16 @@ bool aiIfNeverBeenOnScreen(void) bool aiIfObjectiveComplete(s32 index) { - return index < objectiveGetCount() + return index < (g_ObjectiveLastIndex + 1) && g_ObjectiveStatuses[index] == OBJECTIVE_COMPLETE - && objectiveGetDifficultyBits(index) & (1 << lvGetDifficulty()); + && objectiveGetDifficultyBits(index) & (1 << g_Difficulty); } bool aiIfObjectiveFailed(s32 index) { - return index < objectiveGetCount() + return index < (g_ObjectiveLastIndex + 1) && g_ObjectiveStatuses[index] == OBJECTIVE_FAILED - && objectiveGetDifficultyBits(index) & (1 << lvGetDifficulty()); + && objectiveGetDifficultyBits(index) & (1 << g_Difficulty); } bool aiIfObjectDistanceToPadLessThan(s32 tagnum, s32 padnum, f32 distance) @@ -2090,7 +2090,7 @@ bool aiIfSafety2LessThan(s32 limit) score = 6; numnearby = 0; - if (chrGetNumArghs(g_Vars.chrdata) > 0) { + if (g_Vars.chrdata->numarghs > 0) { score -= 2; } @@ -3842,7 +3842,7 @@ void aiShowCutsceneChrs(void) { s32 i; - for (i = chrsGetNumSlots() - 1; i >= 0; i--) { + for (i = g_NumChrSlots - 1; i >= 0; i--) { if (g_ChrSlots[i].chrnum >= 0 && g_ChrSlots[i].prop && (g_ChrSlots[i].hidden2 & CHRH2FLAG_HIDDENFORCUTSCENE)) { g_ChrSlots[i].hidden2 &= ~CHRH2FLAG_HIDDENFORCUTSCENE; g_ChrSlots[i].chrflags &= ~CHRCFLAG_HIDDEN; @@ -4106,7 +4106,7 @@ struct prop *aiTryEquipWeapon(s32 model, s32 weaponnum, u32 flags) prop = chrGiveWeapon(g_Vars.chrdata, MODEL_CHRDYROCKET, WEAPON_ROCKETLAUNCHER, flags); break; case WEAPON_K7AVENGER: - if (g_Vars.stagenum == STAGE_INVESTIGATION && lvGetDifficulty() == DIFF_PA) { + if (g_Vars.stagenum == STAGE_INVESTIGATION && g_Difficulty == DIFF_PA) { prop = chrGiveWeapon(g_Vars.chrdata, model, weaponnum, flags); } else { prop = chrGiveWeapon(g_Vars.chrdata, MODEL_CHRDYROCKET, WEAPON_ROCKETLAUNCHER, flags); diff --git a/src/game/credits.c b/src/game/credits.c index 02f650e38..69ee5e62e 100644 --- a/src/game/credits.c +++ b/src/game/credits.c @@ -539,7 +539,7 @@ static Gfx *creditsFillFramebuffer(Gfx *gdl, u32 colour) gdl = textSetPrimColour(gdl, colour); - gDPFillRectangle(gdl++, 0, 0, viGetWidth(), viGetHeight()); + gDPFillRectangle(gdl++, 0, 0, g_ViBackData->x, g_ViBackData->y); gdl = text0f153838(gdl); @@ -1537,7 +1537,7 @@ Gfx *creditsDraw(Gfx *gdl) gdl = vi0000b1d0(gdl); gdl = creditsFillFramebuffer(gdl, 0x000000ff); - gDPSetScissorFrac(gdl++, G_SC_NON_INTERLACE, 0, 120, viGetWidth() * 4.0f, (viGetHeight() - 30) * 4.0f); + gDPSetScissorFrac(gdl++, G_SC_NON_INTERLACE, 0, 120, g_ViBackData->x * 4.0f, (g_ViBackData->y - 30) * 4.0f); creditsTick(); diff --git a/src/game/dlights.c b/src/game/dlights.c index bd736ba73..1f84d6567 100644 --- a/src/game/dlights.c +++ b/src/game/dlights.c @@ -215,11 +215,6 @@ u8 func0f000b24(s32 roomnum) return value; } -u8 roomGetBrightness(s32 room) -{ - return g_Rooms[room].brightness & 0xff; -} - s32 func0f000c54(s32 roomnum) { if (g_Rooms[roomnum].unk52 > 255) { @@ -351,8 +346,8 @@ Gfx *lightsSetForRoom(Gfx *gdl, s16 roomnum) gSPSetLights1(gdl++, (*lights)); - gSPLookAtX(gdl++, &camGetLookAt()->l[0]); - gSPLookAtY(gdl++, &camGetLookAt()->l[1]); + gSPLookAtX(gdl++, &g_Vars.currentplayer->lookat->l[0]); + gSPLookAtY(gdl++, &g_Vars.currentplayer->lookat->l[1]); return gdl; } @@ -361,8 +356,8 @@ Gfx *lightsSetDefault(Gfx *gdl) { gSPSetLights1(gdl++, var80061460); - gSPLookAtX(gdl++, &camGetLookAt()->l[0]); - gSPLookAtY(gdl++, &camGetLookAt()->l[1]); + gSPLookAtX(gdl++, &g_Vars.currentplayer->lookat->l[0]); + gSPLookAtY(gdl++, &g_Vars.currentplayer->lookat->l[1]); return gdl; } @@ -1916,7 +1911,7 @@ static void func0f005bb0(void) g_Vars.currentplayer->usinggoggles = USINGDEVICE(DEVICE_NIGHTVISION) || USINGDEVICE(DEVICE_IRSCANNER); - if (USINGDEVICE(DEVICE_NIGHTVISION) && !lvIsPaused()) { + if (USINGDEVICE(DEVICE_NIGHTVISION) && !g_LvIsPaused) { // Play the goggle's hum sound if (g_Vars.currentplayer->nvhum == NULL) { sndStart(var80095200, SFX_0505, &g_Vars.currentplayer->nvhum, -1, -1, -1.0f, -1, -1); diff --git a/src/game/dyntex.c b/src/game/dyntex.c index 808eb6c2e..bb31ad37b 100644 --- a/src/game/dyntex.c +++ b/src/game/dyntex.c @@ -239,12 +239,12 @@ void dyntexTickRoom(s32 roomnum, struct gfxvtx *vertices) break; case DYNTEXTYPE_TELEPORTAL: // Deep Sea - teleports enabled and not SA disabled - if (chrHasStageFlag(0, 0x00000100) && !chrHasStageFlag(0, 0x00010000)) { + if ((g_StageFlags & 0x00010100) == 0x00000100) { dyntexUpdateLinear(vertices, type); } break; case DYNTEXTYPE_POWERRING: - if (chrHasStageFlag(0, 0x00010000)) { + if (g_StageFlags & 0x00010000) { // Attack Ship engines are destroyed dyntexUpdateReset(vertices, type); } else { @@ -253,7 +253,7 @@ void dyntexTickRoom(s32 roomnum, struct gfxvtx *vertices) } break; case DYNTEXTYPE_POWERJUICE: - if (!chrHasStageFlag(0, 0x00010000)) { + if ((g_StageFlags & 0x00010000) == 0) { // Attack Ship engines are healthy dyntexUpdateLinear(vertices, type); } @@ -393,14 +393,4 @@ void dyntexReset(void) size3 = ALIGN64(g_DyntexRoomsMax * sizeof(struct dyntexroom)); g_DyntexRooms = mempAlloc(size3, MEMPOOL_STAGE); - - if (g_DyntexVerticesMax); - if (g_DyntexTypesMax); - if (size1); -} - - -bool dyntexHasRoom(void) -{ - return g_DyntexCurRoom >= 0; } diff --git a/src/game/endscreen.c b/src/game/endscreen.c index 8fa6348a2..329021e4c 100644 --- a/src/game/endscreen.c +++ b/src/game/endscreen.c @@ -414,16 +414,16 @@ static struct menudialogdef *endscreenAdvance(void) static void endscreen0f10d770(void) { func0f0f8bb4(&g_Menus[0].unk840, bgunCalculateGunMemCapacity() - menugfxGetParticleArraySize(), 0); - g_Menus[0].unk840.unk004 = bgunGetGunMem() + menugfxGetParticleArraySize(); + g_Menus[0].unk840.unk004 = g_Vars.currentplayer->gunctrl.gunmem + menugfxGetParticleArraySize(); func0f0f8bb4(&g_Menus[1].unk840, bgunCalculateGunMemCapacity() - menugfxGetParticleArraySize(), 0); - g_Menus[1].unk840.unk004 = bgunGetGunMem() + menugfxGetParticleArraySize(); + g_Menus[1].unk840.unk004 = g_Vars.currentplayer->gunctrl.gunmem + menugfxGetParticleArraySize(); func0f0f8bb4(&g_Menus[2].unk840, bgunCalculateGunMemCapacity() - menugfxGetParticleArraySize(), 0); - g_Menus[2].unk840.unk004 = bgunGetGunMem() + menugfxGetParticleArraySize(); + g_Menus[2].unk840.unk004 = g_Vars.currentplayer->gunctrl.gunmem + menugfxGetParticleArraySize(); func0f0f8bb4(&g_Menus[3].unk840, bgunCalculateGunMemCapacity() - menugfxGetParticleArraySize(), 0); - g_Menus[3].unk840.unk004 = bgunGetGunMem() + menugfxGetParticleArraySize(); + g_Menus[3].unk840.unk004 = g_Vars.currentplayer->gunctrl.gunmem + menugfxGetParticleArraySize(); } static s32 endscreenHandleReplayLastLevel(s32 operation, struct menuitem *item, union handlerdata *data) @@ -1463,14 +1463,14 @@ void endscreenPushCoop(void) || g_Vars.coop->aborted || !objectiveIsAllComplete()) { // Failed or aborted - if (optionsGetScreenSplit() == SCREENSPLIT_VERTICAL) { + if (g_ScreenSplit == SCREENSPLIT_VERTICAL) { menuPushRootDialog(&g_2PMissionEndscreenFailedVMenuDialog, MENUROOT_MPENDSCREEN); } else { menuPushRootDialog(&g_2PMissionEndscreenFailedHMenuDialog, MENUROOT_MPENDSCREEN); } } else { // Completed - if (optionsGetScreenSplit() == SCREENSPLIT_VERTICAL) { + if (g_ScreenSplit == SCREENSPLIT_VERTICAL) { menuPushRootDialog(&g_2PMissionEndscreenCompletedVMenuDialog, MENUROOT_MPENDSCREEN); } else { menuPushRootDialog(&g_2PMissionEndscreenCompletedHMenuDialog, MENUROOT_MPENDSCREEN); @@ -1532,14 +1532,14 @@ void endscreenPushAnti(void) if (g_Vars.currentplayer == g_Vars.bond) { if (!g_Vars.anti->aborted && (g_Vars.bond->isdead || g_Vars.bond->aborted || !objectiveIsAllComplete())) { // Bond - failed or aborted - if (optionsGetScreenSplit() == SCREENSPLIT_VERTICAL) { + if (g_ScreenSplit == SCREENSPLIT_VERTICAL) { menuPushRootDialog(&g_2PMissionEndscreenFailedVMenuDialog, MENUROOT_MPENDSCREEN); } else { menuPushRootDialog(&g_2PMissionEndscreenFailedHMenuDialog, MENUROOT_MPENDSCREEN); } } else { // Bond - completed - if (optionsGetScreenSplit() == SCREENSPLIT_VERTICAL) { + if (g_ScreenSplit == SCREENSPLIT_VERTICAL) { menuPushRootDialog(&g_2PMissionEndscreenCompletedVMenuDialog, MENUROOT_MPENDSCREEN); } else { menuPushRootDialog(&g_2PMissionEndscreenCompletedHMenuDialog, MENUROOT_MPENDSCREEN); @@ -1550,14 +1550,14 @@ void endscreenPushAnti(void) } else { if (!g_Vars.anti->aborted && (g_Vars.bond->isdead || g_Vars.bond->aborted || !objectiveIsAllComplete())) { // Anti - completed - if (optionsGetScreenSplit() == SCREENSPLIT_VERTICAL) { + if (g_ScreenSplit == SCREENSPLIT_VERTICAL) { menuPushRootDialog(&g_2PMissionEndscreenCompletedVMenuDialog, MENUROOT_MPENDSCREEN); } else { menuPushRootDialog(&g_2PMissionEndscreenCompletedHMenuDialog, MENUROOT_MPENDSCREEN); } } else { // Anti - failed or aborted - if (optionsGetScreenSplit() == SCREENSPLIT_VERTICAL) { + if (g_ScreenSplit == SCREENSPLIT_VERTICAL) { menuPushRootDialog(&g_2PMissionEndscreenFailedVMenuDialog, MENUROOT_MPENDSCREEN); } else { menuPushRootDialog(&g_2PMissionEndscreenFailedHMenuDialog, MENUROOT_MPENDSCREEN); diff --git a/src/game/env.c b/src/game/env.c index e33da1c0a..6691f0b1d 100644 --- a/src/game/env.c +++ b/src/game/env.c @@ -113,16 +113,6 @@ struct envtype2 g_EnvironmentsType2[] = { { 0 }, }; -struct environment *envGetCurrent(void) -{ - return &g_Env; -} - -f32 env0f1657e4(void) -{ - return var80081050 * var80081050; -} - void env0f1657f8(void) { struct zrange zrange; @@ -138,7 +128,7 @@ void env0f1657f8(void) viGetZRange(&zrange); - scale = currentPlayerGetScaleBg2Gfx(); + scale = g_Vars.currentplayerstats->scale_bg2gfx; zrange.near /= scale; zrange.far /= scale; @@ -196,12 +186,12 @@ static void envApplyType1(struct envtype1 *env) g_Env.unk40 = env->unk28; if (!env->unk06) { - var800a65e8 = NULL; + g_Env800a65e8 = NULL; } else { var800a65f0.x = env->unk06; var800a65f0.y = env->unk08; var800a65f0.z = env->unk0a; - var800a65e8 = &var800a65f0; + g_Env800a65e8 = &var800a65f0; } env0f1657f8(); @@ -241,12 +231,12 @@ static void envApplyType2(struct envtype2 *env) g_Env.unk40 = env->unk30; if (!env->unk08) { - var800a65e8 = NULL; + g_Env800a65e8 = NULL; } else { var800a65f0.x = env->unk08; var800a65f0.y = env->unk0a; var800a65f0.z = env->unk0c; - var800a65e8 = &var800a65f0; + g_Env800a65e8 = &var800a65f0; } g_FogEnabled = false; @@ -347,7 +337,7 @@ bool env0f1666f8(struct coord *pos, f32 arg1) return true; } - mtx = camGetWorldToScreenMtxf(); + mtx = g_Vars.currentplayer->worldtoscreenmtx; sp24.x = pos->x - campos->x; sp24.y = pos->y - campos->y; @@ -362,11 +352,6 @@ bool env0f1666f8(struct coord *pos, f32 arg1) return true; } -struct coord *env0f1667e8(void) -{ - return var800a65e8; -} - s32 env0f1667f4(struct prop *prop, f32 arg1[4]) { if (!g_FogEnabled) { diff --git a/src/game/explosions.c b/src/game/explosions.c index 71b8b0163..a7bbb3f5f 100644 --- a/src/game/explosions.c +++ b/src/game/explosions.c @@ -216,7 +216,7 @@ bool explosionCreate(struct prop *sourceprop, struct coord *exppos, s16 *exproom // Bullet holes: only crate the flame (explosion) if within 4 metres if (type == EXPLOSIONTYPE_BULLETHOLE) { - f32 lodscale = camGetLodScaleZ(); + f32 lodscale = g_Vars.currentplayer->c_lodscalez; struct coord *campos = &g_Vars.currentplayer->cam_pos; f32 xdist = exppos->x - campos->x; f32 ydist = exppos->y - campos->y; @@ -1213,7 +1213,7 @@ u32 explosionTickPlayer(struct prop *prop) } { - Mtxf *matrix = camGetWorldToScreenMtxf(); + Mtxf *matrix = g_Vars.currentplayer->worldtoscreenmtx; prop->z = -(matrix->m[0][2] * prop->pos.x + matrix->m[1][2] * prop->pos.y + matrix->m[2][2] * prop->pos.z + matrix->m[3][2]); @@ -1265,7 +1265,7 @@ Gfx *explosionRender(struct prop *prop, Gfx *gdl, bool xlupass) } gSPClearGeometryMode(gdl++, G_CULL_BOTH | G_FOG); - gSPMatrix(gdl++, osVirtualToPhysical(camGetOrthogonalMtxL()), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_PROJECTION); + gSPMatrix(gdl++, osVirtualToPhysical(g_Vars.currentplayer->orthomtxl), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_PROJECTION); gdl = roomApplyMtx(gdl, roomnum); @@ -1331,7 +1331,7 @@ Gfx *explosionRender(struct prop *prop, Gfx *gdl, bool xlupass) } } - gSPMatrix(gdl++, osVirtualToPhysical(camGetPerspectiveMtxL()), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_PROJECTION); + gSPMatrix(gdl++, osVirtualToPhysical(g_Vars.currentplayer->perspmtxl), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_PROJECTION); #if PAL tmp = (g_ExplosionTypes[exp->type].flarespeed * 15.0f) * 0.83333331346512f; @@ -1352,7 +1352,7 @@ Gfx *explosionRender(struct prop *prop, Gfx *gdl, bool xlupass) static Gfx *explosionRenderPart(struct explosion *exp, struct explosionpart *part, Gfx *gdl, struct coord *coord, s32 arg4) { struct gfxvtx *vertices = gfxAllocateVertices(4); - Mtxf *mtx = camGetProjectionMtxF(); + Mtxf *mtx = g_Vars.currentplayer->projectionmtx; struct coord spbc; struct coord spb0; struct coord spa4; diff --git a/src/game/filemgr.c b/src/game/filemgr.c index 7febaf4dd..07499f9d8 100644 --- a/src/game/filemgr.c +++ b/src/game/filemgr.c @@ -1578,7 +1578,7 @@ static s32 filemgrFileToCopyOrDeleteListMenuHandler(s32 operation, struct menuit if (file) { filemgrGetSelectName(text, file, g_Menus[g_MpPlayerNum].fm.filetypeplusone - 1); gdl = textRenderProjected(gdl, &x, &y, text, g_CharsHandelGothicSm, g_FontHandelGothicSm, - colour, viGetWidth(), viGetHeight(), 0, 1); + colour, g_ViBackData->x, g_ViBackData->y, 0, 1); y = renderdata->y + 12; x = renderdata->x + 2; } @@ -1745,7 +1745,7 @@ static s32 pakGameNoteListMenuHandler(s32 operation, struct menuitem *item, unio x = renderdata->x + 4; y = renderdata->y + 1; gdl = textRenderProjected(gdl, &x, &y, generalbuffer, g_CharsHandelGothicSm, g_FontHandelGothicSm, - renderdata->colour, viGetWidth(), viGetHeight(), 0, 1); + renderdata->colour, g_ViBackData->x, g_ViBackData->y, 0, 1); // Prepare buffers for remaining text if (g_EditingPak->notesinuse[data->list.unk04] == 1) { @@ -1767,13 +1767,13 @@ static s32 pakGameNoteListMenuHandler(s32 operation, struct menuitem *item, unio x = renderdata->x + 20; y = renderdata->y + 1; gdl = textRenderProjected(gdl, &x, &y, generalbuffer, g_CharsHandelGothicSm, g_FontHandelGothicSm, - renderdata->colour, viGetWidth(), viGetHeight(), 0, 1); + renderdata->colour, g_ViBackData->x, g_ViBackData->y, 0, 1); // Render ext character (for when a game has multiple notes) x = renderdata->x + 190; y = renderdata->y + 1; gdl = textRenderProjected(gdl, &x, &y, extbuffer, g_CharsHandelGothicSm, g_FontHandelGothicSm, - renderdata->colour, viGetWidth(), viGetHeight(), 0, 1); + renderdata->colour, g_ViBackData->x, g_ViBackData->y, 0, 1); // Render number of pages textMeasure(&textheight, &textwidth, pagesbuffer, g_CharsHandelGothicSm, g_FontHandelGothicSm, 0); @@ -1781,7 +1781,7 @@ static s32 pakGameNoteListMenuHandler(s32 operation, struct menuitem *item, unio x = renderdata->x + renderdata->width - textwidth - 6; y = renderdata->y + 1; gdl = textRenderProjected(gdl, &x, &y, pagesbuffer, g_CharsHandelGothicSm, g_FontHandelGothicSm, - renderdata->colour, viGetWidth(), viGetHeight(), 0, 1); + renderdata->colour, g_ViBackData->x, g_ViBackData->y, 0, 1); return (u32)gdl; case MENUOP_GETOPTIONHEIGHT: @@ -2129,11 +2129,11 @@ s32 filemgrChooseAgentListMenuHandler(s32 operation, struct menuitem *item, unio if (data->list.unk04 == g_FileLists[0]->numfiles) { // "New Agent..." gdl = textRenderProjected(gdl, &x, &y, langGet(L_OPTIONS_403), - g_CharsHandelGothicMd, g_FontHandelGothicMd, renderdata->colour, viGetWidth(), viGetHeight(), 0, 0); + g_CharsHandelGothicMd, g_FontHandelGothicMd, renderdata->colour, g_ViBackData->x, g_ViBackData->y, 0, 0); } else if (file) { // Render file name gdl = textRenderProjected(gdl, &x, &y, name, - g_CharsHandelGothicMd, g_FontHandelGothicMd, renderdata->colour, viGetWidth(), viGetHeight(), 0, 1); + g_CharsHandelGothicMd, g_FontHandelGothicMd, renderdata->colour, g_ViBackData->x, g_ViBackData->y, 0, 1); // Prepare and render stage name y = renderdata->y + 18; @@ -2150,7 +2150,7 @@ s32 filemgrChooseAgentListMenuHandler(s32 operation, struct menuitem *item, unio strcat(buffer, "\n"); gdl = textRenderProjected(gdl, &x, &y, buffer, - g_CharsHandelGothicSm, g_FontHandelGothicSm, renderdata->colour, viGetWidth(), viGetHeight(), 0, 0); + g_CharsHandelGothicSm, g_FontHandelGothicSm, renderdata->colour, g_ViBackData->x, g_ViBackData->y, 0, 0); // Prepare and render mission time x = renderdata->x + 62; @@ -2168,14 +2168,14 @@ s32 filemgrChooseAgentListMenuHandler(s32 operation, struct menuitem *item, unio textMeasure(&textheight, &textwidth, buffer, g_CharsHandelGothicSm, g_FontHandelGothicSm, 0); gdl = textRenderProjected(gdl, &x, &y, buffer, - g_CharsHandelGothicSm, g_FontHandelGothicSm, renderdata->colour, viGetWidth(), viGetHeight(), 0, 0); + g_CharsHandelGothicSm, g_FontHandelGothicSm, renderdata->colour, g_ViBackData->x, g_ViBackData->y, 0, 0); // Render seconds part of mission time (uses a smaller font) y += 1; x++; sprintf(buffer, ".%02d", seconds); gdl = textRenderProjected(gdl, &x, &y, buffer, - g_CharsHandelGothicXs, g_FontHandelGothicXs, renderdata->colour, viGetWidth(), viGetHeight(), 0, 0); + g_CharsHandelGothicXs, g_FontHandelGothicXs, renderdata->colour, g_ViBackData->x, g_ViBackData->y, 0, 0); } gdl = text0f153780(gdl); return (u32) gdl; diff --git a/src/game/game_0b0fd0.c b/src/game/game_0b0fd0.c index 4f292e3f4..af6b247b1 100644 --- a/src/game/game_0b0fd0.c +++ b/src/game/game_0b0fd0.c @@ -107,11 +107,6 @@ struct inventory_ammo *weaponGetAmmoByFunction(u32 weaponnum, u32 funcnum) return NULL; } -f32 handGetXShift(s32 handnum) -{ - return g_Vars.currentplayer->hands[handnum].xshift; -} - f32 func0f0b131c(s32 hand) { f32 x; @@ -121,7 +116,7 @@ f32 func0f0b131c(s32 hand) weapon = weaponFindById(bgunGetWeaponNum2(0)); x = weapon->posx; - if (PLAYERCOUNT() == 2 && optionsGetScreenSplit() == SCREENSPLIT_VERTICAL) { + if (PLAYERCOUNT() == 2 && g_ScreenSplit == SCREENSPLIT_VERTICAL) { x -= 3.5f; if (g_Vars.currentplayernum == 0) { @@ -132,7 +127,7 @@ f32 func0f0b131c(s32 hand) weapon = weaponFindById(bgunGetWeaponNum2(1)); x = -weapon->posx; - if (PLAYERCOUNT() == 2 && optionsGetScreenSplit() == SCREENSPLIT_VERTICAL) { + if (PLAYERCOUNT() == 2 && g_ScreenSplit == SCREENSPLIT_VERTICAL) { x += 3.5f; if (g_Vars.currentplayernum == 0) { @@ -416,7 +411,7 @@ f32 gsetGetDamage(struct gset *gset) damage = (gset->unk063a / 3.0f + 1.0f) * damage; } - if (bgunIsFiring(HAND_LEFT) && bgunIsFiring(HAND_RIGHT)) { + if (g_Vars.currentplayer->hands[HAND_LEFT].firing && g_Vars.currentplayer->hands[HAND_RIGHT].firing) { damage += damage; } diff --git a/src/game/game_0b2150.c b/src/game/game_0b2150.c index ee87c4509..20c722cac 100644 --- a/src/game/game_0b2150.c +++ b/src/game/game_0b2150.c @@ -69,8 +69,8 @@ void func0f0b2150(Gfx **gdlptr, f32 *arg1, f32 *arg2, s32 width, s32 height, s32 yl = 0; } - widthx4 = viGetWidth() * 4; - heightx4 = viGetHeight() * 4; + widthx4 = g_ViBackData->x * 4; + heightx4 = g_ViBackData->y * 4; if (widthx4 < xh) { xh = widthx4; diff --git a/src/game/game_13c510.c b/src/game/game_13c510.c index 8f445320b..70b206632 100644 --- a/src/game/game_13c510.c +++ b/src/game/game_13c510.c @@ -139,13 +139,13 @@ void artifactsCalculateGlaresForRoom(s32 roomnum) s1 = &var800a41a0[g_Rooms[roomnum].gfxdata->lightsindex * 3]; roomPopulateMtx(&sp138, roomnum); - mtx00015f88(currentPlayerGetScaleBg2Gfx(), &sp138); - mtx4MultMtx4(camGetMtxF006c(), &sp138, &spf8); + mtx00015f88(g_Vars.currentplayerstats->scale_bg2gfx, &sp138); + mtx4MultMtx4(g_Vars.currentplayer->mtxf006c, &sp138, &spf8); - viewwidth = viGetViewWidth(); - viewheight = viGetViewHeight(); - viewleft = viGetViewLeft(); - viewtop = viGetViewTop(); + viewwidth = g_ViBackData->viewx; + viewheight = g_ViBackData->viewy; + viewleft = g_ViBackData->viewleft; + viewtop = g_ViBackData->viewtop; for (i = 0; i < numlights; i++) { origin.x = 0.0f; @@ -308,7 +308,7 @@ void artifactsCalculateGlaresForRoom(s32 roomnum) && yi >= (s32)viewtop && yi < (s32)(viewtop + viewheight) && f0 < 32576.0f) { - index = envGetCurrent()->numsuns; + index = g_Env.numsuns; index *= 8; artifact = artifacts; artifact += index; @@ -320,7 +320,7 @@ void artifactsCalculateGlaresForRoom(s32 roomnum) if (index < MAX_ARTIFACTS) { artifact->unk04 = func0f13c574(f0) >> 2; - artifact->unk08 = &var800844f0[viGetWidth() * yi + xi]; + artifact->unk08 = &var800844f0[g_ViBackData->x * yi + xi]; artifact->light = &roomlights[i]; artifact->type = ARTIFACTTYPE_GLARE; artifact->unk0c.u16_2 = xi; @@ -408,13 +408,13 @@ Gfx *artifactsRenderGlaresForRoom(Gfx *gdl, s32 roomnum) f32 f26; artifacts = g_ArtifactLists[g_SchedFrontArtifactsIndex]; - f30 = roomGetUnk5c(roomnum); + f30 = g_Rooms[roomnum].unk5c; if (g_Rooms[roomnum].gfxdata == NULL || g_Rooms[roomnum].loaded240 == 0) { return gdl; } - for (i = envGetCurrent()->numsuns * 8; i < MAX_ARTIFACTS; i++) { + for (i = g_Env.numsuns * 8; i < MAX_ARTIFACTS; i++) { struct light *light2 = artifacts[i].light; count = 0; @@ -469,7 +469,7 @@ Gfx *artifactsRenderGlaresForRoom(Gfx *gdl, s32 roomnum) s3[0] = func0f13d3c4(s3[0], t2 * 2); if (t2 > 0) { - brightness = viGetFovY() * 0.017453292f; + brightness = g_ViBackData->fovy * 0.017453292f; add = cosf(brightness) / sinf(brightness) * 14.6f; if (lightIsHealthy(roomnum, lightindex - g_Rooms[roomnum].gfxdata->lightsindex)) { @@ -508,7 +508,7 @@ Gfx *artifactsRenderGlaresForRoom(Gfx *gdl, s32 roomnum) lightscreenpos.f[l] = lightworldpos.f[l] - g_Vars.currentplayer->cam_pos.f[l]; } - mtx4RotateVecInPlace(camGetWorldToScreenMtxf(), &lightscreenpos); + mtx4RotateVecInPlace(g_Vars.currentplayer->worldtoscreenmtx, &lightscreenpos); cam0f0b4d04(&lightscreenpos, spdc); @@ -534,8 +534,8 @@ Gfx *artifactsRenderGlaresForRoom(Gfx *gdl, s32 roomnum) f24 = g_CurrentStage->light_width * brightness * 0.01f; f26 = g_CurrentStage->light_height * brightness * 0.01f; - f24 *= viGetViewWidth() * (1.0f / 240.0f) / camGetPerspAspect(); - f26 *= viGetViewHeight() * (1.0f / 240.0f); + f24 *= g_ViBackData->viewx * (1.0f / 240.0f) / g_Vars.currentplayer->c_perspaspect; + f26 *= g_ViBackData->viewy * (1.0f / 240.0f); if (brightness > 3.0f) { f32 alpha = (light->colour & 0xf) * 17; diff --git a/src/game/game_1531a0.c b/src/game/game_1531a0.c index 9643f6617..2d9fb1092 100644 --- a/src/game/game_1531a0.c +++ b/src/game/game_1531a0.c @@ -854,7 +854,7 @@ static Gfx *text0f15568c(Gfx *gdl, s32 *x, s32 *y, struct fontchar *curchar, str *x -= (tmp - 1) * xscale; width *= xscale; - if (g_TextRotated90 || (*x > 0 && *x <= viGetWidth() && sp90 + curchar->baseline <= viGetHeight())) { + if (g_TextRotated90 || (*x > 0 && *x <= g_ViBackData->x && sp90 + curchar->baseline <= g_ViBackData->y)) { if (savedx + width >= *x && savedy + height >= curchar->baseline + sp90 && *x >= savedx @@ -1101,8 +1101,8 @@ static Gfx *textRenderChar(Gfx *gdl, s32 *x, s32 *y, struct fontchar *char1, str *x -= (tmp - 1) * var8007fad0; if (*x > 0 - && *x <= viGetWidth() - && sp38 + char1->baseline <= viGetHeight() + && *x <= g_ViBackData->x + && sp38 + char1->baseline <= g_ViBackData->y && *x <= arg6 + arg8 && char1->baseline + sp38 <= arg7 + arg9 && *x >= arg6 diff --git a/src/game/game_176080.c b/src/game/game_176080.c index 79ec8affc..27b62727b 100644 --- a/src/game/game_176080.c +++ b/src/game/game_176080.c @@ -64,9 +64,9 @@ Gfx *mblur0f1762ac(Gfx *gdl) if (g_Vars.normmplayerisrunning && (g_Vars.currentplayernum >= 2 || (PLAYERCOUNT() == 2 && g_Vars.currentplayernum == 1))) { - subamount = playerGetFbWidth() * playerGetFbHeight(); + subamount = g_ViModes[VIRES_LO].fbwidth * g_ViModes[VIRES_LO].fbheight; - if (optionsGetScreenSplit() == SCREENSPLIT_VERTICAL) { + if (g_ScreenSplit == SCREENSPLIT_VERTICAL) { subamount = 0; } } else { @@ -89,23 +89,23 @@ Gfx *mblur0f1763f4(Gfx *gdl) gDPPipeSync(gdl++); gDPSetRenderMode(gdl++, G_RM_NOOP, G_RM_NOOP2); - gDPSetColorImage(gdl++, G_IM_FMT_RGBA, G_IM_SIZ_16b, viGetWidth(), OS_PHYSICAL_TO_K0(var800844f4)); + gDPSetColorImage(gdl++, G_IM_FMT_RGBA, G_IM_SIZ_16b, g_ViBackData->x, OS_PHYSICAL_TO_K0(var800844f4)); gDPSetCycleType(gdl++, G_CYC_FILL); gDPSetFillColor(gdl++, 0xfffcfffc); - gDPSetScissorFrac(gdl++, G_SC_NON_INTERLACE, 0, 0, playerGetFbWidth() * 4.0f, playerGetFbHeight() * 4.0f); + gDPSetScissorFrac(gdl++, G_SC_NON_INTERLACE, 0, 0, g_ViModes[VIRES_LO].fbwidth * 4.0f, g_ViModes[VIRES_LO].fbheight * 4.0f); if (PLAYERCOUNT() <= 2) { left = 0; - right = playerGetFbWidth() - 1; + right = g_ViModes[VIRES_LO].fbwidth - 1; } else if (g_Vars.currentplayernum == 0 || g_Vars.currentplayernum == 2) { left = 0; - right = playerGetFbWidth() / 2 - 1; + right = g_ViModes[VIRES_LO].fbwidth / 2 - 1; } else { - left = playerGetFbWidth() / 2; - right = playerGetFbWidth() - 1; + left = g_ViModes[VIRES_LO].fbwidth / 2; + right = g_ViModes[VIRES_LO].fbwidth - 1; } - gDPFillRectangle(gdl++, left, 0, right, playerGetFbHeight() - 1); + gDPFillRectangle(gdl++, left, 0, right, g_ViModes[VIRES_LO].fbheight - 1); gDPPipeSync(gdl++); return gdl; @@ -143,12 +143,11 @@ Gfx *mblurRender(Gfx *gdl) u16 *image; s32 i; - viGetBackBuffer(); sp44 = mblur0f176668(g_SchedWriteArtifactsIndex); g_SchedSpecialArtifactIndexes[g_SchedWriteArtifactsIndex] = 1; gDPPipeSync(gdl++); - gDPSetColorImage(gdl++, G_IM_FMT_RGBA, G_IM_SIZ_16b, viGetBufWidth(), OS_PHYSICAL_TO_K0(sp44)); + gDPSetColorImage(gdl++, G_IM_FMT_RGBA, G_IM_SIZ_16b, g_ViBackData->bufx, OS_PHYSICAL_TO_K0(sp44)); gDPSetScissor(gdl++, G_SC_NON_INTERLACE, 0, 0, 320, 240); gDPSetCycleType(gdl++, G_CYC_COPY); gDPSetTile(gdl++, G_IM_FMT_RGBA, G_IM_SIZ_16b, 0, 0x0000, 5, 0, G_TX_NOMIRROR | G_TX_WRAP, G_TX_NOMASK, G_TX_NOLOD, G_TX_NOMIRROR | G_TX_WRAP, G_TX_NOMASK, G_TX_NOLOD); @@ -176,12 +175,12 @@ Gfx *mblurRender(Gfx *gdl) if (artifacts[i].type != ARTIFACTTYPE_FREE) { s2 = &sp44[s4]; - image = &sp4c[artifacts[i].unk0c.u16_1 * viGetWidth()]; + image = &sp4c[artifacts[i].unk0c.u16_1 * g_ViBackData->x]; gDPPipeSync(gdl++); gDPSetTextureImage(gdl++, G_IM_FMT_RGBA, G_IM_SIZ_16b, 320, image); gDPLoadSync(gdl++); - gDPLoadBlock(gdl++, 5, 0, 0, viGetWidth() - 1, 0); + gDPLoadBlock(gdl++, 5, 0, 0, g_ViBackData->x - 1, 0); gDPPipeSync(gdl++); gSPTextureRectangle(gdl++, @@ -199,8 +198,8 @@ Gfx *mblurRender(Gfx *gdl) gDPPipeSync(gdl++); gDPLoadSync(gdl++); gDPTileSync(gdl++); - gDPSetColorImage(gdl++, G_IM_FMT_RGBA, G_IM_SIZ_16b, viGetBufWidth(), OS_PHYSICAL_TO_K0(viGetBackBuffer())); - gDPSetScissorFrac(gdl++, G_SC_NON_INTERLACE, 0, 0, viGetWidth() * 4.0f, viGetHeight() * 4.0f); + gDPSetColorImage(gdl++, G_IM_FMT_RGBA, G_IM_SIZ_16b, g_ViBackData->bufx, OS_PHYSICAL_TO_K0(g_ViBackData->fb)); + gDPSetScissorFrac(gdl++, G_SC_NON_INTERLACE, 0, 0, g_ViBackData->x * 4.0f, g_ViBackData->y * 4.0f); gSPSetGeometryMode(gdl++, G_ZBUFFER); gDPSetTextureFilter(gdl++, G_TF_BILERP); gDPSetTexturePersp(gdl++, G_TP_PERSP); diff --git a/src/game/gamefile.c b/src/game/gamefile.c index dce4d50be..cf90083ae 100644 --- a/src/game/gamefile.c +++ b/src/game/gamefile.c @@ -10,6 +10,7 @@ #include "game/training.h" #include "game/gamefile.h" #include "game/mplayer/mplayer.h" +#include "game/music.h" #include "game/pak.h" #include "game/options.h" #include "game/utils.h" @@ -65,23 +66,23 @@ void gamefileApplyOptions(struct gamefile *file) optionsSetShowMissionTime(player2, pakHasBitflag(GAMEFILEFLAG_P2_SHOWMISSIONTIME, file->flags)); optionsSetPaintball(player2, pakHasBitflag(GAMEFILEFLAG_P2_PAINTBALL, file->flags)); - optionsSetInGameSubtitles(pakHasBitflag(GAMEFILEFLAG_INGAMESUBTITLES, file->flags)); - optionsSetCutsceneSubtitles(pakHasBitflag(GAMEFILEFLAG_CUTSCENESUBTITLES, file->flags)); + g_InGameSubtitles = pakHasBitflag(GAMEFILEFLAG_INGAMESUBTITLES, file->flags); + g_CutsceneSubtitles = pakHasBitflag(GAMEFILEFLAG_CUTSCENESUBTITLES, file->flags); // Duplicate optionsSetPaintball(player2, pakHasBitflag(GAMEFILEFLAG_P2_PAINTBALL, file->flags)); g_Vars.langfilteron = pakHasBitflag(GAMEFILEFLAG_LANGFILTERON, file->flags); - optionsSetScreenSplit(pakHasBitflag(GAMEFILEFLAG_SCREENSPLIT, file->flags)); - optionsSetScreenRatio(pakHasBitflag(GAMEFILEFLAG_SCREENRATIO, file->flags)); + g_ScreenSplit = pakHasBitflag(GAMEFILEFLAG_SCREENSPLIT, file->flags); + g_ScreenRatio = pakHasBitflag(GAMEFILEFLAG_SCREENRATIO, file->flags); if (pakHasBitflag(GAMEFILEFLAG_SCREENSIZE_CINEMA, file->flags)) { - optionsSetScreenSize(SCREENSIZE_CINEMA); + g_ScreenSize = SCREENSIZE_CINEMA; } else if (pakHasBitflag(GAMEFILEFLAG_SCREENSIZE_WIDE, file->flags)) { - optionsSetScreenSize(SCREENSIZE_WIDE); + g_ScreenSize = SCREENSIZE_WIDE; } else { - optionsSetScreenSize(SCREENSIZE_FULL); + g_ScreenSize = SCREENSIZE_FULL; } g_Vars.pendingantiplayernum = pakHasBitflag(GAMEFILEFLAG_ANTIPLAYERNUM, file->flags) ? 1 : 0; @@ -103,7 +104,7 @@ void gamefileLoadDefaults(struct gamefile *file) file->autostageindex = 0; file->totaltime = 0; sndSetSfxVolume(0x5000); - optionsSetMusicVolume(0x5000); + musicSetVolume(0x5000); sndSetSoundMode(SOUNDMODE_STEREO); optionsSetControlMode(player1, CONTROLMODE_11); optionsSetControlMode(player2, CONTROLMODE_11); @@ -228,7 +229,7 @@ s32 gamefileLoad(s32 device) volume = 255; } - optionsSetMusicVolume((volume & 0x1ff) * 128); + musicSetVolume((volume & 0x1ff) * 128); sndSetSoundMode(savebufferReadBits(&buffer, 2)); optionsSetControlMode(p1index, savebufferReadBits(&buffer, 3)); @@ -333,15 +334,15 @@ s32 gamefileSave(s32 device, s32 fileid, u16 deviceserial) pakSetBitflag(GAMEFILEFLAG_P2_SHOWMISSIONTIME, g_GameFile.flags, optionsGetShowMissionTime(p2index)); pakSetBitflag(GAMEFILEFLAG_P2_PAINTBALL, g_GameFile.flags, optionsGetPaintball(p2index)); - pakSetBitflag(GAMEFILEFLAG_SCREENSPLIT, g_GameFile.flags, optionsGetScreenSplit()); - pakSetBitflag(GAMEFILEFLAG_SCREENRATIO, g_GameFile.flags, optionsGetScreenRatio()); + pakSetBitflag(GAMEFILEFLAG_SCREENSPLIT, g_GameFile.flags, g_ScreenSplit); + pakSetBitflag(GAMEFILEFLAG_SCREENRATIO, g_GameFile.flags, g_ScreenRatio); - pakSetBitflag(GAMEFILEFLAG_SCREENSIZE_WIDE, g_GameFile.flags, optionsGetScreenSize() == SCREENSIZE_WIDE); - pakSetBitflag(GAMEFILEFLAG_SCREENSIZE_CINEMA, g_GameFile.flags, optionsGetScreenSize() == SCREENSIZE_CINEMA); + pakSetBitflag(GAMEFILEFLAG_SCREENSIZE_WIDE, g_GameFile.flags, g_ScreenSize == SCREENSIZE_WIDE); + pakSetBitflag(GAMEFILEFLAG_SCREENSIZE_CINEMA, g_GameFile.flags, g_ScreenSize == SCREENSIZE_CINEMA); pakSetBitflag(GAMEFILEFLAG_HIRES, g_GameFile.flags, 0); - pakSetBitflag(GAMEFILEFLAG_INGAMESUBTITLES, g_GameFile.flags, optionsGetInGameSubtitles()); - pakSetBitflag(GAMEFILEFLAG_CUTSCENESUBTITLES, g_GameFile.flags, optionsGetCutsceneSubtitles()); + pakSetBitflag(GAMEFILEFLAG_INGAMESUBTITLES, g_GameFile.flags, g_InGameSubtitles); + pakSetBitflag(GAMEFILEFLAG_CUTSCENESUBTITLES, g_GameFile.flags, g_CutsceneSubtitles); pakSetBitflag(GAMEFILEFLAG_LANGFILTERON, g_GameFile.flags, g_Vars.langfilteron); pakSetBitflag(GAMEFILEFLAG_FOUNDTIMEDMINE, g_GameFile.flags, frIsWeaponFound(WEAPON_TIMEDMINE)); @@ -365,14 +366,14 @@ s32 gamefileSave(s32 device, s32 fileid, u16 deviceserial) value = VOLUME(g_SfxVolume) >> 7; savebufferOr(&buffer, value >> 2, 6); - value = optionsGetMusicVolume() >> 7; + value = musicGetVolume() >> 7; savebufferOr(&buffer, value >> 2, 6); value = g_SoundMode; savebufferOr(&buffer, value, 2); - savebufferOr(&buffer, optionsGetControlMode(p1index), 3); - savebufferOr(&buffer, optionsGetControlMode(p2index), 3); + savebufferOr(&buffer, g_PlayerConfigsArray[p1index].controlmode, 3); + savebufferOr(&buffer, g_PlayerConfigsArray[p2index].controlmode, 3); for (i = 0; i < 10; i++) { savebufferOr(&buffer, g_GameFile.flags[i], 8); diff --git a/src/game/gunfx.c b/src/game/gunfx.c index ba19dbc1e..8316c7547 100644 --- a/src/game/gunfx.c +++ b/src/game/gunfx.c @@ -108,7 +108,7 @@ void beamCreateForHand(s32 handnum) { struct player *player = g_Vars.currentplayer; struct hand *hand = player->hands + handnum; - Mtxf *mtx = camGetWorldToScreenMtxf(); + Mtxf *mtx = g_Vars.currentplayer->worldtoscreenmtx; f32 tmp; tmp = hand->hitpos.f[0] * mtx->m[0][2] + hand->hitpos.f[1] * mtx->m[1][2] + hand->hitpos.f[2] * mtx->m[2][2] + mtx->m[3][2]; @@ -186,7 +186,7 @@ static Gfx *beamRenderGeneric(Gfx *gdl, struct textureconfig *texconfig, Mtxf *spc8; u32 *colours = gfxAllocateColours(2); Mtxf sp84; - Mtxf *worldtoscreenmtx = camGetWorldToScreenMtxf(); + Mtxf *worldtoscreenmtx = g_Vars.currentplayer->worldtoscreenmtx; struct coord sp74 = {0, 0, 0}; f32 mult; u32 stack[2]; @@ -206,7 +206,7 @@ static Gfx *beamRenderGeneric(Gfx *gdl, struct textureconfig *texconfig, spe4.f[1] /= length; spe4.f[2] /= length; - mtx4TransformVec(camGetWorldToScreenMtxf(), headpos, &sp5c); + mtx4TransformVec(g_Vars.currentplayer->worldtoscreenmtx, headpos, &sp5c); if (sp5c.f[0] * arg2 > 10000.0f || sp5c.f[0] * arg2 < -10000.0f) { return gdl; @@ -220,7 +220,7 @@ static Gfx *beamRenderGeneric(Gfx *gdl, struct textureconfig *texconfig, return gdl; } - mtx4TransformVec(camGetWorldToScreenMtxf(), tailpos, &sp5c); + mtx4TransformVec(g_Vars.currentplayer->worldtoscreenmtx, tailpos, &sp5c); if (sp5c.f[0] * arg2 > 10000.0f || sp5c.f[0] * arg2 < -10000.0f) { return gdl; @@ -326,7 +326,7 @@ Gfx *beamRender(Gfx *gdl, struct beam *beam, bool arg2, u8 arg3) f32 spf0 = 1.4142f; struct textureconfig *texconfig = &g_TexBeamConfigs[arg3]; // ec s32 i; - Mtxf *worldtoscreenmtx = camGetWorldToScreenMtxf(); // e4 + Mtxf *worldtoscreenmtx = g_Vars.currentplayer->worldtoscreenmtx; // e4 s32 j; u32 stack1; s32 spd8; @@ -477,7 +477,7 @@ Gfx *beamRender(Gfx *gdl, struct beam *beam, bool arg2, u8 arg3) spcc.f[2] *= spc0[0] * 0.5f; } - mtx4TransformVecInPlace(camGetProjectionMtxF(), &spcc); + mtx4TransformVecInPlace(g_Vars.currentplayer->projectionmtx, &spcc); spcc.f[0] -= sp138.f[0]; spcc.f[1] -= sp138.f[1]; @@ -712,7 +712,7 @@ void casingCreateForHand(s32 handnum, f32 ground, Mtxf *mtx) mtx4Copy(mtx, &spec); - modeldef = bgunGetCartModeldef(); + modeldef = g_Vars.currentplayer->gunctrl.cartmodeldef; if (modeldef != NULL) { casing = casingCreate(modeldef, &spec); @@ -862,7 +862,7 @@ static void casingRender(struct casing *casing, Gfx **gdlptr) mtx00015f04(0.1000000089407f, &mtx); mtx4SetTranslation(&casing->pos, &mtx); - mtx00015be4(camGetWorldToScreenMtxf(), &mtx, model.matrices); + mtx00015be4(g_Vars.currentplayer->worldtoscreenmtx, &mtx, model.matrices); // Check if any coordinate is out of range for (i = 0; i < 3; i++) { @@ -1059,14 +1059,14 @@ Gfx *lasersightRenderDot(Gfx *gdl) u32 spi = 6; mtx4LoadIdentity(&sp164); - mtx00015be0(camGetWorldToScreenMtxf(), &sp164); + mtx00015be0(g_Vars.currentplayer->worldtoscreenmtx, &sp164); mtx4LoadIdentity(&sp124); - mtx00015be0(camGetProjectionMtxF(), &sp124); + mtx00015be0(g_Vars.currentplayer->projectionmtx, &sp124); sp124.m[3][0] = sp124.m[3][1] = sp124.m[3][2] = 0.0f; mtx4LoadIdentity(&sp1b0); - mtx00015be0(camGetWorldToScreenMtxf(), &sp1b0); + mtx00015be0(g_Vars.currentplayer->worldtoscreenmtx, &sp1b0); campos = player->cam_pos; @@ -1238,16 +1238,16 @@ Gfx *lasersightRenderBeam(Gfx *gdl) texSelect(&gdl, &g_TexGeneralConfigs[3], 4, 0, 2, 1, NULL); mtx4LoadIdentity(&sp14c); - mtx00015be0(camGetWorldToScreenMtxf(), &sp14c); + mtx00015be0(g_Vars.currentplayer->worldtoscreenmtx, &sp14c); mtx4LoadIdentity(&sp10c); - mtx00015be0(camGetProjectionMtxF(), &sp10c); + mtx00015be0(g_Vars.currentplayer->projectionmtx, &sp10c); sp10c.m[3][1] = 0; sp10c.m[3][0] = 0; sp10c.m[3][2] = 0; mtx4LoadIdentity(&sp198); - mtx00015be0(camGetWorldToScreenMtxf(), &sp198); + mtx00015be0(g_Vars.currentplayer->worldtoscreenmtx, &sp198); campos = player->cam_pos; diff --git a/src/game/hudmsg.c b/src/game/hudmsg.c index 5702db30c..05bae6e0e 100644 --- a/src/game/hudmsg.c +++ b/src/game/hudmsg.c @@ -75,18 +75,6 @@ static s32 hudmsgIsZoomRangeVisible(void) && g_Vars.currentplayer->cameramode != CAMERAMODE_THIRDPERSON; } -/** - * hudmsgRenderMissionTimer calls viGetWidth (which returns an s16), then stores - * the width in sp42 while it calls viGetHeight. However, when we do this it - * stores the width to sp40 instead. - * - * Changing the definition of viGetHeight to return an s32 fixes this, but is - * surely wrong and creates mismatches elsewhere. So we declare a new function - * with the return type we need, and link it to the same address as viGetHeight - * via the linker config. - */ -extern s32 viGetHeight_hack(void); - static Gfx *hudmsgRenderMissionTimer(Gfx *gdl, u32 alpha) { s32 x; @@ -103,9 +91,9 @@ static Gfx *hudmsgRenderMissionTimer(Gfx *gdl, u32 alpha) textcolour = alpha; - viewleft = viGetViewLeft(); - viewtop = viGetViewTop(); - viewheight = viGetViewHeight(); + viewleft = g_ViBackData->viewleft; + viewtop = g_ViBackData->viewtop; + viewheight = g_ViBackData->viewy; playercount = PLAYERCOUNT(); playernum = g_Vars.currentplayernum; @@ -118,16 +106,16 @@ static Gfx *hudmsgRenderMissionTimer(Gfx *gdl, u32 alpha) // Because of this, in 1 player the timer is drawn out of place when the // screen split option is vertical and either the countdown timer is visible // or a zoomable weapon is in use. - if (optionsGetScreenSplit() == SCREENSPLIT_VERTICAL && !g_CountdownTimerOff) { + if (g_ScreenSplit == SCREENSPLIT_VERTICAL && !g_CountdownTimerOff) { timery -= 8; } - if ((optionsGetScreenSplit() == SCREENSPLIT_VERTICAL || playercount >= 3) && hudmsgIsZoomRangeVisible()) { + if ((g_ScreenSplit == SCREENSPLIT_VERTICAL || playercount >= 3) && hudmsgIsZoomRangeVisible()) { timery -= 8; } if (playercount == 2) { - if (optionsGetScreenSplit() != SCREENSPLIT_VERTICAL && playernum == 0) { + if (g_ScreenSplit != SCREENSPLIT_VERTICAL && playernum == 0) { timery += 10; } else { timery += 2; @@ -147,7 +135,7 @@ static Gfx *hudmsgRenderMissionTimer(Gfx *gdl, u32 alpha) // If this is a second player with their viewport on the right side of the // screen, move the timer left a bit as the safe zone doesn't need to be // considered. - if (playercount == 2 && optionsGetScreenSplit() == SCREENSPLIT_VERTICAL && playernum == 1) { + if (playercount == 2 && g_ScreenSplit == SCREENSPLIT_VERTICAL && playernum == 1) { viewleft -= 14; } else if (playercount >= 3 && (playernum & 1) == 1) { viewleft -= 14; @@ -161,7 +149,7 @@ static Gfx *hudmsgRenderMissionTimer(Gfx *gdl, u32 alpha) x = viewleft + g_HudPaddingX + 3; y = timery; - gdl = textRender(gdl, &x, &y, buffer, g_CharsNumeric, g_FontNumeric, textcolour, 0x000000a0, viGetWidth(), viGetHeight_hack(), 0, 0); + gdl = textRender(gdl, &x, &y, buffer, g_CharsNumeric, g_FontNumeric, textcolour, 0x000000a0, g_ViBackData->x, g_ViBackData->y, 0, 0); return gdl; } @@ -189,10 +177,10 @@ static Gfx *hudmsgRenderZoomRange(Gfx *gdl, u32 alpha) u32 colour; colour = (alpha * 0xa0 / 255) | 0x00ff0000; - viewtop = viGetViewTop(); - viewleft = viGetViewLeft(); - viewhalfwidth = viGetViewWidth() >> 1; - viewheight = viGetViewHeight(); + viewtop = g_ViBackData->viewtop; + viewleft = g_ViBackData->viewleft; + viewhalfwidth = g_ViBackData->viewx >> 1; + viewheight = g_ViBackData->viewy; texty = viewheight + viewtop - 1; maxzoom = 1.0f; weaponnum = g_Vars.currentplayer->hands[0].gset.weaponnum; @@ -205,7 +193,7 @@ static Gfx *hudmsgRenderZoomRange(Gfx *gdl, u32 alpha) } if (playercount == 2) { - if (optionsGetScreenSplit() != SCREENSPLIT_VERTICAL && g_Vars.currentplayernum == 0) { + if (g_ScreenSplit != SCREENSPLIT_VERTICAL && g_Vars.currentplayernum == 0) { texty += 10; } else { texty += 2; @@ -244,7 +232,7 @@ static Gfx *hudmsgRenderZoomRange(Gfx *gdl, u32 alpha) y2 = y + textheight; gdl = text0f1538e4(gdl, &x, &y, &x2, &y2); - gdl = textRender(gdl, &x, &y, text, g_CharsNumeric, g_FontNumeric, colour, 0x000000a0, viGetWidth(), viGetHeight(), 0, 0); + gdl = textRender(gdl, &x, &y, text, g_CharsNumeric, g_FontNumeric, colour, 0x000000a0, g_ViBackData->x, g_ViBackData->y, 0, 0); // Divider sprintf(text, "/"); @@ -256,7 +244,7 @@ static Gfx *hudmsgRenderZoomRange(Gfx *gdl, u32 alpha) y2 = y + textheight; gdl = text0f1538e4(gdl, &x, &y, &x2, &y2); - gdl = textRender(gdl, &x, &y, text, g_CharsNumeric, g_FontNumeric, colour, 0x000000a0, viGetWidth(), viGetHeight(), 0, 0); + gdl = textRender(gdl, &x, &y, text, g_CharsNumeric, g_FontNumeric, colour, 0x000000a0, g_ViBackData->x, g_ViBackData->y, 0, 0); // Right side - max zoom level sprintf(text, "%s%s%4.2fX", "", "", maxzoom); @@ -268,7 +256,7 @@ static Gfx *hudmsgRenderZoomRange(Gfx *gdl, u32 alpha) y2 = y + textheight; gdl = text0f1538e4(gdl, &x, &y, &x2, &y2); - gdl = textRender(gdl, &x, &y, text, g_CharsNumeric, g_FontNumeric, colour, 0x000000a0, viGetWidth(), viGetHeight(), 0, 0); + gdl = textRender(gdl, &x, &y, text, g_CharsNumeric, g_FontNumeric, colour, 0x000000a0, g_ViBackData->x, g_ViBackData->y, 0, 0); return gdl; } @@ -323,7 +311,7 @@ static s32 hudmsg0f0ddb1c(s32 *arg0, s32 arg1) *arg0 = 24; - if (PLAYERCOUNT() == 2 && optionsGetScreenSplit() == SCREENSPLIT_VERTICAL) { + if (PLAYERCOUNT() == 2 && g_ScreenSplit == SCREENSPLIT_VERTICAL) { result -= *arg0 * 2 / 3; if (g_Vars.currentplayernum == 0) { @@ -501,12 +489,12 @@ void hudmsgCreateAsSubtitle(char *srctext, s32 type, u8 colourindex, s32 audioch if (type == HUDMSGTYPE_INGAMESUBTITLE) { if (g_Vars.tickmode == TICKMODE_CUTSCENE) { - if (!optionsGetCutsceneSubtitles()) { + if (!g_CutsceneSubtitles) { return; } type = HUDMSGTYPE_CUTSCENESUBTITLE; - } else if (!optionsGetInGameSubtitles()) { + } else if (!g_InGameSubtitles) { return; } } @@ -730,7 +718,7 @@ static void hudmsgCalculatePosition(struct hudmessage *msg) } } - if (PLAYERCOUNT() == 2 && optionsGetScreenSplit() == SCREENSPLIT_VERTICAL) { + if (PLAYERCOUNT() == 2 && g_ScreenSplit == SCREENSPLIT_VERTICAL) { { viewwidth -= offset; @@ -750,7 +738,7 @@ static void hudmsgCalculatePosition(struct hudmessage *msg) x = viewleft + v0 + msg->xmargin + 3; if (PLAYERCOUNT() == 2 - && optionsGetScreenSplit() == SCREENSPLIT_VERTICAL + && g_ScreenSplit == SCREENSPLIT_VERTICAL && (!g_InCutscene || g_MainIsEndscreen)) { if (msg->playernum == 0) { x += 15; @@ -787,7 +775,7 @@ static void hudmsgCalculatePosition(struct hudmessage *msg) y = viewtop + viewheight - msg->height - msg->ymargin - 14; if (PLAYERCOUNT() == 2 && (g_InCutscene == 0 || g_MainIsEndscreen)) { - if (optionsGetScreenSplit() != SCREENSPLIT_VERTICAL && msg->playernum == 0) { + if (g_ScreenSplit != SCREENSPLIT_VERTICAL && msg->playernum == 0) { y += 8; } else { y += 3; @@ -836,7 +824,7 @@ static void hudmsgCreateFromArgs(char *text, s32 type, s32 conf00, s32 conf01, s char stacktext[400]; s32 writeindex; - if (type == HUDMSGTYPE_INGAMESUBTITLE && !optionsGetInGameSubtitles()) { + if (type == HUDMSGTYPE_INGAMESUBTITLE && !g_InGameSubtitles) { return; } @@ -1099,7 +1087,7 @@ void hudmsgsTick(void) } else { // Most HUD messages play a swish sound effect if (msg->timer == 0 - && !lvIsPaused() + && !g_LvIsPaused && !mpIsPaused() && msg->type != HUDMSGTYPE_CUTSCENESUBTITLE && msg->type != HUDMSGTYPE_INGAMESUBTITLE @@ -1250,14 +1238,14 @@ Gfx *hudmsgsRender(Gfx *gdl) x = msg->x; y = msg->y; - if (msg->type == HUDMSGTYPE_INGAMESUBTITLE && playerIsHealthVisible()) { + if (msg->type == HUDMSGTYPE_INGAMESUBTITLE && g_Vars.currentplayer->healthshowmode != HEALTHSHOWMODE_HIDDEN) { y += (s32)(16.0f * playerGetHealthBarHeightFrac()); } if (msg->type == HUDMSGTYPE_CUTSCENESUBTITLE) { gDPSetScissor(gdl++, 0, (x - 4), 0, - (x + msg->width + 3), viGetBufHeight()); + (x + msg->width + 3), g_ViBackData->bufy); } switch (msg->state) { @@ -1298,11 +1286,11 @@ Gfx *hudmsgsRender(Gfx *gdl) if (msg->boxed) { gdl = hudmsgRenderBox(gdl, x - 3, y - 3, x + msg->width + 2, y + msg->height + 2, 1.0f, bordercolour, spc0); - gdl = textRenderProjected(gdl, &x, &y, msg->text, msg->font1, msg->font2, textcolour, viGetWidth(), viGetHeight(), 0, 0); + gdl = textRenderProjected(gdl, &x, &y, msg->text, msg->font1, msg->font2, textcolour, g_ViBackData->x, g_ViBackData->y, 0, 0); } else { gdl = text0f153a34(gdl, x, y, x + msg->width, y + msg->height, 0); - gdl = textRender(gdl, &x, &y, msg->text, msg->font1, msg->font2, textcolour, glowcolour, viGetWidth(), viGetHeight(), 0, 0); + gdl = textRender(gdl, &x, &y, msg->text, msg->font1, msg->font2, textcolour, glowcolour, g_ViBackData->x, g_ViBackData->y, 0, 0); } if (msg->alignv == 6) { @@ -1323,11 +1311,11 @@ Gfx *hudmsgsRender(Gfx *gdl) gdl = hudmsgRenderBox(gdl, x - 3, y - 3, x + msg->width + 2, y + msg->height + 2, 1.0f, bordercolour, 1.0f); - gdl = textRenderProjected(gdl, &x, &y, msg->text, msg->font1, msg->font2, textcolour, viGetWidth(), viGetHeight(), 0, 0); + gdl = textRenderProjected(gdl, &x, &y, msg->text, msg->font1, msg->font2, textcolour, g_ViBackData->x, g_ViBackData->y, 0, 0); } else { gdl = text0f153a34(gdl, x, y, x + msg->width, y + msg->height, 0); - gdl = textRender(gdl, &x, &y, msg->text, msg->font1, msg->font2, textcolour, glowcolour, viGetWidth(), viGetHeight(), 0, 0); + gdl = textRender(gdl, &x, &y, msg->text, msg->font1, msg->font2, textcolour, glowcolour, g_ViBackData->x, g_ViBackData->y, 0, 0); } if (msg->alignv == 6) { timerthing = 0; @@ -1364,11 +1352,11 @@ Gfx *hudmsgsRender(Gfx *gdl) if (msg->boxed) { gdl = hudmsgRenderBox(gdl, x - 3, y - 3, x + msg->width + 2, y + msg->height + 2, 1.0f, bordercolour, 1.0f - spa8); - gdl = textRenderProjected(gdl, &x, &y, msg->text, msg->font1, msg->font2, textcolour, viGetWidth(), viGetHeight(), 0, 0); + gdl = textRenderProjected(gdl, &x, &y, msg->text, msg->font1, msg->font2, textcolour, g_ViBackData->x, g_ViBackData->y, 0, 0); } else { gdl = text0f153a34(gdl, x, y, x + msg->width, y + msg->height, 0); - gdl = textRender(gdl, &x, &y, msg->text, msg->font1, msg->font2, textcolour, glowcolour, viGetWidth(), viGetHeight(), 0, 0); + gdl = textRender(gdl, &x, &y, msg->text, msg->font1, msg->font2, textcolour, glowcolour, g_ViBackData->x, g_ViBackData->y, 0, 0); } if (msg->alignv == 6) { @@ -1382,8 +1370,8 @@ Gfx *hudmsgsRender(Gfx *gdl) if (msg->type == HUDMSGTYPE_CUTSCENESUBTITLE) { gDPSetScissor(gdl++, 0, - viGetViewLeft(), viGetViewTop(), - viGetViewLeft() + viGetViewWidth(), viGetViewTop() + viGetViewHeight()); + g_ViBackData->viewleft, g_ViBackData->viewtop, + g_ViBackData->viewleft + g_ViBackData->viewx, g_ViBackData->viewtop + g_ViBackData->viewy); } } diff --git a/src/game/inv.c b/src/game/inv.c index 0aed835b3..a3dee6bec 100644 --- a/src/game/inv.c +++ b/src/game/inv.c @@ -273,11 +273,7 @@ bool invHasSingleWeaponOrProp(s32 weaponnum) static s32 invAddOneIfCantHaveSlayer(s32 index) { - if (mainGetStageNum()); - - if (mainGetStageNum() != STAGE_ATTACKSHIP - && mainGetStageNum() != STAGE_SKEDARRUINS - && index >= WEAPON_SLAYER) { + if (g_StageNum != STAGE_ATTACKSHIP && g_StageNum != STAGE_SKEDARRUINS && index >= WEAPON_SLAYER) { index++; } @@ -288,7 +284,7 @@ static s32 currentStageForbidsSlayer(void) { bool value = 0; - if (mainGetStageNum() != STAGE_ATTACKSHIP && mainGetStageNum() != STAGE_SKEDARRUINS) { + if (g_StageNum != STAGE_ATTACKSHIP && g_StageNum != STAGE_SKEDARRUINS) { value++; } @@ -304,7 +300,7 @@ static bool invCanHaveAllGunsWeapon(s32 weaponnum) } // @bug: The stage conditions need an OR. This condition can never pass. - if ((mainGetStageNum() == STAGE_ATTACKSHIP && mainGetStageNum() == STAGE_SKEDARRUINS) + if ((g_StageNum == STAGE_ATTACKSHIP && g_StageNum == STAGE_SKEDARRUINS) && weaponnum == WEAPON_SLAYER) { canhave = true; } @@ -970,12 +966,12 @@ u16 invGetNameIdByIndex(s32 index) if (g_Vars.currentplayer->equipallguns) { if (index < WEAPON_PSYCHOSISGUN - currentStageForbidsSlayer()) { index++; - return bgunGetNameId(invAddOneIfCantHaveSlayer(index)); + return g_Weapons[invAddOneIfCantHaveSlayer(index)]->name; } } } - return bgunGetNameId(weaponnum); + return g_Weapons[weaponnum]->name; } char *invGetNameByIndex(s32 index) diff --git a/src/game/lv.c b/src/game/lv.c index c38471530..d8b3acc75 100644 --- a/src/game/lv.c +++ b/src/game/lv.c @@ -102,7 +102,7 @@ s32 g_MiscSfxActiveTypes[3]; struct stagetableentry *g_CurrentStage; u32 var80084010 = 0; -bool var80084014 = false; +bool g_LvIsPaused = false; s32 g_Difficulty = DIFF_A; @@ -223,7 +223,7 @@ void lvReset(s32 stagenum) g_FadeColour = 0; g_FadeDelay = 0; - var80084014 = false; + g_LvIsPaused = false; var80084010 = 0; joy00013900(); @@ -467,10 +467,10 @@ static Gfx *lvRenderFade(Gfx *gdl) gDPSetPrimColorViaWord(gdl++, 0, 0, colour); gDPFillRectangle(gdl++, - viGetViewLeft(), - viGetViewTop() + inset, - viGetViewLeft() + viGetViewWidth() + 1, - viGetViewTop() + viGetViewHeight() - inset + 2); + g_ViBackData->viewleft, + g_ViBackData->viewtop + inset, + g_ViBackData->viewleft + g_ViBackData->viewx + 1, + g_ViBackData->viewtop + g_ViBackData->viewy - inset + 2); return text0f153838(gdl); } @@ -841,11 +841,11 @@ static Gfx *lvPrintRateGraph(Gfx *gdl) if (g_FontHandelGothicXs) { x = 120 + 15; y = 7; - gdl = textRender(gdl, &x, &y, "60", g_CharsHandelGothicXs, g_FontHandelGothicXs, 0x00ff00a0, 0x000000a0, viGetWidth(), viGetHeight(), 0, 0); + gdl = textRender(gdl, &x, &y, "60", g_CharsHandelGothicXs, g_FontHandelGothicXs, 0x00ff00a0, 0x000000a0, g_ViBackData->x, g_ViBackData->y, 0, 0); x = 120 + 15; y = 37; - gdl = textRender(gdl, &x, &y, "30", g_CharsHandelGothicXs, g_FontHandelGothicXs, 0x00ff00a0, 0x000000a0, viGetWidth(), viGetHeight(), 0, 0); + gdl = textRender(gdl, &x, &y, "30", g_CharsHandelGothicXs, g_FontHandelGothicXs, 0x00ff00a0, 0x000000a0, g_ViBackData->x, g_ViBackData->y, 0, 0); } return gdl; @@ -882,19 +882,19 @@ static Gfx *lvPrintCounter(Gfx *gdl, s32 *y, char *label, u32 cycles, u32 cycles // Label x = 10; - gdl = textRender(gdl, &x, y, label, g_CharsHandelGothicXs, g_FontHandelGothicXs, colour, 0x000000a0, viGetWidth(), viGetHeight(), 0, 0); + gdl = textRender(gdl, &x, y, label, g_CharsHandelGothicXs, g_FontHandelGothicXs, colour, 0x000000a0, g_ViBackData->x, g_ViBackData->y, 0, 0); // Microseconds sprintf(buffer, "%d", microseconds); textMeasure(&textheight, &textwidth, buffer, g_CharsHandelGothicXs, g_FontHandelGothicXs, 0); x = 80 - textwidth; - gdl = textRender(gdl, &x, y, buffer, g_CharsHandelGothicXs, g_FontHandelGothicXs, colour, 0x000000a0, viGetWidth(), viGetHeight(), 0, 0); + gdl = textRender(gdl, &x, y, buffer, g_CharsHandelGothicXs, g_FontHandelGothicXs, colour, 0x000000a0, g_ViBackData->x, g_ViBackData->y, 0, 0); // Percentage sprintf(buffer, "(%d%%)\n", percentage); textMeasure(&textheight, &textwidth, buffer, g_CharsHandelGothicXs, g_FontHandelGothicXs, 0); x = 120 - textwidth; - gdl = textRender(gdl, &x, y, buffer, g_CharsHandelGothicXs, g_FontHandelGothicXs, colour, 0x000000a0, viGetWidth(), viGetHeight(), 0, 0); + gdl = textRender(gdl, &x, y, buffer, g_CharsHandelGothicXs, g_FontHandelGothicXs, colour, 0x000000a0, g_ViBackData->x, g_ViBackData->y, 0, 0); // Line gdl = textSetPrimColour(gdl, colour); @@ -938,19 +938,19 @@ static Gfx *lvPrintRateText(Gfx *gdl) if (count) { x = 10; sprintf(buffer, "min %d", min); - gdl = textRender(gdl, &x, &y, buffer, g_CharsHandelGothicXs, g_FontHandelGothicXs, 0x00ff00a0, 0x000000a0, viGetWidth(), viGetHeight(), 0, 0); + gdl = textRender(gdl, &x, &y, buffer, g_CharsHandelGothicXs, g_FontHandelGothicXs, 0x00ff00a0, 0x000000a0, g_ViBackData->x, g_ViBackData->y, 0, 0); x = 50; sprintf(buffer, "max %d", max); - gdl = textRender(gdl, &x, &y, buffer, g_CharsHandelGothicXs, g_FontHandelGothicXs, 0x00ff00a0, 0x000000a0, viGetWidth(), viGetHeight(), 0, 0); + gdl = textRender(gdl, &x, &y, buffer, g_CharsHandelGothicXs, g_FontHandelGothicXs, 0x00ff00a0, 0x000000a0, g_ViBackData->x, g_ViBackData->y, 0, 0); x = 90; sprintf(buffer, "avg %d", sum / count); - gdl = textRender(gdl, &x, &y, buffer, g_CharsHandelGothicXs, g_FontHandelGothicXs, 0x00ff00a0, 0x000000a0, viGetWidth(), viGetHeight(), 0, 0); + gdl = textRender(gdl, &x, &y, buffer, g_CharsHandelGothicXs, g_FontHandelGothicXs, 0x00ff00a0, 0x000000a0, g_ViBackData->x, g_ViBackData->y, 0, 0); x = 130; sprintf(buffer, "cur %d\n\n", (s32) (OS_CPU_COUNTER / g_Vars.diffframet)); - gdl = textRender(gdl, &x, &y, buffer, g_CharsHandelGothicXs, g_FontHandelGothicXs, 0x00ff00a0, 0x000000a0, viGetWidth(), viGetHeight(), 0, 0); + gdl = textRender(gdl, &x, &y, buffer, g_CharsHandelGothicXs, g_FontHandelGothicXs, 0x00ff00a0, 0x000000a0, g_ViBackData->x, g_ViBackData->y, 0, 0); } { @@ -965,28 +965,28 @@ static Gfx *lvPrintRateText(Gfx *gdl) gdl = lvPrintCounter(gdl, &y, " main", counters[3], OS_CPU_COUNTER); gdl = lvPrintCounter(gdl, &y, " sched", counters[4], OS_CPU_COUNTER); - gdl = textRender(gdl, &x, &y, "\n", g_CharsHandelGothicXs, g_FontHandelGothicXs, 0x00ff00a0, 0x000000a0, viGetWidth(), viGetHeight(), 0, 0); + gdl = textRender(gdl, &x, &y, "\n", g_CharsHandelGothicXs, g_FontHandelGothicXs, 0x00ff00a0, 0x000000a0, g_ViBackData->x, g_ViBackData->y, 0, 0); } x = 10; if (g_ScBottleneck == 'C') { - gdl = textRender(gdl, &x, &y, "bottleneck CPU\n\n", g_CharsHandelGothicXs, g_FontHandelGothicXs, 0x3333ffa0, 0x000000a0, viGetWidth(), viGetHeight(), 0, 0); + gdl = textRender(gdl, &x, &y, "bottleneck CPU\n\n", g_CharsHandelGothicXs, g_FontHandelGothicXs, 0x3333ffa0, 0x000000a0, g_ViBackData->x, g_ViBackData->y, 0, 0); } else if (g_ScBottleneck == 'R') { - gdl = textRender(gdl, &x, &y, "bottleneck RDP\n\n", g_CharsHandelGothicXs, g_FontHandelGothicXs, 0xff0000a0, 0x000000a0, viGetWidth(), viGetHeight(), 0, 0); + gdl = textRender(gdl, &x, &y, "bottleneck RDP\n\n", g_CharsHandelGothicXs, g_FontHandelGothicXs, 0xff0000a0, 0x000000a0, g_ViBackData->x, g_ViBackData->y, 0, 0); } else if (g_ScBottleneck == 'V') { - gdl = textRender(gdl, &x, &y, "bottleneck VI\n\n", g_CharsHandelGothicXs, g_FontHandelGothicXs, 0x00ff00a0, 0x000000a0, viGetWidth(), viGetHeight(), 0, 0); + gdl = textRender(gdl, &x, &y, "bottleneck VI\n\n", g_CharsHandelGothicXs, g_FontHandelGothicXs, 0x00ff00a0, 0x000000a0, g_ViBackData->x, g_ViBackData->y, 0, 0); } sprintf(buffer, "mema free %d KB\n", memaGetLongestFree() / 1024); - gdl = textRender(gdl, &x, &y, buffer, g_CharsHandelGothicXs, g_FontHandelGothicXs, 0x00ff00a0, 0x000000a0, viGetWidth(), viGetHeight(), 0, 0); + gdl = textRender(gdl, &x, &y, buffer, g_CharsHandelGothicXs, g_FontHandelGothicXs, 0x00ff00a0, 0x000000a0, g_ViBackData->x, g_ViBackData->y, 0, 0); sprintf(buffer, "memp free %d KB\n", mempGetStageFree() / 1024); - gdl = textRender(gdl, &x, &y, buffer, g_CharsHandelGothicXs, g_FontHandelGothicXs, 0x00ff00a0, 0x000000a0, viGetWidth(), viGetHeight(), 0, 0); + gdl = textRender(gdl, &x, &y, buffer, g_CharsHandelGothicXs, g_FontHandelGothicXs, 0x00ff00a0, 0x000000a0, g_ViBackData->x, g_ViBackData->y, 0, 0); if (g_LvOom) { sprintf(buffer, "mem%c OOM %x\n", g_LvOom, g_LvOomSize); - gdl = textRender(gdl, &x, &y, buffer, g_CharsHandelGothicXs, g_FontHandelGothicXs, 0xff0000a0, 0x000000a0, viGetWidth(), viGetHeight(), 0, 0); + gdl = textRender(gdl, &x, &y, buffer, g_CharsHandelGothicXs, g_FontHandelGothicXs, 0xff0000a0, 0x000000a0, g_ViBackData->x, g_ViBackData->y, 0, 0); } } @@ -1061,9 +1061,9 @@ Gfx *lvRender(Gfx *gdl) gdl = vi0000b1d0(gdl); gDPSetScissorFrac(gdl++, 0, - viGetViewLeft() * 4.0f, viGetViewTop() * 4.0f, - (viGetViewLeft() + viGetViewWidth()) * 4.0f, - (viGetViewTop() + viGetViewHeight()) * 4.0f); + g_ViBackData->viewleft * 4.0f, g_ViBackData->viewtop * 4.0f, + (g_ViBackData->viewleft + g_ViBackData->viewx) * 4.0f, + (g_ViBackData->viewtop + g_ViBackData->viewy) * 4.0f); gdl = titleRender(gdl); gdl = lvRenderFade(gdl); @@ -1076,7 +1076,7 @@ Gfx *lvRender(Gfx *gdl) viSetViewPosition(g_Vars.currentplayer->viewleft, g_Vars.currentplayer->viewtop); viSetFovAspectAndSize(g_Vars.currentplayer->fovy, g_Vars.currentplayer->aspect, g_Vars.currentplayer->viewwidth, g_Vars.currentplayer->viewheight); - mtx00016748(1); + var8005ef10[0] = 65536; gdl = vi0000b1d0(gdl); gdl = viRenderViewportEdges(gdl); @@ -1094,7 +1094,7 @@ Gfx *lvRender(Gfx *gdl) viSetFovAspectAndSize(g_Vars.currentplayer->fovy, g_Vars.currentplayer->aspect, g_Vars.currentplayer->viewwidth, g_Vars.currentplayer->viewheight); - mtx00016748(1); + var8005ef10[0] = 65536; gdl = vi0000b1d0(gdl); gdl = currentPlayerScissorToViewport(gdl); @@ -1112,7 +1112,7 @@ Gfx *lvRender(Gfx *gdl) viSetViewPosition(g_Vars.currentplayer->viewleft, g_Vars.currentplayer->viewtop); viSetFovAspectAndSize(g_Vars.currentplayer->fovy, g_Vars.currentplayer->aspect, g_Vars.currentplayer->viewwidth, g_Vars.currentplayer->viewheight); - mtx00016748(1); + var8005ef10[0] = 65536; gdl = vi0000b1a8(gdl); gdl = vi0000b1d0(gdl); @@ -1184,7 +1184,7 @@ Gfx *lvRender(Gfx *gdl) viSetViewPosition(g_Vars.currentplayer->viewleft, g_Vars.currentplayer->viewtop); viSetFovAspectAndSize(g_Vars.currentplayer->fovy, g_Vars.currentplayer->aspect, g_Vars.currentplayer->viewwidth, g_Vars.currentplayer->viewheight); - mtx00016748(g_Vars.currentplayerstats->scale_bg2gfx); + var8005ef10[0] = 65536 * g_Vars.currentplayerstats->scale_bg2gfx; env0f1657f8(); mblur0f176298(); gdl = vi0000b280(gdl); @@ -1217,7 +1217,7 @@ Gfx *lvRender(Gfx *gdl) } else if (var8009dfc0) { gdl = viRenderViewportEdges(gdl); gdl = currentPlayerScissorToViewport(gdl); - mtx00016748(1); + var8005ef10[0] = 65536; if (g_Vars.currentplayer->menuisactive) { PROFILE(PROFILEMARKER_LVR_MENU, gdl = menuRender(gdl)); @@ -1243,7 +1243,7 @@ Gfx *lvRender(Gfx *gdl) // we are using the R-aimer in 1 player combat simulator, or // we are using the R-aimer in 2+ player combat simulator with a gun that uses prop tracking, or // we are playing Holo 1 (Looking Around), which uses lookingatprop - if ((bmoveIsInSightAimMode() && ( + if ((g_Vars.currentplayer->insightaimmode && ( PLAYERCOUNT() == 1 || !g_Vars.normmplayerisrunning || weaponHasFlag(bgunGetWeaponNum(HAND_RIGHT), WEAPONFLAG_AIMTRACK))) || (g_Vars.stagenum == STAGE_CITRAINING && (g_StageFlags & 0x00040000))) { g_Vars.currentplayer->lookingatprop.prop = func0f061d54(HAND_RIGHT, 0, 0); @@ -1290,7 +1290,7 @@ Gfx *lvRender(Gfx *gdl) if (frIsInTraining() && g_Vars.currentplayer->lookingatprop.prop - && bmoveIsInSightAimMode()) { + && g_Vars.currentplayer->insightaimmode) { func0f1a0924(g_Vars.currentplayer->lookingatprop.prop); } else if (lvUpdateTrackedProp(&g_Vars.currentplayer->lookingatprop, -1) == 0) { g_Vars.currentplayer->lookingatprop.prop = NULL; @@ -1552,9 +1552,9 @@ Gfx *lvRender(Gfx *gdl) if (alpha) { gdl = text0f153628(gdl); gdl = text0f153a34(gdl, - viGetViewLeft(), viGetViewTop(), - viGetViewLeft() + viGetViewWidth(), - viGetViewTop() + viGetViewHeight(), 0xffffff00 | alpha); + g_ViBackData->viewleft, g_ViBackData->viewtop, + g_ViBackData->viewleft + g_ViBackData->viewx, + g_ViBackData->viewtop + g_ViBackData->viewy, 0xffffff00 | alpha); gdl = text0f153780(gdl); } } @@ -1573,13 +1573,13 @@ Gfx *lvRender(Gfx *gdl) PROFILE(PROFILEMARKER_LVR_ACTIVEMENU, gdl = amRender(gdl)); } - mtx00016748(1); + var8005ef10[0] = 65536; if (g_Vars.currentplayer->menuisactive) { PROFILE(PROFILEMARKER_LVR_MENU, gdl = menuRender(gdl)); } - mtx00016748(g_Vars.currentplayerstats->scale_bg2gfx); + var8005ef10[0] = 65536 * g_Vars.currentplayerstats->scale_bg2gfx; if (g_Vars.mplayerisrunning) { gdl = mpRenderModalText(gdl); @@ -1647,7 +1647,7 @@ Gfx *lvRender(Gfx *gdl) } } - gDPSetScissor(gdl++, G_SC_NON_INTERLACE, 0, 0, viGetWidth(), viGetHeight()); + gDPSetScissor(gdl++, G_SC_NON_INTERLACE, 0, 0, g_ViBackData->x, g_ViBackData->y); gdl = lvPrint(gdl); @@ -1848,7 +1848,7 @@ void lvTick(void) g_Vars.players[j]->hands[HAND_RIGHT].hasdotinfo = false; } - if (lvIsPaused()) { + if (g_LvIsPaused) { g_Vars.lvupdate240 = 0; } else if (mpIsPaused()) { g_Vars.lvupdate240 = 0; @@ -1999,7 +1999,7 @@ void lvTick(void) break; case 3: // sounding alarm and waiting for match end { - if (g_MiscAudioHandle == NULL && !lvIsPaused()) { + if (g_MiscAudioHandle == NULL && !g_LvIsPaused) { snd00010718(&g_MiscAudioHandle, 0, 0x7fff, 0x40, SFX_ALARM_DEFAULT, 1, 1, -1, 1); } @@ -2066,7 +2066,7 @@ void lvTick(void) g_StageTimeElapsed60 += g_Vars.lvupdate60; - viSetUseZBuf(true); + g_ViBackData->usezbuf = true; if (g_Vars.stagenum == STAGE_TITLE) { titleTick(); @@ -2129,7 +2129,7 @@ void lvTick(void) PROFILE(PROFILEMARKER_LVT_MUSIC, musicTick()); PROFILE(PROFILEMARKER_LVT_PADEFFECTS, propsTickPadEffects()); - if (mainGetStageNum() == STAGE_CITRAINING) { + if (g_StageNum == STAGE_CITRAINING) { struct trainingdata *trainingdata = dtGetData(); if ((g_Vars.currentplayer->prop->rooms[0] < ROOM_DISH_HOLO1 || g_Vars.currentplayer->prop->rooms[0] > ROOM_DISH_HOLO4) @@ -2227,17 +2227,7 @@ void lvSetPaused(bool paused) pakEnableRumbleForAllPlayers(); } - var80084014 = paused; -} - -bool lvIsPaused(void) -{ - return var80084014; -} - -s32 lvGetDifficulty(void) -{ - return g_Difficulty; + g_LvIsPaused = paused; } void lvSetDifficulty(s32 difficulty) @@ -2263,8 +2253,3 @@ void lvSetMpTeamScoreLimit(u32 limit) { g_MpTeamScoreLimit = limit; } - -s32 lvGetStageTime60(void) -{ - return g_StageTimeElapsed60; -} diff --git a/src/game/mainmenu.c b/src/game/mainmenu.c index 437088e49..d472309d1 100644 --- a/src/game/mainmenu.c +++ b/src/game/mainmenu.c @@ -11,6 +11,7 @@ #include "game/player.h" #include "game/menu.h" #include "game/mainmenu.h" +#include "game/music.h" #include "game/filemgr.h" #include "game/inv.h" #include "game/game_1531a0.h" @@ -81,7 +82,7 @@ static s32 menuhandlerControlStyleImpl(s32 operation, struct menuitem *item, uni g_Vars.modifiedfiles |= MODFILE_GAME; break; case MENUOP_GETSELECTEDINDEX: - data->list.value = optionsGetControlMode(mpindex); + data->list.value = g_PlayerConfigsArray[mpindex].controlmode; g_Menus[g_MpPlayerNum].main.mpindex = mpindex; break; case MENUOP_LISTITEMFOCUS: @@ -175,7 +176,7 @@ static s32 menuhandlerScreenSize(s32 operation, struct menuitem *item, union han case MENUOP_GETOPTIONTEXT: return (s32) langGet(L_OPTIONS_220 + data->dropdown.value); case MENUOP_SET: - optionsSetScreenSize(data->dropdown.value); + g_ScreenSize = data->dropdown.value; g_Vars.modifiedfiles |= MODFILE_GAME; break; case MENUOP_GETSELECTEDINDEX: @@ -194,11 +195,11 @@ s32 menuhandlerScreenRatio(s32 operation, struct menuitem *item, union handlerda case MENUOP_GETOPTIONTEXT: return (s32) langGet(L_OPTIONS_223 + data->dropdown.value); case MENUOP_SET: - optionsSetScreenRatio(data->dropdown.value); + g_ScreenRatio = data->dropdown.value; g_Vars.modifiedfiles |= MODFILE_GAME; break; case MENUOP_GETSELECTEDINDEX: - data->dropdown.value = optionsGetScreenRatio(); + data->dropdown.value = g_ScreenRatio; } return 0; @@ -213,8 +214,8 @@ s32 menuhandlerScreenSplit(s32 operation, struct menuitem *item, union handlerda case MENUOP_GETOPTIONTEXT: return (s32) langGet(L_OPTIONS_225 + data->dropdown.value); case MENUOP_SET: - if (data->dropdown.value != (u32)optionsGetScreenSplit()) { - optionsSetScreenSplit(data->dropdown.value); + if (data->dropdown.value != (u32)g_ScreenSplit) { + g_ScreenSplit = data->dropdown.value; g_Vars.modifiedfiles |= MODFILE_GAME; @@ -229,7 +230,7 @@ s32 menuhandlerScreenSplit(s32 operation, struct menuitem *item, union handlerda } break; case MENUOP_GETSELECTEDINDEX: - data->dropdown.value = optionsGetScreenSplit(); + data->dropdown.value = g_ScreenSplit; break; } @@ -282,9 +283,9 @@ static s32 menuhandlerInGameSubtitles(s32 operation, struct menuitem *item, unio { switch (operation) { case MENUOP_GET: - return optionsGetInGameSubtitles(); + return g_InGameSubtitles; case MENUOP_SET: - optionsSetInGameSubtitles(data->checkbox.value); + g_InGameSubtitles = data->checkbox.value; g_Vars.modifiedfiles |= MODFILE_GAME; } @@ -295,9 +296,9 @@ static s32 menuhandlerCutsceneSubtitles(s32 operation, struct menuitem *item, un { switch (operation) { case MENUOP_GET: - return optionsGetCutsceneSubtitles(); + return g_CutsceneSubtitles; case MENUOP_SET: - optionsSetCutsceneSubtitles(data->checkbox.value); + g_CutsceneSubtitles = data->checkbox.value; g_Vars.modifiedfiles |= MODFILE_GAME; } @@ -509,10 +510,10 @@ s32 menuhandlerMusicVolume(s32 operation, struct menuitem *item, union handlerda { switch (operation) { case MENUOP_GETSLIDER: - data->slider.value = optionsGetMusicVolume(); + data->slider.value = musicGetVolume(); break; case MENUOP_SET: - optionsSetMusicVolume(data->slider.value); + musicSetVolume(data->slider.value); g_Vars.modifiedfiles |= MODFILE_GAME; } @@ -1867,13 +1868,13 @@ static s32 menuhandlerMissionList(s32 operation, struct menuitem *item, union ha strcat(text, "\n"); gdl = textRenderProjected(gdl, &x, &y, text, g_CharsHandelGothicMd, g_FontHandelGothicMd, - renderdata->colour, viGetWidth(), viGetHeight(), 0, 0); + renderdata->colour, g_ViBackData->x, g_ViBackData->y, 0, 0); // Draw last part of name strcpy(text, langGet(g_StageNames[stageindex].name2)); gdl = textRenderProjected(gdl, &x, &y, text, g_CharsHandelGothicSm, g_FontHandelGothicSm, - renderdata->colour, viGetWidth(), viGetHeight(), 0, 0); + renderdata->colour, g_ViBackData->x, g_ViBackData->y, 0, 0); gdl = text0f153780(gdl); @@ -3547,7 +3548,7 @@ static char *invMenuTextWeaponDescription(struct menuitem *item) if (g_InventoryWeapon == WEAPON_NECKLACE && g_Vars.stagenum == STAGE_ATTACKSHIP - && lvGetDifficulty() >= DIFF_PA) { + && g_Difficulty >= DIFF_PA) { // Phrases included here to assist people searching the code for them: // CDV780322 // I8MOZYM8NDI85 @@ -3955,11 +3956,11 @@ s32 soloMenuDialogPauseStatus(s32 operation, struct menudialogdef *dialogdef, un s32 wanttype = BRIEFINGTYPE_TEXT_PA; s32 i; - if (lvGetDifficulty() == DIFF_A) { + if (g_Difficulty == DIFF_A) { wanttype = BRIEFINGTYPE_TEXT_A; } - if (lvGetDifficulty() == DIFF_SA) { + if (g_Difficulty == DIFF_SA) { wanttype = BRIEFINGTYPE_TEXT_SA; } @@ -3978,7 +3979,7 @@ s32 soloMenuDialogPauseStatus(s32 operation, struct menudialogdef *dialogdef, un briefing = briefing->next; } - for (i = 0; i < objectiveGetCount(); i++) { + for (i = 0; i < (g_ObjectiveLastIndex + 1); i++) { if (g_Objectives[i]) { g_Briefing.objectivenames[i] = g_Objectives[i]->text; g_Briefing.objectivedifficulties[i] = objectiveGetDifficultyBits(i); diff --git a/src/game/menu.c b/src/game/menu.c index 1d191fd68..25b263ba7 100644 --- a/src/game/menu.c +++ b/src/game/menu.c @@ -308,32 +308,32 @@ static Gfx *menuRenderBanner(Gfx *gdl, s32 x1, s32 y1, s32 x2, s32 y2, bool big, x = midx - textwidth / 2 + 2; y += 2; gdl = textRenderProjected(gdl, &x, &y, langGet(msgs[msgnum]), - chars, font, 0x000000ff, viGetWidth(), viGetWidth(), 0, 0); + chars, font, 0x000000ff, g_ViBackData->x, g_ViBackData->x, 0, 0); // Render "Please Wait..." shadow x = midx - waitwidth / 2 + 2; y += 3; gdl = textRenderProjected(gdl, &x, &y, langGet(L_MPMENU_495), - chars, font, 0x000000ff, viGetWidth(), viGetWidth(), 0, 0); + chars, font, 0x000000ff, g_ViBackData->x, g_ViBackData->x, 0, 0); // Render the selected message proper x = midx - textwidth / 2; y = texttop; gdl = textRenderProjected(gdl, &x, &y, langGet(msgs[msgnum]), - chars, font, 0xbfbfffff, viGetWidth(), viGetWidth(), 0, 0); + chars, font, 0xbfbfffff, g_ViBackData->x, g_ViBackData->x, 0, 0); // Render "Please Wait..." proper x = midx - waitwidth / 2; y += 3; gdl = textRenderProjected(gdl, &x, &y, langGet(L_MPMENU_495), - chars, font, 0xbfbfffff, viGetWidth(), viGetWidth(), 0, 0); + chars, font, 0xbfbfffff, g_ViBackData->x, g_ViBackData->x, 0, 0); if (msgs[msgnum] == L_MPMENU_491) { // "Checking Controller Pak" // Render "TM" y = texttop - 1; x = textwidth / 2 + midx - 7; gdl = textRenderProjected(gdl, &x, &y, "TM", - g_CharsHandelGothicXs, g_FontHandelGothicXs, 0xbfbfffff, viGetWidth(), viGetWidth(), 0, 0); + g_CharsHandelGothicXs, g_FontHandelGothicXs, 0xbfbfffff, g_ViBackData->x, g_ViBackData->x, 0, 0); } gdl = text0f153780(gdl); @@ -679,7 +679,7 @@ static void menuCalculateItemSize(struct menuitem *item, s16 *width, s16 *height *width = 240; for (i = 0; i < 6; i++) { - if (g_Briefing.objectivenames[i] && (g_Briefing.objectivedifficulties[i] & (1 << lvGetDifficulty()))) { + if (g_Briefing.objectivenames[i] && (g_Briefing.objectivedifficulties[i] & (1 << g_Difficulty))) { numobjectives++; } } @@ -1308,8 +1308,8 @@ void menuPushDialog(struct menudialogdef *dialogdef) menuOpenDialog(dialogdef, dialog, &g_Menus[g_MpPlayerNum]); - dialog->dstx = (viGetWidth() - dialog->width) / 2; - dialog->dsty = (viGetHeight() - dialog->height) / 2; + dialog->dstx = (g_ViBackData->x - dialog->width) / 2; + dialog->dsty = (g_ViBackData->y - dialog->height) / 2; g_Menus[g_MpPlayerNum].fm.unke40_00 = true; sibling = dialogdef->nextsibling; @@ -1329,7 +1329,7 @@ void menuPushDialog(struct menudialogdef *dialogdef) menuOpenDialog(sibling, dialog, &g_Menus[g_MpPlayerNum]); dialog->dstx = dialog->x = -320; - dialog->dsty = dialog->y = (viGetHeight() - dialog->height) / 2; + dialog->dsty = dialog->y = (g_ViBackData->y - dialog->height) / 2; dialog->type = 0; sibling = sibling->nextsibling; @@ -1576,7 +1576,7 @@ Gfx *menuRenderModels(Gfx *gdl, struct menu840 *thing, s32 arg2) if (thing->unk004 == NULL) { if (bgun0f09e004(1)) { - thing->unk004 = bgunGetGunMem(); + thing->unk004 = g_Vars.currentplayer->gunctrl.gunmem; thing->unk008 = bgunCalculateGunMemCapacity(); } else { return gdl; @@ -1902,8 +1902,8 @@ Gfx *menuRenderModels(Gfx *gdl, struct menu840 *thing, s32 arg2) sp390[0] = thing->unk510; sp390[1] = thing->unk514; } else { - sp390[0] = sp430 + viGetViewLeft() + viGetViewWidth() * 0.5f; - sp390[1] = sp42c + viGetViewTop() + viGetViewHeight() * 0.5f; + sp390[0] = sp430 + g_ViBackData->viewleft + g_ViBackData->viewx * 0.5f; + sp390[1] = sp42c + g_ViBackData->viewtop + g_ViBackData->viewy * 0.5f; } cam0f0b4c3c(sp390, &sp398, 1.0f); @@ -1980,7 +1980,7 @@ Gfx *menuRenderModels(Gfx *gdl, struct menu840 *thing, s32 arg2) if (arg2 < 3) { if (arg2 != 0) { gdl = func0f0d49c8(gdl); - gSPMatrix(gdl++, osVirtualToPhysical(camGetPerspectiveMtxL()), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_PROJECTION); + gSPMatrix(gdl++, osVirtualToPhysical(g_Vars.currentplayer->perspmtxl), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_PROJECTION); } else { f32 aspect = (f32) (g_MenuScissorX2 - g_MenuScissorX1) / (f32) (g_MenuScissorY2 - g_MenuScissorY1); u32 znear = 10; @@ -2089,15 +2089,15 @@ Gfx *menuRenderModels(Gfx *gdl, struct menu840 *thing, s32 arg2) spd0.z = sp3b4[index].m[3][2]; cam0f0b4d04(&spd0, spc8); - var8009de98 = (s32)spc8[0] - viGetWidth() / 2; - var8009de9c = (s32)spc8[1] - viGetHeight() / 2; + var8009de98 = (s32)spc8[0] - g_ViBackData->x / 2; + var8009de9c = (s32)spc8[1] - g_ViBackData->y / 2; } } } gSPSetLights1(gdl++, var80071468); - gSPLookAtX(gdl++, &camGetLookAt()->l[0]); - gSPLookAtY(gdl++, &camGetLookAt()->l[1]); + gSPLookAtX(gdl++, &g_Vars.currentplayer->lookat->l[0]); + gSPLookAtY(gdl++, &g_Vars.currentplayer->lookat->l[1]); renderdata.unk30 = 1; renderdata.envcolour = 0xffffffff; @@ -2118,7 +2118,7 @@ Gfx *menuRenderModels(Gfx *gdl, struct menu840 *thing, s32 arg2) mtx00016054(&sp70, &thing->bodymodel.matrices[i]); } - mtx00016784(); + var8005ef10[0] = g_Vars.unk000510; if (arg2 < 3) { gdl = func0f0d479c(gdl); @@ -2187,20 +2187,20 @@ Gfx *menuApplyScissor(Gfx *gdl) g_ScissorY2 = 0; } - if (g_ScissorX1 > viGetBufWidth()) { - g_ScissorX1 = viGetBufWidth(); + if (g_ScissorX1 > g_ViBackData->bufx) { + g_ScissorX1 = g_ViBackData->bufx; } - if (g_ScissorX2 > viGetBufWidth()) { - g_ScissorX2 = viGetBufWidth(); + if (g_ScissorX2 > g_ViBackData->bufx) { + g_ScissorX2 = g_ViBackData->bufx; } - if (g_ScissorY1 > viGetBufHeight()) { - g_ScissorY1 = viGetBufHeight(); + if (g_ScissorY1 > g_ViBackData->bufy) { + g_ScissorY1 = g_ViBackData->bufy; } - if (g_ScissorY2 > viGetBufHeight()) { - g_ScissorY2 = viGetBufHeight(); + if (g_ScissorY2 > g_ViBackData->bufy) { + g_ScissorY2 = g_ViBackData->bufy; } if (g_ScissorX2 < g_ScissorX1) { @@ -2379,13 +2379,13 @@ static Gfx *dialogRender(Gfx *gdl, struct menudialog *dialog, struct menu *menu, x = dialogleft + 3; y = dialogtop + 3; - gdl = textRenderProjected(gdl, &x, &y, title, g_CharsHandelGothicSm, g_FontHandelGothicSm, colour1 & 0xff, dialogwidth, viGetHeight(), 0, 0); + gdl = textRenderProjected(gdl, &x, &y, title, g_CharsHandelGothicSm, g_FontHandelGothicSm, colour1 & 0xff, dialogwidth, g_ViBackData->y, 0, 0); // Title proper x = dialogleft + 2; y = dialogtop + 2; - gdl = textRenderProjected(gdl, &x, &y, title, g_CharsHandelGothicSm, g_FontHandelGothicSm, colour1, dialogwidth, viGetHeight(), 0, 0); + gdl = textRenderProjected(gdl, &x, &y, title, g_CharsHandelGothicSm, g_FontHandelGothicSm, colour1, dialogwidth, g_ViBackData->y, 0, 0); // In MP dialogs, render the player number in the top right if (g_MenuData.root == MENUROOT_MPSETUP @@ -2395,7 +2395,7 @@ static Gfx *dialogRender(Gfx *gdl, struct menudialog *dialog, struct menu *menu, x = dialogright - 9; y = dialogtop + 2; - gdl = textRenderProjected(gdl, &x, &y, sp154[g_MpPlayerNum], g_CharsHandelGothicSm, g_FontHandelGothicSm, colour1, dialogwidth, viGetHeight(), 0, 0); + gdl = textRenderProjected(gdl, &x, &y, sp154[g_MpPlayerNum], g_CharsHandelGothicSm, g_FontHandelGothicSm, colour1, dialogwidth, g_ViBackData->y, 0, 0); } } @@ -2451,10 +2451,10 @@ static Gfx *dialogRender(Gfx *gdl, struct menudialog *dialog, struct menu *menu, { struct menulayer *layer; - s32 viewleft = viGetViewLeft(); - s32 viewtop = viGetViewTop(); - s32 viewright = (viGetViewLeft() + viGetViewWidth()); - s32 viewbottom = viGetViewTop() + viGetViewHeight(); + s32 viewleft = g_ViBackData->viewleft; + s32 viewtop = g_ViBackData->viewtop; + s32 viewright = (g_ViBackData->viewleft + g_ViBackData->viewx); + s32 viewbottom = g_ViBackData->viewtop + g_ViBackData->viewy; g_MenuScissorX1 = dialogleft + 2; g_MenuScissorX2 = dialogright - 2; @@ -2718,11 +2718,11 @@ static Gfx *dialogRender(Gfx *gdl, struct menudialog *dialog, struct menu *menu, gdl = text0f153838(gdl); } - gDPSetScissor(gdl++, G_SC_NON_INTERLACE, viGetViewLeft(), viGetViewTop(), - viGetViewLeft() + viGetViewWidth(), viGetViewTop() + viGetViewHeight()); + gDPSetScissor(gdl++, G_SC_NON_INTERLACE, g_ViBackData->viewleft, g_ViBackData->viewtop, + g_ViBackData->viewleft + g_ViBackData->viewx, g_ViBackData->viewtop + g_ViBackData->viewy); } else { - gDPSetScissor(gdl++, G_SC_NON_INTERLACE, viGetViewLeft(), viGetViewTop(), - viGetViewLeft() + viGetViewWidth(), viGetViewTop() + viGetViewHeight()); + gDPSetScissor(gdl++, G_SC_NON_INTERLACE, g_ViBackData->viewleft, g_ViBackData->viewtop, + g_ViBackData->viewleft + g_ViBackData->viewx, g_ViBackData->viewtop + g_ViBackData->viewy); } // Render left/right chevrons and sibling dialog titles @@ -2776,7 +2776,7 @@ static Gfx *dialogRender(Gfx *gdl, struct menudialog *dialog, struct menu *menu, x -= 3; } - gdl = textRenderProjected(gdl, &y, &x, title, g_CharsHandelGothicXs, g_FontHandelGothicXs, 0xffffffff, dialogwidth, viGetHeight(), 0, 0); + gdl = textRenderProjected(gdl, &y, &x, title, g_CharsHandelGothicXs, g_FontHandelGothicXs, 0xffffffff, dialogwidth, g_ViBackData->y, 0, 0); // Right/next title nextindex = layer->cursibling + 1; @@ -2797,7 +2797,7 @@ static Gfx *dialogRender(Gfx *gdl, struct menudialog *dialog, struct menu *menu, x += 3; } - gdl = textRenderProjected(gdl, &y, &x, title, g_CharsHandelGothicXs, g_FontHandelGothicXs, -1, dialogwidth, viGetHeight(), 0, 0); + gdl = textRenderProjected(gdl, &y, &x, title, g_CharsHandelGothicXs, g_FontHandelGothicXs, -1, dialogwidth, g_ViBackData->y, 0, 0); gdl = text0f153780(gdl); textSetRotation90(false); @@ -2821,14 +2821,14 @@ static void menuGetContPads(s8 *contpadnum1, s8 *contpadnum2) *contpadnum2 = -1; break; default: - *contpadnum1 = optionsGetContpadNum1(g_Vars.currentplayerstats->mpindex); + *contpadnum1 = g_PlayerConfigsArray[g_Vars.currentplayerstats->mpindex].contpad1; *contpadnum2 = -1; if (!g_Vars.normmplayerisrunning) { - s32 mode = optionsGetControlMode(g_Vars.currentplayerstats->mpindex); + s32 mode = g_PlayerConfigsArray[g_Vars.currentplayerstats->mpindex].controlmode; - if (mode == CONTROLMODE_23 || mode == CONTROLMODE_24 || mode == CONTROLMODE_22 || mode == CONTROLMODE_21) { - *contpadnum2 = optionsGetContpadNum2(g_Vars.currentplayerstats->mpindex); + if (mode >= CONTROLMODE_21) { + *contpadnum2 = g_PlayerConfigsArray[g_Vars.currentplayerstats->mpindex].contpad2; } } break; @@ -2916,10 +2916,10 @@ static void func0f0f7594(s32 arg0, s32 *vdir, s32 *hdir) */ static void menuFindAvailableSize(s32 *leftptr, s32 *topptr, s32 *rightptr, s32 *bottomptr) { - s32 left = viGetViewLeft() + 20; - s32 top = viGetViewTop() + 4; - s32 right = (viGetViewLeft() + viGetViewWidth()) - 20; - s32 bottom = viGetViewTop() + viGetViewHeight() - 4; + s32 left = g_ViBackData->viewleft + 20; + s32 top = g_ViBackData->viewtop + 4; + s32 right = (g_ViBackData->viewleft + g_ViBackData->viewx) - 20; + s32 bottom = g_ViBackData->viewtop + g_ViBackData->viewy - 4; s32 playernum; u32 stack[2]; @@ -3024,7 +3024,7 @@ static void menuFindAvailableSize(s32 *leftptr, s32 *topptr, s32 *rightptr, s32 } } - if (PLAYERCOUNT() == 2 && optionsGetScreenSplit() == SCREENSPLIT_VERTICAL) { + if (PLAYERCOUNT() == 2 && g_ScreenSplit == SCREENSPLIT_VERTICAL) { if (g_Menus[g_MpPlayerNum].playernum == 0) { *leftptr += 22; } else { @@ -3078,7 +3078,7 @@ static void dialogCalculatePosition(struct menudialog *dialog) } if (hdir > 0) { - dialog->dstx = (viGetViewLeft() + viGetViewWidth()) + 4; + dialog->dstx = (g_ViBackData->viewleft + g_ViBackData->viewx) + 4; } if (vdir < 0) { @@ -3086,7 +3086,7 @@ static void dialogCalculatePosition(struct menudialog *dialog) } if (vdir > 0) { - dialog->dsty = viGetViewTop() + viGetViewHeight() + 4; + dialog->dsty = g_ViBackData->viewtop + g_ViBackData->viewy + 4; } } } @@ -3303,8 +3303,8 @@ static Gfx *menuRenderDialogs(Gfx *gdl) if (g_MenuData.root == MENUROOT_MPPAUSE || g_MenuData.root == MENUROOT_PICKTARGET || g_MenuData.root == MENUROOT_MPENDSCREEN) { - var8009de98 = g_Menus[g_MpPlayerNum].curdialog->x + g_Menus[g_MpPlayerNum].curdialog->width / 2 - viGetWidth() / 2; - var8009de9c = g_Menus[g_MpPlayerNum].curdialog->y + g_Menus[g_MpPlayerNum].curdialog->height / 2 - viGetHeight() / 2; + var8009de98 = g_Menus[g_MpPlayerNum].curdialog->x + g_Menus[g_MpPlayerNum].curdialog->width / 2 - g_ViBackData->x / 2; + var8009de9c = g_Menus[g_MpPlayerNum].curdialog->y + g_Menus[g_MpPlayerNum].curdialog->height / 2 - g_ViBackData->y / 2; gdl = menuRenderDialog(gdl, g_Menus[g_MpPlayerNum].curdialog, &g_Menus[g_MpPlayerNum], 0); } else { @@ -3352,10 +3352,10 @@ static Gfx *menuRenderDialogs(Gfx *gdl) gdl = menuRenderBanner(gdl, xmin, ymin, xmax, ymax, false, g_Menus[g_MpPlayerNum].bannernum, 0, 0); } else { - s32 xmin = viGetViewLeft(); - s32 ymin = viGetViewTop(); - s32 xmax = (viGetViewLeft() + viGetViewWidth()); - s32 ymax = viGetViewTop() + viGetViewHeight(); + s32 xmin = g_ViBackData->viewleft; + s32 ymin = g_ViBackData->viewtop; + s32 xmax = (g_ViBackData->viewleft + g_ViBackData->viewx); + s32 ymax = g_ViBackData->viewtop + g_ViBackData->viewy; gdl = menuRenderBanner(gdl, xmin, ymin, xmax, ymax, true, g_Menus[g_MpPlayerNum].bannernum, 0, 0); } @@ -4663,7 +4663,7 @@ static Gfx *menuRenderBackgroundLayer1(Gfx *gdl, u8 bg, f32 frac) u32 colour = 255 * frac; gSPDisplayList(gdl++, var800613a0); gdl = textSetPrimColour(gdl, colour); - gDPFillRectangle(gdl++, 0, 0, viGetWidth(), viGetHeight()); + gDPFillRectangle(gdl++, 0, 0, g_ViBackData->x, g_ViBackData->y); gdl = text0f153838(gdl); } break; @@ -4672,7 +4672,7 @@ static Gfx *menuRenderBackgroundLayer1(Gfx *gdl, u8 bg, f32 frac) // Fill with black gSPDisplayList(gdl++, var800613a0); gdl = textSetPrimColour(gdl, 0x000000ff); - gDPFillRectangle(gdl++, 0, 0, viGetWidth(), viGetHeight()); + gDPFillRectangle(gdl++, 0, 0, g_ViBackData->x, g_ViBackData->y); gdl = text0f153838(gdl); // Render the success BG @@ -4685,7 +4685,7 @@ static Gfx *menuRenderBackgroundLayer1(Gfx *gdl, u8 bg, f32 frac) if (alpha) { gSPDisplayList(gdl++, var800613a0); gdl = textSetPrimColour(gdl, alpha); - gDPFillRectangle(gdl++, 0, 0, viGetWidth(), viGetHeight()); + gDPFillRectangle(gdl++, 0, 0, g_ViBackData->x, g_ViBackData->y); gdl = text0f153838(gdl); } } @@ -4698,7 +4698,7 @@ static Gfx *menuRenderBackgroundLayer1(Gfx *gdl, u8 bg, f32 frac) u32 channel = (1.0f - frac) * 255; gSPDisplayList(gdl++, var800613a0); gdl = textSetPrimColour(gdl, channel << 24 | channel << 16 | channel << 8 | 0xff); - gDPFillRectangle(gdl++, 0, 0, viGetWidth(), viGetHeight()); + gDPFillRectangle(gdl++, 0, 0, g_ViBackData->x, g_ViBackData->y); gdl = text0f153838(gdl); // Render the failure BG @@ -4721,17 +4721,17 @@ static Gfx *menuRenderBackgroundLayer1(Gfx *gdl, u8 bg, f32 frac) gSPDisplayList(gdl++, var800613a0); alpha = (1.0f - frac) * 255; gdl = textSetPrimColour(gdl, 0xff000000 | alpha); - gDPFillRectangle(gdl++, 0, 0, viGetWidth(), viGetHeight()); + gDPFillRectangle(gdl++, 0, 0, g_ViBackData->x, g_ViBackData->y); gdl = text0f153838(gdl); } break; case MENUBG_GRADIENT: // Blue to red - gdl = menugfxRenderGradient(gdl, 0, 0, viGetWidth(), viGetHeight(), 0x00007f7f, 0x000000ff, 0x8f0000ff); + gdl = menugfxRenderGradient(gdl, 0, 0, g_ViBackData->x, g_ViBackData->y, 0x00007f7f, 0x000000ff, 0x8f0000ff); break; case MENUBG_CONEOPAQUE: // Yellow to yellow (ie. not a gradient) - gdl = menugfxRenderGradient(gdl, 0, 0, viGetWidth(), viGetHeight(), 0x3f3f00ff, 0x7f0000ff, 0x3f3f00ff); + gdl = menugfxRenderGradient(gdl, 0, 0, g_ViBackData->x, g_ViBackData->y, 0x3f3f00ff, 0x7f0000ff, 0x3f3f00ff); break; } @@ -4884,7 +4884,7 @@ Gfx *menuRender(Gfx *gdl) g_MpPlayerNum = 0; - gSPMatrix(gdl++, osVirtualToPhysical(camGetPerspectiveMtxL()), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_PROJECTION); + gSPMatrix(gdl++, osVirtualToPhysical(g_Vars.currentplayer->perspmtxl), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_PROJECTION); gSPDisplayList(gdl++, var800613a0); text0f153b40(); @@ -4893,10 +4893,10 @@ Gfx *menuRender(Gfx *gdl) if (g_MenuData.root == MENUROOT_MPSETUP || g_MenuData.root == MENUROOT_4MBMAINMENU) { s32 i; s32 j; - s32 viewleft = viGetViewLeft() + 20; - s32 viewtop = viGetViewTop() + 4; - s32 viewright = (viGetViewLeft() + viGetViewWidth()) - 20; - s32 viewbottom = viGetViewTop() + viGetViewHeight() - 4; + s32 viewleft = g_ViBackData->viewleft + 20; + s32 viewtop = g_ViBackData->viewtop + 4; + s32 viewright = (g_ViBackData->viewleft + g_ViBackData->viewx) - 20; + s32 viewbottom = g_ViBackData->viewtop + g_ViBackData->viewy - 4; s32 textheight; s32 textwidth; bool renderit; @@ -4987,7 +4987,7 @@ Gfx *menuRender(Gfx *gdl) x = viewleft + 2; } - gdl = textRenderProjected(gdl, &x, &y, text, g_CharsHandelGothicSm, g_FontHandelGothicSm, g_MenuData.playerjoinalpha[i] | 0x5070ff00, viGetWidth(), viGetHeight(), 0, 0); + gdl = textRenderProjected(gdl, &x, &y, text, g_CharsHandelGothicSm, g_FontHandelGothicSm, g_MenuData.playerjoinalpha[i] | 0x5070ff00, g_ViBackData->x, g_ViBackData->y, 0, 0); if (g_Vars.mpsetupmenu == MPSETUPMENU_GENERAL && g_Vars.waitingtojoin[i]) { // "Ready!" @@ -4999,7 +4999,7 @@ Gfx *menuRender(Gfx *gdl) colour = colourBlend(0x00ffff00, 0xffffff00, weight) | g_MenuData.playerjoinalpha[i]; } - gdl = textRenderProjected(gdl, &x, &y, text, g_CharsHandelGothicSm, g_FontHandelGothicSm, colour, viGetWidth(), viGetHeight(), 0, 0); + gdl = textRenderProjected(gdl, &x, &y, text, g_CharsHandelGothicSm, g_FontHandelGothicSm, colour, g_ViBackData->x, g_ViBackData->y, 0, 0); } } } @@ -5013,10 +5013,10 @@ Gfx *menuRender(Gfx *gdl) // Render banner messages, such as "Please Wait...", // "Checking Controller Pak" and some unused game boy camera texts. if (g_MenuData.bannernum != -1) { - s32 x1 = viGetViewLeft(); - s32 y1 = viGetViewTop(); - s32 x2 = viGetViewLeft() + viGetViewWidth(); - s32 y2 = viGetViewTop() + viGetViewHeight(); + s32 x1 = g_ViBackData->viewleft; + s32 y1 = g_ViBackData->viewtop; + s32 x2 = g_ViBackData->viewleft + g_ViBackData->viewx; + s32 y2 = g_ViBackData->viewtop + g_ViBackData->viewy; s32 left = 0; s32 right = 0; @@ -5029,7 +5029,7 @@ Gfx *menuRender(Gfx *gdl) } } - if (PLAYERCOUNT() == 2 && optionsGetScreenSplit() == SCREENSPLIT_VERTICAL) { + if (PLAYERCOUNT() == 2 && g_ScreenSplit == SCREENSPLIT_VERTICAL) { if (g_Vars.currentplayernum == 1) { right = 15; } else { @@ -5496,13 +5496,13 @@ void func0f0fd494(struct coord *pos) g_MenuData.unk5d5_04 = true; - matrix = camGetWorldToScreenMtxf(); + matrix = g_Vars.currentplayer->worldtoscreenmtx; mtx4TransformVec(matrix, pos, &coord); cam0f0b4d04(&coord, xy); - g_MenuData.unk670 = (s32)xy[0] - viGetWidth() / 2; - g_MenuData.unk674 = (s32)xy[1] - viGetHeight() / 2; + g_MenuData.unk670 = (s32)xy[0] - g_ViBackData->x / 2; + g_MenuData.unk674 = (s32)xy[1] - g_ViBackData->y / 2; g_MenuData.unk5d5_05 = false; } diff --git a/src/game/menugfx.c b/src/game/menugfx.c index 23a26bbec..a2e3cb77c 100644 --- a/src/game/menugfx.c +++ b/src/game/menugfx.c @@ -44,14 +44,14 @@ */ void menugfxCreateBlur(void) { - u8 *fb = (u8 *) viGetFrontBuffer(); + u8 *fb = (u8 *) g_ViFrontData->fb; s32 dstx; s32 dsty; #if PAL - s32 fbwidthinbytes = viGetWidth() * 2; - f32 scale = viGetWidth() / 320.0f; + s32 fbwidthinbytes = g_ViBackData->x * 2; + f32 scale = g_ViBackData->x / 320.0f; #else - s32 fbwidthinbytes = PXTOBYTES(viGetWidth()); + s32 fbwidthinbytes = PXTOBYTES(g_ViBackData->x); #endif s32 srcx; s32 srcy; @@ -60,7 +60,7 @@ void menugfxCreateBlur(void) u32 b; u16 colour; - fb = (u8 *) viGetFrontBuffer(); + fb = (u8 *) g_ViFrontData->fb; for (dsty = 0; dsty < BLURIMG_HEIGHT; dsty++) { @@ -1216,7 +1216,7 @@ Gfx *menugfxRenderBgSuccess(Gfx *gdl) // Initialise particles if they haven't been already if (g_MenuParticles == NULL) { - g_MenuParticles = (struct coord *) bgunGetGunMem(); + g_MenuParticles = (struct coord *) g_Vars.currentplayer->gunctrl.gunmem; if (g_MenuParticles == NULL) { return gdl; @@ -1263,10 +1263,10 @@ Gfx *menugfxRenderBgSuccess(Gfx *gdl) if (gray) { gdl = menugfxDrawPlane(gdl, -1000, -10, 2000, -10, 0x6060607f, 0x6060607f, MENUPLANE_05); - gdl = menugfxDrawPlane(gdl, -1000, viGetHeight() + 10, 2000, viGetHeight() + 10, 0x9090907f, 0x9090907f, MENUPLANE_05); + gdl = menugfxDrawPlane(gdl, -1000, g_ViBackData->y + 10, 2000, g_ViBackData->y + 10, 0x9090907f, 0x9090907f, MENUPLANE_05); } else { gdl = menugfxDrawPlane(gdl, -1000, -10, 2000, -10, 0x0000947f, 0x0000947f, MENUPLANE_10); - gdl = menugfxDrawPlane(gdl, -1000, viGetHeight() + 10, 2000, viGetHeight() + 10, 0x6200947f, 0x6200947f, MENUPLANE_06); + gdl = menugfxDrawPlane(gdl, -1000, g_ViBackData->y + 10, 2000, g_ViBackData->y + 10, 0x6200947f, 0x6200947f, MENUPLANE_06); } // Prepare stuff for drawing the particles diff --git a/src/game/menuitem.c b/src/game/menuitem.c index f9d074e43..c86ac5e2b 100644 --- a/src/game/menuitem.c +++ b/src/game/menuitem.c @@ -242,20 +242,20 @@ static Gfx *menuitemListRender(Gfx *gdl, struct menurendercontext *context) g_ScissorY2 = 0; } - if (g_ScissorX1 > viGetBufWidth()) { - g_ScissorX1 = viGetBufWidth(); + if (g_ScissorX1 > g_ViBackData->bufx) { + g_ScissorX1 = g_ViBackData->bufx; } - if (g_ScissorX2 > viGetBufWidth()) { - g_ScissorX2 = viGetBufWidth(); + if (g_ScissorX2 > g_ViBackData->bufx) { + g_ScissorX2 = g_ViBackData->bufx; } - if (g_ScissorY1 > viGetBufHeight()) { - g_ScissorY1 = viGetBufHeight(); + if (g_ScissorY1 > g_ViBackData->bufy) { + g_ScissorY1 = g_ViBackData->bufy; } - if (g_ScissorY2 > viGetBufHeight()) { - g_ScissorY2 = viGetBufHeight(); + if (g_ScissorY2 > g_ViBackData->bufy) { + g_ScissorY2 = g_ViBackData->bufy; } if (g_ScissorX1 > g_ScissorX2) { @@ -478,12 +478,12 @@ static Gfx *menuitemListRender(Gfx *gdl, struct menurendercontext *context) sp8cright = 0; } - if (sp94left > viGetWidth()) { - sp94left = viGetWidth(); + if (sp94left > g_ViBackData->x) { + sp94left = g_ViBackData->x; } - if (sp8cright > viGetWidth()) { - sp8cright = viGetWidth(); + if (sp8cright > g_ViBackData->x) { + sp8cright = g_ViBackData->x; } gDPPipeSync(gdl++); @@ -509,20 +509,20 @@ static Gfx *menuitemListRender(Gfx *gdl, struct menurendercontext *context) g_ScissorY2 = 0; } - if (g_ScissorX1 > viGetBufWidth()) { - g_ScissorX1 = viGetBufWidth(); + if (g_ScissorX1 > g_ViBackData->bufx) { + g_ScissorX1 = g_ViBackData->bufx; } - if (g_ScissorX2 > viGetBufWidth()) { - g_ScissorX2 = viGetBufWidth(); + if (g_ScissorX2 > g_ViBackData->bufx) { + g_ScissorX2 = g_ViBackData->bufx; } - if (g_ScissorY1 > viGetBufHeight()) { - g_ScissorY1 = viGetBufHeight(); + if (g_ScissorY1 > g_ViBackData->bufy) { + g_ScissorY1 = g_ViBackData->bufy; } - if (g_ScissorY2 > viGetBufHeight()) { - g_ScissorY2 = viGetBufHeight(); + if (g_ScissorY2 > g_ViBackData->bufy) { + g_ScissorY2 = g_ViBackData->bufy; } if (g_ScissorX2 < g_ScissorX1) { @@ -611,7 +611,7 @@ static Gfx *menuitemListRender(Gfx *gdl, struct menurendercontext *context) y = context->y + context->height / 2; // "< Empty >" - gdl = textRenderProjected(gdl, &x, &y, langGet(L_OPTIONS_313), chars, font, colour, context->width - left + context->x, viGetHeight(), sp128, 0); + gdl = textRenderProjected(gdl, &x, &y, langGet(L_OPTIONS_313), chars, font, colour, context->width - left + context->x, g_ViBackData->y, sp128, 0); } gdl = text0f153780(gdl); @@ -1706,7 +1706,7 @@ static Gfx *menuitemObjectivesRender(Gfx *gdl, struct menurendercontext *context s32 i; for (i = 0; i < 6; i++) { - if (g_Briefing.objectivenames[i] && g_Briefing.objectivedifficulties[i] & (1 << lvGetDifficulty())) { + if (g_Briefing.objectivenames[i] && g_Briefing.objectivedifficulties[i] & (1 << g_Difficulty)) { gdl = menuitemObjectivesRenderOne(gdl, context->dialog, i, position, context->x, y, context->width, context->height, @@ -2929,20 +2929,20 @@ static Gfx *menuitemMarqueeRender(Gfx *gdl, struct menurendercontext *context) g_ScissorY2 = 0; } - if (g_ScissorX1 > viGetBufWidth()) { - g_ScissorX1 = viGetBufWidth(); + if (g_ScissorX1 > g_ViBackData->bufx) { + g_ScissorX1 = g_ViBackData->bufx; } - if (g_ScissorX2 > viGetBufWidth()) { - g_ScissorX2 = viGetBufWidth(); + if (g_ScissorX2 > g_ViBackData->bufx) { + g_ScissorX2 = g_ViBackData->bufx; } - if (g_ScissorY1 > viGetBufHeight()) { - g_ScissorY1 = viGetBufHeight(); + if (g_ScissorY1 > g_ViBackData->bufy) { + g_ScissorY1 = g_ViBackData->bufy; } - if (g_ScissorY2 > viGetBufHeight()) { - g_ScissorY2 = viGetBufHeight(); + if (g_ScissorY2 > g_ViBackData->bufy) { + g_ScissorY2 = g_ViBackData->bufy; } if (g_ScissorX2 < g_ScissorX1) { @@ -3160,20 +3160,20 @@ static Gfx *menuitemRankingRender(Gfx *gdl, struct menurendercontext *context) g_ScissorY2 = 0; } - if (g_ScissorX1 > viGetBufWidth()) { - g_ScissorX1 = viGetBufWidth(); + if (g_ScissorX1 > g_ViBackData->bufx) { + g_ScissorX1 = g_ViBackData->bufx; } - if (g_ScissorX2 > viGetBufWidth()) { - g_ScissorX2 = viGetBufWidth(); + if (g_ScissorX2 > g_ViBackData->bufx) { + g_ScissorX2 = g_ViBackData->bufx; } - if (g_ScissorY1 > viGetBufHeight()) { - g_ScissorY1 = viGetBufHeight(); + if (g_ScissorY1 > g_ViBackData->bufy) { + g_ScissorY1 = g_ViBackData->bufy; } - if (g_ScissorY2 > viGetBufHeight()) { - g_ScissorY2 = viGetBufHeight(); + if (g_ScissorY2 > g_ViBackData->bufy) { + g_ScissorY2 = g_ViBackData->bufy; } if (g_ScissorX2 < g_ScissorX1) { @@ -3408,20 +3408,20 @@ static Gfx *menuitemPlayerStatsRender(Gfx *gdl, struct menurendercontext *contex g_ScissorY2 = 0; } - if (g_ScissorX1 > viGetBufWidth()) { - g_ScissorX1 = viGetBufWidth(); + if (g_ScissorX1 > g_ViBackData->bufx) { + g_ScissorX1 = g_ViBackData->bufx; } - if (g_ScissorX2 > viGetBufWidth()) { - g_ScissorX2 = viGetBufWidth(); + if (g_ScissorX2 > g_ViBackData->bufx) { + g_ScissorX2 = g_ViBackData->bufx; } - if (g_ScissorY1 > viGetBufHeight()) { - g_ScissorY1 = viGetBufHeight(); + if (g_ScissorY1 > g_ViBackData->bufy) { + g_ScissorY1 = g_ViBackData->bufy; } - if (g_ScissorY2 > viGetBufHeight()) { - g_ScissorY2 = viGetBufHeight(); + if (g_ScissorY2 > g_ViBackData->bufy) { + g_ScissorY2 = g_ViBackData->bufy; } if (g_ScissorX2 < g_ScissorX1) { @@ -3727,7 +3727,7 @@ static Gfx *menuitemControllerRenderText(Gfx *gdl, s32 curmode, struct menurende // Rendering a label such as "L/R BUTTONS:" rx = context->x + padx + 76; gdl = textRenderProjected(gdl, &rx, &ry, langGet(L_MPWEAPONS_185 + i), - g_CharsHandelGothicXs, g_FontHandelGothicXs, labelcolour, viGetWidth(), viGetHeight(), 0, 0); + g_CharsHandelGothicXs, g_FontHandelGothicXs, labelcolour, g_ViBackData->x, g_ViBackData->y, 0, 0); } textnum = menuitemControllerGetButtonAction(curmode, i); @@ -3762,7 +3762,7 @@ static Gfx *menuitemControllerRenderText(Gfx *gdl, s32 curmode, struct menurende } gdl = textRenderProjected(gdl, &rx, &ry, langGet(textnum), - g_CharsHandelGothicXs, g_FontHandelGothicXs, colour, viGetWidth(), viGetHeight(), 0, 0); + g_CharsHandelGothicXs, g_FontHandelGothicXs, colour, g_ViBackData->x, g_ViBackData->y, 0, 0); } return text0f153780(gdl); @@ -3880,7 +3880,7 @@ static Gfx *menuitemControllerRender(Gfx *gdl, struct menurendercontext *context x = context->x + 2; y = context->y + 2; gdl = textRenderProjected(gdl, &x, &y, text, - g_CharsHandelGothicSm, g_FontHandelGothicSm, colour, viGetWidth(), viGetHeight(), 0, 0); + g_CharsHandelGothicSm, g_FontHandelGothicSm, colour, g_ViBackData->x, g_ViBackData->y, 0, 0); gdl = text0f153780(gdl); textcolour = colourBlend(colour, colour & 0xffffff00, textalpha); @@ -3903,7 +3903,7 @@ static Gfx *menuitemControllerRender(Gfx *gdl, struct menurendercontext *context gdl = text0f153628(gdl); gdl = textRenderProjected(gdl, &x, &y, langGet(L_MPWEAPONS_216), // "Hold weapon button for ..." - g_CharsHandelGothicSm, g_FontHandelGothicSm, colour, viGetWidth(), viGetHeight(), 0, 0); + g_CharsHandelGothicSm, g_FontHandelGothicSm, colour, g_ViBackData->x, g_ViBackData->y, 0, 0); gdl = text0f153780(gdl); } diff --git a/src/game/menutick.c b/src/game/menutick.c index 1d3d92c0d..c5edaeb74 100644 --- a/src/game/menutick.c +++ b/src/game/menutick.c @@ -565,7 +565,7 @@ void menuTick(void) switch (g_MenuData.root) { case MENUROOT_ENDSCREEN: if (g_Vars.restartlevel) { - mainChangeToStage(mainGetStageNum()); + mainChangeToStage(g_StageNum); } else { mainChangeToStage(STAGE_TITLE); } @@ -592,7 +592,7 @@ void menuTick(void) && ((!g_CheatsActiveBank0 && !g_CheatsActiveBank1) || isStageDifficultyUnlocked(g_MissionConfig.stageindex + 1, g_MissionConfig.difficulty))) { endscreenPushSolo(); } else if (g_Vars.restartlevel) { - mainChangeToStage(mainGetStageNum()); + mainChangeToStage(g_StageNum); } else { mpSetPaused(MPPAUSEMODE_UNPAUSED); g_Vars.mplayerisrunning = false; @@ -645,7 +645,7 @@ void menuTick(void) g_MenuData.unk5d5_01 = true; if (g_Menus[0].unk840.unk004) { - bgunFreeGunMem(); + g_Vars.currentplayer->gunctrl.gunmemowner = GUNMEMOWNER_FREE; g_Menus[0].unk840.unk004 = NULL; } } diff --git a/src/game/mplayer/ingame.c b/src/game/mplayer/ingame.c index d50c4fe58..978b21925 100644 --- a/src/game/mplayer/ingame.c +++ b/src/game/mplayer/ingame.c @@ -187,11 +187,7 @@ char *menutextPauseOrUnpause(s32 arg0) static char *menutextMatchTime(s32 arg0) { -#if PAL - formatTime(g_StringPointer, lvGetStageTime60() * 60 / 50, TIMEPRECISION_SECONDS); -#else - formatTime(g_StringPointer, lvGetStageTime60(), TIMEPRECISION_SECONDS); -#endif + formatTime(g_StringPointer, g_StageTimeElapsed60, TIMEPRECISION_SECONDS); return g_StringPointer; } @@ -653,7 +649,7 @@ void mpPushPauseDialog(void) menuPushRootDialog(&g_MpPausePlayerRankingMenuDialog, MENUROOT_MPPAUSE); } } else { - if (optionsGetScreenSplit() == SCREENSPLIT_VERTICAL) { + if (g_ScreenSplit == SCREENSPLIT_VERTICAL) { menuPushRootDialog(&g_2PMissionPauseVMenuDialog, MENUROOT_MPPAUSE); } else { menuPushRootDialog(&g_2PMissionPauseHMenuDialog, MENUROOT_MPPAUSE); diff --git a/src/game/mplayer/mplayer.c b/src/game/mplayer/mplayer.c index 0e3c8226b..b58df47ca 100644 --- a/src/game/mplayer/mplayer.c +++ b/src/game/mplayer/mplayer.c @@ -1129,7 +1129,7 @@ void mpSetPaused(u8 mode) * or "Press START" if player has finished their death animation. * * @bug: When calling textRender(), viGetWidth() is used twice but it should be - * viGetViewWidth() and viGetViewHeight(). These arguments to textRender() set + * g_ViBackData->viewx and g_ViBackData->viewy. These arguments to textRender() set * the crop box for the text, but the text doesn't extend past the box anyway * so it has no effect. */ @@ -1150,18 +1150,18 @@ Gfx *mpRenderModalText(Gfx *gdl) strcpy(text, langGet(L_MPWEAPONS_040)); // "Paused" - x = viGetViewLeft() + viGetViewWidth() / 2; + x = g_ViBackData->viewleft + g_ViBackData->viewx / 2; if (g_Menus[g_Vars.currentplayerstats->mpindex].curdialog) { - y = viGetViewTop() + 10; + y = g_ViBackData->viewtop + 10; } else { - y = viGetViewTop() + viGetViewHeight() / 2; + y = g_ViBackData->viewtop + g_ViBackData->viewy / 2; } textMeasure(&textheight, &textwidth, text, g_CharsHandelGothicMd, g_FontHandelGothicMd, 0); x -= textwidth / 2; - gdl = textRender(gdl, &x, &y, text, g_CharsHandelGothicMd, g_FontHandelGothicMd, (red << 24) | 0x00ff00ff, 0x000000ff, viGetWidth(), viGetWidth(), 0, 0); + gdl = textRender(gdl, &x, &y, text, g_CharsHandelGothicMd, g_FontHandelGothicMd, (red << 24) | 0x00ff00ff, 0x000000ff, g_ViBackData->x, g_ViBackData->x, 0, 0); gdl = text0f153780(gdl); } else if (!g_MainIsEndscreen @@ -1177,19 +1177,19 @@ Gfx *mpRenderModalText(Gfx *gdl) strcpy(text, langGet(L_MPWEAPONS_039)); - x = viGetViewLeft() + viGetViewWidth() / 2; + x = g_ViBackData->viewleft + g_ViBackData->viewx / 2; - y = viGetViewTop() + viGetViewHeight() / 2; + y = g_ViBackData->viewtop + g_ViBackData->viewy / 2; textMeasure(&textheight, &textwidth, text, g_CharsHandelGothicSm, g_FontHandelGothicSm, 0); x -= textwidth / 2; - gdl = textRender(gdl, &x, &y, text, g_CharsHandelGothicSm, g_FontHandelGothicSm, 0xff0000ff, 0x000000ff, viGetWidth(), viGetWidth(), 0, 0); + gdl = textRender(gdl, &x, &y, text, g_CharsHandelGothicSm, g_FontHandelGothicSm, 0xff0000ff, 0x000000ff, g_ViBackData->x, g_ViBackData->x, 0, 0); if (g_Vars.currentplayer->deadtimer > 0) { // Render countdown timer - s32 countdowny = viGetViewTop() + viGetViewHeight() / 2 + textheight + 2; - s32 countdownx = viGetViewLeft() + viGetViewWidth() / 2; + s32 countdowny = g_ViBackData->viewtop + g_ViBackData->viewy / 2 + textheight + 2; + s32 countdownx = g_ViBackData->viewleft + g_ViBackData->viewx / 2; sprintf(text, "%d\n", (g_Vars.currentplayer->deadtimer + TICKS(60) - 1) / TICKS(60)); @@ -1197,7 +1197,7 @@ Gfx *mpRenderModalText(Gfx *gdl) x = countdownx - textwidth / 2; y = countdowny; - gdl = textRender(gdl, &x, &y, text, g_CharsHandelGothicSm, g_FontHandelGothicSm, 0xff0000ff, 0x000000ff, viGetWidth(), viGetWidth(), 0, 0); + gdl = textRender(gdl, &x, &y, text, g_CharsHandelGothicSm, g_FontHandelGothicSm, 0xff0000ff, 0x000000ff, g_ViBackData->x, g_ViBackData->x, 0, 0); } gdl = text0f153780(gdl); diff --git a/src/game/mplayer/scenarios.c b/src/game/mplayer/scenarios.c index 3bc1fe5d1..4f6b17216 100644 --- a/src/game/mplayer/scenarios.c +++ b/src/game/mplayer/scenarios.c @@ -568,10 +568,10 @@ Gfx *scenarioRenderHud(Gfx *gdl) colour = var80087ce4[radarGetTeamIndex(chr->team)]; gDPSetFillColor(gdl++, colour); - viewleft = viGetViewLeft(); - viewright = viewleft + viGetViewWidth(); - viewtop = viGetViewTop(); - viewheight = viGetViewHeight(); + viewleft = g_ViBackData->viewleft; + viewright = viewleft + g_ViBackData->viewx; + viewtop = g_ViBackData->viewtop; + viewheight = g_ViBackData->viewy; if (playercount >= 3) { if (cplayernum <= 1) { diff --git a/src/game/mplayer/scenarios/hackthatmac.inc b/src/game/mplayer/scenarios/hackthatmac.inc index 6dd0089be..775a3ceab 100644 --- a/src/game/mplayer/scenarios/hackthatmac.inc +++ b/src/game/mplayer/scenarios/hackthatmac.inc @@ -541,11 +541,11 @@ static Gfx *htmRenderHud(Gfx *gdl) dltime = data->dltime240[g_Vars.currentplayernum]; if (data->dlterminalnum != -1 && g_Vars.currentplayernum == data->dlplayernum) { - viewleft = viGetViewLeft(); - viewright = viGetViewLeft() + viGetViewWidth(); - viewtop = viGetViewTop(); + viewleft = g_ViBackData->viewleft; + viewright = g_ViBackData->viewleft + g_ViBackData->viewx; + viewtop = g_ViBackData->viewtop; t6 = (viewleft + viewright) / 2; - a1 = viGetViewWidth() / 3; + a1 = g_ViBackData->viewx / 3; barleft = t6 - a1 / 2; barright = t6 + a1 / 2; s1 = barleft + (s32) (a1 * (dltime / TICKS(4800.0f))); diff --git a/src/game/mplayer/scenarios/holdthebriefcase.inc b/src/game/mplayer/scenarios/holdthebriefcase.inc index e8aa51436..50704fddf 100644 --- a/src/game/mplayer/scenarios/holdthebriefcase.inc +++ b/src/game/mplayer/scenarios/holdthebriefcase.inc @@ -385,8 +385,8 @@ static Gfx *htbRenderHud(Gfx *gdl) char text[64]; if (invHasBriefcase()) { - x = viGetViewLeft() + viGetViewWidth() / 2; - y = viGetViewTop() + 10; + x = g_ViBackData->viewleft + g_ViBackData->viewx / 2; + y = g_ViBackData->viewtop + 10; time240 = TICKS(7200) - g_Vars.currentplayerstats->tokenheldtime; @@ -403,7 +403,7 @@ static Gfx *htbRenderHud(Gfx *gdl) textheight += y; gdl = text0f153990(gdl, x, y, textwidth, textheight); - gdl = textRender(gdl, &x, &y, text, g_CharsNumeric, g_FontNumeric, 0x00ff00a0, 0xa0, viGetWidth(), viGetHeight(), 0, 0); + gdl = textRender(gdl, &x, &y, text, g_CharsNumeric, g_FontNumeric, 0x00ff00a0, 0xa0, g_ViBackData->x, g_ViBackData->y, 0, 0); gdl = text0f153780(gdl); } diff --git a/src/game/mplayer/scenarios/kingofthehill.inc b/src/game/mplayer/scenarios/kingofthehill.inc index b5735e51e..19a4fa74b 100644 --- a/src/game/mplayer/scenarios/kingofthehill.inc +++ b/src/game/mplayer/scenarios/kingofthehill.inc @@ -539,8 +539,8 @@ static Gfx *kohRenderHud(Gfx *gdl) char text[64]; if (radarGetTeamIndex(chr->team) == g_ScenarioData.koh.occupiedteam && !g_ScenarioData.koh.movehill) { - x = viGetViewLeft() + viGetViewWidth() / 2; - y = viGetViewTop() + 10; + x = g_ViBackData->viewleft + g_ViBackData->viewx / 2; + y = g_ViBackData->viewtop + 10; time240 = g_Vars.mphilltime * TICKS(240) - g_ScenarioData.koh.elapsed240; time240 += 2400; @@ -563,7 +563,7 @@ static Gfx *kohRenderHud(Gfx *gdl) textheight += y; gdl = text0f153990(gdl, x, y, textwidth, textheight); - gdl = textRender(gdl, &x, &y, text, g_CharsNumeric, g_FontNumeric, 0x00ff00a0, 0xa0, viGetWidth(), viGetHeight(), 0, 0); + gdl = textRender(gdl, &x, &y, text, g_CharsNumeric, g_FontNumeric, 0x00ff00a0, 0xa0, g_ViBackData->x, g_ViBackData->y, 0, 0); gdl = text0f153780(gdl); } diff --git a/src/game/mplayer/scenarios/popacap.inc b/src/game/mplayer/scenarios/popacap.inc index 26fd08d17..3856f869f 100644 --- a/src/game/mplayer/scenarios/popacap.inc +++ b/src/game/mplayer/scenarios/popacap.inc @@ -275,8 +275,8 @@ static Gfx *pacRenderHud(Gfx *gdl) if (g_Vars.currentplayernum == data->victims[data->victimindex] && !g_Vars.currentplayer->isdead) { time240 = TICKS(60 * 240) - data->age240; - x = viGetViewLeft() + viGetViewWidth() / 2; - y = viGetViewTop() + 10; + x = g_ViBackData->viewleft + g_ViBackData->viewx / 2; + y = g_ViBackData->viewtop + 10; if (time240 < 0) { time240 = 0; @@ -295,7 +295,7 @@ static Gfx *pacRenderHud(Gfx *gdl) textheight += y; gdl = text0f153990(gdl, x, y, textwidth, textheight); - gdl = textRender(gdl, &x, &y, text, g_CharsNumeric, g_FontNumeric, 0x00ff00a0, 0xa0, viGetWidth(), viGetHeight(), 0, 0); + gdl = textRender(gdl, &x, &y, text, g_CharsNumeric, g_FontNumeric, 0x00ff00a0, 0xa0, g_ViBackData->x, g_ViBackData->y, 0, 0); gdl = text0f153780(gdl); } diff --git a/src/game/mplayer/setup.c b/src/game/mplayer/setup.c index 698592abe..633daae2d 100644 --- a/src/game/mplayer/setup.c +++ b/src/game/mplayer/setup.c @@ -259,7 +259,7 @@ static s32 menuhandlerMpControlStyle(s32 operation, struct menuitem *item, union optionsSetControlMode(g_MpPlayerNum, data->dropdown.value); break; case MENUOP_GETSELECTEDINDEX: - data->dropdown.value = optionsGetControlMode(g_MpPlayerNum); + data->dropdown.value = g_PlayerConfigsArray[g_MpPlayerNum].controlmode; break; } @@ -614,7 +614,7 @@ static s32 mpChallengesListHandler(s32 operation, struct menuitem *item, union h gdl = textRenderProjected(gdl, &x, &y, name, g_CharsHandelGothicSm, g_FontHandelGothicSm, renderdata->colour, - viGetWidth(), viGetHeight(), 0, 0); + g_ViBackData->x, g_ViBackData->y, 0, 0); gdl = text0f153780(gdl); @@ -4135,7 +4135,7 @@ s32 mpChallengesListMenuHandler(s32 operation, struct menuitem *item, union hand y = renderdata->y + 1; gdl = text0f153628(gdl); - gdl = textRenderProjected(gdl, &x, &y, challengeGetNameBySlot(data->type19.unk04), g_CharsHandelGothicSm, g_FontHandelGothicSm, renderdata->colour, viGetWidth(), viGetHeight(), 0, 0); + gdl = textRenderProjected(gdl, &x, &y, challengeGetNameBySlot(data->type19.unk04), g_CharsHandelGothicSm, g_FontHandelGothicSm, renderdata->colour, g_ViBackData->x, g_ViBackData->y, 0, 0); gdl = text0f153780(gdl); gDPPipeSync(gdl++); diff --git a/src/game/music.c b/src/game/music.c index 0be700fd5..448984ce7 100644 --- a/src/game/music.c +++ b/src/game/music.c @@ -251,7 +251,7 @@ static bool musicIsAnyPlayerInAmbientRoom(void) return false; } - if (lvIsPaused()) { + if (g_LvIsPaused) { return false; } diff --git a/src/game/nbomb.c b/src/game/nbomb.c index 41c08453a..fe2acffee 100644 --- a/src/game/nbomb.c +++ b/src/game/nbomb.c @@ -277,7 +277,7 @@ static Gfx *nbombRender(Gfx *gdl, struct nbomb *nbomb, Gfx *subgdl) mtx00015f04(nbomb->radius / 2000.0f, &sp88); mtx4MultMtx4(&sp48, &sp88, &spc8); - mtx00015be0(camGetWorldToScreenMtxf(), &spc8); + mtx00015be0(g_Vars.currentplayer->worldtoscreenmtx, &spc8); mtx00016054(&spc8, mtx); gSPMatrix(gdl++, osVirtualToPhysical(mtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); @@ -638,10 +638,10 @@ Gfx *nbombRenderOverlay(Gfx *gdl) colours = gfxAllocateColours(1); vertices = gfxAllocateVertices(4); - viewleft = viGetViewLeft() * 10; - viewtop = viGetViewTop() * 10; - viewright = (s16) (viGetViewLeft() + viGetViewWidth()) * 10; - viewbottom = (s16) (viGetViewTop() + viGetViewHeight()) * 10; + viewleft = g_ViBackData->viewleft * 10; + viewtop = g_ViBackData->viewtop * 10; + viewright = (s16) (g_ViBackData->viewleft + g_ViBackData->viewx) * 10; + viewbottom = (s16) (g_ViBackData->viewtop + g_ViBackData->viewy) * 10; s = (s32) (8.0f * g_20SecIntervalFrac * 128.0f * 32.0f) % 2048; t = (s16) ((s32) (campos.f[1] * 8.0f) % 2048) + (s16) (2.0f * g_20SecIntervalFrac * 128.0f * 32.0f); @@ -775,10 +775,10 @@ Gfx *gasRender(Gfx *gdl) if (show) { u32 *colours = gfxAllocateColours(1); struct gfxvtx *vertices = gfxAllocateVertices(8); - s16 viewleft = viGetViewLeft() * 10; - s16 viewtop = viGetViewTop() * 10; - s16 viewright = (s16) (viGetViewLeft() + viGetViewWidth()) * 10; - s16 viewbottom = (s16) (viGetViewTop() + viGetViewHeight()) * 10; + s16 viewleft = g_ViBackData->viewleft * 10; + s16 viewtop = g_ViBackData->viewtop * 10; + s16 viewright = (s16) (g_ViBackData->viewleft + g_ViBackData->viewx) * 10; + s16 viewbottom = (s16) (g_ViBackData->viewtop + g_ViBackData->viewy) * 10; f32 lookx = g_Vars.currentplayer->cam_look.x; f32 lookz = g_Vars.currentplayer->cam_look.z; f32 camposx = g_Vars.currentplayer->cam_pos.x; diff --git a/src/game/objectives.c b/src/game/objectives.c index 95fe7a66d..f8417f92d 100644 --- a/src/game/objectives.c +++ b/src/game/objectives.c @@ -84,11 +84,6 @@ s32 objGetTagNum(struct defaultobj *obj) return -1; } -s32 objectiveGetCount(void) -{ - return g_ObjectiveLastIndex + 1; -} - u32 objectiveGetDifficultyBits(s32 index) { if (index < 10 && g_Objectives[index]) { @@ -194,10 +189,10 @@ bool objectiveIsAllComplete(void) { s32 i; - for (i = 0; i < objectiveGetCount(); i++) { + for (i = 0; i < (g_ObjectiveLastIndex + 1); i++) { u32 diffbits = objectiveGetDifficultyBits(i); - if ((1 << lvGetDifficulty() & diffbits) && + if ((1 << g_Difficulty & diffbits) && objectiveCheck(i) != OBJECTIVE_COMPLETE) { return false; } @@ -241,7 +236,7 @@ void objectivesCheckAll(void) if (g_ObjectiveStatuses[i] != status) { g_ObjectiveStatuses[i] = status; - if (objectiveGetDifficultyBits(i) & (1 << lvGetDifficulty())) { + if (objectiveGetDifficultyBits(i) & (1 << g_Difficulty)) { sprintf(buffer, "%s %d: ", langGet(L_MISC_044), availableindex + 1); // "Objective" // NTSC 1.0 and above shows objective messages to everyone, @@ -263,7 +258,7 @@ void objectivesCheckAll(void) anyfailed = true; } - if (objectiveGetDifficultyBits(i) & (1 << lvGetDifficulty())) { + if (objectiveGetDifficultyBits(i) & (1 << g_Difficulty)) { availableindex++; } } @@ -306,14 +301,14 @@ void objectiveCheckHolograph(f32 maxdist) f32 sp70[2]; func0f06803c(&sp9c, sp94, sp8c, sp78, sp70); - if (sp78[0] > camGetScreenLeft() - && sp78[0] < camGetScreenLeft() + camGetScreenWidth() - && sp70[0] > camGetScreenLeft() - && sp70[0] < camGetScreenLeft() + camGetScreenWidth() - && sp78[1] > camGetScreenTop() - && sp78[1] < camGetScreenTop() + camGetScreenHeight() - && sp70[1] > camGetScreenTop() - && sp70[1] < camGetScreenTop() + camGetScreenHeight()) { + if (sp78[0] > g_Vars.currentplayer->c_screenleft + && sp78[0] < g_Vars.currentplayer->c_screenleft + g_Vars.currentplayer->c_screenwidth + && sp70[0] > g_Vars.currentplayer->c_screenleft + && sp70[0] < g_Vars.currentplayer->c_screenleft + g_Vars.currentplayer->c_screenwidth + && sp78[1] > g_Vars.currentplayer->c_screentop + && sp78[1] < g_Vars.currentplayer->c_screentop + g_Vars.currentplayer->c_screenheight + && sp70[1] > g_Vars.currentplayer->c_screentop + && sp70[1] < g_Vars.currentplayer->c_screentop + g_Vars.currentplayer->c_screenheight) { criteria->status = OBJECTIVE_COMPLETE; if (g_Vars.stagenum == STAGE_CITRAINING) { diff --git a/src/game/objectivesreset.c b/src/game/objectivesreset.c index 0fa052785..161b9e702 100644 --- a/src/game/objectivesreset.c +++ b/src/game/objectivesreset.c @@ -10,7 +10,7 @@ void objectivesReset(void) { s32 i; - if (mainGetStageNum() < STAGE_TITLE) { + if (g_StageNum < STAGE_TITLE) { g_ObjectiveLastIndex = -1; for (i = 0; i < ARRAYCOUNT(g_ObjectiveStatuses); i++) { diff --git a/src/game/options.c b/src/game/options.c index 60e93837a..efb60913c 100644 --- a/src/game/options.c +++ b/src/game/options.c @@ -14,96 +14,6 @@ s32 g_ScreenSize = SCREENSIZE_FULL; s32 g_ScreenRatio = SCREENRATIO_NORMAL; u8 g_ScreenSplit = SCREENSPLIT_HORIZONTAL; -s32 optionsGetControlMode(s32 mpchrnum) -{ - return g_PlayerConfigsArray[mpchrnum].controlmode; -} - -void optionsSetControlMode(s32 mpchrnum, s32 mode) -{ - g_PlayerConfigsArray[mpchrnum].controlmode = mode; -} - -s32 optionsGetContpadNum1(s32 mpchrnum) -{ - return g_PlayerConfigsArray[mpchrnum].contpad1; -} - -s32 optionsGetContpadNum2(s32 mpchrnum) -{ - return g_PlayerConfigsArray[mpchrnum].contpad2; -} - -s32 optionsGetForwardPitch(s32 mpchrnum) -{ - return (g_PlayerConfigsArray[mpchrnum].options & OPTION_FORWARDPITCH) != 0; -} - -s32 optionsGetAutoAim(s32 mpchrnum) -{ - return (g_PlayerConfigsArray[mpchrnum].options & OPTION_AUTOAIM) != 0; -} - -s32 optionsGetLookAhead(s32 mpchrnum) -{ - return (g_PlayerConfigsArray[mpchrnum].options & OPTION_LOOKAHEAD) != 0; -} - -s32 optionsGetAimControl(s32 mpchrnum) -{ - return (g_PlayerConfigsArray[mpchrnum].options & OPTION_AIMCONTROL) != 0; -} - -s32 optionsGetSightOnScreen(s32 mpchrnum) -{ - return (g_PlayerConfigsArray[mpchrnum].options & OPTION_SIGHTONSCREEN) != 0; -} - -s32 optionsGetAmmoOnScreen(s32 mpchrnum) -{ - return (g_PlayerConfigsArray[mpchrnum].options & OPTION_AMMOONSCREEN) != 0; -} - -s32 optionsGetShowGunFunction(s32 mpchrnum) -{ - return (g_PlayerConfigsArray[mpchrnum].options & OPTION_SHOWGUNFUNCTION) != 0; -} - -s32 optionsGetAlwaysShowTarget(s32 mpchrnum) -{ - return (g_PlayerConfigsArray[mpchrnum].options & OPTION_ALWAYSSHOWTARGET) != 0; -} - -s32 optionsGetShowZoomRange(s32 mpchrnum) -{ - return (g_PlayerConfigsArray[mpchrnum].options & OPTION_SHOWZOOMRANGE) != 0; -} - -s32 optionsGetPaintball(s32 mpchrnum) -{ - return (g_PlayerConfigsArray[mpchrnum].options & OPTION_PAINTBALL) != 0; -} - -s32 optionsGetShowMissionTime(s32 mpchrnum) -{ - return (g_PlayerConfigsArray[mpchrnum].options & OPTION_SHOWMISSIONTIME) != 0; -} - -u8 optionsGetInGameSubtitles(void) -{ - return g_InGameSubtitles; -} - -u8 optionsGetCutsceneSubtitles(void) -{ - return g_CutsceneSubtitles; -} - -s32 optionsGetHeadRoll(s32 mpchrnum) -{ - return (g_PlayerConfigsArray[mpchrnum].options & OPTION_HEADROLL) != 0; -} - void optionsSetForwardPitch(s32 mpchrnum, bool enable) { if (enable) { @@ -203,16 +113,6 @@ void optionsSetShowMissionTime(s32 mpchrnum, bool enable) } } -void optionsSetInGameSubtitles(s32 enable) -{ - g_InGameSubtitles = enable; -} - -void optionsSetCutsceneSubtitles(s32 enable) -{ - g_CutsceneSubtitles = enable; -} - void optionsSetHeadRoll(s32 mpchrnum, bool enable) { if (enable) { @@ -246,43 +146,3 @@ s32 optionsGetEffectiveScreenSize(void) return g_ScreenSize; } - -s32 optionsGetScreenSize(void) -{ - return g_ScreenSize; -} - -void optionsSetScreenSize(s32 size) -{ - g_ScreenSize = size; -} - -s32 optionsGetScreenRatio(void) -{ - return g_ScreenRatio; -} - -void optionsSetScreenRatio(s32 ratio) -{ - g_ScreenRatio = ratio; -} - -u8 optionsGetScreenSplit(void) -{ - return g_ScreenSplit; -} - -void optionsSetScreenSplit(u8 split) -{ - g_ScreenSplit = split; -} - -u16 optionsGetMusicVolume(void) -{ - return musicGetVolume(); -} - -void optionsSetMusicVolume(u16 volume) -{ - musicSetVolume(volume); -} diff --git a/src/game/padhalllv.c b/src/game/padhalllv.c index eac8b2e00..f5a9b5eae 100644 --- a/src/game/padhalllv.c +++ b/src/game/padhalllv.c @@ -128,7 +128,8 @@ struct waypoint *waypointFindClosestToPos(struct coord *pos, s16 *rooms) checkmore[i] = false; } else if (cdresult == CDRESULT_COLLISION) { checkmore[i] = true; - cdGetEdge(&sp250[i], &sp1d8[i]); + sp250[i] = g_CdEdgeVtx1; + sp1d8[i] = g_CdEdgeVtx2; } else { closest = candwaypoints[i]; break; diff --git a/src/game/player.c b/src/game/player.c index c38161c63..27850df61 100644 --- a/src/game/player.c +++ b/src/game/player.c @@ -79,6 +79,7 @@ static void playerStartChrFade(f32 duration60, f32 targetfrac); static void playersClearMemCamRoom(void); static void playerTickChrBody(void); static void player0f0c1840(struct coord *pos, struct coord *up, struct coord *look, struct coord *pos2, s16 *rooms2); +static bool playerIsHealthVisible(void); s32 g_DefaultWeapons[2]; f32 g_MpSwirlRotateSpeed; @@ -775,7 +776,7 @@ static bool playerSpawnAnti(struct chrdata *hostchr, bool force) g_Vars.currentplayer->bondhealth = 1; } - chrSetShield(playerchr, chrGetShield(hostchr)); + chrSetShield(playerchr, hostchr->cshield); g_Vars.currentplayer->haschrbody = false; g_Vars.currentplayer->model00d4 = NULL; @@ -876,8 +877,8 @@ void playerSpawn(void) s32 prevplayernum = g_Vars.currentplayernum; setCurrentPlayerNum(g_Vars.bondplayernum); bgun0f0a0c08(&sp84, &sp9c); - mtx4RotateVec(camGetProjectionMtxF(), &sp9c, &sp90); - mtx4TransformVec(camGetProjectionMtxF(), &sp84, &sp78); + mtx4RotateVec(g_Vars.currentplayer->projectionmtx, &sp9c, &sp90); + mtx4TransformVec(g_Vars.currentplayer->projectionmtx, &sp84, &sp78); setCurrentPlayerNum(prevplayernum); } @@ -885,7 +886,7 @@ void playerSpawn(void) playerTickChrBody(); } - for (i = 0; i < chrsGetNumSlots(); i++) { + for (i = 0; i < g_NumChrSlots; i++) { if (g_ChrSlots[i].model && g_ChrSlots[i].prop && (g_ChrSlots[i].hidden & CHRHFLAG_00400000) @@ -1070,7 +1071,7 @@ void playerChooseBodyAndHead(s32 *bodynum, s32 *headnum, s32 *arg2) return; } - if (g_Vars.stagenum == STAGE_VILLA && lvGetDifficulty() >= DIFF_PA) { + if (g_Vars.stagenum == STAGE_VILLA && g_Difficulty >= DIFF_PA) { outfit = OUTFIT_NEGOTIATOR; } @@ -1234,7 +1235,7 @@ static void playerTickChrBody(void) // 1 player if (g_Vars.currentplayer->gunmem2 == NULL) { if (!var8009dfc0 && bgun0f09e004(2)) { - g_Vars.currentplayer->gunmem2 = bgunGetGunMem(); + g_Vars.currentplayer->gunmem2 = g_Vars.currentplayer->gunctrl.gunmem; } else { if (var8009dfc0); @@ -1277,7 +1278,6 @@ static void playerTickChrBody(void) } offset2 += 0x4000; - bgunCalculateGunMemCapacity(); spe8 = g_Vars.currentplayer->gunmem2 + offset2; texInitPool(&texpool, spe8, bgunCalculateGunMemCapacity() - offset2); bodyfiledata = modeldefLoad(g_HeadsAndBodies[bodynum].filenum, allocation + offset1, offset2 - offset1, &texpool); @@ -1298,12 +1298,6 @@ static void playerTickChrBody(void) animInit(model->anim); model->rwdatalen = 256; - - texGetPoolLeftPos(&texpool); - - // @TODO: Figure out these arguments - - texGetPoolLeftPos(&texpool); } else { // 2-4 players if (g_HeadsAndBodies[bodynum].filedata == NULL) { @@ -1411,7 +1405,7 @@ void playerRemoveChrBody(void) chrRemove(g_Vars.currentplayer->prop, false); g_Vars.currentplayer->model00d4 = NULL; bmoveUpdateRooms(g_Vars.currentplayer); - bgunFreeGunMem(); + g_Vars.currentplayer->gunctrl.gunmemowner = GUNMEMOWNER_FREE; g_Vars.currentplayer->gunmem2 = NULL; } } @@ -1433,7 +1427,7 @@ void playersBeginMpSwirl(void) g_MpSwirlForwardSpeed = 0; g_MpSwirlDistance = 80; - envChooseAndApply(mainGetStageNum(), false); + envChooseAndApply(g_StageNum, false); } static void playerTickMpSwirl(void) @@ -1507,7 +1501,7 @@ void player0f0b9a20(void) playerSetTickMode(TICKMODE_NORMAL); bmoveSetMode(MOVEMODE_WALK); - envChooseAndApply(mainGetStageNum(), false); + envChooseAndApply(g_StageNum, false); bgunEquipWeapon2(HAND_LEFT, g_DefaultWeapons[HAND_LEFT]); bgunEquipWeapon2(HAND_RIGHT, g_DefaultWeapons[HAND_RIGHT]); } @@ -1643,7 +1637,7 @@ static void playerTickCutscene(bool arg0) f32 sp118 = func0f15c888(); f32 fovy; s32 endframe; - s8 contpadnum = optionsGetContpadNum1(g_Vars.currentplayerstats->mpindex); + s8 contpadnum = g_PlayerConfigsArray[g_Vars.currentplayerstats->mpindex].contpad1; u16 buttons; #if PAL u8 stack3[0x2c]; @@ -1765,7 +1759,7 @@ static void playerTickCutscene(bool arg0) playerSetCameraMode(CAMERAMODE_THIRDPERSON); player0f0c1bd8(&pos, &up, &look); - playermgrSetFovY(fovy); + g_Vars.currentplayer->fovy = fovy; viSetFovY(fovy); if (g_Vars.currentplayerindex == 0) { @@ -1862,12 +1856,12 @@ void playerUpdateZoom(void) g_Vars.currentplayer->zoominfovy = g_Vars.currentplayer->zoominfovynew; } - playermgrSetFovY(g_Vars.currentplayer->zoominfovy); + g_Vars.currentplayer->fovy = g_Vars.currentplayer->zoominfovy; viSetFovY(g_Vars.currentplayer->zoominfovy); if (g_Vars.currentplayer->teleportstate != TELEPORTSTATE_INACTIVE) { fovy = playerGetTeleportFovY(); - playermgrSetFovY(fovy); + g_Vars.currentplayer->fovy = fovy; viSetFovY(fovy); } @@ -2012,8 +2006,8 @@ Gfx *playerDrawFade(Gfx *gdl, u32 r, u32 g, u32 b, f32 frac) gDPSetRenderMode(gdl++, G_RM_CLD_SURF, G_RM_CLD_SURF2); gDPSetCombineMode(gdl++, G_CC_PRIMITIVE, G_CC_PRIMITIVE); gDPSetPrimColor(gdl++, 0, 0, r, g, b, (s32)(frac * 255)); - gDPFillRectangle(gdl++, viGetViewLeft(), viGetViewTop(), - viGetViewLeft() + viGetViewWidth(), viGetViewTop() + viGetViewHeight()); + gDPFillRectangle(gdl++, g_ViBackData->viewleft, g_ViBackData->viewtop, + g_ViBackData->viewleft + g_ViBackData->viewx, g_ViBackData->viewtop + g_ViBackData->viewy); gDPPipeSync(gdl++); gDPSetColorDither(gdl++, G_CD_BAYER); gDPSetTexturePersp(gdl++, G_TP_PERSP); @@ -2424,7 +2418,7 @@ Gfx *playerRenderHealthBar(Gfx *gdl) gdl = healthbarDraw(gdl, NULL, 0, 0); - gSPMatrix(gdl++, osVirtualToPhysical(camGetPerspectiveMtxL()), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_PROJECTION); + gSPMatrix(gdl++, osVirtualToPhysical(g_Vars.currentplayer->perspmtxl), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_PROJECTION); return gdl; } @@ -2461,19 +2455,6 @@ static void playerTickExplode(void) } } -s16 playerGetFbWidth(void) -{ - s16 width = g_ViModes[VIRES_LO].fbwidth; - return width; -} - -s16 playerGetFbHeight(void) -{ - s16 height = g_ViModes[VIRES_LO].fbheight; - - return height; -} - bool playerHasSharedViewport(void) { if ((g_Vars.coopplayernum >= 0 || g_Vars.antiplayernum >= 0) @@ -2498,7 +2479,7 @@ static s16 playerGetViewportWidth(void) width--; } } else if (PLAYERCOUNT() == 2) { - if (optionsGetScreenSplit() == SCREENSPLIT_VERTICAL) { + if (g_ScreenSplit == SCREENSPLIT_VERTICAL) { // 2 players vsplit width = g_ViModes[VIRES_LO].width / 2; @@ -2535,7 +2516,7 @@ static s16 playerGetViewportLeft(void) left = g_ViModes[VIRES_LO].fbwidth - g_ViModes[VIRES_LO].width; } } else if (PLAYERCOUNT() == 2 && something != 0) { - if (optionsGetScreenSplit() == SCREENSPLIT_VERTICAL) { + if (g_ScreenSplit == SCREENSPLIT_VERTICAL) { if (g_Vars.currentplayernum == 1) { // 2 players vsplit - right side left = (g_ViModes[VIRES_LO].width / 2) + g_ViModes[VIRES_LO].fbwidth - g_ViModes[VIRES_LO].width; @@ -2565,7 +2546,7 @@ static s16 playerGetViewportHeight(void) height = tmp / 2; if (PLAYERCOUNT() == 2) { - if (optionsGetScreenSplit() == SCREENSPLIT_VERTICAL) { + if (g_ScreenSplit == SCREENSPLIT_VERTICAL) { height = tmp; } else if (g_Vars.currentplayernum == 0) { height--; @@ -2603,10 +2584,10 @@ static s16 playerGetViewportTop(void) if (PLAYERCOUNT() >= 2 && !playerHasSharedViewport()) { top = g_ViModes[VIRES_LO].fulltop; - if (optionsGetScreenSplit() != SCREENSPLIT_VERTICAL || PLAYERCOUNT() != 2) { + if (g_ScreenSplit != SCREENSPLIT_VERTICAL || PLAYERCOUNT() != 2) { if (PLAYERCOUNT() == 2 && g_Vars.currentplayernum == 1 - && optionsGetScreenSplit() != SCREENSPLIT_VERTICAL) { + && g_ScreenSplit != SCREENSPLIT_VERTICAL) { // 2 players hsplit - bottom side top = g_ViModes[VIRES_LO].fulltop + g_ViModes[VIRES_LO].fullheight / 2; } else if (g_Vars.currentplayernum == 2 || g_Vars.currentplayernum == 3) { @@ -2616,7 +2597,7 @@ static s16 playerGetViewportTop(void) } } else { if (optionsGetEffectiveScreenSize() == SCREENSIZE_WIDE) { - if (g_InCutscene && optionsGetCutsceneSubtitles() && g_Vars.stagenum != STAGE_CITRAINING) { + if (g_InCutscene && g_CutsceneSubtitles && g_Vars.stagenum != STAGE_CITRAINING) { if (var8009de2c >= 1) { f32 a = g_ViModes[VIRES_LO].fulltop; f32 b = g_ViModes[VIRES_LO].widetop; @@ -2633,7 +2614,7 @@ static s16 playerGetViewportTop(void) top = g_ViModes[VIRES_LO].cinematop; } else { if (g_InCutscene && !var8009dfc0 - && (!optionsGetCutsceneSubtitles() || g_Vars.stagenum == STAGE_CITRAINING)) { + && (!g_CutsceneSubtitles || g_Vars.stagenum == STAGE_CITRAINING)) { if (var8009de2c >= 1) { f32 a = g_ViModes[VIRES_LO].widetop; f32 b = g_ViModes[VIRES_LO].fulltop; @@ -2763,7 +2744,7 @@ static void playerTickTeleport(f32 *aspectratio) if (g_Vars.currentplayer->teleportstate != TELEPORTSTATE_INACTIVE) { f32 fovy = playerGetTeleportFovY(); - playermgrSetFovY(fovy); + g_Vars.currentplayer->fovy = fovy; viSetFovY(fovy); } } @@ -2774,8 +2755,8 @@ void playerConfigureVi(void) text0f1531dc(false); - playermgrSetFovY(60); - playermgrSetAspectRatio(ratio); + g_Vars.currentplayer->fovy = 60; + g_Vars.currentplayer->aspect = ratio; playermgrSetViewSize(playerGetViewportWidth(), playerGetViewportHeight()); playermgrSetViewPosition(playerGetViewportLeft(), playerGetViewportTop()); @@ -2784,8 +2765,8 @@ void playerConfigureVi(void) viSetFovAspectAndSize(60, ratio, playerGetViewportWidth(), playerGetViewportHeight()); viSetViewPosition(playerGetViewportLeft(), playerGetViewportTop()); - viSetSize(playerGetFbWidth(), playerGetFbHeight()); - viSetBufSize(playerGetFbWidth(), playerGetFbHeight()); + viSetSize(g_ViModes[VIRES_LO].fbwidth, g_ViModes[VIRES_LO].fbheight); + viSetBufSize(g_ViModes[VIRES_LO].fbwidth, g_ViModes[VIRES_LO].fbheight); } void playerTick(bool arg0) @@ -2795,7 +2776,7 @@ void playerTick(bool arg0) text0f1531dc(false); - if (optionsGetScreenRatio() == SCREENRATIO_16_9) { + if (g_ScreenRatio == SCREENRATIO_16_9) { aspectratio = player0f0bd358() * 1.33333333f; } else { aspectratio = player0f0bd358(); @@ -2809,16 +2790,16 @@ void playerTick(bool arg0) playerTickTeleport(&aspectratio); } - playermgrSetFovY(60); - playermgrSetAspectRatio(aspectratio); + g_Vars.currentplayer->fovy = 60; + g_Vars.currentplayer->aspect = aspectratio; playermgrSetViewSize(playerGetViewportWidth(), playerGetViewportHeight()); playermgrSetViewPosition(playerGetViewportLeft(), playerGetViewportTop()); viSetMode(g_ViModes[VIRES_LO].xscale); viSetFovAspectAndSize(60, aspectratio, playerGetViewportWidth(), playerGetViewportHeight()); viSetViewPosition(playerGetViewportLeft(), playerGetViewportTop()); - viSetSize(playerGetFbWidth(), playerGetFbHeight()); - viSetBufSize(playerGetFbWidth(), playerGetFbHeight()); + viSetSize(g_ViModes[VIRES_LO].fbwidth, g_ViModes[VIRES_LO].fbheight); + viSetBufSize(g_ViModes[VIRES_LO].fbwidth, g_ViModes[VIRES_LO].fbheight); playerUpdateColourScreenProperties(); playerTickChrFade(); @@ -2859,7 +2840,7 @@ void playerTick(bool arg0) // Eyespy is deployed if (g_Vars.currentplayer->eyespy->active) { // And is being controlled - s8 contpad1 = optionsGetContpadNum1(g_Vars.currentplayerstats->mpindex); + s8 contpad1 = g_PlayerConfigsArray[g_Vars.currentplayerstats->mpindex].contpad1; u16 buttons = arg0 ? joyGetButtons(contpad1, 0xffff) : 0; if (g_Vars.currentplayer->isdead == false @@ -2908,7 +2889,7 @@ void playerTick(bool arg0) } } - if (lvIsPaused()) { + if (g_LvIsPaused) { playerStopAudioForPause(); } @@ -2948,7 +2929,7 @@ void playerTick(bool arg0) && g_Vars.currentplayer->eyespy->active) { // Controlling an eyespy struct coord sp308; - playermgrSetFovY(120); + g_Vars.currentplayer->fovy = 120; viSetFovY(120); sp308 = g_Vars.currentplayer->eyespy->prop->pos; playerTickChrBody(); @@ -3027,10 +3008,10 @@ void playerTick(bool arg0) if (rocket->base.hidden & OBJHFLAG_PROJECTILE) { struct projectile *projectile = rocket->base.projectile; - u32 mode = optionsGetControlMode(g_Vars.currentplayerstats->mpindex); + u32 mode = g_PlayerConfigsArray[g_Vars.currentplayerstats->mpindex].controlmode; f32 targetspeed; - s8 contpad1 = optionsGetContpadNum1(g_Vars.currentplayerstats->mpindex); - s8 contpad2 = optionsGetContpadNum2(g_Vars.currentplayerstats->mpindex); + s8 contpad1 = g_PlayerConfigsArray[g_Vars.currentplayerstats->mpindex].contpad1; + s8 contpad2 = g_PlayerConfigsArray[g_Vars.currentplayerstats->mpindex].contpad2; s8 stickx = 0; s8 sticky = 0; Mtxf sp1fc; @@ -3548,7 +3529,7 @@ void playerTick(bool arg0) playerRemoveChrBody(); pad = &g_Pads[g_Vars.currentplayer->autocontrol_aimpad]; - if (mainGetStageNum() == g_Stages[STAGEINDEX_EXTRACTION].id + if (g_StageNum == g_Stages[STAGEINDEX_EXTRACTION].id && g_Vars.currentplayer->autocontrol_aimpad == 0x19) { xdist = pad->pos.x - 100 - g_Vars.currentplayer->bond2.unk10.x; } else { @@ -3739,7 +3720,7 @@ static void playerSetGlobalDrawCameraOffset(void) { g_Vars.currentplayer->globaldrawcameraoffset = g_Vars.currentplayer->globaldrawworldoffset; - mtx4RotateVecInPlace(camGetWorldToScreenMtxf(), &g_Vars.currentplayer->globaldrawcameraoffset); + mtx4RotateVecInPlace(g_Vars.currentplayer->worldtoscreenmtx, &g_Vars.currentplayer->globaldrawcameraoffset); } static void playerAllocateMatrices(struct coord *cam_pos, struct coord *cam_look, struct coord *cam_up) @@ -3755,7 +3736,7 @@ static void playerAllocateMatrices(struct coord *cam_pos, struct coord *cam_look s32 i; s32 j; - scale = currentPlayerGetScaleBg2Gfx(); + scale = g_Vars.currentplayerstats->scale_bg2gfx; playerSetGlobalDrawWorldOffset(g_Vars.currentplayer->cam_room); g_Vars.currentplayer->mtxl005c = gfxAllocateMatrix(); @@ -3795,7 +3776,7 @@ static void playerAllocateMatrices(struct coord *cam_pos, struct coord *cam_look s1 = gfxAllocateMatrix(); s0 = gfxAllocateMatrix(); - mtx4MultMtx4(camGetMtxF1754(), &sp8c, s0); + mtx4MultMtx4(g_Vars.currentplayer->mtxf1754, &sp8c, s0); for (i = 0; i < 4; i++) { for (j = 0; j < 4; j++) { @@ -3807,17 +3788,17 @@ static void playerAllocateMatrices(struct coord *cam_pos, struct coord *cam_look } } - camSetMtxF006c(s0); + g_Vars.currentplayer->mtxf006c = s0; guMtxF2L(s0->m, s1); - camSetOrthogonalMtxL(s1); + g_Vars.currentplayer->orthomtxl = s1; mtx00015f04(scale, &sp8c); guMtxF2L(sp8c.m, g_Vars.currentplayer->mtxl005c); mtx00016820(g_Vars.currentplayer->mtxl005c, g_Vars.currentplayer->mtxl0060); - camSetMtxL173c(g_Vars.currentplayer->mtxl005c); - camSetMtxL1738(g_Vars.currentplayer->mtxl0060); + g_Vars.currentplayer->mtxl173c = g_Vars.currentplayer->mtxl005c; + g_Vars.currentplayer->mtxl1738 = g_Vars.currentplayer->mtxl0060; camSetWorldToScreenMtxf(g_Vars.currentplayer->mtxf0064); camSetProjectionMtxF(g_Vars.currentplayer->mtxf0068); - camSetLookAt(lookat); + g_Vars.currentplayer->lookat = lookat; cam0f0b5838(); playerSetGlobalDrawCameraOffset(); } @@ -3906,13 +3887,13 @@ static Gfx *playerRenderShield(Gfx *gdl) } f20 = (sinf(g_Vars.currentplayer->shieldshowrot * (M_BADTAU / maxrotf)) + 1) * 0.5f; - sp90[0] = camGetScreenLeft() + camGetScreenWidth() * f20; + sp90[0] = g_Vars.currentplayer->c_screenleft + g_Vars.currentplayer->c_screenwidth * f20; f20 = (cosf(g_Vars.currentplayer->shieldshowrot * (M_BADTAU / maxrotf)) + 1) * 0.5f; - sp90[1] = camGetScreenTop() + camGetScreenHeight() * f20; + sp90[1] = g_Vars.currentplayer->c_screentop + g_Vars.currentplayer->c_screenheight * f20; - sp88[0] = camGetScreenWidth() * (1.0f + 0.002f * ((g_Vars.currentplayer->shieldshowrnd >> 20) % 100) + (g_Vars.currentplayer->shieldshowtime * (0.2f + 0.002f * (g_Vars.currentplayer->shieldshowrnd % 100)) * (1.0f / 60.0f))); - sp88[1] = camGetScreenHeight() * (1.0f + 0.002f * ((g_Vars.currentplayer->shieldshowrnd >> 24) % 100) + (g_Vars.currentplayer->shieldshowtime * (0.2f + 0.002f * ((g_Vars.currentplayer->shieldshowrnd >> 8) % 100)) * (1.0f / 60.0f))); + sp88[0] = g_Vars.currentplayer->c_screenwidth * (1.0f + 0.002f * ((g_Vars.currentplayer->shieldshowrnd >> 20) % 100) + (g_Vars.currentplayer->shieldshowtime * (0.2f + 0.002f * (g_Vars.currentplayer->shieldshowrnd % 100)) * (1.0f / 60.0f))); + sp88[1] = g_Vars.currentplayer->c_screenheight * (1.0f + 0.002f * ((g_Vars.currentplayer->shieldshowrnd >> 24) % 100) + (g_Vars.currentplayer->shieldshowtime * (0.2f + 0.002f * ((g_Vars.currentplayer->shieldshowrnd >> 8) % 100)) * (1.0f / 60.0f))); chr0f0295f8(shield, &red, &green, &blue); @@ -4068,10 +4049,10 @@ Gfx *playerRenderHud(Gfx *gdl) // Draw menu if (g_Vars.currentplayer->cameramode != CAMERAMODE_EYESPY && g_Vars.currentplayer->mpmenuon) { - s32 a = viGetViewLeft(); - s32 b = viGetViewTop(); - s32 c = viGetViewLeft() + viGetViewWidth(); - s32 d = viGetViewTop() + viGetViewHeight(); + s32 a = g_ViBackData->viewleft; + s32 b = g_ViBackData->viewtop; + s32 c = g_ViBackData->viewleft + g_ViBackData->viewx; + s32 d = g_ViBackData->viewtop + g_ViBackData->viewy; gdl = text0f153628(gdl); gdl = text0f153a34(gdl, a, b, c, d, 0x000000a0); @@ -4137,7 +4118,7 @@ Gfx *playerRenderHud(Gfx *gdl) if (g_Vars.antiplayernum >= 0 && g_Vars.currentplayer == g_Vars.anti) { // Anti - if (joyGetButtons(optionsGetContpadNum1(g_Vars.currentplayerstats->mpindex), 0xb000) && !mpIsPaused()) { + if (joyGetButtons(g_PlayerConfigsArray[g_Vars.currentplayerstats->mpindex].contpad1, 0xb000) && !mpIsPaused()) { g_Vars.currentplayer->dostartnewlife = true; } } else { @@ -4150,7 +4131,7 @@ Gfx *playerRenderHud(Gfx *gdl) f32 stealhealth; f32 shield; - canrestart = joyGetButtons(optionsGetContpadNum1(g_Vars.currentplayerstats->mpindex), 0xb000) + canrestart = joyGetButtons(g_PlayerConfigsArray[g_Vars.currentplayerstats->mpindex].contpad1, 0xb000) && !mpIsPaused(); // Get ready to respawn. @@ -4158,7 +4139,7 @@ Gfx *playerRenderHud(Gfx *gdl) buddyplayernum = g_Vars.currentplayer == g_Vars.coop ? g_Vars.bondplayernum : g_Vars.coopplayernum; setCurrentPlayerNum(buddyplayernum); - shield = chrGetShield(g_Vars.currentplayer->prop->chr) * 0.125f; + shield = g_Vars.currentplayer->prop->chr->cshield * 0.125f; totalhealth = g_Vars.currentplayer->bondhealth + shield; // NTSC final prevents coop from being able to respawn @@ -4166,7 +4147,7 @@ Gfx *playerRenderHud(Gfx *gdl) // the player could respawn on the other side of the exit trigger. // Additionally, the logic for coopcanrestart is different. if (totalhealth > 0.125f - && !(mainGetStageNum() == STAGE_DEEPSEA && chrHasStageFlag(NULL, 0x00000200))) { + && !(g_StageNum == STAGE_DEEPSEA && (g_StageFlags & 0x00000200))) { if (canrestart) { playerDisplayHealth(); @@ -4227,7 +4208,7 @@ Gfx *playerRenderHud(Gfx *gdl) } } - if (joyGetButtons(optionsGetContpadNum1(g_Vars.currentplayerstats->mpindex), 0xb000) + if (joyGetButtons(g_PlayerConfigsArray[g_Vars.currentplayerstats->mpindex].contpad1, 0xb000) && !mpIsPaused() && g_MpMatchIsEnding == 0) { canrestart = true; @@ -4283,10 +4264,10 @@ Gfx *playerRenderHud(Gfx *gdl) } if (g_Vars.currentplayer->mpmenuon) { - s32 a = viGetViewLeft(); - s32 b = viGetViewTop(); - s32 c = viGetViewLeft() + viGetViewWidth(); - s32 d = viGetViewTop() + viGetViewHeight(); + s32 a = g_ViBackData->viewleft; + s32 b = g_ViBackData->viewtop; + s32 c = g_ViBackData->viewleft + g_ViBackData->viewx; + s32 d = g_ViBackData->viewtop + g_ViBackData->viewy; gdl = text0f153628(gdl); gdl = text0f153a34(gdl, a, b, c, d, 0x000000a0); @@ -4406,7 +4387,7 @@ f32 playerGetHealthBarHeightFrac(void) return 1; } -bool playerIsHealthVisible(void) +static bool playerIsHealthVisible(void) { return g_Vars.currentplayer->healthshowmode != HEALTHSHOWMODE_HIDDEN; } @@ -4661,7 +4642,7 @@ f32 playerGetHealthFrac(void) f32 playerGetShieldFrac(void) { - f32 frac = chrGetShield(g_Vars.currentplayer->prop->chr) * 0.125f; + f32 frac = g_Vars.currentplayer->prop->chr->cshield * 0.125f; if (frac < 0) { frac = 0; @@ -4761,7 +4742,7 @@ s32 playerTickThirdPerson(struct prop *prop) spe8 = player->model00d4->matrices; } - mtx00015be4(camGetProjectionMtxF(), spe8, &spa8); + mtx00015be4(g_Vars.currentplayer->projectionmtx, spe8, &spa8); sp9c.x = spa8.m[3][0] + spa8.m[1][0] * 7; sp9c.y = spa8.m[3][1] + spa8.m[1][1] * 7; @@ -5161,7 +5142,7 @@ void player0f0c3320(Mtxf *matrices, s32 count) s32 j; for (i = 0, j = 0; i < count; i++, j += sizeof(Mtxf)) { - mtx00015be4(camGetProjectionMtxF(), (Mtxf *)((u32)matrices + j), &sp40); + mtx00015be4(g_Vars.currentplayer->projectionmtx, (Mtxf *)((u32)matrices + j), &sp40); sp40.m[3][0] -= g_Vars.currentplayer->globaldrawworldoffset.x; sp40.m[3][1] -= g_Vars.currentplayer->globaldrawworldoffset.y; diff --git a/src/game/playermgr.c b/src/game/playermgr.c index 057fcbcbf..189b53b9a 100644 --- a/src/game/playermgr.c +++ b/src/game/playermgr.c @@ -76,7 +76,7 @@ void playermgrAllocatePlayers(s32 count) playermgrAllocatePlayer(0); setCurrentPlayerNum(0); - playermgrSetViewSize(playerGetFbWidth(), playerGetFbHeight()); + playermgrSetViewSize(g_ViModes[VIRES_LO].fbwidth, g_ViModes[VIRES_LO].fbheight); g_Vars.coop = NULL; g_Vars.anti = NULL; @@ -423,7 +423,6 @@ static void playermgrAllocatePlayer(s32 index) g_Vars.players[index]->gunshadecol[2] = 0xff; g_Vars.players[index]->gunshadecol[3] = 0; g_Vars.players[index]->resetshadecol = true; - g_Vars.players[index]->aimtype = 0; g_Vars.players[index]->lookingatprop.prop = NULL; for (i = 0; i < 4; i++) { @@ -685,16 +684,6 @@ void playermgrSetViewPosition(s32 viewleft, s32 viewtop) g_Vars.currentplayer->viewtop = viewtop; } -void playermgrSetFovY(f32 fovy) -{ - g_Vars.currentplayer->fovy = fovy; -} - -void playermgrSetAspectRatio(f32 aspect) -{ - g_Vars.currentplayer->aspect = aspect; -} - s32 playermgrGetModelOfWeapon(s32 weapon) { switch (weapon) { diff --git a/src/game/playerreset.c b/src/game/playerreset.c index cdb048128..0b87f9cf1 100644 --- a/src/game/playerreset.c +++ b/src/game/playerreset.c @@ -414,7 +414,7 @@ void playerReset(void) &g_Vars.currentplayer->bond2.unk28, &g_Vars.currentplayer->bond2.unk1c, rooms[0]); - numchrs = chrsGetNumSlots(); + numchrs = g_NumChrSlots; for (i = 0; i < numchrs; i++) { chr = &g_ChrSlots[i]; diff --git a/src/game/prop.c b/src/game/prop.c index 3a43e9ed0..920b11df4 100644 --- a/src/game/prop.c +++ b/src/game/prop.c @@ -104,14 +104,6 @@ void propsSort(void) } } -/** - * Enable a prop. This is the opposite of disabling (see propDisable below). - */ -void propEnable(struct prop *prop) -{ - prop->flags |= PROPFLAG_ENABLED; -} - /** * Disable the given prop. Disabled props do not tick, do not render and do not * have any collision checks. This is commonly used for chrs who "spawn" later @@ -668,7 +660,7 @@ static struct prop *shotCalculateHits(s32 handnum, bool arg1, struct coord *arg2 } if (hitbg && shotdata.gset.weaponnum != WEAPON_FARSIGHT) { - mtx4TransformVec(camGetWorldToScreenMtxf(), &sp694.unk00, &sp658); + mtx4TransformVec(g_Vars.currentplayer->worldtoscreenmtx, &sp694.unk00, &sp658); if (shotdata.unk34 > -sp658.z) { shotdata.unk34 = -sp658.z; @@ -928,8 +920,8 @@ struct prop *func0f061d54(s32 handnum, u32 arg1, u32 arg2) sp58.y -= 15 * RANDOMFRAC(); } - mtx4TransformVec(camGetProjectionMtxF(), &sp58, &sp40); - mtx4RotateVec(camGetProjectionMtxF(), &sp64, &sp4c); + mtx4TransformVec(g_Vars.currentplayer->projectionmtx, &sp58, &sp40); + mtx4RotateVec(g_Vars.currentplayer->projectionmtx, &sp64, &sp4c); return shotCalculateHits(handnum, arg1, &sp58, &sp64, &sp40, &sp4c, 0, 4294836224, PLAYERCOUNT() >= 2); } @@ -944,8 +936,8 @@ static void shotCreate(s32 handnum, bool arg1, bool dorandom, s32 arg3, bool arg bgunCalculatePlayerShotSpread(&sp38, &sp44, handnum, dorandom); if (arg3 > 0) { - mtx4TransformVec(camGetProjectionMtxF(), &sp38, &shootpos); - mtx4RotateVec(camGetProjectionMtxF(), &sp44, &shootdir); + mtx4TransformVec(g_Vars.currentplayer->projectionmtx, &sp38, &shootpos); + mtx4RotateVec(g_Vars.currentplayer->projectionmtx, &sp44, &shootdir); shotCalculateHits(handnum, arg1, &sp38, &sp44, &shootpos, &shootdir, 0, 4294836224, arg4); @@ -1115,10 +1107,10 @@ static void handInflictCloseRangeDamage(s32 handnum, struct gset *gset, bool arg bgunGetCrossPos(&x, &y); - spfc[0] = (x - camGetScreenLeft()) / (camGetScreenWidth() * 0.5f) - 1.0f; - spfc[1] = (y - camGetScreenTop()) / (camGetScreenHeight() * 0.5f) - 1.0f; - spf4[0] = camGetScreenHeight() * 0.16666667163372f; - spf4[1] = camGetScreenHeight() * 0.125f; + spfc[0] = (x - g_Vars.currentplayer->c_screenleft) / (g_Vars.currentplayer->c_screenwidth * 0.5f) - 1.0f; + spfc[1] = (y - g_Vars.currentplayer->c_screentop) / (g_Vars.currentplayer->c_screenheight * 0.5f) - 1.0f; + spf4[0] = g_Vars.currentplayer->c_screenheight * 0.16666667163372f; + spf4[1] = g_Vars.currentplayer->c_screenheight * 0.125f; if (isglass) { model = obj->model; @@ -1164,10 +1156,10 @@ static void handInflictCloseRangeDamage(s32 handnum, struct gset *gset, bool arg if (!chrIsAvoiding(chr)) { bgunCalculatePlayerShotSpread(&spb8, &vector, handnum, true); skipthething = true; - mtx4RotateVecInPlace(camGetProjectionMtxF(), &vector); + mtx4RotateVecInPlace(g_Vars.currentplayer->projectionmtx, &vector); bgunPlayPropHitSound(gset, prop, -1); - if (chr->model && chrGetShield(chr) > 0) { + if (chr->model && chr->cshield > 0) { chrCalculateShieldHit(chr, &playerprop->pos, &vector, &node, &hitpart, &model, &side); } @@ -1213,8 +1205,8 @@ static void handTickAttack(s32 handnum) g_Vars.currentplayer->hands[handnum].unk0d0f_02 = false; } - if (bgunIsFiring(handnum)) { - s32 type = bgunGetAttackType(handnum); + if (g_Vars.currentplayer->hands[handnum].firing) { + s32 type = g_Vars.currentplayer->hands[handnum].attacktype; s32 weaponnum = bgunGetWeaponNum(handnum); struct gset gset; bool cloaked; @@ -1228,7 +1220,7 @@ static void handTickAttack(s32 handnum) case HANDATTACKTYPE_SHOOT: // Always execute if right hand, but if left hand then execute if // right hand is not (ie. prevent firing both guns on the same tick) - if (handnum == HAND_RIGHT || !bgunIsFiring(HAND_RIGHT)) { + if (handnum == HAND_RIGHT || !g_Vars.currentplayer->hands[HAND_RIGHT].firing) { chrUncloakTemporarily(g_Vars.currentplayer->prop->chr); mpstatsIncrementPlayerShotCount2(&gset, 0); @@ -2227,15 +2219,15 @@ static f32 func0f06438c(struct prop *prop, struct coord *arg1, f32 *arg2, f32 *a } if (sp50) { - top = camGetScreenTop(); - bottom = camGetScreenTop() + camGetScreenHeight(); - left = camGetScreenLeft(); - right = camGetScreenLeft() + camGetScreenWidth(); + top = g_Vars.currentplayer->c_screentop; + bottom = g_Vars.currentplayer->c_screentop + g_Vars.currentplayer->c_screenheight; + left = g_Vars.currentplayer->c_screenleft; + right = g_Vars.currentplayer->c_screenleft + g_Vars.currentplayer->c_screenwidth; } else { - top = camGetScreenTop() + camGetScreenHeight() * 0.175f; - bottom = camGetScreenTop() + camGetScreenHeight() * 0.825f; - left = camGetScreenLeft() + camGetScreenWidth() * 0.25f; - right = camGetScreenLeft() + camGetScreenWidth() * 0.75f; + top = g_Vars.currentplayer->c_screentop + g_Vars.currentplayer->c_screenheight * 0.175f; + bottom = g_Vars.currentplayer->c_screentop + g_Vars.currentplayer->c_screenheight * 0.825f; + left = g_Vars.currentplayer->c_screenleft + g_Vars.currentplayer->c_screenwidth * 0.25f; + right = g_Vars.currentplayer->c_screenleft + g_Vars.currentplayer->c_screenwidth * 0.75f; } if (arg1->z > -2.5f) { @@ -2273,8 +2265,8 @@ static f32 func0f06438c(struct prop *prop, struct coord *arg1, f32 *arg2, f32 *a sp48 = sp48 * g_AutoAimScale; } - sp4c = camGetScreenLeft() + 0.5f * camGetScreenWidth() >= (sp8c[0] + sp84[0]) * 0.5f - sp48 - && camGetScreenLeft() + 0.5f * camGetScreenWidth() <= (sp8c[0] + sp84[0]) * 0.5f + sp48 + sp4c = g_Vars.currentplayer->c_screenleft + 0.5f * g_Vars.currentplayer->c_screenwidth >= (sp8c[0] + sp84[0]) * 0.5f - sp48 + && g_Vars.currentplayer->c_screenleft + 0.5f * g_Vars.currentplayer->c_screenwidth <= (sp8c[0] + sp84[0]) * 0.5f + sp48 && left <= spa0[0] && right >= spa0[0]; } @@ -2311,13 +2303,13 @@ static f32 func0f06438c(struct prop *prop, struct coord *arg1, f32 *arg2, f32 *a arg4[0] = value; } - if (camGetScreenLeft() + 0.5f * camGetScreenWidth() >= sp8c[0] - && camGetScreenLeft() + 0.5f * camGetScreenWidth() <= sp84[0]) { + if (g_Vars.currentplayer->c_screenleft + 0.5f * g_Vars.currentplayer->c_screenwidth >= sp8c[0] + && g_Vars.currentplayer->c_screenleft + 0.5f * g_Vars.currentplayer->c_screenwidth <= sp84[0]) { result = 1; - } else if (camGetScreenLeft() + 0.5f * camGetScreenWidth() >= sp8c[0]) { - result = 1 - ((camGetScreenLeft() + 0.5f * camGetScreenWidth()) - sp84[0]) / sp48; + } else if (g_Vars.currentplayer->c_screenleft + 0.5f * g_Vars.currentplayer->c_screenwidth >= sp8c[0]) { + result = 1 - ((g_Vars.currentplayer->c_screenleft + 0.5f * g_Vars.currentplayer->c_screenwidth) - sp84[0]) / sp48; } else { - result = 1 - (sp8c[0] - (camGetScreenLeft() + 0.5f * camGetScreenWidth())) / sp48; + result = 1 - (sp8c[0] - (g_Vars.currentplayer->c_screenleft + 0.5f * g_Vars.currentplayer->c_screenwidth)) / sp48; } } @@ -2337,7 +2329,7 @@ static void farsightChooseTarget(void) s32 i; if (weaponnum == WEAPON_FARSIGHT) { - s32 numchrs = chrsGetNumSlots(); + s32 numchrs = g_NumChrSlots; for (i = numchrs - 1; i >= 0; i--) { struct prop *prop = g_ChrSlots[i].prop; @@ -2394,10 +2386,10 @@ static struct prop *autoaimFindBestCmpProp(f32 aimpos[2]) && (trackedprop->x1 >= 0 || trackedprop->x2 >= 0) && (trackedprop->y1 >= 0 || trackedprop->y2 >= 0)) { // Define the aim limits - f32 top = camGetScreenTop() + camGetScreenHeight() * 0.125f; - f32 bottom = camGetScreenTop() + camGetScreenHeight() * 0.875f; - f32 left = camGetScreenLeft() + camGetScreenWidth() * 0.125f; - f32 right = camGetScreenLeft() + camGetScreenWidth() * 0.875f; + f32 top = g_Vars.currentplayer->c_screentop + g_Vars.currentplayer->c_screenheight * 0.125f; + f32 bottom = g_Vars.currentplayer->c_screentop + g_Vars.currentplayer->c_screenheight * 0.875f; + f32 left = g_Vars.currentplayer->c_screenleft + g_Vars.currentplayer->c_screenwidth * 0.125f; + f32 right = g_Vars.currentplayer->c_screenleft + g_Vars.currentplayer->c_screenwidth * 0.875f; struct chrdata *chr = NULL; bestprop = trackedprop->prop; @@ -2527,8 +2519,8 @@ static struct prop *autoaimFindGeneralProp(f32 aimpos[2]) static void autoaimSetProp(struct prop *prop, f32 aimpos[2]) { if (prop) { - f32 x = (aimpos[0] - camGetScreenLeft()) / (camGetScreenWidth() * 0.5f) - 1; - f32 y = (aimpos[1] - camGetScreenTop()) / (camGetScreenHeight() * 0.5f) - 1; + f32 x = (aimpos[0] - g_Vars.currentplayer->c_screenleft) / (g_Vars.currentplayer->c_screenwidth * 0.5f) - 1; + f32 y = (aimpos[1] - g_Vars.currentplayer->c_screentop) / (g_Vars.currentplayer->c_screenheight * 0.5f) - 1; bmoveUpdateAutoAimProp(prop, x, y); } else { bmoveUpdateAutoAimProp(NULL, 0, 0); diff --git a/src/game/propobj.c b/src/game/propobj.c index 6105f2ccb..02424adca 100644 --- a/src/game/propobj.c +++ b/src/game/propobj.c @@ -185,7 +185,7 @@ bool doorCallLift(struct prop *doorprop, bool allowclose) handled = false; } else { bool vacant = true; - s32 numchrslots = chrsGetNumSlots(); + s32 numchrslots = g_NumChrSlots; s32 i; for (i = 0; i < PLAYERCOUNT(); i++) { @@ -893,8 +893,8 @@ void func0f06803c(struct coord *arg0, f32 *arg1, f32 *arg2, f32 *arg3, f32 *arg4 struct coord sp4c; f32 sp44[2]; - f32 aspect = viGetAspect(); - f32 fovy = viGetFovY(); + f32 aspect = g_ViBackData->aspect; + f32 fovy = g_ViBackData->fovy; if (g_Vars.currentplayer->devicesactive & ~g_Vars.currentplayer->devicesinhibit & DEVICE_EYESPY) { if (g_Vars.currentplayer->eyespy && g_Vars.currentplayer->eyespy->active) { @@ -1997,8 +1997,7 @@ static struct prop *objInit(struct defaultobj *obj, struct modelfiledata *fileda obj->floorcol = 0xfff; obj->model->obj = obj; obj->model->unk01 = 0; - - modelSetScale(obj->model, g_ModelStates[obj->modelnum].scale * (1.0f / 4096.0f)); + obj->model->scale = g_ModelStates[obj->modelnum].scale * (1.0f / 4096.0f); prop->type = PROPTYPE_OBJ; prop->obj = obj; @@ -2369,7 +2368,7 @@ void objFree(struct defaultobj *obj, bool freeprop, bool canregen) // If obj is an occupied chair, remove the chr from it if (obj->hidden & OBJHFLAG_OCCUPIEDCHAIR) { - s32 numchrs = chrsGetNumSlots(); + s32 numchrs = g_NumChrSlots; s32 i; obj->hidden &= ~OBJHFLAG_OCCUPIEDCHAIR; @@ -2483,23 +2482,15 @@ bool func0f06b39c(struct coord *arg0, struct coord *arg1, struct coord *arg2, f3 static bool func0f06b488(struct prop *prop, struct coord *arg1, struct coord *arg2, struct coord *arg3, struct coord *arg4, struct coord *arg5, f32 *arg6) { - struct coord sp3c; - struct coord sp30; - f32 f0; - struct coord sp20; - if (!cd0002ded8(arg1, arg2, prop)) { - cdGetEdge(&sp3c, &sp30); - cdGetPos(&sp20); - - f0 = (sp20.f[0] - arg1->f[0]) * arg3->f[0] - + (sp20.f[1] - arg1->f[1]) * arg3->f[1] - + (sp20.f[2] - arg1->f[2]) * arg3->f[2]; + f32 f0 = (g_CdObstaclePos.f[0] - arg1->f[0]) * arg3->f[0] + + (g_CdObstaclePos.f[1] - arg1->f[1]) * arg3->f[1] + + (g_CdObstaclePos.f[2] - arg1->f[2]) * arg3->f[2]; if (f0 < *arg6) { *arg6 = f0; - *arg4 = sp20; + *arg4 = g_CdObstaclePos; arg5->x = -arg3->x; arg5->y = 0.0f; @@ -2574,8 +2565,8 @@ static bool func0f06b610(struct defaultobj *obj, struct coord *arg1, struct coor *arg9 = sum2; - mtx4TransformVec(camGetProjectionMtxF(), &spfc, arg7); - mtx4RotateVec(camGetProjectionMtxF(), &spf0, arg8); + mtx4TransformVec(g_Vars.currentplayer->projectionmtx, &spfc, arg7); + mtx4RotateVec(g_Vars.currentplayer->projectionmtx, &spf0, arg8); if (arg8->x != 0.0f || arg8->y != 0.0f || arg8->z != 0.0f) { guNormalize(&arg8->x, &arg8->y, &arg8->z); @@ -2645,7 +2636,7 @@ static bool func0f06b610(struct defaultobj *obj, struct coord *arg1, struct coor *arg9 = sum1; - mtx4TransformVec(camGetProjectionMtxF(), &spfc, arg7); + mtx4TransformVec(g_Vars.currentplayer->projectionmtx, &spfc, arg7); if (spf0.f[0] * arg6->f[0] + spf0.f[1] * arg6->f[1] + spf0.f[2] * arg6->f[2] > 0.0f) { spf0.f[0] = -spf0.f[0]; @@ -2653,7 +2644,7 @@ static bool func0f06b610(struct defaultobj *obj, struct coord *arg1, struct coor spf0.f[2] = -spf0.f[2]; } - mtx4RotateVec(camGetProjectionMtxF(), &spf0, arg8); + mtx4RotateVec(g_Vars.currentplayer->projectionmtx, &spf0, arg8); if (arg8->f[0] != 0.0f || arg8->f[1] != 0.0f || arg8->f[2] != 0.0f) { guNormalize(&arg8->x, &arg8->y, &arg8->z); @@ -2866,7 +2857,7 @@ static bool func0f06c28c(struct chrdata *chr, struct coord *arg1, struct coord * struct modelnode *sp74 = NULL; struct model *model = chr->model; - if (chrGetShield(chr) > 0.0f) { + if (chr->cshield > 0.0f) { var8005efc0 = 10.0f / chr->model->scale; } @@ -2888,8 +2879,8 @@ static bool func0f06c28c(struct chrdata *chr, struct coord *arg1, struct coord * *arg9 = spec; - mtx4TransformVec(camGetProjectionMtxF(), &spb8, arg7); - mtx4RotateVec(camGetProjectionMtxF(), &spac, arg8); + mtx4TransformVec(g_Vars.currentplayer->projectionmtx, &spb8, arg7); + mtx4RotateVec(g_Vars.currentplayer->projectionmtx, &spac, arg8); if (arg8->x != 0.0f || arg8->y != 0.0f || arg8->z != 0.0f) { guNormalize(&arg8->x, &arg8->y, &arg8->z); @@ -2920,8 +2911,8 @@ static bool func0f06c28c(struct chrdata *chr, struct coord *arg1, struct coord * && func0f06bea0(model, model->filedata->rootnode, model->filedata->rootnode, arg5, arg6, &sp7c.unk00, &spec, &spcc, &hitpart, &sp78, &sp74) && spec < *arg9) { *arg9 = spec; - mtx4TransformVec(camGetProjectionMtxF(), &sp7c.unk00, arg7); - mtx4RotateVec(camGetProjectionMtxF(), &sp7c.unk0c, arg8); + mtx4TransformVec(g_Vars.currentplayer->projectionmtx, &sp7c.unk00, arg7); + mtx4RotateVec(g_Vars.currentplayer->projectionmtx, &sp7c.unk0c, arg8); if (arg8->x != 0.0f || arg8->y != 0.0f || arg8->z != 0.0f) { guNormalize(&arg8->x, &arg8->y, &arg8->z); @@ -2996,11 +2987,11 @@ static bool projectileFindCollidingProp(struct prop *prop, struct coord *pos1, s sp88 = *pos1; - mtx4TransformVecInPlace(camGetWorldToScreenMtxf(), &sp88); + mtx4TransformVecInPlace(g_Vars.currentplayer->worldtoscreenmtx, &sp88); sp7c = sp98; - mtx4RotateVecInPlace(camGetWorldToScreenMtxf(), &sp7c); + mtx4RotateVecInPlace(g_Vars.currentplayer->worldtoscreenmtx, &sp7c); spa8 = dist; @@ -3136,8 +3127,8 @@ static s32 func0f06cd00(struct defaultobj *obj, struct coord *pos, struct coord if (cdExamLos09(&prop->pos, spa0, &sp1c4, CDTYPE_BG) == CDRESULT_COLLISION) { s0 = true; - cdGetPos(&hitthing.unk00); - cdGetObstacleNormal(&hitthing.unk0c); + hitthing.unk00 = g_CdObstaclePos; + cdGetGeoNormal(g_CdObstacleGeo, &hitthing.unk0c); } } @@ -3235,11 +3226,9 @@ static bool func0f06d37c(struct defaultobj *obj, struct coord *arg1, struct coor } if (!result) { - cdGetEdge(&sp64, &sp58); - - arg3->x = sp58.z - sp64.z; + arg3->x = g_CdEdgeVtx2.z - g_CdEdgeVtx1.z; arg3->y = 0.0f; - arg3->z = sp64.x - sp58.x; + arg3->z = g_CdEdgeVtx1.x - g_CdEdgeVtx2.x; if (arg3->x != 0.0f || arg3->z != 0.0f) { guNormalize(&arg3->x, &arg3->y, &arg3->z); @@ -3296,7 +3285,7 @@ static bool func0f06d37c(struct defaultobj *obj, struct coord *arg1, struct coor } } - f2 = cd00024e98() * 0.99f; + f2 = g_Cd8009a8b0 * 0.99f; sp4c.x = sp8c.x * f2 + prop->pos.x; sp4c.y = sp80.y; @@ -3697,7 +3686,7 @@ static void knifePlayWooshSound(struct defaultobj *obj) if (obj->projectile->lastwooshframe < g_Vars.lvframe60 - TICKS(6)) { func0f0926bc(obj->prop, 1, 0xffff); - if (!lvIsPaused()) { + if (!g_LvIsPaused) { propsnd0f0939f8(0, obj->prop, soundnums[index], -1, -1, 0, 0, 0, 0, -1.0f, 0, -1, -1.0f, -1.0f, -1.0f); obj->projectile->lastwooshframe = g_Vars.lvframe60; } @@ -3893,7 +3882,7 @@ static bool objEmbed(struct prop *prop, struct prop *parent, struct model *model mtx3ToMtx4(obj->realrot, &sp34); mtx4SetTranslation(&prop->pos, &sp34); mtx00015be4(&sp34, &sp74, &sp134); - mtx00015be4(camGetProjectionMtxF(), sp24, &spf4); + mtx00015be4(g_Vars.currentplayer->projectionmtx, sp24, &spf4); mtx000172f0(spf4.m, spb4.m); mtx00015be4(&spb4, &sp134, &obj->embedment->matrix); @@ -3995,7 +3984,7 @@ static bool propExplode(struct prop *prop, s32 exptype) pos.y = mtx->m[3][1]; pos.z = mtx->m[3][2]; - mtx4TransformVecInPlace(camGetProjectionMtxF(), &pos); + mtx4TransformVecInPlace(g_Vars.currentplayer->projectionmtx, &pos); } else { pos = parent->pos; } @@ -5393,7 +5382,7 @@ static void hovercarIncrementStep(struct hovercarobj *hovercar) static f32 objCollide(struct defaultobj *movingobj, struct coord *movingvel, f32 rotation) { f32 force = 1.0f; - struct prop *obstacle = cdGetObstacleProp(); + struct prop *obstacle = g_CdObstacleProp; if (obstacle && g_Vars.lvupdate240 > 0) { if (obstacle->type & (PROPTYPE_CHR | PROPTYPE_PLAYER)) { @@ -5406,8 +5395,6 @@ static f32 objCollide(struct defaultobj *movingobj, struct coord *movingvel, f32 && (obstacleobj->flags3 & OBJFLAG3_PUSHABLE)) { struct coord sp88; struct coord obstaclevel = {0, 0, 0}; - struct coord sp70; - struct coord sp64; struct coord sp58; struct coord sp4c; @@ -5417,8 +5404,6 @@ static f32 objCollide(struct defaultobj *movingobj, struct coord *movingvel, f32 objApplyMomentum(obstacleobj, &obstaclevel, 0.0f, true, true); - cdGetEdge(&sp70, &sp64); - if (cdGetSavedPos(&sp58, &sp4c)) { sp4c.x -= sp58.x; sp4c.y -= sp58.y; @@ -5431,7 +5416,7 @@ static f32 objCollide(struct defaultobj *movingobj, struct coord *movingvel, f32 sp4c.z = obstacle->pos.z - movingobj->prop->pos.z; } - func0f02e3dc(&sp70, &sp64, &sp58, &sp4c, &sp88); + func0f02e3dc(&g_CdEdgeVtx1, &g_CdEdgeVtx2, &sp58, &sp4c, &sp88); force = 0.5f; @@ -6122,7 +6107,8 @@ s32 projectileTick(struct defaultobj *obj, bool *embedded) sp3c4.y -= sp3d0.y; sp3c4.z -= sp3d0.z; } else { - cdGetEdge(&sp3d0, &sp3c4); + sp3d0 = g_CdEdgeVtx1; + sp3c4 = g_CdEdgeVtx2; sp3d0.x -= sp3c4.x; sp3d0.y -= sp3c4.y; @@ -6154,7 +6140,8 @@ s32 projectileTick(struct defaultobj *obj, bool *embedded) projectile->unk0dc += f0; - cdGetEdge(&sp3e8, &sp3dc); + sp3e8 = g_CdEdgeVtx1; + sp3dc = g_CdEdgeVtx2; sp3f4.x = sp3dc.z - sp3e8.z; sp3f4.y = 0.0f; @@ -6609,7 +6596,7 @@ s32 projectileTick(struct defaultobj *obj, bool *embedded) } } } else if ((hitprop->type & (PROPTYPE_CHR | PROPTYPE_PLAYER)) - && chrGetShield(hitprop->chr) > 0.0f) { + && hitprop->chr->cshield > 0.0f) { stick = false; } } @@ -6627,7 +6614,7 @@ s32 projectileTick(struct defaultobj *obj, bool *embedded) struct prop *ownerprop; ownerprop = obj->projectile->ownerprop; - ownershield = chrGetShield(hitchr); + ownershield = hitchr->cshield; func0f0341dc(hitchr, gsetGetDamage(&weapon->gset), &var8009ce78, &weapon->gset, ownerprop, g_EmbedHitPart, g_EmbedProp, g_EmbedNode, g_EmbedModel, g_EmbedSide, var8006993c); @@ -6642,7 +6629,7 @@ s32 projectileTick(struct defaultobj *obj, bool *embedded) Mtxf *sp184; sp184 = model0001a5cc(g_EmbedModel, g_EmbedNode, 0); - mtx4TransformVec(camGetWorldToScreenMtxf(), &sp5e8, &sp1c8); + mtx4TransformVec(g_Vars.currentplayer->worldtoscreenmtx, &sp5e8, &sp1c8); mtx0001719c(sp184->m, sp188.m); mtx4TransformVecInPlace(&sp188, &sp1c8); @@ -7315,7 +7302,7 @@ static void doorInitMatrices(struct prop *prop) Mtxf *matrices = model->matrices; func0f08c424(door, matrices); - mtx00015be0(camGetWorldToScreenMtxf(), matrices); + mtx00015be0(g_Vars.currentplayer->worldtoscreenmtx, matrices); if (model->filedata->skel == &g_Skel11) { union modelrodata *rodata; @@ -7899,7 +7886,7 @@ static void cctvInitMatrices(struct prop *prop, Mtxf *mtx) mtx4TransformVecInPlace(mtx, &sp64); mtx4SetTranslation(&sp64, &matrices[1]); - mtx00015be0(camGetWorldToScreenMtxf(), &matrices[1]); + mtx00015be0(g_Vars.currentplayer->worldtoscreenmtx, &matrices[1]); } static void fanTick(struct prop *prop) @@ -8093,7 +8080,7 @@ static void autogunTick(struct prop *prop) if (g_Vars.normmplayerisrunning) { numchrs = g_MpNumChrs; } else { - numchrs = chrsGetNumSlots(); + numchrs = g_NumChrSlots; } while (true) { @@ -8450,7 +8437,7 @@ static void autogunInitMatrices(struct prop *prop, Mtxf *mtx) mtx4LoadYRotation(yrot, &matrices[1]); mtx4SetTranslation(&sp4c, &matrices[1]); mtx00015f04(autogun->base.model->scale, &matrices[1]); - mtx00015be0(camGetWorldToScreenMtxf(), &matrices[1]); + mtx00015be0(g_Vars.currentplayer->worldtoscreenmtx, &matrices[1]); node2 = modelGetPart(model->filedata, MODELPART_AUTOGUN_0002); rodata = node2->rodata; @@ -8498,7 +8485,7 @@ static void autogunInitMatrices(struct prop *prop, Mtxf *mtx) static void autogunTickShoot(struct prop *autogunprop) { - if (!lvIsPaused()) { + if (!g_LvIsPaused) { struct autogunobj *autogun = (struct autogunobj *) autogunprop->obj; struct defaultobj *obj = autogunprop->obj; bool fireleft = false; @@ -8572,7 +8559,7 @@ static void autogunTickShoot(struct prop *autogunprop) gunpos.z = 0.0f; } - mtx00015be4(camGetProjectionMtxF(), sp108, &spc8); + mtx00015be4(g_Vars.currentplayer->projectionmtx, sp108, &spc8); mtx4TransformVecInPlace(&spc8, &gunpos); if (cdTestLos10(&autogunprop->pos, autogunprop->rooms, &gunpos, gunrooms, CDTYPE_BG, GEOFLAG_BLOCK_SHOOT) == CDRESULT_COLLISION) { @@ -8600,9 +8587,8 @@ static void autogunTickShoot(struct prop *autogunprop) || (targetprop && (targetprop->type == PROPTYPE_CHR)) || (g_Vars.antiplayernum >= 0 && targetprop && targetprop == g_Vars.anti->prop)) { if (cdExamLos08(&gunpos, gunrooms, &hitpos, CDTYPE_ALL, GEOFLAG_BLOCK_SHOOT) == CDRESULT_COLLISION) { - cdGetPos(&hitpos); - - hitprop = cdGetObstacleProp(); + hitpos = g_CdObstaclePos; + hitprop = g_CdObstacleProp; // SP: If the hit prop is a chr and it's our target // MP: If the hit prop is a chr @@ -8631,7 +8617,7 @@ static void autogunTickShoot(struct prop *autogunprop) if (fireleft || fireright) { bgunPlayPropHitSound(&gset, hitprop, -1); - if (hitchr->model && chrGetShield(hitchr) > 0.0f) { + if (hitchr->model && hitchr->cshield > 0.0f) { chrCalculateShieldHit(hitchr, &hitpos, &dir, &hitnode, &hitpart, &hitmodel, &hitside); } @@ -8649,9 +8635,8 @@ static void autogunTickShoot(struct prop *autogunprop) if (cdExamLos08(&gunpos, gunrooms, &hitpos, CDTYPE_ALL & ~CDTYPE_PLAYERS, GEOFLAG_BLOCK_SHOOT) == CDRESULT_COLLISION) { - cdGetPos(&hitpos); - - hitprop = cdGetObstacleProp(); + hitpos = g_CdObstaclePos; + hitprop = g_CdObstacleProp; missed = true; } @@ -8679,8 +8664,7 @@ static void autogunTickShoot(struct prop *autogunprop) if (cdExamLos08(&gunpos, gunrooms, &hitpos, CDTYPE_DOORS | CDTYPE_BG, GEOFLAG_BLOCK_SHOOT) == CDRESULT_COLLISION) { - cdGetPos(&hitpos); - + hitpos = g_CdObstaclePos; missed = true; } @@ -9534,7 +9518,6 @@ static void chopperTickFall(struct prop *chopperprop) if (cdExamLos09(&chopperprop->pos, chopperprop->rooms, &newpos, CDTYPE_BG) == CDRESULT_COLLISION) { struct coord sp74; s16 room; - struct coord sp64; f32 ground; s16 newrooms[8]; @@ -9542,11 +9525,9 @@ static void chopperTickFall(struct prop *chopperprop) ground = cdFindGroundAtCyl(&chopperprop->pos, 5, chopperprop->rooms, NULL, NULL); chopperprop->pos.y -= 100; - cdGetPos(&sp64); - - newpos.x = sp64.x; + newpos.x = g_CdObstaclePos.x; newpos.y = ground + 20; - newpos.z = sp64.z; + newpos.z = g_CdObstaclePos.z; func0f065e74(&chopperprop->pos, chopperprop->rooms, &newpos, newrooms); @@ -9954,7 +9935,7 @@ static void hovercarTick(struct prop *prop) if (active) { if (cdExamCylMove03(&prop->pos, prop->rooms, &sp214, CDTYPE_CLOSEDDOORS | CDTYPE_AJARDOORS, 0, 0, 0) == CDRESULT_COLLISION) { - doorprop = cdGetObstacleProp(); + doorprop = g_CdObstacleProp; } if (doorprop) { @@ -10207,7 +10188,7 @@ static void objInitMatrices(struct prop *prop) } else { mtx3ToMtx4(obj->realrot, &mtx); mtx4SetTranslation(&prop->pos, &mtx); - mtx00015be4(camGetWorldToScreenMtxf(), &mtx, obj->model->matrices); + mtx00015be4(g_Vars.currentplayer->worldtoscreenmtx, &mtx, obj->model->matrices); if (obj->type == OBJTYPE_CCTV) { cctvInitMatrices(prop, &mtx); @@ -10276,7 +10257,6 @@ void objTick(struct prop *prop) newparent = setupGetObjByCmdIndex(cmdindex + padnum); if (newparent && newparent->prop) { - modelSetScale(obj->model, obj->model->scale); propReparent(obj->prop, newparent->prop); silent = true; } @@ -10433,11 +10413,11 @@ s32 objTickPlayer(struct prop *prop) sp556 = true; sp476.unk10 = gfxAllocate(model->filedata->nummatrices * sizeof(Mtxf)); - sp476.unk00 = camGetWorldToScreenMtxf(); + sp476.unk00 = g_Vars.currentplayer->worldtoscreenmtx; model0001cebc(&sp476, model); if (fulltick) { - mtx00015be4(camGetProjectionMtxF(), model->matrices, &sp412); + mtx00015be4(g_Vars.currentplayer->projectionmtx, model->matrices, &sp412); mtx4ToMtx3(&sp412, obj->realrot); sp400.x = sp412.m[3][0]; @@ -10525,7 +10505,7 @@ s32 objTickPlayer(struct prop *prop) mtx3ToMtx4(obj->realrot, &sp248); mtx4SetTranslation(&prop->pos, &sp248); - mtx4MultMtx4(camGetWorldToScreenMtxf(), &sp248, &sp152); + mtx4MultMtx4(g_Vars.currentplayer->worldtoscreenmtx, &sp248, &sp152); sp556 = true; sp312.unk10 = gfxAllocate(model->filedata->nummatrices * sizeof(Mtxf)); @@ -10546,12 +10526,12 @@ s32 objTickPlayer(struct prop *prop) if (modelGetCurAnimFrame(model) >= modelGetNumAnimFrames(model) - 1) { modelmgrFreeAnim(model->anim); model->anim = NULL; - mtx00015be4(camGetProjectionMtxF(), model->matrices, &sp248); + mtx00015be4(g_Vars.currentplayer->projectionmtx, model->matrices, &sp248); mtx4ToMtx3(&sp248, obj->realrot); tagnum = objGetTagNum(obj); if (tagnum >= 0) { - numchrs = chrsGetNumSlots(); + numchrs = g_NumChrSlots; for (i = 0; i < numchrs; i++) { if (g_ChrSlots[i].myspecial == tagnum) { @@ -10609,7 +10589,7 @@ s32 objTickPlayer(struct prop *prop) struct chopperobj *chopper = (struct chopperobj *)obj; if (!chopper->dead) { - if (!lvIsPaused()) { + if (!g_LvIsPaused) { if (chopper->attackmode == CHOPPERMODE_DEAD) { // empty } else if (chopper->attackmode == CHOPPERMODE_FALL) { @@ -11630,7 +11610,7 @@ static void objRenderProp(struct prop *prop, struct modelrenderdata *renderdata, s32 sp60; sp6c = 0; - sp6c += (obj->flags & OBJFLAG_00000200) && camGetOrthogonalMtxL(); + sp6c += (obj->flags & OBJFLAG_00000200) && g_Vars.currentplayer->orthomtxl; gdl = renderdata->gdl; @@ -11716,7 +11696,7 @@ static void objRenderProp(struct prop *prop, struct modelrenderdata *renderdata, } if (sp6c) { - gSPMatrix(gdl++, camGetOrthogonalMtxL(), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_PROJECTION); + gSPMatrix(gdl++, g_Vars.currentplayer->orthomtxl, G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_PROJECTION); } renderdata->gdl = gdl; @@ -11732,7 +11712,7 @@ static void objRenderProp(struct prop *prop, struct modelrenderdata *renderdata, } if (sp6c) { - gSPMatrix(gdl++, camGetPerspectiveMtxL(), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_PROJECTION); + gSPMatrix(gdl++, g_Vars.currentplayer->perspmtxl, G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_PROJECTION); } renderdata->gdl = gdl; @@ -11790,7 +11770,7 @@ Gfx *gfxRenderRadialShadow(Gfx *gdl, f32 x, f32 y, f32 z, f32 angle, f32 radius, mtx = gfxAllocateMatrix(); mtx4LoadYRotationWithTranslation(&pos, angle, &spc0); - mtx4MultMtx4(camGetWorldToScreenMtxf(), &spc0, &sp80); + mtx4MultMtx4(g_Vars.currentplayer->worldtoscreenmtx, &spc0, &sp80); mtx00016054(&sp80, mtx); for (i = 0; i < 4; i++) { @@ -12418,7 +12398,7 @@ static void objBounce(struct defaultobj *obj, struct coord *arg1) dir = *arg1; - mtx4RotateVecInPlace(camGetProjectionMtxF(), &dir); + mtx4RotateVecInPlace(g_Vars.currentplayer->projectionmtx, &dir); projectile->speed.x += 3.3333333f * dir.x; projectile->speed.z += 3.3333333f * dir.z; @@ -12732,7 +12712,7 @@ bool objDrop(struct prop *prop, bool lazy) if (!lazy && (prop->flags & PROPFLAG_ONTHISSCREENTHISTICK)) { // Do collision checks Mtxf *sp48 = model0001a60c(model); - mtx00015be4(camGetProjectionMtxF(), sp48, &spf0); + mtx00015be4(g_Vars.currentplayer->projectionmtx, sp48, &spf0); propSetPerimEnabled(root, false); spe4.x = spf0.m[3][0]; @@ -13705,9 +13685,9 @@ void func0f0859a0(struct prop *prop, struct shotdata *shotdata) } } - mtx4TransformVec(camGetProjectionMtxF(), &spd8, &sp7c); + mtx4TransformVec(g_Vars.currentplayer->projectionmtx, &spd8, &sp7c); mtx4RotateVec(&model->matrices[spe4], &hitthing1.unk0c, &sp70); - mtx4RotateVecInPlace(camGetProjectionMtxF(), &sp70); + mtx4RotateVecInPlace(g_Vars.currentplayer->projectionmtx, &sp70); func0f061fa8(shotdata, prop, spd4, lVar3, node1, &hitthing1, spe4, node2, @@ -13776,7 +13756,7 @@ void objHit(struct shotdata *shotdata, struct hit *hit) sp110.y = shotdata->unk00.y - hit->distance * shotdata->unk0c.y / shotdata->unk0c.z; sp110.z = shotdata->unk00.z - hit->distance; - mtx4TransformVecInPlace(camGetProjectionMtxF(), &sp110); + mtx4TransformVecInPlace(g_Vars.currentplayer->projectionmtx, &sp110); if (!spfc && chrIsUsingPaintball(g_Vars.currentplayer->prop->chr)) { spfc = true; @@ -13940,7 +13920,7 @@ void objHit(struct shotdata *shotdata, struct hit *hit) spb0.y = shotdata->dir.y * 3.0f; spb0.z = shotdata->dir.z * 3.0f; - mtx4MultMtx4(camGetProjectionMtxF(), &obj->model->matrices[hit->mtxindex], &sp58); + mtx4MultMtx4(g_Vars.currentplayer->projectionmtx, &obj->model->matrices[hit->mtxindex], &sp58); mtx4TransformVec(&sp58, &hit->hitthing.unk00, &spa4); pushdir = shotdata->dir; @@ -14194,7 +14174,7 @@ bool propobjInteract(struct prop *prop) // Button press sound sndStart(var80095200, SFX_PRESS_SWITCH, NULL, -1, -1, -1, -1, -1); - if (alarmIsActive()) { + if (g_AlarmTimer > 0) { alarmDeactivate(); } else { alarmActivate(); @@ -14333,7 +14313,7 @@ static void ammotypeGetDeterminer(char *dst, s32 ammotype, s32 qty) s32 playercount = PLAYERCOUNT(); s32 full = playercount <= 2 - && !(playercount == 2 && optionsGetScreenSplit() == SCREENSPLIT_VERTICAL); + && !(playercount == 2 && g_ScreenSplit == SCREENSPLIT_VERTICAL); switch (ammotype) { case AMMOTYPE_CLOAK: @@ -14575,7 +14555,7 @@ static void ammotypeGetPickupMessage(char *dst, s32 ammotype, s32 qty) { s32 playercount = PLAYERCOUNT(); s32 full = playercount <= 2 - && !(playercount == 2 && optionsGetScreenSplit() == SCREENSPLIT_VERTICAL); + && !(playercount == 2 && g_ScreenSplit == SCREENSPLIT_VERTICAL); *dst = '\0'; @@ -14732,7 +14712,7 @@ static void weaponGetPickupText(char *buffer, s32 weaponnum, bool dual) { s32 playercount = PLAYERCOUNT(); s32 full = playercount <= 2 - && !(playercount == 2 && optionsGetScreenSplit() == SCREENSPLIT_VERTICAL); + && !(playercount == 2 && g_ScreenSplit == SCREENSPLIT_VERTICAL); s32 textid; bool plural = false; @@ -15015,7 +14995,7 @@ s32 propPickupByPlayer(struct prop *prop, bool showhudmsg) if (text == NULL) { s32 playercount = PLAYERCOUNT(); - if (playercount <= 2 && !(playercount == 2 && optionsGetScreenSplit() == SCREENSPLIT_VERTICAL)) { + if (playercount <= 2 && !(playercount == 2 && g_ScreenSplit == SCREENSPLIT_VERTICAL)) { text = langGet(L_PROPOBJ_041); // "Picked up a shield." } else { text = langGet(L_PROPOBJ_042); // "A shield." @@ -15670,7 +15650,7 @@ void coordTriggerProxies(struct coord *pos, bool arg1) static void chrsTriggerProxies(void) { - s32 numchrs = chrsGetNumSlots(); + s32 numchrs = g_NumChrSlots; s32 i; for (i = 0; i < numchrs; i++) { @@ -15794,7 +15774,7 @@ static struct prop *func0f08b108(struct weaponobj *weapon, struct chrdata *chr, if (prop && weapon->base.model) { f32 scale = weapon->base.extrascale * (1.0f / 256.0f); - modelSetScale(weapon->base.model, weapon->base.model->scale * scale); + weapon->base.model->scale *= scale; if (!chrEquipWeapon(weapon, chr)) { propFree(prop); @@ -17201,10 +17181,10 @@ s32 func0f08e5a8(s16 *rooms2, struct screenbox *box) f32 func0f08e6bc(struct prop *prop, f32 arg1) { f32 result = 1; - struct coord *coord = env0f1667e8(); + struct coord *coord = g_Env800a65e8; if (coord != NULL && coord->z < prop->z) { - f32 scalez = camGetLodScaleZ(); + f32 scalez = g_Vars.currentplayer->c_lodscalez; f32 value = ((prop->z - coord->z) * 100.0f / arg1 + coord->z) * scalez; if (value >= coord->y) { @@ -17220,13 +17200,13 @@ f32 func0f08e6bc(struct prop *prop, f32 arg1) static bool func0f08e794(struct coord *coord, f32 arg1) { bool result = true; - struct coord *ptr = env0f1667e8(); + struct coord *ptr = g_Env800a65e8; struct coord tmp; f32 sp20; if (ptr != NULL) { struct coord *campos = &g_Vars.currentplayer->cam_pos; - Mtxf *mtx = camGetWorldToScreenMtxf(); + Mtxf *mtx = g_Vars.currentplayer->worldtoscreenmtx; tmp.x = coord->x - campos->x; tmp.y = coord->y - campos->y; @@ -17235,7 +17215,7 @@ static bool func0f08e794(struct coord *coord, f32 arg1) sp20 = tmp.f[0] * mtx->m[0][0] + tmp.f[1] * mtx->m[0][1] + tmp.f[2] * mtx->m[0][2]; if (sp20 > ptr->z) { - f32 scalez = camGetLodScaleZ(); + f32 scalez = g_Vars.currentplayer->c_lodscalez; sp20 = ((sp20 - ptr->z) * 100 / arg1 + ptr->z) * scalez; if (sp20 >= ptr->y) { @@ -17495,7 +17475,7 @@ static void doorsCalcFrac(struct doorobj *door) propSetPerimEnabled(loopprop, true); if (cdresult == CDRESULT_COLLISION) { - struct prop *blockerprop = cdGetObstacleProp(); + struct prop *blockerprop = g_CdObstacleProp; if (blockerprop && blockerprop->type == PROPTYPE_CHR) { struct chrdata *chr = blockerprop->chr; @@ -18049,11 +18029,6 @@ void alarmDeactivate(void) alarmStopAudio(); } -bool alarmIsActive(void) -{ - return g_AlarmTimer > 0; -} - void countdownTimerSetVisible(u32 reason, bool visible) { if (visible) { @@ -18071,13 +18046,13 @@ Gfx *countdownTimerRender(Gfx *gdl) f32 value60 = g_CountdownTimerValue60; u32 stack; - s32 viewright = viGetViewLeft() + (viGetViewWidth() >> 1); - s32 y = viGetViewTop() + viGetViewHeight() - 18; + s32 viewright = g_ViBackData->viewleft + (g_ViBackData->viewx >> 1); + s32 y = g_ViBackData->viewtop + g_ViBackData->viewy - 18; s32 playercount = PLAYERCOUNT(); char *fmt = ":\n"; if (playercount == 2) { - if (optionsGetScreenSplit() != SCREENSPLIT_VERTICAL && g_Vars.currentplayernum == 0) { + if (g_ScreenSplit != SCREENSPLIT_VERTICAL && g_Vars.currentplayernum == 0) { y += 10; } else { y += 2; @@ -18119,7 +18094,7 @@ Gfx *countdownTimerRender(Gfx *gdl) void alarmTick(void) { - if (alarmIsActive()) { + if (g_AlarmTimer > 0) { s32 limit; s16 sound; @@ -18135,7 +18110,7 @@ void alarmTick(void) default: sound = SFX_ALARM_DEFAULT; break; } - if (!lvIsPaused()) { + if (!g_LvIsPaused) { if (g_AlarmAudioHandle) { // The sound is currently playing. Cycle between the left/right // speaker for stereo or headphone mode. @@ -18272,7 +18247,7 @@ void weaponCreateForPlayerDrop(s32 weaponnum) void projectileCreate(struct prop *fromprop, struct fireslotthing *arg1, struct coord *pos, struct coord *dir, u8 weaponnum, struct prop *targetprop) { - if (!lvIsPaused()) { + if (!g_LvIsPaused) { bool blocked = false; struct coord endpos; u32 stack; @@ -18385,8 +18360,8 @@ void projectileCreate(struct prop *fromprop, struct fireslotthing *arg1, struct CDTYPE_OBJS | CDTYPE_DOORS | CDTYPE_CHRS | CDTYPE_PATHBLOCKER| CDTYPE_BG, GEOFLAG_BLOCK_SHOOT) == CDRESULT_COLLISION) { blocked = true; - cdGetPos(&endpos); - obstacle = cdGetObstacleProp(); + endpos = g_CdObstaclePos; + obstacle = g_CdObstacleProp; } propSetPerimEnabled(fromprop, true); diff --git a/src/game/propsnd.c b/src/game/propsnd.c index a8556e823..4d07991c4 100644 --- a/src/game/propsnd.c +++ b/src/game/propsnd.c @@ -168,7 +168,7 @@ static void propsndTickChannel(s32 channelnum) && ((channel->audiohandle != NULL && sndGetState(channel->audiohandle) != AL_STOPPED) || (channel->flags & AUDIOCHANNELFLAG_0002) || (channel->flags & AUDIOCHANNELFLAG_1000) - || ((channel->flags & AUDIOCHANNELFLAG_ISMP3) && sndIsPlayingMp3()))) { + || ((channel->flags & AUDIOCHANNELFLAG_ISMP3) && g_SndCurMp3.playing))) { struct coord *pos = NULL; // 50 s16 *rooms = NULL; // 4c s32 sp48; @@ -266,7 +266,7 @@ static void propsndTickChannel(s32 channelnum) sp48 = channel->unk04; } - if (lvIsPaused() + if (g_LvIsPaused || (mpIsPaused() && (channel->flags2 & AUDIOCHANNELFLAG2_0002)) || (mpIsPaused() && PLAYERCOUNT() == 1)) { channel->unk06 = -1; @@ -357,7 +357,7 @@ static void propsndTickChannel(s32 channelnum) } else { if (channel->unk28 != 11) { if (channel->flags & AUDIOCHANNELFLAG_ISMP3) { - if (!sndIsPlayingMp3()) { + if (!g_SndCurMp3.playing) { if (channel->flags & AUDIOCHANNELFLAG_FORPROP) { propDecrementSoundCount(channel->prop); } diff --git a/src/game/raceinit.c b/src/game/raceinit.c index 7222370b2..a7c85d7ba 100644 --- a/src/game/raceinit.c +++ b/src/game/raceinit.c @@ -9,6 +9,6 @@ void racesInit(void) { - modelSetVtxAllocatorFunc(&chrAllocateVertices); + g_ModelVtxAllocatorFunc = &chrAllocateVertices; raceInitAnims(); } diff --git a/src/game/radar.c b/src/game/radar.c index a79f748cb..ff5b3affa 100644 --- a/src/game/radar.c +++ b/src/game/radar.c @@ -262,10 +262,10 @@ Gfx *radarRender(Gfx *gdl) return gdl; } - g_RadarX = (viGetViewLeft() + viGetViewWidth()) - 41; + g_RadarX = (g_ViBackData->viewleft + g_ViBackData->viewx) - 41; if (playercount == 2) { - if (optionsGetScreenSplit() == SCREENSPLIT_VERTICAL) { + if (g_ScreenSplit == SCREENSPLIT_VERTICAL) { if (playernum == 0) { g_RadarX += 16; } @@ -280,10 +280,10 @@ Gfx *radarRender(Gfx *gdl) } } - g_RadarY = viGetViewTop() + (PAL ? 29 : 26); + g_RadarY = g_ViBackData->viewtop + (PAL ? 29 : 26); if (playercount == 2) { - if (optionsGetScreenSplit() != SCREENSPLIT_VERTICAL && playernum == 1) { + if (g_ScreenSplit != SCREENSPLIT_VERTICAL && playernum == 1) { g_RadarY -= 8; } } else if (playercount >= 3) { diff --git a/src/game/savebuffer.c b/src/game/savebuffer.c index 39a4f998b..c04911118 100644 --- a/src/game/savebuffer.c +++ b/src/game/savebuffer.c @@ -30,8 +30,8 @@ static void func0f0d4690(Mtxf *mtx) pos.y = PAL ? 136.25f : 120.25f; pos.z = 0; - pos.x = (.5f - viGetWidth()) * 0.5f; - pos.y = (.5f + viGetHeight()) * 0.5f; + pos.x = (.5f - g_ViBackData->x) * 0.5f; + pos.y = (.5f + g_ViBackData->y) * 0.5f; pos.z = 0; mtx4SetTranslation(&pos, mtx); @@ -60,12 +60,12 @@ Gfx *func0f0d479c(Gfx *gdl) mtx4LoadIdentity(&mtx); guFrustumF(mtx.m, - -(f32) viGetWidth() * 0.5f, viGetWidth() * 0.5f, - -(f32) viGetHeight() * 0.5f, viGetHeight() * 0.5f, + -(f32) g_ViBackData->x * 0.5f, g_ViBackData->x * 0.5f, + -(f32) g_ViBackData->y * 0.5f, g_ViBackData->y * 0.5f, 10, 10000, 1); mtx00016054(&mtx, mtx1); - mtx00016784(); + var8005ef10[0] = g_Vars.unk000510; gSPMatrix(gdl++, osVirtualToPhysical(mtx2), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPMatrix(gdl++, osVirtualToPhysical(mtx1), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_PROJECTION); @@ -75,13 +75,13 @@ Gfx *func0f0d479c(Gfx *gdl) var80070f10 = gfxAllocate(size); if (var80070f10 != NULL) { - var80070f10->vp.vscale[0] = viGetWidth() << 1; - var80070f10->vp.vscale[1] = viGetHeight() << 1; + var80070f10->vp.vscale[0] = g_ViBackData->x << 1; + var80070f10->vp.vscale[1] = g_ViBackData->y << 1; var80070f10->vp.vscale[2] = 1; var80070f10->vp.vscale[3] = 0; - var80070f10->vp.vtrans[0] = viGetWidth() << 1; - var80070f10->vp.vtrans[1] = viGetHeight() << 1; + var80070f10->vp.vtrans[0] = g_ViBackData->x << 1; + var80070f10->vp.vtrans[1] = g_ViBackData->y << 1; var80070f10->vp.vtrans[2] = 0x1ff; var80070f10->vp.vtrans[3] = 0; } @@ -96,8 +96,8 @@ Gfx *func0f0d479c(Gfx *gdl) Gfx *func0f0d49c8(Gfx *gdl) { - gSPViewport(gdl++, OS_K0_TO_PHYSICAL(viGetCurrentPlayerViewport())); - gSPMatrix(gdl++, osVirtualToPhysical(camGetPerspectiveMtxL()), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_PROJECTION); + gSPViewport(gdl++, OS_K0_TO_PHYSICAL(&g_Vars.currentplayer->viewport[g_ViBackIndex])); + gSPMatrix(gdl++, osVirtualToPhysical(g_Vars.currentplayer->perspmtxl), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_PROJECTION); return gdl; } diff --git a/src/game/setup.c b/src/game/setup.c index c7b88943f..efcc79cce 100644 --- a/src/game/setup.c +++ b/src/game/setup.c @@ -282,7 +282,7 @@ void setupCreateObject(struct defaultobj *obj, s32 cmdindex) objInitWithModelDef(obj, g_ModelStates[modelnum].filedata); } - modelSetScale(obj->model, obj->model->scale * scale); + obj->model->scale *= scale; return; } @@ -296,7 +296,7 @@ void setupCreateObject(struct defaultobj *obj, s32 cmdindex) prop = objInitWithModelDef(obj, g_ModelStates[modelnum].filedata); } - modelSetScale(obj->model, obj->model->scale * scale); + obj->model->scale *= scale; propReparent(prop, chr->prop); } } else { @@ -307,7 +307,7 @@ void setupCreateObject(struct defaultobj *obj, s32 cmdindex) objInitWithModelDef(obj, g_ModelStates[modelnum].filedata); } - modelSetScale(obj->model, obj->model->scale * scale); + obj->model->scale *= scale; return; } @@ -444,11 +444,11 @@ void setupCreateObject(struct defaultobj *obj, s32 cmdindex) mtx00015e80(yscale, &mtx); mtx00015edc(zscale, &mtx); - modelSetScale(obj->model, obj->model->scale * maxscale); + obj->model->scale *= maxscale; } } - modelSetScale(obj->model, obj->model->scale * scale); + obj->model->scale *= scale; mtx00015f04(obj->model->scale, &mtx); if (obj->flags2 & OBJFLAG2_00020000) { @@ -534,7 +534,7 @@ void setupPlaceWeapon(struct weaponobj *weapon, s32 cmdindex) // Don't replace the K7 guard's weapon in Investigation // because it would make an objective impossible. // @bug: It's still replaced on PD mode difficulty. - if (g_Vars.stagenum != STAGE_INVESTIGATION || lvGetDifficulty() != DIFF_PA) { + if (g_Vars.stagenum != STAGE_INVESTIGATION || g_Difficulty != DIFF_PA) { weapon->weaponnum = WEAPON_ROCKETLAUNCHER; weapon->base.modelnum = MODEL_CHRDYROCKET; weapon->base.extrascale = 256; @@ -755,7 +755,7 @@ static void setupCreateSingleMonitor(struct singlemonitorobj *monitor, s32 cmdin if (prop && monitor->base.embedment) { monitor->base.hidden |= OBJHFLAG_EMBEDDED; - modelSetScale(monitor->base.model, monitor->base.model->scale * scale); + monitor->base.model->scale *= scale; monitor->base.model->attachedtomodel = owner->model; if (monitor->ownerpart == MODELPART_0000) { @@ -995,7 +995,7 @@ static void setupCreateDoor(struct doorobj *door, s32 cmdindex) scale = zscale; } - modelSetScale(door->base.model, door->base.model->scale * scale); + door->base.model->scale *= scale; } propActivate(prop); @@ -1061,11 +1061,11 @@ void setupLoadBriefing(s32 stagenum, u8 *buffer, s32 bufferlen, struct briefing struct defaultobj *obj; s32 wanttype = BRIEFINGTYPE_TEXT_PA; - if (lvGetDifficulty() == DIFF_A) { + if (g_Difficulty == DIFF_A) { wanttype = BRIEFINGTYPE_TEXT_A; } - if (lvGetDifficulty() == DIFF_SA) { + if (g_Difficulty == DIFF_SA) { wanttype = BRIEFINGTYPE_TEXT_SA; } @@ -1339,7 +1339,7 @@ void setupCreateProps(s32 stagenum) u32 diffflag = 0; s32 index; - diffflag |= 1 << (lvGetDifficulty() + 4); + diffflag |= 1 << (g_Difficulty + 4); if (g_Vars.mplayerisrunning) { if (PLAYERCOUNT() == 2) { @@ -1711,11 +1711,11 @@ void setupCreateProps(s32 stagenum) briefingInsert(briefing); - if (lvGetDifficulty() == DIFF_A) { + if (g_Difficulty == DIFF_A) { wanttype = BRIEFINGTYPE_TEXT_A; } - if (lvGetDifficulty() == DIFF_SA) { + if (g_Difficulty == DIFF_SA) { wanttype = BRIEFINGTYPE_TEXT_SA; } @@ -1830,7 +1830,6 @@ void setupCreateProps(s32 stagenum) if (owner && owner->prop) { obj->hidden |= OBJHFLAG_HASOWNER; - modelSetScale(obj->model, obj->model->scale); propReparent(obj->prop, owner->prop); } } diff --git a/src/game/shards.c b/src/game/shards.c index 7a9991c13..ab70ff1aa 100644 --- a/src/game/shards.c +++ b/src/game/shards.c @@ -224,7 +224,7 @@ static Gfx *shardsRenderWood(Gfx *gdl) gDPSetTextureFilter(gdl++, G_TF_BILERP); gDPSetCycleType(gdl++, G_CYC_2CYCLE); gDPSetTextureLOD(gdl++, G_TL_LOD); - gSPMatrix(gdl++, osVirtualToPhysical(camGetOrthogonalMtxL()), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_PROJECTION); + gSPMatrix(gdl++, osVirtualToPhysical(g_Vars.currentplayer->orthomtxl), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_PROJECTION); for (i = 0; i < g_MaxShards; i++) { if (g_Shards[i].age60 > 0 && g_Shards[i].type == SHARDTYPE_WOOD) { @@ -322,8 +322,8 @@ static Gfx *shardsRenderWood(Gfx *gdl) } gSPClearGeometryMode(gdl++, G_LIGHTING | G_TEXTURE_GEN); - gSPMatrix(gdl++, camGetPerspectiveMtxL(), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_PROJECTION); - gSPMatrix(gdl++, camGetMtxL173c(), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPMatrix(gdl++, g_Vars.currentplayer->perspmtxl, G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_PROJECTION); + gSPMatrix(gdl++, g_Vars.currentplayer->mtxl173c, G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); } return gdl; @@ -353,7 +353,7 @@ static Gfx *shardsRenderGlass(Gfx *gdl) gSPSetGeometryMode(gdl++, G_LIGHTING | G_TEXTURE_GEN); } - gSPMatrix(gdl++, osVirtualToPhysical(camGetOrthogonalMtxL()), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_PROJECTION); + gSPMatrix(gdl++, osVirtualToPhysical(g_Vars.currentplayer->orthomtxl), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_PROJECTION); for (i = 0; i < g_MaxShards; i++) { if (g_Shards[i].age60 > 0 && g_Shards[i].type != SHARDTYPE_WOOD) { @@ -445,8 +445,8 @@ static Gfx *shardsRenderGlass(Gfx *gdl) } gSPClearGeometryMode(gdl++, G_LIGHTING | G_TEXTURE_GEN); - gSPMatrix(gdl++, camGetPerspectiveMtxL(), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_PROJECTION); - gSPMatrix(gdl++, camGetMtxL173c(), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPMatrix(gdl++, g_Vars.currentplayer->perspmtxl, G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_PROJECTION); + gSPMatrix(gdl++, g_Vars.currentplayer->mtxl173c, G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); } return gdl; diff --git a/src/game/sight.c b/src/game/sight.c index 684bcbd09..a40d31c51 100644 --- a/src/game/sight.c +++ b/src/game/sight.c @@ -333,10 +333,10 @@ static s32 sightCalculateBoxBound(s32 targetx, s32 viewleft, s32 timeelapsed, s3 */ static Gfx *sightDrawTargetBox(Gfx *gdl, struct trackedprop *trackedprop, s32 textid, s32 time) { - s32 viewleft = viGetViewLeft(); - s32 viewtop = viGetViewTop(); - s32 viewwidth = viGetViewWidth(); - s32 viewheight = viGetViewHeight(); + s32 viewleft = g_ViBackData->viewleft; + s32 viewtop = g_ViBackData->viewtop; + s32 viewwidth = g_ViBackData->viewx; + s32 viewheight = g_ViBackData->viewy; s32 viewright = viewleft + viewwidth - 1; s32 viewbottom = viewtop + viewheight - 1; u32 colour; @@ -404,10 +404,10 @@ static Gfx *sightDrawTargetBox(Gfx *gdl, struct trackedprop *trackedprop, s32 te // textid 1 writes '0' label[0] = textid + 0x2f; - gdl = textRender(gdl, &x, &y, label, g_CharsNumeric, g_FontNumeric, 0x00ff00a0, 0x000000a0, viGetWidth(), viGetHeight(), 0, 0); + gdl = textRender(gdl, &x, &y, label, g_CharsNumeric, g_FontNumeric, 0x00ff00a0, 0x000000a0, g_ViBackData->x, g_ViBackData->y, 0, 0); } else { char *text = langGet(textid); - gdl = textRender(gdl, &x, &y, text, g_CharsHandelGothicXs, g_FontHandelGothicXs, 0x00ff00a0, 0x000000a0, viGetWidth(), viGetHeight(), 0, 0); + gdl = textRender(gdl, &x, &y, text, g_CharsHandelGothicXs, g_FontHandelGothicXs, 0x00ff00a0, 0x000000a0, g_ViBackData->x, g_ViBackData->y, 0, 0); } } } @@ -417,10 +417,10 @@ static Gfx *sightDrawTargetBox(Gfx *gdl, struct trackedprop *trackedprop, s32 te static Gfx *sightDrawAimer(Gfx *gdl, s32 x, s32 y, s32 radius, s32 cornergap, u32 colour) { - s32 viewleft = viGetViewLeft(); - s32 viewtop = viGetViewTop(); - s32 viewwidth = viGetViewWidth(); - s32 viewheight = viGetViewHeight(); + s32 viewleft = g_ViBackData->viewleft; + s32 viewtop = g_ViBackData->viewtop; + s32 viewwidth = g_ViBackData->viewx; + s32 viewheight = g_ViBackData->viewy; s32 viewright = viewleft + viewwidth - 1; s32 viewbottom = viewtop + viewheight - 1; @@ -532,7 +532,7 @@ static Gfx *sightDrawDefault(Gfx *gdl, bool sighton) // "Identify" gdl = textRender(gdl, &textx, &texty, langGet(L_MISC_439), g_CharsHandelGothicXs, g_FontHandelGothicXs, 0x00ff00a0, 0x000000a0, - viGetWidth(), viGetHeight(), 0, 0); + g_ViBackData->x, g_ViBackData->y, 0, 0); } gdl = sightDrawAimer(gdl, x, y, radius, cornergap, colour); @@ -791,10 +791,10 @@ static Gfx *sightDrawSkedarTriangle(Gfx *gdl, s32 x, s32 y, s32 dir, u32 colour) static Gfx *sightDrawSkedar(Gfx *gdl, bool sighton) { - s32 viewleft = viGetViewLeft(); - s32 viewtop = viGetViewTop(); - s32 viewwidth = viGetViewWidth(); - s32 viewheight = viGetViewHeight(); + s32 viewleft = g_ViBackData->viewleft; + s32 viewtop = g_ViBackData->viewtop; + s32 viewwidth = g_ViBackData->viewx; + s32 viewheight = g_ViBackData->viewy; s32 viewright = viewleft + viewwidth - 1; s32 viewbottom = viewtop + viewheight - 1; s32 paddingy = viewheight / 4; @@ -975,10 +975,10 @@ static Gfx *sightDrawSkedar(Gfx *gdl, bool sighton) static Gfx *sightDrawZoom(Gfx *gdl, bool sighton) { - s32 viewleft = viGetViewLeft(); - s32 viewtop = viGetViewTop(); - s32 viewhalfwidth = viGetViewWidth() >> 1; - s32 viewhalfheight = viGetViewHeight() >> 1; + s32 viewleft = g_ViBackData->viewleft; + s32 viewtop = g_ViBackData->viewtop; + s32 viewhalfwidth = g_ViBackData->viewx >> 1; + s32 viewhalfheight = g_ViBackData->viewy >> 1; s32 viewright = viewleft + viewhalfwidth * 2 - 1; s32 viewbottom = viewtop + viewhalfheight * 2 - 1; f32 maxfovy; @@ -1113,10 +1113,10 @@ static Gfx *sightDrawZoom(Gfx *gdl, bool sighton) static Gfx *sightDrawMaian(Gfx *gdl, bool sighton) { - s32 viewleft = viGetViewLeft(); - s32 viewtop = viGetViewTop(); - s32 viewwidth = viGetViewWidth(); - s32 viewheight = viGetViewHeight(); + s32 viewleft = g_ViBackData->viewleft; + s32 viewtop = g_ViBackData->viewtop; + s32 viewwidth = g_ViBackData->viewx; + s32 viewheight = g_ViBackData->viewy; s32 viewright = viewleft + viewwidth - 1; s32 viewbottom = viewtop + viewheight - 1; s32 x = (s32)g_Vars.currentplayer->crosspos[0]; diff --git a/src/game/sky.c b/src/game/sky.c index 5246758f4..18361939f 100644 --- a/src/game/sky.c +++ b/src/game/sky.c @@ -34,11 +34,11 @@ static Gfx *sky0f123fd4(Gfx *gdl, struct skything38 *arg1, struct skything38 *ar static void sky0f11f000(f32 left, f32 top, struct coord *arg2) { - Mtxf *mtx = camGetProjectionMtxF(); + Mtxf *mtx = g_Vars.currentplayer->projectionmtx; f32 pos[2]; - pos[0] = left + camGetScreenLeft(); - pos[1] = top + camGetScreenTop() + envGetCurrent()->unk40; + pos[0] = left + g_Vars.currentplayer->c_screenleft; + pos[1] = top + g_Vars.currentplayer->c_screentop + g_Env.unk40; cam0f0b4c3c(pos, arg2, 100); mtx4RotateVecInPlace(mtx, arg2); @@ -66,7 +66,7 @@ static bool sky0f11f07c(struct coord *arg0, struct coord *arg1, f32 *arg2) } if (sp24 > 0.0f) { - sp2c = (envGetCurrent()->clouds_scale - campos->y) / sp24; + sp2c = (g_Env.clouds_scale - campos->y) / sp24; f12_2 = sqrtf(arg0->f[0] * arg0->f[0] + arg0->f[2] * arg0->f[2]) * sp2c; if (f12_2 > 300000) { @@ -105,7 +105,7 @@ static bool sky0f11f1fc(struct coord *arg0, struct coord *arg1, f32 *arg2) } if (sp24 < 0.0f) { - sp2c = (envGetCurrent()->water_scale - campos->y) / sp24; + sp2c = (g_Env.water_scale - campos->y) / sp24; f12_2 = sqrtf(arg0->f[0] * arg0->f[0] + arg0->f[2] * arg0->f[2]) * sp2c; if (f12_2 > 300000) { @@ -157,7 +157,7 @@ static f32 skyRound(f32 value) static void skyChooseCloudVtxColour(struct skything18 *arg0, f32 arg1) { - struct environment *env = envGetCurrent(); + struct environment *env = &g_Env; f32 scale = 1.0f - arg1; f32 r = env->sky_r; f32 g = env->sky_g; @@ -176,7 +176,7 @@ static void skyChooseCloudVtxColour(struct skything18 *arg0, f32 arg1) static void sky0f11f6ec(struct skything18 *arg0, f32 arg1) { - struct environment *env = envGetCurrent(); + struct environment *env = &g_Env; f32 scale = 1.0f - arg1; f32 r = env->sky_r; f32 g = env->sky_g; @@ -247,7 +247,7 @@ Gfx *skyRender(Gfx *gdl) struct environment *env; sp430 = false; - env = envGetCurrent(); + env = &g_Env; if (!env->clouds_enabled || g_Vars.currentplayer->visionmode == VISIONMODE_XRAY) { if (PLAYERCOUNT() == 1) { @@ -259,9 +259,9 @@ Gfx *skyRender(Gfx *gdl) gdl = viSetFillColour(gdl, env->sky_r, env->sky_g, env->sky_b); } - gDPFillRectangle(gdl++, viGetViewLeft(), viGetViewTop(), - viGetViewLeft() + viGetViewWidth() - 1, - viGetViewTop() + viGetViewHeight() - 1); + gDPFillRectangle(gdl++, g_ViBackData->viewleft, g_ViBackData->viewtop, + g_ViBackData->viewleft + g_ViBackData->viewx - 1, + g_ViBackData->viewtop + g_ViBackData->viewy - 1); gDPPipeSync(gdl++); return gdl; @@ -292,9 +292,9 @@ Gfx *skyRender(Gfx *gdl) if (&sp6a4); sky0f11f000(0.0f, 0.0f, &sp6a4); - sky0f11f000(camGetScreenWidth() - 0.1f, 0.0f, &sp698); - sky0f11f000(0.0f, camGetScreenHeight() - 0.1f, &sp68c); - sky0f11f000(camGetScreenWidth() - 0.1f, camGetScreenHeight() - 0.1f, &sp680); + sky0f11f000(g_Vars.currentplayer->c_screenwidth - 0.1f, 0.0f, &sp698); + sky0f11f000(0.0f, g_Vars.currentplayer->c_screenheight - 0.1f, &sp68c); + sky0f11f000(g_Vars.currentplayer->c_screenwidth - 0.1f, g_Vars.currentplayer->c_screenheight - 0.1f, &sp680); sp538 = sky0f11f07c(&sp6a4, &sp644, &sp58c); sp534 = sky0f11f07c(&sp698, &sp638, &sp588); @@ -307,7 +307,7 @@ Gfx *skyRender(Gfx *gdl) sky0f11f1fc(&sp680, &sp5c0, &sp560); if (sp538 != sp530) { - sp54c = camGetScreenTop() + camGetScreenHeight() * (sp6a4.f[1] / (sp6a4.f[1] - sp68c.f[1])); + sp54c = g_Vars.currentplayer->c_screentop + g_Vars.currentplayer->c_screenheight * (sp6a4.f[1] / (sp6a4.f[1] - sp68c.f[1])); sky0f11f000(0.0f, sp54c, &sp65c); sky0f11f384(&sp6a4, &sp68c, &sp65c); @@ -318,9 +318,9 @@ Gfx *skyRender(Gfx *gdl) } if (sp534 != sp52c) { - sp548 = camGetScreenTop() + camGetScreenHeight() * (sp698.f[1] / (sp698.f[1] - sp680.f[1])); + sp548 = g_Vars.currentplayer->c_screentop + g_Vars.currentplayer->c_screenheight * (sp698.f[1] / (sp698.f[1] - sp680.f[1])); - sky0f11f000(camGetScreenWidth() - 0.1f, sp548, &sp650); + sky0f11f000(g_Vars.currentplayer->c_screenwidth - 0.1f, sp548, &sp650); sky0f11f384(&sp698, &sp680, &sp650); sky0f11f07c(&sp650, &sp5f0, &sp570); sky0f11f1fc(&sp650, &sp590, &sp550); @@ -329,16 +329,16 @@ Gfx *skyRender(Gfx *gdl) } if (sp538 != sp534) { - sky0f11f000(camGetScreenLeft() + camGetScreenWidth() * (sp6a4.f[1] / (sp6a4.f[1] - sp698.f[1])), 0.0f, &sp674); + sky0f11f000(g_Vars.currentplayer->c_screenleft + g_Vars.currentplayer->c_screenwidth * (sp6a4.f[1] / (sp6a4.f[1] - sp698.f[1])), 0.0f, &sp674); sky0f11f384(&sp6a4, &sp698, &sp674); sky0f11f07c(&sp674, &sp614, &sp57c); sky0f11f1fc(&sp674, &sp5b4, &sp55c); } if (sp530 != sp52c) { - tmp = camGetScreenLeft() + camGetScreenWidth() * (sp68c.f[1] / (sp68c.f[1] - sp680.f[1])); + tmp = g_Vars.currentplayer->c_screenleft + g_Vars.currentplayer->c_screenwidth * (sp68c.f[1] / (sp68c.f[1] - sp680.f[1])); - sky0f11f000(tmp, camGetScreenHeight() - 0.1f, &sp668); + sky0f11f000(tmp, g_Vars.currentplayer->c_screenheight - 0.1f, &sp668); sky0f11f384(&sp68c, &sp680, &sp668); sky0f11f07c(&sp668, &sp608, &sp578); sky0f11f1fc(&sp668, &sp5a8, &sp558); @@ -737,18 +737,18 @@ Gfx *skyRender(Gfx *gdl) struct skything38 sp274[5]; s32 i; - mtx4MultMtx4(camGetMtxF1754(), camGetWorldToScreenMtxf(), &sp3cc); + mtx4MultMtx4(g_Vars.currentplayer->mtxf1754, g_Vars.currentplayer->worldtoscreenmtx, &sp3cc); guScaleF(var800a33a8.m, 1.0f / scale, 1.0f / scale, 1.0f / scale); mtx4MultMtx4(&sp3cc, &var800a33a8, &sp38c); for (i = 0; i < s1; i++) { sky0f1228d0(&sp43c[i], &sp38c, 130, 65535.0f, 65535.0f, &sp274[i]); - sp274[i].unk28 = skyClamp(sp274[i].unk28, camGetScreenLeft() * 4.0f, (camGetScreenLeft() + camGetScreenWidth()) * 4.0f - 1.0f); - sp274[i].unk2c = skyClamp(sp274[i].unk2c, camGetScreenTop() * 4.0f, (camGetScreenTop() + camGetScreenHeight()) * 4.0f - 1.0f); + sp274[i].unk28 = skyClamp(sp274[i].unk28, g_Vars.currentplayer->c_screenleft * 4.0f, (g_Vars.currentplayer->c_screenleft + g_Vars.currentplayer->c_screenwidth) * 4.0f - 1.0f); + sp274[i].unk2c = skyClamp(sp274[i].unk2c, g_Vars.currentplayer->c_screentop * 4.0f, (g_Vars.currentplayer->c_screentop + g_Vars.currentplayer->c_screenheight) * 4.0f - 1.0f); - if (sp274[i].unk2c > camGetScreenTop() * 4.0f + 4.0f - && sp274[i].unk2c < (camGetScreenTop() + camGetScreenHeight()) * 4.0f - 4.0f) { + if (sp274[i].unk2c > g_Vars.currentplayer->c_screentop * 4.0f + 4.0f + && sp274[i].unk2c < (g_Vars.currentplayer->c_screentop + g_Vars.currentplayer->c_screenheight) * 4.0f - 4.0f) { sp274[i].unk2c -= 4.0f; } } @@ -1201,39 +1201,39 @@ Gfx *skyRender(Gfx *gdl) struct skything38 sp94[5]; s32 i; - mtx4MultMtx4(camGetMtxF1754(), camGetWorldToScreenMtxf(), &sp1ec); + mtx4MultMtx4(g_Vars.currentplayer->mtxf1754, g_Vars.currentplayer->worldtoscreenmtx, &sp1ec); guScaleF(var800a33a8.m, 1.0f / scale, 1.0f / scale, 1.0f / scale); mtx4MultMtx4(&sp1ec, &var800a33a8, &sp1ac); for (i = 0; i < s1; i++) { sky0f1228d0(&sp4b4[i], &sp1ac, 130, 65535.0f, 65535.0f, &sp94[i]); - sp94[i].unk28 = skyClamp(sp94[i].unk28, camGetScreenLeft() * 4.0f, (camGetScreenLeft() + camGetScreenWidth()) * 4.0f - 1.0f); - sp94[i].unk2c = skyClamp(sp94[i].unk2c, camGetScreenTop() * 4.0f, (camGetScreenTop() + camGetScreenHeight()) * 4.0f - 1.0f); + sp94[i].unk28 = skyClamp(sp94[i].unk28, g_Vars.currentplayer->c_screenleft * 4.0f, (g_Vars.currentplayer->c_screenleft + g_Vars.currentplayer->c_screenwidth) * 4.0f - 1.0f); + sp94[i].unk2c = skyClamp(sp94[i].unk2c, g_Vars.currentplayer->c_screentop * 4.0f, (g_Vars.currentplayer->c_screentop + g_Vars.currentplayer->c_screenheight) * 4.0f - 1.0f); } if (s1 == 4) { if (((sp538 << 3) | (sp534 << 2) | (sp530 << 1) | sp52c) == 12) { if (sp548 < sp54c) { if (sp94[3].unk2c >= sp94[1].unk2c + 4.0f) { - sp94[0].unk28 = camGetScreenLeft() * 4.0f; - sp94[0].unk2c = camGetScreenTop() * 4.0f; - sp94[1].unk28 = (camGetScreenLeft() + camGetScreenWidth()) * 4.0f - 1.0f; - sp94[1].unk2c = camGetScreenTop() * 4.0f; - sp94[2].unk28 = camGetScreenLeft() * 4.0f; - sp94[3].unk28 = (camGetScreenLeft() + camGetScreenWidth()) * 4.0f - 1.0f; + sp94[0].unk28 = g_Vars.currentplayer->c_screenleft * 4.0f; + sp94[0].unk2c = g_Vars.currentplayer->c_screentop * 4.0f; + sp94[1].unk28 = (g_Vars.currentplayer->c_screenleft + g_Vars.currentplayer->c_screenwidth) * 4.0f - 1.0f; + sp94[1].unk2c = g_Vars.currentplayer->c_screentop * 4.0f; + sp94[2].unk28 = g_Vars.currentplayer->c_screenleft * 4.0f; + sp94[3].unk28 = (g_Vars.currentplayer->c_screenleft + g_Vars.currentplayer->c_screenwidth) * 4.0f - 1.0f; gdl = sky0f123fd4(gdl, &sp94[0], &sp94[1], &sp94[2], &sp94[3], 130.0f); } else { gdl = sky0f122d4c(gdl, &sp94[0], &sp94[1], &sp94[2], 130.0f, true); } } else if (sp94[2].unk2c >= sp94[0].unk2c + 4.0f) { - sp94[0].unk28 = camGetScreenLeft() * 4.0f; - sp94[0].unk2c = camGetScreenTop() * 4.0f; - sp94[1].unk28 = (camGetScreenLeft() + camGetScreenWidth()) * 4.0f - 1.0f; - sp94[1].unk2c = camGetScreenTop() * 4.0f; - sp94[2].unk28 = camGetScreenLeft() * 4.0f; - sp94[3].unk28 = (camGetScreenLeft() + camGetScreenWidth()) * 4.0f - 1.0f; + sp94[0].unk28 = g_Vars.currentplayer->c_screenleft * 4.0f; + sp94[0].unk2c = g_Vars.currentplayer->c_screentop * 4.0f; + sp94[1].unk28 = (g_Vars.currentplayer->c_screenleft + g_Vars.currentplayer->c_screenwidth) * 4.0f - 1.0f; + sp94[1].unk2c = g_Vars.currentplayer->c_screentop * 4.0f; + sp94[2].unk28 = g_Vars.currentplayer->c_screenleft * 4.0f; + sp94[3].unk28 = (g_Vars.currentplayer->c_screenleft + g_Vars.currentplayer->c_screenwidth) * 4.0f - 1.0f; gdl = sky0f123fd4(gdl, &sp94[1], &sp94[0], &sp94[3], &sp94[2], 130.0f); } else { @@ -1295,13 +1295,13 @@ static void sky0f1228d0(struct skything18 *arg0, Mtxf *arg1, u16 arg2, f32 arg3, sp48[2] = sp68[2] * f0 * mult; sp48[3] = sp68[3] * f0 * mult; - sp34 = camGetScreenWidth(); - sp30 = camGetScreenWidth(); - sp38[0] = sp48[0] * (sp34 + sp34) + (sp30 + sp30 + camGetScreenLeft() * 4); + sp34 = g_Vars.currentplayer->c_screenwidth; + sp30 = g_Vars.currentplayer->c_screenwidth; + sp38[0] = sp48[0] * (sp34 + sp34) + (sp30 + sp30 + g_Vars.currentplayer->c_screenleft * 4); - sp34 = camGetScreenHeight(); - sp30 = camGetScreenHeight(); - sp38[1] = -sp48[1] * (sp34 + sp34) + (sp30 + sp30 + camGetScreenTop() * 4); + sp34 = g_Vars.currentplayer->c_screenheight; + sp30 = g_Vars.currentplayer->c_screenheight; + sp38[1] = -sp48[1] * (sp34 + sp34) + (sp30 + sp30 + g_Vars.currentplayer->c_screentop * 4); sp34 = 511.0f; sp30 = 511.0f; @@ -1323,7 +1323,7 @@ static void sky0f1228d0(struct skything18 *arg0, Mtxf *arg1, u16 arg2, f32 arg3, arg5->unk20 = sp60; arg5->unk24 = sp64; arg5->unk28 = sp38[0]; - arg5->unk2c = sp38[1] - envGetCurrent()->unk40 * 4.0f; + arg5->unk2c = sp38[1] - g_Env.unk40 * 4.0f; arg5->unk30 = sp38[2]; arg5->unk34 = f22; @@ -2093,19 +2093,19 @@ static Gfx *sky0f123fd4(Gfx *gdl, struct skything38 *arg1, struct skything38 *ar if (arg3->unk2c - arg4->unk2c < 1.0f) { sp1bc = -1878.0f; } else { - sp1bc = -(camGetScreenWidth() - 0.25f) / ((arg3->unk2c - arg4->unk2c) / 4.0f); + sp1bc = -(g_Vars.currentplayer->c_screenwidth - 0.25f) / ((arg3->unk2c - arg4->unk2c) / 4.0f); } gImmp1(gdl++, G_RDPHALF_1, (G_TRI_SHADE_TXTR << 24) | 0x00800000 | (u32) arg3->unk2c); gImmp1(gdl++, G_RDPHALF_CONT, (s32) arg4->unk2c << 16 | (s32) arg1->unk2c); - gImmp1(gdl++, G_RDPHALF_1, func0f152fa0(camGetScreenLeft() + camGetScreenWidth() - 0.25f)); + gImmp1(gdl++, G_RDPHALF_1, func0f152fa0(g_Vars.currentplayer->c_screenleft + g_Vars.currentplayer->c_screenwidth - 0.25f)); gImmp1(gdl++, G_RDPHALF_CONT, func0f152fa0(sp1bc)); - gImmp1(gdl++, G_RDPHALF_1, func0f152fa0(camGetScreenLeft())); + gImmp1(gdl++, G_RDPHALF_1, func0f152fa0(g_Vars.currentplayer->c_screenleft)); gImmp1(gdl++, G_RDPHALF_CONT, func0f152fa0(0.0f)); - gImmp1(gdl++, G_RDPHALF_1, func0f152fa0(camGetScreenLeft() + camGetScreenWidth() - 0.25f)); + gImmp1(gdl++, G_RDPHALF_1, func0f152fa0(g_Vars.currentplayer->c_screenleft + g_Vars.currentplayer->c_screenwidth - 0.25f)); gImmp1(gdl++, G_RDPHALF_CONT, func0f152fa0(0.0f)); } else { f32 sp198; @@ -2113,19 +2113,19 @@ static Gfx *sky0f123fd4(Gfx *gdl, struct skything38 *arg1, struct skything38 *ar if (arg3->unk2c - arg4->unk2c < 1.0f) { sp198 = 1877.0f; } else { - sp198 = (camGetScreenWidth() - 0.25f) / ((arg3->unk2c - arg4->unk2c) / 4.0f); + sp198 = (g_Vars.currentplayer->c_screenwidth - 0.25f) / ((arg3->unk2c - arg4->unk2c) / 4.0f); } gImmp1(gdl++, G_RDPHALF_1, 0xce000000 | (u32) arg3->unk2c); gImmp1(gdl++, G_RDPHALF_CONT, (s32) arg4->unk2c << 16 | (s32) arg1->unk2c); - gImmp1(gdl++, G_RDPHALF_1, func0f152fa0(camGetScreenLeft())); + gImmp1(gdl++, G_RDPHALF_1, func0f152fa0(g_Vars.currentplayer->c_screenleft)); gImmp1(gdl++, G_RDPHALF_CONT, func0f152fa0(sp198)); - gImmp1(gdl++, G_RDPHALF_1, func0f152fa0(camGetScreenLeft() + camGetScreenWidth() - 0.25f)); + gImmp1(gdl++, G_RDPHALF_1, func0f152fa0(g_Vars.currentplayer->c_screenleft + g_Vars.currentplayer->c_screenwidth - 0.25f)); gImmp1(gdl++, G_RDPHALF_CONT, func0f152fa0(0.0f)); - gImmp1(gdl++, G_RDPHALF_1, func0f152fa0(camGetScreenLeft())); + gImmp1(gdl++, G_RDPHALF_1, func0f152fa0(g_Vars.currentplayer->c_screenleft)); gImmp1(gdl++, G_RDPHALF_CONT, func0f152fa0(0.0f)); } @@ -2371,13 +2371,13 @@ static Gfx *sky0f123fd4(Gfx *gdl, struct skything38 *arg1, struct skything38 *ar static void skyCreateArtifact(struct artifact *artifact, s32 x, s32 y) { - s32 viewleft = viGetViewLeft(); - s32 viewtop = viGetViewTop(); - s32 viewwidth = viGetViewWidth(); - s32 viewheight = viGetViewHeight(); + s32 viewleft = g_ViBackData->viewleft; + s32 viewtop = g_ViBackData->viewtop; + s32 viewwidth = g_ViBackData->viewx; + s32 viewheight = g_ViBackData->viewy; if (x >= viewleft && x < viewleft + viewwidth && y >= viewtop && y < viewtop + viewheight) { - artifact->unk08 = &var800844f0[(s32)camGetScreenWidth() * y + x]; + artifact->unk08 = &var800844f0[(s32)g_Vars.currentplayer->c_screenwidth * y + x]; artifact->unk0c.u16_2 = x; artifact->unk0c.u16_1 = y; artifact->type = ARTIFACTTYPE_CIRCLE; @@ -2422,9 +2422,9 @@ Gfx *skyRenderSuns(Gfx *gdl, bool xray) bool onscreen; f32 radius; - sp16c = camGetWorldToScreenMtxf(); - sp168 = camGetMtxF1754(); - env = envGetCurrent(); + sp16c = g_Vars.currentplayer->worldtoscreenmtx; + sp168 = g_Vars.currentplayer->mtxf1754; + env = &g_Env; xscale = 1; @@ -2432,10 +2432,10 @@ Gfx *skyRenderSuns(Gfx *gdl, bool xray) return gdl; } - viewleft = viGetViewLeft(); - viewtop = viGetViewTop(); - viewwidth = viGetViewWidth(); - viewheight = viGetViewHeight(); + viewleft = g_ViBackData->viewleft; + viewtop = g_ViBackData->viewtop; + viewwidth = g_ViBackData->viewx; + viewheight = g_ViBackData->viewy; viewleftf = viewleft; viewtopf = viewtop; @@ -2460,7 +2460,7 @@ Gfx *skyRenderSuns(Gfx *gdl, bool xray) if (g_SunPositions[i].f[2] > 1.0f) { g_SunScreenXPositions[i] = (g_SunPositions[i].f[0] / g_SunPositions[i].f[2] + 1.0f) * 0.5f * viewwidthf + viewleftf; g_SunScreenYPositions[i] = (-g_SunPositions[i].f[1] / g_SunPositions[i].f[2] + 1.0f) * 0.5f * viewheightf + viewtopf; - radius = 60.0f / viGetFovY() * sun->texture_size; + radius = 60.0f / g_ViBackData->fovy * sun->texture_size; onscreen = false; if (g_SunScreenXPositions[i] >= viewleftf - radius @@ -2613,8 +2613,8 @@ static Gfx *sky0f126384(Gfx *gdl, f32 x, f32 y, f32 arg3, f32 size, s32 arg5, f3 scale = 1; - sp128 = (x - viGetViewWidth() / 2.0f) * 0.01f; - sp124 = (y - viGetViewHeight() / 2.0f) * 0.01f; + sp128 = (x - g_ViBackData->viewx / 2.0f) * 0.01f; + sp124 = (y - g_ViBackData->viewy / 2.0f) * 0.01f; // Render the sun texSelect(&gdl, &g_TexLightGlareConfigs[6], 4, 0, 2, 1, NULL); @@ -2633,7 +2633,7 @@ static Gfx *sky0f126384(Gfx *gdl, f32 x, f32 y, f32 arg3, f32 size, s32 arg5, f3 0, 0, 0, ENVIRONMENT, TEXEL0, 0, ENVIRONMENT, 0, 0, 0, 0, ENVIRONMENT, TEXEL0, 0, ENVIRONMENT, 0); - fovy = viGetFovY(); + fovy = g_ViBackData->fovy; gDPSetEnvColor(gdl++, 0xff, 0xff, 0xff, (s32) (arg6 * arg3 * 255.0f)); f2 = ((s32) ((60.0f / fovy) * (size * (0.5f + (0.5f * arg3))))); @@ -2703,8 +2703,8 @@ static Gfx *sky0f126384(Gfx *gdl, f32 x, f32 y, f32 arg3, f32 size, s32 arg5, f3 func0f0b2150(&gdl, sp17c, sp174, g_TexLightGlareConfigs[1].width, g_TexLightGlareConfigs[1].height, 0, 0, 0, 0, 0, 1); } - sp128 = viGetViewWidth() / 2.0f - x; - sp124 = viGetViewHeight() / 2.0f - y; + sp128 = g_ViBackData->viewx / 2.0f - x; + sp124 = g_ViBackData->viewy / 2.0f - y; f12 = (40.0f - sqrtf(sp128 * sp128 + sp124 * sp124)) * 0.0125f; @@ -2745,16 +2745,16 @@ static Gfx *sky0f126c3c(Gfx *gdl, f32 x, f32 y, f32 z, f32 arg4, f32 arg5) sp64.y = y; sp64.z = z; - mtx4TransformVecInPlace(camGetWorldToScreenMtxf(), &sp64); - mtx4TransformVecInPlace(camGetMtxF1754(), &sp64); + mtx4TransformVecInPlace(g_Vars.currentplayer->worldtoscreenmtx, &sp64); + mtx4TransformVecInPlace(g_Vars.currentplayer->mtxf1754, &sp64); if (sp64.z > 1.0f) { f32 xpos; f32 ypos; - s16 viewlefti = viGetViewLeft(); - s16 viewtopi = viGetViewTop(); - s16 viewwidthi = viGetViewWidth(); - s16 viewheighti = viGetViewHeight(); + s16 viewlefti = g_ViBackData->viewleft; + s16 viewtopi = g_ViBackData->viewtop; + s16 viewwidthi = g_ViBackData->viewx; + s16 viewheighti = g_ViBackData->viewy; f32 viewleft = viewlefti; f32 viewwidth = viewwidthi; f32 viewtop = viewtopi; @@ -2853,7 +2853,7 @@ static Gfx *sky0f126de8(Gfx *gdl) */ Gfx *skyRenderArtifacts(Gfx *gdl) { - struct environment *env = envGetCurrent(); + struct environment *env = &g_Env; struct sun *sun; s32 i; @@ -2962,10 +2962,10 @@ Gfx *sky0f1274d8(Gfx *gdl) gDPSetPrimColor(gdl++, 0, 0, (s32)r, (s32)g, (s32)b, (s32)a); gDPFillRectangle(gdl++, - viGetViewLeft(), - viGetViewTop(), - viGetViewLeft() + viGetViewWidth(), - viGetViewTop() + viGetViewHeight()); + g_ViBackData->viewleft, + g_ViBackData->viewtop, + g_ViBackData->viewleft + g_ViBackData->viewx, + g_ViBackData->viewtop + g_ViBackData->viewy); gDPPipeSync(gdl++); } diff --git a/src/game/smoke.c b/src/game/smoke.c index a28ed932b..b5c2ee73d 100644 --- a/src/game/smoke.c +++ b/src/game/smoke.c @@ -88,7 +88,7 @@ static Gfx *smokeRenderPart(struct smoke *smoke, struct smokepart *part, Gfx *gd { struct gfxvtx *vertices = gfxAllocateVertices(4); struct colour *colours = (struct colour *)gfxAllocateColours(1); - Mtxf *mtx = camGetProjectionMtxF(); + Mtxf *mtx = g_Vars.currentplayer->projectionmtx; struct coord spa0; struct coord sp94; struct coord sp88; @@ -593,7 +593,7 @@ u32 smokeTickPlayer(struct prop *prop) } { - Mtxf *matrix = camGetWorldToScreenMtxf(); + Mtxf *matrix = g_Vars.currentplayer->worldtoscreenmtx; prop->z = -(matrix->m[0][2] * prop->pos.x + matrix->m[1][2] * prop->pos.y + matrix->m[2][2] * prop->pos.z + matrix->m[3][2]); @@ -659,7 +659,7 @@ Gfx *smokeRender(struct prop *prop, Gfx *gdl, bool xlupass) } gSPClearGeometryMode(gdl++, G_CULL_BOTH | G_FOG); - gSPMatrix(gdl++, osVirtualToPhysical(camGetOrthogonalMtxL()), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_PROJECTION); + gSPMatrix(gdl++, osVirtualToPhysical(g_Vars.currentplayer->orthomtxl), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_PROJECTION); gdl = roomApplyMtx(gdl, roomnum); @@ -693,7 +693,7 @@ Gfx *smokeRender(struct prop *prop, Gfx *gdl, bool xlupass) } gDPSetColorDither(gdl++, G_CD_BAYER); - gSPMatrix(gdl++, osVirtualToPhysical(camGetPerspectiveMtxL()), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_PROJECTION); + gSPMatrix(gdl++, osVirtualToPhysical(g_Vars.currentplayer->perspmtxl), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_PROJECTION); } return gdl; diff --git a/src/game/sparks.c b/src/game/sparks.c index f1722fe55..cccebb525 100644 --- a/src/game/sparks.c +++ b/src/game/sparks.c @@ -414,7 +414,7 @@ Gfx *sparksRender(Gfx *gdl) gDPSetColorArray(gdl++, osVirtualToPhysical(colours), 2); sp120 *= 0.2f; - sp120 *= viGetFovY() / 60.0f; + sp120 *= g_ViBackData->fovy / 60.0f; mtx4LoadIdentity(&spd4); @@ -424,7 +424,7 @@ Gfx *sparksRender(Gfx *gdl) spd4.m[3][3] = 0.05f; mtx4SetTranslation(&group->pos, &spd4); - mtx00015be0(camGetWorldToScreenMtxf(), &spd4); + mtx00015be0(g_Vars.currentplayer->worldtoscreenmtx, &spd4); mtx = gfxAllocateMatrix(); mtx00016054(&spd4, mtx); diff --git a/src/game/stars.c b/src/game/stars.c index f1c6bcf86..17bf79043 100644 --- a/src/game/stars.c +++ b/src/game/stars.c @@ -210,10 +210,10 @@ Gfx *starsRender(Gfx *gdl) { bool isddtower = false; Mtxf mtx; - f32 viewleft = viGetViewLeft(); - f32 viewright = viewleft + viGetViewWidth(); - f32 viewtop = viGetViewTop(); - f32 viewbottom = viewtop + viGetViewHeight(); + f32 viewleft = g_ViBackData->viewleft; + f32 viewright = viewleft + g_ViBackData->viewx; + f32 viewtop = g_ViBackData->viewtop; + f32 viewbottom = viewtop + g_ViBackData->viewy; s32 i; f32 sp154; struct coord sp148; @@ -249,10 +249,10 @@ Gfx *starsRender(Gfx *gdl) } } - sp154 = cosf(0.017453199252486f * (90.0f - viGetFovY() / viGetAspect() * 0.5f)); + sp154 = cosf(0.017453199252486f * (90.0f - g_ViBackData->fovy / g_ViBackData->aspect * 0.5f)); mtx4LoadIdentity(&mtx); - mtx00015be0(camGetWorldToScreenMtxf(), &mtx); + mtx00015be0(g_Vars.currentplayer->worldtoscreenmtx, &mtx); mtx.m[3][0] = 0.0f; mtx.m[3][1] = 0.0f; diff --git a/src/game/tex.c b/src/game/tex.c index e01fd31c6..c911758f3 100644 --- a/src/game/tex.c +++ b/src/game/tex.c @@ -786,7 +786,7 @@ s32 texLoadFromGdl(Gfx *arg0, s32 gdlsizeinbytes, Gfx *arg2, struct texpool *poo tex0f173a08(); - spe0 = dyntexHasRoom(); + spe0 = g_DyntexCurRoom >= 0; if (spe0) { for (j = 0; j < 16; j++) { diff --git a/src/game/texreset.c b/src/game/texreset.c index f5714554f..71a4b71dd 100644 --- a/src/game/texreset.c +++ b/src/game/texreset.c @@ -21,7 +21,6 @@ extern u8 _textureconfigSegmentEnd; void texReset(void) { - s32 stage; u32 len = &_textureconfigSegmentEnd - &_textureconfigSegmentStart; s32 i; @@ -62,6 +61,4 @@ void texReset(void) texLoadFromDisplayList(g_TexGdl1, 0, 0); texLoadFromDisplayList(g_TexGdl3, 0, 0); - - stage = mainGetStageNum(); } diff --git a/src/game/title.c b/src/game/title.c index 2ae3ffe87..7d48069fa 100644 --- a/src/game/title.c +++ b/src/game/title.c @@ -117,7 +117,7 @@ static void titleTickLegal(void) viSetFovY(60); viSetAspect(1.33333333f); viSetZRange(100, 10000); - viSetUseZBuf(false); + g_ViBackData->usezbuf = false; g_TitleTimer += g_Vars.lvupdate60; @@ -143,7 +143,7 @@ static void titleTickCheckControllers(void) { g_TitleTimer++; viSetZRange(100, 10000); - viSetUseZBuf(false); + g_ViBackData->usezbuf = false; if (g_TitleTimer > 6) { if ((joyGetConnectedControllers() & 1) == 0) { @@ -262,7 +262,7 @@ static Gfx *titleRenderLegal(Gfx *gdl) if (elem->type == LEGALELEMENTTYPE_LINE) { gdl = text0f153780(gdl); - gdl = text0f153a34(gdl, elem->x, elem->y, viGetWidth(), elem->y + 2, 0x7f7fff7f); + gdl = text0f153a34(gdl, elem->x, elem->y, g_ViBackData->x, elem->y + 2, 0x7f7fff7f); gdl = text0f153628(gdl); } else if (elem->type == LEGALELEMENTTYPE_DOLBYLOGO) { gdl = text0f153780(gdl); @@ -313,7 +313,7 @@ static Gfx *titleRenderLegal(Gfx *gdl) } else { x = elem->x; y = elem->y; - gdl = textRenderProjected(gdl, &x, &y, langGet(elem->textid), font1, font2, colour, viGetWidth(), viGetHeight(), 0, 0); + gdl = textRenderProjected(gdl, &x, &y, langGet(elem->textid), font1, font2, colour, g_ViBackData->x, g_ViBackData->y, 0, 0); } } @@ -344,7 +344,7 @@ static void titleInitPdLogo(void) modelCalculateRwDataLen(g_ModelStates[MODEL_NLOGO].filedata); g_TitleModel = modelmgrInstantiateModelWithAnim(g_ModelStates[MODEL_NLOGO].filedata); - modelSetScale(g_TitleModel, 1); + g_TitleModel->scale = 1; modelSetRootPosition(g_TitleModel, &coord); } @@ -357,7 +357,7 @@ static void titleInitPdLogo(void) modelCalculateRwDataLen(g_ModelStates[MODEL_NLOGO2].filedata); g_TitleModelNLogo2 = modelmgrInstantiateModelWithAnim(g_ModelStates[MODEL_NLOGO2].filedata); - modelSetScale(g_TitleModelNLogo2, 1); + g_TitleModelNLogo2->scale = 1; modelSetRootPosition(g_TitleModelNLogo2, &coord); } @@ -370,7 +370,7 @@ static void titleInitPdLogo(void) modelCalculateRwDataLen(g_ModelStates[MODEL_PDTWO].filedata); g_TitleModelPdTwo = modelmgrInstantiateModelWithoutAnim(g_ModelStates[MODEL_PDTWO].filedata); - modelSetScale(g_TitleModelPdTwo, 1); + g_TitleModelPdTwo->scale = 1; modelSetRootPosition(g_TitleModelPdTwo, &coord); } @@ -383,7 +383,7 @@ static void titleInitPdLogo(void) modelCalculateRwDataLen(g_ModelStates[MODEL_PDTHREE].filedata); g_TitleModelPdThree = modelmgrInstantiateModelWithoutAnim(g_ModelStates[MODEL_PDTHREE].filedata); - modelSetScale(g_TitleModelPdThree, 1); + g_TitleModelPdThree->scale = 1; modelSetRootPosition(g_TitleModelPdThree, &coord); } @@ -432,7 +432,7 @@ static void titleTickPdLogo(void) viSetFovY(46); viSetAspect(1.33333333f); viSetZRange(100, 10000); - viSetUseZBuf(false); + g_ViBackData->usezbuf = false; g_TitleTimer += g_Vars.lvupdate60; var8009ccb8 = 1 - var8009ccb8; @@ -1159,7 +1159,7 @@ static void titleInitNintendoLogo(void) modelCalculateRwDataLen(g_ModelStates[MODEL_NINTENDOLOGO].filedata); g_TitleModel = modelmgrInstantiateModelWithoutAnim(g_ModelStates[MODEL_NINTENDOLOGO].filedata); - modelSetScale(g_TitleModel, 1); + g_TitleModel->scale = 1; modelSetRootPosition(g_TitleModel, &coord); } } @@ -1180,7 +1180,7 @@ static void titleTickNintendoLogo(void) viSetFovY(60); viSetAspect(1.33333333f); viSetZRange(100, 10000); - viSetUseZBuf(false); + g_ViBackData->usezbuf = false; g_TitleTimer += g_Vars.lvupdate60; @@ -1310,7 +1310,7 @@ static void titleInitRareLogo(void) modelCalculateRwDataLen(g_ModelStates[MODEL_RARELOGO].filedata); g_TitleModel = modelmgrInstantiateModelWithoutAnim(g_ModelStates[MODEL_RARELOGO].filedata); - modelSetScale(g_TitleModel, 1); + g_TitleModel->scale = 1; modelSetRootPosition(g_TitleModel, &coord); musicQueueStopAllEvent(); @@ -1341,7 +1341,7 @@ static void titleTickRareLogo(void) viSetFovY(60); viSetAspect(1.33333333f); viSetZRange(100, 10000); - viSetUseZBuf(false); + g_ViBackData->usezbuf = false; if (g_TitleTimer < 0) { g_TitleTimer++; @@ -1573,7 +1573,7 @@ static void titleTickNoController(void) viSetFovY(60); viSetAspect(1.33333333f); viSetZRange(100, 10000); - viSetUseZBuf(false); + g_ViBackData->usezbuf = false; g_TitleTimer += g_Vars.lvupdate60; } @@ -1606,8 +1606,8 @@ static Gfx *titleRenderNoController(Gfx *gdl) x = 288 - (textwidth >> 1); y = (480 / 2) - (textheight >> 1) - 12; - width = viGetWidth(); - gdl = textRenderProjected(gdl, &x, &y, text, g_CharsHandelGothicLg, g_FontHandelGothicLg, 0xffffffff, width, viGetHeight(), 0, 0); + width = g_ViBackData->x; + gdl = textRenderProjected(gdl, &x, &y, text, g_CharsHandelGothicLg, g_FontHandelGothicLg, 0xffffffff, width, g_ViBackData->y, 0, 0); // Line 2 text = langGet(L_OPTIONS_072); // "please power off and attach a controller" @@ -1616,8 +1616,8 @@ static Gfx *titleRenderNoController(Gfx *gdl) x = 288 - (textwidth >> 1); y = (480 / 2) - (textheight >> 1) + 12; - width = viGetWidth(); - gdl = textRenderProjected(gdl, &x, &y, text, g_CharsHandelGothicLg, g_FontHandelGothicLg, 0xffffffff, width, viGetHeight(), 0, 0); + width = g_ViBackData->x; + gdl = textRenderProjected(gdl, &x, &y, text, g_CharsHandelGothicLg, g_FontHandelGothicLg, 0xffffffff, width, g_ViBackData->y, 0, 0); gdl = text0f153780(gdl); @@ -1743,7 +1743,7 @@ void titleTick(void) titleTickNoController(); break; case TITLEMODE_SKIP: - viSetUseZBuf(false); + g_ViBackData->usezbuf = false; titleSetNextMode(TITLEMODE_RARELOGO); break; } diff --git a/src/game/titleclear.c b/src/game/titleclear.c index 5d8e89e75..bbb415a20 100644 --- a/src/game/titleclear.c +++ b/src/game/titleclear.c @@ -8,9 +8,9 @@ Gfx *titleClear(Gfx *gdl) { gDPSetCycleType(gdl++, G_CYC_FILL); - gDPSetColorImage(gdl++, G_IM_FMT_RGBA, G_IM_SIZ_16b, viGetWidth(), osVirtualToPhysical((void *)viGetBackBuffer())); + gDPSetColorImage(gdl++, G_IM_FMT_RGBA, G_IM_SIZ_16b, g_ViBackData->x, osVirtualToPhysical((void *)g_ViBackData->fb)); gDPSetFillColor(gdl++, 0x00010001); - gDPFillRectangle(gdl++, 0, 0, viGetWidth() - 1, viGetHeight() - 1); + gDPFillRectangle(gdl++, 0, 0, g_ViBackData->x - 1, g_ViBackData->y - 1); return gdl; } diff --git a/src/game/training.c b/src/game/training.c index 79132108f..8ea5a9385 100644 --- a/src/game/training.c +++ b/src/game/training.c @@ -2038,7 +2038,7 @@ s32 frIsInTraining(void) return g_Vars.currentplayer->prop->rooms[0] == ROOM_DISH_FIRINGRANGE && g_FrIsValidWeapon - && mainGetStageNum() == STAGE_CITRAINING; + && g_StageNum == STAGE_CITRAINING; } void frCalculateHit(struct defaultobj *obj, struct coord *hitpos, f32 maulercharge) @@ -3077,7 +3077,7 @@ static Gfx *frRenderHudElement(Gfx *gdl, s32 x, s32 y, char *string1, char *stri gdl = text0f153858(gdl, &x2, &y2, &textwidth, &textheight); gdl = textRender(gdl, &x2, &y2, string1, - g_CharsHandelGothicMd, g_FontHandelGothicMd, fullcolour, halfalpha, viGetWidth(), viGetHeight(), 0, 0); + g_CharsHandelGothicMd, g_FontHandelGothicMd, fullcolour, halfalpha, g_ViBackData->x, g_ViBackData->y, 0, 0); if (string2) { textMeasure(&textheight, &textwidth, string2, g_CharsHandelGothicXs, g_FontHandelGothicXs, 0); @@ -3087,7 +3087,7 @@ static Gfx *frRenderHudElement(Gfx *gdl, s32 x, s32 y, char *string1, char *stri gdl = text0f153858(gdl, &x2, &y2, &textwidth, &textheight); gdl = textRender(gdl, &x2, &y2, string2, - g_CharsHandelGothicXs, g_FontHandelGothicXs, fullcolour, halfalpha, viGetWidth(), viGetHeight(), 0, 0); + g_CharsHandelGothicXs, g_FontHandelGothicXs, fullcolour, halfalpha, g_ViBackData->x, g_ViBackData->y, 0, 0); } return gdl; @@ -3102,7 +3102,7 @@ Gfx *frRenderHud(Gfx *gdl) s32 alpha = 0xa0; f32 mult; - if (viGetViewWidth() > 400) { + if (g_ViBackData->viewx > 400) { mult = 2; } else { mult = 1; @@ -3122,7 +3122,7 @@ Gfx *frRenderHud(Gfx *gdl) red = frFormatTime(string1); exists = frGetHudMiddleSubtext(string2); - gdl = frRenderHudElement(gdl, viGetViewWidth() >> 1, viGetViewTop() + 12, + gdl = frRenderHudElement(gdl, g_ViBackData->viewx >> 1, g_ViBackData->viewtop + 12, string1, exists ? string2 : NULL, red ? 0xff0000a0 : 0x00ff00a0, alpha); @@ -3130,19 +3130,19 @@ Gfx *frRenderHud(Gfx *gdl) // Score frGetScoreValue(string1); frGetGoalScoreText(string2); - gdl = frRenderHudElement(gdl, viGetViewLeft() + 65.0f * mult, viGetViewTop() + 12, + gdl = frRenderHudElement(gdl, g_ViBackData->viewleft + 65.0f * mult, g_ViBackData->viewtop + 12, string1, string2, 0x00ff00a0, alpha); // Feedback if (frGetFeedback(string1, string2)) { - gdl = frRenderHudElement(gdl,viGetViewLeft() + 65.0f * mult, viGetViewTop() + 40, + gdl = frRenderHudElement(gdl,g_ViBackData->viewleft + 65.0f * mult, g_ViBackData->viewtop + 40, string1, string2, 0x00ff00a0, alpha); } if (g_FrData.goalaccuracy > 0) { red = frGetMinAccuracy(string2, frGetAccuracy(string1)); - gdl = frRenderHudElement(gdl, viGetViewLeft() + viGetViewWidth() - 70.0f * mult, viGetViewTop() + 12, + gdl = frRenderHudElement(gdl, g_ViBackData->viewleft + g_ViBackData->viewx - 70.0f * mult, g_ViBackData->viewtop + 12, string1, string2, red ? 0xff0000a0 : 0x00ff00a0, alpha); @@ -3154,7 +3154,7 @@ Gfx *frRenderHud(Gfx *gdl) mult = 2.4; } - gdl = frRenderHudElement(gdl, viGetViewLeft() + viGetViewWidth() - 70.0f * mult, viGetViewTop() + 12, + gdl = frRenderHudElement(gdl, g_ViBackData->viewleft + g_ViBackData->viewx - 70.0f * mult, g_ViBackData->viewtop + 12, string1, string2, 0x00ff00a0, alpha); } diff --git a/src/game/trainingmenus.c b/src/game/trainingmenus.c index be88b7a51..4d6fb3c70 100644 --- a/src/game/trainingmenus.c +++ b/src/game/trainingmenus.c @@ -144,7 +144,7 @@ static s32 frWeaponListMenuHandler(s32 operation, struct menuitem *item, union h y = renderdata->y; gdl = text0f153628(gdl); - gdl = textRenderProjected(gdl, &x, &y, bgunGetName(weaponnum2), g_CharsHandelGothicSm, g_FontHandelGothicSm, renderdata->colour, viGetWidth(), viGetHeight(), 0, 0); + gdl = textRenderProjected(gdl, &x, &y, bgunGetName(weaponnum2), g_CharsHandelGothicSm, g_FontHandelGothicSm, renderdata->colour, g_ViBackData->x, g_ViBackData->y, 0, 0); gdl = text0f153780(gdl); // Prepare the star texture for the difficulties @@ -563,14 +563,14 @@ static s32 frScoringMenuHandler(s32 operation, struct menuitem *item, union hand x = renderdata->x + 93; y = renderdata->y + 14; gdl = text0f153858(gdl, &x, &y, &textheight, &textwidth); - gdl = textRenderProjected(gdl, &x, &y, text, g_CharsHandelGothicSm, g_FontHandelGothicSm, COLOUR(), viGetWidth(), viGetHeight(), 0, 0); + gdl = textRenderProjected(gdl, &x, &y, text, g_CharsHandelGothicSm, g_FontHandelGothicSm, COLOUR(), g_ViBackData->x, g_ViBackData->y, 0, 0); // "Bull's-eye" sprintf(text, langGet(L_MPMENU_461)); x = renderdata->x + 122; y = renderdata->y + 14; gdl = text0f153858(gdl, &x, &y, &textheight, &textwidth); - gdl = textRenderProjected(gdl, &x, &y, text, g_CharsHandelGothicSm, g_FontHandelGothicSm, COLOUR(), viGetWidth(), viGetHeight(), 0, 0); + gdl = textRenderProjected(gdl, &x, &y, text, g_CharsHandelGothicSm, g_FontHandelGothicSm, COLOUR(), g_ViBackData->x, g_ViBackData->y, 0, 0); // Bull's-eye score sprintf(text, "%d\n", frdata->numhitsbullseye * 10); @@ -578,21 +578,21 @@ static s32 frScoringMenuHandler(s32 operation, struct menuitem *item, union hand x = renderdata->x - textheight + 182; y = renderdata->y + 14; gdl = text0f153858(gdl, &x, &y, &textheight, &textwidth); - gdl = textRenderProjected(gdl, &x, &y, text, g_CharsHandelGothicSm, g_FontHandelGothicSm, COLOUR(), viGetWidth(), viGetHeight(), 0, 0); + gdl = textRenderProjected(gdl, &x, &y, text, g_CharsHandelGothicSm, g_FontHandelGothicSm, COLOUR(), g_ViBackData->x, g_ViBackData->y, 0, 0); // Zone 1 count sprintf(text, "%d\n", frdata->numhitsring1); x = renderdata->x + 93; y = renderdata->y + 25; gdl = text0f153858(gdl, &x, &y, &textheight, &textwidth); - gdl = textRenderProjected(gdl, &x, &y, text, g_CharsHandelGothicSm, g_FontHandelGothicSm, COLOUR(), viGetWidth(), viGetHeight(), 0, 0); + gdl = textRenderProjected(gdl, &x, &y, text, g_CharsHandelGothicSm, g_FontHandelGothicSm, COLOUR(), g_ViBackData->x, g_ViBackData->y, 0, 0); // "Zone 1" sprintf(text, langGet(L_MPMENU_462)); x = renderdata->x + 122; y = renderdata->y + 25; gdl = text0f153858(gdl, &x, &y, &textheight, &textwidth); - gdl = textRenderProjected(gdl, &x, &y, text, g_CharsHandelGothicSm, g_FontHandelGothicSm, COLOUR(), viGetWidth(), viGetHeight(), 0, 0); + gdl = textRenderProjected(gdl, &x, &y, text, g_CharsHandelGothicSm, g_FontHandelGothicSm, COLOUR(), g_ViBackData->x, g_ViBackData->y, 0, 0); // Zone 1 score sprintf(text, "%d\n", frdata->numhitsring1 * 5); @@ -600,21 +600,21 @@ static s32 frScoringMenuHandler(s32 operation, struct menuitem *item, union hand x = renderdata->x - textheight + 182; y = renderdata->y + 25; gdl = text0f153858(gdl, &x, &y, &textheight, &textwidth); - gdl = textRenderProjected(gdl, &x, &y, text, g_CharsHandelGothicSm, g_FontHandelGothicSm, COLOUR(), viGetWidth(), viGetHeight(), 0, 0); + gdl = textRenderProjected(gdl, &x, &y, text, g_CharsHandelGothicSm, g_FontHandelGothicSm, COLOUR(), g_ViBackData->x, g_ViBackData->y, 0, 0); // Zone 2 count sprintf(text, "%d\n", frdata->numhitsring2); x = renderdata->x + 93; y = renderdata->y + 36; gdl = text0f153858(gdl, &x, &y, &textheight, &textwidth); - gdl = textRenderProjected(gdl, &x, &y, text, g_CharsHandelGothicSm, g_FontHandelGothicSm, COLOUR(), viGetWidth(), viGetHeight(), 0, 0); + gdl = textRenderProjected(gdl, &x, &y, text, g_CharsHandelGothicSm, g_FontHandelGothicSm, COLOUR(), g_ViBackData->x, g_ViBackData->y, 0, 0); // "Zone 2" sprintf(text, langGet(L_MPMENU_463)); x = renderdata->x + 122; y = renderdata->y + 36; gdl = text0f153858(gdl, &x, &y, &textheight, &textwidth); - gdl = textRenderProjected(gdl, &x, &y, text, g_CharsHandelGothicSm, g_FontHandelGothicSm, COLOUR(), viGetWidth(), viGetHeight(), 0, 0); + gdl = textRenderProjected(gdl, &x, &y, text, g_CharsHandelGothicSm, g_FontHandelGothicSm, COLOUR(), g_ViBackData->x, g_ViBackData->y, 0, 0); // Zone 2 score sprintf(text, "%d\n", frdata->numhitsring2 * 2); @@ -622,14 +622,14 @@ static s32 frScoringMenuHandler(s32 operation, struct menuitem *item, union hand x = renderdata->x - textheight + 182; y = renderdata->y + 36; gdl = text0f153858(gdl, &x, &y, &textheight, &textwidth); - gdl = textRenderProjected(gdl, &x, &y, text, g_CharsHandelGothicSm, g_FontHandelGothicSm, COLOUR(), viGetWidth(), viGetHeight(), 0, 0); + gdl = textRenderProjected(gdl, &x, &y, text, g_CharsHandelGothicSm, g_FontHandelGothicSm, COLOUR(), g_ViBackData->x, g_ViBackData->y, 0, 0); // Zone 3 count sprintf(text, "%d\n", frdata->numhitsring3); x = renderdata->x + 93; y = renderdata->y + 47; gdl = text0f153858(gdl, &x, &y, &textheight, &textwidth); - gdl = textRenderProjected(gdl, &x, &y, text, g_CharsHandelGothicSm, g_FontHandelGothicSm, COLOUR(), viGetWidth(), viGetHeight(), 0, 0); + gdl = textRenderProjected(gdl, &x, &y, text, g_CharsHandelGothicSm, g_FontHandelGothicSm, COLOUR(), g_ViBackData->x, g_ViBackData->y, 0, 0); // "Zone 3" // Note: developers forgot to remove last argument when copy/pasting @@ -637,7 +637,7 @@ static s32 frScoringMenuHandler(s32 operation, struct menuitem *item, union hand x = renderdata->x + 122; y = renderdata->y + 47; gdl = text0f153858(gdl, &x, &y, &textheight, &textwidth); - gdl = textRenderProjected(gdl, &x, &y, text, g_CharsHandelGothicSm, g_FontHandelGothicSm, COLOUR(), viGetWidth(), viGetHeight(), 0, 0); + gdl = textRenderProjected(gdl, &x, &y, text, g_CharsHandelGothicSm, g_FontHandelGothicSm, COLOUR(), g_ViBackData->x, g_ViBackData->y, 0, 0); // Zone 3 score sprintf(text, "%d\n", frdata->numhitsring3); @@ -645,7 +645,7 @@ static s32 frScoringMenuHandler(s32 operation, struct menuitem *item, union hand x = renderdata->x - textheight + 182; y = renderdata->y + 47; gdl = text0f153858(gdl, &x, &y, &textheight, &textwidth); - gdl = textRenderProjected(gdl, &x, &y, text, g_CharsHandelGothicSm, g_FontHandelGothicSm, COLOUR(), viGetWidth(), viGetHeight(), 0, 0); + gdl = textRenderProjected(gdl, &x, &y, text, g_CharsHandelGothicSm, g_FontHandelGothicSm, COLOUR(), g_ViBackData->x, g_ViBackData->y, 0, 0); // "Hit total" sprintf(text, langGet(L_MPMENU_465)); @@ -653,7 +653,7 @@ static s32 frScoringMenuHandler(s32 operation, struct menuitem *item, union hand y = renderdata->y + 63; gdl = text0f153858(gdl, &x, &y, &textheight, &textwidth); - gdl = textRenderProjected(gdl, &x, &y, text, g_CharsHandelGothicSm, g_FontHandelGothicSm, COLOUR(), viGetWidth(), viGetHeight(), 0, 0); + gdl = textRenderProjected(gdl, &x, &y, text, g_CharsHandelGothicSm, g_FontHandelGothicSm, COLOUR(), g_ViBackData->x, g_ViBackData->y, 0, 0); // Hit total count sprintf(text, "%d\n", frdata->numhitsring3 + frdata->numhitsbullseye + frdata->numhitsring1 + frdata->numhitsring2); @@ -662,42 +662,42 @@ static s32 frScoringMenuHandler(s32 operation, struct menuitem *item, union hand y = renderdata->y + 63; gdl = text0f153858(gdl, &x, &y, &textheight, &textwidth); - gdl = textRenderProjected(gdl, &x, &y, text, g_CharsHandelGothicSm, g_FontHandelGothicSm, COLOUR(), viGetWidth(), viGetHeight(), 0, 0); + gdl = textRenderProjected(gdl, &x, &y, text, g_CharsHandelGothicSm, g_FontHandelGothicSm, COLOUR(), g_ViBackData->x, g_ViBackData->y, 0, 0); // "Scoring" sprintf(text, langGet(L_MPMENU_466)); x = renderdata->x + 83; y = renderdata->y + 1; gdl = text0f153858(gdl, &x, &y, &textheight, &textwidth); - gdl = textRenderProjected(gdl, &x, &y, text, g_CharsHandelGothicSm, g_FontHandelGothicSm, COLOUR(), viGetWidth(), viGetHeight(), 0, 0); + gdl = textRenderProjected(gdl, &x, &y, text, g_CharsHandelGothicSm, g_FontHandelGothicSm, COLOUR(), g_ViBackData->x, g_ViBackData->y, 0, 0); // "10" sprintf(text, langGet(L_MPMENU_467)); x = renderdata->x + 38; y = renderdata->y + 35; gdl = text0f153858(gdl, &x, &y, &textheight, &textwidth); - gdl = textRenderProjected(gdl, &x, &y, text, g_CharsNumeric, g_FontNumeric, COLOURWHITE(), viGetWidth(), viGetHeight(), 0, 0); + gdl = textRenderProjected(gdl, &x, &y, text, g_CharsNumeric, g_FontNumeric, COLOURWHITE(), g_ViBackData->x, g_ViBackData->y, 0, 0); // "5" sprintf(text, langGet(L_MPMENU_468)); x = renderdata->x + 32; y = renderdata->y + 26; gdl = text0f153858(gdl, &x, &y, &textheight, &textwidth); - gdl = textRenderProjected(gdl, &x, &y, text, g_CharsNumeric, g_FontNumeric, COLOURWHITE(), viGetWidth(), viGetHeight(), 0, 0); + gdl = textRenderProjected(gdl, &x, &y, text, g_CharsNumeric, g_FontNumeric, COLOURWHITE(), g_ViBackData->x, g_ViBackData->y, 0, 0); // "2" sprintf(text, langGet(L_MPMENU_469)); x = renderdata->x + 24; y = renderdata->y + 16; gdl = text0f153858(gdl, &x, &y, &textheight, &textwidth); - gdl = textRenderProjected(gdl, &x, &y, text, g_CharsNumeric, g_FontNumeric, COLOURWHITE(), viGetWidth(), viGetHeight(), 0, 0); + gdl = textRenderProjected(gdl, &x, &y, text, g_CharsNumeric, g_FontNumeric, COLOURWHITE(), g_ViBackData->x, g_ViBackData->y, 0, 0); // "1" sprintf(text, langGet(L_MPMENU_470)); x = renderdata->x + 14; y = renderdata->y + 4; gdl = text0f153858(gdl, &x, &y, &textheight, &textwidth); - gdl = textRenderProjected(gdl, &x, &y, text, g_CharsNumeric, g_FontNumeric, COLOURWHITE(), viGetWidth(), viGetHeight(), 0, 0); + gdl = textRenderProjected(gdl, &x, &y, text, g_CharsNumeric, g_FontNumeric, COLOURWHITE(), g_ViBackData->x, g_ViBackData->y, 0, 0); gdl = text0f153838(gdl); @@ -1314,7 +1314,7 @@ static s32 ciCharacterProfileMenuDialog(s32 operation, struct menudialogdef *dia x = -130; - if (optionsGetScreenRatio() == SCREENRATIO_16_9) { + if (g_ScreenRatio == SCREENRATIO_16_9) { x = -100; } @@ -1623,7 +1623,7 @@ static s32 dtTrainingDetailsMenuDialog(s32 operation, struct menudialogdef *dial g_Menus[g_MpPlayerNum].training.weaponnum = weaponnum; func0f105948(weaponnum); - if (optionsGetScreenRatio() == SCREENRATIO_16_9) { + if (g_ScreenRatio == SCREENRATIO_16_9) { g_Menus[g_MpPlayerNum].unk840.unk538 = 70; g_Menus[g_MpPlayerNum].unk840.unk510 = 70; } else { @@ -2286,7 +2286,7 @@ static s32 ciHangarTitleMenuHandler(s32 operation, struct menuitem *item, union } textheight = renderdata->y + 8; - gdl = textRenderProjected(gdl, &textwidth, &textheight, text, g_CharsHandelGothicMd, g_FontHandelGothicMd, renderdata->colour, viGetWidth(), viGetHeight(), 0, 0); + gdl = textRenderProjected(gdl, &textwidth, &textheight, text, g_CharsHandelGothicMd, g_FontHandelGothicMd, renderdata->colour, g_ViBackData->x, g_ViBackData->y, 0, 0); // Render subheading text = ciMenuTextHangarBioSubheading(NULL); @@ -2299,7 +2299,7 @@ static s32 ciHangarTitleMenuHandler(s32 operation, struct menuitem *item, union } textheight = renderdata->y + 25; - gdl = textRenderProjected(gdl, &textwidth, &textheight, text, g_CharsHandelGothicSm, g_FontHandelGothicSm, renderdata->colour, viGetWidth(), viGetHeight(), 0, 0); + gdl = textRenderProjected(gdl, &textwidth, &textheight, text, g_CharsHandelGothicSm, g_FontHandelGothicSm, renderdata->colour, g_ViBackData->x, g_ViBackData->y, 0, 0); gdl = text0f153780(gdl); diff --git a/src/game/vtxstore.c b/src/game/vtxstore.c index 0da9923ca..0302c4ae4 100644 --- a/src/game/vtxstore.c +++ b/src/game/vtxstore.c @@ -139,7 +139,7 @@ void *vtxstoreAllocate(s32 count, s32 index, struct modelnode *node, s32 level) // reaping on a random corpse and replace its entry in the array. // So at the end, we'll have an array of up to six unreapable corpses and // all other corpses will be flagged for reaping. - numchrs = chrsGetNumSlots(); + numchrs = g_NumChrSlots; tally = 0; for (i = 0; i < numchrs; i++) { diff --git a/src/game/weather.c b/src/game/weather.c index f3ac4882b..eef28ede6 100644 --- a/src/game/weather.c +++ b/src/game/weather.c @@ -303,7 +303,7 @@ void weatherTickRain(struct weatherdata *weather) iVar10 = weather->unk58[i].unk00 * 32767.0f * weather->unk88; - if (lvIsPaused()) { + if (g_LvIsPaused) { iVar10 = 0; } @@ -851,7 +851,7 @@ static Gfx *weatherRenderRain(Gfx *gdl, struct weatherdata *weather, s32 arg2) sp194 = 0; mtx4LoadIdentity(&sp1c8); - mtx00015be0(camGetWorldToScreenMtxf(), &sp1c8); + mtx00015be0(g_Vars.currentplayer->worldtoscreenmtx, &sp1c8); sp1c8.m[3][0] = 0.0f; sp1c8.m[3][1] = 0.0f; @@ -1436,7 +1436,7 @@ static Gfx *weatherRenderSnow(Gfx *gdl, struct weatherdata *weather, s32 arg2) sp198 = 0; mtx4LoadIdentity(&sp1cc); - mtx00015be0(camGetWorldToScreenMtxf(), &sp1cc); + mtx00015be0(g_Vars.currentplayer->worldtoscreenmtx, &sp1cc); sp1cc.m[3][0] = 0.0f; sp1cc.m[3][1] = 0.0f; diff --git a/src/include/bss.h b/src/include/bss.h index b226ccd17..c2ccb3589 100644 --- a/src/include/bss.h +++ b/src/include/bss.h @@ -220,7 +220,7 @@ extern struct screenbox var800a65c0; extern struct screenbox g_PortalScreenBbox; extern u32 g_FogEnabled; extern u32 var800a65e4; -extern struct coord *var800a65e8; +extern struct coord *g_Env800a65e8; extern u8 *var800a6660; extern s16 *var800a6664; extern s16 *var800a6668; diff --git a/src/include/game/bg.h b/src/include/game/bg.h index e43d1c226..9db00e6ff 100644 --- a/src/include/game/bg.h +++ b/src/include/game/bg.h @@ -15,7 +15,6 @@ void bgBuildTables(s32 stagenum); void bgStop(void); void func0f15c880(f32 arg0); f32 func0f15c888(void); -f32 currentPlayerGetScaleBg2Gfx(void); void currentPlayerSetScaleBg2Gfx(f32 arg0); void func0f15c920(void); void bgTick(void); diff --git a/src/include/game/bondgun.h b/src/include/game/bondgun.h index 9dde79700..eeb6ad55f 100644 --- a/src/include/game/bondgun.h +++ b/src/include/game/bondgun.h @@ -4,6 +4,8 @@ #include "data.h" #include "types.h" +extern struct ammotype g_AmmoTypes[]; + void bgunReset(void); void bgunStop(void); @@ -12,16 +14,12 @@ void bgunPreload(void); s32 bgunGetMinClipQty(s32 weaponnum, s32 funcnum); s32 bgunTickIncState2(struct handweaponinfo *info, s32 handnum, struct hand *hand, s32 lvupdate); void bgunInitHandAnims(void); -f32 bgunGetNoiseRadius(s32 handnum); void bgunCalculateBlend(s32 hand); void bgun0f09d8dc(f32 breathing, f32 arg1, f32 arg2, f32 arg3, f32 arg4); -u8 *bgunGetGunMem(void); u32 bgunCalculateGunMemCapacity(void); -void bgunFreeGunMem(void); bool bgun0f09e004(s32 newowner); void bgunTickGunLoad(void); bool bgun0f09eae4(void); -struct modelfiledata *bgunGetCartModeldef(void); void bgun0f09ebcc(struct defaultobj *obj, struct coord *coord, s16 *rooms, Mtxf *matrix1, struct coord *velocity, Mtxf *matrix2, struct prop *prop, struct coord *pos); struct defaultobj *bgunCreateThrownProjectile2(struct chrdata *chr, struct gset *gset, struct coord *pos, s16 *rooms, Mtxf *arg4, struct coord *velocity); void bgunCreateThrownProjectile(s32 handnum, struct gset *gset); @@ -42,10 +40,7 @@ void bgunCycleForward(void); void bgunCycleBack(void); bool bgunHasAmmoForWeapon(s32 weaponnum); void bgunEquipWeapon2(s32 handnum, s32 weaponnum); -s32 bgunIsFiring(s32 handnum); -s32 bgunGetAttackType(s32 handnum); char *bgunGetName(s32 weaponnum); -u16 bgunGetNameId(s32 weaponnum); char *bgunGetShortName(s32 arg0); void bgunReloadIfPossible(s32 handnum); void bgunSetAdjustPos(f32 angle); @@ -64,7 +59,6 @@ s32 bgunConsiderToggleGunFunction(s32 usedowntime, bool trigpressed, bool fromac void bgun0f0a8c50(void); void bgunTickGameplay(bool triggeron); void bgunSetPassiveMode(bool enable); -void bgunSetAimType(u32 aimtype); void bgunSetHitPos(struct coord *coord); void bgun0f0a9494(u32 operation); void bgun0f0a94d0(u32 operation, struct coord *pos, struct coord *rot); @@ -72,7 +66,6 @@ void bgunSetGunAmmoVisible(u32 reason, bool enable); void bgunSetAmmoQuantity(s32 ammotype, s32 quantity); s32 bgunGetReservedAmmoCount(s32 type); s32 bgunGetAmmoCount(s32 ammotype); -s32 bgunGetCapacityByAmmotype(s32 ammotype); void bgunGiveMaxAmmo(bool force); u32 bgunGetAmmoTypeForWeapon(u32 weaponnum, u32 func); s32 bgunGetAmmoQtyForWeapon(u32 weaponnum, u32 func); @@ -90,4 +83,9 @@ s32 bgunGetWeaponNum2(s32 handnum); void bgunFreeFireslotWrapper(s32 fireslot); void bgunFreeFireslot(s32 fireslot); +static inline s32 bgunGetCapacityByAmmotype(s32 ammotype) +{ + return g_AmmoTypes[ammotype].capacity; +} + #endif diff --git a/src/include/game/bondmove.h b/src/include/game/bondmove.h index 827440a79..3aedd4b57 100644 --- a/src/include/game/bondmove.h +++ b/src/include/game/bondmove.h @@ -8,7 +8,6 @@ void bmoveSetControlDef(u32 controldef); void bmoveSetAutoMoveCentreEnabled(bool enabled); void bmoveSetAutoAim(bool enabled); bool bmoveIsAutoAimEnabledForCurrentWeapon(void); -bool bmoveIsInSightAimMode(void); void bmoveUpdateAutoAimProp(struct prop *prop, f32 x, f32 y); struct prop *bmoveGetHoverbike(void); struct prop *bmoveGetGrabbedProp(void); diff --git a/src/include/game/camera.h b/src/include/game/camera.h index 20072e572..219f051e6 100644 --- a/src/include/game/camera.h +++ b/src/include/game/camera.h @@ -4,9 +4,6 @@ #include "data.h" #include "types.h" -void camSetScreenSize(f32 width, f32 height); -void camSetScreenPosition(f32 left, f32 top); -void camSetPerspective(f32 near, f32 fovy, f32 aspect); f32 cam0f0b49b8(f32 arg0); void camSetScale(void); void cam0f0b4c3c(f32 *crosspos, struct coord *dst, f32 arg2); @@ -15,31 +12,11 @@ void cam0f0b4d68(struct coord *in, f32 out[2]); void cam0f0b4dec(struct coord *in, f32 out[2]); void cam0f0b4e68(f32 in[2], f32 divisor, f32 out[2]); void cam0f0b4eb8(struct coord *arg0, f32 arg1[2], f32 zoom, f32 aspect); -void camSetMtxL1738(Mtx *mtx); -void camSetMtxL173c(Mtx *mtx); -Mtx *camGetMtxL173c(void); -void camSetMtxF006c(Mtxf *mtx); Mtxf *camGetMtxF006c(void); -void camSetPerspectiveMtxL(Mtx *value); -Mtx *camGetPerspectiveMtxL(void); -void camSetOrthogonalMtxL(Mtx *mtx); -Mtx *camGetOrthogonalMtxL(void); void camSetWorldToScreenMtxf(Mtxf *mtx); Mtxf *cam0f0b5050(u8 *arg0); Mtxf *cam0f0b53a4(u8 *arg0); -Mtxf *camGetWorldToScreenMtxf(void); -void camSetMtxF1754(Mtxf *mtx); -Mtxf *camGetMtxF1754(void); void camSetProjectionMtxF(Mtxf *mtx); -Mtxf *camGetProjectionMtxF(void); -void camSetLookAt(LookAt *lookat); -LookAt *camGetLookAt(void); -f32 camGetLodScaleZ(void); -f32 camGetScreenWidth(void); -f32 camGetScreenHeight(void); -f32 camGetScreenLeft(void); -f32 camGetScreenTop(void); -f32 camGetPerspAspect(void); void cam0f0b5838(void); bool cam0f0b5b9c(struct coord *arg0, f32 arg1); bool camIsPosInScreenBox(struct coord *pos, f32 arg1, struct var800a4640_00 *arg2); diff --git a/src/include/game/chr.h b/src/include/game/chr.h index 097e96399..2042b3680 100644 --- a/src/include/game/chr.h +++ b/src/include/game/chr.h @@ -47,7 +47,6 @@ void shieldhitsRemoveByProp(struct prop *prop); void chr0f0295f8(f32 arg0, s32 *arg1, s32 *arg2, s32 *arg3); Gfx *shieldhitRender(Gfx *gdl, struct prop *prop1, struct prop *prop2, s32 alpha, bool arg4, s32 cmnum1, s32 cmnum2, s32 cmnum3, s32 cmnum4); void shieldhitsTick(void); -s32 chrsGetNumSlots(void); struct gfxvtx *chrAllocateVertices(s32 numvertices); void chrsSetVar8006297c(u32 arg0); u32 chrsGetVar8006297c(void); @@ -68,10 +67,14 @@ void chrUncloakTemporarily(struct chrdata *chr); void chr0f02472c(void); void chr0f028490(f32 arg1); struct chrdata *chrFindByLiteralId(s32 chrnum); -struct prop *chrGetHeldProp(struct chrdata *chr, s32 hand); struct prop *chrGetHeldUsableProp(struct chrdata *chr, s32 hand); struct prop *chrGetTargetProp(struct chrdata *chr); bool chrUpdateGeometry(struct prop *prop, u8 **start, u8 **end); void chrGetBbox(struct prop *prop, f32 *radius, f32 *ymax, f32 *ymin); +static inline struct prop *chrGetHeldProp(struct chrdata *chr, s32 hand) +{ + return chr->weapons_held[hand]; +} + #endif diff --git a/src/include/game/chraction.h b/src/include/game/chraction.h index f92b5228c..88507265d 100644 --- a/src/include/game/chraction.h +++ b/src/include/game/chraction.h @@ -77,7 +77,6 @@ bool chrIsTargetInFov(struct chrdata *chr, u8 arg1, u8 reverse); bool chrIsLookingAtPos(struct chrdata *chr, struct coord *pos, u8 arg2); f32 chrGetSameFloorDistanceToPad(struct chrdata *chr, s32 pad_id); void chrsClearRefsToPlayer(s32 playernum); -s32 chrGetTimer(struct chrdata *chr); bool chrCanSeeTargetWithExtraCheck(struct chrdata *chr); bool chrSawInjury(struct chrdata *chr, u8 arg1); bool chrSawDeath(struct chrdata *chr, u8 arg1); @@ -100,7 +99,6 @@ void rebuildSquadrons(void); void func0f02e9a0(struct chrdata *chr, f32 mergetime); void chrDoSurprisedSurrender(struct chrdata *chr); void chrDoSurprisedLookAround(struct chrdata *chr); -f32 chrGetShield(struct chrdata *chr); void chrDie(struct chrdata *chr, s32 aplayernum); struct path *pathFindById(u32 path_id); bool chrCanSeeTarget(struct chrdata *chr); @@ -168,7 +166,6 @@ bool chrHasStageFlag(struct chrdata *chr, u32 flag); bool chrIsHearingTarget(struct chrdata *chr); void chrRestartTimer(struct chrdata *chr); bool chrResetNearMiss(struct chrdata *chr); -s32 chrGetNumArghs(struct chrdata *chr); s32 chrGetNumCloseArghs(struct chrdata *chr); void decrementByte(u8 *dst, u8 amount); void incrementByte(u8 *dst, u8 amount); diff --git a/src/include/game/dlights.h b/src/include/game/dlights.h index 19c9cf869..c352b6148 100644 --- a/src/include/game/dlights.h +++ b/src/include/game/dlights.h @@ -7,7 +7,6 @@ u8 func0f0009c0(s32 roomnum); u8 func0f000a10(s32 roomnum); u8 func0f000b24(s32 roomnum); -u8 roomGetBrightness(s32 room); s32 func0f000c54(s32 roomnum); f32 roomGetUnk5c(s32 roomnum); f32 func0f000dbc(s32 roomnum); diff --git a/src/include/game/dyntex.h b/src/include/game/dyntex.h index f728d8fcf..07e86b27e 100644 --- a/src/include/game/dyntex.h +++ b/src/include/game/dyntex.h @@ -4,6 +4,8 @@ #include "data.h" #include "types.h" +extern s32 g_DyntexCurRoom; + void dyntexTickRoom(s32 roomnum, struct gfxvtx *vertices); void dyntexAddVertex(struct gfxvtx *vertex); void dyntexSetCurrentType(s16 type); diff --git a/src/include/game/env.h b/src/include/game/env.h index 71a3d94a3..26e24cd99 100644 --- a/src/include/game/env.h +++ b/src/include/game/env.h @@ -4,8 +4,9 @@ #include "data.h" #include "types.h" -struct environment *envGetCurrent(void); -f32 env0f1657e4(void); +extern struct environment g_Env; +extern f32 var80081050; + void env0f1657f8(void); void envSetStageNum(s32 stagenum); void envChooseAndApply(s32 stagenum, bool allowoverride); @@ -13,7 +14,6 @@ void envApplyTransitionFrac(f32 arg0); Gfx *envStartFog(Gfx *gdl, bool xlupass); Gfx *envStopFog(Gfx *gdl); bool env0f1666f8(struct coord *pos, f32 arg1); -struct coord *env0f1667e8(void); s32 env0f1667f4(struct prop *prop, f32 arg1[4]); #endif diff --git a/src/include/game/game_0b0fd0.h b/src/include/game/game_0b0fd0.h index 8bbccd8eb..cc94beafb 100644 --- a/src/include/game/game_0b0fd0.h +++ b/src/include/game/game_0b0fd0.h @@ -12,7 +12,6 @@ struct weaponfunc *weaponGetFunction(struct gset *gset, s32 which); struct weaponfunc *currentPlayerGetWeaponFunction(u32 hand); struct invaimsettings *gsetGetAimSettings(struct gset *gset); struct inventory_ammo *weaponGetAmmoByFunction(u32 weaponnum, u32 funcnum); -f32 handGetXShift(s32 handnum); f32 func0f0b131c(s32 handnum); f32 currentPlayerGetGunZoomFov(void); void currentPlayerZoomOut(f32 fovpersec); diff --git a/src/include/game/lv.h b/src/include/game/lv.h index 20c48675a..9904a8bf9 100644 --- a/src/include/game/lv.h +++ b/src/include/game/lv.h @@ -4,6 +4,10 @@ #include "data.h" #include "types.h" +extern bool g_LvIsPaused; +extern s32 g_StageTimeElapsed60; +extern s32 g_Difficulty; + void lvInit(void); void lvReset(s32 stagenum); Gfx *lvRender(Gfx *gdl); @@ -15,7 +19,6 @@ void lvConfigureFade(u32 color, s16 num_frames); bool lvIsFadeActive(void); void lvStop(void); bool lvIsPaused(void); -s32 lvGetDifficulty(void); void lvSetDifficulty(s32 difficulty); void lvSetMpTimeLimit60(u32 limit); void lvSetMpScoreLimit(u32 limit); diff --git a/src/include/game/objectives.h b/src/include/game/objectives.h index 581dafa6f..aaeaea8ec 100644 --- a/src/include/game/objectives.h +++ b/src/include/game/objectives.h @@ -19,7 +19,6 @@ u32 xorBabeffff(u32 value); u32 xorBoobless(u32 value); void tagsReset(void); s32 objGetTagNum(struct defaultobj *obj); -s32 objectiveGetCount(void); u32 objectiveGetDifficultyBits(s32 index); s32 objectiveCheck(s32 index); bool objectiveIsAllComplete(void); diff --git a/src/include/game/options.h b/src/include/game/options.h index d73d4a4f0..43db8dcee 100644 --- a/src/include/game/options.h +++ b/src/include/game/options.h @@ -1,27 +1,15 @@ #ifndef IN_GAME_PDOPTIONS_H #define IN_GAME_PDOPTIONS_H #include +#include "bss.h" #include "data.h" #include "types.h" -s32 optionsGetControlMode(s32 mpchrnum); -void optionsSetControlMode(s32 mpchrnum, s32 mode); -s32 optionsGetContpadNum1(s32 mpchrnum); -s32 optionsGetContpadNum2(s32 mpchrnum); -s32 optionsGetForwardPitch(s32 mpchrnum); -s32 optionsGetAutoAim(s32 mpchrnum); -s32 optionsGetLookAhead(s32 mpchrnum); -s32 optionsGetAimControl(s32 mpchrnum); -s32 optionsGetSightOnScreen(s32 mpchrnum); -s32 optionsGetAmmoOnScreen(s32 mpchrnum); -s32 optionsGetShowGunFunction(s32 mpchrnum); -s32 optionsGetAlwaysShowTarget(s32 mpchrnum); -s32 optionsGetShowZoomRange(s32 mpchrnum); -s32 optionsGetPaintball(s32 mpchrnum); -s32 optionsGetShowMissionTime(s32 mpchrnum); -u8 optionsGetInGameSubtitles(void); -u8 optionsGetCutsceneSubtitles(void); -s32 optionsGetHeadRoll(s32 mpchrnum); +extern u8 g_InGameSubtitles; +extern u8 g_CutsceneSubtitles; +extern s32 g_ScreenSize; +extern s32 g_ScreenRatio; +extern u8 g_ScreenSplit; void optionsSetForwardPitch(s32 mpchrnum, bool enable); void optionsSetAutoAim(s32 mpchrnum, bool enable); @@ -34,17 +22,72 @@ void optionsSetAlwaysShowTarget(s32 mpchrnum, bool enable); void optionsSetShowZoomRange(s32 mpchrnum, bool enable); void optionsSetPaintball(s32 mpchrnum, bool enable); void optionsSetShowMissionTime(s32 mpchrnum, bool enable); -void optionsSetInGameSubtitles(s32 enable); -void optionsSetCutsceneSubtitles(s32 enable); void optionsSetHeadRoll(s32 mpchrnum, bool enable); s32 optionsGetEffectiveScreenSize(void); -s32 optionsGetScreenSize(void); -void optionsSetScreenSize(s32 size); -s32 optionsGetScreenRatio(void); -void optionsSetScreenRatio(s32 ratio); -u8 optionsGetScreenSplit(void); -void optionsSetScreenSplit(u8 split); -u16 optionsGetMusicVolume(void); -void optionsSetMusicVolume(u16 volume); + +inline static void optionsSetControlMode(s32 mpchrnum, s32 mode) +{ + g_PlayerConfigsArray[mpchrnum].controlmode = mode; +} + +inline static s32 optionsGetForwardPitch(s32 mpchrnum) +{ + return (g_PlayerConfigsArray[mpchrnum].options & OPTION_FORWARDPITCH) != 0; +} + +inline static s32 optionsGetAutoAim(s32 mpchrnum) +{ + return (g_PlayerConfigsArray[mpchrnum].options & OPTION_AUTOAIM) != 0; +} + +inline static s32 optionsGetLookAhead(s32 mpchrnum) +{ + return (g_PlayerConfigsArray[mpchrnum].options & OPTION_LOOKAHEAD) != 0; +} + +inline static s32 optionsGetAimControl(s32 mpchrnum) +{ + return (g_PlayerConfigsArray[mpchrnum].options & OPTION_AIMCONTROL) != 0; +} + +inline static s32 optionsGetSightOnScreen(s32 mpchrnum) +{ + return (g_PlayerConfigsArray[mpchrnum].options & OPTION_SIGHTONSCREEN) != 0; +} + +inline static s32 optionsGetAmmoOnScreen(s32 mpchrnum) +{ + return (g_PlayerConfigsArray[mpchrnum].options & OPTION_AMMOONSCREEN) != 0; +} + +inline static s32 optionsGetShowGunFunction(s32 mpchrnum) +{ + return (g_PlayerConfigsArray[mpchrnum].options & OPTION_SHOWGUNFUNCTION) != 0; +} + +inline static s32 optionsGetAlwaysShowTarget(s32 mpchrnum) +{ + return (g_PlayerConfigsArray[mpchrnum].options & OPTION_ALWAYSSHOWTARGET) != 0; +} + +inline static s32 optionsGetShowZoomRange(s32 mpchrnum) +{ + return (g_PlayerConfigsArray[mpchrnum].options & OPTION_SHOWZOOMRANGE) != 0; +} + +inline static s32 optionsGetPaintball(s32 mpchrnum) +{ + return (g_PlayerConfigsArray[mpchrnum].options & OPTION_PAINTBALL) != 0; +} + +inline static s32 optionsGetShowMissionTime(s32 mpchrnum) +{ + return (g_PlayerConfigsArray[mpchrnum].options & OPTION_SHOWMISSIONTIME) != 0; +} + +inline static s32 optionsGetHeadRoll(s32 mpchrnum) +{ + return (g_PlayerConfigsArray[mpchrnum].options & OPTION_HEADROLL) != 0; +} #endif diff --git a/src/include/game/player.h b/src/include/game/player.h index ed09aa1f5..a9af353c0 100644 --- a/src/include/game/player.h +++ b/src/include/game/player.h @@ -4,6 +4,8 @@ #include "data.h" #include "types.h" +extern struct vimode g_ViModes[]; + f32 playerChooseSpawnLocation(f32 chrradius, struct coord *dstpos, s16 *dstrooms, struct prop *prop, s16 *spawnpads, s32 numspawnpads); f32 playerChooseGeneralSpawnLocation(f32 chrradius, struct coord *pos, s16 *rooms, struct prop *prop); void playerStartNewLife(void); @@ -26,8 +28,6 @@ void playerDisplayDamage(void); Gfx *playerRenderHealthBar(Gfx *gdl); void playerSurroundWithExplosions(s32 arg0); void playerResetLoResIf4Mb(void); -s16 playerGetFbWidth(void); -s16 playerGetFbHeight(void); bool playerHasSharedViewport(void); f32 player0f0bd358(void); void playerConfigureVi(void); @@ -63,7 +63,6 @@ void playerPrepareWarpType2(struct warpparams *cmd, bool hasdir, s32 arg2); void playerPrepareWarpType3(f32 posangle, f32 rotangle, f32 range, f32 height1, f32 height2, s32 padnum); void playerAutoWalk(s16 aimpad, u8 walkspeed, u8 turnspeed, u8 lookup, u8 dist); void playerLaunchSlayerRocket(struct weaponobj *rocket); -bool playerIsHealthVisible(void); void playerSetCamPropertiesWithRoom(struct coord *pos, struct coord *up, struct coord *look, s32 room); #endif diff --git a/src/include/game/playermgr.h b/src/include/game/playermgr.h index 76733e9da..8634fb67c 100644 --- a/src/include/game/playermgr.h +++ b/src/include/game/playermgr.h @@ -12,8 +12,6 @@ void setCurrentPlayerNum(s32 playernum); s32 playermgrGetPlayerNumByProp(struct prop *prop); void playermgrSetViewSize(s32 viewx, s32 viewy); void playermgrSetViewPosition(s32 viewleft, s32 viewtop); -void playermgrSetFovY(f32 fovy); -void playermgrSetAspectRatio(f32 aspect); s32 playermgrGetModelOfWeapon(s32 weapon); void playermgrDeleteWeapon(s32 hand); void playermgrCreateWeapon(s32 hand); diff --git a/src/include/game/prop.h b/src/include/game/prop.h index 57c22c454..4cbc4c104 100644 --- a/src/include/game/prop.h +++ b/src/include/game/prop.h @@ -11,7 +11,6 @@ void propsTick(void); void propsStop(void); void propsSort(void); -void propEnable(struct prop *prop); void propDisable(struct prop *prop); struct prop *propAllocate(void); void propFree(struct prop *prop); @@ -49,4 +48,9 @@ void roomGetProps(s16 *room, s16 *propnums, s32 len); void propGetBbox(struct prop *prop, f32 *radius, f32 *ymax, f32 *ymin); bool propUpdateGeometry(struct prop *prop, u8 **start, u8 **end); +static inline void propEnable(struct prop *prop) +{ + prop->flags |= PROPFLAG_ENABLED; +} + #endif diff --git a/src/include/game/propobj.h b/src/include/game/propobj.h index 4a769c6d7..c3a8e5da4 100644 --- a/src/include/game/propobj.h +++ b/src/include/game/propobj.h @@ -15,7 +15,6 @@ extern struct beam *g_ThrownLaptopBeams; void alarmActivate(void); void alarmDeactivate(void); -bool alarmIsActive(void); s32 audioPlayFromProp(s32 channelnum, s16 soundnum, s32 arg2, struct prop *prop, s16 arg4, u16 arg5); void countdownTimerSetVisible(u32 reason, bool visible); bool doorCallLift(struct prop *doorprop, bool allowclose); diff --git a/src/include/lib/anim.h b/src/include/lib/anim.h index 035552591..70f85b76f 100644 --- a/src/include/lib/anim.h +++ b/src/include/lib/anim.h @@ -6,8 +6,6 @@ void animsInit(void); void animsReset(void); -s32 animGetNumFrames(s16 anim_id); -bool animHasFrames(s16 animnum); s32 animGetNumAnimations(void); s32 anim0002384c(s16 animnum, s32 frame); bool anim000239e0(s16 animnum, s32 frame); @@ -19,4 +17,14 @@ u16 anim0002485c(s32 arg0, bool arg1, struct skeleton *skel, s16 animnum, s32 lo f32 anim00024b64(u32 arg0, u32 arg1, struct skeleton *skel, s16 animnum, u32 arg4, struct coord *coord, u32 arg6); f32 anim00024c14(s32 arg0, s16 animnum, u8 arg2); +static inline s32 animGetNumFrames(s16 animnum) +{ + return g_Anims[animnum].numframes; +} + +static inline bool animHasFrames(s16 animnum) +{ + return animnum < g_NumAnimations && g_Anims[animnum].numframes > 0; +} + #endif diff --git a/src/include/lib/audiomgr.h b/src/include/lib/audiomgr.h index 1a140dc94..0b8f57e0f 100644 --- a/src/include/lib/audiomgr.h +++ b/src/include/lib/audiomgr.h @@ -13,7 +13,6 @@ void amgrCreate(ALSynConfig *config); #endif void amgrStartThread(void); -OSMesgQueue *amgrGetFrameMesgQueue(void); void amgrStopThread(void); #endif diff --git a/src/include/lib/boot.h b/src/include/lib/boot.h index b25c6712f..2998f68e4 100644 --- a/src/include/lib/boot.h +++ b/src/include/lib/boot.h @@ -2,8 +2,9 @@ #define _IN_LIB_BOOT_H #include +extern u32 g_OsMemSize; + void bootPhase1(void); -s32 bootGetMemSize(void); void *bootAllocateStack(s32 threadid, s32 size); #endif diff --git a/src/include/lib/collision.h b/src/include/lib/collision.h index 38f42c8ea..e692f7cb6 100644 --- a/src/include/lib/collision.h +++ b/src/include/lib/collision.h @@ -4,13 +4,16 @@ #include "data.h" #include "types.h" -f32 cd00024e40(void); -void cdGetEdge(struct coord *pos1, struct coord *pos2); -f32 cd00024e98(void); -s32 cd00024ea4(void); -struct prop *cdGetObstacleProp(void); -void cdGetPos(struct coord *pos); -void cdGetObstacleNormal(struct coord *normal); +extern s32 g_Cd8009a8ac; +extern f32 g_Cd8009a8b0; +extern f32 g_Cd8009a8f0; +extern struct coord g_CdEdgeVtx1; +extern struct coord g_CdEdgeVtx2; +extern struct prop *g_CdObstacleProp; +extern struct coord g_CdObstaclePos; +extern struct geo *g_CdObstacleGeo; + +void cdGetGeoNormal(struct geo *geo, struct coord *normal); u32 cdGetGeoFlags(void); void cdSetSavedPos(struct coord *pos1, struct coord *pos2); bool cdGetSavedPos(struct coord *arg0, struct coord *arg1); diff --git a/src/include/lib/main.h b/src/include/lib/main.h index 8a46aaa99..9e9688133 100644 --- a/src/include/lib/main.h +++ b/src/include/lib/main.h @@ -5,12 +5,12 @@ #include "types.h" extern s32 var8005dd18; +extern s32 g_StageNum; void mainProc(void); void mainEndStage(void); void mainChangeToStage(s32 stagenum); void func0000e990(void); void func0000e9c0(void); -s32 mainGetStageNum(void); #endif diff --git a/src/include/lib/model.h b/src/include/lib/model.h index 629c6f903..1797d72ab 100644 --- a/src/include/lib/model.h +++ b/src/include/lib/model.h @@ -7,10 +7,9 @@ extern bool (*var8005efc4)(struct model *model, struct modelnode *node); extern struct gfxvtx *(*g_ModelVtxAllocatorFunc)(s32 numvertices); extern void (*g_ModelJointPositionedFunc)(s32 mtxindex, Mtxf *mtx); +extern bool var8005efdc; bool model00018680(struct modelrenderdata *renderdata, struct model *model); -void modelSetDistanceScale(f32 value); -void modelSetVtxAllocatorFunc(struct gfxvtx *(*fn)(s32 numvertices)); s32 model0001a524(struct modelnode *node, s32 arg1); Mtxf *model0001a5cc(struct model *model, struct modelnode *node, s32 arg2); Mtxf *model0001a60c(struct model *model); @@ -29,7 +28,6 @@ void modelSetRootPosition(struct model *model, struct coord *pos); void modelNodeGetModelRelativePosition(struct model *model, struct modelnode *node, struct coord *pos); f32 model0001ae44(struct model *model); void model0001ae90(struct model *model, f32 angle); -void modelSetScale(struct model *model, f32 scale); void modelSetAnimScale(struct model *model, f32 scale); f32 model0001af80(struct model *model); f32 model0001afe8(f32 arg0, f32 angle, f32 frac); @@ -60,8 +58,6 @@ void modelSetAnimSpeedAuto(struct model *model, f32 arg1, f32 startframe); void modelSetAnimPlaySpeed(struct model *model, f32 speed, f32 frame); void modelSetAnim70(struct model *model, void *callback); void model0001e018(struct model *model, f32 startframe); -void model0001e29c(bool value); -bool model0001e2a8(void); void model0001ee18(struct model *model, s32 lvupdate240, bool arg2); void model0001f314(struct model *model, s32 lvupdate240, bool arg2); void modelRender(struct modelrenderdata *renderdata, struct model *model); diff --git a/src/include/lib/mp3.h b/src/include/lib/mp3.h index fef024488..86ccb05f8 100644 --- a/src/include/lib/mp3.h +++ b/src/include/lib/mp3.h @@ -6,7 +6,6 @@ void mp3Init(ALHeap *heap); void mp3PlayFile(s32 romaddr, s32 filesize); -void func00037e1c(void); void func00037e38(void); void func00037e68(void); s32 func00037ea4(void); diff --git a/src/include/lib/mtx.h b/src/include/lib/mtx.h index 1f970e9b3..fd8715401 100644 --- a/src/include/lib/mtx.h +++ b/src/include/lib/mtx.h @@ -41,9 +41,7 @@ void mtx4GetRotation(f32 mtx[4][4], struct coord *dst); void mtx4LoadRotationAndTranslation(struct coord *pos, struct coord *rot, Mtxf *mtx); void mtx4LoadTranslation(struct coord *pos, Mtxf *mtx); void mtx00016710(f32 mult, f32 mtx[4][4]); -void mtx00016748(f32 arg0); void mtx00016760(void); -void mtx00016784(void); void mtx00016798(Mtxf *src, Mtxf *dst); void mtx00016820(Mtx *src, Mtx *dst); void mtx00016874(Mtxf *mtx, f32 posx, f32 posy, f32 posz, f32 lookx, f32 looky, f32 lookz, f32 upx, f32 upy, f32 upz); diff --git a/src/include/lib/snd.h b/src/include/lib/snd.h index de0c4469a..c6945825b 100644 --- a/src/include/lib/snd.h +++ b/src/include/lib/snd.h @@ -4,8 +4,22 @@ #include "data.h" #include "types.h" +struct curmp3 { + union soundnumhack sfxref; + u32 playing; + u32 unk08; + s32 responsetimer240; + s32 prevwhisper; + s32 prevacknowledge; + s32 prevgreeting; + u32 romaddr; + u32 romsize; + s32 responsetype; +}; + +extern struct curmp3 g_SndCurMp3; + bool sndIsFiltered(s32 audioid); -bool sndIsPlayingMp3(void); void sndSetSfxVolume(u16 volume); void sndResetCurMp3(void); void sndSetSoundMode(s32 mode); diff --git a/src/include/lib/vi.h b/src/include/lib/vi.h index 45bdbd2a3..bcc63e1cb 100644 --- a/src/include/lib/vi.h +++ b/src/include/lib/vi.h @@ -4,6 +4,11 @@ #include "data.h" #include "types.h" +extern struct rend_vidat *g_ViFrontData; +extern struct rend_vidat *g_ViBackData; +extern u8 g_ViBackIndex; +extern u16 g_ViPerspScale; + void viConfigureForLogos(void); void viConfigureForCopyright(u16 *fb); void viConfigureForLegal(void); @@ -14,10 +19,6 @@ void viUpdateMode(void); void viShake(f32 intensity); void viSetMode(s32 mode); void viSet16Bit(void); -u16 *viGetBackBuffer(void); -u16 *viGetFrontBuffer(void); -Vp *viGetCurrentPlayerViewport(void); -u16 viGetPerspScale(void); Gfx *vi0000ab78(Gfx *gdl); Gfx *vi0000aca4(Gfx *gdl, f32 znear, f32 zfar); Gfx *vi0000af00(Gfx *gdl, Vp *vp); @@ -28,23 +29,12 @@ Gfx *vi0000b280(Gfx *gdl); Gfx *viFillBuffer(Gfx *gdl); Gfx *viRenderViewportEdges(Gfx *gdl); void viSetBufSize(s16 width, s16 height); -s16 viGetBufWidth(void); -s16 viGetBufHeight(void); void viSetSize(s16 width, s16 height); -s16 viGetWidth(void); -s16 viGetHeight(void); void viSetViewSize(s16 width, s16 height); -s16 viGetViewWidth(void); -s16 viGetViewHeight(void); void viSetViewPosition(s16 left, s16 top); -s16 viGetViewLeft(void); -s16 viGetViewTop(void); -void viSetUseZBuf(bool use); void viSetFovY(f32 fovy); void viSetAspect(f32 aspect); -f32 viGetAspect(void); void viSetFovAspectAndSize(f32 fovy, f32 aspect, s16 width, s16 height); -f32 viGetFovY(void); void viSetZRange(f32 arg0, f32 arg1); void viGetZRange(struct zrange *zrange); Gfx *viSetFillColour(Gfx *gdl, s32 r, s32 g, s32 b); diff --git a/src/lib/anim.c b/src/lib/anim.c index 54763803e..4cdda80d9 100644 --- a/src/lib/anim.c +++ b/src/lib/anim.c @@ -106,16 +106,6 @@ void animsReset(void) g_AnimHostEnabled = false; } -s32 animGetNumFrames(s16 animnum) -{ - return g_Anims[animnum].numframes; -} - -bool animHasFrames(s16 animnum) -{ - return animnum < g_NumAnimations && g_Anims[animnum].numframes > 0; -} - extern u8 _animationsSegmentRomStart; static u8 *animDma(u8 *dst, u32 segoffset, u32 len) diff --git a/src/lib/audiomgr.c b/src/lib/audiomgr.c index 478efd9e4..9dcd82386 100644 --- a/src/lib/audiomgr.c +++ b/src/lib/audiomgr.c @@ -111,11 +111,6 @@ void amgrStartThread(void) g_AudioIsThreadRunning = true; } -OSMesgQueue *amgrGetFrameMesgQueue(void) -{ - return &g_AudioManager.audioFrameMsgQ; -} - /** * This doesn't set g_AudioIsThreadRunning to false, but that's okay because * this is only called when resetting the console, and when that happens the diff --git a/src/lib/boot.c b/src/lib/boot.c index 1a9f1f2c8..4c5b72bd5 100644 --- a/src/lib/boot.c +++ b/src/lib/boot.c @@ -37,11 +37,6 @@ extern u8 *_inflateSegmentRomEnd; static void bootPhase2(void *arg); -s32 bootGetMemSize(void) -{ - return g_OsMemSize; -} - u32 __osGetFpcCsr(void); u32 __osSetFpcCsr(u32 arg0); diff --git a/src/lib/collision.c b/src/lib/collision.c index 7ee3d149b..94e8da53b 100644 --- a/src/lib/collision.c +++ b/src/lib/collision.c @@ -18,7 +18,6 @@ #define SURFACE_FLOOR 0 #define SURFACE_CEILING 1 -static void cdGetGeoNormal(struct geo *geo, struct coord *normal); static void cdGetFloorCol(struct geo *geo, u16 *floorcol); static void cdGetFloorType(struct geo *geo, u8 *floortype); static s32 cdTestRampWall(struct geotilei *tile, struct coord *pos, f32 width, f32 y1, f32 y2); @@ -31,13 +30,13 @@ struct debugtri { union filedataptr g_TileFileData; s32 g_TileNumRooms; u32 *g_TileRooms; -s32 var8009a8ac; -f32 var8009a8b0; +s32 g_Cd8009a8ac; +f32 g_Cd8009a8b0; struct coord g_CdEdgeVtx1; struct coord g_CdEdgeVtx2; struct prop *g_CdObstacleProp; struct coord g_CdObstaclePos; -f32 var8009a8f0; +f32 g_Cd8009a8f0; bool g_CdHasSavedPos; struct coord g_CdPos1; struct coord g_CdPos2; @@ -212,43 +211,6 @@ handlezero: return (f32) sp60 * (1.0f / spac); } -f32 cd00024e40(void) -{ - return var8009a8f0; -} - -void cdGetEdge(struct coord *vtx1, struct coord *vtx2) -{ - *vtx1 = g_CdEdgeVtx1; - - *vtx2 = g_CdEdgeVtx2; -} - -f32 cd00024e98(void) -{ - return var8009a8b0; -} - -s32 cd00024ea4(void) -{ - return var8009a8ac; -} - -struct prop *cdGetObstacleProp(void) -{ - return g_CdObstacleProp; -} - -void cdGetPos(struct coord *pos) -{ - *pos = g_CdObstaclePos; -} - -void cdGetObstacleNormal(struct coord *normal) -{ - cdGetGeoNormal(g_CdObstacleGeo, normal); -} - u32 cdGetGeoFlags(void) { u32 flags = 0; @@ -273,7 +235,7 @@ u32 cdGetGeoFlags(void) static void cdClearResults(void) { - var8009a8ac = 0; + g_Cd8009a8ac = 0; g_CdObstacleProp = NULL; g_CdHasSavedPos = false; g_CdHasSavedBlock = false; @@ -285,7 +247,7 @@ static void cdSetObstacleVtxProp(struct coord *vtx1, struct coord *vtx2, struct g_CdEdgeVtx2 = *vtx2; - var8009a8ac = 0; + g_Cd8009a8ac = 0; g_CdObstacleProp = prop; g_CdHasSavedPos = false; g_CdHasSavedBlock = false; @@ -293,13 +255,13 @@ static void cdSetObstacleVtxProp(struct coord *vtx1, struct coord *vtx2, struct static void cdSetObstacleVtxPropFlt(struct coord *vtx1, struct coord *vtx2, struct prop *prop, f32 arg3) { - var8009a8b0 = arg3; + g_Cd8009a8b0 = arg3; g_CdEdgeVtx1 = *vtx1; g_CdEdgeVtx2 = *vtx2; - var8009a8ac = 1; + g_Cd8009a8ac = 1; g_CdObstacleProp = prop; g_CdHasSavedPos = false; g_CdHasSavedBlock = false; @@ -325,13 +287,13 @@ static void cd000250cc(struct coord *arg0, struct coord *arg1, f32 width) sp24.x = g_CdEdgeVtx2.x; sp24.z = g_CdEdgeVtx2.z; - var8009a8b0 = func0f1579cc(&sp34, &sp2c, &sp24, &sp1c); - var8009a8ac = 1; + g_Cd8009a8b0 = func0f1579cc(&sp34, &sp2c, &sp24, &sp1c); + g_Cd8009a8ac = 1; } static void cdSetObstacleProp(struct prop *prop) { - var8009a8ac = 0; + g_Cd8009a8ac = 0; g_CdObstacleProp = prop; g_CdHasSavedPos = false; g_CdHasSavedBlock = false; @@ -345,7 +307,7 @@ static void cdSetObstacleVtxColProp(struct coord *vtxpos1, struct coord *vtxpos2 g_CdObstaclePos = *collisionpos; - var8009a8ac = 0; + g_Cd8009a8ac = 0; g_CdObstacleProp = prop; g_CdHasSavedPos = false; g_CdHasSavedBlock = false; @@ -354,14 +316,11 @@ static void cdSetObstacleVtxColProp(struct coord *vtxpos1, struct coord *vtxpos2 static void cdSetObstacleVtxColPropFltGeo(struct coord *vtxpos1, struct coord *vtxpos2, struct coord *collisionpos, struct prop *prop, f32 arg4, struct geo *geo) { g_CdEdgeVtx1 = *vtxpos1; - g_CdEdgeVtx2 = *vtxpos2; - g_CdObstaclePos = *collisionpos; - - var8009a8ac = 0; + g_Cd8009a8ac = 0; g_CdObstacleProp = prop; - var8009a8f0 = arg4; + g_Cd8009a8f0 = arg4; g_CdHasSavedPos = false; g_CdHasSavedBlock = false; g_CdObstacleGeo = geo; @@ -370,7 +329,6 @@ static void cdSetObstacleVtxColPropFltGeo(struct coord *vtxpos1, struct coord *v void cdSetSavedPos(struct coord *pos1, struct coord *pos2) { g_CdPos1 = *pos1; - g_CdPos2 = *pos2; g_CdHasSavedPos = true; @@ -380,7 +338,6 @@ bool cdGetSavedPos(struct coord *pos1, struct coord *pos2) { if (g_CdHasSavedPos) { *pos1 = g_CdPos1; - *pos2 = g_CdPos2; } @@ -520,7 +477,7 @@ static void cd00025848(f32 tilex, f32 tilez, f32 tilewidth, f32 posx, f32 posz, *z2 = tilez + posz + posx; } -static void cdGetGeoNormal(struct geo *geo, struct coord *normal) +void cdGetGeoNormal(struct geo *geo, struct coord *normal) { if (geo->type == GEOTYPE_TILE_I) { struct geotilei *tile = (struct geotilei *) geo; diff --git a/src/lib/lib_04f60nb.c b/src/lib/lib_04f60nb.c deleted file mode 100644 index 60c71d291..000000000 --- a/src/lib/lib_04f60nb.c +++ /dev/null @@ -1,7 +0,0 @@ -#include -#include "lib/mtx.h" - -void func00004f60nb(u32 arg0, u32 arg1, u32 arg2, u32 arg3) -{ - u32 foo; -} diff --git a/src/lib/main.c b/src/lib/main.c index a4f6239fa..3b61e2775 100644 --- a/src/lib/main.c +++ b/src/lib/main.c @@ -200,26 +200,7 @@ static void mainInit(void) s32 numpages; u8 scratch[1024 * 5 - 8]; - // Choose where to place the temporary framebuffer. - // In 4MB mode, place it close to the end of memory, - // but before the thread stacks and VM system. - // In 8MB mode, put it at the end of the expansion pak. - if (bootGetMemSize() <= 4 * 1024 * 1024) { - addr = K0BASE + 4 * 1024 * 1024; - addr -= STACKSIZE_MAIN; - addr -= STACKSIZE_IDLE; - addr -= STACKSIZE_RMON; - addr -= STACKSIZE_SCHED; - addr -= STACKSIZE_AUDIO; - addr -= 8; // markers for stack overflow detection - addr -= g_VmNumPages * 8; // vm state table - addr -= 268 * 4096; // vm loaded pages buffer - addr -= addr % 0x2000; // align down to a multiple of 0x2000 - addr -= 0x1c80; // buffer for single biggest game zip - } else { - addr = K0BASE + 8 * 1024 * 1024; - } - + addr = K0BASE + 8 * 1024 * 1024; addr -= 640 * 480 * 2; // the framebuffer itself addr -= 0x40; // align down to a multiple of 0x40 @@ -608,11 +589,6 @@ void mainChangeToStage(s32 stagenum) g_MainChangeToStageNum = stagenum; } -s32 mainGetStageNum(void) -{ - return g_StageNum; -} - void func0000e990(void) { objectivesCheckAll(); diff --git a/src/lib/memp.c b/src/lib/memp.c index e3e0f76f8..ac3b9aa3a 100644 --- a/src/lib/memp.c +++ b/src/lib/memp.c @@ -84,7 +84,7 @@ void mempSetHeap(u8 *heapstart, u32 heaplen) g_MempOnboardPools[MEMPOOL_STAGE].rightpos = heapstart + heaplen; // If 8MB, reserve the entire expansion pak for the stage pool - extraend = (u8 *) K0BASE + bootGetMemSize() - FRAMEBUFFER_SIZE; + extraend = (u8 *) K0BASE + g_OsMemSize - FRAMEBUFFER_SIZE; g_MempExpansionPools[MEMPOOL_STAGE].start = (u8 *) K0BASE + 4 * 1024 * 1024 + FRAMEBUFFER_SIZE; g_MempExpansionPools[MEMPOOL_STAGE].rightpos = extraend; diff --git a/src/lib/model.c b/src/lib/model.c index dce6d461d..dccc5b3e2 100644 --- a/src/lib/model.c +++ b/src/lib/model.c @@ -27,16 +27,6 @@ bool (*var8005efc4)(struct model *model, struct modelnode *node) = NULL; struct gfxvtx *(*g_ModelVtxAllocatorFunc)(s32 numvertices) = NULL; void (*g_ModelJointPositionedFunc)(s32 mtxindex, Mtxf *mtx) = NULL; -void modelSetDistanceScale(f32 scale) -{ - g_ModelDistanceScale = scale; -} - -void modelSetVtxAllocatorFunc(struct gfxvtx *(*fn)(s32 numvertices)) -{ - g_ModelVtxAllocatorFunc = fn; -} - s32 model0001a524(struct modelnode *node, s32 arg1) { s32 index; @@ -472,11 +462,6 @@ void model0001ae90(struct model *model, f32 angle) } } -void modelSetScale(struct model *model, f32 scale) -{ - model->scale = scale; -} - void modelSetAnimScale(struct model *model, f32 scale) { if (model->anim) { @@ -1104,7 +1089,7 @@ static void model0001c664(struct model *model, struct modelnode *node) if (g_ModelDistanceDisabled || !mtx) { distance = 0; } else { - distance = -mtx->m[3][2] * camGetLodScaleZ(); + distance = -mtx->m[3][2] * g_Vars.currentplayer->c_lodscalez; if (g_ModelDistanceScale != 1) { distance *= g_ModelDistanceScale; @@ -1987,16 +1972,6 @@ static void model0001e14c(struct model *model, f32 arg1, f32 arg2) bool var8005efdc = true; -void model0001e29c(bool value) -{ - var8005efdc = value; -} - -bool model0001e2a8(void) -{ - return var8005efdc; -} - static void model0001e2b4(struct model *model, f32 curframe, f32 endframe, f32 curframe2, f32 endframe2) { struct anim *anim = model->anim; diff --git a/src/lib/mp3.c b/src/lib/mp3.c index 442a40116..81e19420d 100644 --- a/src/lib/mp3.c +++ b/src/lib/mp3.c @@ -92,11 +92,6 @@ void mp3PlayFile(s32 romaddr, s32 filesize) g_Mp3Vars.var8009c3e0 = 4; } -void func00037e1c(void) -{ - g_Mp3Vars.var8009c3e0 = 3; -} - void func00037e38(void) { if (g_Mp3Vars.var8009c3e0 == 1) { diff --git a/src/lib/mtx.c b/src/lib/mtx.c index 74fde5dd1..4f14d9501 100644 --- a/src/lib/mtx.c +++ b/src/lib/mtx.c @@ -232,22 +232,12 @@ void mtx00016710(f32 mult, f32 mtx[4][4]) mtx[3][2] *= mult; } -void mtx00016748(f32 arg0) -{ - var8005ef10[0] = 65536 * arg0; -} - void mtx00016760(void) { g_Vars.unk000510 = var8005ef10[0]; var8005ef10[0] = 65536; } -void mtx00016784(void) -{ - var8005ef10[0] = g_Vars.unk000510; -} - /** * src is passed as an Mtxf but it's read as words rather than floats. * It might be an Mtx rather than Mtxf. diff --git a/src/lib/profile.c b/src/lib/profile.c index dc075e53f..0d9da8296 100644 --- a/src/lib/profile.c +++ b/src/lib/profile.c @@ -217,19 +217,19 @@ Gfx *profileRenderCpuLine(Gfx *gdl, s32 x, s32 *y, char *label, s32 marker) } x2 = x; - gdl = textRender(gdl, &x2, y, label, g_CharsHandelGothicXs, g_FontHandelGothicXs, colour, 0x000000a0, viGetWidth(), viGetHeight(), 0, 0); + gdl = textRender(gdl, &x2, y, label, g_CharsHandelGothicXs, g_FontHandelGothicXs, colour, 0x000000a0, g_ViBackData->x, g_ViBackData->y, 0, 0); sprintf(buffer, "%d", microseconds); textMeasure(&textheight, &textwidth, buffer, g_CharsHandelGothicXs, g_FontHandelGothicXs, 0); x2 = x + 100 - textwidth; - gdl = textRender(gdl, &x2, y, buffer, g_CharsHandelGothicXs, g_FontHandelGothicXs, colour, 0x000000a0, viGetWidth(), viGetHeight(), 0, 0); + gdl = textRender(gdl, &x2, y, buffer, g_CharsHandelGothicXs, g_FontHandelGothicXs, colour, 0x000000a0, g_ViBackData->x, g_ViBackData->y, 0, 0); sprintf(buffer, "%d%%\n", percent); textMeasure(&textheight, &textwidth, buffer, g_CharsHandelGothicXs, g_FontHandelGothicXs, 0); x2 = x + 130 - textwidth; - gdl = textRender(gdl, &x2, y, buffer, g_CharsHandelGothicXs, g_FontHandelGothicXs, colour, 0x000000a0, viGetWidth(), viGetHeight(), 0, 0); + gdl = textRender(gdl, &x2, y, buffer, g_CharsHandelGothicXs, g_FontHandelGothicXs, colour, 0x000000a0, g_ViBackData->x, g_ViBackData->y, 0, 0); return gdl; } @@ -316,21 +316,21 @@ Gfx *profileRenderDynamicSlot(Gfx *gdl, s32 x, s32 *y, s32 index) if (slot->recursion) { sprintf(buffer, "%s:%d *RECURSION*\n", slot->file, slot->line); - gdl = textRender(gdl, &x2, y, buffer, g_CharsHandelGothicXs, g_FontHandelGothicXs, 0x00ff00a0, 0x000000a0, viGetWidth(), viGetHeight(), 0, 0); + gdl = textRender(gdl, &x2, y, buffer, g_CharsHandelGothicXs, g_FontHandelGothicXs, 0x00ff00a0, 0x000000a0, g_ViBackData->x, g_ViBackData->y, 0, 0); } else { // Render this slot sprintf(buffer, "%s:%d", slot->file, slot->line); - gdl = textRender(gdl, &x2, y, buffer, g_CharsHandelGothicXs, g_FontHandelGothicXs, 0x00ff00a0, 0x000000a0, viGetWidth(), viGetHeight(), 0, 0); + gdl = textRender(gdl, &x2, y, buffer, g_CharsHandelGothicXs, g_FontHandelGothicXs, 0x00ff00a0, 0x000000a0, g_ViBackData->x, g_ViBackData->y, 0, 0); sprintf(buffer, "%dus", (u32) OS_CYCLES_TO_USEC(slot->ticks)); textMeasure(&textheight, &textwidth, buffer, g_CharsHandelGothicXs, g_FontHandelGothicXs, 0); x2 = 160 - textwidth; - gdl = textRender(gdl, &x2, y, buffer, g_CharsHandelGothicXs, g_FontHandelGothicXs, 0x00ff00a0, 0x000000a0, viGetWidth(), viGetHeight(), 0, 0); + gdl = textRender(gdl, &x2, y, buffer, g_CharsHandelGothicXs, g_FontHandelGothicXs, 0x00ff00a0, 0x000000a0, g_ViBackData->x, g_ViBackData->y, 0, 0); sprintf(buffer, "%d\n", slot->numiterations); x2 = 170; - gdl = textRender(gdl, &x2, y, buffer, g_CharsHandelGothicXs, g_FontHandelGothicXs, 0x00ff00a0, 0x000000a0, viGetWidth(), viGetHeight(), 0, 0); + gdl = textRender(gdl, &x2, y, buffer, g_CharsHandelGothicXs, g_FontHandelGothicXs, 0x00ff00a0, 0x000000a0, g_ViBackData->x, g_ViBackData->y, 0, 0); // Render child slots for (i = 0; i < ARRAYCOUNT(g_ProfileSlots); i++) { @@ -343,13 +343,13 @@ Gfx *profileRenderDynamicSlot(Gfx *gdl, s32 x, s32 *y, s32 index) // Render child "other" slot if (childticks > 0) { x2 = x + 5; - gdl = textRender(gdl, &x2, y, "other", g_CharsHandelGothicXs, g_FontHandelGothicXs, 0x00ff00a0, 0x000000a0, viGetWidth(), viGetHeight(), 0, 0); + gdl = textRender(gdl, &x2, y, "other", g_CharsHandelGothicXs, g_FontHandelGothicXs, 0x00ff00a0, 0x000000a0, g_ViBackData->x, g_ViBackData->y, 0, 0); sprintf(buffer, "%dus\n", (u32) OS_CYCLES_TO_USEC(slot->ticks - childticks)); textMeasure(&textheight, &textwidth, buffer, g_CharsHandelGothicXs, g_FontHandelGothicXs, 0); x2 = 160 - textwidth; - gdl = textRender(gdl, &x2, y, buffer, g_CharsHandelGothicXs, g_FontHandelGothicXs, 0x00ff00a0, 0x000000a0, viGetWidth(), viGetHeight(), 0, 0); + gdl = textRender(gdl, &x2, y, buffer, g_CharsHandelGothicXs, g_FontHandelGothicXs, 0x00ff00a0, 0x000000a0, g_ViBackData->x, g_ViBackData->y, 0, 0); } } diff --git a/src/lib/sched.c b/src/lib/sched.c index 57c15a840..04140caea 100644 --- a/src/lib/sched.c +++ b/src/lib/sched.c @@ -175,7 +175,7 @@ static void __scHandleRetrace(OSSched *sc) */ if (sc->alt && !g_Resetting) { osStopTimer(&g_SchedRspTimer); - osSetTimer(&g_SchedRspTimer, 280000, 0, amgrGetFrameMesgQueue(), (OSMesg) OS_SC_RSP_MSG); + osSetTimer(&g_SchedRspTimer, 280000, 0, &g_AudioManager.audioFrameMsgQ, (OSMesg) OS_SC_RSP_MSG); if (sc->nextAudTask && sc->curRSPTask->list.t.type == M_GFXTASK) { osSpTaskYield(); diff --git a/src/lib/snd.c b/src/lib/snd.c index fc6850db9..1c32329ac 100644 --- a/src/lib/snd.c +++ b/src/lib/snd.c @@ -20,18 +20,7 @@ #include "data.h" #include "types.h" -struct curmp3 { - union soundnumhack sfxref; - u32 playing; - u32 unk08; - s32 responsetimer240; - s32 prevwhisper; - s32 prevacknowledge; - s32 prevgreeting; - u32 romaddr; - u32 romsize; - s32 responsetype; -}; +extern struct mp3vars g_Mp3Vars; s32 g_NumSounds; u32 *g_ALSoundRomOffsets; @@ -780,11 +769,6 @@ static u16 seqGetVolume(struct seqinstance *seq); static void sndTickNosedive(void); static void sndTickUfo(void); -bool sndIsPlayingMp3(void) -{ - return g_SndCurMp3.playing; -} - static u16 snd0000e9dc(void) { s32 result; @@ -1369,7 +1353,7 @@ bool snd0000fbc4(s16 arg0) return false; } - func00037e1c(); + g_Mp3Vars.var8009c3e0 = 3; g_SndCurMp3.playing = false; g_SndCurMp3.responsetimer240 = -1; @@ -1908,7 +1892,7 @@ static void sndTickNosedive(void) if (percentage < 1.0f) { // less than 100% complete percentage += 0.44f; - if (lvIsPaused()) { + if (g_LvIsPaused) { // Fade out volume during pause instead of stopping abruptly if (g_SndNosediveVolume > 0) { g_SndNosediveVolume -= g_Vars.diffframe240 * PALUP(80); @@ -1992,7 +1976,7 @@ static void sndTickUfo(void) percentage = (percentage - 0.65f) / 0.35f * 0.8f + 1.0f; } - if (lvIsPaused()) { + if (g_LvIsPaused) { // Fade out volume during pause instead of stopping abruptly if (g_SndUfoVolume > 0) { g_SndUfoVolume -= g_Vars.diffframe240 * PALUP(120); diff --git a/src/lib/vi.c b/src/lib/vi.c index 243e7405e..0c8cae451 100644 --- a/src/lib/vi.c +++ b/src/lib/vi.c @@ -418,26 +418,6 @@ void viSetMode(s32 mode) g_ViBackData->y = g_ViBackData->bufy = g_ViModeHeights[mode]; } -u16 *viGetBackBuffer(void) -{ - return g_ViBackData->fb; -} - -u16 *viGetFrontBuffer(void) -{ - return g_ViFrontData->fb; -} - -Vp *viGetCurrentPlayerViewport(void) -{ - return &g_Vars.currentplayer->viewport[g_ViBackIndex]; -} - -u16 viGetPerspScale(void) -{ - return g_ViPerspScale; -} - Gfx *vi0000ab78(Gfx *gdl) { Mtxf sp110; @@ -449,7 +429,7 @@ Gfx *vi0000ab78(Gfx *gdl) u16 sp46; guPerspectiveF(sp110.m, &sp46, g_ViBackData->fovy, g_ViBackData->aspect, g_ViBackData->znear, g_ViBackData->zfar + g_ViBackData->zfar, 1); - mtx4Copy(camGetWorldToScreenMtxf(), &sp90); + mtx4Copy(g_Vars.currentplayer->worldtoscreenmtx, &sp90); sp90.m[3][0] = 0; sp90.m[3][1] = 0; @@ -502,8 +482,8 @@ static Gfx *vi0000ad5c(Gfx *gdl, Vp *vp) gSPMatrix(gdl++, OS_K0_TO_PHYSICAL(var80092870), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_PROJECTION); gSPPerspNormalize(gdl++, g_ViPerspScale); - camSetPerspectiveMtxL(var80092870); - camSetMtxF1754(&var80092830); + g_Vars.currentplayer->perspmtxl = var80092870; + g_Vars.currentplayer->mtxf1754 = &var80092830; return gdl; } @@ -531,8 +511,8 @@ Gfx *vi0000af00(Gfx *gdl, Vp *vp) gSPMatrix(gdl++, OS_K0_TO_PHYSICAL(var80092870), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_PROJECTION); gSPPerspNormalize(gdl++, g_ViPerspScale); - camSetPerspectiveMtxL(var80092870); - camSetMtxF1754(&var80092830); + g_Vars.currentplayer->perspmtxl = var80092870; + g_Vars.currentplayer->mtxf1754 = &var80092830; return gdl; } @@ -587,24 +567,24 @@ Gfx *viFillBuffer(Gfx *gdl) Gfx *viRenderViewportEdges(Gfx *gdl) { gDPSetCycleType(gdl++, G_CYC_FILL); - gDPSetScissor(gdl++, G_SC_NON_INTERLACE, 0, 0, viGetWidth(), viGetHeight()); + gDPSetScissor(gdl++, G_SC_NON_INTERLACE, 0, 0, g_ViBackData->x, g_ViBackData->y); gDPSetFillColor(gdl++, GPACK_RGBA5551(0, 0, 0, 1) << 16 | GPACK_RGBA5551(0, 0, 0, 1)); if (PLAYERCOUNT() == 1 || ((g_Vars.coopplayernum >= 0 || g_Vars.antiplayernum >= 0) && playerHasSharedViewport() && g_Vars.currentplayernum == 0)) { // Single viewport - if (viGetViewTop() > 0) { + if (g_ViBackData->viewtop > 0) { // Fill above - gDPFillRectangle(gdl++, 0, 0, viGetWidth() - 1, viGetViewTop() - 1); + gDPFillRectangle(gdl++, 0, 0, g_ViBackData->x - 1, g_ViBackData->viewtop - 1); gDPPipeSync(gdl++); } - if (viGetViewTop() + viGetViewHeight() < viGetHeight()) { + if (g_ViBackData->viewtop + g_ViBackData->viewy < g_ViBackData->y) { // Fill below gDPFillRectangle(gdl++, - 0, viGetViewTop() + viGetViewHeight(), - viGetWidth() - 1, viGetHeight() - 1); + 0, g_ViBackData->viewtop + g_ViBackData->viewy, + g_ViBackData->x - 1, g_ViBackData->y - 1); gDPPipeSync(gdl++); } } else { @@ -623,26 +603,26 @@ Gfx *viRenderViewportEdges(Gfx *gdl) if (g_Vars.players[topplayernum]->viewtop > 0) { // Fill above all viewports - full width - gDPFillRectangle(gdl++, 0, 0, viGetWidth() - 1, g_Vars.players[topplayernum]->viewtop - 1); + gDPFillRectangle(gdl++, 0, 0, g_ViBackData->x - 1, g_Vars.players[topplayernum]->viewtop - 1); gDPPipeSync(gdl++); } - if (g_Vars.players[bottomplayernum]->viewtop + g_Vars.players[bottomplayernum]->viewheight < viGetHeight()) { + if (g_Vars.players[bottomplayernum]->viewtop + g_Vars.players[bottomplayernum]->viewheight < g_ViBackData->y) { // Fill below all viewports - full width gDPFillRectangle(gdl++, 0, g_Vars.players[bottomplayernum]->viewtop + g_Vars.players[bottomplayernum]->viewheight, - viGetWidth() - 1, viGetHeight() - 1); + g_ViBackData->x - 1, g_ViBackData->y - 1); gDPPipeSync(gdl++); } // Horizontal middle line gDPFillRectangle(gdl++, 0, g_Vars.players[tmpplayernum]->viewtop - 1, - viGetWidth() - 1, g_Vars.players[tmpplayernum]->viewtop - 1); + g_ViBackData->x - 1, g_Vars.players[tmpplayernum]->viewtop - 1); gDPPipeSync(gdl++); if (PLAYERCOUNT() >= 3 || - (PLAYERCOUNT() == 2 && optionsGetScreenSplit() == SCREENSPLIT_VERTICAL)) { + (PLAYERCOUNT() == 2 && g_ScreenSplit == SCREENSPLIT_VERTICAL)) { if (PLAYERCOUNT() == 2) { tmpplayernum = 0; } @@ -650,7 +630,7 @@ Gfx *viRenderViewportEdges(Gfx *gdl) // Vertical middle line gDPFillRectangle(gdl++, g_Vars.players[tmpplayernum]->viewleft + g_Vars.players[tmpplayernum]->viewwidth, 0, - g_Vars.players[tmpplayernum]->viewleft + g_Vars.players[tmpplayernum]->viewwidth, viGetHeight() - 1); + g_Vars.players[tmpplayernum]->viewleft + g_Vars.players[tmpplayernum]->viewwidth, g_ViBackData->y - 1); gDPPipeSync(gdl++); } @@ -658,7 +638,7 @@ Gfx *viRenderViewportEdges(Gfx *gdl) // Blank square in P4 spot gDPFillRectangle(gdl++, g_Vars.players[tmpplayernum]->viewleft + g_Vars.players[tmpplayernum]->viewwidth + 1, g_Vars.players[tmpplayernum]->viewtop, - viGetWidth() - 1, viGetHeight() - 1); + g_ViBackData->x - 1, g_ViBackData->y - 1); gDPPipeSync(gdl++); } } @@ -667,38 +647,45 @@ Gfx *viRenderViewportEdges(Gfx *gdl) return gdl; } +static void camSetScreenSize(f32 width, f32 height) +{ + struct player *player = g_Vars.currentplayer; + + player->c_screenwidth = width; + player->c_screenheight = height; + player->c_halfwidth = width * 0.5f; + player->c_halfheight = height * 0.5f; +} + +static void camSetScreenPosition(f32 left, f32 top) +{ + struct player *player = g_Vars.currentplayer; + + player->c_screenleft = left; + player->c_screentop = top; +} + +static void camSetPerspective(f32 near, f32 fovy, f32 aspect) +{ + struct player *player = g_Vars.currentplayer; + + player->c_perspnear = near; + player->c_perspfovy = fovy; + player->c_perspaspect = aspect; +} + void viSetBufSize(s16 width, s16 height) { g_ViBackData->bufx = width; g_ViBackData->bufy = height; } -s16 viGetBufWidth(void) -{ - return g_ViBackData->bufx; -} - -s16 viGetBufHeight(void) -{ - return g_ViBackData->bufy; -} - void viSetSize(s16 width, s16 height) { g_ViBackData->x = width; g_ViBackData->y = height; } -s16 viGetWidth(void) -{ - return g_ViBackData->x; -} - -s16 viGetHeight(void) -{ - return g_ViBackData->y; -} - void viSetViewSize(s16 width, s16 height) { g_ViBackData->viewx = width; @@ -708,16 +695,6 @@ void viSetViewSize(s16 width, s16 height) camSetScale(); } -s16 viGetViewWidth(void) -{ - return g_ViBackData->viewx; -} - -s16 viGetViewHeight(void) -{ - return g_ViBackData->viewy; -} - void viSetViewPosition(s16 left, s16 top) { g_ViBackData->viewleft = left; @@ -726,21 +703,6 @@ void viSetViewPosition(s16 left, s16 top) camSetScreenPosition(g_ViBackData->viewleft, g_ViBackData->viewtop); } -s16 viGetViewLeft(void) -{ - return g_ViBackData->viewleft; -} - -s16 viGetViewTop(void) -{ - return g_ViBackData->viewtop; -} - -void viSetUseZBuf(bool use) -{ - g_ViBackData->usezbuf = use; -} - void viSetFovY(f32 fovy) { g_ViBackData->fovy = fovy; @@ -757,11 +719,6 @@ void viSetAspect(f32 aspect) camSetScale(); } -f32 viGetAspect(void) -{ - return g_ViBackData->aspect; -} - void viSetFovAspectAndSize(f32 fovy, f32 aspect, s16 width, s16 height) { g_ViBackData->fovy = fovy; @@ -774,11 +731,6 @@ void viSetFovAspectAndSize(f32 fovy, f32 aspect, s16 width, s16 height) camSetScale(); } -f32 viGetFovY(void) -{ - return g_ViBackData->fovy; -} - void viSetZRange(f32 near, f32 far) { g_ViBackData->znear = near; diff --git a/src/lib/vm.c b/src/lib/vm.c index ca2fc0ffa..95c8327c6 100644 --- a/src/lib/vm.c +++ b/src/lib/vm.c @@ -165,37 +165,32 @@ void vmInit(void) rzipInit(); - if (bootGetMemSize() <= 0x400000) { - while (1); - } else { - // Expansion pak is being used - t8 = (u32)((&_gameSegmentEnd - &_gameSegmentStart) + (PAGE_SIZE - 1)) / PAGE_SIZE; - s7 = (u8 *)(STACK_START - 8); + t8 = (u32)((&_gameSegmentEnd - &_gameSegmentStart) + (PAGE_SIZE - 1)) / PAGE_SIZE; + s7 = (u8 *)(STACK_START - 8); - // 0x803c0000 - (_gameSegmentLen aligned to 0x20000) - gameseg = (u8 *) &_gameSegmentStart; + // 0x803c0000 - (_gameSegmentLen aligned to 0x20000) + gameseg = (u8 *) &_gameSegmentStart; - s5 = (u32 *) 0x80600000; - g_VmMarker = (u8 *) s7; - sp1474 = t8 + 1; + s5 = (u32 *) 0x80600000; + g_VmMarker = (u8 *) s7; + sp1474 = t8 + 1; - // Load gamezips pointer list - dmaExec(s5, (u32) &_gamezipSegmentRomStart, ALIGN16((sp1474 + 1) << 2)); + // Load gamezips pointer list + dmaExec(s5, (u32) &_gamezipSegmentRomStart, ALIGN16((sp1474 + 1) << 2)); - // Make pointers absolute instead of relative to their segment - for (i = 0; i < sp1474; i++) { \ - s5[i] += (u32) &_gamezipSegmentRomStart; - } + // Make pointers absolute instead of relative to their segment + for (i = 0; i < sp1474; i++) { \ + s5[i] += (u32) &_gamezipSegmentRomStart; + } - // Load each zip from the ROM and inflate them to the game segment - s2 = gameseg; - chunkbuffer = (u8 *) ((u32)s5 - PAGE_SIZE * 2); - zip = chunkbuffer + 2; + // Load each zip from the ROM and inflate them to the game segment + s2 = gameseg; + chunkbuffer = (u8 *) ((u32)s5 - PAGE_SIZE * 2); + zip = chunkbuffer + 2; - for (i = 0; i < sp1474 - 1; i++) { \ - dmaExec(chunkbuffer, s5[i], ALIGN16(s5[i + 1] - s5[i])); \ - s2 += rzipInflate(zip, s2, sp68); - } + for (i = 0; i < sp1474 - 1; i++) { \ + dmaExec(chunkbuffer, s5[i], ALIGN16(s5[i + 1] - s5[i])); \ + s2 += rzipInflate(zip, s2, sp68); } osInvalICache(0, ICACHE_SIZE); diff --git a/tools/ai2asm/ai2asm.py b/tools/ai2asm/ai2asm.py index 7f0d51006..3aa17d74d 100755 --- a/tools/ai2asm/ai2asm.py +++ b/tools/ai2asm/ai2asm.py @@ -567,8 +567,9 @@ class App(): self.emit_bnez_label(params[0]) def ai_if_can_hear_alarm(self, params): - self.emit('jal', ['alarmIsActive']) - self.emit_bnez_label(params[0]) + self.emit('lui', ['$a0', '%hi(g_AlarmTimer)']) + self.emit('lw', ['$v0', '%lo(g_AlarmTimer)($a0)']) + self.emit('bgtz', ['$v0', self.label_name(params[0])]) def ai_if_can_see_attack_target(self, params): self.emit('jal', ['aiIfCanSeeAttackTarget']) @@ -1118,7 +1119,8 @@ class App(): self.emit_bnez_label(params[5]) def ai_if_stage_is_not(self, params): - self.emit('jal', ['mainGetStageNum']) + self.emit('lui', ['$v0', '%hi(g_StageNum)']) + self.emit('lw', ['$v0', '%lo(g_StageNum)($v0)']) self.emit('li', ['$v1', params[0]]) self.emit('bne', ['$v0', '$v1', self.label_name(params[1])]) @@ -1330,12 +1332,12 @@ class App(): def ai_play_track_isolated(self, params): if params[0] == 101: # MUSIC_CI_TRAINING - self.emit('jal', ['optionsGetMusicVolume']) + self.emit('jal', ['musicGetVolume']) self.emit('sw', ['$v0', '0x10($sp)']) self.emit('li', ['$a0', params[0]]) self.emit('jal', ['musicPlayTrackIsolated']) self.emit('lw', ['$a0', '0x10($sp)']) - self.emit('jal', ['optionsSetMusicVolume']) + self.emit('jal', ['musicSetVolume']) else: self.emit('li', ['$a0', params[0]]) self.emit('jal', ['musicPlayTrackIsolated'])