move some parameters to defines.h

This commit is contained in:
ABelliqueux 2021-04-20 19:11:18 +02:00
parent 31e5f5f541
commit 179c272b60
4 changed files with 73 additions and 26 deletions

View File

@ -1,4 +1,6 @@
#define VMODE 0 #define VMODE 0 // 0 == NTSC, 1 == PAL
#define VSYNC 0
#define SCREENXRES 320 #define SCREENXRES 320
@ -10,22 +12,51 @@
#define FOV CENTERX #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 OT2LEN 8
#define OTLEN 256 #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 GRAVITY 10
#define SCALE 4 #define SCALE 4
#define PRIMBUFFLEN 4096 * sizeof(POLY_GT4) // Maximum number of POLY_GT3 primitives // Pad codes defines
// Pad defines
// Applied on PADL // Applied on PADL

4
main.c
View File

@ -30,7 +30,7 @@
#include "graphics.h" #include "graphics.h"
#include "space.h" #include "space.h"
//~ #define USECD #define USECD
// START OVERLAY // 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); //~ FntPrint("%x\n", curLvl.actorPtr->tim);

48
psx.c
View File

@ -14,7 +14,7 @@ void init(DISPENV disp[2], DRAWENV draw[2], short db, MATRIX * cmat, CVECTOR * B
// Reset the GPU // Reset the GPU
ResetGraph(0); ResetGraph( 0 );
// Initialize and setup the GTE // 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); SetDefDrawEnv(&draw[1], 0, 0, SCREENXRES, SCREENYRES);
// If PAL // If PAL , add 8 pix vertical offset ((256 - 240) /2)
if ( VMODE ) { if ( VMODE ) {
@ -67,19 +67,31 @@ void init(DISPENV disp[2], DRAWENV draw[2], short db, MATRIX * cmat, CVECTOR * B
// Init font system // 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 // 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; 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); 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); 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; int cdread = 0, cdsync = 1;
cdread = CdReadFile( (char *)(LevelName), LoadAddress, 0); cdread = CdReadFile( (char *)(LevelName), LoadAddress, 0);
cdsync = CdReadSync(0, 0); cdsync = CdReadSync(0, 0);
// return loaded size
return cdread;
}; };
void SwitchLevel(const char*const LevelName, u_long * LoadAddress, LEVEL * curLevel, LEVEL * loadLevel ){ void SwitchLevel(const char*const LevelName, u_long * LoadAddress, LEVEL * curLevel, LEVEL * loadLevel ){

2
psx.h
View File

@ -24,7 +24,7 @@ void display(DISPENV * disp, DRAWENV * draw, u_long * otdisc, char * primbuff, c
void LvlPtrSet( LEVEL * curLevel, LEVEL * level ); 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); void SwitchLevel(const char*const LevelName, u_long * LoadAddress, LEVEL * curLevel, LEVEL * loadLevel);