annotate vgmplay.c @ 418:dbf4e1c86f3c

Implement basic joystick support
author Mike Pavone <pavone@retrodev.com>
date Sun, 23 Jun 2013 22:27:12 -0700
parents c1bddeadc566
children bc9e0829ffc7
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
408
a13a83934ba3 Add primitive vgm player for testing
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
1 #include "render.h"
a13a83934ba3 Add primitive vgm player for testing
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
2 #include "ym2612.h"
a13a83934ba3 Add primitive vgm player for testing
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
3 #include "psg.h"
a13a83934ba3 Add primitive vgm player for testing
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
4 #include <stdint.h>
a13a83934ba3 Add primitive vgm player for testing
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
5 #include <stdio.h>
a13a83934ba3 Add primitive vgm player for testing
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
6
a13a83934ba3 Add primitive vgm player for testing
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
7 #define MCLKS_NTSC 53693175
a13a83934ba3 Add primitive vgm player for testing
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
8 #define MCLKS_PAL 53203395
a13a83934ba3 Add primitive vgm player for testing
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
9
a13a83934ba3 Add primitive vgm player for testing
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
10 #define MCLKS_PER_68K 7
a13a83934ba3 Add primitive vgm player for testing
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
11 #define MCLKS_PER_YM MCLKS_PER_68K
a13a83934ba3 Add primitive vgm player for testing
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
12 #define MCLKS_PER_Z80 15
a13a83934ba3 Add primitive vgm player for testing
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
13 #define MCLKS_PER_PSG (MCLKS_PER_Z80*16)
a13a83934ba3 Add primitive vgm player for testing
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
14
a13a83934ba3 Add primitive vgm player for testing
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
15 #pragma pack(push, 1)
a13a83934ba3 Add primitive vgm player for testing
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
16 typedef struct {
a13a83934ba3 Add primitive vgm player for testing
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
17 char ident[4];
a13a83934ba3 Add primitive vgm player for testing
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
18 uint32_t eof_offset;
a13a83934ba3 Add primitive vgm player for testing
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
19 uint32_t version;
a13a83934ba3 Add primitive vgm player for testing
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
20 uint32_t sn76489_clk;
a13a83934ba3 Add primitive vgm player for testing
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
21 uint32_t ym2413_clk;
a13a83934ba3 Add primitive vgm player for testing
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
22 uint32_t gd3_offset;
a13a83934ba3 Add primitive vgm player for testing
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
23 uint32_t num_samples;
a13a83934ba3 Add primitive vgm player for testing
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
24 uint32_t loop_offset;
a13a83934ba3 Add primitive vgm player for testing
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
25 uint32_t loop_count;
a13a83934ba3 Add primitive vgm player for testing
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
26 uint32_t rate;
a13a83934ba3 Add primitive vgm player for testing
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
27 uint16_t sn76489_fb;
a13a83934ba3 Add primitive vgm player for testing
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
28 uint8_t sn76489_shift;
a13a83934ba3 Add primitive vgm player for testing
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
29 uint8_t sn76489_flags;
a13a83934ba3 Add primitive vgm player for testing
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
30 uint32_t ym2612_clk;
a13a83934ba3 Add primitive vgm player for testing
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
31 uint32_t ym2151_clk;
a13a83934ba3 Add primitive vgm player for testing
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
32 uint32_t data_offset;
a13a83934ba3 Add primitive vgm player for testing
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
33 uint32_t sega_pcm_clk;
a13a83934ba3 Add primitive vgm player for testing
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
34 uint32_t sega_pcm_reg;
a13a83934ba3 Add primitive vgm player for testing
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
35 } vgm_header;
a13a83934ba3 Add primitive vgm player for testing
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
36
a13a83934ba3 Add primitive vgm player for testing
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
37 enum {
a13a83934ba3 Add primitive vgm player for testing
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
38 CMD_PSG_STEREO = 0x4F,
a13a83934ba3 Add primitive vgm player for testing
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
39 CMD_PSG,
a13a83934ba3 Add primitive vgm player for testing
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
40 CMD_YM2413,
a13a83934ba3 Add primitive vgm player for testing
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
41 CMD_YM2612_0,
a13a83934ba3 Add primitive vgm player for testing
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
42 CMD_YM2612_1,
a13a83934ba3 Add primitive vgm player for testing
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
43 CMD_YM2151,
a13a83934ba3 Add primitive vgm player for testing
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
44 CMD_YM2203,
a13a83934ba3 Add primitive vgm player for testing
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
45 CMD_YM2608_0,
a13a83934ba3 Add primitive vgm player for testing
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
46 CMD_YM2608_1,
a13a83934ba3 Add primitive vgm player for testing
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
47 CMD_YM2610_0,
a13a83934ba3 Add primitive vgm player for testing
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
48 CMD_YM2610_1,
a13a83934ba3 Add primitive vgm player for testing
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
49 CMD_YM3812,
a13a83934ba3 Add primitive vgm player for testing
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
50 CMD_YM3526,
a13a83934ba3 Add primitive vgm player for testing
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
51 CMD_Y8950,
a13a83934ba3 Add primitive vgm player for testing
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
52 CMD_YMZ280B,
a13a83934ba3 Add primitive vgm player for testing
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
53 CMD_YMF262_0,
a13a83934ba3 Add primitive vgm player for testing
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
54 CMD_YMF262_1,
a13a83934ba3 Add primitive vgm player for testing
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
55 CMD_WAIT = 0x61,
a13a83934ba3 Add primitive vgm player for testing
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
56 CMD_WAIT_60,
a13a83934ba3 Add primitive vgm player for testing
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
57 CMD_WAIT_50,
a13a83934ba3 Add primitive vgm player for testing
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
58 CMD_END = 0x66,
a13a83934ba3 Add primitive vgm player for testing
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
59 CMD_DATA,
a13a83934ba3 Add primitive vgm player for testing
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
60 CMD_PCM_WRITE,
a13a83934ba3 Add primitive vgm player for testing
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
61 CMD_WAIT_SHORT = 0x70,
a13a83934ba3 Add primitive vgm player for testing
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
62 CMD_YM2612_DAC = 0x80
a13a83934ba3 Add primitive vgm player for testing
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
63 };
a13a83934ba3 Add primitive vgm player for testing
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
64
a13a83934ba3 Add primitive vgm player for testing
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
65 #pragma pack(pop)
a13a83934ba3 Add primitive vgm player for testing
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
66
a13a83934ba3 Add primitive vgm player for testing
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
67 void handle_keydown(int keycode)
a13a83934ba3 Add primitive vgm player for testing
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
68 {
a13a83934ba3 Add primitive vgm player for testing
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
69 }
a13a83934ba3 Add primitive vgm player for testing
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
70
a13a83934ba3 Add primitive vgm player for testing
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
71 void handle_keyup(int keycode)
a13a83934ba3 Add primitive vgm player for testing
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
72 {
a13a83934ba3 Add primitive vgm player for testing
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
73 }
a13a83934ba3 Add primitive vgm player for testing
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
74
409
c1bddeadc566 Process events in vgm player so that quitting works
Mike Pavone <pavone@retrodev.com>
parents: 408
diff changeset
75 #define CYCLE_LIMIT MCLKS_NTSC/60
c1bddeadc566 Process events in vgm player so that quitting works
Mike Pavone <pavone@retrodev.com>
parents: 408
diff changeset
76
408
a13a83934ba3 Add primitive vgm player for testing
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
77 void wait(ym2612_context * y_context, psg_context * p_context, uint32_t * current_cycle, uint32_t cycles)
a13a83934ba3 Add primitive vgm player for testing
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
78 {
a13a83934ba3 Add primitive vgm player for testing
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
79 *current_cycle += cycles;
a13a83934ba3 Add primitive vgm player for testing
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
80 psg_run(p_context, *current_cycle);
a13a83934ba3 Add primitive vgm player for testing
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
81 ym_run(y_context, *current_cycle);
a13a83934ba3 Add primitive vgm player for testing
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
82
409
c1bddeadc566 Process events in vgm player so that quitting works
Mike Pavone <pavone@retrodev.com>
parents: 408
diff changeset
83 if (*current_cycle > CYCLE_LIMIT) {
c1bddeadc566 Process events in vgm player so that quitting works
Mike Pavone <pavone@retrodev.com>
parents: 408
diff changeset
84 *current_cycle -= CYCLE_LIMIT;
c1bddeadc566 Process events in vgm player so that quitting works
Mike Pavone <pavone@retrodev.com>
parents: 408
diff changeset
85 p_context->cycles -= CYCLE_LIMIT;
c1bddeadc566 Process events in vgm player so that quitting works
Mike Pavone <pavone@retrodev.com>
parents: 408
diff changeset
86 y_context->current_cycle -= CYCLE_LIMIT;
c1bddeadc566 Process events in vgm player so that quitting works
Mike Pavone <pavone@retrodev.com>
parents: 408
diff changeset
87 process_events();
408
a13a83934ba3 Add primitive vgm player for testing
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
88 }
a13a83934ba3 Add primitive vgm player for testing
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
89 }
a13a83934ba3 Add primitive vgm player for testing
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
90
a13a83934ba3 Add primitive vgm player for testing
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
91 int main(int argc, char ** argv)
a13a83934ba3 Add primitive vgm player for testing
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
92 {
a13a83934ba3 Add primitive vgm player for testing
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
93 uint32_t fps = 60;
a13a83934ba3 Add primitive vgm player for testing
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
94 render_init(320, 240, "vgm play", 60);
a13a83934ba3 Add primitive vgm player for testing
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
95
a13a83934ba3 Add primitive vgm player for testing
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
96
a13a83934ba3 Add primitive vgm player for testing
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
97 ym2612_context y_context;
a13a83934ba3 Add primitive vgm player for testing
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
98 ym_init(&y_context, render_sample_rate(), MCLKS_NTSC, MCLKS_PER_YM, render_audio_buffer(), 0);
a13a83934ba3 Add primitive vgm player for testing
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
99
a13a83934ba3 Add primitive vgm player for testing
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
100 psg_context p_context;
a13a83934ba3 Add primitive vgm player for testing
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
101 psg_init(&p_context, render_sample_rate(), MCLKS_NTSC, MCLKS_PER_PSG, render_audio_buffer());
a13a83934ba3 Add primitive vgm player for testing
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
102
a13a83934ba3 Add primitive vgm player for testing
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
103 FILE * f = fopen(argv[1], "rb");
a13a83934ba3 Add primitive vgm player for testing
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
104 vgm_header header;
a13a83934ba3 Add primitive vgm player for testing
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
105 fread(&header, sizeof(header), 1, f);
a13a83934ba3 Add primitive vgm player for testing
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
106 if (header.version < 0x150 || !header.data_offset) {
a13a83934ba3 Add primitive vgm player for testing
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
107 header.data_offset = 0xC;
a13a83934ba3 Add primitive vgm player for testing
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
108 }
a13a83934ba3 Add primitive vgm player for testing
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
109 fseek(f, header.data_offset + 0x34, SEEK_SET);
a13a83934ba3 Add primitive vgm player for testing
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
110 uint32_t data_size = header.eof_offset + 4 - (header.data_offset + 0x34);
a13a83934ba3 Add primitive vgm player for testing
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
111 uint8_t * data = malloc(data_size);
a13a83934ba3 Add primitive vgm player for testing
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
112 fread(data, 1, data_size, f);
a13a83934ba3 Add primitive vgm player for testing
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
113 fclose(f);
a13a83934ba3 Add primitive vgm player for testing
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
114
a13a83934ba3 Add primitive vgm player for testing
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
115 uint32_t mclks_sample = MCLKS_NTSC / 44100;
a13a83934ba3 Add primitive vgm player for testing
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
116
a13a83934ba3 Add primitive vgm player for testing
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
117 uint8_t * end = data + data_size;
a13a83934ba3 Add primitive vgm player for testing
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
118 uint8_t * cur = data;
a13a83934ba3 Add primitive vgm player for testing
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
119 uint32_t current_cycle = 0;
a13a83934ba3 Add primitive vgm player for testing
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
120 while (cur < end) {
a13a83934ba3 Add primitive vgm player for testing
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
121 uint8_t cmd = *(cur++);
a13a83934ba3 Add primitive vgm player for testing
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
122 switch(cmd)
a13a83934ba3 Add primitive vgm player for testing
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
123 {
a13a83934ba3 Add primitive vgm player for testing
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
124 case CMD_PSG_STEREO:
a13a83934ba3 Add primitive vgm player for testing
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
125 //ignore for now
a13a83934ba3 Add primitive vgm player for testing
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
126 cur++;
a13a83934ba3 Add primitive vgm player for testing
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
127 break;
a13a83934ba3 Add primitive vgm player for testing
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
128 case CMD_PSG:
a13a83934ba3 Add primitive vgm player for testing
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
129 psg_write(&p_context, *(cur++));
a13a83934ba3 Add primitive vgm player for testing
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
130 break;
a13a83934ba3 Add primitive vgm player for testing
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
131 case CMD_YM2612_0:
a13a83934ba3 Add primitive vgm player for testing
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
132 ym_address_write_part1(&y_context, *(cur++));
a13a83934ba3 Add primitive vgm player for testing
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
133 ym_data_write(&y_context, *(cur++));
a13a83934ba3 Add primitive vgm player for testing
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
134 break;
a13a83934ba3 Add primitive vgm player for testing
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
135 case CMD_YM2612_1:
a13a83934ba3 Add primitive vgm player for testing
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
136 ym_address_write_part2(&y_context, *(cur++));
a13a83934ba3 Add primitive vgm player for testing
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
137 ym_data_write(&y_context, *(cur++));
a13a83934ba3 Add primitive vgm player for testing
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
138 break;
a13a83934ba3 Add primitive vgm player for testing
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
139 case CMD_WAIT: {
a13a83934ba3 Add primitive vgm player for testing
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
140 uint32_t wait_time = *(cur++);
a13a83934ba3 Add primitive vgm player for testing
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
141 wait_time |= *(cur++) << 8;
a13a83934ba3 Add primitive vgm player for testing
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
142 wait_time *= mclks_sample;
a13a83934ba3 Add primitive vgm player for testing
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
143 wait(&y_context, &p_context, &current_cycle, wait_time);
a13a83934ba3 Add primitive vgm player for testing
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
144 break;
a13a83934ba3 Add primitive vgm player for testing
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
145 }
a13a83934ba3 Add primitive vgm player for testing
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
146 case CMD_WAIT_60:
a13a83934ba3 Add primitive vgm player for testing
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
147 wait(&y_context, &p_context, &current_cycle, 735 * mclks_sample);
a13a83934ba3 Add primitive vgm player for testing
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
148 break;
a13a83934ba3 Add primitive vgm player for testing
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
149 case CMD_WAIT_50:
a13a83934ba3 Add primitive vgm player for testing
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
150 wait(&y_context, &p_context, &current_cycle, 882 * mclks_sample);
a13a83934ba3 Add primitive vgm player for testing
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
151 break;
a13a83934ba3 Add primitive vgm player for testing
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
152 case CMD_END:
a13a83934ba3 Add primitive vgm player for testing
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
153 return 0;
a13a83934ba3 Add primitive vgm player for testing
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
154 default:
a13a83934ba3 Add primitive vgm player for testing
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
155 if (cmd >= CMD_WAIT_SHORT && cmd < (CMD_WAIT_SHORT + 0x10)) {
a13a83934ba3 Add primitive vgm player for testing
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
156 uint32_t wait_time = (cmd & 0xF) + 1;
a13a83934ba3 Add primitive vgm player for testing
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
157 wait_time *= mclks_sample;
a13a83934ba3 Add primitive vgm player for testing
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
158 wait(&y_context, &p_context, &current_cycle, wait_time);
a13a83934ba3 Add primitive vgm player for testing
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
159 } else {
a13a83934ba3 Add primitive vgm player for testing
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
160 printf("unimplemented command: %X at offset %X\n", cmd, cur - data - 1);
a13a83934ba3 Add primitive vgm player for testing
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
161 exit(1);
a13a83934ba3 Add primitive vgm player for testing
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
162 }
a13a83934ba3 Add primitive vgm player for testing
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
163 }
a13a83934ba3 Add primitive vgm player for testing
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
164 }
a13a83934ba3 Add primitive vgm player for testing
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
165 return 0;
a13a83934ba3 Add primitive vgm player for testing
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
166 }