| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
|
| 20 |
|
| 21 |
|
| 22 |
|
| 23 |
#ifndef OPLL_H |
| 24 |
#define OPLL_H |
| 25 |
|
| 26 |
#include <cstdint> |
| 27 |
|
| 28 |
enum : uint8_t { |
| 29 |
opll_type_ym2413 = 0x00, |
| 30 |
opll_type_ds1001, |
| 31 |
opll_type_ym2413b, |
| 32 |
opll_type_ymf281, |
| 33 |
opll_type_ymf281b, |
| 34 |
opll_type_ym2420, |
| 35 |
opll_type_ym2423, |
| 36 |
}; |
| 37 |
|
| 38 |
enum : uint8_t { |
| 39 |
opll_patch_1 = 0x00, |
| 40 |
opll_patch_2, |
| 41 |
opll_patch_3, |
| 42 |
opll_patch_4, |
| 43 |
opll_patch_5, |
| 44 |
opll_patch_6, |
| 45 |
opll_patch_7, |
| 46 |
opll_patch_8, |
| 47 |
opll_patch_9, |
| 48 |
opll_patch_10, |
| 49 |
opll_patch_11, |
| 50 |
opll_patch_12, |
| 51 |
opll_patch_13, |
| 52 |
opll_patch_14, |
| 53 |
opll_patch_15, |
| 54 |
opll_patch_drum_0, |
| 55 |
opll_patch_drum_1, |
| 56 |
opll_patch_drum_2, |
| 57 |
opll_patch_drum_3, |
| 58 |
opll_patch_drum_4, |
| 59 |
opll_patch_drum_5, |
| 60 |
opll_patch_max |
| 61 |
}; |
| 62 |
|
| 63 |
struct opll_patch_t { |
| 64 |
uint8_t tl; |
| 65 |
uint8_t dc; |
| 66 |
uint8_t dm; |
| 67 |
uint8_t fb; |
| 68 |
uint8_t am[2]; |
| 69 |
uint8_t vib[2]; |
| 70 |
uint8_t et[2]; |
| 71 |
uint8_t ksr[2]; |
| 72 |
uint8_t multi[2]; |
| 73 |
uint8_t ksl[2]; |
| 74 |
uint8_t ar[2]; |
| 75 |
uint8_t dr[2]; |
| 76 |
uint8_t sl[2]; |
| 77 |
uint8_t rr[2]; |
| 78 |
}; |
| 79 |
|
| 80 |
struct opll_t { |
| 81 |
uint32_t chip_type; |
| 82 |
uint32_t cycles; |
| 83 |
uint32_t slot; |
| 84 |
const opll_patch_t *patchrom; |
| 85 |
|
| 86 |
uint8_t write_data; |
| 87 |
uint8_t write_a; |
| 88 |
uint8_t write_d; |
| 89 |
uint8_t write_a_en; |
| 90 |
uint8_t write_d_en; |
| 91 |
uint8_t write_fm_address; |
| 92 |
uint8_t write_fm_data; |
| 93 |
uint8_t write_mode_address; |
| 94 |
uint8_t address; |
| 95 |
uint8_t data; |
| 96 |
|
| 97 |
uint8_t eg_counter_state; |
| 98 |
uint8_t eg_counter_state_prev; |
| 99 |
uint32_t eg_timer; |
| 100 |
uint8_t eg_timer_low_lock; |
| 101 |
uint8_t eg_timer_carry; |
| 102 |
uint8_t eg_timer_shift; |
| 103 |
uint8_t eg_timer_shift_lock; |
| 104 |
uint8_t eg_timer_shift_stop; |
| 105 |
uint8_t eg_state[18]; |
| 106 |
uint8_t eg_level[18]; |
| 107 |
uint8_t eg_kon; |
| 108 |
uint32_t eg_dokon; |
| 109 |
uint8_t eg_off; |
| 110 |
uint8_t eg_rate; |
| 111 |
uint8_t eg_maxrate; |
| 112 |
uint8_t eg_zerorate; |
| 113 |
uint8_t eg_inc_lo; |
| 114 |
uint8_t eg_inc_hi; |
| 115 |
uint8_t eg_rate_hi; |
| 116 |
uint16_t eg_sl; |
| 117 |
uint16_t eg_ksltl; |
| 118 |
uint8_t eg_out; |
| 119 |
uint8_t eg_silent; |
| 120 |
|
| 121 |
uint16_t pg_fnum; |
| 122 |
uint8_t pg_block; |
| 123 |
uint16_t pg_out; |
| 124 |
uint32_t pg_inc; |
| 125 |
uint32_t pg_phase[18]; |
| 126 |
uint32_t pg_phase_next; |
| 127 |
|
| 128 |
int16_t op_fb1[9]; |
| 129 |
int16_t op_fb2[9]; |
| 130 |
int16_t op_fbsum; |
| 131 |
int16_t op_mod; |
| 132 |
uint8_t op_neg; |
| 133 |
uint16_t op_logsin; |
| 134 |
uint16_t op_exp_m; |
| 135 |
uint16_t op_exp_s; |
| 136 |
|
| 137 |
int16_t ch_out; |
| 138 |
int16_t ch_out_hh; |
| 139 |
int16_t ch_out_tm; |
| 140 |
int16_t ch_out_bd; |
| 141 |
int16_t ch_out_sd; |
| 142 |
int16_t ch_out_tc; |
| 143 |
|
| 144 |
uint16_t lfo_counter; |
| 145 |
uint8_t lfo_vib_counter; |
| 146 |
uint16_t lfo_am_counter; |
| 147 |
uint8_t lfo_am_step; |
| 148 |
uint8_t lfo_am_dir; |
| 149 |
uint8_t lfo_am_car; |
| 150 |
uint8_t lfo_am_out; |
| 151 |
|
| 152 |
uint16_t fnum[9]; |
| 153 |
uint8_t block[9]; |
| 154 |
uint8_t kon[9]; |
| 155 |
uint8_t son[9]; |
| 156 |
uint8_t vol[9]; |
| 157 |
uint8_t inst[9]; |
| 158 |
uint8_t rhythm; |
| 159 |
uint8_t testmode; |
| 160 |
opll_patch_t patch; |
| 161 |
uint8_t c_instr; |
| 162 |
uint8_t c_op; |
| 163 |
uint8_t c_tl; |
| 164 |
uint8_t c_dc; |
| 165 |
uint8_t c_dm; |
| 166 |
uint8_t c_fb; |
| 167 |
uint8_t c_am; |
| 168 |
uint8_t c_vib; |
| 169 |
uint8_t c_et; |
| 170 |
uint8_t c_ksr; |
| 171 |
uint8_t c_ksr_freq; |
| 172 |
uint8_t c_ksl_freq; |
| 173 |
uint8_t c_ksl_block; |
| 174 |
uint8_t c_multi; |
| 175 |
uint8_t c_ksl; |
| 176 |
uint8_t c_adrr[3]; |
| 177 |
uint8_t c_sl; |
| 178 |
uint16_t c_fnum; |
| 179 |
uint16_t c_block; |
| 180 |
|
| 181 |
int8_t rm_enable; |
| 182 |
uint32_t rm_noise; |
| 183 |
uint32_t rm_select; |
| 184 |
uint8_t rm_hh_bit2; |
| 185 |
uint8_t rm_hh_bit3; |
| 186 |
uint8_t rm_hh_bit7; |
| 187 |
uint8_t rm_hh_bit8; |
| 188 |
uint8_t rm_tc_bit3; |
| 189 |
uint8_t rm_tc_bit5; |
| 190 |
|
| 191 |
int16_t output_m; |
| 192 |
int16_t output_r; |
| 193 |
}; |
| 194 |
|
| 195 |
void OPLL_Reset(opll_t *chip, uint32_t chip_type); |
| 196 |
void OPLL_Clock(opll_t *chip, int32_t *buffer); |
| 197 |
void OPLL_Write(opll_t *chip, uint32_t port, uint8_t data); |
| 198 |
|
| 199 |
#endif |