From 0c63be93f784170280318721fa21cb69aeaf5626 Mon Sep 17 00:00:00 2001 From: ekeeke Date: Fri, 17 Sep 2021 10:08:40 +0200 Subject: [PATCH] [Core/CD] fixed track index when decoding CUE file MegaSD specific loop commands --- core/cd_hw/cdd.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/core/cd_hw/cdd.c b/core/cd_hw/cdd.c index 3eac694..0e70400 100644 --- a/core/cd_hw/cdd.c +++ b/core/cd_hw/cdd.c @@ -623,6 +623,7 @@ int cdd_load(char *filename, char *header) if (fd) { int mm, ss, bb, pregap = 0; + int index = 0; /* DATA track already loaded ? */ if (cdd.toc.last) @@ -795,27 +796,30 @@ int cdd_load(char *filename, char *header) cdd.toc.tracks[cdd.toc.last - 1].end = 0; } } + + /* save current track index */ + index = cdd.toc.last; } /* decode REM LOOP xxx command (MegaSD specific command) */ else if (sscanf(lptr, "REM LOOP %d", &bb) == 1) { - cdd.toc.tracks[cdd.toc.last].loopEnabled = 1; - cdd.toc.tracks[cdd.toc.last].loopOffset = bb; + cdd.toc.tracks[index].loopEnabled = 1; + cdd.toc.tracks[index].loopOffset = bb; isMSDfile = 1; } /* decode REM LOOP command (MegaSD specific command) */ else if (strstr(lptr,"REM LOOP")) { - cdd.toc.tracks[cdd.toc.last].loopEnabled = 1; + cdd.toc.tracks[index].loopEnabled = 1; isMSDfile = 1; } /* decode REM NOLOOP command (MegaSD specific command) */ else if (strstr(lptr,"REM NOLOOP")) { - cdd.toc.tracks[cdd.toc.last].loopEnabled = -1; + cdd.toc.tracks[index].loopEnabled = -1; isMSDfile = 1; }