From e6560cc1d6c142483f353d8f2cb8951bc798a269 Mon Sep 17 00:00:00 2001 From: ABelliqueux Date: Fri, 25 Jun 2021 14:58:31 +0200 Subject: [PATCH] Fix issue #2: Update light matrix on rotation --- src/main.c | 12 +++++++++--- src/psx.c | 9 ++------- 2 files changed, 11 insertions(+), 10 deletions(-) diff --git a/src/main.c b/src/main.c index 03397ce..dc5668c 100644 --- a/src/main.c +++ b/src/main.c @@ -36,8 +36,6 @@ u_long overlaySize = 0; #include "../levels/level0.h" #include "../levels/level1.h" -//FIXME : Refresh BGc, lightmatrix on ovly upload... - volatile u_char level = 0; // level 1 : 8003F05C -2147225508 // level 0 : 800AF744 -2146764988 @@ -60,7 +58,10 @@ char db = 0; // Current buffer counter CVECTOR BGc = {128, 128, 128, 0}; // Default Far color - This can be set in each level. VECTOR BKc = {128, 128, 128, 0}; // Back color MATRIX rotlgt; +MATRIX rotactor; SVECTOR lgtang = {0, 0, 0}; +SVECTOR invang = {0, 0, 0}; +SVECTOR actorang = {0, 0, 0}; MATRIX light; short vs; CAMERA camera = {0}; @@ -561,7 +562,12 @@ int main() { } } // Find and apply light rotation matrix - RotMatrix(&lgtang, &rotlgt); + + // Update light rotation on actor + // Find rotmat from actor angle + RotMatrix_gte(&curLvl.actorPtr->rot, &rotactor); + RotMatrix_gte(&lgtang, &rotlgt); + MulMatrix0(&rotactor, &rotlgt, &rotlgt); MulMatrix0(curLvl.lgtmat, &rotlgt, &light); SetLightMatrix(&light); // Set camera diff --git a/src/psx.c b/src/psx.c index 66f03e7..47deead 100644 --- a/src/psx.c +++ b/src/psx.c @@ -5,7 +5,7 @@ void setLightEnv(DRAWENV draw[2], CVECTOR * BGc, VECTOR * BKc, MATRIX * cmat){ setRGB0(&draw[0], BGc->r, BGc->g, BGc->b); setRGB0(&draw[1], BGc->r, BGc->g, BGc->b); // Set Farcolor from here - //~ SetFarColor( BGc->r, BGc->g, BGc->b ); + SetFarColor( BGc->r, BGc->g, BGc->b ); // Set Ambient color SetBackColor( BKc->vx, BKc->vy, BKc->vz ); // Set Light matrix @@ -53,12 +53,7 @@ void init(DISPENV disp[2], DRAWENV draw[2], short db, MATRIX * cmat, CVECTOR * B FNT_SCR_BG, FNT_SCR_MAX_CHAR ); - // TODO : Move these to level files - SetFarColor( 128, 128, 128 ); - //~ // Set Ambient color - //~ SetBackColor( BKc->vx, BKc->vy, BKc->vz ); - //~ // Set Light matrix - //~ SetColorMatrix(cmat); + // TODO : Move this to level files SetFogNearFar( FOG_NEAR, FOG_FAR, SCREENXRES ); }; void ScrRst(void){