Skip to content

Commit

Permalink
#1 : Use separate FC and BG colors
Browse files Browse the repository at this point in the history
  • Loading branch information
ABelliqueux committed Jul 3, 2021
1 parent 93331f4 commit 800be60
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 6 deletions.
1 change: 1 addition & 0 deletions include/defines.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
#define CENTERX SCREENXRES/2
#define CENTERY SCREENYRES/2
#define FOV CENTERX
#define FOG_COLOR {128, 128, 128} // Default to neutral grey
#define CLEAR_COLOR_R 0
#define CLEAR_COLOR_G 0
#define CLEAR_COLOR_B 0
Expand Down
2 changes: 1 addition & 1 deletion include/psx.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

// PSX setup
void setLightEnv(DRAWENV draw[2], CVECTOR * BGc, VECTOR * BKc, MATRIX * cmat);
void init(DISPENV disp[2], DRAWENV draw[2], short db, MATRIX * cmat, CVECTOR * BG, VECTOR * BK );
void init(DISPENV disp[2], DRAWENV draw[2], short db, MATRIX * cmat, CVECTOR * BG, VECTOR * BK, VECTOR * FC );
void ScrRst(void);
void display(DISPENV * disp, DRAWENV * draw, u_long * otdisc, char * primbuff, char ** nextprim, char * db);

Expand Down
2 changes: 1 addition & 1 deletion src/graphics.c
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ void transformMesh(CAMERA * camera, MESH * mesh){
void drawPoly(MESH * mesh, long * Flag, int atime, int * camMode, char ** nextpri, u_long * ot, char * db, DRAWENV * draw) {
long nclip, t = 0;
// mesh is POLY_GT3 ( triangle )
for (int i = 0; i < (mesh->totalVerts);) {
for (int i = 0; i < (mesh->totalVerts) && (mesh->totalVerts - i) > 2;) {
if (mesh->index[t].code == 4) {
t = drawTri(mesh, Flag, atime, camMode, nextpri, ot, db, draw, t, i);
i += 3;
Expand Down
5 changes: 3 additions & 2 deletions src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,9 @@ int primcnt=0; // Primitive counter
char * nextpri = primbuff[0]; // Primitive counter
char db = 0; // Current buffer counter
// Lighting
CVECTOR BGc = {128, 128, 128, 0}; // Default Far color - This can be set in each level.
CVECTOR BGc = {128, 128, 128, 0}; // Default Far color - This can be set in each level.
VECTOR BKc = {128, 128, 128, 0}; // Back color
VECTOR FC = FOG_COLOR; // Far (Fog) color
SVECTOR lgtang = {0, 0, 0};
MATRIX rotlgt, light;
short vs;
Expand Down Expand Up @@ -130,7 +131,7 @@ int main() {
}
levelWas = level;
// Init dislay, Gte..
init(disp, draw, db, curLvl.cmat, curLvl.BGc, curLvl.BKc);
init(disp, draw, db, curLvl.cmat, curLvl.BGc, curLvl.BKc, &FC);
// Init Pads
InitPAD(controllers[0].pad, 34, controllers[1].pad, 34);
StartPAD();
Expand Down
4 changes: 2 additions & 2 deletions src/psx.c
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ void setLightEnv(DRAWENV draw[2], CVECTOR * BGc, VECTOR * BKc, MATRIX * cmat){
SetColorMatrix(cmat);
};

void init(DISPENV disp[2], DRAWENV draw[2], short db, MATRIX * cmat, CVECTOR * BGc, VECTOR * BKc) {
void init(DISPENV disp[2], DRAWENV draw[2], short db, MATRIX * cmat, CVECTOR * BGc, VECTOR * BKc, VECTOR * FC) {
ResetCallback();
// Init pad
//~ PadInit(0);
Expand All @@ -37,7 +37,6 @@ void init(DISPENV disp[2], DRAWENV draw[2], short db, MATRIX * cmat, CVECTOR * B
}
// Set Draw area color
setLightEnv(draw, BGc, BKc, cmat);

// Set Draw area clear flag
draw[0].isbg = 1;
draw[1].isbg = 1;
Expand All @@ -53,6 +52,7 @@ void init(DISPENV disp[2], DRAWENV draw[2], short db, MATRIX * cmat, CVECTOR * B
FNT_SCR_BG,
FNT_SCR_MAX_CHAR
);
SetFarColor(FC->vx, FC->vy, FC->vz);
// TODO : Move this to level files
SetFogNearFar( FOG_NEAR, FOG_FAR, SCREENXRES );
};
Expand Down

0 comments on commit 800be60

Please sign in to comment.