Mercurial > repos > blastem
annotate vgm.h @ 2195:40290a923886
Implement Game Gear start button and region register
author | Michael Pavone <pavone@retrodev.com> |
---|---|
date | Sun, 21 Aug 2022 22:56:32 -0700 |
parents | cfd53c94fffb |
children | 92449b47cce8 |
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 |
a2034b8d7495
Commit of VGM header that was missed previously
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
29 enum { |
a2034b8d7495
Commit of VGM header that was missed previously
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
30 CMD_PSG_STEREO = 0x4F, |
a2034b8d7495
Commit of VGM header that was missed previously
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
31 CMD_PSG, |
a2034b8d7495
Commit of VGM header that was missed previously
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
32 CMD_YM2413, |
a2034b8d7495
Commit of VGM header that was missed previously
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
33 CMD_YM2612_0, |
a2034b8d7495
Commit of VGM header that was missed previously
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
34 CMD_YM2612_1, |
a2034b8d7495
Commit of VGM header that was missed previously
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
35 CMD_YM2151, |
a2034b8d7495
Commit of VGM header that was missed previously
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
36 CMD_YM2203, |
a2034b8d7495
Commit of VGM header that was missed previously
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
37 CMD_YM2608_0, |
a2034b8d7495
Commit of VGM header that was missed previously
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
38 CMD_YM2608_1, |
a2034b8d7495
Commit of VGM header that was missed previously
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
39 CMD_YM2610_0, |
a2034b8d7495
Commit of VGM header that was missed previously
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
40 CMD_YM2610_1, |
a2034b8d7495
Commit of VGM header that was missed previously
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
41 CMD_YM3812, |
a2034b8d7495
Commit of VGM header that was missed previously
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
42 CMD_YM3526, |
a2034b8d7495
Commit of VGM header that was missed previously
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
43 CMD_Y8950, |
a2034b8d7495
Commit of VGM header that was missed previously
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
44 CMD_YMZ280B, |
a2034b8d7495
Commit of VGM header that was missed previously
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
45 CMD_YMF262_0, |
a2034b8d7495
Commit of VGM header that was missed previously
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
46 CMD_YMF262_1, |
a2034b8d7495
Commit of VGM header that was missed previously
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
47 CMD_WAIT = 0x61, |
a2034b8d7495
Commit of VGM header that was missed previously
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
48 CMD_WAIT_60, |
a2034b8d7495
Commit of VGM header that was missed previously
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
49 CMD_WAIT_50, |
a2034b8d7495
Commit of VGM header that was missed previously
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
50 CMD_END = 0x66, |
a2034b8d7495
Commit of VGM header that was missed previously
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
51 CMD_DATA, |
a2034b8d7495
Commit of VGM header that was missed previously
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
52 CMD_PCM_WRITE, |
a2034b8d7495
Commit of VGM header that was missed previously
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
53 CMD_WAIT_SHORT = 0x70, |
a2034b8d7495
Commit of VGM header that was missed previously
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
54 CMD_YM2612_DAC = 0x80, |
a2034b8d7495
Commit of VGM header that was missed previously
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
55 CMD_DAC_STREAM_SETUP = 0x90, |
a2034b8d7495
Commit of VGM header that was missed previously
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
56 CMD_DAC_STREAM_DATA, |
a2034b8d7495
Commit of VGM header that was missed previously
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
57 CMD_DAC_STREAM_FREQ, |
a2034b8d7495
Commit of VGM header that was missed previously
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
58 CMD_DAC_STREAM_START, |
a2034b8d7495
Commit of VGM header that was missed previously
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
59 CMD_DAC_STREAM_STOP, |
a2034b8d7495
Commit of VGM header that was missed previously
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
60 CMD_DAC_STREAM_STARTFAST, |
2081
cfd53c94fffb
Initial stab at RF5C164 emulation
Michael Pavone <pavone@retrodev.com>
parents:
2006
diff
changeset
|
61 CMD_PCM68_REG = 0xB0, |
cfd53c94fffb
Initial stab at RF5C164 emulation
Michael Pavone <pavone@retrodev.com>
parents:
2006
diff
changeset
|
62 CMD_PCM164_REG, |
cfd53c94fffb
Initial stab at RF5C164 emulation
Michael Pavone <pavone@retrodev.com>
parents:
2006
diff
changeset
|
63 CMD_PCM68_RAM = 0xC1, |
cfd53c94fffb
Initial stab at RF5C164 emulation
Michael Pavone <pavone@retrodev.com>
parents:
2006
diff
changeset
|
64 CMD_PCM164_RAM = 0xC2, |
862
a2034b8d7495
Commit of VGM header that was missed previously
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
65 CMD_DATA_SEEK = 0xE0 |
a2034b8d7495
Commit of VGM header that was missed previously
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
66 }; |
a2034b8d7495
Commit of VGM header that was missed previously
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
67 |
a2034b8d7495
Commit of VGM header that was missed previously
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
68 enum { |
2081
cfd53c94fffb
Initial stab at RF5C164 emulation
Michael Pavone <pavone@retrodev.com>
parents:
2006
diff
changeset
|
69 DATA_YM2612_PCM = 0, |
cfd53c94fffb
Initial stab at RF5C164 emulation
Michael Pavone <pavone@retrodev.com>
parents:
2006
diff
changeset
|
70 DATA_RF5C68, |
cfd53c94fffb
Initial stab at RF5C164 emulation
Michael Pavone <pavone@retrodev.com>
parents:
2006
diff
changeset
|
71 DATA_RF5C164, |
862
a2034b8d7495
Commit of VGM header that was missed previously
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
72 }; |
a2034b8d7495
Commit of VGM header that was missed previously
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
73 |
a2034b8d7495
Commit of VGM header that was missed previously
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
74 #pragma pack(pop) |
a2034b8d7495
Commit of VGM header that was missed previously
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
75 |
2081
cfd53c94fffb
Initial stab at RF5C164 emulation
Michael Pavone <pavone@retrodev.com>
parents:
2006
diff
changeset
|
76 typedef struct data_block data_block; |
cfd53c94fffb
Initial stab at RF5C164 emulation
Michael Pavone <pavone@retrodev.com>
parents:
2006
diff
changeset
|
77 struct data_block { |
cfd53c94fffb
Initial stab at RF5C164 emulation
Michael Pavone <pavone@retrodev.com>
parents:
2006
diff
changeset
|
78 data_block *next; |
cfd53c94fffb
Initial stab at RF5C164 emulation
Michael Pavone <pavone@retrodev.com>
parents:
2006
diff
changeset
|
79 uint8_t *data; |
cfd53c94fffb
Initial stab at RF5C164 emulation
Michael Pavone <pavone@retrodev.com>
parents:
2006
diff
changeset
|
80 uint32_t size; |
cfd53c94fffb
Initial stab at RF5C164 emulation
Michael Pavone <pavone@retrodev.com>
parents:
2006
diff
changeset
|
81 uint8_t type; |
cfd53c94fffb
Initial stab at RF5C164 emulation
Michael Pavone <pavone@retrodev.com>
parents:
2006
diff
changeset
|
82 }; |
862
a2034b8d7495
Commit of VGM header that was missed previously
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
83 |
1909
508522f08e4d
Initial stab at VGM logging support
Michael Pavone <pavone@retrodev.com>
parents:
862
diff
changeset
|
84 typedef struct { |
508522f08e4d
Initial stab at VGM logging support
Michael Pavone <pavone@retrodev.com>
parents:
862
diff
changeset
|
85 vgm_header header; |
508522f08e4d
Initial stab at VGM logging support
Michael Pavone <pavone@retrodev.com>
parents:
862
diff
changeset
|
86 FILE *f; |
508522f08e4d
Initial stab at VGM logging support
Michael Pavone <pavone@retrodev.com>
parents:
862
diff
changeset
|
87 uint32_t master_clock; |
508522f08e4d
Initial stab at VGM logging support
Michael Pavone <pavone@retrodev.com>
parents:
862
diff
changeset
|
88 uint32_t last_cycle; |
2006
327332138c5c
Prevent wait truncation in VGM logging
Michael Pavone <pavone@retrodev.com>
parents:
1909
diff
changeset
|
89 uint32_t extra_delta; |
1909
508522f08e4d
Initial stab at VGM logging support
Michael Pavone <pavone@retrodev.com>
parents:
862
diff
changeset
|
90 } vgm_writer; |
508522f08e4d
Initial stab at VGM logging support
Michael Pavone <pavone@retrodev.com>
parents:
862
diff
changeset
|
91 |
508522f08e4d
Initial stab at VGM logging support
Michael Pavone <pavone@retrodev.com>
parents:
862
diff
changeset
|
92 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
|
93 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
|
94 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
|
95 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
|
96 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
|
97 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
|
98 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
|
99 void vgm_close(vgm_writer *writer); |
508522f08e4d
Initial stab at VGM logging support
Michael Pavone <pavone@retrodev.com>
parents:
862
diff
changeset
|
100 |
862
a2034b8d7495
Commit of VGM header that was missed previously
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
101 #endif //VGM_H_ |