preparing level ovly loading

This commit is contained in:
ABelliqueux 2021-04-13 16:52:48 +02:00
parent a31df994cf
commit bef4cc057f
11 changed files with 6373 additions and 756 deletions

View File

@ -8,6 +8,7 @@ physics.c \
graphics.c \ graphics.c \
psx.c \ psx.c \
space.c \ space.c \
levels/level.c \
../common/crt0/crt0.s \ ../common/crt0/crt0.s \
TIM/home.tim \ TIM/home.tim \
TIM/cat.tim \ TIM/cat.tim \
@ -19,6 +20,9 @@ TIM/bg_camPath_003.tim \
TIM/bg_camPath_004.tim \ TIM/bg_camPath_004.tim \
TIM/bg_camPath_005.tim \ TIM/bg_camPath_005.tim \
#~ OVERLAYSCRIPT ?= overlay.ld
#~ OVERLAYSECTION ?= .ovly0 .ovly1
# img2tim -t -bpp 8 -org 320 0 -plt 0 481 -o bg.tim bg.png # img2tim -t -bpp 8 -org 320 0 -plt 0 481 -o bg.tim bg.png
CPPFLAGS += -I../psyq/include CPPFLAGS += -I../psyq/include

View File

@ -1,3 +1,4 @@
#pragma once
#include <sys/types.h> #include <sys/types.h>
#include <libgte.h> #include <libgte.h>
#include <libgpu.h> #include <libgpu.h>

View File

@ -1,3 +1,5 @@
#define LEVEL 1
#define VMODE 0 #define VMODE 0
#define SCREENXRES 320 #define SCREENXRES 320

View File

