Start using display size defines

This commit is contained in:
gamemasterplc 2024-09-09 23:39:00 -05:00
parent 18038b2870
commit 5650eb9905
18 changed files with 210 additions and 159 deletions

View file

@ -1,9 +1,13 @@
#include "game/hsfex.h"
#include "game/hsfman.h"
#include "game/hsfmotion.h"
#include "game/disp.h"
#include "math.h"
#define DISP_HALF_W (HU_DISP_WIDTH/2.0f)
#define DISP_HALF_H (HU_DISP_HEIGHT/2.0f)
typedef struct {
/* 0x00 */ float unk00;
/* 0x04 */ float unk04;
@ -430,9 +434,9 @@ void Hu3D2Dto3D(Vec *arg0, s16 arg1, Vec *arg2) {
temp_r31 = &Hu3DCamera[i];
temp_f30 = sin((temp_r31->fov / 2) * M_PI / 180.0) / cos((temp_r31->fov / 2) * M_PI / 180.0);
temp_f31 = temp_f30 * arg0->z * 2.0f;
temp_f29 = temp_f31 * 1.2f;
temp_f28 = arg0->x / 576.0f;
temp_f27 = arg0->y / 480.0f;
temp_f29 = temp_f31 * HU_DISP_ASPECT;
temp_f28 = arg0->x / HU_DISP_WIDTH;
temp_f27 = arg0->y / HU_DISP_HEIGHT;
arg2->x = (temp_f28 - 0.5) * temp_f29;
arg2->y = -(temp_f27 - 0.5) * temp_f31;
arg2->z = -arg0->z;
@ -457,10 +461,10 @@ void Hu3D3Dto2D(Vec *arg0, s16 arg1, Vec *arg2) {
temp_r31 = &Hu3DCamera[i];
C_MTXLookAt(sp1C, &temp_r31->pos, &temp_r31->up, &temp_r31->target);
PSMTXMultVec(sp1C, arg0, &sp10);
temp_f31 = (sin((temp_r31->fov / 2) * M_PI / 180.0) / cos((temp_r31->fov / 2) * M_PI / 180.0)) * sp10.z * 1.2f;
temp_f31 = (sin((temp_r31->fov / 2) * M_PI / 180.0) / cos((temp_r31->fov / 2) * M_PI / 180.0)) * sp10.z * HU_DISP_ASPECT;
temp_f30 = (sin((temp_r31->fov / 2) * M_PI / 180.0) / cos((temp_r31->fov / 2) * M_PI / 180.0)) * sp10.z;
arg2->x = 288.0f + sp10.x * (288.0f / -temp_f31);
arg2->y = 240.0f + sp10.y * (240.0f / temp_f30);
arg2->x = DISP_HALF_W + sp10.x * (DISP_HALF_W / -temp_f31);
arg2->y = DISP_HALF_H + sp10.y * (DISP_HALF_H / temp_f30);
arg2->z = 0.0f;
}