From 179c272b6039547d1b634579a5501b91fb136c68 Mon Sep 17 00:00:00 2001 From: ABelliqueux Date: Tue, 20 Apr 2021 19:11:18 +0200 Subject: [PATCH] move some parameters to defines.h --- defines.h | 45 ++++++++++++++++++++++++++++++++++++++------- main.c | 4 ++-- psx.c | 48 ++++++++++++++++++++++++++++++++---------------- psx.h | 2 +- 4 files changed, 73 insertions(+), 26 deletions(-) diff --git a/defines.h b/defines.h index 3b57be3..3057ba7 100644 --- a/defines.h +++ b/defines.h @@ -1,4 +1,6 @@ -#define VMODE 0 +#define VMODE 0 // 0 == NTSC, 1 == PAL + +#define VSYNC 0 #define SCREENXRES 320 @@ -10,22 +12,51 @@ #define FOV CENTERX -#define FNT_POS_X 960 +#define CLEAR_COLOR_R 0 -#define FNT_POS_Y 256 +#define CLEAR_COLOR_G 0 + +#define CLEAR_COLOR_B 0 + +// Debug Font + +#define FNT_VRAM_X 960 + +#define FNT_VRAM_Y 256 + +#define FNT_SCR_X 16 + +#define FNT_SCR_Y 192 + +#define FNT_SCR_W 240 + +#define FNT_SCR_H 32 + +#define FNT_SCR_BG 0 + +#define FNT_SCR_MAX_CHAR 256 + +// Ordering table #define OT2LEN 8 #define OTLEN 256 +#define PRIMBUFFLEN 4096 * sizeof(POLY_GT4) // Maximum number of POLY_GT3 primitives + +// Fog + +#define FOG_NEAR 1200 + +#define FOG_FAR 1600 + +// Physics + #define GRAVITY 10 #define SCALE 4 -#define PRIMBUFFLEN 4096 * sizeof(POLY_GT4) // Maximum number of POLY_GT3 primitives - - -// Pad defines +// Pad codes defines // Applied on PADL diff --git a/main.c b/main.c index 0c4413d..827508c 100644 --- a/main.c +++ b/main.c @@ -30,7 +30,7 @@ #include "graphics.h" #include "space.h" -//~ #define USECD +#define USECD // START OVERLAY @@ -355,7 +355,7 @@ int main() { } - FntPrint("cmat : %x %x\n", &curLvl.curNode, &curLvl.cmat); + FntPrint("Lvl : %s\n", overlayFile); //~ FntPrint("%x\n", curLvl.actorPtr->tim); diff --git a/psx.c b/psx.c index dd0a1fd..bebc48a 100644 --- a/psx.c +++ b/psx.c @@ -14,7 +14,7 @@ void init(DISPENV disp[2], DRAWENV draw[2], short db, MATRIX * cmat, CVECTOR * B // Reset the GPU - ResetGraph(0); + ResetGraph( 0 ); // Initialize and setup the GTE @@ -36,7 +36,7 @@ void init(DISPENV disp[2], DRAWENV draw[2], short db, MATRIX * cmat, CVECTOR * B SetDefDrawEnv(&draw[1], 0, 0, SCREENXRES, SCREENYRES); - // If PAL + // If PAL , add 8 pix vertical offset ((256 - 240) /2) if ( VMODE ) { @@ -67,19 +67,31 @@ void init(DISPENV disp[2], DRAWENV draw[2], short db, MATRIX * cmat, CVECTOR * B // Init font system - FntLoad(FNT_POS_X, FNT_POS_Y); + FntLoad(FNT_VRAM_X, FNT_VRAM_Y); - FntOpen(16, 90, 240, 180, 0, 512); + FntOpen( FNT_SCR_X, + + FNT_SCR_Y, + + FNT_SCR_W, + + FNT_SCR_H, + + FNT_SCR_BG, + + FNT_SCR_MAX_CHAR + + ); // Lighting setup - SetColorMatrix(cmat); + SetColorMatrix( cmat ); - SetBackColor(BKc->vx,BKc->vy,BKc->vz); + SetBackColor( BKc->vx, BKc->vy, BKc->vz ); - SetFarColor(BGc->r, BGc->g, BGc->b); + SetFarColor( BGc->r, BGc->g, BGc->b ); - SetFogNearFar(1200, 1600, SCREENXRES); + SetFogNearFar( FOG_NEAR, FOG_FAR, SCREENXRES ); }; @@ -87,17 +99,17 @@ void ScrRst(void){ RECT scr; - VSync(0); // Wait for current drawing to finish + VSync( 0 ); // Wait for current drawing to finish - SetDispMask(0); // Set mask to not displayed + SetDispMask( 0 ); // Set mask to not displayed - ResetGraph(1); // Cancel current drawing + ResetGraph( 1 ); // Cancel current drawing - setRECT(&scr, 0, 0, 320, 480); + setRECT(&scr, 0, 0, SCREENXRES, SCREENYRES); - ClearImage(&scr, 0, 0, 0); + ClearImage(&scr, CLEAR_COLOR_R, CLEAR_COLOR_G, CLEAR_COLOR_B ); - DrawSync(0); + DrawSync( 0 ); }; @@ -107,7 +119,7 @@ void display(DISPENV * disp, DRAWENV * draw, u_long * otdisc, char * primbuff, c DrawSync(0); - VSync(0); // Using VSync 2 insures constant framerate. 0 makes the fr polycount dependant. + VSync(VSYNC); // Using VSync 2 insures constant framerate. 0 makes the fr polycount dependant. ResetGraph(1); @@ -162,13 +174,17 @@ void LvlPtrSet(LEVEL * curLevel, LEVEL * level){ }; -void LoadLevel(const char*const LevelName, u_long * LoadAddress){ +int LoadLevel(const char*const LevelName, u_long * LoadAddress){ int cdread = 0, cdsync = 1; cdread = CdReadFile( (char *)(LevelName), LoadAddress, 0); cdsync = CdReadSync(0, 0); + + // return loaded size + + return cdread; }; void SwitchLevel(const char*const LevelName, u_long * LoadAddress, LEVEL * curLevel, LEVEL * loadLevel ){ diff --git a/psx.h b/psx.h index 7a8ddc8..db5c6b6 100644 --- a/psx.h +++ b/psx.h @@ -24,7 +24,7 @@ void display(DISPENV * disp, DRAWENV * draw, u_long * otdisc, char * primbuff, c void LvlPtrSet( LEVEL * curLevel, LEVEL * level ); -void LoadLevel(const char*const LevelName, u_long * LoadAddress); +int LoadLevel(const char*const LevelName, u_long * LoadAddress); void SwitchLevel(const char*const LevelName, u_long * LoadAddress, LEVEL * curLevel, LEVEL * loadLevel);