port Output_AlterFOV

This commit is contained in:
Marcin Kurczewski 2023-10-29 23:37:50 +01:00
parent a3629c1023
commit f1ba45c4b4
No known key found for this signature in database
GPG Key ID: CC65E6FD28CAE42A
8 changed files with 39 additions and 16 deletions

View File

@ -69,10 +69,10 @@
</g>
<g transform="translate(0 116)">
<text x="0" y="7.50">Tomb2.exe progress according to the physical function order:</text>
<text class="todo" style="font-size: 12px; " x="747" y="9"><tspan text-anchor="end"><tspan class="decompiled">19.17% (230)</tspan> · <tspan class="known">78.42% (941)</tspan> · <tspan class="todo">0.67% (8)</tspan> · <tspan class="unused">1.75% (21)</tspan></tspan></text>
<text class="todo" style="font-size: 12px; " x="747" y="9"><tspan text-anchor="end"><tspan class="decompiled">19.25% (231)</tspan> · <tspan class="known">78.33% (940)</tspan> · <tspan class="todo">0.67% (8)</tspan> · <tspan class="unused">1.75% (21)</tspan></tspan></text>
<g transform="translate(0 20)">
<rect width="143.18" height="6" x="0" y="0" class="decompiled"/>
<rect width="585.77" height="6" x="143.18" y="0" class="known"/>
<rect width="143.80" height="6" x="0" y="0" class="decompiled"/>
<rect width="585.15" height="6" x="143.80" y="0" class="known"/>
<rect width="4.98" height="6" x="728.95" y="0" class="todo"/>
<rect width="13.07" height="6" x="733.93" y="0" class="unused"/>
</g>
@ -100,7 +100,7 @@
<rect width="12" height="12" x="300" y="0" class="decompiled"><title>void __cdecl Output_SortPolyList(void);</title></rect>
<rect width="12" height="12" x="315" y="0" class="decompiled"><title>void __cdecl Output_QuickSort(int32_t left, int32_t right);</title></rect>
<rect width="12" height="12" x="330" y="0" class="decompiled"><title>void __cdecl Output_PrintPolyList(uint8_t *surface_ptr);</title></rect>
<rect width="12" height="12" x="345" y="0" class="known"><title>void __cdecl Viewport_AlterFOV(int16_t fov);</title></rect>
<rect width="12" height="12" x="345" y="0" class="decompiled"><title>void __cdecl Output_AlterFOV(int16_t fov);</title></rect>
<rect width="12" height="12" x="360" y="0" class="decompiled"><title>void __cdecl Output_SetNearZ(int32_t near_z);</title></rect>
<rect width="12" height="12" x="375" y="0" class="decompiled"><title>void __cdecl Output_SetFarZ(int32_t far_z);</title></rect>
<rect width="12" height="12" x="390" y="0" class="decompiled"><title>void __cdecl Output_Init(int16_t x, int16_t y, int32_t width, int32_t height, int32_t near_z, int32_t far_z, int16_t view_angle, int32_t screen_width, int32_t screen_height);</title></rect>
@ -1281,10 +1281,10 @@
</g>
<g transform="translate(0 531)">
<text x="0" y="7.50">Tomb2.exe progress according to the function sizes:</text>
<text class="todo" style="font-size: 12px; " x="747" y="9"><tspan text-anchor="end"><tspan class="decompiled">11.15%</tspan> · <tspan class="known">88.52%</tspan> · <tspan class="todo">0.02%</tspan> · <tspan class="unused">0.31%</tspan></tspan></text>
<text class="todo" style="font-size: 12px; " x="747" y="9"><tspan text-anchor="end"><tspan class="decompiled">11.20%</tspan> · <tspan class="known">88.48%</tspan> · <tspan class="todo">0.02%</tspan> · <tspan class="unused">0.31%</tspan></tspan></text>
<g transform="translate(0 20)">
<rect width="83.27" height="6" x="0" y="0" class="decompiled"/>
<rect width="661.26" height="6" x="83.27" y="0" class="known"/>
<rect width="83.63" height="6" x="0" y="0" class="decompiled"/>
<rect width="660.91" height="6" x="83.63" y="0" class="known"/>
<rect width="0.13" height="6" x="744.54" y="0" class="todo"/>
<rect width="2.33" height="6" x="744.67" y="0" class="unused"/>
</g>
@ -1810,7 +1810,7 @@
<rect width="8.38" height="8.53" x="544.80" y="216.06" class="decompiled"><title>void __cdecl Lara_State_Extra_FinalAnim(struct ITEM_INFO *item, struct COLL_INFO *coll);</title></rect>
<rect width="8.38" height="8.53" x="544.80" y="227.59" class="known"><title>int32_t __cdecl OnTrapDoor(struct ITEM_INFO *item, int32_t x, int32_t z);</title></rect>
<rect width="8.38" height="8.46" x="544.80" y="239.12" class="known"><title>bool __cdecl LoadTexturePage(int32_t pageIndex, bool reset);</title></rect>
<rect width="8.38" height="8.39" x="544.80" y="250.58" class="known"><title>void __cdecl Viewport_AlterFOV(int16_t fov);</title></rect>
<rect width="8.38" height="8.39" x="544.80" y="250.58" class="decompiled"><title>void __cdecl Output_AlterFOV(int16_t fov);</title></rect>
<rect width="8.38" height="8.39" x="544.80" y="261.97" class="decompiled"><title>void __cdecl Matrix_RotYXZsuperpack(int16_t **pprot, int32_t skip);</title></rect>
<rect width="8.38" height="8.39" x="544.80" y="273.36" class="known"><title>void __cdecl CreateRenderBuffer(void);</title></rect>
<rect width="8.38" height="8.32" x="544.80" y="284.75" class="known"><title>int32_t __cdecl LOS_Check(struct GAME_VECTOR *start, struct GAME_VECTOR *target);</title></rect>

