Fix XA playback delay
This commit is contained in:
parent
d662d0b465
commit
da2eac1d48
@ -16,6 +16,8 @@ struct NODE;
|
|||||||
struct LEVEL;
|
struct LEVEL;
|
||||||
struct VAGsound;
|
struct VAGsound;
|
||||||
struct VAGbank;
|
struct VAGbank;
|
||||||
|
struct XAbank;
|
||||||
|
struct XAsound;
|
||||||
|
|
||||||
typedef struct BODY {
|
typedef struct BODY {
|
||||||
VECTOR gForce;
|
VECTOR gForce;
|
||||||
@ -141,7 +143,7 @@ typedef struct XAsound {
|
|||||||
} XAsound;
|
} XAsound;
|
||||||
|
|
||||||
typedef struct XAbank {
|
typedef struct XAbank {
|
||||||
char * name;
|
char name[16];
|
||||||
u_int index;
|
u_int index;
|
||||||
int offset;
|
int offset;
|
||||||
XAsound samples[];
|
XAsound samples[];
|
||||||
|
@ -33,7 +33,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 32
|
#define FNT_SCR_Y 168
|
||||||
#define FNT_SCR_W 240
|
#define FNT_SCR_W 240
|
||||||
#define FNT_SCR_H 48
|
#define FNT_SCR_H 48
|
||||||
#define FNT_SCR_BG 0
|
#define FNT_SCR_BG 0
|
||||||
|
@ -56,4 +56,5 @@ u_long setSPUtransfer(SpuVoiceAttr * voiceAttributes, VAGsound * sound);
|
|||||||
void playSFX(SpuVoiceAttr * voiceAttributes, VAGsound * sound);
|
void playSFX(SpuVoiceAttr * voiceAttributes, VAGsound * sound);
|
||||||
// XA playback
|
// XA playback
|
||||||
void XAsetup(void);
|
void XAsetup(void);
|
||||||
|
void getXAoffset(LEVEL * level);
|
||||||
void setXAsample(XAsound * sound, CdlFILTER * filter);
|
void setXAsample(XAsound * sound, CdlFILTER * filter);
|
||||||
|
@ -1021,11 +1021,9 @@ XAbank XABank0 = {
|
|||||||
{
|
{
|
||||||
//channel 0
|
//channel 0
|
||||||
{ 0, 698464, 1, 0, 0, ((698464/2336)-1) * XA_CHANNELS, -1 },
|
{ 0, 698464, 1, 0, 0, ((698464/2336)-1) * XA_CHANNELS, -1 },
|
||||||
{ 1, 366752, 1, 1 , 0, ((366752/2336)-1) * XA_CHANNELS, -1 },
|
{ 1, 366752, 1, 1 , 0, ((366752/2336)-1) * XA_CHANNELS, -1 }
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
// XA file to load
|
|
||||||
//~ static char * loadXA0 = "\\INTER8.XA;1";
|
|
||||||
|
|
||||||
LEVEL level0 = {
|
LEVEL level0 = {
|
||||||
&level0_BGc,
|
&level0_BGc,
|
||||||
|
@ -39,4 +39,3 @@ extern NODE * level0_curNode;
|
|||||||
extern NODE level0_nodePlane;
|
extern NODE level0_nodePlane;
|
||||||
extern VAGbank VAGBank0;
|
extern VAGbank VAGBank0;
|
||||||
extern XAbank XABank0;
|
extern XAbank XABank0;
|
||||||
//~ extern char * loadXA0;
|
|
||||||
|
@ -11073,8 +11073,6 @@ XAbank XABank1 = {
|
|||||||
{ 1, 366752, 1, 1 , 0, ((366752/2336)-1) * XA_CHANNELS, -1 },
|
{ 1, 366752, 1, 1 , 0, ((366752/2336)-1) * XA_CHANNELS, -1 },
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
// XA file to load
|
|
||||||
//~ static char * loadXA1 = "\\INTER8.XA;1";
|
|
||||||
|
|
||||||
LEVEL level1 = {
|
LEVEL level1 = {
|
||||||
&level1_BGc,
|
&level1_BGc,
|
||||||
|
@ -178,4 +178,3 @@ extern NODE level1_nodegnd_002;
|
|||||||
extern NODE level1_nodegnd;
|
extern NODE level1_nodegnd;
|
||||||
extern VAGbank VAGBank1;
|
extern VAGbank VAGBank1;
|
||||||
extern XAbank XABank1;
|
extern XAbank XABank1;
|
||||||
//~ extern char * loadXA1;
|
|
||||||
|
54
src/main.c
54
src/main.c
@ -112,44 +112,7 @@ int atime = 0;
|
|||||||
char spu_malloc_rec[SPU_MALLOC_RECSIZ * (2 + MALLOC_MAX + 1)];
|
char spu_malloc_rec[SPU_MALLOC_RECSIZ * (2 + MALLOC_MAX + 1)];
|
||||||
// SPU settings
|
// SPU settings
|
||||||
SpuCommonAttr spuSettings; // structure for changing common voice attributes
|
SpuCommonAttr spuSettings; // structure for changing common voice attributes
|
||||||
SpuVoiceAttr voiceAttributes ; // structure for changing individual voice attributes
|
SpuVoiceAttr voiceAttributes ; // structure for changing individual voice attributes
|
||||||
// extern VAG files
|
|
||||||
//~ extern u_char _binary_VAG_0_come_vag_start;
|
|
||||||
//~ extern u_char _binary_VAG_1_cuek_vag_start;
|
|
||||||
//~ extern u_char _binary_VAG_2_erro_vag_start;
|
|
||||||
//~ extern u_char _binary_VAG_3_hehe_vag_start;
|
|
||||||
//~ extern u_char _binary_VAG_4_m4a1_vag_start;
|
|
||||||
//~ extern u_char _binary_VAG_5_punc_vag_start;
|
|
||||||
//~ extern u_char _binary_VAG_7_wron_vag_start;
|
|
||||||
//~ extern u_char _binary_VAG_8_yooo_vag_start;
|
|
||||||
// soundBank
|
|
||||||
//~ VAGbank VAGBank = {
|
|
||||||
//~ 8,
|
|
||||||
//~ {
|
|
||||||
//~ { &_binary_VAG_0_come_vag_start, SPU_00CH, 0 },
|
|
||||||
//~ { &_binary_VAG_1_cuek_vag_start, SPU_01CH, 0 },
|
|
||||||
//~ { &_binary_VAG_2_erro_vag_start, SPU_02CH, 0 },
|
|
||||||
//~ { &_binary_VAG_3_hehe_vag_start, SPU_03CH, 0 },
|
|
||||||
//~ { &_binary_VAG_4_m4a1_vag_start, SPU_04CH, 0 },
|
|
||||||
//~ { &_binary_VAG_5_punc_vag_start, SPU_05CH, 0 },
|
|
||||||
//~ { &_binary_VAG_7_wron_vag_start, SPU_06CH, 0 },
|
|
||||||
//~ { &_binary_VAG_8_yooo_vag_start, SPU_07CH, 0 }
|
|
||||||
//~ }
|
|
||||||
//~ };
|
|
||||||
// XA playback
|
|
||||||
//~ XAbank XABank = {
|
|
||||||
//~ 8,
|
|
||||||
//~ 0,
|
|
||||||
//~ {
|
|
||||||
//~ //channel 0
|
|
||||||
//~ { 0, 698464, 1, 0, 0, ((698464/2336)-1) * XA_CHANNELS, -1 },
|
|
||||||
//~ { 1, 366752, 1, 1 , 0, ((366752/2336)-1) * XA_CHANNELS, -1 },
|
|
||||||
//~ }
|
|
||||||
//~ };
|
|
||||||
//~ // XA file to load
|
|
||||||
//~ static char * loadXA = "\\INTER8.XA;1";
|
|
||||||
// File informations : pos, size, name
|
|
||||||
CdlFILE XAPos = {0};
|
|
||||||
// CD filter
|
// CD filter
|
||||||
CdlFILTER filter;
|
CdlFILTER filter;
|
||||||
// File position in m/s/f
|
// File position in m/s/f
|
||||||
@ -178,10 +141,6 @@ int main() {
|
|||||||
CdInit();
|
CdInit();
|
||||||
// Load level
|
// Load level
|
||||||
LoadLevelCD(overlayFile, &load_all_overlays_here);
|
LoadLevelCD(overlayFile, &load_all_overlays_here);
|
||||||
// Load XA file
|
|
||||||
CdSearchFile( &XAPos, curLvl.XA->name);
|
|
||||||
// Set cd head to start of file
|
|
||||||
curLvl.XA->offset = CdPosToInt(&XAPos.pos);
|
|
||||||
#endif
|
#endif
|
||||||
// TODO : Add switch case to get the correct pointers
|
// TODO : Add switch case to get the correct pointers
|
||||||
// Get needed pointers from level file
|
// Get needed pointers from level file
|
||||||
@ -190,6 +149,13 @@ int main() {
|
|||||||
} else if ( level == 1) {
|
} else if ( level == 1) {
|
||||||
LvlPtrSet( &curLvl, &level1);
|
LvlPtrSet( &curLvl, &level1);
|
||||||
}
|
}
|
||||||
|
#ifdef USECD
|
||||||
|
getXAoffset(&curLvl);
|
||||||
|
//~ // Load XA file
|
||||||
|
//~ CdSearchFile(&XAPos, curLvl.XA->name);
|
||||||
|
//~ // Set cd head to start of file
|
||||||
|
//~ curLvl.XA->offset = CdPosToInt(&XAPos.pos);
|
||||||
|
#endif
|
||||||
levelWas = level;
|
levelWas = level;
|
||||||
// Copy light matrices / vector to scratchpad
|
// Copy light matrices / vector to scratchpad
|
||||||
setDCLightEnv(curLvl.cmat, curLvl.lgtmat, &lgtang);
|
setDCLightEnv(curLvl.cmat, curLvl.lgtmat, &lgtang);
|
||||||
@ -256,7 +222,7 @@ int main() {
|
|||||||
// if sample's cursor is 0
|
// if sample's cursor is 0
|
||||||
if (curLvl.XA->samples[sample].cursor == 0){
|
if (curLvl.XA->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->samples[sample].start + curLvl.XA->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);
|
||||||
@ -457,7 +423,7 @@ int main() {
|
|||||||
AddPrims(otdisc[db], ot[db] + OTLEN - 1, ot[db]);
|
AddPrims(otdisc[db], ot[db] + OTLEN - 1, ot[db]);
|
||||||
|
|
||||||
FntPrint("\n#Tri : %d\n", triCount);
|
FntPrint("\n#Tri : %d\n", triCount);
|
||||||
FntPrint("#RCnt : %d %d %d\n", VSync(-1), XA_CDSPEED, dt);
|
FntPrint("#RCnt : %d %d %d\n", VSync(-1), dt);
|
||||||
FntPrint("CamAngle : %d\n", curCamAngle);
|
FntPrint("CamAngle : %d\n", curCamAngle);
|
||||||
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);
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
#include "../include/psx.h"
|
#include "../include/psx.h"
|
||||||
|
#include "../include/sound.h"
|
||||||
|
|
||||||
|
|
||||||
void setDCLightEnv(MATRIX * curLevelCMat, MATRIX * curLevelLgtMat, SVECTOR * curLevelLgtAng){
|
void setDCLightEnv(MATRIX * curLevelCMat, MATRIX * curLevelLgtMat, SVECTOR * curLevelLgtAng){
|
||||||
@ -103,8 +104,8 @@ void LvlPtrSet(LEVEL * curLevel, LEVEL * level){
|
|||||||
curLevel->camPath = level->camPath;
|
curLevel->camPath = level->camPath;
|
||||||
curLevel->camAngles = level->camAngles;
|
curLevel->camAngles = level->camAngles;
|
||||||
curLevel->curNode = level->curNode; // Blank
|
curLevel->curNode = level->curNode; // Blank
|
||||||
curLevel->VAG = level->VAG; // Blank
|
curLevel->VAG = level->VAG;
|
||||||
curLevel->XA = level->XA; // Blank
|
curLevel->XA = level->XA;
|
||||||
|
|
||||||
//~ curLevel->actorPtr->body = level->actorPtr->body;
|
//~ curLevel->actorPtr->body = level->actorPtr->body;
|
||||||
// Move these to drawPoly()
|
// Move these to drawPoly()
|
||||||
@ -121,6 +122,8 @@ int LoadLevelCD(const char*const LevelName, u_long * LoadAddress){
|
|||||||
void SwitchLevel( LEVEL * curLevel, LEVEL * loadLevel ){
|
void SwitchLevel( LEVEL * curLevel, LEVEL * loadLevel ){
|
||||||
//~ ScrRst();
|
//~ ScrRst();
|
||||||
LvlPtrSet( curLevel, loadLevel);
|
LvlPtrSet( curLevel, loadLevel);
|
||||||
|
// XA
|
||||||
|
getXAoffset(curLevel);
|
||||||
// Reload textures
|
// Reload textures
|
||||||
for (int k = 0; k < *curLevel->meshes_length ; k++){
|
for (int k = 0; k < *curLevel->meshes_length ; k++){
|
||||||
// Check data exists
|
// Check data exists
|
||||||
@ -148,6 +151,7 @@ void SwitchLevel( LEVEL * curLevel, LEVEL * loadLevel ){
|
|||||||
applyVector( &curLevel->propPtr->body->position, 0, 100, 0, -=);
|
applyVector( &curLevel->propPtr->body->position, 0, 100, 0, -=);
|
||||||
applyVector( &curLevel->propPtr->body->velocity, 0, 0, 0, =);
|
applyVector( &curLevel->propPtr->body->velocity, 0, 0, 0, =);
|
||||||
applyVector( &curLevel->propPtr->body->gForce, 0, 0, 0, =);
|
applyVector( &curLevel->propPtr->body->gForce, 0, 0, 0, =);
|
||||||
|
|
||||||
};
|
};
|
||||||
void LoadTexture(u_long * tim, TIM_IMAGE * tparam){ // This part is from Lameguy64's tutorial series : lameguy64.net/svn/pstutorials/chapter1/3-textures.html login/pw: annoyingmous
|
void LoadTexture(u_long * tim, TIM_IMAGE * tparam){ // This part is from Lameguy64's tutorial series : lameguy64.net/svn/pstutorials/chapter1/3-textures.html login/pw: annoyingmous
|
||||||
OpenTIM(tim); // Open the tim binary data, feed it the address of the data in memory
|
OpenTIM(tim); // Open the tim binary data, feed it the address of the data in memory
|
||||||
|
@ -73,7 +73,6 @@ u_long setSPUtransfer(SpuVoiceAttr * voiceAttributes, VAGsound * sound){
|
|||||||
//~ return 1;
|
//~ return 1;
|
||||||
//~ }
|
//~ }
|
||||||
//~ return transferred;
|
//~ return transferred;
|
||||||
FntPrint("Tr: %", transferred);
|
|
||||||
return spu_address;
|
return spu_address;
|
||||||
}
|
}
|
||||||
void playSFX(SpuVoiceAttr * voiceAttributes, VAGsound * sound){
|
void playSFX(SpuVoiceAttr * voiceAttributes, VAGsound * sound){
|
||||||
@ -99,6 +98,13 @@ void XAsetup(void){
|
|||||||
// Pause at current pos
|
// Pause at current pos
|
||||||
CdControlF(CdlPause,0);
|
CdControlF(CdlPause,0);
|
||||||
}
|
}
|
||||||
|
void getXAoffset(LEVEL * level){
|
||||||
|
CdlFILE XAPos = {0};
|
||||||
|
// Load XA file
|
||||||
|
CdSearchFile(&XAPos, level->XA->name);
|
||||||
|
// Set cd head to start of file
|
||||||
|
level->XA->offset = CdPosToInt(&XAPos.pos);
|
||||||
|
};
|
||||||
void setXAsample(XAsound * sound, CdlFILTER * filter){
|
void setXAsample(XAsound * sound, CdlFILTER * filter){
|
||||||
filter->chan = sound->channel;
|
filter->chan = sound->channel;
|
||||||
filter->file = sound->file;
|
filter->file = sound->file;
|
||||||
|
Loading…
Reference in New Issue
Block a user