# HG changeset patch # User Michael Pavone # Date 1391836685 28800 # Node ID f66c78cbdcaa90a261edbe2a5c38eb017af13e30 # Parent 24ebabd891625a755917fc7fcc657f0072524106 Implement per-channel wave logging and primitive looping support in vgm player. diff -r 24ebabd89162 -r f66c78cbdcaa vgmplay.c --- 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++);