annotate ym_common.h @ 2688:b42f00a3a937 default tip

Fix default target. Ensure m68k.h and z80.h are built before anything else when no dep info is available
author Michael Pavone <pavone@retrodev.com>
date Mon, 31 Mar 2025 21:06:18 -0700
parents eb588f22ec76
children
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
2565
eb588f22ec76 More work on OPL3 emulation
Michael Pavone <pavone@retrodev.com>
parents: 2558
diff changeset
9 #define SSG_ENABLE 8
eb588f22ec76 More work on OPL3 emulation
Michael Pavone <pavone@retrodev.com>
parents: 2558
diff changeset
10 #define SSG_INVERT 4
eb588f22ec76 More work on OPL3 emulation
Michael Pavone <pavone@retrodev.com>
parents: 2558
diff changeset
11 #define SSG_ALTERNATE 2
eb588f22ec76 More work on OPL3 emulation
Michael Pavone <pavone@retrodev.com>
parents: 2558
diff changeset
12 #define SSG_HOLD 1
eb588f22ec76 More work on OPL3 emulation
Michael Pavone <pavone@retrodev.com>
parents: 2558
diff changeset
13
eb588f22ec76 More work on OPL3 emulation
Michael Pavone <pavone@retrodev.com>
parents: 2558
diff changeset
14 #define SSG_CENTER 0x800
eb588f22ec76 More work on OPL3 emulation
Michael Pavone <pavone@retrodev.com>
parents: 2558
diff changeset
15
eb588f22ec76 More work on OPL3 emulation
Michael Pavone <pavone@retrodev.com>
parents: 2558
diff changeset
16 enum {
eb588f22ec76 More work on OPL3 emulation
Michael Pavone <pavone@retrodev.com>
parents: 2558
diff changeset
17 PHASE_ATTACK,
eb588f22ec76 More work on OPL3 emulation
Michael Pavone <pavone@retrodev.com>
parents: 2558
diff changeset
18 PHASE_DECAY,
eb588f22ec76 More work on OPL3 emulation
Michael Pavone <pavone@retrodev.com>
parents: 2558
diff changeset
19 PHASE_SUSTAIN,
eb588f22ec76 More work on OPL3 emulation
Michael Pavone <pavone@retrodev.com>
parents: 2558
diff changeset
20 PHASE_RELEASE
eb588f22ec76 More work on OPL3 emulation
Michael Pavone <pavone@retrodev.com>
parents: 2558
diff changeset
21 };
eb588f22ec76 More work on OPL3 emulation
Michael Pavone <pavone@retrodev.com>
parents: 2558
diff changeset
22
2558
3f58fec775df Initial work on YMF262 (aka OPL3) emulation
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
23 typedef struct {
3f58fec775df Initial work on YMF262 (aka OPL3) emulation
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
24 int16_t *mod_src[2];
3f58fec775df Initial work on YMF262 (aka OPL3) emulation
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
25 uint32_t phase_counter;
3f58fec775df Initial work on YMF262 (aka OPL3) emulation
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
26 uint32_t phase_inc;
3f58fec775df Initial work on YMF262 (aka OPL3) emulation
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
27 uint16_t envelope;
3f58fec775df Initial work on YMF262 (aka OPL3) emulation
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
28 int16_t output;
3f58fec775df Initial work on YMF262 (aka OPL3) emulation
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
29 uint16_t total_level;
3f58fec775df Initial work on YMF262 (aka OPL3) emulation
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
30 uint16_t sustain_level;
3f58fec775df Initial work on YMF262 (aka OPL3) emulation
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
31 uint8_t rates[4];
3f58fec775df Initial work on YMF262 (aka OPL3) emulation
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
32 uint8_t key_scaling;
3f58fec775df Initial work on YMF262 (aka OPL3) emulation
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
33 uint8_t multiple;
3f58fec775df Initial work on YMF262 (aka OPL3) emulation
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
34 uint8_t detune;
3f58fec775df Initial work on YMF262 (aka OPL3) emulation
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
35 uint8_t am;
3f58fec775df Initial work on YMF262 (aka OPL3) emulation
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
36 uint8_t env_phase;
3f58fec775df Initial work on YMF262 (aka OPL3) emulation
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
37 uint8_t ssg;
3f58fec775df Initial work on YMF262 (aka OPL3) emulation
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
38 uint8_t inverted;
3f58fec775df Initial work on YMF262 (aka OPL3) emulation
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
39 uint8_t phase_overflow;
2565
eb588f22ec76 More work on OPL3 emulation
Michael Pavone <pavone@retrodev.com>
parents: 2558
diff changeset
40 uint8_t wave;
2558
3f58fec775df Initial work on YMF262 (aka OPL3) emulation
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
41 } ym_operator;
3f58fec775df Initial work on YMF262 (aka OPL3) emulation
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
42
3f58fec775df Initial work on YMF262 (aka OPL3) emulation
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
43 typedef struct {
3f58fec775df Initial work on YMF262 (aka OPL3) emulation
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
44 FILE * logfile;
3f58fec775df Initial work on YMF262 (aka OPL3) emulation
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
45 uint16_t fnum;
3f58fec775df Initial work on YMF262 (aka OPL3) emulation
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
46 int16_t output;
3f58fec775df Initial work on YMF262 (aka OPL3) emulation
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
47 int16_t op1_old;
3f58fec775df Initial work on YMF262 (aka OPL3) emulation
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
48 int16_t op2_old;
3f58fec775df Initial work on YMF262 (aka OPL3) emulation
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
49 uint8_t block_fnum_latch;
3f58fec775df Initial work on YMF262 (aka OPL3) emulation
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
50 uint8_t block;
3f58fec775df Initial work on YMF262 (aka OPL3) emulation
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
51 uint8_t keycode;
3f58fec775df Initial work on YMF262 (aka OPL3) emulation
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
52 uint8_t algorithm;
3f58fec775df Initial work on YMF262 (aka OPL3) emulation
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
53 uint8_t feedback;
3f58fec775df Initial work on YMF262 (aka OPL3) emulation
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
54 uint8_t ams;
3f58fec775df Initial work on YMF262 (aka OPL3) emulation
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
55 uint8_t pms;
3f58fec775df Initial work on YMF262 (aka OPL3) emulation
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
56 uint8_t lr;
3f58fec775df Initial work on YMF262 (aka OPL3) emulation
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
57 uint8_t keyon;
3f58fec775df Initial work on YMF262 (aka OPL3) emulation
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
58 uint8_t scope_channel;
3f58fec775df Initial work on YMF262 (aka OPL3) emulation
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
59 uint8_t phase_overflow;
3f58fec775df Initial work on YMF262 (aka OPL3) emulation
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
60 } ym_channel;
3f58fec775df Initial work on YMF262 (aka OPL3) emulation
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
61
3f58fec775df Initial work on YMF262 (aka OPL3) emulation
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
62 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
63 extern uint16_t rate_table[64*8];
3f58fec775df Initial work on YMF262 (aka OPL3) emulation
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
64
3f58fec775df Initial work on YMF262 (aka OPL3) emulation
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
65 void ym_init_tables(void);
3f58fec775df Initial work on YMF262 (aka OPL3) emulation
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
66 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
67 int16_t ym_opl_wave(uint16_t phase, int16_t mod, uint16_t env, uint8_t waveform);
2565
eb588f22ec76 More work on OPL3 emulation
Michael Pavone <pavone@retrodev.com>
parents: 2558
diff changeset
68 void start_envelope(ym_operator *op, ym_channel *channel);
eb588f22ec76 More work on OPL3 emulation
Michael Pavone <pavone@retrodev.com>
parents: 2558
diff changeset
69 void keyon(ym_operator *op, ym_channel *channel);
eb588f22ec76 More work on OPL3 emulation
Michael Pavone <pavone@retrodev.com>
parents: 2558
diff changeset
70 void keyoff(ym_operator *op);
2558
3f58fec775df Initial work on YMF262 (aka OPL3) emulation
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
71
3f58fec775df Initial work on YMF262 (aka OPL3) emulation
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
72 #endif //YM_COMMON_H_