Mercurial > repos > blastem
comparison ym2612.h @ 2243:0d1d5dccdd28
Initial implementation of oscilloscope debug view
author | Michael Pavone <pavone@retrodev.com> |
---|---|
date | Tue, 22 Nov 2022 17:57:02 -0800 |
parents | 508522f08e4d |
children | 74112041b2c7 |
comparison
equal
deleted
inserted
replaced
2240:8e8db9141209 | 2243:0d1d5dccdd28 |
---|---|
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_audio.h" | 12 #include "render_audio.h" |
13 #include "vgm.h" | 13 #include "vgm.h" |
14 #include "oscilloscope.h" | |
14 | 15 |
15 #define NUM_PART_REGS (0xB7-0x30) | 16 #define NUM_PART_REGS (0xB7-0x30) |
16 #define NUM_CHANNELS 6 | 17 #define NUM_CHANNELS 6 |
17 #define NUM_OPERATORS (4*NUM_CHANNELS) | 18 #define NUM_OPERATORS (4*NUM_CHANNELS) |
18 | 19 |
33 uint8_t detune; | 34 uint8_t detune; |
34 uint8_t am; | 35 uint8_t am; |
35 uint8_t env_phase; | 36 uint8_t env_phase; |
36 uint8_t ssg; | 37 uint8_t ssg; |
37 uint8_t inverted; | 38 uint8_t inverted; |
39 uint8_t phase_overflow; | |
38 } ym_operator; | 40 } ym_operator; |
39 | 41 |
40 typedef struct { | 42 typedef struct { |
41 FILE * logfile; | 43 FILE * logfile; |
42 uint16_t fnum; | 44 uint16_t fnum; |
50 uint8_t feedback; | 52 uint8_t feedback; |
51 uint8_t ams; | 53 uint8_t ams; |
52 uint8_t pms; | 54 uint8_t pms; |
53 uint8_t lr; | 55 uint8_t lr; |
54 uint8_t keyon; | 56 uint8_t keyon; |
57 uint8_t scope_channel; | |
58 uint8_t phase_overflow; | |
55 } ym_channel; | 59 } ym_channel; |
56 | 60 |
57 typedef struct { | 61 typedef struct { |
58 uint16_t fnum; | 62 uint16_t fnum; |
59 uint8_t block; | 63 uint8_t block; |
67 #define YM_PART1_REGS (YM_REG_END-YM_PART1_START) | 71 #define YM_PART1_REGS (YM_REG_END-YM_PART1_START) |
68 #define YM_PART2_REGS (YM_REG_END-YM_PART2_START) | 72 #define YM_PART2_REGS (YM_REG_END-YM_PART2_START) |
69 | 73 |
70 typedef struct { | 74 typedef struct { |
71 audio_source *audio; | 75 audio_source *audio; |
72 vgm_writer *vgm; | 76 vgm_writer *vgm; |
73 uint32_t clock_inc; | 77 oscilloscope *scope; |
74 uint32_t current_cycle; | 78 uint32_t clock_inc; |
75 uint32_t write_cycle; | 79 uint32_t current_cycle; |
76 uint32_t busy_start; | 80 uint32_t write_cycle; |
77 uint32_t busy_cycles; | 81 uint32_t busy_start; |
78 uint32_t last_status_cycle; | 82 uint32_t busy_cycles; |
79 uint32_t invalid_status_decay; | 83 uint32_t last_status_cycle; |
80 uint32_t status_address_mask; | 84 uint32_t invalid_status_decay; |
81 int32_t volume_mult; | 85 uint32_t status_address_mask; |
82 int32_t volume_div; | 86 int32_t volume_mult; |
83 ym_operator operators[NUM_OPERATORS]; | 87 int32_t volume_div; |
84 ym_channel channels[NUM_CHANNELS]; | 88 ym_operator operators[NUM_OPERATORS]; |
85 int16_t zero_offset; | 89 ym_channel channels[NUM_CHANNELS]; |
86 uint16_t timer_a; | 90 int16_t zero_offset; |
87 uint16_t timer_a_load; | 91 uint16_t timer_a; |
88 uint16_t env_counter; | 92 uint16_t timer_a_load; |
89 ym_supp ch3_supp[3]; | 93 uint16_t env_counter; |
90 uint8_t timer_b; | 94 ym_supp ch3_supp[3]; |
91 uint8_t sub_timer_b; | 95 uint8_t timer_b; |
92 uint8_t timer_b_load; | 96 uint8_t sub_timer_b; |
93 uint8_t ch3_mode; | 97 uint8_t timer_b_load; |
94 uint8_t current_op; | 98 uint8_t ch3_mode; |
95 uint8_t current_env_op; | 99 uint8_t current_op; |
100 uint8_t current_env_op; | |
96 | 101 |
97 uint8_t timer_control; | 102 uint8_t timer_control; |
98 uint8_t dac_enable; | 103 uint8_t dac_enable; |
99 uint8_t lfo_enable; | 104 uint8_t lfo_enable; |
100 uint8_t lfo_freq; | 105 uint8_t lfo_freq; |
101 uint8_t lfo_counter; | 106 uint8_t lfo_counter; |
102 uint8_t lfo_am_step; | 107 uint8_t lfo_am_step; |
103 uint8_t lfo_pm_step; | 108 uint8_t lfo_pm_step; |
104 uint8_t csm_keyon; | 109 uint8_t csm_keyon; |
105 uint8_t status; | 110 uint8_t status; |
106 uint8_t last_status; | 111 uint8_t last_status; |
107 uint8_t selected_reg; | 112 uint8_t selected_reg; |
108 uint8_t selected_part; | 113 uint8_t selected_part; |
109 uint8_t part1_regs[YM_PART1_REGS]; | 114 uint8_t part1_regs[YM_PART1_REGS]; |
110 uint8_t part2_regs[YM_PART2_REGS]; | 115 uint8_t part2_regs[YM_PART2_REGS]; |
111 } ym2612_context; | 116 } ym2612_context; |
112 | 117 |
113 enum { | 118 enum { |
114 REG_LFO = 0x22, | 119 REG_LFO = 0x22, |
115 REG_TIMERA_HIGH = 0x24, | 120 REG_TIMERA_HIGH = 0x24, |
152 uint8_t ym_save_gst(ym2612_context * context, FILE * gstfile); | 157 uint8_t ym_save_gst(ym2612_context * context, FILE * gstfile); |
153 void ym_print_channel_info(ym2612_context *context, int channel); | 158 void ym_print_channel_info(ym2612_context *context, int channel); |
154 void ym_print_timer_info(ym2612_context *context); | 159 void ym_print_timer_info(ym2612_context *context); |
155 void ym_serialize(ym2612_context *context, serialize_buffer *buf); | 160 void ym_serialize(ym2612_context *context, serialize_buffer *buf); |
156 void ym_deserialize(deserialize_buffer *buf, void *vcontext); | 161 void ym_deserialize(deserialize_buffer *buf, void *vcontext); |
162 void ym_enable_scope(ym2612_context *context, oscilloscope *scope); | |
157 | 163 |
158 #endif //YM2612_H_ | 164 #endif //YM2612_H_ |
159 | 165 |