fix loop logic

This commit is contained in:
wbcbz7 2024-06-06 04:08:08 +07:00
parent 173bb1b11b
commit 7d0567d8a2

View file

@ -155,7 +155,12 @@ int opm_requantize(opm_convert_context_t* ctx) {
// flush delays
delay_rate = 0;
if (it == ctx->vgm.vgmfile.begin() + ctx->vgm.loop_pos) loopFrame = true;
if (it == ctx->vgm.vgmfile.begin() + ctx->vgm.loop_pos) {
loopFrame = true;
for (int i = 0; i < 9 + 1; i++) {
oplchans[i].frame = currentFrame;
}
}
// first, do OPL cases
switch ((VGM_Stream_Opcode)*it) {
@ -249,8 +254,8 @@ int opm_requantize(opm_convert_context_t* ctx) {
ctx->oplchan[ch].push_back(oplchans[ch]);
oplchans[ch].data.clear();
oplchans[ch].frame = -1;
loopFrame = false;
}
loopFrame = false;
// and increment current frame
currentFrame += ratio;
}
@ -326,7 +331,7 @@ int opm_write_file(opm_convert_context_t* ctx) {
memcpy(ctx->opmfile.header.magic, "OPM\x1A", 4);
ctx->opmfile.header.version.v = 0x0001;
ctx->opmfile.header.flags = 0;
ctx->opmfile.header.callstack_depth = 0;
ctx->opmfile.header.callstack_depth = ctx->flags.max_stack_depth;
ctx->opmfile.header.frame_rate = ((double)0x1234DD / (double)(44100 / ctx->delay));
ctx->opmfile.header.reserved = 0;