]> git.proxmox.com Git - mirror_qemu.git/blame - hw/audio/fmopl.h
hw/mips: Express dependencies of the r4k platform with Kconfig
[mirror_qemu.git] / hw / audio / fmopl.h
CommitLineData
2a6a4076
MA
1#ifndef FMOPL_H
2#define FMOPL_H
85571bc7 3
4a796e97 4
c57fbf50 5typedef void (*OPL_TIMERHANDLER)(void *param, int channel, double interval_Sec);
85571bc7
FB
6
7/* !!!!! here is private section , do not access there member direct !!!!! */
8
85571bc7
FB
9/* Saving is necessary for member of the 'R' mark for suspend/resume */
10/* ---------- OPL one of slot ---------- */
11typedef struct fm_opl_slot {
7f643fb5
JQ
12 int32_t TL; /* total level :TL << 8 */
13 int32_t TLL; /* adjusted now TL */
4a796e97 14 uint8_t KSR; /* key scale rate :(shift down bit) */
7f643fb5
JQ
15 int32_t *AR; /* attack rate :&AR_TABLE[AR<<2] */
16 int32_t *DR; /* decay rate :&DR_TALBE[DR<<2] */
17 int32_t SL; /* sustin level :SL_TALBE[SL] */
18 int32_t *RR; /* release rate :&DR_TABLE[RR<<2] */
4a796e97
JQ
19 uint8_t ksl; /* keyscale level :(shift down bits) */
20 uint8_t ksr; /* key scale rate :kcode>>KSR */
3795f180
JQ
21 uint32_t mul; /* multiple :ML_TABLE[ML] */
22 uint32_t Cnt; /* frequency count : */
23 uint32_t Incr; /* frequency step : */
85571bc7 24 /* envelope generator state */
4a796e97
JQ
25 uint8_t eg_typ; /* envelope type flag */
26 uint8_t evm; /* envelope phase */
7f643fb5
JQ
27 int32_t evc; /* envelope counter */
28 int32_t eve; /* envelope counter end point */
29 int32_t evs; /* envelope counter step */
30 int32_t evsa; /* envelope step for AR :AR[ksr] */
31 int32_t evsd; /* envelope step for DR :DR[ksr] */
32 int32_t evsr; /* envelope step for RR :RR[ksr] */
85571bc7 33 /* LFO */
4a796e97
JQ
34 uint8_t ams; /* ams flag */
35 uint8_t vib; /* vibrate flag */
85571bc7 36 /* wave selector */
7f643fb5 37 int32_t **wavetable;
85571bc7
FB
38}OPL_SLOT;
39
40/* ---------- OPL one of channel ---------- */
41typedef struct fm_opl_channel {
42 OPL_SLOT SLOT[2];
4a796e97
JQ
43 uint8_t CON; /* connection type */
44 uint8_t FB; /* feed back :(shift down bit) */
7f643fb5
JQ
45 int32_t *connect1; /* slot1 output pointer */
46 int32_t *connect2; /* slot2 output pointer */
47 int32_t op1_out[2]; /* slot1 output for selfeedback */
85571bc7 48 /* phase generator state */
3795f180 49 uint32_t block_fnum; /* block+fnum : */
4a796e97 50 uint8_t kcode; /* key code : KeyScaleCode */
3795f180
JQ
51 uint32_t fc; /* Freq. Increment base */
52 uint32_t ksl_base; /* KeyScaleLevel Base step */
4a796e97 53 uint8_t keyon; /* key on/off flag */
85571bc7
FB
54} OPL_CH;
55
56/* OPL state */
57typedef struct fm_opl_f {
85571bc7
FB
58 int clock; /* master clock (Hz) */
59 int rate; /* sampling rate (Hz) */
60 double freqbase; /* frequency base */
61 double TimerBase; /* Timer base time (==sampling time) */
4a796e97
JQ
62 uint8_t address; /* address register */
63 uint8_t status; /* status flag */
64 uint8_t statusmask; /* status mask */
3795f180 65 uint32_t mode; /* Reg.08 : CSM , notesel,etc. */
85571bc7
FB
66 /* Timer */
67 int T[2]; /* timer counter */
4a796e97 68 uint8_t st[2]; /* timer enable */
85571bc7
FB
69 /* FM channel slots */
70 OPL_CH *P_CH; /* pointer of CH */
71 int max_ch; /* maximum channel */
c11e80e2 72 /* Rhythm sention */
4a796e97 73 uint8_t rhythm; /* Rhythm mode , key flag */
85571bc7 74 /* time tables */
57ac4a7a
GH
75 int32_t AR_TABLE[76]; /* attack rate tables */
76 int32_t DR_TABLE[76]; /* decay rate tables */
3795f180 77 uint32_t FN_TABLE[1024]; /* fnumber -> increment counter */
85571bc7 78 /* LFO */
7f643fb5
JQ
79 int32_t *ams_table;
80 int32_t *vib_table;
81 int32_t amsCnt;
82 int32_t amsIncr;
83 int32_t vibCnt;
84 int32_t vibIncr;
85571bc7 85 /* wave selector enable flag */
4a796e97 86 uint8_t wavesel;
85571bc7
FB
87 /* external event callback handler */
88 OPL_TIMERHANDLER TimerHandler; /* TIMER handler */
c57fbf50 89 void *TimerParam; /* TIMER parameter */
85571bc7
FB
90} FM_OPL;
91
92/* ---------- Generic interface section ---------- */
8f7e2c2c 93FM_OPL *OPLCreate(int clock, int rate);
85571bc7 94void OPLDestroy(FM_OPL *OPL);
c57fbf50
HP
95void OPLSetTimerHandler(FM_OPL *OPL, OPL_TIMERHANDLER TimerHandler,
96 void *param);
85571bc7 97
85571bc7
FB
98int OPLWrite(FM_OPL *OPL,int a,int v);
99unsigned char OPLRead(FM_OPL *OPL,int a);
100int OPLTimerOver(FM_OPL *OPL,int c);
101
7bf10b1d 102void YM3812UpdateOne(FM_OPL *OPL, int16_t *buffer, int length);
85571bc7 103#endif