From 43dea98d6305b6e1d3e2188d9321d9b63a334c74 Mon Sep 17 00:00:00 2001 From: ABelliqueux Date: Tue, 17 Aug 2021 16:44:42 +0200 Subject: [PATCH] Dirty fix for #16 --- include/defines.h | 2 +- include/sound.h | 3 ++- src/main.c | 15 +++++++++++---- 3 files changed, 14 insertions(+), 6 deletions(-) diff --git a/include/defines.h b/include/defines.h index b6a5ce0..212a4cc 100644 --- a/include/defines.h +++ b/include/defines.h @@ -1,5 +1,5 @@ #define VMODE 0 // 0 == NTSC, 1 == PAL -#define VSYNC 0 +#define VSYNC 1 #define SCREENXRES 320 #define SCREENYRES 240 #define CENTERX SCREENXRES/2 diff --git a/include/sound.h b/include/sound.h index 9e2b1f8..43d268a 100644 --- a/include/sound.h +++ b/include/sound.h @@ -4,7 +4,8 @@ // XA // Sector offset for XA data 4: simple speed, 8: double speed #define XA_CHANNELS 8 -#define XA_CDSPEED (XA_CHANNELS >> VSYNC) +#define XA_CDSPEED (XA_CHANNELS >> VSYNC) * ONE +#define XA_RATE 380 // Number of XA samples ( != # of XA files ) #define XA_TRACKS 2 // VAG diff --git a/src/main.c b/src/main.c index 48f39b3..c955a8b 100644 --- a/src/main.c +++ b/src/main.c @@ -211,13 +211,13 @@ int main() { sample = 0; setXAsample(&curLvl.XA->samples[sample], &filter); // Main loop - while ( VSync(VSYNC) ) { + //~ while ( VSync(VSYNC) ) { + while ( 1 ) { dt = GetRCnt(RCntCNT1) - oldTime; oldTime = GetRCnt(RCntCNT1); // XA playback // if sample is set if (sample != -1 ){ - // TODO : Fix XA playback with VSYNC = 1 // Begin XA file playback... // if sample's cursor is 0 if (curLvl.XA->samples[sample].cursor == 0){ @@ -229,7 +229,10 @@ int main() { // Set playing flag } // if sample's cursor is close to sample's end position, stop playback - 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 ){ + // 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 ){ //~ CdControlF(CdlStop,0); curLvl.XA->samples[sample].cursor = -1; //~ sample = !sample; @@ -423,10 +426,14 @@ int main() { AddPrims(otdisc[db], ot[db] + OTLEN - 1, ot[db]); FntPrint("\n#Tri : %d\n", triCount); - FntPrint("#RCnt : %d %d %d\n", VSync(-1), dt); + FntPrint("#RCnt : %d %d\n", VSync(-1), dt); + //~ 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", curLvl.XA->samples[sample].cursor ); FntPrint("CamAngle : %d\n", curCamAngle); FntFlush(-1); display( &disp[db], &draw[db], otdisc[db], primbuff[db], &nextpri, &db); + } return 0; }