mirror of
https://github.com/ekeeke/Genesis-Plus-GX.git
synced 2025-02-04 14:06:24 +01:00
[Core/CD] improved CD audio savestate and CD file seeking (in preparation for MegaSD support)
This commit is contained in:
parent
76a08ebe6a
commit
e87891fcca
430
core/cd_hw/cdd.c
430
core/cd_hw/cdd.c
@ -216,6 +216,7 @@ void cdd_reset(void)
|
|||||||
int cdd_context_save(uint8 *state)
|
int cdd_context_save(uint8 *state)
|
||||||
{
|
{
|
||||||
int bufferptr = 0;
|
int bufferptr = 0;
|
||||||
|
unsigned int offset = 0;
|
||||||
|
|
||||||
save_param(&cdd.cycles, sizeof(cdd.cycles));
|
save_param(&cdd.cycles, sizeof(cdd.cycles));
|
||||||
save_param(&cdd.latency, sizeof(cdd.latency));
|
save_param(&cdd.latency, sizeof(cdd.latency));
|
||||||
@ -225,37 +226,121 @@ int cdd_context_save(uint8 *state)
|
|||||||
save_param(&cdd.fader, sizeof(cdd.fader));
|
save_param(&cdd.fader, sizeof(cdd.fader));
|
||||||
save_param(&cdd.status, sizeof(cdd.status));
|
save_param(&cdd.status, sizeof(cdd.status));
|
||||||
|
|
||||||
|
/* current track is an audio track ? */
|
||||||
|
if (cdd.toc.tracks[cdd.index].type == TYPE_AUDIO)
|
||||||
|
{
|
||||||
|
/* get file read offset */
|
||||||
|
#if defined(USE_LIBCHDR)
|
||||||
|
if (cdd.chd.file)
|
||||||
|
{
|
||||||
|
/* CHD file offset */
|
||||||
|
offset = cdd.chd.hunkofs;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
#endif
|
||||||
|
#if defined(USE_LIBTREMOR) || defined(USE_LIBVORBIS)
|
||||||
|
if (cdd.toc.tracks[cdd.index].vf.seekable)
|
||||||
|
{
|
||||||
|
/* VORBIS file sample offset */
|
||||||
|
offset = ov_pcm_tell(&cdd.toc.tracks[cdd.index].vf);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
#endif
|
||||||
|
if (cdd.toc.tracks[cdd.index].fd)
|
||||||
|
{
|
||||||
|
/* PCM file offset */
|
||||||
|
offset = cdStreamTell(cdd.toc.tracks[cdd.index].fd);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
save_param(&offset, sizeof(offset));
|
||||||
|
save_param(&cdd.audio, sizeof(cdd.audio));
|
||||||
|
|
||||||
return bufferptr;
|
return bufferptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
int cdd_context_load(uint8 *state)
|
int cdd_context_load(uint8 *state, char *version)
|
||||||
{
|
{
|
||||||
int lba;
|
unsigned int offset, lba, index;
|
||||||
int bufferptr = 0;
|
int bufferptr = 0;
|
||||||
|
|
||||||
|
load_param(&cdd.cycles, sizeof(cdd.cycles));
|
||||||
|
load_param(&cdd.latency, sizeof(cdd.latency));
|
||||||
|
load_param(&index, sizeof(cdd.index));
|
||||||
|
load_param(&lba, sizeof(cdd.lba));
|
||||||
|
load_param(&cdd.scanOffset, sizeof(cdd.scanOffset));
|
||||||
|
load_param(&cdd.fader, sizeof(cdd.fader));
|
||||||
|
load_param(&cdd.status, sizeof(cdd.status));
|
||||||
|
|
||||||
|
/* update current sector */
|
||||||
|
cdd.lba = lba;
|
||||||
|
|
||||||
|
/* support for previous state version (1.7.5) */
|
||||||
|
if ((version[11] == 0x31) && (version[13] == 0x37) && (version[15] == 0x35))
|
||||||
|
{
|
||||||
|
/* current track is an audio track ? */
|
||||||
|
if (cdd.toc.tracks[index].type == TYPE_AUDIO)
|
||||||
|
{
|
||||||
|
/* stay within track limits when seeking files */
|
||||||
|
if (lba < cdd.toc.tracks[index].start)
|
||||||
|
{
|
||||||
|
lba = cdd.toc.tracks[index].start;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* seek to current track sector */
|
||||||
|
cdd_seek_audio(index, lba);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
load_param(&offset, sizeof(offset));
|
||||||
|
load_param(&cdd.audio, sizeof(cdd.audio));
|
||||||
|
|
||||||
|
/* current track is an audio track ? */
|
||||||
|
if (cdd.toc.tracks[index].type == TYPE_AUDIO)
|
||||||
|
{
|
||||||
#if defined(USE_LIBTREMOR) || defined(USE_LIBVORBIS)
|
#if defined(USE_LIBTREMOR) || defined(USE_LIBVORBIS)
|
||||||
#ifdef DISABLE_MANY_OGG_OPEN_FILES
|
#ifdef DISABLE_MANY_OGG_OPEN_FILES
|
||||||
|
/* check if track index has changed */
|
||||||
|
if (index != cdd.index)
|
||||||
|
{
|
||||||
/* close previous track VORBIS file structure to save memory */
|
/* close previous track VORBIS file structure to save memory */
|
||||||
if (cdd.toc.tracks[cdd.index].vf.datasource)
|
if (cdd.toc.tracks[cdd.index].vf.datasource)
|
||||||
{
|
{
|
||||||
ogg_free(cdd.index);
|
ogg_free(cdd.index);
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
#endif
|
|
||||||
|
|
||||||
load_param(&cdd.cycles, sizeof(cdd.cycles));
|
/* open current track VORBIS file */
|
||||||
load_param(&cdd.latency, sizeof(cdd.latency));
|
if (cdd.toc.tracks[index].vf.seekable)
|
||||||
load_param(&cdd.index, sizeof(cdd.index));
|
|
||||||
load_param(&cdd.lba, sizeof(cdd.lba));
|
|
||||||
load_param(&cdd.scanOffset, sizeof(cdd.scanOffset));
|
|
||||||
load_param(&cdd.fader, sizeof(cdd.fader));
|
|
||||||
load_param(&cdd.status, sizeof(cdd.status));
|
|
||||||
|
|
||||||
/* adjust current LBA within track limit */
|
|
||||||
lba = cdd.lba;
|
|
||||||
if (lba < cdd.toc.tracks[cdd.index].start)
|
|
||||||
{
|
{
|
||||||
lba = cdd.toc.tracks[cdd.index].start;
|
ov_open_callbacks(cdd.toc.tracks[index].fd,&cdd.toc.tracks[index].vf,0,0,cb);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
/* seek to current file read offset */
|
||||||
|
#if defined(USE_LIBCHDR)
|
||||||
|
if (cdd.chd.file)
|
||||||
|
{
|
||||||
|
/* CHD file offset */
|
||||||
|
cdd.chd.hunkofs = offset;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
#endif
|
||||||
|
#if defined(USE_LIBTREMOR) || defined(USE_LIBVORBIS)
|
||||||
|
if (cdd.toc.tracks[index].vf.seekable)
|
||||||
|
{
|
||||||
|
/* VORBIS file sample offset */
|
||||||
|
ov_pcm_seek(&cdd.toc.tracks[index].vf, offset);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
#endif
|
||||||
|
if (cdd.toc.tracks[index].fd)
|
||||||
|
{
|
||||||
|
/* PCM file offset */
|
||||||
|
cdStreamSeek(cdd.toc.tracks[index].fd, offset, SEEK_SET);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* seek to current subcode position */
|
/* seek to current subcode position */
|
||||||
@ -265,36 +350,8 @@ int cdd_context_load(uint8 *state)
|
|||||||
cdStreamSeek(cdd.toc.sub, lba * 96, SEEK_SET);
|
cdStreamSeek(cdd.toc.sub, lba * 96, SEEK_SET);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* seek to current track position */
|
/* update current track index */
|
||||||
#if defined(USE_LIBCHDR)
|
cdd.index = index;
|
||||||
if (cdd.chd.file)
|
|
||||||
{
|
|
||||||
/* CHD file offset */
|
|
||||||
cdd.chd.hunkofs = cdd.toc.tracks[cdd.index].offset + (lba * CD_FRAME_SIZE);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
#endif
|
|
||||||
if (cdd.toc.tracks[cdd.index].type)
|
|
||||||
{
|
|
||||||
/* DATA track */
|
|
||||||
cdStreamSeek(cdd.toc.tracks[cdd.index].fd, lba * cdd.sectorSize, SEEK_SET);
|
|
||||||
}
|
|
||||||
#if defined(USE_LIBTREMOR) || defined(USE_LIBVORBIS)
|
|
||||||
else if (cdd.toc.tracks[cdd.index].vf.seekable)
|
|
||||||
{
|
|
||||||
#ifdef DISABLE_MANY_OGG_OPEN_FILES
|
|
||||||
/* VORBIS file need to be opened first */
|
|
||||||
ov_open_callbacks(cdd.toc.tracks[cdd.index].fd,&cdd.toc.tracks[cdd.index].vf,0,0,cb);
|
|
||||||
#endif
|
|
||||||
/* VORBIS AUDIO track */
|
|
||||||
ov_pcm_seek(&cdd.toc.tracks[cdd.index].vf, (lba * 588) - cdd.toc.tracks[cdd.index].offset);
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
else if (cdd.toc.tracks[cdd.index].fd)
|
|
||||||
{
|
|
||||||
/* PCM AUDIO track */
|
|
||||||
cdStreamSeek(cdd.toc.tracks[cdd.index].fd, (lba * 2352) - cdd.toc.tracks[cdd.index].offset, SEEK_SET);
|
|
||||||
}
|
|
||||||
|
|
||||||
return bufferptr;
|
return bufferptr;
|
||||||
}
|
}
|
||||||
@ -1305,6 +1362,52 @@ void cdd_read_data(uint8 *dst, uint8 *subheader)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void cdd_seek_audio(int index, int lba)
|
||||||
|
{
|
||||||
|
#if defined(USE_LIBTREMOR) || defined(USE_LIBVORBIS)
|
||||||
|
#ifdef DISABLE_MANY_OGG_OPEN_FILES
|
||||||
|
/* check if track index has changed */
|
||||||
|
if (index != cdd.index)
|
||||||
|
{
|
||||||
|
/* close previous track VORBIS file structure to save memory */
|
||||||
|
if (cdd.toc.tracks[cdd.index].vf.datasource)
|
||||||
|
{
|
||||||
|
ogg_free(cdd.index);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* open current track VORBIS file */
|
||||||
|
if (cdd.toc.tracks[index].vf.seekable)
|
||||||
|
{
|
||||||
|
ov_open_callbacks(cdd.toc.tracks[index].fd,&cdd.toc.tracks[index].vf,0,0,cb);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* seek to track position */
|
||||||
|
#if defined(USE_LIBCHDR)
|
||||||
|
if (cdd.chd.file)
|
||||||
|
{
|
||||||
|
/* CHD file offset */
|
||||||
|
cdd.chd.hunkofs = cdd.toc.tracks[index].offset + (lba * CD_FRAME_SIZE);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
#endif
|
||||||
|
#if defined(USE_LIBTREMOR) || defined(USE_LIBVORBIS)
|
||||||
|
if (cdd.toc.tracks[index].vf.seekable)
|
||||||
|
{
|
||||||
|
/* VORBIS AUDIO track */
|
||||||
|
ov_pcm_seek(&cdd.toc.tracks[index].vf, (lba * 588) - cdd.toc.tracks[index].offset);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
#endif
|
||||||
|
if (cdd.toc.tracks[index].fd)
|
||||||
|
{
|
||||||
|
/* PCM AUDIO track */
|
||||||
|
cdStreamSeek(cdd.toc.tracks[index].fd, (lba * 2352) - cdd.toc.tracks[index].offset, SEEK_SET);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void cdd_read_audio(unsigned int samples)
|
void cdd_read_audio(unsigned int samples)
|
||||||
{
|
{
|
||||||
/* previous audio outputs */
|
/* previous audio outputs */
|
||||||
@ -1637,107 +1740,60 @@ void cdd_update(void)
|
|||||||
/* check end of current track */
|
/* check end of current track */
|
||||||
if (cdd.lba >= cdd.toc.tracks[cdd.index].end)
|
if (cdd.lba >= cdd.toc.tracks[cdd.index].end)
|
||||||
{
|
{
|
||||||
#if defined(USE_LIBTREMOR) || defined(USE_LIBVORBIS)
|
/* seek to next track start (assuming it can only be an audio track) */
|
||||||
#ifdef DISABLE_MANY_OGG_OPEN_FILES
|
cdd_seek_audio(cdd.index + 1, cdd.toc.tracks[cdd.index + 1].start);
|
||||||
/* close previous track VORBIS file structure to save memory */
|
|
||||||
if (cdd.toc.tracks[cdd.index].vf.datasource)
|
/* increment current track index */
|
||||||
{
|
|
||||||
ogg_free(cdd.index);
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
#endif
|
|
||||||
/* play next track */
|
|
||||||
cdd.index++;
|
cdd.index++;
|
||||||
|
|
||||||
/* PAUSE between tracks */
|
/* PAUSE between tracks */
|
||||||
scd.regs[0x36>>1].byte.h = 0x01;
|
scd.regs[0x36>>1].byte.h = 0x01;
|
||||||
|
|
||||||
/* seek to next audio track start */
|
|
||||||
#if defined(USE_LIBCHDR)
|
|
||||||
if (cdd.chd.file)
|
|
||||||
{
|
|
||||||
/* CHD file offset */
|
|
||||||
cdd.chd.hunkofs = cdd.toc.tracks[cdd.index].offset + (cdd.toc.tracks[cdd.index].start * CD_FRAME_SIZE);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
#endif
|
|
||||||
#if defined(USE_LIBTREMOR) || defined(USE_LIBVORBIS)
|
|
||||||
if (cdd.toc.tracks[cdd.index].vf.seekable)
|
|
||||||
{
|
|
||||||
#ifdef DISABLE_MANY_OGG_OPEN_FILES
|
|
||||||
/* VORBIS file need to be opened first */
|
|
||||||
ov_open_callbacks(cdd.toc.tracks[cdd.index].fd,&cdd.toc.tracks[cdd.index].vf,0,0,cb);
|
|
||||||
#endif
|
|
||||||
ov_pcm_seek(&cdd.toc.tracks[cdd.index].vf, (cdd.toc.tracks[cdd.index].start * 588) - cdd.toc.tracks[cdd.index].offset);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
#endif
|
|
||||||
if (cdd.toc.tracks[cdd.index].fd)
|
|
||||||
{
|
|
||||||
cdStreamSeek(cdd.toc.tracks[cdd.index].fd, (cdd.toc.tracks[cdd.index].start * 2352) - cdd.toc.tracks[cdd.index].offset, SEEK_SET);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* scanning disc */
|
/* scanning disc */
|
||||||
else if (cdd.status == CD_SCAN)
|
else if (cdd.status == CD_SCAN)
|
||||||
{
|
{
|
||||||
|
/* current track index */
|
||||||
|
int index = cdd.index;
|
||||||
|
|
||||||
/* fast-forward or fast-rewind */
|
/* fast-forward or fast-rewind */
|
||||||
cdd.lba += cdd.scanOffset;
|
cdd.lba += cdd.scanOffset;
|
||||||
|
|
||||||
/* check current track limits */
|
/* check current track limits */
|
||||||
if (cdd.lba >= cdd.toc.tracks[cdd.index].end)
|
if (cdd.lba >= cdd.toc.tracks[index].end)
|
||||||
{
|
{
|
||||||
#if defined(USE_LIBTREMOR) || defined(USE_LIBVORBIS)
|
|
||||||
#ifdef DISABLE_MANY_OGG_OPEN_FILES
|
|
||||||
/* close previous track VORBIS file structure to save memory */
|
|
||||||
if (cdd.toc.tracks[cdd.index].vf.datasource)
|
|
||||||
{
|
|
||||||
ogg_free(cdd.index);
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* next track */
|
/* next track */
|
||||||
cdd.index++;
|
index++;
|
||||||
|
|
||||||
/* check disc limits */
|
/* check disc limits */
|
||||||
if (cdd.index < cdd.toc.last)
|
if (index < cdd.toc.last)
|
||||||
{
|
{
|
||||||
/* skip directly to next track start position */
|
/* skip directly to next track start position */
|
||||||
cdd.lba = cdd.toc.tracks[cdd.index].start;
|
cdd.lba = cdd.toc.tracks[index].start;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
/* end of disc */
|
/* end of disc */
|
||||||
cdd.lba = cdd.toc.end;
|
cdd.lba = cdd.toc.end;
|
||||||
|
cdd.index = cdd.toc.last;
|
||||||
cdd.status = CD_END;
|
cdd.status = CD_END;
|
||||||
|
|
||||||
/* no AUDIO track playing */
|
/* no audio track playing */
|
||||||
scd.regs[0x36>>1].byte.h = 0x01;
|
scd.regs[0x36>>1].byte.h = 0x01;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (cdd.lba < cdd.toc.tracks[cdd.index].start)
|
else if (cdd.lba < cdd.toc.tracks[index].start)
|
||||||
{
|
{
|
||||||
#if defined(USE_LIBTREMOR) || defined(USE_LIBVORBIS)
|
|
||||||
#ifdef DISABLE_MANY_OGG_OPEN_FILES
|
|
||||||
/* close previous track VORBIS file structure to save memory */
|
|
||||||
if (cdd.toc.tracks[cdd.index].vf.datasource)
|
|
||||||
{
|
|
||||||
ogg_free(cdd.index);
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* check disc limits */
|
/* check disc limits */
|
||||||
if (cdd.index > 0)
|
if (index > 0)
|
||||||
{
|
{
|
||||||
/* previous track */
|
/* previous track */
|
||||||
cdd.index--;
|
index--;
|
||||||
|
|
||||||
/* skip directly to previous track end position */
|
/* skip directly to previous track end position */
|
||||||
cdd.lba = cdd.toc.tracks[cdd.index].end;
|
cdd.lba = cdd.toc.tracks[index].end;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -1746,49 +1802,29 @@ void cdd_update(void)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* AUDIO track playing ? */
|
|
||||||
scd.regs[0x36>>1].byte.h = cdd.toc.tracks[cdd.index].type ? 0x01 : 0x00;
|
|
||||||
|
|
||||||
/* seek to current subcode position */
|
/* seek to current subcode position */
|
||||||
if (cdd.toc.sub)
|
if (cdd.toc.sub)
|
||||||
{
|
{
|
||||||
cdStreamSeek(cdd.toc.sub, cdd.lba * 96, SEEK_SET);
|
cdStreamSeek(cdd.toc.sub, cdd.lba * 96, SEEK_SET);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* seek to current track position */
|
/* current track is an audio track ? */
|
||||||
#if defined(USE_LIBCHDR)
|
if (cdd.toc.tracks[index].type == TYPE_AUDIO)
|
||||||
if (cdd.chd.file)
|
|
||||||
{
|
{
|
||||||
/* CHD file offset */
|
/* seek to current track sector */
|
||||||
cdd.chd.hunkofs = cdd.toc.tracks[cdd.index].offset + (cdd.lba * CD_FRAME_SIZE);
|
cdd_seek_audio(index, cdd.lba);
|
||||||
|
|
||||||
|
/* audio track playing */
|
||||||
|
scd.regs[0x36>>1].byte.h = 0x00;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
#endif
|
|
||||||
if (cdd.toc.tracks[cdd.index].type)
|
|
||||||
{
|
{
|
||||||
/* DATA track */
|
/* no audio track playing */
|
||||||
cdStreamSeek(cdd.toc.tracks[0].fd, cdd.lba * cdd.sectorSize, SEEK_SET);
|
scd.regs[0x36>>1].byte.h = 0x01;
|
||||||
}
|
|
||||||
#if defined(USE_LIBTREMOR) || defined(USE_LIBVORBIS)
|
|
||||||
else if (cdd.toc.tracks[cdd.index].vf.seekable)
|
|
||||||
{
|
|
||||||
#ifdef DISABLE_MANY_OGG_OPEN_FILES
|
|
||||||
/* check if a new track is being played */
|
|
||||||
if (!cdd.toc.tracks[cdd.index].vf.datasource)
|
|
||||||
{
|
|
||||||
/* VORBIS file need to be opened first */
|
|
||||||
ov_open_callbacks(cdd.toc.tracks[cdd.index].fd,&cdd.toc.tracks[cdd.index].vf,0,0,cb);
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
/* VORBIS AUDIO track */
|
|
||||||
ov_pcm_seek(&cdd.toc.tracks[cdd.index].vf, (cdd.lba * 588) - cdd.toc.tracks[cdd.index].offset);
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
else if (cdd.toc.tracks[cdd.index].fd)
|
|
||||||
{
|
|
||||||
/* PCM AUDIO track */
|
|
||||||
cdStreamSeek(cdd.toc.tracks[cdd.index].fd, (cdd.lba * 2352) - cdd.toc.tracks[cdd.index].offset, SEEK_SET);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* udpate current track index */
|
||||||
|
cdd.index = index;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1996,62 +2032,22 @@ void cdd_process(void)
|
|||||||
/* get track index */
|
/* get track index */
|
||||||
while ((cdd.toc.tracks[index].end <= lba) && (index < cdd.toc.last)) index++;
|
while ((cdd.toc.tracks[index].end <= lba) && (index < cdd.toc.last)) index++;
|
||||||
|
|
||||||
#if defined(USE_LIBTREMOR) || defined(USE_LIBVORBIS)
|
/* audio track ? */
|
||||||
#ifdef DISABLE_MANY_OGG_OPEN_FILES
|
if (cdd.toc.tracks[index].type == TYPE_AUDIO)
|
||||||
/* check if track index has changed */
|
|
||||||
if (index != cdd.index)
|
|
||||||
{
|
{
|
||||||
/* close previous track VORBIS file structure to save memory */
|
|
||||||
if (cdd.toc.tracks[cdd.index].vf.datasource)
|
|
||||||
{
|
|
||||||
ogg_free(cdd.index);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* open current track VORBIS file */
|
|
||||||
if (cdd.toc.tracks[index].vf.seekable)
|
|
||||||
{
|
|
||||||
ov_open_callbacks(cdd.toc.tracks[index].fd,&cdd.toc.tracks[index].vf,0,0,cb);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* update current track index */
|
|
||||||
cdd.index = index;
|
|
||||||
|
|
||||||
/* stay within track limits when seeking files */
|
/* stay within track limits when seeking files */
|
||||||
if (lba < cdd.toc.tracks[index].start)
|
if (lba < cdd.toc.tracks[index].start)
|
||||||
{
|
{
|
||||||
lba = cdd.toc.tracks[index].start;
|
lba = cdd.toc.tracks[index].start;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* seek to current track position */
|
/* seek to current track sector */
|
||||||
#if defined(USE_LIBCHDR)
|
cdd_seek_audio(index, lba);
|
||||||
if (cdd.chd.file)
|
|
||||||
{
|
|
||||||
/* CHD file offset */
|
|
||||||
cdd.chd.hunkofs = cdd.toc.tracks[index].offset + (lba * CD_FRAME_SIZE);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
#endif
|
|
||||||
if (cdd.toc.tracks[index].type)
|
|
||||||
{
|
|
||||||
/* DATA track */
|
|
||||||
cdStreamSeek(cdd.toc.tracks[index].fd, lba * cdd.sectorSize, SEEK_SET);
|
|
||||||
}
|
|
||||||
#if defined(USE_LIBTREMOR) || defined(USE_LIBVORBIS)
|
|
||||||
else if (cdd.toc.tracks[index].vf.seekable)
|
|
||||||
{
|
|
||||||
/* VORBIS AUDIO track */
|
|
||||||
ov_pcm_seek(&cdd.toc.tracks[index].vf, (lba * 588) - cdd.toc.tracks[index].offset);
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
else if (cdd.toc.tracks[index].fd)
|
|
||||||
{
|
|
||||||
/* PCM AUDIO track */
|
|
||||||
cdStreamSeek(cdd.toc.tracks[index].fd, (lba * 2352) - cdd.toc.tracks[index].offset, SEEK_SET);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* update current track index */
|
||||||
|
cdd.index = index;
|
||||||
|
|
||||||
/* seek to current subcode position */
|
/* seek to current subcode position */
|
||||||
if (cdd.toc.sub)
|
if (cdd.toc.sub)
|
||||||
{
|
{
|
||||||
@ -2103,62 +2099,22 @@ void cdd_process(void)
|
|||||||
/* get current track index */
|
/* get current track index */
|
||||||
while ((cdd.toc.tracks[index].end <= lba) && (index < cdd.toc.last)) index++;
|
while ((cdd.toc.tracks[index].end <= lba) && (index < cdd.toc.last)) index++;
|
||||||
|
|
||||||
#if defined(USE_LIBTREMOR) || defined(USE_LIBVORBIS)
|
/* audio track ? */
|
||||||
#ifdef DISABLE_MANY_OGG_OPEN_FILES
|
if (cdd.toc.tracks[index].type == TYPE_AUDIO)
|
||||||
/* check if track index has changed */
|
|
||||||
if (index != cdd.index)
|
|
||||||
{
|
{
|
||||||
/* close previous track VORBIS file structure to save memory */
|
/* stay within track limits when seeking files */
|
||||||
if (cdd.toc.tracks[cdd.index].vf.datasource)
|
|
||||||
{
|
|
||||||
ogg_free(cdd.index);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* open current track VORBIS file */
|
|
||||||
if (cdd.toc.tracks[index].vf.seekable)
|
|
||||||
{
|
|
||||||
ov_open_callbacks(cdd.toc.tracks[index].fd,&cdd.toc.tracks[index].vf,0,0,cb);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* update current track index */
|
|
||||||
cdd.index = index;
|
|
||||||
|
|
||||||
/* stay within track limits */
|
|
||||||
if (lba < cdd.toc.tracks[index].start)
|
if (lba < cdd.toc.tracks[index].start)
|
||||||
{
|
{
|
||||||
lba = cdd.toc.tracks[index].start;
|
lba = cdd.toc.tracks[index].start;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* seek to current track position */
|
/* seek to current track sector */
|
||||||
#if defined(USE_LIBCHDR)
|
cdd_seek_audio(index, lba);
|
||||||
if (cdd.chd.file)
|
|
||||||
{
|
|
||||||
/* CHD file offset */
|
|
||||||
cdd.chd.hunkofs = cdd.toc.tracks[index].offset + (lba * CD_FRAME_SIZE);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
#endif
|
|
||||||
if (cdd.toc.tracks[index].type)
|
|
||||||
{
|
|
||||||
/* DATA track */
|
|
||||||
cdStreamSeek(cdd.toc.tracks[index].fd, lba * cdd.sectorSize, SEEK_SET);
|
|
||||||
}
|
|
||||||
#if defined(USE_LIBTREMOR) || defined(USE_LIBVORBIS)
|
|
||||||
else if (cdd.toc.tracks[index].vf.seekable)
|
|
||||||
{
|
|
||||||
/* VORBIS AUDIO track */
|
|
||||||
ov_pcm_seek(&cdd.toc.tracks[index].vf, (lba * 588) - cdd.toc.tracks[index].offset);
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
else if (cdd.toc.tracks[index].fd)
|
|
||||||
{
|
|
||||||
/* PCM AUDIO track */
|
|
||||||
cdStreamSeek(cdd.toc.tracks[index].fd, (lba * 2352) - cdd.toc.tracks[index].offset, SEEK_SET);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* update current track index */
|
||||||
|
cdd.index = index;
|
||||||
|
|
||||||
/* seek to current subcode position */
|
/* seek to current subcode position */
|
||||||
if (cdd.toc.sub)
|
if (cdd.toc.sub)
|
||||||
{
|
{
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
* Genesis Plus
|
* Genesis Plus
|
||||||
* CD drive processor & CD-DA fader
|
* CD drive processor & CD-DA fader
|
||||||
*
|
*
|
||||||
* Copyright (C) 2012-2020 Eke-Eke (Genesis Plus GX)
|
* Copyright (C) 2012-2021 Eke-Eke (Genesis Plus GX)
|
||||||
*
|
*
|
||||||
* Redistribution and use of this code or any derivative works are permitted
|
* Redistribution and use of this code or any derivative works are permitted
|
||||||
* provided that the following conditions are met:
|
* provided that the following conditions are met:
|
||||||
@ -133,10 +133,11 @@ typedef struct
|
|||||||
extern void cdd_init(int samplerate);
|
extern void cdd_init(int samplerate);
|
||||||
extern void cdd_reset(void);
|
extern void cdd_reset(void);
|
||||||
extern int cdd_context_save(uint8 *state);
|
extern int cdd_context_save(uint8 *state);
|
||||||
extern int cdd_context_load(uint8 *state);
|
extern int cdd_context_load(uint8 *state, char *version);
|
||||||
extern int cdd_load(char *filename, char *header);
|
extern int cdd_load(char *filename, char *header);
|
||||||
extern void cdd_unload(void);
|
extern void cdd_unload(void);
|
||||||
extern void cdd_read_data(uint8 *dst, uint8 *subheader);
|
extern void cdd_read_data(uint8 *dst, uint8 *subheader);
|
||||||
|
extern void cdd_seek_audio(int index, int lba);
|
||||||
extern void cdd_read_audio(unsigned int samples);
|
extern void cdd_read_audio(unsigned int samples);
|
||||||
extern void cdd_update(void);
|
extern void cdd_update(void);
|
||||||
extern void cdd_process(void);
|
extern void cdd_process(void);
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
* Genesis Plus
|
* Genesis Plus
|
||||||
* Mega CD / Sega CD hardware
|
* Mega CD / Sega CD hardware
|
||||||
*
|
*
|
||||||
* Copyright (C) 2012-2020 Eke-Eke (Genesis Plus GX)
|
* Copyright (C) 2012-2021 Eke-Eke (Genesis Plus GX)
|
||||||
*
|
*
|
||||||
* Redistribution and use of this code or any derivative works are permitted
|
* Redistribution and use of this code or any derivative works are permitted
|
||||||
* provided that the following conditions are met:
|
* provided that the following conditions are met:
|
||||||
@ -1851,7 +1851,7 @@ int scd_context_save(uint8 *state)
|
|||||||
return bufferptr;
|
return bufferptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
int scd_context_load(uint8 *state)
|
int scd_context_load(uint8 *state, char *version)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
uint16 tmp16;
|
uint16 tmp16;
|
||||||
@ -1873,7 +1873,7 @@ int scd_context_load(uint8 *state)
|
|||||||
bufferptr += cdc_context_load(&state[bufferptr]);
|
bufferptr += cdc_context_load(&state[bufferptr]);
|
||||||
|
|
||||||
/* CD Drive processor */
|
/* CD Drive processor */
|
||||||
bufferptr += cdd_context_load(&state[bufferptr]);
|
bufferptr += cdd_context_load(&state[bufferptr], version);
|
||||||
|
|
||||||
/* PCM chip */
|
/* PCM chip */
|
||||||
bufferptr += pcm_context_load(&state[bufferptr]);
|
bufferptr += pcm_context_load(&state[bufferptr]);
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
* Genesis Plus
|
* Genesis Plus
|
||||||
* Mega CD / Sega CD hardware
|
* Mega CD / Sega CD hardware
|
||||||
*
|
*
|
||||||
* Copyright (C) 2012-2020 Eke-Eke (Genesis Plus GX)
|
* Copyright (C) 2012-2021 Eke-Eke (Genesis Plus GX)
|
||||||
*
|
*
|
||||||
* Redistribution and use of this code or any derivative works are permitted
|
* Redistribution and use of this code or any derivative works are permitted
|
||||||
* provided that the following conditions are met:
|
* provided that the following conditions are met:
|
||||||
@ -87,7 +87,7 @@ extern void scd_init(void);
|
|||||||
extern void scd_reset(int hard);
|
extern void scd_reset(int hard);
|
||||||
extern void scd_update(unsigned int cycles);
|
extern void scd_update(unsigned int cycles);
|
||||||
extern void scd_end_frame(unsigned int cycles);
|
extern void scd_end_frame(unsigned int cycles);
|
||||||
extern int scd_context_load(uint8 *state);
|
extern int scd_context_load(uint8 *state, char *version);
|
||||||
extern int scd_context_save(uint8 *state);
|
extern int scd_context_save(uint8 *state);
|
||||||
extern int scd_68k_irq_ack(int level);
|
extern int scd_68k_irq_ack(int level);
|
||||||
extern void prg_ram_dma_w(unsigned int words);
|
extern void prg_ram_dma_w(unsigned int words);
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
* Genesis Plus
|
* Genesis Plus
|
||||||
* Savestate support
|
* Savestate support
|
||||||
*
|
*
|
||||||
* Copyright (C) 2007-2019 Eke-Eke (Genesis Plus GX)
|
* Copyright (C) 2007-2021 Eke-Eke (Genesis Plus GX)
|
||||||
*
|
*
|
||||||
* Redistribution and use of this code or any derivative works are permitted
|
* Redistribution and use of this code or any derivative works are permitted
|
||||||
* provided that the following conditions are met:
|
* provided that the following conditions are met:
|
||||||
@ -173,7 +173,7 @@ int state_load(unsigned char *state)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* CD hardware */
|
/* CD hardware */
|
||||||
bufferptr += scd_context_load(&state[bufferptr]);
|
bufferptr += scd_context_load(&state[bufferptr], version);
|
||||||
}
|
}
|
||||||
else if ((system_hw & SYSTEM_PBC) == SYSTEM_MD)
|
else if ((system_hw & SYSTEM_PBC) == SYSTEM_MD)
|
||||||
{
|
{
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
* Genesis Plus
|
* Genesis Plus
|
||||||
* Savestate support
|
* Savestate support
|
||||||
*
|
*
|
||||||
* Copyright (C) 2007-2019 Eke-Eke (Genesis Plus GX)
|
* Copyright (C) 2007-2021 Eke-Eke (Genesis Plus GX)
|
||||||
*
|
*
|
||||||
* Redistribution and use of this code or any derivative works are permitted
|
* Redistribution and use of this code or any derivative works are permitted
|
||||||
* provided that the following conditions are met:
|
* provided that the following conditions are met:
|
||||||
@ -40,7 +40,7 @@
|
|||||||
#define _STATE_H_
|
#define _STATE_H_
|
||||||
|
|
||||||
#define STATE_SIZE 0xfd000
|
#define STATE_SIZE 0xfd000
|
||||||
#define STATE_VERSION "GENPLUS-GX 1.7.5"
|
#define STATE_VERSION "GENPLUS-GX 1.7.6"
|
||||||
|
|
||||||
#define load_param(param, size) \
|
#define load_param(param, size) \
|
||||||
memcpy(param, &state[bufferptr], size); \
|
memcpy(param, &state[bufferptr], size); \
|
||||||
|
Loading…
x
Reference in New Issue
Block a user