comparison ym_common.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 eb588f22ec76
comparison
equal deleted inserted replaced
2557:75dd7536c467 2558:3f58fec775df
1 #ifndef YM_COMMON_H_
2 #define YM_COMMON_H_
3 #include <stdint.h>
4 #include <stdio.h>
5
6 #define MAX_ENVELOPE 0xFFC
7 #define MAX_OPL_ENVELOPE 0xFF8
8
9 typedef struct {
10 int16_t *mod_src[2];
11 uint32_t phase_counter;
12 uint32_t phase_inc;
13 uint16_t envelope;
14 int16_t output;
15 uint16_t total_level;
16 uint16_t sustain_level;
17 uint8_t rates[4];
18 uint8_t key_scaling;
19 uint8_t multiple;
20 uint8_t detune;
21 uint8_t am;
22 uint8_t env_phase;
23 uint8_t ssg;
24 uint8_t inverted;
25 uint8_t phase_overflow;
26 } ym_operator;
27
28 typedef struct {
29 FILE * logfile;
30 uint16_t fnum;
31 int16_t output;
32 int16_t op1_old;
33 int16_t op2_old;
34 uint8_t block_fnum_latch;
35 uint8_t block;
36 uint8_t keycode;
37 uint8_t algorithm;
38 uint8_t feedback;
39 uint8_t ams;
40 uint8_t pms;
41 uint8_t lr;
42 uint8_t keyon;
43 uint8_t scope_channel;
44 uint8_t phase_overflow;
45 } ym_channel;
46
47 extern int16_t lfo_pm_table[128 * 32 * 8];
48 extern uint16_t rate_table[64*8];
49
50 void ym_init_tables(void);
51 int16_t ym_sine(uint16_t phase, int16_t mod, uint16_t env);
52 int16_t ym_opl_wave(uint16_t phase, int16_t mod, uint16_t env, uint8_t waveform);
53
54 #endif //YM_COMMON_H_