Browse Source

Changed to 512x240 high resolution output, and implemented aspect ratio correction.

master
Nico de Poel 3 years ago
parent
commit
0665342e66
  1. 12
      main.c

12
main.c

@ -27,7 +27,7 @@
#define OTLEN 256
#define SCREENWIDTH 320
#define SCREENWIDTH 512
#define SCREENHEIGHT 240
#define NUMVERTEXNORMALS 162
@ -78,8 +78,8 @@ typedef struct
ps1texture_t front, back;
} ps1skin_t;
ps1mdl_t playerModel = { .position = { -128, 320, 400 }, .rotation = { 0 } };
ps1mdl_t shamblerModel = { .position = { 128, 320, 400 }, .rotation = { 0 } };
ps1mdl_t playerModel = { .position = { -200, 320, 400 }, .rotation = { 0 } };
ps1mdl_t shamblerModel = { .position = { 200, 320, 400 }, .rotation = { 0 } };
ps1skin_t playerSkin, shamblerSkin;
MATRIX color_mtx = {
@ -94,6 +94,9 @@ MATRIX light_mtx = {
0, 0, 0
};
// Scale X coordinates to correct the aspect ratio for the chosen resolution
VECTOR cam_scale = { SCREENWIDTH * ONE / 320 , ONE, ONE };
void loadModel(const u_long* data, ps1mdl_t *mdl)
{
const char *bytes = (const char*)data;
@ -188,7 +191,7 @@ void init(void)
InitGeom();
gte_SetGeomOffset(SCREENWIDTH >> 1, SCREENHEIGHT >> 1);
gte_SetGeomScreen(SCREENWIDTH >> 1); // Screen depth for FOV control
gte_SetGeomScreen(180); // Screen depth for FOV control. Essentially the Z position of the vanishing point.
// Set texture page for the entire drawing environment. Nice in some cases perhaps, but not what we need.
//draw[0].tpage = getTPage(playerFrontTex.mode & 0x3, 0, playerFrontTex.prect->x, playerFrontTex.prect->y);
@ -358,6 +361,7 @@ void drawModel(ps1mdl_t *model, ps1skin_t *skin, int xOffset, int frameCounter)
MATRIX mtx, lmtx;
RotMatrix(&model->rotation, &mtx);
ScaleMatrixL(&mtx, &cam_scale); // Aspect ratio correction
TransMatrix(&mtx, &model->position);
MulMatrix0(&light_mtx, &mtx, &lmtx);

Loading…
Cancel
Save