Created
July 28, 2021 08:49
-
-
Save AliceLR/02870b0251dcb200379b2147f63faea0 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/src/scan.c b/src/scan.c | |
index 23d1f5ae..039f0b86 100644 | |
--- a/src/scan.c | |
+++ b/src/scan.c | |
@@ -54,9 +54,9 @@ static int scan_module(struct context_data *ctx, int ep, int chain) | |
int parm, gvol_memory, f1, f2, p1, p2, ord, ord2; | |
int row, last_row, break_row, row_count, row_count_total; | |
int orders_since_last_valid, any_valid; | |
- int gvl, bpm, speed, base_time, chn; | |
+ int gvl, bpm, speed, chn; | |
int frame_count; | |
- double time, start_time; | |
+ double time, start_time, base_time, frame_duration; | |
int loop_chn, loop_num, inside_loop; | |
int pdelay = 0; | |
int loop_count[XMP_MAX_CHANNELS]; | |
@@ -89,7 +89,8 @@ static int scan_module(struct context_data *ctx, int ep, int chain) | |
bpm = mod->bpm; | |
speed = mod->spd; | |
- base_time = m->rrate; | |
+ base_time = m->time_factor * m->rrate; | |
+ frame_duration = base_time / mod->bpm; | |
#ifndef LIBXMP_CORE_PLAYER | |
st26_speed = 0; | |
#endif | |
@@ -182,7 +183,7 @@ static int scan_module(struct context_data *ctx, int ep, int chain) | |
info->gvl = gvl; | |
info->bpm = bpm; | |
info->speed = speed; | |
- info->time = time + m->time_factor * frame_count * base_time / bpm; | |
+ info->time = time + frame_duration * frame_count; | |
#ifndef LIBXMP_CORE_PLAYER | |
info->st26_speed = st26_speed; | |
#endif | |
@@ -190,7 +191,7 @@ static int scan_module(struct context_data *ctx, int ep, int chain) | |
if (info->start_row == 0 && ord != 0) { | |
if (ord == ep) { | |
- start_time = time + m->time_factor * frame_count * base_time / bpm; | |
+ start_time = time + frame_duration * frame_count; | |
} | |
info->start_row = break_row; | |
@@ -201,6 +202,7 @@ static int scan_module(struct context_data *ctx, int ep, int chain) | |
/* Prevent crashes caused by large softmixer frames */ | |
if (bpm < XMP_MIN_BPM) { | |
bpm = XMP_MIN_BPM; | |
+ frame_duration = base_time / bpm; | |
} | |
/* Date: Sat, 8 Sep 2007 04:01:06 +0200 | |
@@ -303,9 +305,10 @@ static int scan_module(struct context_data *ctx, int ep, int chain) | |
#endif | |
} | |
} else { | |
- time += m->time_factor * frame_count * base_time / bpm; | |
+ time += frame_duration * frame_count; | |
frame_count = 0; | |
bpm = parm; | |
+ frame_duration = base_time / bpm; | |
} | |
} | |
} | |
@@ -346,9 +349,10 @@ static int scan_module(struct context_data *ctx, int ep, int chain) | |
if (parm >= 0x20) { | |
frame_count += row_count * speed; | |
row_count = 0; | |
- time += m->time_factor * frame_count * base_time / bpm; | |
+ time += frame_duration * frame_count; | |
frame_count = 0; | |
bpm = parm; | |
+ frame_duration = base_time / bpm; | |
} | |
} | |
@@ -357,35 +361,38 @@ static int scan_module(struct context_data *ctx, int ep, int chain) | |
parm = (f1 == FX_IT_BPM) ? p1 : p2; | |
frame_count += row_count * speed; | |
row_count = 0; | |
- time += m->time_factor * frame_count * base_time / bpm; | |
+ time += frame_duration * frame_count; | |
frame_count = 0; | |
if (MSN(parm) == 0) { | |
- time += m->time_factor * base_time / bpm; | |
+ time += frame_duration; | |
for (i = 1; i < speed; i++) { | |
bpm -= LSN(parm); | |
if (bpm < 0x20) | |
bpm = 0x20; | |
- time += m->time_factor * base_time / bpm; | |
+ frame_duration = base_time / bpm; | |
+ time += frame_duration; | |
} | |
/* remove one row at final bpm */ | |
- time -= m->time_factor * speed * base_time / bpm; | |
+ time -= frame_duration * speed; | |
} else if (MSN(parm) == 1) { | |
- time += m->time_factor * base_time / bpm; | |
+ time += frame_duration; | |
for (i = 1; i < speed; i++) { | |
bpm += LSN(parm); | |
if (bpm > 0xff) | |
bpm = 0xff; | |
- time += m->time_factor * base_time / bpm; | |
+ frame_duration = base_time / bpm; | |
+ time += frame_duration; | |
} | |
/* remove one row at final bpm */ | |
- time -= m->time_factor * speed * base_time / bpm; | |
+ time -= frame_duration * speed; | |
} else { | |
bpm = parm; | |
+ frame_duration = base_time / bpm; | |
} | |
} | |
@@ -511,7 +518,7 @@ end_module: | |
time -= start_time; | |
frame_count += row_count * speed; | |
- return (time + m->time_factor * frame_count * base_time / bpm); | |
+ return (time + frame_duration * frame_count); | |
} | |
int libxmp_get_sequence(struct context_data *ctx, int ord) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment