Add vertical collisions, slope

This commit is contained in:
ABelliqueux 2021-11-28 19:59:05 +01:00
parent 56a9fa382f
commit d850180727
33 changed files with 1349 additions and 1286 deletions

BIN
3dcam.bin

Binary file not shown.

View File

@ -1,3 +0,0 @@
FILE "3dcam.bin" BINARY
TRACK 01 MODE2/2352
INDEX 01 00:00:00

View File

@ -1,6 +1,15 @@
TARGET = main TARGET = 3dcam
TYPE = ps-exe
.PHONY: all cleansub
all:
mkpsxiso -y ./config/3dcam.xml
cleansub:
$(MAKE) clean
rm -f $(TARGET).cue $(TARGET).bin
rm -f *.mcd *.frag *.lua *.vert
SRCS = src/main.c \ SRCS = src/main.c \
src/pad.c \ src/pad.c \
src/math.c \ src/math.c \

BIN
XA/inter8.xa Normal file

Binary file not shown.

View File

@ -4,6 +4,9 @@ TYPE = ps-exe
THISDIR := $(dir $(abspath $(lastword $(MAKEFILE_LIST)))) THISDIR := $(dir $(abspath $(lastword $(MAKEFILE_LIST))))
SRCS += $(THISDIR)thirdparty/nugget/common/crt0/crt0.s SRCS += $(THISDIR)thirdparty/nugget/common/crt0/crt0.s
SRCS += $(THISDIR)thirdparty/nugget/common/syscalls/printf.s
CPPFLAGS += -I$(THISDIR)include
CPPFLAGS += -I$(THISDIR)thirdparty/nugget/psyq/include -I$(THISDIR)psyq-4_7-converted/include -I$(THISDIR)psyq-4.7-converted-full/include -I$(THISDIR)psyq/include -I$(THISDIR)../psyq/include CPPFLAGS += -I$(THISDIR)thirdparty/nugget/psyq/include -I$(THISDIR)psyq-4_7-converted/include -I$(THISDIR)psyq-4.7-converted-full/include -I$(THISDIR)psyq/include -I$(THISDIR)../psyq/include
LDFLAGS += -L$(THISDIR)thirdparty/nugget/psyq/lib -L$(THISDIR)psyq-4_7-converted/lib -L$(THISDIR)psyq-4.7-converted-full/lib -L$(THISDIR)psyq/lib -L$(THISDIR)../psyq/lib LDFLAGS += -L$(THISDIR)thirdparty/nugget/psyq/lib -L$(THISDIR)psyq-4_7-converted/lib -L$(THISDIR)psyq-4.7-converted-full/lib -L$(THISDIR)psyq/lib -L$(THISDIR)../psyq/lib

View File

@ -13,7 +13,7 @@
<!--<license file="LICENSEE.DAT"/>--> <!--<license file="LICENSEE.DAT"/>-->
<directory_tree> <directory_tree>
<file name="system.cnf" type="data" source="config/3dcam.cnf"/> <file name="system.cnf" type="data" source="config/3dcam.cnf"/>
<file name="SCES_313.37" type="data" source="main.ps-exe"/> <file name="SCES_313.37" type="data" source="3dcam.ps-exe"/>
<file name="LEVEL0.bin" type="data" source="Overlay.lvl0" /> <file name="LEVEL0.bin" type="data" source="Overlay.lvl0" />
<file name="LEVEL1.bin" type="data" source="Overlay.lvl1" /> <file name="LEVEL1.bin" type="data" source="Overlay.lvl1" />
<file name="INTER8.XA" type="xa" source="XA/inter8.xa"/> <file name="INTER8.XA" type="xa" source="XA/inter8.xa"/>

View File

