Mercurial > repos > blastem
comparison ym2612.h @ 1931:374a5ae694e8 mame_interp
Merge from default
author | Michael Pavone <pavone@retrodev.com> |
---|---|
date | Sat, 18 Apr 2020 11:42:53 -0700 |
parents | 508522f08e4d |
children | 0d1d5dccdd28 |
comparison
equal
deleted
inserted
replaced
1843:13abdc98379e | 1931:374a5ae694e8 |
---|---|
7 #define YM2612_H_ | 7 #define YM2612_H_ |
8 | 8 |
9 #include <stdint.h> | 9 #include <stdint.h> |
10 #include <stdio.h> | 10 #include <stdio.h> |
11 #include "serialize.h" | 11 #include "serialize.h" |
12 #include "render.h" | 12 #include "render_audio.h" |
13 #include "vgm.h" | |
13 | 14 |
14 #define NUM_PART_REGS (0xB7-0x30) | 15 #define NUM_PART_REGS (0xB7-0x30) |
15 #define NUM_CHANNELS 6 | 16 #define NUM_CHANNELS 6 |
16 #define NUM_OPERATORS (4*NUM_CHANNELS) | 17 #define NUM_OPERATORS (4*NUM_CHANNELS) |
17 | 18 |
18 #define YM_OPT_WAVE_LOG 1 | 19 #define YM_OPT_WAVE_LOG 1 |
20 #define YM_OPT_3834 2 | |
19 | 21 |
20 typedef struct { | 22 typedef struct { |
21 int16_t *mod_src[2]; | 23 int16_t *mod_src[2]; |
22 uint32_t phase_counter; | 24 uint32_t phase_counter; |
25 uint32_t phase_inc; | |
23 uint16_t envelope; | 26 uint16_t envelope; |
24 int16_t output; | 27 int16_t output; |
25 uint16_t total_level; | 28 uint16_t total_level; |
26 uint16_t sustain_level; | 29 uint16_t sustain_level; |
27 uint8_t rates[4]; | 30 uint8_t rates[4]; |
64 #define YM_PART1_REGS (YM_REG_END-YM_PART1_START) | 67 #define YM_PART1_REGS (YM_REG_END-YM_PART1_START) |
65 #define YM_PART2_REGS (YM_REG_END-YM_PART2_START) | 68 #define YM_PART2_REGS (YM_REG_END-YM_PART2_START) |
66 | 69 |
67 typedef struct { | 70 typedef struct { |
68 audio_source *audio; | 71 audio_source *audio; |
72 vgm_writer *vgm; | |
69 uint32_t clock_inc; | 73 uint32_t clock_inc; |
70 uint32_t current_cycle; | 74 uint32_t current_cycle; |
71 //TODO: Condense the next two fields into one | |
72 uint32_t write_cycle; | 75 uint32_t write_cycle; |
76 uint32_t busy_start; | |
73 uint32_t busy_cycles; | 77 uint32_t busy_cycles; |
78 uint32_t last_status_cycle; | |
79 uint32_t invalid_status_decay; | |
80 uint32_t status_address_mask; | |
74 int32_t volume_mult; | 81 int32_t volume_mult; |
75 int32_t volume_div; | 82 int32_t volume_div; |
76 ym_operator operators[NUM_OPERATORS]; | 83 ym_operator operators[NUM_OPERATORS]; |
77 ym_channel channels[NUM_CHANNELS]; | 84 ym_channel channels[NUM_CHANNELS]; |
78 int16_t zero_offset; | 85 int16_t zero_offset; |
94 uint8_t lfo_counter; | 101 uint8_t lfo_counter; |
95 uint8_t lfo_am_step; | 102 uint8_t lfo_am_step; |
96 uint8_t lfo_pm_step; | 103 uint8_t lfo_pm_step; |
97 uint8_t csm_keyon; | 104 uint8_t csm_keyon; |
98 uint8_t status; | 105 uint8_t status; |
106 uint8_t last_status; | |
99 uint8_t selected_reg; | 107 uint8_t selected_reg; |
100 uint8_t selected_part; | 108 uint8_t selected_part; |
101 uint8_t part1_regs[YM_PART1_REGS]; | 109 uint8_t part1_regs[YM_PART1_REGS]; |
102 uint8_t part2_regs[YM_PART2_REGS]; | 110 uint8_t part2_regs[YM_PART2_REGS]; |
103 } ym2612_context; | 111 } ym2612_context; |
131 void ym_init(ym2612_context * context, uint32_t master_clock, uint32_t clock_div, uint32_t options); | 139 void ym_init(ym2612_context * context, uint32_t master_clock, uint32_t clock_div, uint32_t options); |
132 void ym_reset(ym2612_context *context); | 140 void ym_reset(ym2612_context *context); |
133 void ym_free(ym2612_context *context); | 141 void ym_free(ym2612_context *context); |
134 void ym_enable_zero_offset(ym2612_context *context, uint8_t enabled); | 142 void ym_enable_zero_offset(ym2612_context *context, uint8_t enabled); |
135 void ym_adjust_master_clock(ym2612_context * context, uint32_t master_clock); | 143 void ym_adjust_master_clock(ym2612_context * context, uint32_t master_clock); |
144 void ym_adjust_cycles(ym2612_context *context, uint32_t deduction); | |
136 void ym_run(ym2612_context * context, uint32_t to_cycle); | 145 void ym_run(ym2612_context * context, uint32_t to_cycle); |
137 void ym_address_write_part1(ym2612_context * context, uint8_t address); | 146 void ym_address_write_part1(ym2612_context * context, uint8_t address); |
138 void ym_address_write_part2(ym2612_context * context, uint8_t address); | 147 void ym_address_write_part2(ym2612_context * context, uint8_t address); |
139 void ym_data_write(ym2612_context * context, uint8_t value); | 148 void ym_data_write(ym2612_context * context, uint8_t value); |
140 uint8_t ym_read_status(ym2612_context * context); | 149 void ym_vgm_log(ym2612_context *context, uint32_t master_clock, vgm_writer *vgm); |
150 uint8_t ym_read_status(ym2612_context * context, uint32_t cycle, uint32_t port); | |
141 uint8_t ym_load_gst(ym2612_context * context, FILE * gstfile); | 151 uint8_t ym_load_gst(ym2612_context * context, FILE * gstfile); |
142 uint8_t ym_save_gst(ym2612_context * context, FILE * gstfile); | 152 uint8_t ym_save_gst(ym2612_context * context, FILE * gstfile); |
143 void ym_print_channel_info(ym2612_context *context, int channel); | 153 void ym_print_channel_info(ym2612_context *context, int channel); |
144 void ym_print_timer_info(ym2612_context *context); | 154 void ym_print_timer_info(ym2612_context *context); |
145 void ym_serialize(ym2612_context *context, serialize_buffer *buf); | 155 void ym_serialize(ym2612_context *context, serialize_buffer *buf); |