Mercurial > repos > blastem
annotate vgm.h @ 2354:a773b8f09292
Remove old refresh hack that is causing VDPFifoTesting to have a failed test
author | Michael Pavone <pavone@retrodev.com> |
---|---|
date | Thu, 19 Oct 2023 23:27:57 -0700 |
parents | 92449b47cce8 |
children | fb8f49b0aece |
rev | line source |
---|---|
862
a2034b8d7495
Commit of VGM header that was missed previously
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1 #ifndef VGM_H_ |
a2034b8d7495
Commit of VGM header that was missed previously
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
2 #define VGM_H_ |
a2034b8d7495
Commit of VGM header that was missed previously
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
3 |
1909
508522f08e4d
Initial stab at VGM logging support
Michael Pavone <pavone@retrodev.com>
parents:
862
diff
changeset
|
4 #include <stdint.h> |
508522f08e4d
Initial stab at VGM logging support
Michael Pavone <pavone@retrodev.com>
parents:
862
diff
changeset
|
5 #include <stdio.h> |
508522f08e4d
Initial stab at VGM logging support
Michael Pavone <pavone@retrodev.com>
parents:
862
diff
changeset
|
6 |
862
a2034b8d7495
Commit of VGM header that was missed previously
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
7 #pragma pack(push, 1) |
a2034b8d7495
Commit of VGM header that was missed previously
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
8 typedef struct { |
a2034b8d7495
Commit of VGM header that was missed previously
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
9 char ident[4]; |
a2034b8d7495
Commit of VGM header that was missed previously
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
10 uint32_t eof_offset; |
a2034b8d7495
Commit of VGM header that was missed previously
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
11 uint32_t version; |
a2034b8d7495
Commit of VGM header that was missed previously
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
12 uint32_t sn76489_clk; |
a2034b8d7495
Commit of VGM header that was missed previously
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
13 uint32_t ym2413_clk; |
a2034b8d7495
Commit of VGM header that was missed previously
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
14 uint32_t gd3_offset; |
a2034b8d7495
Commit of VGM header that was missed previously
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
15 uint32_t num_samples; |
a2034b8d7495
Commit of VGM header that was missed previously
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
16 uint32_t loop_offset; |
a2034b8d7495
Commit of VGM header that was missed previously
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
17 uint32_t loop_samples; |
a2034b8d7495
Commit of VGM header that was missed previously
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
18 uint32_t rate; |
a2034b8d7495
Commit of VGM header that was missed previously
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
19 uint16_t sn76489_fb; |
a2034b8d7495
Commit of VGM header that was missed previously
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
20 uint8_t sn76489_shift; |
a2034b8d7495
Commit of VGM header that was missed previously
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
21 uint8_t sn76489_flags; |
a2034b8d7495
Commit of VGM header that was missed previously
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
22 uint32_t ym2612_clk; |
a2034b8d7495
Commit of VGM header that was missed previously
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
23 uint32_t ym2151_clk; |
a2034b8d7495
Commit of VGM header that was missed previously
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
24 uint32_t data_offset; |
a2034b8d7495
Commit of VGM header that was missed previously
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
25 uint32_t sega_pcm_clk; |
a2034b8d7495
Commit of VGM header that was missed previously
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
26 uint32_t sega_pcm_reg; |
a2034b8d7495
Commit of VGM header that was missed previously
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
27 } vgm_header; |
a2034b8d7495
Commit of VGM header that was missed previously
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
28 |
2289
92449b47cce8
Integrate VGM player into main blastem binary
Michael Pavone <pavone@retrodev.com>
parents:
2081
diff
changeset
|
29 typedef struct { |
92449b47cce8
Integrate VGM player into main blastem binary
Michael Pavone <pavone@retrodev.com>
parents:
2081
diff
changeset
|
30 uint32_t rf5c68_clk; |
92449b47cce8
Integrate VGM player into main blastem binary
Michael Pavone <pavone@retrodev.com>
parents:
2081
diff
changeset
|
31 uint32_t ym2203_clk; |
92449b47cce8
Integrate VGM player into main blastem binary
Michael Pavone <pavone@retrodev.com>
parents:
2081
diff
changeset
|
32 uint32_t ym2608_clk; |
92449b47cce8
Integrate VGM player into main blastem binary
Michael Pavone <pavone@retrodev.com>
parents:
2081
diff
changeset
|
33 uint32_t ym2610_clk; |
92449b47cce8
Integrate VGM player into main blastem binary
Michael Pavone <pavone@retrodev.com>
parents:
2081
diff
changeset
|
34 uint32_t ym3812_clk; |
92449b47cce8
Integrate VGM player into main blastem binary
Michael Pavone <pavone@retrodev.com>
parents:
2081
diff
changeset
|
35 uint32_t ym3526_clk; |
92449b47cce8
Integrate VGM player into main blastem binary
Michael Pavone <pavone@retrodev.com>
parents:
2081
diff
changeset
|
36 uint32_t y8950_clk; |
92449b47cce8
Integrate VGM player into main blastem binary
Michael Pavone <pavone@retrodev.com>
parents:
2081
diff
changeset
|
37 uint32_t ymf262_clk; |
92449b47cce8
Integrate VGM player into main blastem binary
Michael Pavone <pavone@retrodev.com>
parents:
2081
diff
changeset
|
38 uint32_t ymf278b_clk; |
92449b47cce8
Integrate VGM player into main blastem binary
Michael Pavone <pavone@retrodev.com>
parents:
2081
diff
changeset
|
39 uint32_t ymf271_clk; |
92449b47cce8
Integrate VGM player into main blastem binary
Michael Pavone <pavone@retrodev.com>
parents:
2081
diff
changeset
|
40 uint32_t ymz280b_clk; |
92449b47cce8
Integrate VGM player into main blastem binary
Michael Pavone <pavone@retrodev.com>
parents:
2081
diff
changeset
|
41 uint32_t rf5c164_clk; |
92449b47cce8
Integrate VGM player into main blastem binary
Michael Pavone <pavone@retrodev.com>
parents:
2081
diff
changeset
|
42 uint32_t pwm_clk; |
92449b47cce8
Integrate VGM player into main blastem binary
Michael Pavone <pavone@retrodev.com>
parents:
2081
diff
changeset
|
43 uint32_t ay8910_clk; |
92449b47cce8
Integrate VGM player into main blastem binary
Michael Pavone <pavone@retrodev.com>
parents:
2081
diff
changeset
|
44 uint8_t ay8910_type; |
92449b47cce8
Integrate VGM player into main blastem binary
Michael Pavone <pavone@retrodev.com>
parents:
2081
diff
changeset
|
45 uint8_t ay8910_flags; |
92449b47cce8
Integrate VGM player into main blastem binary
Michael Pavone <pavone@retrodev.com>
parents:
2081
diff
changeset
|
46 uint8_t ym2203_ay_flags; |
92449b47cce8
Integrate VGM player into main blastem binary
Michael Pavone <pavone@retrodev.com>
parents:
2081
diff
changeset
|
47 uint8_t ym2608_ay_flags; |
92449b47cce8
Integrate VGM player into main blastem binary
Michael Pavone <pavone@retrodev.com>
parents:
2081
diff
changeset
|
48 //TODO: additional header extension fields |
92449b47cce8
Integrate VGM player into main blastem binary
Michael Pavone <pavone@retrodev.com>
parents:
2081
diff
changeset
|
49 } vgm_extended_header; |
92449b47cce8
Integrate VGM player into main blastem binary
Michael Pavone <pavone@retrodev.com>
parents:
2081
diff
changeset
|
50 |
862
a2034b8d7495
Commit of VGM header that was missed previously
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
51 enum { |
a2034b8d7495
Commit of VGM header that was missed previously
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
52 CMD_PSG_STEREO = 0x4F, |
a2034b8d7495
Commit of VGM header that was missed previously
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
53 CMD_PSG, |
a2034b8d7495
Commit of VGM header that was missed previously
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
54 CMD_YM2413, |
a2034b8d7495
Commit of VGM header that was missed previously
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
55 CMD_YM2612_0, |
a2034b8d7495
Commit of VGM header that was missed previously
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
56 CMD_YM2612_1, |
a2034b8d7495
Commit of VGM header that was missed previously
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
57 CMD_YM2151, |
a2034b8d7495
Commit of VGM header that was missed previously
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
58 CMD_YM2203, |
a2034b8d7495
Commit of VGM header that was missed previously
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
59 CMD_YM2608_0, |
a2034b8d7495
Commit of VGM header that was missed previously
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
60 CMD_YM2608_1, |
a2034b8d7495
Commit of VGM header that was missed previously
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
61 CMD_YM2610_0, |
a2034b8d7495
Commit of VGM header that was missed previously
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
62 CMD_YM2610_1, |
a2034b8d7495
Commit of VGM header that was missed previously
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
63 CMD_YM3812, |
a2034b8d7495
Commit of VGM header that was missed previously
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
64 CMD_YM3526, |
a2034b8d7495
Commit of VGM header that was missed previously
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
65 CMD_Y8950, |
a2034b8d7495
Commit of VGM header that was missed previously
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
66 CMD_YMZ280B, |
a2034b8d7495
Commit of VGM header that was missed previously
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
67 CMD_YMF262_0, |
a2034b8d7495
Commit of VGM header that was missed previously
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
68 CMD_YMF262_1, |
a2034b8d7495
Commit of VGM header that was missed previously
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
69 CMD_WAIT = 0x61, |
a2034b8d7495
Commit of VGM header that was missed previously
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
70 CMD_WAIT_60, |
a2034b8d7495
Commit of VGM header that was missed previously
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
71 CMD_WAIT_50, |
a2034b8d7495
Commit of VGM header that was missed previously
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
72 CMD_END = 0x66, |
a2034b8d7495
Commit of VGM header that was missed previously
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
73 CMD_DATA, |
a2034b8d7495
Commit of VGM header that was missed previously
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
74 CMD_PCM_WRITE, |
a2034b8d7495
Commit of VGM header that was missed previously
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
75 CMD_WAIT_SHORT = 0x70, |
a2034b8d7495
Commit of VGM header that was missed previously
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
76 CMD_YM2612_DAC = 0x80, |
a2034b8d7495
Commit of VGM header that was missed previously
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
77 CMD_DAC_STREAM_SETUP = 0x90, |
a2034b8d7495
Commit of VGM header that was missed previously
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
78 CMD_DAC_STREAM_DATA, |
a2034b8d7495
Commit of VGM header that was missed previously
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
79 CMD_DAC_STREAM_FREQ, |
a2034b8d7495
Commit of VGM header that was missed previously
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
80 CMD_DAC_STREAM_START, |
a2034b8d7495
Commit of VGM header that was missed previously
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
81 CMD_DAC_STREAM_STOP, |
a2034b8d7495
Commit of VGM header that was missed previously
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
82 CMD_DAC_STREAM_STARTFAST, |
2081
cfd53c94fffb
Initial stab at RF5C164 emulation
Michael Pavone <pavone@retrodev.com>
parents:
2006
diff
changeset
|
83 CMD_PCM68_REG = 0xB0, |
cfd53c94fffb
Initial stab at RF5C164 emulation
Michael Pavone <pavone@retrodev.com>
parents:
2006
diff
changeset
|
84 CMD_PCM164_REG, |
cfd53c94fffb
Initial stab at RF5C164 emulation
Michael Pavone <pavone@retrodev.com>
parents:
2006
diff
changeset
|
85 CMD_PCM68_RAM = 0xC1, |
cfd53c94fffb
Initial stab at RF5C164 emulation
Michael Pavone <pavone@retrodev.com>
parents:
2006
diff
changeset
|
86 CMD_PCM164_RAM = 0xC2, |
862
a2034b8d7495
Commit of VGM header that was missed previously
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
87 CMD_DATA_SEEK = 0xE0 |
a2034b8d7495
Commit of VGM header that was missed previously
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
88 }; |
a2034b8d7495
Commit of VGM header that was missed previously
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
89 |
a2034b8d7495
Commit of VGM header that was missed previously
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
90 enum { |
2081
cfd53c94fffb
Initial stab at RF5C164 emulation
Michael Pavone <pavone@retrodev.com>
parents:
2006
diff
changeset
|
91 DATA_YM2612_PCM = 0, |
cfd53c94fffb
Initial stab at RF5C164 emulation
Michael Pavone <pavone@retrodev.com>
parents:
2006
diff
changeset
|
92 DATA_RF5C68, |
cfd53c94fffb
Initial stab at RF5C164 emulation
Michael Pavone <pavone@retrodev.com>
parents:
2006
diff
changeset
|
93 DATA_RF5C164, |
862
a2034b8d7495
Commit of VGM header that was missed previously
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
94 }; |
a2034b8d7495
Commit of VGM header that was missed previously
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
95 |
a2034b8d7495
Commit of VGM header that was missed previously
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
96 #pragma pack(pop) |
a2034b8d7495
Commit of VGM header that was missed previously
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
97 |
2081
cfd53c94fffb
Initial stab at RF5C164 emulation
Michael Pavone <pavone@retrodev.com>
parents:
2006
diff
changeset
|
98 typedef struct data_block data_block; |
cfd53c94fffb
Initial stab at RF5C164 emulation
Michael Pavone <pavone@retrodev.com>
parents:
2006
diff
changeset
|
99 struct data_block { |
cfd53c94fffb
Initial stab at RF5C164 emulation
Michael Pavone <pavone@retrodev.com>
parents:
2006
diff
changeset
|
100 data_block *next; |
cfd53c94fffb
Initial stab at RF5C164 emulation
Michael Pavone <pavone@retrodev.com>
parents:
2006
diff
changeset
|
101 uint8_t *data; |
cfd53c94fffb
Initial stab at RF5C164 emulation
Michael Pavone <pavone@retrodev.com>
parents:
2006
diff
changeset
|
102 uint32_t size; |
cfd53c94fffb
Initial stab at RF5C164 emulation
Michael Pavone <pavone@retrodev.com>
parents:
2006
diff
changeset
|
103 uint8_t type; |
cfd53c94fffb
Initial stab at RF5C164 emulation
Michael Pavone <pavone@retrodev.com>
parents:
2006
diff
changeset
|
104 }; |
862
a2034b8d7495
Commit of VGM header that was missed previously
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
105 |
1909
508522f08e4d
Initial stab at VGM logging support
Michael Pavone <pavone@retrodev.com>
parents:
862
diff
changeset
|
106 typedef struct { |
508522f08e4d
Initial stab at VGM logging support
Michael Pavone <pavone@retrodev.com>
parents:
862
diff
changeset
|
107 vgm_header header; |
508522f08e4d
Initial stab at VGM logging support
Michael Pavone <pavone@retrodev.com>
parents:
862
diff
changeset
|
108 FILE *f; |
508522f08e4d
Initial stab at VGM logging support
Michael Pavone <pavone@retrodev.com>
parents:
862
diff
changeset
|
109 uint32_t master_clock; |
508522f08e4d
Initial stab at VGM logging support
Michael Pavone <pavone@retrodev.com>
parents:
862
diff
changeset
|
110 uint32_t last_cycle; |
2006
327332138c5c
Prevent wait truncation in VGM logging
Michael Pavone <pavone@retrodev.com>
parents:
1909
diff
changeset
|
111 uint32_t extra_delta; |
1909
508522f08e4d
Initial stab at VGM logging support
Michael Pavone <pavone@retrodev.com>
parents:
862
diff
changeset
|
112 } vgm_writer; |
508522f08e4d
Initial stab at VGM logging support
Michael Pavone <pavone@retrodev.com>
parents:
862
diff
changeset
|
113 |
508522f08e4d
Initial stab at VGM logging support
Michael Pavone <pavone@retrodev.com>
parents:
862
diff
changeset
|
114 vgm_writer *vgm_write_open(char *filename, uint32_t rate, uint32_t clock, uint32_t cycle); |
508522f08e4d
Initial stab at VGM logging support
Michael Pavone <pavone@retrodev.com>
parents:
862
diff
changeset
|
115 void vgm_sn76489_init(vgm_writer *writer, uint32_t clock, uint16_t feedback, uint8_t shift_reg_size, uint8_t flags); |
508522f08e4d
Initial stab at VGM logging support
Michael Pavone <pavone@retrodev.com>
parents:
862
diff
changeset
|
116 void vgm_sn76489_write(vgm_writer *writer, uint32_t cycle, uint8_t value); |
508522f08e4d
Initial stab at VGM logging support
Michael Pavone <pavone@retrodev.com>
parents:
862
diff
changeset
|
117 void vgm_ym2612_init(vgm_writer *writer, uint32_t clock); |
508522f08e4d
Initial stab at VGM logging support
Michael Pavone <pavone@retrodev.com>
parents:
862
diff
changeset
|
118 void vgm_ym2612_part1_write(vgm_writer *writer, uint32_t cycle, uint8_t reg, uint8_t value); |
508522f08e4d
Initial stab at VGM logging support
Michael Pavone <pavone@retrodev.com>
parents:
862
diff
changeset
|
119 void vgm_ym2612_part2_write(vgm_writer *writer, uint32_t cycle, uint8_t reg, uint8_t value); |
508522f08e4d
Initial stab at VGM logging support
Michael Pavone <pavone@retrodev.com>
parents:
862
diff
changeset
|
120 void vgm_adjust_cycles(vgm_writer *writer, uint32_t deduction); |
508522f08e4d
Initial stab at VGM logging support
Michael Pavone <pavone@retrodev.com>
parents:
862
diff
changeset
|
121 void vgm_close(vgm_writer *writer); |
508522f08e4d
Initial stab at VGM logging support
Michael Pavone <pavone@retrodev.com>
parents:
862
diff
changeset
|
122 |
862
a2034b8d7495
Commit of VGM header that was missed previously
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
123 #endif //VGM_H_ |