Add sound support (VAG/XA)
This commit is contained in:
parent
43dea98d63
commit
04a3bbbece
3
3dcam.cue
Normal file
3
3dcam.cue
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
FILE "3dcam.bin" BINARY
|
||||||
|
TRACK 01 MODE2/2352
|
||||||
|
INDEX 01 00:00:00
|
@ -26,6 +26,7 @@ Real-time 3D / 8bpp background / 4bpp background
|
|||||||
* Up to 3 light sources
|
* Up to 3 light sources
|
||||||
* Use pre-rendered backgrounds (8bpp and 4bpp)
|
* Use pre-rendered backgrounds (8bpp and 4bpp)
|
||||||
* Basic collisions
|
* Basic collisions
|
||||||
|
* Sound effects (VAG/XA)
|
||||||
|
|
||||||
### Demo Controls
|
### Demo Controls
|
||||||
|
|
||||||
@ -39,7 +40,6 @@ Real-time 3D / 8bpp background / 4bpp background
|
|||||||
## Planned
|
## Planned
|
||||||
|
|
||||||
* Fix and improve all the things !
|
* Fix and improve all the things !
|
||||||
* Wall collisions
|
|
||||||
|
|
||||||
# Compiling
|
# Compiling
|
||||||
|
|
||||||
|
8
XA/inter_0.txt
Normal file
8
XA/inter_0.txt
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
1 xa /home/arthus/build/psxdev/blender_io_export_psx_mesh/XA/3_hehe.xa 0 0
|
||||||
|
1 xa /home/arthus/build/psxdev/blender_io_export_psx_mesh/XA/3_hehe.xa 0 1
|
||||||
|
1 xa /home/arthus/build/psxdev/blender_io_export_psx_mesh/XA/1_cuek.xa 0 2
|
||||||
|
1 xa /home/arthus/build/psxdev/blender_io_export_psx_mesh/XA/1_cuek.xa 0 3
|
||||||
|
1 xa /home/arthus/build/psxdev/blender_io_export_psx_mesh/XA/1_cuek.xa 0 4
|
||||||
|
1 xa /home/arthus/build/psxdev/blender_io_export_psx_mesh/XA/3_hehe.xa 0 5
|
||||||
|
1 null
|
||||||
|
1 null
|
BIN
XA/inter_0.xa
Normal file
BIN
XA/inter_0.xa
Normal file
Binary file not shown.
@ -16,7 +16,8 @@
|
|||||||
<file name="SCES_313.37" type="data" source="main.ps-exe"/>
|
<file name="SCES_313.37" type="data" source="main.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"/>
|
||||||
|
<file name="INTER_0.XA" type="xa" source="/home/arthus/build/psxdev/3dcam-bak/XA/inter_0.xa"/>
|
||||||
|
|
||||||
<dummy sectors="1024"/>
|
<dummy sectors="1024"/>
|
||||||
</directory_tree>
|
</directory_tree>
|
||||||
|
242
custom_types.h
242
custom_types.h
@ -13,76 +13,80 @@ struct CAMANGLE;
|
|||||||
struct SIBLINGS;
|
struct SIBLINGS;
|
||||||
struct CHILDREN;
|
struct CHILDREN;
|
||||||
struct NODE;
|
struct NODE;
|
||||||
|
struct QUAD;
|
||||||
struct LEVEL;
|
struct LEVEL;
|
||||||
struct VAGsound;
|
struct VAGsound;
|
||||||
struct VAGbank;
|
struct VAGbank;
|
||||||
struct XAbank;
|
|
||||||
struct XAsound;
|
struct XAsound;
|
||||||
|
struct XAbank;
|
||||||
|
struct XAfiles;
|
||||||
|
struct SOUND_OBJECT;
|
||||||
|
struct LEVEL_SOUNDS;
|
||||||
|
|
||||||
typedef struct BODY {
|
typedef struct BODY {
|
||||||
VECTOR gForce;
|
VECTOR gForce;
|
||||||
VECTOR position;
|
VECTOR position;
|
||||||
SVECTOR velocity;
|
SVECTOR velocity;
|
||||||
int mass;
|
int mass;
|
||||||
int invMass;
|
int invMass;
|
||||||
VECTOR min;
|
VECTOR min;
|
||||||
VECTOR max;
|
VECTOR max;
|
||||||
int restitution;
|
int restitution;
|
||||||
} BODY;
|
} BODY;
|
||||||
|
|
||||||
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
|
||||||
int cursor; // anim cursor
|
int cursor; // anim cursor
|
||||||
int lerpCursor; // anim cursor
|
int lerpCursor; // anim cursor
|
||||||
int dir; // playback direction (1 or -1)
|
int dir; // playback direction (1 or -1)
|
||||||
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
|
SVECTOR data[]; // vertex pos as SVECTORs e.g 20 * 21 SVECTORS
|
||||||
} VANIM;
|
} VANIM;
|
||||||
|
|
||||||
typedef struct PRIM {
|
typedef struct PRIM {
|
||||||
VECTOR order;
|
VECTOR order;
|
||||||
int code; // Same as POL3/POL4 codes : Code (F3 = 1, FT3 = 2, G3 = 3,
|
int code; // Same as POL3/POL4 codes : Code (F3 = 1, FT3 = 2, G3 = 3,
|
||||||
// GT3 = 4) Code (F4 = 5, FT4 = 6, G4 = 7, GT4 = 8)
|
// GT3 = 4) Code (F4 = 5, FT4 = 6, G4 = 7, GT4 = 8)
|
||||||
} PRIM;
|
} PRIM;
|
||||||
|
|
||||||
typedef struct MESH {
|
typedef struct MESH {
|
||||||
int totalVerts;
|
int totalVerts;
|
||||||
TMESH * tmesh;
|
TMESH * tmesh;
|
||||||
PRIM * index;
|
PRIM * index;
|
||||||
TIM_IMAGE * tim;
|
TIM_IMAGE * tim;
|
||||||
unsigned long * tim_data;
|
unsigned long * tim_data;
|
||||||
MATRIX mat;
|
MATRIX mat;
|
||||||
VECTOR pos;
|
VECTOR pos;
|
||||||
SVECTOR rot;
|
SVECTOR rot;
|
||||||
short isProp;
|
short isProp;
|
||||||
short isRigidBody;
|
short isRigidBody;
|
||||||
short isStaticBody;
|
short isStaticBody;
|
||||||
short isRound;
|
short isRound;
|
||||||
short isPrism;
|
short isPrism;
|
||||||
short isAnim;
|
short isAnim;
|
||||||
short isActor;
|
short isActor;
|
||||||
short isLevel;
|
short isLevel;
|
||||||
short isWall;
|
short isWall;
|
||||||
short isBG;
|
short isBG;
|
||||||
short isSprite;
|
short isSprite;
|
||||||
long p;
|
long p;
|
||||||
long OTz;
|
long OTz;
|
||||||
BODY * body;
|
BODY * body;
|
||||||
VANIM * anim;
|
VANIM * anim;
|
||||||
struct NODE * node;
|
struct NODE * node;
|
||||||
VECTOR pos2D;
|
VECTOR pos2D;
|
||||||
} MESH;
|
} MESH;
|
||||||
|
|
||||||
typedef struct QUAD {
|
typedef struct QUAD {
|
||||||
VECTOR v0, v1;
|
VECTOR v0, v1;
|
||||||
VECTOR v2, v3;
|
VECTOR v2, v3;
|
||||||
} QUAD;
|
} QUAD;
|
||||||
|
|
||||||
typedef struct CAMPOS {
|
typedef struct CAMPOS {
|
||||||
SVECTOR pos;
|
SVECTOR pos;
|
||||||
SVECTOR rot;
|
SVECTOR rot;
|
||||||
} CAMPOS;
|
} CAMPOS;
|
||||||
|
|
||||||
|
|
||||||
// Blender cam ~= PSX cam with these settings :
|
// Blender cam ~= PSX cam with these settings :
|
||||||
@ -92,77 +96,97 @@ typedef struct CAMPOS {
|
|||||||
// Lower values mean wider angle
|
// Lower values mean wider angle
|
||||||
|
|
||||||
typedef struct CAMANGLE {
|
typedef struct CAMANGLE {
|
||||||
CAMPOS * campos;
|
CAMPOS * campos;
|
||||||
TIM_IMAGE * BGtim;
|
TIM_IMAGE * BGtim;
|
||||||
unsigned long * tim_data;
|
unsigned long * tim_data;
|
||||||
QUAD bw, fw;
|
QUAD bw, fw;
|
||||||
int index;
|
int index;
|
||||||
MESH * objects[];
|
MESH * objects[];
|
||||||
} CAMANGLE;
|
} CAMANGLE;
|
||||||
|
|
||||||
typedef struct CAMPATH {
|
typedef struct CAMPATH {
|
||||||
short len, cursor, pos;
|
short len, cursor, pos;
|
||||||
VECTOR points[];
|
VECTOR points[];
|
||||||
} CAMPATH;
|
} CAMPATH;
|
||||||
|
|
||||||
typedef struct SIBLINGS {
|
typedef struct SIBLINGS {
|
||||||
int index;
|
int index;
|
||||||
struct NODE * list[];
|
struct NODE * list[];
|
||||||
} SIBLINGS ;
|
} SIBLINGS ;
|
||||||
|
|
||||||
typedef struct CHILDREN {
|
typedef struct CHILDREN {
|
||||||
int index;
|
int index;
|
||||||
MESH * list[];
|
MESH * list[];
|
||||||
} CHILDREN ;
|
} CHILDREN ;
|
||||||
|
|
||||||
typedef struct NODE {
|
typedef struct NODE {
|
||||||
MESH * plane;
|
MESH * plane;
|
||||||
SIBLINGS * siblings;
|
SIBLINGS * siblings;
|
||||||
CHILDREN * objects;
|
CHILDREN * objects;
|
||||||
CHILDREN * rigidbodies;
|
CHILDREN * rigidbodies;
|
||||||
} NODE;
|
} NODE;
|
||||||
|
|
||||||
|
//VAG
|
||||||
typedef struct VAGsound {
|
typedef struct VAGsound {
|
||||||
u_char * VAGfile; // Pointer to VAG data address
|
u_char * VAGfile; // Pointer to VAG data address
|
||||||
u_long spu_channel; // SPU voice to playback to
|
u_long spu_channel; // SPU voice to playback to
|
||||||
u_long spu_address; // SPU address for memory freeing spu mem
|
u_long spu_address; // SPU address for memory freeing spu mem
|
||||||
} VAGsound;
|
} VAGsound;
|
||||||
|
|
||||||
typedef struct VAGbank {
|
typedef struct VAGbank {
|
||||||
u_int index;
|
u_int index;
|
||||||
VAGsound samples[];
|
VAGsound samples[];
|
||||||
} VAGbank;
|
} VAGbank;
|
||||||
|
|
||||||
// XA
|
// XA
|
||||||
typedef struct XAsound {
|
typedef struct XAsound {
|
||||||
u_int id;
|
u_int id;
|
||||||
u_int size;
|
u_int size;
|
||||||
u_char file, channel;
|
u_char file, channel;
|
||||||
u_int start, end;
|
u_int start, end;
|
||||||
int cursor;
|
int cursor;
|
||||||
} XAsound;
|
} XAsound;
|
||||||
|
|
||||||
typedef struct XAbank {
|
typedef struct XAbank {
|
||||||
char name[16];
|
char name[16];
|
||||||
u_int index;
|
u_int index;
|
||||||
int offset;
|
int offset;
|
||||||
XAsound samples[];
|
XAsound samples[];
|
||||||
} XAbank;
|
} XAbank;
|
||||||
|
|
||||||
|
typedef struct XAfiles {
|
||||||
|
u_int index;
|
||||||
|
XAbank * banks[];
|
||||||
|
} XAfiles;
|
||||||
|
|
||||||
|
typedef struct SOUND_OBJECT {
|
||||||
|
VECTOR location;
|
||||||
|
int volume, volume_min, volume_max;
|
||||||
|
VAGsound * VAGsample;
|
||||||
|
XAsound * XAsample;
|
||||||
|
MESH * parent;
|
||||||
|
} SOUND_OBJECT;
|
||||||
|
|
||||||
|
typedef struct LEVEL_SOUNDS {
|
||||||
|
int index;
|
||||||
|
SOUND_OBJECT * sounds[];
|
||||||
|
} LEVEL_SOUNDS;
|
||||||
|
|
||||||
typedef struct LEVEL {
|
typedef struct LEVEL {
|
||||||
CVECTOR * BGc;
|
CVECTOR * BGc;
|
||||||
VECTOR * BKc;
|
VECTOR * BKc;
|
||||||
MATRIX * cmat;
|
MATRIX * cmat;
|
||||||
MATRIX * lgtmat;
|
MATRIX * lgtmat;
|
||||||
MESH ** meshes;
|
MESH ** meshes;
|
||||||
int * meshes_length;
|
int * meshes_length;
|
||||||
MESH * actorPtr;
|
MESH * actorPtr;
|
||||||
MESH * levelPtr;
|
MESH * levelPtr;
|
||||||
MESH * propPtr;
|
MESH * propPtr;
|
||||||
CAMANGLE * camPtr;
|
CAMANGLE * camPtr;
|
||||||
CAMPATH * camPath;
|
CAMPATH * camPath;
|
||||||
CAMANGLE ** camAngles;
|
CAMANGLE ** camAngles;
|
||||||
NODE * curNode;
|
NODE * curNode;
|
||||||
VAGbank * VAG;
|
LEVEL_SOUNDS * levelSounds;
|
||||||
XAbank * XA;
|
VAGbank * VAG;
|
||||||
} LEVEL;
|
XAfiles * XA;
|
||||||
|
} LEVEL;
|
||||||
|
@ -10,7 +10,18 @@
|
|||||||
#define CLEAR_COLOR_G 0
|
#define CLEAR_COLOR_G 0
|
||||||
#define CLEAR_COLOR_B 0
|
#define CLEAR_COLOR_B 0
|
||||||
|
|
||||||
|
#define CAM_DIST_TO_ACT 200
|
||||||
|
#define CAM_DIST_TO_GND 100
|
||||||
|
|
||||||
// Sound
|
// Sound
|
||||||
|
// Sound engine
|
||||||
|
#define SND_DIST_MIN 200
|
||||||
|
#define SND_DIST_MAX 1200
|
||||||
|
#define SND_ATTENUATION 6144
|
||||||
|
#define SND_MAX_VOL 16383
|
||||||
|
#define SND_RANGE (SND_DIST_MAX-SND_DIST_MIN)
|
||||||
|
#define SND_NMALIZED (SND_RANGE*SND_ATTENUATION/SND_MAX_VOL)
|
||||||
|
// SPU channels
|
||||||
#define SPU_00CH (0x1L<< 0)
|
#define SPU_00CH (0x1L<< 0)
|
||||||
#define SPU_01CH (0x1L<< 1)
|
#define SPU_01CH (0x1L<< 1)
|
||||||
#define SPU_02CH (0x1L<< 2)
|
#define SPU_02CH (0x1L<< 2)
|
||||||
@ -19,7 +30,23 @@
|
|||||||
#define SPU_05CH (0x1L<< 5)
|
#define SPU_05CH (0x1L<< 5)
|
||||||
#define SPU_06CH (0x1L<< 6)
|
#define SPU_06CH (0x1L<< 6)
|
||||||
#define SPU_07CH (0x1L<< 7)
|
#define SPU_07CH (0x1L<< 7)
|
||||||
|
#define SPU_08CH (0x1L<< 8)
|
||||||
|
#define SPU_09CH (0x1L<< 9)
|
||||||
|
#define SPU_10CH (0x1L<<10)
|
||||||
|
#define SPU_11CH (0x1L<<11)
|
||||||
|
#define SPU_12CH (0x1L<<12)
|
||||||
|
#define SPU_13CH (0x1L<<13)
|
||||||
|
#define SPU_14CH (0x1L<<14)
|
||||||
|
#define SPU_15CH (0x1L<<15)
|
||||||
|
#define SPU_16CH (0x1L<<16)
|
||||||
|
#define SPU_17CH (0x1L<<17)
|
||||||
|
#define SPU_18CH (0x1L<<18)
|
||||||
|
#define SPU_19CH (0x1L<<19)
|
||||||
|
|
||||||
|
#define SPU_20CH (0x1L<<20)
|
||||||
|
#define SPU_21CH (0x1L<<21)
|
||||||
|
#define SPU_22CH (0x1L<<22)
|
||||||
|
#define SPU_23CH (0x1L<<23)
|
||||||
// CDDA / XA volume
|
// CDDA / XA volume
|
||||||
#define XA_CHANNELS 8
|
#define XA_CHANNELS 8
|
||||||
#define MVOL_L 0x3fff
|
#define MVOL_L 0x3fff
|
||||||
|
@ -8,20 +8,8 @@
|
|||||||
#define XA_RATE 380
|
#define XA_RATE 380
|
||||||
// Number of XA samples ( != # of XA files )
|
// Number of XA samples ( != # of XA files )
|
||||||
#define XA_TRACKS 2
|
#define XA_TRACKS 2
|
||||||
// VAG
|
// SPU
|
||||||
// Number of VAG files to load
|
#define MALLOC_MAX 48 // Max number of time we can call SpuMalloc
|
||||||
#define VAG_NBR 8
|
|
||||||
#define MALLOC_MAX VAG_NBR // Max number of time we can call SpuMalloc
|
|
||||||
// Custom struct to handle VAG files
|
|
||||||
//~ typedef struct VAGsound {
|
|
||||||
//~ u_char * VAGfile; // Pointer to VAG data address
|
|
||||||
//~ u_long spu_channel; // SPU voice to playback to
|
|
||||||
//~ u_long spu_address; // SPU address for memory freeing spu mem
|
|
||||||
//~ } VAGsound;
|
|
||||||
//~ typedef struct VAGbank {
|
|
||||||
//~ u_int index;
|
|
||||||
//~ VAGsound samples[];
|
|
||||||
//~ } VAGbank;
|
|
||||||
// VAG header struct (see fileformat47.pdf, p.209)
|
// VAG header struct (see fileformat47.pdf, p.209)
|
||||||
typedef struct VAGhdr { // All the values in this header must be big endian
|
typedef struct VAGhdr { // All the values in this header must be big endian
|
||||||
char id[4]; // VAGp 4 bytes -> 1 char * 4
|
char id[4]; // VAGp 4 bytes -> 1 char * 4
|
||||||
@ -33,28 +21,13 @@ typedef struct VAGhdr { // All the values in this header must be
|
|||||||
char name[16]; // 16 bytes -> 1 char * 16
|
char name[16]; // 16 bytes -> 1 char * 16
|
||||||
// Waveform data after that
|
// Waveform data after that
|
||||||
} VAGhdr;
|
} VAGhdr;
|
||||||
//~ // XA
|
|
||||||
//~ typedef struct XAsound {
|
|
||||||
//~ u_int id;
|
|
||||||
//~ u_int size;
|
|
||||||
//~ u_char file, channel;
|
|
||||||
//~ u_int start, end;
|
|
||||||
//~ int cursor;
|
|
||||||
//~ } XAsound;
|
|
||||||
|
|
||||||
//~ typedef struct XAbank {
|
|
||||||
//~ char * name;
|
|
||||||
//~ u_int index;
|
|
||||||
//~ int offset;
|
|
||||||
//~ XAsound samples[];
|
|
||||||
//~ } XAbank;
|
|
||||||
|
|
||||||
// VAG playback
|
// VAG playback
|
||||||
void initSnd(SpuCommonAttr * spuSettings, char * spu_malloc_rec);
|
void initSnd(SpuCommonAttr * spuSettings, char * spu_malloc_rec, u_int mallocMax);
|
||||||
u_long sendVAGtoSPU(unsigned int VAG_data_size, u_char *VAG_data);
|
u_long sendVAGtoSPU(unsigned int VAG_data_size, u_char *VAG_data);
|
||||||
void setVoiceAttr(SpuVoiceAttr * voiceAttributes, u_int pitch, long channel, u_long soundAddr );
|
void setVoiceAttr(SpuVoiceAttr * voiceAttributes, u_int pitch, long channel, u_long soundAddr );
|
||||||
u_long setSPUtransfer(SpuVoiceAttr * voiceAttributes, VAGsound * sound);
|
u_long setSPUtransfer(SpuVoiceAttr * voiceAttributes, VAGsound * sound);
|
||||||
void playSFX(SpuVoiceAttr * voiceAttributes, VAGsound * sound);
|
void setVAGvolume(SpuVoiceAttr * voiceAttributes, VAGsound * sound, int volume);
|
||||||
|
void playSFX(SpuVoiceAttr * voiceAttributes, VAGsound * sound, int volume);
|
||||||
// XA playback
|
// XA playback
|
||||||
void XAsetup(void);
|
void XAsetup(void);
|
||||||
void getXAoffset(LEVEL * level);
|
void getXAoffset(LEVEL * level);
|
||||||
|
2004
levels/level0.c
2004
levels/level0.c
File diff suppressed because it is too large
Load Diff
@ -36,6 +36,19 @@ extern MESH * level0_levelPtr;
|
|||||||
extern MESH * level0_propPtr;
|
extern MESH * level0_propPtr;
|
||||||
extern CAMANGLE * level0_camPtr;
|
extern CAMANGLE * level0_camPtr;
|
||||||
extern NODE * level0_curNode;
|
extern NODE * level0_curNode;
|
||||||
|
extern VAGbank level0_VAGBank;
|
||||||
|
extern XAbank level0_XABank_0;
|
||||||
|
extern XAfiles level0_XAFiles;
|
||||||
|
extern SOUND_OBJECT level0_Speaker;
|
||||||
|
extern SOUND_OBJECT level0_Speaker_001;
|
||||||
|
extern SOUND_OBJECT level0_Speaker_002;
|
||||||
|
extern SOUND_OBJECT level0_Speaker_003;
|
||||||
|
extern SOUND_OBJECT level0_Speaker_004;
|
||||||
|
extern SOUND_OBJECT level0_Speaker_005;
|
||||||
|
extern SOUND_OBJECT level0_Speaker_006;
|
||||||
|
extern SOUND_OBJECT level0_Speaker_007;
|
||||||
|
extern SOUND_OBJECT level0_Speaker_008;
|
||||||
|
extern SOUND_OBJECT level0_Speaker_009;
|
||||||
|
extern SOUND_OBJECT level0_Speaker_010;
|
||||||
|
extern LEVEL_SOUNDS level0_sounds;
|
||||||
extern NODE level0_nodePlane;
|
extern NODE level0_nodePlane;
|
||||||
extern VAGbank VAGBank0;
|
|
||||||
extern XAbank XABank0;
|
|
||||||
|
116
levels/level1.c
116
levels/level1.c
@ -11049,7 +11049,7 @@ extern u_char _binary_VAG_5_punc_vag_start;
|
|||||||
extern u_char _binary_VAG_7_wron_vag_start;
|
extern u_char _binary_VAG_7_wron_vag_start;
|
||||||
extern u_char _binary_VAG_8_yooo_vag_start;
|
extern u_char _binary_VAG_8_yooo_vag_start;
|
||||||
// soundBank
|
// soundBank
|
||||||
VAGbank VAGBank1 = {
|
VAGbank level1_VAGBank = {
|
||||||
8,
|
8,
|
||||||
{
|
{
|
||||||
{ &_binary_VAG_0_come_vag_start, SPU_00CH, 0 },
|
{ &_binary_VAG_0_come_vag_start, SPU_00CH, 0 },
|
||||||
@ -11059,13 +11059,13 @@ VAGbank VAGBank1 = {
|
|||||||
{ &_binary_VAG_4_m4a1_vag_start, SPU_04CH, 0 },
|
{ &_binary_VAG_4_m4a1_vag_start, SPU_04CH, 0 },
|
||||||
{ &_binary_VAG_5_punc_vag_start, SPU_05CH, 0 },
|
{ &_binary_VAG_5_punc_vag_start, SPU_05CH, 0 },
|
||||||
{ &_binary_VAG_7_wron_vag_start, SPU_06CH, 0 },
|
{ &_binary_VAG_7_wron_vag_start, SPU_06CH, 0 },
|
||||||
{ &_binary_VAG_8_yooo_vag_start, SPU_07CH, 0 }
|
{ &_binary_VAG_8_yooo_vag_start, SPU_07CH, 0 },
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
XAbank XABank1 = {
|
XAbank level1_XABank_0 = {
|
||||||
"\\INTER8.XA;1",
|
"\\INTER8.XA;1",
|
||||||
8,
|
2,
|
||||||
0,
|
0,
|
||||||
{
|
{
|
||||||
//channel 0
|
//channel 0
|
||||||
@ -11074,6 +11074,109 @@ XAbank XABank1 = {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
XAfiles level1_XAFiles = {
|
||||||
|
1,
|
||||||
|
{
|
||||||
|
&level1_XABank_0
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
SOUND_OBJECT level1_Speaker = {
|
||||||
|
{102,32,210},
|
||||||
|
16383, 0, 16383,
|
||||||
|
&level1_VAGBank.samples[0],
|
||||||
|
0,
|
||||||
|
&level1_meshCube
|
||||||
|
};
|
||||||
|
|
||||||
|
SOUND_OBJECT level1_Speaker_001 = {
|
||||||
|
{-82,28,210},
|
||||||
|
16383, 0, 16383,
|
||||||
|
&level1_VAGBank.samples[1],
|
||||||
|
0,
|
||||||
|
&level1_meshCube
|
||||||
|
};
|
||||||
|
|
||||||
|
SOUND_OBJECT level1_Speaker_002 = {
|
||||||
|
{-267,432,-146},
|
||||||
|
16383, 0, 16383,
|
||||||
|
&level1_VAGBank.samples[2],
|
||||||
|
0,
|
||||||
|
0
|
||||||
|
};
|
||||||
|
|
||||||
|
SOUND_OBJECT level1_Speaker_003 = {
|
||||||
|
{-101,156,253},
|
||||||
|
16383, 0, 16383,
|
||||||
|
&level1_VAGBank.samples[3],
|
||||||
|
0,
|
||||||
|
&level1_meshCube
|
||||||
|
};
|
||||||
|
|
||||||
|
SOUND_OBJECT level1_Speaker_004 = {
|
||||||
|
{83,161,253},
|
||||||
|
16383, 0, 16383,
|
||||||
|
&level1_VAGBank.samples[4],
|
||||||
|
0,
|
||||||
|
&level1_meshCube
|
||||||
|
};
|
||||||
|
|
||||||
|
SOUND_OBJECT level1_Speaker_005 = {
|
||||||
|
{76,-39,188},
|
||||||
|
16383, 0, 16383,
|
||||||
|
&level1_VAGBank.samples[5],
|
||||||
|
0,
|
||||||
|
&level1_meshCube
|
||||||
|
};
|
||||||
|
|
||||||
|
SOUND_OBJECT level1_Speaker_006 = {
|
||||||
|
{-108,-43,188},
|
||||||
|
16383, 0, 16383,
|
||||||
|
&level1_VAGBank.samples[6],
|
||||||
|
0,
|
||||||
|
&level1_meshCube
|
||||||
|
};
|
||||||
|
|
||||||
|
SOUND_OBJECT level1_Speaker_007 = {
|
||||||
|
{-352,55,234},
|
||||||
|
16383, 0, 16383,
|
||||||
|
&level1_VAGBank.samples[7],
|
||||||
|
0,
|
||||||
|
&level1_meshCube
|
||||||
|
};
|
||||||
|
|
||||||
|
SOUND_OBJECT level1_Speaker_008 = {
|
||||||
|
{-168,60,234},
|
||||||
|
16383, 0, 16383,
|
||||||
|
&level1_VAGBank.samples[8],
|
||||||
|
0,
|
||||||
|
&level1_meshCube
|
||||||
|
};
|
||||||
|
|
||||||
|
SOUND_OBJECT level1_Speaker_009 = {
|
||||||
|
{188,-156,143},
|
||||||
|
16383, 0, 16383,
|
||||||
|
0,
|
||||||
|
&level1_XABank_0.samples[0],
|
||||||
|
&level1_meshCube
|
||||||
|
};
|
||||||
|
|
||||||
|
LEVEL_SOUNDS level1_sounds = {
|
||||||
|
10,
|
||||||
|
{
|
||||||
|
&level1_Speaker,
|
||||||
|
&level1_Speaker_001,
|
||||||
|
&level1_Speaker_002,
|
||||||
|
&level1_Speaker_003,
|
||||||
|
&level1_Speaker_004,
|
||||||
|
&level1_Speaker_005,
|
||||||
|
&level1_Speaker_006,
|
||||||
|
&level1_Speaker_007,
|
||||||
|
&level1_Speaker_008,
|
||||||
|
&level1_Speaker_009
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
LEVEL level1 = {
|
LEVEL level1 = {
|
||||||
&level1_BGc,
|
&level1_BGc,
|
||||||
&level1_BKc,
|
&level1_BKc,
|
||||||
@ -11088,6 +11191,7 @@ LEVEL level1 = {
|
|||||||
&level1_camPath,
|
&level1_camPath,
|
||||||
(CAMANGLE **)&level1_camAngles,
|
(CAMANGLE **)&level1_camAngles,
|
||||||
&level1_nodegnd,
|
&level1_nodegnd,
|
||||||
&VAGBank1,
|
&level1_sounds,
|
||||||
&XABank1
|
&level1_VAGBank,
|
||||||
|
&level1_XAFiles
|
||||||
};
|
};
|
||||||
|
@ -44,7 +44,7 @@ void setCameraMode(LEVEL * curLvl, CAMERA * camera, VECTOR * posToActor, VECTOR
|
|||||||
switch (camMode){
|
switch (camMode){
|
||||||
// Camera follows actor
|
// Camera follows actor
|
||||||
case 0 :
|
case 0 :
|
||||||
dist = 200;
|
dist = CAM_DIST_TO_ACT;
|
||||||
setVector(dc_camPos, -(camera->x/ONE), -(camera->y/ONE), -(camera->z/ONE));
|
setVector(dc_camPos, -(camera->x/ONE), -(camera->y/ONE), -(camera->z/ONE));
|
||||||
angle->vy = -(curLvl->actorPtr->rot.vy / 2) + angleCam->vy;
|
angle->vy = -(curLvl->actorPtr->rot.vy / 2) + angleCam->vy;
|
||||||
// Camera horizontal and vertical position
|
// Camera horizontal and vertical position
|
||||||
@ -55,9 +55,9 @@ void setCameraMode(LEVEL * curLvl, CAMERA * camera, VECTOR * posToActor, VECTOR
|
|||||||
// Camera rotates continuously around actor
|
// Camera rotates continuously around actor
|
||||||
case 1 :
|
case 1 :
|
||||||
// Set distance between cam and actor
|
// Set distance between cam and actor
|
||||||
dist = 150;
|
dist = CAM_DIST_TO_ACT;
|
||||||
// Set camera position
|
// Set camera position
|
||||||
setVector(dc_camPos, -(camera->x/ONE), 100, -(camera->z/ONE));
|
setVector(dc_camPos, -(camera->x/ONE), CAM_DIST_TO_GND, -(camera->z/ONE));
|
||||||
// Find new camera position
|
// Find new camera position
|
||||||
getCameraXZ(&camera->x, &camera->z, curLvl->actorPtr->pos.vx, curLvl->actorPtr->pos.vz, angle->vy, dist);
|
getCameraXZ(&camera->x, &camera->z, curLvl->actorPtr->pos.vx, curLvl->actorPtr->pos.vz, angle->vy, dist);
|
||||||
// Set rotation amount
|
// Set rotation amount
|
||||||
@ -105,7 +105,7 @@ void setCameraMode(LEVEL * curLvl, CAMERA * camera, VECTOR * posToActor, VECTOR
|
|||||||
// Using precalc sqrt
|
// Using precalc sqrt
|
||||||
dist = psqrt( (posToActor->vx * posToActor->vx ) + (posToActor->vz * posToActor->vz) );
|
dist = psqrt( (posToActor->vx * posToActor->vx ) + (posToActor->vz * posToActor->vz) );
|
||||||
// Set camera position
|
// Set camera position
|
||||||
setVector(dc_camPos, 190, 100, 180);
|
setVector(dc_camPos, 190, CAM_DIST_TO_GND, 180);
|
||||||
break;
|
break;
|
||||||
// Flyby mode with LERP from camStart to camEnd
|
// Flyby mode with LERP from camStart to camEnd
|
||||||
case 4 :
|
case 4 :
|
||||||
|
103
src/main.c
103
src/main.c
@ -37,7 +37,7 @@ u_long overlaySize = 0;
|
|||||||
#include "../levels/level1.h"
|
#include "../levels/level1.h"
|
||||||
|
|
||||||
// Levels
|
// Levels
|
||||||
u_char level = 1;
|
u_char level = 0;
|
||||||
u_short levelWas = 0;
|
u_short levelWas = 0;
|
||||||
u_short levelHasChanged = 0;
|
u_short levelHasChanged = 0;
|
||||||
// Overlay
|
// Overlay
|
||||||
@ -199,17 +199,21 @@ int main() {
|
|||||||
// Time counter
|
// Time counter
|
||||||
oldTime = GetRCnt(RCntCNT1);
|
oldTime = GetRCnt(RCntCNT1);
|
||||||
// Sound
|
// Sound
|
||||||
SpuInit();
|
SpuInit();
|
||||||
// Init sound settings
|
|
||||||
initSnd(&spuSettings, spu_malloc_rec);
|
|
||||||
//~ spuCDsetup(&spuSettings);
|
//~ spuCDsetup(&spuSettings);
|
||||||
XAsetup();
|
XAsetup();
|
||||||
for (u_short vag = 0; vag < VAG_NBR; vag++ ){
|
if (curLvl.VAG != 0){
|
||||||
//~ VAGBank.samples[vag].spu_address = setSPUtransfer(&voiceAttributes, &VAGBank.samples[vag]);
|
// Init sound settings
|
||||||
curLvl.VAG->samples[vag].spu_address = setSPUtransfer(&voiceAttributes, &curLvl.VAG->samples[vag]);
|
initSnd(&spuSettings, spu_malloc_rec, curLvl.VAG->index );
|
||||||
|
for (u_short vag = 0; vag < curLvl.VAG->index; vag++ ){
|
||||||
|
curLvl.VAG->samples[vag].spu_address = setSPUtransfer(&voiceAttributes, &curLvl.VAG->samples[vag]);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
sample = 0;
|
if ( curLvl.XA != 0 ){
|
||||||
setXAsample(&curLvl.XA->samples[sample], &filter);
|
sample = 0;
|
||||||
|
setXAsample(&curLvl.XA->banks[1]->samples[sample], &filter);
|
||||||
|
}
|
||||||
|
|
||||||
// Main loop
|
// Main loop
|
||||||
//~ while ( VSync(VSYNC) ) {
|
//~ while ( VSync(VSYNC) ) {
|
||||||
while ( 1 ) {
|
while ( 1 ) {
|
||||||
@ -220,9 +224,9 @@ int main() {
|
|||||||
if (sample != -1 ){
|
if (sample != -1 ){
|
||||||
// Begin XA file playback...
|
// Begin XA file playback...
|
||||||
// if sample's cursor is 0
|
// if sample's cursor is 0
|
||||||
if (curLvl.XA->samples[sample].cursor == 0){
|
if (curLvl.XA->banks[0]->samples[sample].cursor == 0){
|
||||||
// Convert sector number to CD position in min/second/frame and set CdlLOC accordingly.
|
// Convert sector number to CD position in min/second/frame and set CdlLOC accordingly.
|
||||||
CdIntToPos(curLvl.XA->samples[sample].start + curLvl.XA->offset , &loc);
|
CdIntToPos(curLvl.XA->banks[0]->samples[sample].start + curLvl.XA->banks[0]->offset , &loc);
|
||||||
// Send CDROM read command
|
// Send CDROM read command
|
||||||
CdControlF(CdlReadS, (u_char *)&loc);
|
CdControlF(CdlReadS, (u_char *)&loc);
|
||||||
XATime = VSync(-1);
|
XATime = VSync(-1);
|
||||||
@ -232,11 +236,11 @@ int main() {
|
|||||||
//~ if ((curLvl.XA->samples[sample].cursor += XA_CDSPEED) >= curLvl.XA->samples[sample].end - curLvl.XA->samples[sample].start ){
|
//~ if ((curLvl.XA->samples[sample].cursor += XA_CDSPEED) >= curLvl.XA->samples[sample].end - curLvl.XA->samples[sample].start ){
|
||||||
//~ if ((curLvl.XA->samples[sample].cursor += (XA_CDSPEED*4096)/((400/(dt+1)+1)) ) >= (curLvl.XA->samples[sample].end - curLvl.XA->samples[sample].start)*4096 ){
|
//~ if ((curLvl.XA->samples[sample].cursor += (XA_CDSPEED*4096)/((400/(dt+1)+1)) ) >= (curLvl.XA->samples[sample].end - curLvl.XA->samples[sample].start)*4096 ){
|
||||||
// XA playback has fixed rate
|
// XA playback has fixed rate
|
||||||
if ((curLvl.XA->samples[sample].cursor += XA_CDSPEED / ((XA_RATE/(dt+1)+1)) ) >= (curLvl.XA->samples[sample].end - curLvl.XA->samples[sample].start) * ONE ){
|
if ((curLvl.XA->banks[0]->samples[sample].cursor += XA_CDSPEED / ((XA_RATE/(dt+1)+1)) ) >= (curLvl.XA->banks[0]->samples[sample].end - curLvl.XA->banks[0]->samples[sample].start) * ONE ){
|
||||||
//~ CdControlF(CdlStop,0);
|
//~ CdControlF(CdlStop,0);
|
||||||
curLvl.XA->samples[sample].cursor = -1;
|
curLvl.XA->banks[0]->samples[sample].cursor = -1;
|
||||||
//~ sample = !sample;
|
//~ sample = !sample;
|
||||||
setXAsample(&curLvl.XA->samples[sample], &filter);
|
setXAsample(&curLvl.XA->banks[0]->samples[sample], &filter);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Check if level has changed
|
// Check if level has changed
|
||||||
@ -277,14 +281,32 @@ int main() {
|
|||||||
// Set level lighting
|
// Set level lighting
|
||||||
setLightEnv(draw, curLvl.BGc, curLvl.BKc);
|
setLightEnv(draw, curLvl.BGc, curLvl.BKc);
|
||||||
levelWas = level;
|
levelWas = level;
|
||||||
// Change XA track
|
// TODO : move to functions
|
||||||
XAsetup();
|
if (curLvl.VAG != 0) {
|
||||||
sample = !sample;
|
// Free SPU mem
|
||||||
curLvl.XA->samples[sample].cursor = -1;
|
for (u_short vag = 0; vag < curLvl.VAG->index; vag++ ){
|
||||||
setXAsample(&curLvl.XA->samples[sample], &filter);
|
//~ VAGBank.samples[vag].spu_address = setSPUtransfer(&voiceAttributes, &VAGBank.samples[vag]);
|
||||||
CdIntToPos( curLvl.XA->samples[sample].start + curLvl.XA->offset , &loc);
|
SpuFree(curLvl.VAG->samples[vag].spu_address);
|
||||||
// Send CDROM read command
|
}
|
||||||
CdControlF(CdlReadS, (u_char *)&loc);
|
// Reinit SPU
|
||||||
|
initSnd(&spuSettings, spu_malloc_rec, curLvl.VAG->index );
|
||||||
|
// Load level VAGs
|
||||||
|
for (u_short vag = 0; vag < curLvl.VAG->index; vag++ ){
|
||||||
|
//~ //VAGBank.samples[vag].spu_address = setSPUtransfer(&voiceAttributes, &VAGBank.samples[vag]);
|
||||||
|
curLvl.VAG->samples[vag].spu_address = setSPUtransfer(&voiceAttributes, &curLvl.VAG->samples[vag]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (curLvl.XA != 0){
|
||||||
|
// Change XA track
|
||||||
|
XAsetup();
|
||||||
|
//~ sample = !sample;
|
||||||
|
curLvl.XA->banks[0]->samples[sample].cursor = -1;
|
||||||
|
getXAoffset(&curLvl);
|
||||||
|
setXAsample(&curLvl.XA->banks[0]->samples[sample], &filter);
|
||||||
|
CdIntToPos( curLvl.XA->banks[0]->samples[sample].start + curLvl.XA->banks[0]->offset , &loc);
|
||||||
|
// Send CDROM read command
|
||||||
|
CdControlF(CdlReadS, (u_char *)&loc);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
//~ FntPrint("Ovl:%s\nLvl : %x\nLvl: %d %d \n%x", overlayFile, &level, level, levelWas, loadLvl);
|
//~ FntPrint("Ovl:%s\nLvl : %x\nLvl: %d %d \n%x", overlayFile, &level, level, levelWas, loadLvl);
|
||||||
// atime is used for animations timing
|
// atime is used for animations timing
|
||||||
@ -296,18 +318,41 @@ int main() {
|
|||||||
// TODO : put in a function
|
// TODO : put in a function
|
||||||
// Reset player/prop pos
|
// Reset player/prop pos
|
||||||
if(curLvl.actorPtr->pos.vy >= 200){
|
if(curLvl.actorPtr->pos.vy >= 200){
|
||||||
playSFX(&voiceAttributes, &curLvl.VAG->samples[6]);
|
playSFX(&voiceAttributes, curLvl.levelSounds->sounds[6]->VAGsample, curLvl.levelSounds->sounds[6]->volume);
|
||||||
copyVector(&curLvl.actorPtr->body->position, &actorStartPos );
|
copyVector(&curLvl.actorPtr->body->position, &actorStartPos );
|
||||||
copyVector(&curLvl.actorPtr->rot, &actorStartRot );
|
copyVector(&curLvl.actorPtr->rot, &actorStartRot );
|
||||||
curLvl.curNode = actorStartNode;
|
curLvl.curNode = actorStartNode;
|
||||||
curLvl.levelPtr = curLvl.curNode->plane;
|
curLvl.levelPtr = curLvl.curNode->plane;
|
||||||
}
|
}
|
||||||
if(curLvl.propPtr->pos.vy >= 200){
|
if(curLvl.propPtr->pos.vy >= 200){
|
||||||
playSFX(&voiceAttributes, &curLvl.VAG->samples[3]);
|
playSFX(&voiceAttributes, curLvl.levelSounds->sounds[3]->VAGsample, curLvl.levelSounds->sounds[3]->volume);
|
||||||
copyVector(&curLvl.propPtr->body->position, &propStartPos );
|
copyVector(&curLvl.propPtr->body->position, &propStartPos );
|
||||||
copyVector(&curLvl.propPtr->rot, &propStartRot );
|
copyVector(&curLvl.propPtr->rot, &propStartRot );
|
||||||
curLvl.propPtr->node = propStartNode;
|
curLvl.propPtr->node = propStartNode;
|
||||||
}
|
}
|
||||||
|
// Sound
|
||||||
|
if (curLvl.levelSounds != 0){
|
||||||
|
//~ for(int snd = 0; snd < level0_sounds.index; snd++){
|
||||||
|
for(int snd = 0; snd < curLvl.levelSounds->index; snd++){
|
||||||
|
// TODO : move in playSFX()
|
||||||
|
// update sound location if sound has a parent
|
||||||
|
u_int r;
|
||||||
|
// If parent is actor,
|
||||||
|
if (curLvl.levelSounds->sounds[snd]->parent == curLvl.actorPtr && camMode <= 1){
|
||||||
|
r = CAM_DIST_TO_ACT;
|
||||||
|
} else if ( curLvl.levelSounds->sounds[snd]->parent != 0){
|
||||||
|
VECTOR dist;
|
||||||
|
copyVector(&curLvl.levelSounds->sounds[snd]->location, &curLvl.levelSounds->sounds[snd]->parent->pos);
|
||||||
|
// Get distance between sound source and camera
|
||||||
|
addVector2(camera.pos, &curLvl.levelSounds->sounds[snd]->location, &dist);
|
||||||
|
r = psqrt((dist.vx * dist.vx) + (dist.vz * dist.vz));
|
||||||
|
}
|
||||||
|
curLvl.levelSounds->sounds[snd]->volume = (curLvl.levelSounds->sounds[snd]->volume_max/r) * SND_NMALIZED > SND_MAX_VOL ? SND_MAX_VOL :
|
||||||
|
(curLvl.levelSounds->sounds[snd]->volume_max/r) * SND_NMALIZED < 0 ? 0 :
|
||||||
|
(curLvl.levelSounds->sounds[snd]->volume_max/r) * SND_NMALIZED;
|
||||||
|
//~ FntPrint("Vol %d\n", curLvl.levelSounds->sounds[snd]->volume);
|
||||||
|
}
|
||||||
|
}
|
||||||
// Spatial partitioning
|
// Spatial partitioning
|
||||||
if (curLvl.curNode){
|
if (curLvl.curNode){
|
||||||
for ( int msh = 0; msh < curLvl.curNode->siblings->index; msh ++ ) {
|
for ( int msh = 0; msh < curLvl.curNode->siblings->index; msh ++ ) {
|
||||||
@ -431,6 +476,7 @@ int main() {
|
|||||||
//~ 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("XA: %x", curLvl.XA);
|
||||||
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);
|
||||||
|
|
||||||
@ -508,7 +554,7 @@ void callback() {
|
|||||||
} else {
|
} else {
|
||||||
curLvl.actorPtr->isPrism = 1;
|
curLvl.actorPtr->isPrism = 1;
|
||||||
}
|
}
|
||||||
playSFX(&voiceAttributes, &curLvl.VAG->samples[0]);
|
playSFX(&voiceAttributes, curLvl.levelSounds->sounds[0]->VAGsample, curLvl.levelSounds->sounds[0]->volume );
|
||||||
//~ timer = 10;
|
//~ timer = 10;
|
||||||
lastPad = PAD;
|
lastPad = PAD;
|
||||||
}
|
}
|
||||||
@ -516,7 +562,7 @@ void callback() {
|
|||||||
lastPad = PAD;
|
lastPad = PAD;
|
||||||
}
|
}
|
||||||
if ( PAD & Square && !( lastPad & Square ) ){
|
if ( PAD & Square && !( lastPad & Square ) ){
|
||||||
playSFX(&voiceAttributes, &curLvl.VAG->samples[7]);
|
playSFX(&voiceAttributes, curLvl.levelSounds->sounds[7]->VAGsample, curLvl.levelSounds->sounds[7]->volume);
|
||||||
//~ sample = 0;
|
//~ sample = 0;
|
||||||
//~ setXAsample(&XABank.samples[sample], &filter);
|
//~ setXAsample(&XABank.samples[sample], &filter);
|
||||||
lastPad = PAD;
|
lastPad = PAD;
|
||||||
@ -527,18 +573,17 @@ void callback() {
|
|||||||
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 ){
|
||||||
// Use delta to find jump force
|
// Use delta to find jump force
|
||||||
//~ curLvl.actorPtr->body->gForce.vy = - ((200/((ONE/(dt<1?1:dt))<1?1:(ONE/(dt<1?1:dt))))*14);
|
|
||||||
curLvl.actorPtr->body->gForce.vy = -200;
|
curLvl.actorPtr->body->gForce.vy = -200;
|
||||||
}
|
}
|
||||||
timer = 10;
|
timer = 10;
|
||||||
playSFX(&voiceAttributes, &curLvl.VAG->samples[4]);
|
playSFX(&voiceAttributes, curLvl.levelSounds->sounds[4]->VAGsample, curLvl.levelSounds->sounds[4]->volume);
|
||||||
lastPad = PAD;
|
lastPad = PAD;
|
||||||
}
|
}
|
||||||
if ( !(PAD & Cross) && lastPad & Cross ) {
|
if ( !(PAD & Cross) && lastPad & Cross ) {
|
||||||
lastPad = PAD;
|
lastPad = PAD;
|
||||||
}
|
}
|
||||||
if ( PAD & Circle && !(PAD & lastPad) ){
|
if ( PAD & Circle && !(PAD & lastPad) ){
|
||||||
playSFX(&voiceAttributes, &curLvl.VAG->samples[5]);
|
playSFX(&voiceAttributes, curLvl.levelSounds->sounds[5]->VAGsample, curLvl.levelSounds->sounds[5]->volume);
|
||||||
lastPad = PAD;
|
lastPad = PAD;
|
||||||
}
|
}
|
||||||
if ( !(PAD & Circle) && lastPad & Circle ) {
|
if ( !(PAD & Circle) && lastPad & Circle ) {
|
||||||
|
@ -106,6 +106,7 @@ void LvlPtrSet(LEVEL * curLevel, LEVEL * level){
|
|||||||
curLevel->curNode = level->curNode; // Blank
|
curLevel->curNode = level->curNode; // Blank
|
||||||
curLevel->VAG = level->VAG;
|
curLevel->VAG = level->VAG;
|
||||||
curLevel->XA = level->XA;
|
curLevel->XA = level->XA;
|
||||||
|
curLevel->levelSounds = level->levelSounds;
|
||||||
|
|
||||||
//~ curLevel->actorPtr->body = level->actorPtr->body;
|
//~ curLevel->actorPtr->body = level->actorPtr->body;
|
||||||
// Move these to drawPoly()
|
// Move these to drawPoly()
|
||||||
|
31
src/sound.c
31
src/sound.c
@ -2,9 +2,8 @@
|
|||||||
#include "../include/space.h"
|
#include "../include/space.h"
|
||||||
|
|
||||||
// VAG playback
|
// VAG playback
|
||||||
void initSnd(SpuCommonAttr * spuSettings, char * spu_malloc_rec){
|
void initSnd(SpuCommonAttr * spuSettings, char * spu_malloc_rec, u_int mallocMax){
|
||||||
|
SpuInitMalloc(mallocMax, spu_malloc_rec); // Maximum number of blocks, mem. management table address.
|
||||||
SpuInitMalloc(MALLOC_MAX, spu_malloc_rec); // Maximum number of blocks, mem. management table address.
|
|
||||||
spuSettings->mask = (SPU_COMMON_MVOLL | SPU_COMMON_MVOLR | SPU_COMMON_CDVOLL | SPU_COMMON_CDVOLR | SPU_COMMON_CDMIX ); // Mask which attributes to set
|
spuSettings->mask = (SPU_COMMON_MVOLL | SPU_COMMON_MVOLR | SPU_COMMON_CDVOLL | SPU_COMMON_CDVOLR | SPU_COMMON_CDMIX ); // Mask which attributes to set
|
||||||
spuSettings->mvol.left = MVOL_L; // Master volume left
|
spuSettings->mvol.left = MVOL_L; // Master volume left
|
||||||
spuSettings->mvol.right = MVOL_R; // see libref47.pdf, p.1058
|
spuSettings->mvol.right = MVOL_R; // see libref47.pdf, p.1058
|
||||||
@ -12,7 +11,7 @@ void initSnd(SpuCommonAttr * spuSettings, char * spu_malloc_rec){
|
|||||||
spuSettings->cd.volume.right = CDVOL_R;
|
spuSettings->cd.volume.right = CDVOL_R;
|
||||||
// Enable CD input ON
|
// Enable CD input ON
|
||||||
spuSettings->cd.mix = SPU_ON;
|
spuSettings->cd.mix = SPU_ON;
|
||||||
|
// Apply settings
|
||||||
SpuSetCommonAttr(spuSettings);
|
SpuSetCommonAttr(spuSettings);
|
||||||
// Set transfer mode
|
// Set transfer mode
|
||||||
SpuSetTransferMode(SPU_TRANSFER_BY_DMA);
|
SpuSetTransferMode(SPU_TRANSFER_BY_DMA);
|
||||||
@ -68,21 +67,19 @@ u_long setSPUtransfer(SpuVoiceAttr * voiceAttributes, VAGsound * sound){
|
|||||||
SpuSetTransferStartAddr(spu_address); // Sets a starting address in the sound buffer
|
SpuSetTransferStartAddr(spu_address); // Sets a starting address in the sound buffer
|
||||||
transferred = sendVAGtoSPU(SWAP_ENDIAN32(VAGheader->dataSize), sound->VAGfile);
|
transferred = sendVAGtoSPU(SWAP_ENDIAN32(VAGheader->dataSize), sound->VAGfile);
|
||||||
setVoiceAttr(voiceAttributes, pitch, sound->spu_channel, spu_address);
|
setVoiceAttr(voiceAttributes, pitch, sound->spu_channel, spu_address);
|
||||||
// Return 1 if ok, size transferred else.
|
|
||||||
//~ if (transferred == SWAP_ENDIAN32(VAGheader->dataSize)){
|
|
||||||
//~ return 1;
|
|
||||||
//~ }
|
|
||||||
//~ return transferred;
|
|
||||||
return spu_address;
|
return spu_address;
|
||||||
}
|
}
|
||||||
void playSFX(SpuVoiceAttr * voiceAttributes, VAGsound * sound){
|
void setVAGvolume(SpuVoiceAttr * voiceAttributes, VAGsound * sound, int volume){
|
||||||
// Set voice volume to max
|
|
||||||
voiceAttributes->mask= ( SPU_VOICE_VOLL | SPU_VOICE_VOLR );
|
voiceAttributes->mask= ( SPU_VOICE_VOLL | SPU_VOICE_VOLR );
|
||||||
voiceAttributes->voice = sound->spu_channel;
|
voiceAttributes->voice = sound->spu_channel;
|
||||||
// Range 0 - 3fff
|
// Range 0 - 3fff
|
||||||
voiceAttributes->volume.left = VOICEVOL_L;
|
voiceAttributes->volume.left = volume;
|
||||||
voiceAttributes->volume.right = VOICEVOL_R;
|
voiceAttributes->volume.right = volume;
|
||||||
SpuSetVoiceAttr(voiceAttributes);
|
SpuSetVoiceAttr(voiceAttributes);
|
||||||
|
}
|
||||||
|
void playSFX(SpuVoiceAttr * voiceAttributes, VAGsound * sound, int volume){
|
||||||
|
// Set voice volume to sample volume
|
||||||
|
setVAGvolume(voiceAttributes, sound, volume);
|
||||||
// Play voice
|
// Play voice
|
||||||
SpuSetKey(SpuOn, sound->spu_channel);
|
SpuSetKey(SpuOn, sound->spu_channel);
|
||||||
}
|
}
|
||||||
@ -101,9 +98,11 @@ void XAsetup(void){
|
|||||||
void getXAoffset(LEVEL * level){
|
void getXAoffset(LEVEL * level){
|
||||||
CdlFILE XAPos = {0};
|
CdlFILE XAPos = {0};
|
||||||
// Load XA file
|
// Load XA file
|
||||||
CdSearchFile(&XAPos, level->XA->name);
|
//~ CdSearchFile(&XAPos, level->XA->name);
|
||||||
|
CdSearchFile(&XAPos, level->XA->banks[0]->name);
|
||||||
// Set cd head to start of file
|
// Set cd head to start of file
|
||||||
level->XA->offset = CdPosToInt(&XAPos.pos);
|
//~ level->XA->offset = CdPosToInt(&XAPos.pos);
|
||||||
|
level->XA->banks[0]->offset = CdPosToInt(&XAPos.pos);
|
||||||
};
|
};
|
||||||
void setXAsample(XAsound * sound, CdlFILTER * filter){
|
void setXAsample(XAsound * sound, CdlFILTER * filter){
|
||||||
filter->chan = sound->channel;
|
filter->chan = sound->channel;
|
||||||
|
BIN
xa/inter8.xa
BIN
xa/inter8.xa
Binary file not shown.
@ -1,8 +0,0 @@
|
|||||||
1 xa lobby.xa 1 0
|
|
||||||
1 xa pixel.xa 1 1
|
|
||||||
1 null
|
|
||||||
1 null
|
|
||||||
1 null
|
|
||||||
1 null
|
|
||||||
1 null
|
|
||||||
1 null
|
|
BIN
xa/lobby.xa
BIN
xa/lobby.xa
Binary file not shown.
BIN
xa/pixel.xa
BIN
xa/pixel.xa
Binary file not shown.
Loading…
Reference in New Issue
Block a user