comparison ym_common.h @ 2565:eb588f22ec76

More work on OPL3 emulation
author Michael Pavone <pavone@retrodev.com>
date Sun, 26 Jan 2025 23:32:40 -0800
parents 3f58fec775df
children
comparison
equal deleted inserted replaced
2564:553a0b4888db 2565:eb588f22ec76
3 #include <stdint.h> 3 #include <stdint.h>
4 #include <stdio.h> 4 #include <stdio.h>
5 5
6 #define MAX_ENVELOPE 0xFFC 6 #define MAX_ENVELOPE 0xFFC
7 #define MAX_OPL_ENVELOPE 0xFF8 7 #define MAX_OPL_ENVELOPE 0xFF8
8
9 #define SSG_ENABLE 8
10 #define SSG_INVERT 4
11 #define SSG_ALTERNATE 2
12 #define SSG_HOLD 1
13
14 #define SSG_CENTER 0x800
15
16 enum {
17 PHASE_ATTACK,
18 PHASE_DECAY,
19 PHASE_SUSTAIN,
20 PHASE_RELEASE
21 };
8 22
9 typedef struct { 23 typedef struct {
10 int16_t *mod_src[2]; 24 int16_t *mod_src[2];
11 uint32_t phase_counter; 25 uint32_t phase_counter;
12 uint32_t phase_inc; 26 uint32_t phase_inc;
21 uint8_t am; 35 uint8_t am;
22 uint8_t env_phase; 36 uint8_t env_phase;
23 uint8_t ssg; 37 uint8_t ssg;
24 uint8_t inverted; 38 uint8_t inverted;
25 uint8_t phase_overflow; 39 uint8_t phase_overflow;
40 uint8_t wave;
26 } ym_operator; 41 } ym_operator;
27 42
28 typedef struct { 43 typedef struct {
29 FILE * logfile; 44 FILE * logfile;
30 uint16_t fnum; 45 uint16_t fnum;
48 extern uint16_t rate_table[64*8]; 63 extern uint16_t rate_table[64*8];
49 64
50 void ym_init_tables(void); 65 void ym_init_tables(void);
51 int16_t ym_sine(uint16_t phase, int16_t mod, uint16_t env); 66 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); 67 int16_t ym_opl_wave(uint16_t phase, int16_t mod, uint16_t env, uint8_t waveform);
68 void start_envelope(ym_operator *op, ym_channel *channel);
69 void keyon(ym_operator *op, ym_channel *channel);
70 void keyoff(ym_operator *op);
53 71
54 #endif //YM_COMMON_H_ 72 #endif //YM_COMMON_H_