Before

Width:  |  Height:  |  Size: 359 KiB

After

Width:  |  Height:  |  Size: 359 KiB

View File

@ -1164,7 +1164,7 @@ typedef enum LARA_MESH {
00402430 00000033 + void __cdecl Output_SortPolyList(void);
00402470 000000C5 + void __cdecl Output_QuickSort(int32_t left, int32_t right);
00402540 00000036 + void __cdecl Output_PrintPolyList(uint8_t *surface_ptr);
00402580 000000A1 * void __cdecl Viewport_AlterFOV(int16_t fov);
00402580 000000A1 + void __cdecl Output_AlterFOV(int16_t fov);
00402690 00000095 + void __cdecl Output_SetNearZ(int32_t near_z);
004026E0 0000006B + void __cdecl Output_SetFarZ(int32_t far_z);
00402700 00000266 + void __cdecl Output_Init(int16_t x, int16_t y, int32_t width, int32_t height, int32_t near_z, int32_t far_z, int16_t view_angle, int32_t screen_width, int32_t screen_height);

View File

@ -3,6 +3,7 @@
#include "game/math.h"
#include "game/matrix.h"
#include "game/music.h"
#include "game/output.h"
#include "global/const.h"
#include "global/funcs.h"
#include "global/vars.h"
@ -48,7 +49,7 @@ void __cdecl Camera_Initialise(void)
g_Camera.num = NO_CAMERA;
g_Camera.fixed_camera = 0;
Viewport_AlterFOV(GAME_FOV * PHD_DEGREE);
Output_AlterFOV(GAME_FOV * PHD_DEGREE);
Camera_Update();
}
@ -820,7 +821,7 @@ void __cdecl Camera_LoadCutsceneFrame(void)
g_Camera.pos.y = g_CinePos.y + cy;
g_Camera.pos.z = g_CinePos.z + ((cz * c - cx * s) >> W2V_SHIFT);
Viewport_AlterFOV(fov);
Output_AlterFOV(fov);
Matrix_LookAt(
g_Camera.pos.x, g_Camera.pos.y, g_Camera.pos.z, g_Camera.target.x,
g_Camera.target.y, g_Camera.target.z, roll);
@ -873,7 +874,7 @@ void __cdecl Camera_UpdateCutscene(void)
if (room_num >= 0) {
g_Camera.pos.room_num = room_num;
}
Viewport_AlterFOV(fov);
Output_AlterFOV(fov);
Matrix_LookAt(
campos.x, campos.y, campos.z, camtar.x, camtar.y, camtar.z, roll);
}

