| 1 |
/* |
| 2 |
* Copyright (C) 2023 nukeykt |
| 3 |
* |
| 4 |
* This file is part of YMF262-LLE. |
| 5 |
* |
| 6 |
* This program is free software; you can redistribute it and/or |
| 7 |
* modify it under the terms of the GNU General Public License |
| 8 |
* as published by the Free Software Foundation; either version 2 |
| 9 |
* of the License, or (at your option) any later version. |
| 10 |
* |
| 11 |
* This program is distributed in the hope that it will be useful, |
| 12 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 13 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 14 |
* GNU General Public License for more details. |
| 15 |
* |
| 16 |
* YMF262 emulator |
| 17 |
* Thanks: |
| 18 |
* John McMaster (siliconpr0n.org): |
| 19 |
* YMF262 decap and die shot |
| 20 |
* |
| 21 |
*/ |
| 22 |
|
| 23 |
#pragma once |
| 24 |
|
| 25 |
#include <stdint.h> |
| 26 |
|
| 27 |
typedef struct |
| 28 |
{ |
| 29 |
int mclk; |
| 30 |
int address; |
| 31 |
int data_i; |
| 32 |
int ic; |
| 33 |
int cs; |
| 34 |
int rd; |
| 35 |
int wr; |
| 36 |
} fmopl3_input_t; |
| 37 |
|
| 38 |
typedef struct |
| 39 |
{ |
| 40 |
fmopl3_input_t input; |
| 41 |
|
| 42 |
int mclk1; |
| 43 |
int mclk2; |
| 44 |
int aclk1; |
| 45 |
int aclk2; |
| 46 |
int clk1; |
| 47 |
int clk2; |
| 48 |
int rclk1; |
| 49 |
int rclk2; |
| 50 |
|
| 51 |
int o_clk1; |
| 52 |
int o_clk2; |
| 53 |
int o_rclk1; |
| 54 |
int o_rclk2; |
| 55 |
int o_wrcheck; |
| 56 |
int o_data_latch; |
| 57 |
int o_bank_latch; |
| 58 |
int o_reset0; |
| 59 |
int o_ra_w1_l1; |
| 60 |
|
| 61 |
int prescaler1_reset[2]; |
| 62 |
int prescaler1_cnt[2]; |
| 63 |
|
| 64 |
int prescaler2_reset_l[2]; |
| 65 |
int prescaler2_cnt[2]; |
| 66 |
int prescaler2_reset; |
| 67 |
int prescaler2_l1[2]; |
| 68 |
int prescaler2_l2; |
| 69 |
int prescaler2_l3[2]; |
| 70 |
int prescaler2_l4; |
| 71 |
int prescaler2_l5[2]; |
| 72 |
int prescaler2_l6[2]; |
| 73 |
int prescaler2_l7; |
| 74 |
|
| 75 |
int fsm_cnt1[2]; |
| 76 |
int fsm_cnt2[2]; |
| 77 |
int fsm_cnt3[2]; |
| 78 |
int fsm_cnt; |
| 79 |
|
| 80 |
int fsm_reset_l[2]; |
| 81 |
int fsm_out[17]; |
| 82 |
int fsm_l1[2]; |
| 83 |
int fsm_l2[2]; |
| 84 |
int fsm_l3[2]; |
| 85 |
int fsm_l4[2]; |
| 86 |
int fsm_l5[2]; |
| 87 |
int fsm_l6[2]; |
| 88 |
int fsm_l7[2]; |
| 89 |
int fsm_l8[2]; |
| 90 |
int fsm_l9[2]; |
| 91 |
int fsm_l10[2]; |
| 92 |
|
| 93 |
int ic_latch[2]; |
| 94 |
|
| 95 |
int io_rd; |
| 96 |
int io_wr; |
| 97 |
int io_cs; |
| 98 |
int io_a0; |
| 99 |
int io_a1; |
| 100 |
|
| 101 |
int io_read; |
| 102 |
int io_write; |
| 103 |
int io_write0; |
| 104 |
int io_write1; |
| 105 |
int io_bank; |
| 106 |
|
| 107 |
int data_latch; |
| 108 |
int bank_latch; |
| 109 |
int bank_masked; |
| 110 |
|
| 111 |
int reg_sel1; |
| 112 |
int reg_sel2; |
| 113 |
int reg_sel3; |
| 114 |
int reg_sel4; |
| 115 |
int reg_sel5; |
| 116 |
int reg_sel8; |
| 117 |
int reg_selbd; |
| 118 |
|
| 119 |
int reg_test0; |
| 120 |
int reg_timer1; |
| 121 |
int reg_timer2; |
| 122 |
int reg_notesel; |
| 123 |
int rhythm; |
| 124 |
int reg_rh_kon; |
| 125 |
int reg_da; |
| 126 |
int reg_dv; |
| 127 |
|
| 128 |
int reg_test1; |
| 129 |
int reg_new; |
| 130 |
int reg_4op; |
| 131 |
|
| 132 |
int reg_t1_mask; |
| 133 |
int reg_t2_mask; |
| 134 |
int reg_t1_start; |
| 135 |
int reg_t2_start; |
| 136 |
|
| 137 |
int lfo_cnt[2]; |
| 138 |
int vib_cnt[2]; |
| 139 |
int t1_step; |
| 140 |
int t2_step; |
| 141 |
int am_step; |
| 142 |
int vib_step; |
| 143 |
|
| 144 |
int rh_sel0; |
| 145 |
int rh_sel[2]; |
| 146 |
|
| 147 |
int keyon_comb; |
| 148 |
|
| 149 |
int ra_address_latch; |
| 150 |
int ra_address_good; |
| 151 |
int ra_data_latch; |
| 152 |
int ra_cnt1[2]; |
| 153 |
int ra_cnt2[2]; |
| 154 |
int ra_cnt3[2]; |
| 155 |
int ra_cnt4[2]; |
| 156 |
int ra_cnt; |
| 157 |
int ra_rst_l[2]; |
| 158 |
int ra_w1_l1; |
| 159 |
int ra_w1_l2; |
| 160 |
int ra_write; |
| 161 |
int ra_write_a; |
| 162 |
|
| 163 |
int ra_multi[36]; |
| 164 |
int ra_ksr[36]; |
| 165 |
int ra_egt[36]; |
| 166 |
int ra_am[36]; |
| 167 |
int ra_vib[36]; |
| 168 |
int ra_tl[36]; |
| 169 |
int ra_ksl[36]; |
| 170 |
int ra_ar[36]; |
| 171 |
int ra_dr[36]; |
| 172 |
int ra_sl[36]; |
| 173 |
int ra_rr[36]; |
| 174 |
int ra_wf[36]; |
| 175 |
int ra_fnum[18]; |
| 176 |
int ra_block[18]; |
| 177 |
int ra_keyon[18]; |
| 178 |
int ra_connect[18]; |
| 179 |
int ra_fb[18]; |
| 180 |
int ra_pan[18]; |
| 181 |
int ra_connect_pair[18]; |
| 182 |
int multi[2]; |
| 183 |
int ksr[2]; |
| 184 |
int egt[2]; |
| 185 |
int am[2]; |
| 186 |
int vib[2]; |
| 187 |
int tl[2]; |
| 188 |
int ksl[2]; |
| 189 |
int ar[2]; |
| 190 |
int dr[2]; |
| 191 |
int sl[2]; |
| 192 |
int rr[2]; |
| 193 |
int wf[2]; |
| 194 |
int fnum[2]; |
| 195 |
int block[2]; |
| 196 |
int keyon[2]; |
| 197 |
int connect[2]; |
| 198 |
int fb[2]; |
| 199 |
int pan[2]; |
| 200 |
int connect_pair[2]; |
| 201 |
|
| 202 |
int64_t ra_dbg1[2]; |
| 203 |
int ra_dbg2[2]; |
| 204 |
int ra_dbg_load[2]; |
| 205 |
|
| 206 |
int fb_l[2][2]; |
| 207 |
int pan_l[2][2]; |
| 208 |
|
| 209 |
int write0_sr; |
| 210 |
int write0_l[4]; |
| 211 |
int write0; |
| 212 |
|
| 213 |
int write1_sr; |
| 214 |
int write1_l[4]; |
| 215 |
int write1; |
| 216 |
|
| 217 |
int connect_l[2]; |
| 218 |
int connect_pair_l[2]; |
| 219 |
|
| 220 |
int t1_cnt[2]; |
| 221 |
int t2_cnt[2]; |
| 222 |
int t1_of[2]; |
| 223 |
int t2_of[2]; |
| 224 |
int t1_status; |
| 225 |
int t2_status; |
| 226 |
int timer_st_load_l; |
| 227 |
int timer_st_load; |
| 228 |
int t1_start; |
| 229 |
int t2_start; |
| 230 |
int t1_start_l[2]; |
| 231 |
int t2_start_l[2]; |
| 232 |
|
| 233 |
int reset0; |
| 234 |
int reset1; |
| 235 |
|
| 236 |
int pg_phase_o[4]; |
| 237 |
int pg_dbg[2]; |
| 238 |
int pg_dbg_load_l[2]; |
| 239 |
int noise_lfsr[2]; |
| 240 |
int pg_index[2]; |
| 241 |
int pg_cells[36]; |
| 242 |
int pg_out_rhy; |
| 243 |
|
| 244 |
int trem_load_l; |
| 245 |
int trem_load; |
| 246 |
int trem_st_load_l; |
| 247 |
int trem_st_load; |
| 248 |
int trem_carry[2]; |
| 249 |
int trem_value[2]; |
| 250 |
int trem_dir[2]; |
| 251 |
int trem_step; |
| 252 |
int trem_out; |
| 253 |
int trem_of[2]; |
| 254 |
|
| 255 |
int eg_load_l1[2]; |
| 256 |
int eg_load_l; |
| 257 |
int eg_load; |
| 258 |
|
| 259 |
int64_t eg_timer_masked[2]; |
| 260 |
int eg_carry[2]; |
| 261 |
int eg_mask[2]; |
| 262 |
int eg_subcnt[2]; |
| 263 |
int eg_subcnt_l[2]; |
| 264 |
int eg_sync_l[2]; |
| 265 |
int eg_timer_low; |
| 266 |
int eg_shift; |
| 267 |
int eg_timer_dbg[2]; |
| 268 |
|
| 269 |
int eg_timer_i; |
| 270 |
int eg_timer_o[4]; |
| 271 |
int eg_state_o[4]; |
| 272 |
int eg_level_o[4]; |
| 273 |
int eg_index[2]; |
| 274 |
int eg_cells[36]; |
| 275 |
|
| 276 |
int eg_out[2]; |
| 277 |
int eg_dbg[2]; |
| 278 |
int eg_dbg_load_l[2]; |
| 279 |
|
| 280 |
int hh_load; |
| 281 |
int tc_load; |
| 282 |
int hh_bit2; |
| 283 |
int hh_bit3; |
| 284 |
int hh_bit7; |
| 285 |
int hh_bit8; |
| 286 |
int tc_bit3; |
| 287 |
int tc_bit5; |
| 288 |
|
| 289 |
int op_logsin[2]; |
| 290 |
int op_saw[2]; |
| 291 |
int op_saw_phase[2]; |
| 292 |
int op_shift[2]; |
| 293 |
int op_pow[2]; |
| 294 |
int op_mute[2]; |
| 295 |
int op_sign[2]; |
| 296 |
int op_fb[4][13][2]; |
| 297 |
int op_mod[2]; |
| 298 |
|
| 299 |
int op_value; |
| 300 |
int op_value_debug; |
| 301 |
|
| 302 |
int accm_a[2]; |
| 303 |
int accm_b[2]; |
| 304 |
int accm_c[2]; |
| 305 |
int accm_d[2]; |
| 306 |
int accm_shift_a[2]; |
| 307 |
int accm_shift_b[2]; |
| 308 |
int accm_shift_c[2]; |
| 309 |
int accm_shift_d[2]; |
| 310 |
int accm_load_ac_l; |
| 311 |
int accm_load_ac; |
| 312 |
int accm_load_bd_l; |
| 313 |
int accm_load_bd; |
| 314 |
int accm_a_of; |
| 315 |
int accm_a_sign; |
| 316 |
int accm_b_of; |
| 317 |
int accm_b_sign; |
| 318 |
int accm_c_of; |
| 319 |
int accm_c_sign; |
| 320 |
int accm_d_of; |
| 321 |
int accm_d_sign; |
| 322 |
|
| 323 |
int o_doab; |
| 324 |
int o_docd; |
| 325 |
int o_sy; |
| 326 |
int o_smpac; |
| 327 |
int o_smpbd; |
| 328 |
int o_irq_pull; |
| 329 |
int o_test; |
| 330 |
|
| 331 |
int data_o; |
| 332 |
int data_z; |
| 333 |
} fmopl3_t; |
| 334 |
|
| 335 |
// modification |
| 336 |
void FMOPL3_Clock(fmopl3_t *chip); |