Mercurial > repos > blastem
changeset 514:f66c78cbdcaa
Implement per-channel wave logging and primitive looping support in vgm player.
author | Michael Pavone <pavone@retrodev.com> |
---|---|
date | Fri, 07 Feb 2014 21:18:05 -0800 |
parents | 24ebabd89162 |
children | 1495179d6737 6e9d1a8c1b08 |
files | vgmplay.c |
diffstat | 1 files changed, 14 insertions(+), 3 deletions(-) [+] |
line wrap: on
line diff
--- a/vgmplay.c Fri Feb 07 00:41:51 2014 -0800 +++ b/vgmplay.c Fri Feb 07 21:18:05 2014 -0800 @@ -28,7 +28,7 @@ uint32_t gd3_offset; uint32_t num_samples; uint32_t loop_offset; - uint32_t loop_count; + uint32_t loop_samples; uint32_t rate; uint16_t sn76489_fb; uint8_t sn76489_shift; @@ -144,9 +144,13 @@ config = load_config(argv[0]); render_init(320, 240, "vgm play", 60, 0, 0); + uint32_t opts = 0; + if (argc >= 3 && !strcmp(argv[2], "-y")) { + opts |= YM_OPT_WAVE_LOG; + } ym2612_context y_context; - ym_init(&y_context, render_sample_rate(), MCLKS_NTSC, MCLKS_PER_YM, render_audio_buffer(), 0); + ym_init(&y_context, render_sample_rate(), MCLKS_NTSC, MCLKS_PER_YM, render_audio_buffer(), opts); psg_context p_context; psg_init(&p_context, render_sample_rate(), MCLKS_NTSC, MCLKS_PER_PSG, render_audio_buffer()); @@ -164,6 +168,7 @@ fclose(f); uint32_t mclks_sample = MCLKS_NTSC / 44100; + uint32_t loop_count = 2; uint8_t * end = data + data_size; uint8_t * cur = data; @@ -201,7 +206,13 @@ wait(&y_context, &p_context, ¤t_cycle, 882 * mclks_sample); break; case CMD_END: - return 0; + if (header.loop_offset && --loop_count) { + cur = data + header.loop_offset + 0x1C - (header.data_offset + 0x34); + } else { + //TODO: fade out + return 0; + } + break; case CMD_DATA: { cur++; //skip compat command uint8_t data_type = *(cur++);