View File

@ -2,6 +2,7 @@
#include "game/lara/lara_misc.h"
#include "game/music.h"
#include "game/output.h"
#include "global/const.h"
#include "global/funcs.h"
#include "global/vars.h"
@ -685,7 +686,7 @@ void __cdecl Lara_State_Extra_Breath(
g_Lara.extra_anim = 0;
g_Lara.gun_status = LGS_ARMLESS;
g_Camera.type = CAM_CHASE;
Viewport_AlterFOV(GAME_FOV * PHD_DEGREE);
Output_AlterFOV(GAME_FOV * PHD_DEGREE);
}
void __cdecl Lara_State_Extra_YetiKill(
@ -796,7 +797,7 @@ void __cdecl Lara_State_Extra_StartHouse(
Inv_AddItem(O_PUZZLE_ITEM_1);
} else if (item->frame_num == g_Anims[item->anim_num].frame_end) {
g_Camera.type = CAM_CHASE;
Viewport_AlterFOV(GAME_FOV * PHD_DEGREE);
Output_AlterFOV(GAME_FOV * PHD_DEGREE);
}
}

View File

@ -42,7 +42,7 @@ void __cdecl Output_Init(
g_PhdScreenWidth = screen_width;
g_PhdScreenHeight = screen_height;
Viewport_AlterFOV(182 * view_angle);
Output_AlterFOV(182 * view_angle);
Output_SetNearZ(g_PhdNearZ);
Output_SetFarZ(g_PhdFarZ);
@ -506,3 +506,23 @@ void __cdecl Output_SetFarZ(int32_t far_z)
g_FltResZORhw = res_z / g_RhwFactor;
g_FltResZBuf = 0.005 - res_z / g_FltNearZ;
}
void __cdecl Output_AlterFOV(int16_t fov)
{
fov /= 2;
g_PhdPersp = g_PhdWinWidth / 2 * Math_Cos(fov) / Math_Sin(fov);
g_FltPersp = g_PhdPersp;
g_FltRhwOPersp = g_RhwFactor / g_FltPersp;
g_FltPerspONearZ = g_FltPersp / g_FltNearZ;
double window_aspect_ratio = 4.0 / 3.0;
if (!g_SavedAppSettings.fullscreen
&& g_SavedAppSettings.aspect_mode == AM_16_9) {
window_aspect_ratio = 16.0 / 9.0;
}
g_ViewportAspectRatio =
window_aspect_ratio / ((double)g_PhdWinWidth / (double)g_PhdWinHeight);
}

View File

@ -22,3 +22,4 @@ void __cdecl Output_QuickSort(int32_t left, int32_t right);
void __cdecl Output_PrintPolyList(uint8_t *surface_ptr);
void __cdecl Output_SetNearZ(int32_t near_z);
void __cdecl Output_SetFarZ(int32_t far_z);
void __cdecl Output_AlterFOV(int16_t fov);

View File

@ -6,7 +6,6 @@
// clang-format off
#define Output_InsertInventoryBackground ((void __cdecl (*)(const int16_t *obj_ptr))0x00401D50)
#define Viewport_AlterFOV ((void __cdecl (*)(int16_t fov))0x00402580)
#define Output_DrawPolyLine ((void __cdecl (*)(int16_t *obj_ptr))0x00402970)
#define Output_DrawPolyFlat ((void __cdecl (*)(int16_t *obj_ptr))0x00402B10)
#define Output_DrawPolyTrans ((void __cdecl (*)(int16_t *obj_ptr))0x00402B50)

View File

@ -101,6 +101,7 @@ static void Inject_Output(void)
INJECT(1, 0x00402430, Output_SortPolyList);
INJECT(1, 0x00402470, Output_QuickSort);
INJECT(1, 0x00402540, Output_PrintPolyList);
INJECT(1, 0x00402580, Output_AlterFOV);
INJECT(1, 0x00402690, Output_SetNearZ);
INJECT(1, 0x004026E0, Output_SetFarZ);
INJECT(1, 0x00402700, Output_Init);