@ -1,9 +1,11 @@
#pragma once #pragma once
#include <sys/types.h> #include <sys/types.h>
#include <libgte.h> #include <libgte.h>
#include <stdint.h>
#include <libgpu.h> #include <libgpu.h>
struct BODY; struct BODY;
struct BVECTOR;
struct VANIM; struct VANIM;
struct MESH_ANIMS_TRACKS; struct MESH_ANIMS_TRACKS;
struct PRIM; struct PRIM;
@ -33,8 +35,15 @@ typedef struct BODY {
VECTOR min; VECTOR min;
VECTOR max; VECTOR max;
int restitution; int restitution;
SVECTOR normal;
} BODY; } BODY;
typedef struct BVECTOR {
int8_t vx, vy;
int8_t vz;
// int8_t factor; // could be useful for anims where delta is > 256
} BVECTOR;
typedef struct VANIM { typedef struct VANIM {
int nframes; // number of frames e.g 20 int nframes; // number of frames e.g 20
int nvert; // number of vertices e.g 21 int nvert; // number of vertices e.g 21
@ -44,7 +53,7 @@ typedef struct VANIM {
int dir; // playback direction (1 or -1) int dir; // playback direction (1 or -1)
int pingpong; // ping pong animation (A>B>A) int pingpong; // ping pong animation (A>B>A)
int interpolate; // use lerp to interpolate keyframes int interpolate; // use lerp to interpolate keyframes
SVECTOR data[]; // vertex pos as SVECTORs e.g 20 * 21 SVECTORS BVECTOR data[]; // vertex pos as SVECTORs e.g 20 * 21 SVECTORS
} VANIM; } VANIM;
typedef struct MESH_ANIMS_TRACKS { typedef struct MESH_ANIMS_TRACKS {

View File

@ -61,7 +61,7 @@
#define FNT_VRAM_X 960 #define FNT_VRAM_X 960
#define FNT_VRAM_Y 256 #define FNT_VRAM_Y 256
#define FNT_SCR_X 16 #define FNT_SCR_X 16
#define FNT_SCR_Y 128 #define FNT_SCR_Y 150
#define FNT_SCR_W 240 #define FNT_SCR_W 240
#define FNT_SCR_H 88 #define FNT_SCR_H 88
#define FNT_SCR_BG 0 #define FNT_SCR_BG 0

View File

@ -1,7 +1,7 @@
#pragma once #pragma once
#include "../include/camera.h" #include <camera.h>
#include "../include/physics.h" #include <physics.h>
#include "../include/defines.h" #include <defines.h>
// Drawing // Drawing
void updateLight(void); void updateLight(void);

View File

@ -3,10 +3,9 @@
#include <stddef.h> #include <stddef.h>
#include <stdint.h> #include <stdint.h>
#include <libgte.h> #include <libgte.h>
#include "../include/macros.h" #include <macros.h>
// Precalculated arctan values // Precalculated arctan values
#include "../src/atan.c" #include <atan.h>
// fixed point math // fixed point math
int32_t dMul(int32_t a, int32_t b); int32_t dMul(int32_t a, int32_t b);

View File

@ -3,16 +3,18 @@
#include <libgte.h> #include <libgte.h>
#include <libetc.h> #include <libetc.h>
#include <libgpu.h> #include <libgpu.h>
#include "../include/defines.h" #include <defines.h>
#include "../include/math.h" #include <math.h>
#include "../include/macros.h" #include <macros.h>
#include "../custom_types.h" #include <custom_types.h>
#include "../thirdparty/nugget/common/syscalls/syscalls.h"
#define printf ramsyscall_printf
short checkLineW( VECTOR * pointA, VECTOR * pointB, MESH * mesh ); short checkLineW( VECTOR * pointA, VECTOR * pointB, MESH * mesh );
short checkLineS( VECTOR * pointA, VECTOR * pointB, MESH * mesh ); short checkLineS( VECTOR * pointA, VECTOR * pointB, MESH * mesh );
VECTOR getIntCollision(BODY one, BODY two); VECTOR getIntCollision(BODY one, BODY two);
VECTOR getExtCollision(BODY one, BODY two); VECTOR getExtCollision(BODY one, BODY two);
void checkBodyCol(BODY * one, BODY * two); VECTOR checkBodyCol(BODY * one, BODY * two);
void applyAngMom(LEVEL curLvl ); void applyAngMom(LEVEL curLvl );
void ResolveCollision( BODY * one, BODY * two ); void ResolveCollision( BODY * one, BODY * two );
VECTOR angularMom(BODY body); VECTOR angularMom(BODY body);

View File

@ -10,9 +10,11 @@
#include <string.h> #include <string.h>
#include <inline_n.h> #include <inline_n.h>
#include <gtemac.h> #include <gtemac.h>
#include "../include/defines.h" #include <defines.h>
#include <stdint.h> #include <stdint.h>
#include "../custom_types.h" #include <custom_types.h>
#include "../thirdparty/nugget/common/syscalls/syscalls.h"
#define printf ramsyscall_printf
// PSX setup // PSX setup
void setDCLightEnv(MATRIX * curLevelCMat, MATRIX * curLevelLgtMat, SVECTOR * curLevelLgtAng); void setDCLightEnv(MATRIX * curLevelCMat, MATRIX * curLevelLgtMat, SVECTOR * curLevelLgtAng);

View File

@ -1,8 +1,8 @@
#pragma once #pragma once
#include "../include/psx.h" #include <psx.h>
#include "../include/camera.h" #include <camera.h>
#include "../include/math.h" #include <math.h>
#include "../include/macros.h" #include <macros.h>
// XA // XA
// Sector offset for XA data 4: simple speed, 8: double speed // Sector offset for XA data 4: simple speed, 8: double speed
#define XA_CHANNELS 8 #define XA_CHANNELS 8

View File

@ -2,7 +2,7 @@
#include <sys/types.h> #include <sys/types.h>
#include <libgte.h> #include <libgte.h>
#include <libgpu.h> #include <libgpu.h>
#include "../include/defines.h" #include <defines.h>
int cliptest3(short * v1); int cliptest3(short * v1);
void worldToScreen( VECTOR * worldPos, VECTOR * screenPos ); void worldToScreen( VECTOR * worldPos, VECTOR * screenPos );

View File

@ -1,2 +1,2 @@
#!/bin/bash #!/bin/bash
make && ~/bin/mkpsxiso -y config/3dcam.xml && pcsx-redux -run -iso 3dcam.cue make && ~/bin/mkpsxiso -y config/3dcam.xml && prime-run pcsx-redux -run -iso 3dcam.cue

File diff suppressed because it is too large Load Diff

View File

@ -1,16 +1,16 @@
#pragma once #pragma once
#include "../custom_types.h" #include <custom_types.h>
#include "../include/defines.h" #include <defines.h>
extern LEVEL level0; extern LEVEL level0;
extern CVECTOR level0_BGc; extern CVECTOR level0_BGc;
extern VECTOR level0_BKc; extern VECTOR level0_BKc;
extern MESH_ANIMS_TRACKS level0_modelCube_001_anims; extern MESH_ANIMS_TRACKS level0_modelCube_001_anims;
extern VANIM level0_modelCube_001_anim_KeyAction;
extern VANIM level0_modelCube_001_anim_KeyAction_004;
extern VANIM level0_modelCube_001_anim_KeyAction_003; extern VANIM level0_modelCube_001_anim_KeyAction_003;
extern VANIM level0_modelCube_001_anim_KeyAction_001; extern VANIM level0_modelCube_001_anim_KeyAction_001;
extern VANIM level0_modelCube_001_anim_KeyAction_002; extern VANIM level0_modelCube_001_anim_KeyAction_002;
extern VANIM level0_modelCube_001_anim_KeyAction;
extern VANIM level0_modelCube_001_anim_KeyAction_004;
extern CAMPOS level0_camPos_Camera; extern CAMPOS level0_camPos_Camera;
extern CAMPATH level0_camPath; extern CAMPATH level0_camPath;
extern MATRIX level0_lgtmat; extern MATRIX level0_lgtmat;

View File

@ -2607,8 +2607,8 @@ BODY level1_modelCube_body = {
0,899,0, 0, 0,899,0, 0,
5, 5,
ONE/5, ONE/5,
-45,-23,-27, 0, -35,-13,-17, 0,
42,31,26, 0, 32,21,16, 0,
1024, 1024,
}; };
@ -2984,8 +2984,8 @@ BODY level1_modelCylindre_body = {
0,0,0, 0, 0,0,0, 0,
20, 20,
ONE/20, ONE/20,
-38,-30,-36, 0, -28,-20,-26, 0,
39,35,41, 0, 29,35,31, 0,
0, 0,
}; };
@ -10744,7 +10744,7 @@ PRIM level1_modelSphere_index[] = {
BODY level1_modelSphere_body = { BODY level1_modelSphere_body = {
{0, 0, 0, 0}, {0, 0, 0, 0},
-495,-129,16, 0, -405,-109,16, 0,
0,0,0, 0, 0,0,0, 0,
10, 10,
ONE/10, ONE/10,
@ -10768,7 +10768,7 @@ MESH level1_meshSphere = {
&level1_tim_home, &level1_tim_home,
_binary_TIM_home_tim_start, _binary_TIM_home_tim_start,
{0}, // Matrix {0}, // Matrix
{-495,-129,16, 0}, // position {-405,-109,16, 0}, // position
{0,0,0, 0}, // rotation {0,0,0, 0}, // rotation
0, // isProp 0, // isProp
1, // isRigidBody 1, // isRigidBody
@ -11211,7 +11211,7 @@ PRIM level1_modelSphere_001_index[] = {
BODY level1_modelSphere_001_body = { BODY level1_modelSphere_001_body = {
{0, 0, 0, 0}, {0, 0, 0, 0},
44,-73,92, 0, 144,-73,92, 0,
0,0,0, 0, 0,0,0, 0,
5, 5,
ONE/5, ONE/5,
@ -11235,7 +11235,7 @@ MESH level1_meshSphere_001 = {
&level1_tim_home, &level1_tim_home,
_binary_TIM_home_tim_start, _binary_TIM_home_tim_start,
{0}, // Matrix {0}, // Matrix
{44,-73,92, 0}, // position {144,-73,92, 0}, // position
{0,0,0, 0}, // rotation {0,0,0, 0}, // rotation
1, // isProp 1, // isProp
1, // isRigidBody 1, // isRigidBody

View File

@ -1,6 +1,6 @@
#pragma once #pragma once
#include "../custom_types.h" #include <custom_types.h>
#include "../include/defines.h" #include <defines.h>
extern LEVEL level1; extern LEVEL level1;
extern CVECTOR level1_BGc; extern CVECTOR level1_BGc;

View File

@ -14,20 +14,20 @@ SECTIONS {
KEEP(levels/level0.o(.text.startup._GLOBAL__*)) KEEP(levels/level0.o(.text.startup._GLOBAL__*))
KEEP(levels/level0.o(.text.*)) KEEP(levels/level0.o(.text.*))
KEEP(levels/level0.o(.rodata*)) KEEP(levels/level0.o(.rodata*))
KEEP(levels/level0.o(.sdata*)) KEEP(levels/level0.o(.sdata*))
KEEP(levels/level0.o(.data*)) KEEP(levels/level0.o(.data*))
KEEP(levels/level0.o(.sbss*)) KEEP(levels/level0.o(.sbss*))
KEEP(levels/level0.o(.bss*)) KEEP(levels/level0.o(.bss*))
KEEP(levels/level0.o(.ctors)) KEEP(levels/level0.o(.ctors))
/*KEEP(TIM/bg_camPath_*.o(.text)) /*KEEP(TIM/bg_camPath_*.o(.text))
__lvl0_ctor = .; __lvl0_ctor = .;
KEEP(TIM/bg_camPath_*.o(.text.startup._GLOBAL__*)) KEEP(TIM/bg_camPath_*.o(.text.startup._GLOBAL__*))
KEEP(TIM/bg_camPath_*.o(.text.*)) KEEP(TIM/bg_camPath_*.o(.text.*))
KEEP(TIM/bg_camPath_*.o(.rodata*)) KEEP(TIM/bg_camPath_*.o(.rodata*))
KEEP(TIM/bg_camPath_*.o(.sdata*)) KEEP(TIM/bg_camPath_*.o(.sdata*))
KEEP(TIM/bg_camPath_*.o(.data*)) KEEP(TIM/bg_camPath_*.o(.data*))
KEEP(TIM/bg_camPath_*.o(.sbss*)) KEEP(TIM/bg_camPath_*.o(.sbss*))
KEEP(TIM/bg_camPath_*.o(.bss*)) KEEP(TIM/bg_camPath_*.o(.bss*))
KEEP(TIM/bg_camPath_*.o(.ctors)) KEEP(TIM/bg_camPath_*.o(.ctors))
*/ */
@ -42,9 +42,9 @@ SECTIONS {
KEEP(levels/level1.o(.text.startup._GLOBAL__*)) KEEP(levels/level1.o(.text.startup._GLOBAL__*))
KEEP(levels/level1.o(.text.*)) KEEP(levels/level1.o(.text.*))
KEEP(levels/level1.o(.rodata*)) KEEP(levels/level1.o(.rodata*))
KEEP(levels/level1.o(.sdata*)) KEEP(levels/level1.o(.sdata*))
KEEP(levels/level1.o(.data*)) KEEP(levels/level1.o(.data*))
KEEP(levels/level1.o(.sbss*)) KEEP(levels/level1.o(.sbss*))
KEEP(levels/level1.o(.bss*)) KEEP(levels/level1.o(.bss*))
KEEP(levels/level1.o(.ctors)) KEEP(levels/level1.o(.ctors))

View File

@ -1,31 +0,0 @@
#!/bin/bash
# Path to nops executable
NOPS="nops"
if [ $# -eq 0 ]
then
echo "PSX Overlay Upload helper script
Upload a binary and the corresponding executable to a real PSX memory, via unirom + serial cable.
This script is dependant on NOTpsxserial being available on your system : https://github.com/JonathanDotCel/NOTPSXSerial
Edit the $NOPS value to reflect the executable path on your system, e.g :
\$NOPS = '/blah/nops'
Usage : ./ovly_upload_helper.sh bin_filename psx_exe_name com_port
- bin_filename , eg : Overlay.lvl0
- psx_exe_name, e.g : main.ps-exe
- com_port, e.g : /dev/ttyUSB0, COM1
"
else
# Find map file corresponding to ps-exe
MAP_FILE="`echo $2 | awk -F. '{print $1}'`.map"
# Find loading address
LOAD_ADDR="0x`cat $MAP_FILE | grep load_all_overlays_here | awk '{print $1}' | cut -c 11-`"
$NOPS /debug $3
$NOPS /fast /bin $LOAD_ADDR $1 $3
$NOPS /fast /exe $2 $3
$NOPS /slow $3
fi

View File

@ -1,8 +1,8 @@
#include "../include/psx.h" #include <psx.h>
#include "../include/camera.h" #include <camera.h>
#include "../include/math.h" #include <math.h>
#include "../include/physics.h" #include <physics.h>
#include "../include/space.h" #include <space.h>
void getCameraXZ(int * x, int * z, int actorX, int actorZ, int angle, int distance) { void getCameraXZ(int * x, int * z, int actorX, int actorZ, int angle, int distance) {
// Using Nic's Costable : https://github.com/grumpycoders/Balau/blob/master/tests/test-Handles.cc#L20-L102 // Using Nic's Costable : https://github.com/grumpycoders/Balau/blob/master/tests/test-Handles.cc#L20-L102

View File

@ -1,7 +1,7 @@
#include "../include/psx.h" #include <psx.h>
#include "../include/graphics.h" #include <graphics.h>
#include "../include/math.h" #include <math.h>
#include "../include/CPUMAC.H" #include <CPUMAC.H>
void updateLight(void){ void updateLight(void){
RotMatrix_gte(dc_lgtangp, dc_lgtmatp); RotMatrix_gte(dc_lgtangp, dc_lgtmatp);
@ -79,9 +79,18 @@ void set3VertexLerPos(MESH * mesh, long t){
}; };
void set3VertexPos(MESH * mesh, long t, int atime){ void set3VertexPos(MESH * mesh, long t, int atime){
// Set vertices according to anim // Set vertices according to anim
mesh->tmesh->v[ mesh->index[ t ].order.vx ] = mesh->currentAnim->data[ atime % mesh->currentAnim->nframes * mesh->currentAnim->nvert + mesh->index[t].order.vx ]; mesh->tmesh->v[ mesh->index[ t ].order.vx ].vx = mesh->currentAnim->data[ atime % mesh->currentAnim->nframes * mesh->currentAnim->nvert + mesh->index[t].order.vx ].vx;
mesh->tmesh->v[ mesh->index[ t ].order.vz ] = mesh->currentAnim->data[ atime % mesh->currentAnim->nframes * mesh->currentAnim->nvert + mesh->index[t].order.vz ]; mesh->tmesh->v[ mesh->index[ t ].order.vx ].vy = mesh->currentAnim->data[ atime % mesh->currentAnim->nframes * mesh->currentAnim->nvert + mesh->index[t].order.vx ].vy;
mesh->tmesh->v[ mesh->index[ t ].order.vy ] = mesh->currentAnim->data[ atime % mesh->currentAnim->nframes * mesh->currentAnim->nvert + mesh->index[t].order.vy ]; mesh->tmesh->v[ mesh->index[ t ].order.vx ].vz = mesh->currentAnim->data[ atime % mesh->currentAnim->nframes * mesh->currentAnim->nvert + mesh->index[t].order.vx ].vz;
mesh->tmesh->v[ mesh->index[ t ].order.vz ].vx = mesh->currentAnim->data[ atime % mesh->currentAnim->nframes * mesh->currentAnim->nvert + mesh->index[t].order.vz ].vx;
mesh->tmesh->v[ mesh->index[ t ].order.vz ].vy = mesh->currentAnim->data[ atime % mesh->currentAnim->nframes * mesh->currentAnim->nvert + mesh->index[t].order.vz ].vy;
mesh->tmesh->v[ mesh->index[ t ].order.vz ].vz = mesh->currentAnim->data[ atime % mesh->currentAnim->nframes * mesh->currentAnim->nvert + mesh->index[t].order.vz ].vz;
mesh->tmesh->v[ mesh->index[ t ].order.vy ].vx = mesh->currentAnim->data[ atime % mesh->currentAnim->nframes * mesh->currentAnim->nvert + mesh->index[t].order.vy ].vx;
mesh->tmesh->v[ mesh->index[ t ].order.vy ].vy = mesh->currentAnim->data[ atime % mesh->currentAnim->nframes * mesh->currentAnim->nvert + mesh->index[t].order.vy ].vy;
mesh->tmesh->v[ mesh->index[ t ].order.vy ].vz = mesh->currentAnim->data[ atime % mesh->currentAnim->nframes * mesh->currentAnim->nvert + mesh->index[t].order.vy ].vz;
} }
void set4VertexLerPos(MESH * mesh, long t){ void set4VertexLerPos(MESH * mesh, long t){
// Find and set 4 interpolated vertex value // Find and set 4 interpolated vertex value
@ -108,10 +117,31 @@ void set4VertexLerPos(MESH * mesh, long t){
} }
void set4VertexPos(MESH * mesh, long t, int atime){ void set4VertexPos(MESH * mesh, long t, int atime){
// Set vertices according to anim // Set vertices according to anim
mesh->tmesh->v[ mesh->index[ t ].order.vx ] = mesh->currentAnim->data[ atime % mesh->currentAnim->nframes * mesh->currentAnim->nvert + mesh->index[t].order.vx ]; // TODO : fix using delta animation
mesh->tmesh->v[ mesh->index[ t ].order.vz ] = mesh->currentAnim->data[ atime % mesh->currentAnim->nframes * mesh->currentAnim->nvert + mesh->index[t].order.vz ]; //~ SVECTOR x, y, z, pad;
mesh->tmesh->v[ mesh->index[ t ].order.vy ] = mesh->currentAnim->data[ atime % mesh->currentAnim->nframes * mesh->currentAnim->nvert + mesh->index[t].order.vy ]; //~ addVector2(&mesh->tmesh->v[ mesh->index[ t ].order.vx ], &mesh->currentAnim->data[ atime % mesh->currentAnim->nframes * mesh->currentAnim->nvert + mesh->index[t].order.vx ], &x );
mesh->tmesh->v[ mesh->index[ t ].order.pad ] = mesh->currentAnim->data[ atime % mesh->currentAnim->nframes * mesh->currentAnim->nvert + mesh->index[t].order.pad ]; //~ addVector2(&mesh->tmesh->v[ mesh->index[ t ].order.vz ], &mesh->currentAnim->data[ atime % mesh->currentAnim->nframes * mesh->currentAnim->nvert + mesh->index[t].order.vz ], &z );
//~ addVector2(&mesh->tmesh->v[ mesh->index[ t ].order.vy ], &mesh->currentAnim->data[ atime % mesh->currentAnim->nframes * mesh->currentAnim->nvert + mesh->index[t].order.vy ], &y );
//~ addVector2(&mesh->tmesh->v[ mesh->index[ t ].order.pad ], &mesh->currentAnim->data[ atime % mesh->currentAnim->nframes * mesh->currentAnim->nvert + mesh->index[t].order.pad ], &pad );
//~ mesh->tmesh->v[ mesh->index[ t ].order.vx ] = x;
//~ mesh->tmesh->v[ mesh->index[ t ].order.vz ] = z;
//~ mesh->tmesh->v[ mesh->index[ t ].order.vy ] = y;
//~ mesh->tmesh->v[ mesh->index[ t ].order.pad ] = pad;
mesh->tmesh->v[ mesh->index[ t ].order.vx ].vx = mesh->currentAnim->data[ atime % mesh->currentAnim->nframes * mesh->currentAnim->nvert + mesh->index[t].order.vx ].vx;
mesh->tmesh->v[ mesh->index[ t ].order.vx ].vy = mesh->currentAnim->data[ atime % mesh->currentAnim->nframes * mesh->currentAnim->nvert + mesh->index[t].order.vx ].vy;
mesh->tmesh->v[ mesh->index[ t ].order.vx ].vz = mesh->currentAnim->data[ atime % mesh->currentAnim->nframes * mesh->currentAnim->nvert + mesh->index[t].order.vx ].vz;
mesh->tmesh->v[ mesh->index[ t ].order.vz ].vx = mesh->currentAnim->data[ atime % mesh->currentAnim->nframes * mesh->currentAnim->nvert + mesh->index[t].order.vz ].vx;
mesh->tmesh->v[ mesh->index[ t ].order.vz ].vy = mesh->currentAnim->data[ atime % mesh->currentAnim->nframes * mesh->currentAnim->nvert + mesh->index[t].order.vz ].vy;
mesh->tmesh->v[ mesh->index[ t ].order.vz ].vz = mesh->currentAnim->data[ atime % mesh->currentAnim->nframes * mesh->currentAnim->nvert + mesh->index[t].order.vz ].vz;
mesh->tmesh->v[ mesh->index[ t ].order.vy ].vx = mesh->currentAnim->data[ atime % mesh->currentAnim->nframes * mesh->currentAnim->nvert + mesh->index[t].order.vy ].vx;
mesh->tmesh->v[ mesh->index[ t ].order.vy ].vy = mesh->currentAnim->data[ atime % mesh->currentAnim->nframes * mesh->currentAnim->nvert + mesh->index[t].order.vy ].vy;
mesh->tmesh->v[ mesh->index[ t ].order.vy ].vz = mesh->currentAnim->data[ atime % mesh->currentAnim->nframes * mesh->currentAnim->nvert + mesh->index[t].order.vy ].vz;
mesh->tmesh->v[ mesh->index[ t ].order.pad ].vx = mesh->currentAnim->data[ atime % mesh->currentAnim->nframes * mesh->currentAnim->nvert + mesh->index[t].order.pad ].vx;
mesh->tmesh->v[ mesh->index[ t ].order.pad ].vy = mesh->currentAnim->data[ atime % mesh->currentAnim->nframes * mesh->currentAnim->nvert + mesh->index[t].order.pad ].vy;
mesh->tmesh->v[ mesh->index[ t ].order.pad ].vz = mesh->currentAnim->data[ atime % mesh->currentAnim->nframes * mesh->currentAnim->nvert + mesh->index[t].order.pad ].vz;
} }
void interpolateTri(POLY_GT3 * poly, MESH * mesh, long t){ void interpolateTri(POLY_GT3 * poly, MESH * mesh, long t){
long Flag, nclip = 0; long Flag, nclip = 0;

View File

@ -16,15 +16,16 @@
* eye */ * eye */
// Blender debug mode // Blender debug mode
// bpy. app. debug = True // bpy. app. debug = True
#include "../include/psx.h" #include <psx.h>
#include "../include/pad.h" #include <pad.h>
#include "../include/math.h" #include <math.h>
#include "../include/camera.h" #include <camera.h>
#include "../include/physics.h" #include <physics.h>
#include "../include/graphics.h" #include <graphics.h>
#include "../include/space.h" #include <space.h>
#include "../include/sound.h" #include <sound.h>
//~ #include "../thirdparty/nugget/common/syscalls/syscalls.h"
//~ #define printf ramsyscall_printf
#define USECD #define USECD
// START OVERLAY // START OVERLAY
@ -196,6 +197,7 @@ int main() {
// Main loop // Main loop
//~ while ( VSync(VSYNC) ) { //~ while ( VSync(VSYNC) ) {
while ( 1 ) { while ( 1 ) {
printf("Let's go!");
dt = GetRCnt(RCntCNT1) - oldTime; dt = GetRCnt(RCntCNT1) - oldTime;
oldTime = GetRCnt(RCntCNT1); oldTime = GetRCnt(RCntCNT1);
// XA playback (keep track of playback and loop XA) // XA playback (keep track of playback and loop XA)
@ -251,11 +253,11 @@ int main() {
atime ++; atime ++;
} }
// Reset player/prop pos // Reset player/prop pos
if(curLvl.actorPtr->pos.vy >= 200){ if(curLvl.actorPtr->pos.vy >= curLvl.levelPtr->body->max.vy + 200){
playSFX(&voiceAttributes, curLvl.levelSounds->sounds[6]->VAGsample, curLvl.levelSounds->sounds[6]->volumeL, curLvl.levelSounds->sounds[6]->volumeR); playSFX(&voiceAttributes, curLvl.levelSounds->sounds[6]->VAGsample, curLvl.levelSounds->sounds[6]->volumeL, curLvl.levelSounds->sounds[6]->volumeR);
respawnMesh(&curLvl, curLvl.actorPtr, &actorStartRot, &actorStartPos, actorStartNode ); respawnMesh(&curLvl, curLvl.actorPtr, &actorStartRot, &actorStartPos, actorStartNode );
} }
if(curLvl.propPtr->pos.vy >= 200){ if(curLvl.propPtr->pos.vy >= curLvl.levelPtr->body->max.vy + 200){
playSFX(&voiceAttributes, curLvl.levelSounds->sounds[3]->VAGsample, curLvl.levelSounds->sounds[3]->volumeL, curLvl.levelSounds->sounds[3]->volumeR); playSFX(&voiceAttributes, curLvl.levelSounds->sounds[3]->VAGsample, curLvl.levelSounds->sounds[3]->volumeL, curLvl.levelSounds->sounds[3]->volumeR);
respawnMesh(&curLvl, curLvl.propPtr, &propStartRot, &propStartPos, propStartNode ); respawnMesh(&curLvl, curLvl.propPtr, &propStartRot, &propStartPos, propStartNode );
} }
@ -308,26 +310,37 @@ int main() {
// Get col between actor and level // Get col between actor and level
if ( curLvl.meshes[k]->isActor ){ if ( curLvl.meshes[k]->isActor ){
// Check col // Check col
checkBodyCol( curLvl.meshes[k]->body , curLvl.levelPtr->body ); VECTOR colLvl = checkBodyCol( curLvl.meshes[k]->body , curLvl.levelPtr->body );
FntPrint("ColLvl: %d %d %d\n", colLvl.vz, colLvl.vx, colLvl.vy);
// Get col between actor and current node's walls // Get col between actor and current node's walls
// Loop on current node's objects // Loop on current node's objects
for (short obj=0; obj < curLvl.curNode->objects->index; obj++){ for (short obj=0; obj < curLvl.curNode->objects->index; obj++){
VECTOR col = getExtCollision( *curLvl.meshes[k]->body, *curLvl.curNode->objects->list[obj]->body );
// If isWall, check collision // If isWall, check collision
if ( curLvl.curNode->objects->list[obj]->isWall ){ //~ if ( curLvl.curNode->objects->list[obj]->isWall){
if( getExtCollision( *curLvl.meshes[k]->body, *curLvl.curNode->objects->list[obj]->body ).vz && //~ if( col.vz && col.vx) {
getExtCollision( *curLvl.meshes[k]->body, *curLvl.curNode->objects->list[obj]->body ).vx) { //~ curLvl.meshes[k]->body->position.vz = curLvl.meshes[k]->body->position.vz - curLvl.meshes[k]->body->velocity.vz ;
curLvl.meshes[k]->body->position.vz = curLvl.meshes[k]->body->position.vz - curLvl.meshes[k]->body->velocity.vz ; //~ curLvl.meshes[k]->body->position.vx = curLvl.meshes[k]->body->position.vx - curLvl.meshes[k]->body->velocity.vx ;
curLvl.meshes[k]->body->position.vx = curLvl.meshes[k]->body->position.vx - curLvl.meshes[k]->body->velocity.vx ; //~ }
//~ }
if ( curLvl.curNode->objects->list[obj]->isStaticBody ){
FntPrint("Col : %d %d %d\n", col.vz, col.vx, col.vy);
if( col.vz && col.vx && col.vy ) {
if (!colLvl.vy) {
curLvl.meshes[k]->body->position.vz = curLvl.meshes[k]->body->position.vz - curLvl.meshes[k]->body->velocity.vz ;
curLvl.meshes[k]->body->position.vx = curLvl.meshes[k]->body->position.vx - curLvl.meshes[k]->body->velocity.vx ;
}
curLvl.meshes[k]->body->position.vy = curLvl.meshes[k]->body->position.vy - curLvl.meshes[k]->body->velocity.vy ;
} }
} }
} }
} }
// Only evaluate collision if actor is on same plane as prop // Only evaluate collision if actor is on same plane as prop
if ( curLvl.curNode == curLvl.propPtr->node ){ if ( curLvl.curNode == curLvl.propPtr->node ){
// Get col between actor and props // Get col between actor and props
col = getExtCollision( *curLvl.meshes[k]->body, *curLvl.propPtr->body ); VECTOR col = getExtCollision( *curLvl.meshes[k]->body, *curLvl.propPtr->body );
if (col.vx && col.vz && canMove == 1 ) { if (col.vx && col.vz && col.vy && canMove == 1 ) {
setVector( &curLvl.propPtr->body->velocity, setVector( &curLvl.propPtr->body->velocity,
curLvl.meshes[k]->body->velocity.vx, curLvl.meshes[k]->body->velocity.vx,
0, 0,
@ -374,7 +387,8 @@ int main() {
curLvl.actorPtr->pos.vy, curLvl.actorPtr->pos.vy,
curLvl.actorPtr->pos.vz - (ncos(curLvl.actorPtr->rot.vy/2)) curLvl.actorPtr->pos.vz - (ncos(curLvl.actorPtr->rot.vy/2))
); );
curLvl.levelPtr->body->normal = curLvl.levelPtr->tmesh->n[0];
// Add secondary OT to main OT // Add secondary OT to main OT
AddPrims(otdisc[db], ot[db] + OTLEN - 1, ot[db]); AddPrims(otdisc[db], ot[db] + OTLEN - 1, ot[db]);
@ -383,11 +397,13 @@ int main() {
//~ FntPrint("Dt : %d %d %d\n", 400/(dt+1), (XA_CDSPEED)/((400/(dt+1))+1), (curLvl.XA->samples[sample].end - curLvl.XA->samples[sample].start)<<12); //~ FntPrint("Dt : %d %d %d\n", 400/(dt+1), (XA_CDSPEED)/((400/(dt+1))+1), (curLvl.XA->samples[sample].end - curLvl.XA->samples[sample].start)<<12);
//~ FntPrint("XA : %d\n", (XA_CDSPEED)/((400/(dt+1))+1) ); //~ FntPrint("XA : %d\n", (XA_CDSPEED)/((400/(dt+1))+1) );
//~ FntPrint("XA : %d\n", curLvl.XA->samples[sample].cursor ); //~ FntPrint("XA : %d\n", curLvl.XA->samples[sample].cursor );
FntPrint("CamAngle : %d\n", curCamAngle); FntPrint("CamAngle : %d\n", curCamAngle );
FntPrint("fVector : %d %d %d\n", fVecActor.vx, fVecActor.vy, fVecActor.vz );
//~ FntPrint("XA: %x\n", curLvl.XA); //~ FntPrint("XA: %x\n", curLvl.XA);
//~ FntPrint("Ofst: %d\n", curLvl.XA->banks[0]->offset); //~ FntPrint("Ofst: %d\n", curLvl.XA->banks[0]->offset);
//~ FntPrint("Vol: %d %d\n", curLvl.levelSounds->sounds[0]->volumeL, curLvl.levelSounds->sounds[0]->volumeR ); //~ FntPrint("Vol: %d %d\n", curLvl.levelSounds->sounds[0]->volumeL, curLvl.levelSounds->sounds[0]->volumeR );
FntPrint("Curanim : %x\n", curLvl.meshes[1]->currentAnim); FntPrint("Curanim : %x\n", curLvl.meshes[1]->currentAnim);
FntPrint("Gforce: %d", curLvl.actorPtr->body->gForce.vy);
//~ FntPrint("Anims : %x %x", curLvl.meshes[1]->anim_tracks->strips[3], curLvl.meshes[1]->anim_tracks->strips[4]); //~ FntPrint("Anims : %x %x", curLvl.meshes[1]->anim_tracks->strips[3], curLvl.meshes[1]->anim_tracks->strips[4]);
FntFlush(-1); FntFlush(-1);
display( &disp[db], &draw[db], otdisc[db], primbuff[db], &nextpri, &db); display( &disp[db], &draw[db], otdisc[db], primbuff[db], &nextpri, &db);
@ -493,9 +509,10 @@ void callback() {
lastPad = PAD; lastPad = PAD;
} }
if ( PAD & Cross && !(lastPad & Cross) ){ if ( PAD & Cross && !(lastPad & Cross) ){
if (curLvl.actorPtr->body->gForce.vy == 0 && (curLvl.actorPtr->body->position.vy - curLvl.actorPtr->body->min.vy) == curLvl.levelPtr->body->min.vy ){ //~ if (curLvl.actorPtr->body->gForce.vy == 0 && (curLvl.actorPtr->body->position.vy - curLvl.actorPtr->body->min.vy) == curLvl.levelPtr->body->min.vy ){
if (curLvl.actorPtr->body->gForce.vy == 0){
// Use delta to find jump force // Use delta to find jump force
curLvl.actorPtr->body->gForce.vy = -200; curLvl.actorPtr->body->gForce.vy = -300;
} }
timer = 10; timer = 10;
playSFX(&voiceAttributes, curLvl.levelSounds->sounds[4]->VAGsample, curLvl.levelSounds->sounds[4]->volumeL, curLvl.levelSounds->sounds[4]->volumeR ); playSFX(&voiceAttributes, curLvl.levelSounds->sounds[4]->VAGsample, curLvl.levelSounds->sounds[4]->volumeL, curLvl.levelSounds->sounds[4]->volumeR );

View File

@ -1,4 +1,4 @@
#include "../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 // this is from here : https://github.com/grumpycoders/Balau/blob/master/tests/test-Handles.cc#L20-L102

View File

@ -1,4 +1,4 @@
#include "../include/pad.h" #include <pad.h>
void get_digital_direction( Controller_Data *c, int buttondata ) // get analog stick values void get_digital_direction( Controller_Data *c, int buttondata ) // get analog stick values
{ {

View File

@ -1,4 +1,4 @@
#include "../include/pcdrv.h" #include <pcdrv.h>
int waitForSIODone( int * flag ){ int waitForSIODone( int * flag ){
// This should wait for a signal from the SIO to tell when it's done // This should wait for a signal from the SIO to tell when it's done

View File

@ -1,4 +1,4 @@
#include "../include/physics.h" #include <physics.h>
short checkLineW( VECTOR * pointA, VECTOR * pointB, MESH * mesh ) { short checkLineW( VECTOR * pointA, VECTOR * pointB, MESH * mesh ) {
long val1 = ( ( mesh->body->position.vx + mesh->body->min.vx ) - pointA->vx ) * ( pointB->vy - pointA->vy ) - ( ( mesh->body->position.vz + mesh->body->min.vy ) - pointA->vy ) * ( pointB->vx - pointA->vx ) ; long val1 = ( ( mesh->body->position.vx + mesh->body->min.vx ) - pointA->vx ) * ( pointB->vy - pointA->vy ) - ( ( mesh->body->position.vz + mesh->body->min.vy ) - pointA->vy ) * ( pointB->vx - pointA->vx ) ;
@ -87,7 +87,7 @@ VECTOR getIntCollision(BODY one, BODY two){
d2.vy = (two.position.vy + two.max.vy) - (one.position.vy + one.min.vy); d2.vy = (two.position.vy + two.max.vy) - (one.position.vy + one.min.vy);
d2.vz = (two.position.vz + two.max.vz) - (one.position.vz - one.max.vz); d2.vz = (two.position.vz + two.max.vz) - (one.position.vz - one.max.vz);
col.vx = !(d1.vx > 0 && d2.vx > 0); col.vx = !(d1.vx > 0 && d2.vx > 0);
col.vy = d1.vy > 0 && d2.vy > 0; col.vy = !(d1.vy > 0 && d2.vy > 0);
col.vz = !(d1.vz > 0 && d2.vz > 0); col.vz = !(d1.vz > 0 && d2.vz > 0);
return col; return col;
}; };
@ -104,20 +104,39 @@ VECTOR getExtCollision(BODY one, BODY two){
col.vz = d1.vz > 0 && d2.vz > 0; col.vz = d1.vz > 0 && d2.vz > 0;
return col; return col;
}; };
void checkBodyCol(BODY * one, BODY * two){ VECTOR checkBodyCol(BODY * one, BODY * two){
VECTOR colInt, colExt; VECTOR colInt;
colInt = getIntCollision( *one , *two ); colInt = getIntCollision( *one , *two );
//~ colExt = getExtCollision( *one , *two );
// If collisiton on Y axis, // If collisiton on Y axis,
if ( colInt.vy ) { if ( !(colInt.vy) ) {
// and above plane // and above plane
if ( !colInt.vx && !colInt.vz ) { if ( !colInt.vx && !colInt.vz ) {
// collide // collide
one->position.vy = two->max.vy - one->max.vy ; short slopeX = two->normal.vx > 0 ? 1 : -1;
//~ short slopeZ = two->normal.vz > 0 ? 1 : -1;
long o = two->max.vy - two->min.vy ;
long a = two->max.vx - two->min.vx;
long aa = (two->position.vx + two->min.vx) - (one->position.vx + one->min.vx) ;
//~ long b = two->max.vz - two->min.vz;
//~ long ab = (two->position.vz + two->min.vz) - (one->position.vz + one->min.vz) ;
// Avoid div/0
if (a){
long y = (( (slopeX * o) * ONE) / a) * aa;
// long y = (( (slopeZ * o) * ONE) / b) * ab;
// FntPrint("sly: %d", y >> 12);
if (y) {
one->position.vy = (y >> 12) - ( slopeX < 0 ? 128 : 0 );
// one->position.vy = (y >> 12) - ( slopeZ < 0 ? 64 : 0 ) ;
} else {
one->position.vy = two->max.vy - one->max.vy;
}
}
one->velocity.vy = 0; one->velocity.vy = 0;
two->velocity.vy = 0; two->velocity.vy = 0;
//~ FntPrint("col: %d %d %d %d\nY: %d, Z: %d, X: %d\nSlope: %d", o, a, aa, ab, one->position.vy, one->position.vz, one->position.vx, slopeX);
} }
} }
return colInt;
}; };
void applyAngMom(LEVEL curLvl ){ void applyAngMom(LEVEL curLvl ){
if (curLvl.propPtr->isRound){ if (curLvl.propPtr->isRound){

View File

@ -1,5 +1,5 @@
#include "../include/psx.h" #include <psx.h>
#include "../include/sound.h" #include <sound.h>
void setDCLightEnv(MATRIX * curLevelCMat, MATRIX * curLevelLgtMat, SVECTOR * curLevelLgtAng){ void setDCLightEnv(MATRIX * curLevelCMat, MATRIX * curLevelLgtMat, SVECTOR * curLevelLgtAng){

View File

@ -1,5 +1,5 @@
#include "../include/sound.h" #include <sound.h>
#include "../include/space.h" #include <space.h>
// VAG playback // VAG playback
void initSnd(SpuCommonAttr * spuSettings, char * spu_malloc_rec, u_int mallocMax){ void initSnd(SpuCommonAttr * spuSettings, char * spu_malloc_rec, u_int mallocMax){

View File

@ -1,4 +1,4 @@
#include "../include/space.h" #include <space.h>
// From 'psyq/addons/graphics/ZIMEN/CLIP.C' // From 'psyq/addons/graphics/ZIMEN/CLIP.C'
void worldToScreen( VECTOR * worldPos, VECTOR * screenPos ) { void worldToScreen( VECTOR * worldPos, VECTOR * screenPos ) {

2
thirdparty/nugget vendored

@ -1 +1 @@
Subproject commit 6483f1e13b5c89932500129548e8aa8f2a026f25 Subproject commit a6e3be17bac082d789dfcc9e3b767128f560c28f