@ -26,7 +26,7 @@ void transformMesh(CAMERA * camera, MESH * mesh){
//~ } //~ }
}; };
// Drawing //TODO : Break this monster in tiny bits ?
void drawPoly(MESH * mesh, long * Flag, int atime, int * camMode, char ** nextpri, u_long * ot, char * db, DRAWENV * draw) { void drawPoly(MESH * mesh, long * Flag, int atime, int * camMode, char ** nextpri, u_long * ot, char * db, DRAWENV * draw) {

View File

@ -1,24 +1,9 @@
#pragma once #pragma once
//~ #include <sys/types.h>
//~ #include <libgte.h>
//~ #include <libgpu.h>
//~ #include "psx.h"
#include "camera.h" #include "camera.h"
#include "physics.h" #include "physics.h"
#include "defines.h" #include "defines.h"
//~ int camMode = 0;
//~ #define SCREENXRES 320
//~ #define SCREENYRES 240
//~ #define OT2LEN 8
//~ #define OTLEN 256
// Drawing // Drawing
void transformMesh(CAMERA * camera, MESH * meshes); void transformMesh(CAMERA * camera, MESH * meshes);

5547
levels/level.c Normal file

File diff suppressed because it is too large Load Diff

686
levels/level.h Normal file
View File

@ -0,0 +1,686 @@
#pragma once
#include "../custom_types.h"
extern CAMPOS level_camPos_camPath;
extern CAMPOS level_camPos_camPath_001;
extern CAMPOS level_camPos_camPath_002;
extern CAMPOS level_camPos_camPath_003;
extern CAMPOS level_camPos_camPath_004;
extern CAMPOS level_camPos_camPath_005;
extern CAMPATH level_camPath;
extern MATRIX level_lgtmat;
extern MATRIX level_cmat;
extern SVECTOR modelCube_mesh[];
extern SVECTOR level_modelCube_normal[];
extern SVECTOR level_modelCube_uv[];
extern CVECTOR level_modelCube_color[];
extern PRIM level_modelCube_index[];
extern MATRIX level_modelCube_matrix;
extern VECTOR level_modelCube_pos;
extern SVECTOR level_modelCube_rot;
extern short level_modelCube_isRigidBody;
extern short level_modelCube_isStaticBody;
extern short level_modelCube_isPrism;
extern short level_modelCube_isAnim;
extern short level_modelCube_isActor;
extern short level_modelCube_isLevel;
extern short level_modelCube_isBG;
extern short level_modelCube_isSprite;
extern long level_modelCube_p;
extern long level_modelCube_OTz;
extern BODY level_modelCube_body;
extern TMESH level_modelCube;
extern unsigned long _binary_TIM_cat_tim_start[];
extern unsigned long _binary_TIM_cat_tim_end[];
extern unsigned long _binary_TIM_cat_tim_length;
extern TIM_IMAGE tim_cat;
extern MESH level_meshCube;
extern SVECTOR modelCylindre_mesh[];
extern SVECTOR level_modelCylindre_normal[];
extern SVECTOR level_modelCylindre_uv[];
extern CVECTOR level_modelCylindre_color[];
extern PRIM level_modelCylindre_index[];
extern VANIM level_modelCylindre_anim;
extern MATRIX level_modelCylindre_matrix;
extern VECTOR level_modelCylindre_pos;
extern SVECTOR level_modelCylindre_rot;
extern short level_modelCylindre_isRigidBody;
extern short level_modelCylindre_isStaticBody;
extern short level_modelCylindre_isPrism;
extern short level_modelCylindre_isAnim;
extern short level_modelCylindre_isActor;
extern short level_modelCylindre_isLevel;
extern short level_modelCylindre_isBG;
extern short level_modelCylindre_isSprite;
extern long level_modelCylindre_p;
extern long level_modelCylindre_OTz;
extern BODY level_modelCylindre_body;
extern TMESH level_modelCylindre;
extern unsigned long _binary_TIM_home_tim_start[];
extern unsigned long _binary_TIM_home_tim_end[];
extern unsigned long _binary_TIM_home_tim_length;
extern TIM_IMAGE tim_home;
extern MESH level_meshCylindre;
extern SVECTOR modelgnd_mesh[];
extern SVECTOR level_modelgnd_normal[];
extern SVECTOR level_modelgnd_uv[];
extern CVECTOR level_modelgnd_color[];
extern PRIM level_modelgnd_index[];
extern MATRIX level_modelgnd_matrix;
extern VECTOR level_modelgnd_pos;
extern SVECTOR level_modelgnd_rot;
extern short level_modelgnd_isRigidBody;
extern short level_modelgnd_isStaticBody;
extern short level_modelgnd_isPrism;
extern short level_modelgnd_isAnim;
extern short level_modelgnd_isActor;
extern short level_modelgnd_isLevel;
extern short level_modelgnd_isBG;
extern short level_modelgnd_isSprite;
extern long level_modelgnd_p;
extern long level_modelgnd_OTz;
extern BODY level_modelgnd_body;
extern TMESH level_modelgnd;
extern MESH level_meshgnd;
extern SVECTOR modelgnd_001_mesh[];
extern SVECTOR level_modelgnd_001_normal[];
extern SVECTOR level_modelgnd_001_uv[];
extern CVECTOR level_modelgnd_001_color[];
extern PRIM level_modelgnd_001_index[];
extern MATRIX level_modelgnd_001_matrix;
extern VECTOR level_modelgnd_001_pos;
extern SVECTOR level_modelgnd_001_rot;
extern short level_modelgnd_001_isRigidBody;
extern short level_modelgnd_001_isStaticBody;
extern short level_modelgnd_001_isPrism;
extern short level_modelgnd_001_isAnim;
extern short level_modelgnd_001_isActor;
extern short level_modelgnd_001_isLevel;
extern short level_modelgnd_001_isBG;
extern short level_modelgnd_001_isSprite;
extern long level_modelgnd_001_p;
extern long level_modelgnd_001_OTz;
extern BODY level_modelgnd_001_body;
extern TMESH level_modelgnd_001;
extern MESH level_meshgnd_001;
extern SVECTOR modelgnd_003_mesh[];
extern SVECTOR level_modelgnd_003_normal[];
extern SVECTOR level_modelgnd_003_uv[];
extern CVECTOR level_modelgnd_003_color[];
extern PRIM level_modelgnd_003_index[];
extern MATRIX level_modelgnd_003_matrix;
extern VECTOR level_modelgnd_003_pos;
extern SVECTOR level_modelgnd_003_rot;
extern short level_modelgnd_003_isRigidBody;
extern short level_modelgnd_003_isStaticBody;
extern short level_modelgnd_003_isPrism;
extern short level_modelgnd_003_isAnim;
extern short level_modelgnd_003_isActor;
extern short level_modelgnd_003_isLevel;
extern short level_modelgnd_003_isBG;
extern short level_modelgnd_003_isSprite;
extern long level_modelgnd_003_p;
extern long level_modelgnd_003_OTz;
extern BODY level_modelgnd_003_body;
extern TMESH level_modelgnd_003;
extern MESH level_meshgnd_003;
extern SVECTOR modelgnd_002_mesh[];
extern SVECTOR level_modelgnd_002_normal[];
extern SVECTOR level_modelgnd_002_uv[];
extern CVECTOR level_modelgnd_002_color[];
extern PRIM level_modelgnd_002_index[];
extern MATRIX level_modelgnd_002_matrix;
extern VECTOR level_modelgnd_002_pos;
extern SVECTOR level_modelgnd_002_rot;
extern short level_modelgnd_002_isRigidBody;
extern short level_modelgnd_002_isStaticBody;
extern short level_modelgnd_002_isPrism;
extern short level_modelgnd_002_isAnim;
extern short level_modelgnd_002_isActor;
extern short level_modelgnd_002_isLevel;
extern short level_modelgnd_002_isBG;
extern short level_modelgnd_002_isSprite;
extern long level_modelgnd_002_p;
extern long level_modelgnd_002_OTz;
extern BODY level_modelgnd_002_body;
extern TMESH level_modelgnd_002;
extern MESH level_meshgnd_002;
extern SVECTOR modelobject_mesh[];
extern SVECTOR level_modelobject_normal[];
extern SVECTOR level_modelobject_uv[];
extern CVECTOR level_modelobject_color[];
extern PRIM level_modelobject_index[];
extern MATRIX level_modelobject_matrix;
extern VECTOR level_modelobject_pos;
extern SVECTOR level_modelobject_rot;
extern short level_modelobject_isRigidBody;
extern short level_modelobject_isStaticBody;
extern short level_modelobject_isPrism;
extern short level_modelobject_isAnim;
extern short level_modelobject_isActor;
extern short level_modelobject_isLevel;
extern short level_modelobject_isBG;
extern short level_modelobject_isSprite;
extern long level_modelobject_p;
extern long level_modelobject_OTz;
extern BODY level_modelobject_body;
extern TMESH level_modelobject;
extern MESH level_meshobject;
extern SVECTOR modelPlan_mesh[];
extern SVECTOR level_modelPlan_normal[];
extern SVECTOR level_modelPlan_uv[];
extern CVECTOR level_modelPlan_color[];
extern PRIM level_modelPlan_index[];
extern MATRIX level_modelPlan_matrix;
extern VECTOR level_modelPlan_pos;
extern SVECTOR level_modelPlan_rot;
extern short level_modelPlan_isRigidBody;
extern short level_modelPlan_isStaticBody;
extern short level_modelPlan_isPrism;
extern short level_modelPlan_isAnim;
extern short level_modelPlan_isActor;
extern short level_modelPlan_isLevel;
extern short level_modelPlan_isBG;
extern short level_modelPlan_isSprite;
extern long level_modelPlan_p;
extern long level_modelPlan_OTz;
extern BODY level_modelPlan_body;
extern TMESH level_modelPlan;
extern MESH level_meshPlan;
extern SVECTOR modelSphere_mesh[];
extern SVECTOR level_modelSphere_normal[];
extern SVECTOR level_modelSphere_uv[];
extern CVECTOR level_modelSphere_color[];
extern PRIM level_modelSphere_index[];
extern MATRIX level_modelSphere_matrix;
extern VECTOR level_modelSphere_pos;
extern SVECTOR level_modelSphere_rot;
extern short level_modelSphere_isRigidBody;
extern short level_modelSphere_isStaticBody;
extern short level_modelSphere_isPrism;
extern short level_modelSphere_isAnim;
extern short level_modelSphere_isActor;
extern short level_modelSphere_isLevel;
extern short level_modelSphere_isBG;
extern short level_modelSphere_isSprite;
extern long level_modelSphere_p;
extern long level_modelSphere_OTz;
extern BODY level_modelSphere_body;
extern TMESH level_modelSphere;
extern MESH level_meshSphere;
extern SVECTOR modelSphere_001_mesh[];
extern SVECTOR level_modelSphere_001_normal[];
extern SVECTOR level_modelSphere_001_uv[];
extern CVECTOR level_modelSphere_001_color[];
extern PRIM level_modelSphere_001_index[];
extern MATRIX level_modelSphere_001_matrix;
extern VECTOR level_modelSphere_001_pos;
extern SVECTOR level_modelSphere_001_rot;
extern short level_modelSphere_001_isRigidBody;
extern short level_modelSphere_001_isStaticBody;
extern short level_modelSphere_001_isPrism;
extern short level_modelSphere_001_isAnim;
extern short level_modelSphere_001_isActor;
extern short level_modelSphere_001_isLevel;
extern short level_modelSphere_001_isBG;
extern short level_modelSphere_001_isSprite;
extern long level_modelSphere_001_p;
extern long level_modelSphere_001_OTz;
extern BODY level_modelSphere_001_body;
extern TMESH level_modelSphere_001;
extern MESH level_meshSphere_001;
extern SVECTOR modelwall_mesh[];
extern SVECTOR level_modelwall_normal[];
extern SVECTOR level_modelwall_uv[];
extern CVECTOR level_modelwall_color[];
extern PRIM level_modelwall_index[];
extern MATRIX level_modelwall_matrix;
extern VECTOR level_modelwall_pos;
extern SVECTOR level_modelwall_rot;
extern short level_modelwall_isRigidBody;
extern short level_modelwall_isStaticBody;
extern short level_modelwall_isPrism;
extern short level_modelwall_isAnim;
extern short level_modelwall_isActor;
extern short level_modelwall_isLevel;
extern short level_modelwall_isBG;
extern short level_modelwall_isSprite;
extern long level_modelwall_p;
extern long level_modelwall_OTz;
extern BODY level_modelwall_body;
extern TMESH level_modelwall;
extern MESH level_meshwall;
extern SVECTOR modelwall_001_mesh[];
extern SVECTOR level_modelwall_001_normal[];
extern SVECTOR level_modelwall_001_uv[];
extern CVECTOR level_modelwall_001_color[];
extern PRIM level_modelwall_001_index[];
extern MATRIX level_modelwall_001_matrix;
extern VECTOR level_modelwall_001_pos;
extern SVECTOR level_modelwall_001_rot;
extern short level_modelwall_001_isRigidBody;
extern short level_modelwall_001_isStaticBody;
extern short level_modelwall_001_isPrism;
extern short level_modelwall_001_isAnim;
extern short level_modelwall_001_isActor;
extern short level_modelwall_001_isLevel;
extern short level_modelwall_001_isBG;
extern short level_modelwall_001_isSprite;
extern long level_modelwall_001_p;
extern long level_modelwall_001_OTz;
extern BODY level_modelwall_001_body;
extern TMESH level_modelwall_001;
extern MESH level_meshwall_001;
extern SVECTOR modelwall_002_mesh[];
extern SVECTOR level_modelwall_002_normal[];
extern SVECTOR level_modelwall_002_uv[];
extern CVECTOR level_modelwall_002_color[];
extern PRIM level_modelwall_002_index[];
extern MATRIX level_modelwall_002_matrix;
extern VECTOR level_modelwall_002_pos;
extern SVECTOR level_modelwall_002_rot;
extern short level_modelwall_002_isRigidBody;
extern short level_modelwall_002_isStaticBody;
extern short level_modelwall_002_isPrism;
extern short level_modelwall_002_isAnim;
extern short level_modelwall_002_isActor;
extern short level_modelwall_002_isLevel;
extern short level_modelwall_002_isBG;
extern short level_modelwall_002_isSprite;
extern long level_modelwall_002_p;
extern long level_modelwall_002_OTz;
extern BODY level_modelwall_002_body;
extern TMESH level_modelwall_002;
extern MESH level_meshwall_002;
extern SVECTOR modelwall_003_mesh[];
extern SVECTOR level_modelwall_003_normal[];
extern SVECTOR level_modelwall_003_uv[];
extern CVECTOR level_modelwall_003_color[];
extern PRIM level_modelwall_003_index[];
extern MATRIX level_modelwall_003_matrix;
extern VECTOR level_modelwall_003_pos;
extern SVECTOR level_modelwall_003_rot;
extern short level_modelwall_003_isRigidBody;
extern short level_modelwall_003_isStaticBody;
extern short level_modelwall_003_isPrism;
extern short level_modelwall_003_isAnim;
extern short level_modelwall_003_isActor;
extern short level_modelwall_003_isLevel;
extern short level_modelwall_003_isBG;
extern short level_modelwall_003_isSprite;
extern long level_modelwall_003_p;
extern long level_modelwall_003_OTz;
extern BODY level_modelwall_003_body;
extern TMESH level_modelwall_003;
extern MESH level_meshwall_003;
extern MESH * level_meshes[14];
extern int level_meshes_length;
extern CAMANGLE level_camAngle_camPath_001;
extern CAMANGLE * level_camAngles[0];
extern SIBLINGS level_nodegnd_003_siblings;
extern CHILDREN level_nodegnd_003_objects;
extern CHILDREN level_nodegnd_003_rigidbodies;
extern NODE level_nodegnd_003;
extern SIBLINGS level_nodegnd_001_siblings;
extern CHILDREN level_nodegnd_001_objects;
extern CHILDREN level_nodegnd_001_rigidbodies;
extern NODE level_nodegnd_001;
extern SIBLINGS level_nodegnd_002_siblings;
extern CHILDREN level_nodegnd_002_objects;
extern CHILDREN level_nodegnd_002_rigidbodies;
extern NODE level_nodegnd_002;
extern SIBLINGS level_nodegnd_siblings;
extern CHILDREN level_nodegnd_objects;
extern CHILDREN level_nodegnd_rigidbodies;
extern NODE level_nodegnd;
extern MESH * level_actorPtr;
extern MESH * level_levelPtr;
extern MESH * level_propPtr;
extern CAMANGLE * level_camPtr;
extern NODE * level_curNode;
extern NODE level_nodegnd_003;
extern NODE level_nodegnd_001;
extern NODE level_nodegnd_002;
extern NODE level_nodegnd;

844
main.c

File diff suppressed because it is too large Load Diff

12
math.c
View File

@ -1,10 +1,13 @@
#include "math.h" #include "math.h"
// Stolen from grumpycoder // Stolen from grumpycoder
// this is from here : https://github.com/grumpycoders/Balau/blob/master/tests/test-Handles.cc#L20-L102
static int m_cosTable[512]; // precalc costable // precalc costable
static const unsigned int DC_2PI = 2048; // this is from here : https://github.com/grumpycoders/Balau/blob/master/tests/test-Handles.cc#L20-L102 static int m_cosTable[512];
static const unsigned int DC_2PI = 2048;
static const unsigned int DC_PI = 1024; static const unsigned int DC_PI = 1024;
@ -12,6 +15,7 @@ static const unsigned int DC_PI2 = 512;
// f(n) = cos(n * 2pi / 2048) <- 2048 is == DC_2PI value // f(n) = cos(n * 2pi / 2048) <- 2048 is == DC_2PI value
// f(n) = 2 * f(1) * f(n - 1) - f(n - 2) // f(n) = 2 * f(1) * f(n - 1) - f(n - 2)
void generateTable(void){ void generateTable(void){
m_cosTable[0] = 16777216; // 2^24 * cos(0 * 2pi / 2048) => 2^24 * 1 = 2^24 : here, 2^24 defines the precision we want after the decimal point m_cosTable[0] = 16777216; // 2^24 * cos(0 * 2pi / 2048) => 2^24 * 1 = 2^24 : here, 2^24 defines the precision we want after the decimal point
@ -58,6 +62,7 @@ int ncos(unsigned int t) {
}; };
// sin(x) = cos(x - pi / 2) // sin(x) = cos(x - pi / 2)
int nsin(unsigned int t) { int nsin(unsigned int t) {
t %= DC_2PI; t %= DC_2PI;
@ -71,8 +76,6 @@ int nsin(unsigned int t) {
return ncos(t - DC_PI2); return ncos(t - DC_PI2);
}; };
// https://github.com/Arsunt/TR2Main/blob/411cacb35914c616cb7960c0e677e00c71c7ee88/3dsystem/phd_math.cpp#L432 // https://github.com/Arsunt/TR2Main/blob/411cacb35914c616cb7960c0e677e00c71c7ee88/3dsystem/phd_math.cpp#L432
long long patan(long x, long y){ long long patan(long x, long y){
@ -160,6 +163,7 @@ u_int psqrt(u_int n){
}; };
// From : https://github.com/grumpycoders/pcsx-redux/blob/7438e9995833db5bc1e14da735bbf9dc78300f0b/src/mips/shell/math.h // From : https://github.com/grumpycoders/pcsx-redux/blob/7438e9995833db5bc1e14da735bbf9dc78300f0b/src/mips/shell/math.h
int32_t dMul(int32_t a, int32_t b) { int32_t dMul(int32_t a, int32_t b) {
long long r = a; long long r = a;

View File

@ -1,8 +1,6 @@
#pragma once #pragma once
#include <sys/types.h> #include <sys/types.h>
//~ #include <stddef.h>
//~ #include <stdint.h>
#include <libgte.h> #include <libgte.h>
#include <libgpu.h> #include <libgpu.h>
@ -10,7 +8,10 @@
#include "macros.h" #include "macros.h"
#include "coridor2.h" //~ #ifndef TYPES
#include "custom_types.h"
//~ #define TYPES 1
//~ #endif
short checkLineW( VECTOR * pointA, VECTOR * pointB, MESH * mesh ); short checkLineW( VECTOR * pointA, VECTOR * pointB, MESH * mesh );

1
psx.h
View File

@ -4,6 +4,7 @@
#include <libgte.h> #include <libgte.h>
#include <libgpu.h> #include <libgpu.h>
#include <libetc.h> #include <libetc.h>
#include <libcd.h>
#include "defines.h" #include "defines.h"