annotate vgm.h @ 1918:6fdac0108e47

Fix bug in in (c) instruction in Z80 dynarec
author Michael Pavone <pavone@retrodev.com>
date Fri, 03 Apr 2020 23:47:57 -0700
parents 508522f08e4d
children 327332138c5c
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
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,
a2034b8d7495 Commit of VGM header that was missed previously
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
61 CMD_DATA_SEEK = 0xE0
a2034b8d7495 Commit of VGM header that was missed previously
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
62 };
a2034b8d7495 Commit of VGM header that was missed previously
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
63
a2034b8d7495 Commit of VGM header that was missed previously
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
64 enum {
a2034b8d7495 Commit of VGM header that was missed previously
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
65 DATA_YM2612_PCM = 0
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 #pragma pack(pop)
a2034b8d7495 Commit of VGM header that was missed previously
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
69
a2034b8d7495 Commit of VGM header that was missed previously
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
70 typedef struct {
a2034b8d7495 Commit of VGM header that was missed previously
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
71 struct data_block *next;
a2034b8d7495 Commit of VGM header that was missed previously
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
72 uint8_t *data;
a2034b8d7495 Commit of VGM header that was missed previously
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
73 uint32_t size;
a2034b8d7495 Commit of VGM header that was missed previously
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
74 uint8_t type;
a2034b8d7495 Commit of VGM header that was missed previously
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
75 } data_block;
a2034b8d7495 Commit of VGM header that was missed previously
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
76
1909
508522f08e4d Initial stab at VGM logging support
Michael Pavone <pavone@retrodev.com>
parents: 862
diff changeset
77 typedef struct {
508522f08e4d Initial stab at VGM logging support
Michael Pavone <pavone@retrodev.com>
parents: 862
diff changeset
78 vgm_header header;
508522f08e4d Initial stab at VGM logging support
Michael Pavone <pavone@retrodev.com>
parents: 862
diff changeset
79 FILE *f;
508522f08e4d Initial stab at VGM logging support
Michael Pavone <pavone@retrodev.com>
parents: 862
diff changeset
80 uint32_t master_clock;
508522f08e4d Initial stab at VGM logging support
Michael Pavone <pavone@retrodev.com>
parents: 862
diff changeset
81 uint32_t last_cycle;
508522f08e4d Initial stab at VGM logging support
Michael Pavone <pavone@retrodev.com>
parents: 862
diff changeset
82 } vgm_writer;
508522f08e4d Initial stab at VGM logging support
Michael Pavone <pavone@retrodev.com>
parents: 862
diff changeset
83
508522f08e4d Initial stab at VGM logging support
Michael Pavone <pavone@retrodev.com>
parents: 862
diff changeset
84 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
85 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
86 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
87 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
88 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
89 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
90 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
91 void vgm_close(vgm_writer *writer);
508522f08e4d Initial stab at VGM logging support
Michael Pavone <pavone@retrodev.com>
parents: 862
diff changeset
92
862
a2034b8d7495 Commit of VGM header that was missed previously
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
93 #endif //VGM_H_