Mercurial > repos > blastem
comparison ymf262.h @ 2558:3f58fec775df
Initial work on YMF262 (aka OPL3) emulation
author | Michael Pavone <pavone@retrodev.com> |
---|---|
date | Sun, 19 Jan 2025 00:31:16 -0800 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
2557:75dd7536c467 | 2558:3f58fec775df |
---|---|
1 #ifndef YMF262_H_ | |
2 #define YMF262_H_ | |
3 | |
4 #include "ym_common.h" | |
5 #include "render_audio.h" | |
6 #include "vgm.h" | |
7 #include "oscilloscope.h" | |
8 | |
9 #define OPL3_NUM_CHANNELS 18 | |
10 #define OPL3_NUM_OPERATORS (2*OPL3_NUM_CHANNELS) | |
11 #define OPL3_PARAM_START 0x20 | |
12 #define OPL3_PARAM_END 0xF6 | |
13 #define OPL3_PARAM_REGS (OPL3_PARAM_END - OPL3_PARAM_START) | |
14 | |
15 typedef struct { | |
16 audio_source *audio; | |
17 vgm_writer *vgm; | |
18 oscilloscope *scope; | |
19 uint32_t clock_inc; | |
20 uint32_t cycle; | |
21 int32_t volume_mult; | |
22 int32_t volume_div; | |
23 ym_operator operators[OPL3_NUM_OPERATORS]; | |
24 ym_channel channels[OPL3_NUM_CHANNELS]; | |
25 uint8_t part1_regs[OPL3_PARAM_REGS]; | |
26 uint8_t part2_regs[OPL3_PARAM_REGS]; | |
27 uint8_t timer_test[4]; | |
28 uint8_t nts; | |
29 uint8_t connection_sel; | |
30 uint8_t opl3_mode; | |
31 uint8_t part2_test; | |
32 uint8_t status; | |
33 uint8_t current_op; | |
34 uint8_t selected_reg; | |
35 uint8_t selected_part; | |
36 } ymf262_context; | |
37 | |
38 void ymf262_init(ymf262_context *context, uint32_t master_clock, uint32_t clock_div, uint32_t options); | |
39 void ymf262_reset(ymf262_context *context); | |
40 void ymf262_free(ymf262_context *context); | |
41 void ymf262_adjust_master_clock(ymf262_context *context, uint32_t master_clock); | |
42 void ymf262_adjust_cycles(ymf262_context *context, uint32_t deduction); | |
43 void ymf262_run(ymf262_context *context, uint32_t to_cycle); | |
44 void ymf262_address_write_part1(ymf262_context *context, uint8_t address); | |
45 void ymf262_address_write_part2(ymf262_context *context, uint8_t address); | |
46 void ymf262_data_write(ymf262_context *context, uint8_t value); | |
47 void ymf262_vgm_log(ymf262_context *context, uint32_t master_clock, vgm_writer *vgm); | |
48 uint8_t ymf262_read_status(ymf262_context *context, uint32_t cycle, uint32_t port); | |
49 | |
50 | |
51 #endif // YMF262_H_ |