annotate 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
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
2558
3f58fec775df Initial work on YMF262 (aka OPL3) emulation
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
1 #ifndef YM_COMMON_H_
3f58fec775df Initial work on YMF262 (aka OPL3) emulation
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
2 #define YM_COMMON_H_
3f58fec775df Initial work on YMF262 (aka OPL3) emulation
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
3 #include <stdint.h>
3f58fec775df Initial work on YMF262 (aka OPL3) emulation
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
4 #include <stdio.h>
3f58fec775df Initial work on YMF262 (aka OPL3) emulation
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
5
3f58fec775df Initial work on YMF262 (aka OPL3) emulation
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
6 #define MAX_ENVELOPE 0xFFC
3f58fec775df Initial work on YMF262 (aka OPL3) emulation
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
7 #define MAX_OPL_ENVELOPE 0xFF8
3f58fec775df Initial work on YMF262 (aka OPL3) emulation
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
8
3f58fec775df Initial work on YMF262 (aka OPL3) emulation
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
9 typedef struct {
3f58fec775df Initial work on YMF262 (aka OPL3) emulation
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
10 int16_t *mod_src[2];
3f58fec775df Initial work on YMF262 (aka OPL3) emulation
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
11 uint32_t phase_counter;
3f58fec775df Initial work on YMF262 (aka OPL3) emulation
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
12 uint32_t phase_inc;
3f58fec775df Initial work on YMF262 (aka OPL3) emulation
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
13 uint16_t envelope;
3f58fec775df Initial work on YMF262 (aka OPL3) emulation
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
14 int16_t output;
3f58fec775df Initial work on YMF262 (aka OPL3) emulation
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
15 uint16_t total_level;
3f58fec775df Initial work on YMF262 (aka OPL3) emulation
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
16 uint16_t sustain_level;
3f58fec775df Initial work on YMF262 (aka OPL3) emulation
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
17 uint8_t rates[4];
3f58fec775df Initial work on YMF262 (aka OPL3) emulation
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
18 uint8_t key_scaling;
3f58fec775df Initial work on YMF262 (aka OPL3) emulation
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
19 uint8_t multiple;
3f58fec775df Initial work on YMF262 (aka OPL3) emulation
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
20 uint8_t detune;
3f58fec775df Initial work on YMF262 (aka OPL3) emulation
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
21 uint8_t am;
3f58fec775df Initial work on YMF262 (aka OPL3) emulation
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
22 uint8_t env_phase;
3f58fec775df Initial work on YMF262 (aka OPL3) emulation
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
23 uint8_t ssg;
3f58fec775df Initial work on YMF262 (aka OPL3) emulation
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
24 uint8_t inverted;
3f58fec775df Initial work on YMF262 (aka OPL3) emulation
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
25 uint8_t phase_overflow;
3f58fec775df Initial work on YMF262 (aka OPL3) emulation
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
26 } ym_operator;
3f58fec775df Initial work on YMF262 (aka OPL3) emulation
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
27
3f58fec775df Initial work on YMF262 (aka OPL3) emulation
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
28 typedef struct {
3f58fec775df Initial work on YMF262 (aka OPL3) emulation
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
29 FILE * logfile;
3f58fec775df Initial work on YMF262 (aka OPL3) emulation
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
30 uint16_t fnum;
3f58fec775df Initial work on YMF262 (aka OPL3) emulation
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
31 int16_t output;
3f58fec775df Initial work on YMF262 (aka OPL3) emulation
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
32 int16_t op1_old;
3f58fec775df Initial work on YMF262 (aka OPL3) emulation
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
33 int16_t op2_old;
3f58fec775df Initial work on YMF262 (aka OPL3) emulation
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
34 uint8_t block_fnum_latch;
3f58fec775df Initial work on YMF262 (aka OPL3) emulation
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
35 uint8_t block;
3f58fec775df Initial work on YMF262 (aka OPL3) emulation
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
36 uint8_t keycode;
3f58fec775df Initial work on YMF262 (aka OPL3) emulation
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
37 uint8_t algorithm;
3f58fec775df Initial work on YMF262 (aka OPL3) emulation
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
38 uint8_t feedback;
3f58fec775df Initial work on YMF262 (aka OPL3) emulation
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
39 uint8_t ams;
3f58fec775df Initial work on YMF262 (aka OPL3) emulation
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
40 uint8_t pms;
3f58fec775df Initial work on YMF262 (aka OPL3) emulation
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
41 uint8_t lr;
3f58fec775df Initial work on YMF262 (aka OPL3) emulation
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
42 uint8_t keyon;
3f58fec775df Initial work on YMF262 (aka OPL3) emulation
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
43 uint8_t scope_channel;
3f58fec775df Initial work on YMF262 (aka OPL3) emulation
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
44 uint8_t phase_overflow;
3f58fec775df Initial work on YMF262 (aka OPL3) emulation
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
45 } ym_channel;
3f58fec775df Initial work on YMF262 (aka OPL3) emulation
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
46
3f58fec775df Initial work on YMF262 (aka OPL3) emulation
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
47 extern int16_t lfo_pm_table[128 * 32 * 8];
3f58fec775df Initial work on YMF262 (aka OPL3) emulation
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
48 extern uint16_t rate_table[64*8];
3f58fec775df Initial work on YMF262 (aka OPL3) emulation
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
49
3f58fec775df Initial work on YMF262 (aka OPL3) emulation
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
50 void ym_init_tables(void);
3f58fec775df Initial work on YMF262 (aka OPL3) emulation
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
51 int16_t ym_sine(uint16_t phase, int16_t mod, uint16_t env);
3f58fec775df Initial work on YMF262 (aka OPL3) emulation
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
52 int16_t ym_opl_wave(uint16_t phase, int16_t mod, uint16_t env, uint8_t waveform);
3f58fec775df Initial work on YMF262 (aka OPL3) emulation
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
53
3f58fec775df Initial work on YMF262 (aka OPL3) emulation
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
54 #endif //YM_COMMON_H_