Skip to content

Commit

Permalink
Dirty fix for #16
Browse files Browse the repository at this point in the history
  • Loading branch information
ABelliqueux committed Aug 17, 2021
1 parent da2eac1 commit 43dea98
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 6 deletions.
2 changes: 1 addition & 1 deletion include/defines.h
Original file line number Diff line number Diff line change
@@ -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
Expand Down
3 changes: 2 additions & 1 deletion include/sound.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
15 changes: 11 additions & 4 deletions src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -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){
Expand All @@ -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;
Expand Down Expand Up @@ -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;
}
Expand Down

0 comments on commit 43dea98

Please sign in to comment.