ia64/xen-unstable

view tools/ioemu/hw/fmopl.h @ 6946:e703abaf6e3d

Add behaviour to the remove methods to remove the transaction's path itself. This allows us to write Remove(path) to remove the specified path rather than having to slice the path ourselves.
author emellor@ewan
date Sun Sep 18 14:42:13 2005 +0100 (2005-09-18)
parents 8e5fc5fe636c
children
line source
1 #ifndef __FMOPL_H_
2 #define __FMOPL_H_
4 /* --- select emulation chips --- */
5 #define BUILD_YM3812 (HAS_YM3812)
6 //#define BUILD_YM3526 (HAS_YM3526)
7 //#define BUILD_Y8950 (HAS_Y8950)
9 /* --- system optimize --- */
10 /* select bit size of output : 8 or 16 */
11 #define OPL_OUTPUT_BIT 16
13 /* compiler dependence */
14 #ifndef OSD_CPU_H
15 #define OSD_CPU_H
16 typedef unsigned char UINT8; /* unsigned 8bit */
17 typedef unsigned short UINT16; /* unsigned 16bit */
18 typedef unsigned int UINT32; /* unsigned 32bit */
19 typedef signed char INT8; /* signed 8bit */
20 typedef signed short INT16; /* signed 16bit */
21 typedef signed int INT32; /* signed 32bit */
22 #endif
24 #if (OPL_OUTPUT_BIT==16)
25 typedef INT16 OPLSAMPLE;
26 #endif
27 #if (OPL_OUTPUT_BIT==8)
28 typedef unsigned char OPLSAMPLE;
29 #endif
32 #if BUILD_Y8950
33 #include "ymdeltat.h"
34 #endif
36 typedef void (*OPL_TIMERHANDLER)(int channel,double interval_Sec);
37 typedef void (*OPL_IRQHANDLER)(int param,int irq);
38 typedef void (*OPL_UPDATEHANDLER)(int param,int min_interval_us);
39 typedef void (*OPL_PORTHANDLER_W)(int param,unsigned char data);
40 typedef unsigned char (*OPL_PORTHANDLER_R)(int param);
42 /* !!!!! here is private section , do not access there member direct !!!!! */
44 #define OPL_TYPE_WAVESEL 0x01 /* waveform select */
45 #define OPL_TYPE_ADPCM 0x02 /* DELTA-T ADPCM unit */
46 #define OPL_TYPE_KEYBOARD 0x04 /* keyboard interface */
47 #define OPL_TYPE_IO 0x08 /* I/O port */
49 /* Saving is necessary for member of the 'R' mark for suspend/resume */
50 /* ---------- OPL one of slot ---------- */
51 typedef struct fm_opl_slot {
52 INT32 TL; /* total level :TL << 8 */
53 INT32 TLL; /* adjusted now TL */
54 UINT8 KSR; /* key scale rate :(shift down bit) */
55 INT32 *AR; /* attack rate :&AR_TABLE[AR<<2] */
56 INT32 *DR; /* decay rate :&DR_TALBE[DR<<2] */
57 INT32 SL; /* sustin level :SL_TALBE[SL] */
58 INT32 *RR; /* release rate :&DR_TABLE[RR<<2] */
59 UINT8 ksl; /* keyscale level :(shift down bits) */
60 UINT8 ksr; /* key scale rate :kcode>>KSR */
61 UINT32 mul; /* multiple :ML_TABLE[ML] */
62 UINT32 Cnt; /* frequency count : */
63 UINT32 Incr; /* frequency step : */
64 /* envelope generator state */
65 UINT8 eg_typ; /* envelope type flag */
66 UINT8 evm; /* envelope phase */
67 INT32 evc; /* envelope counter */
68 INT32 eve; /* envelope counter end point */
69 INT32 evs; /* envelope counter step */
70 INT32 evsa; /* envelope step for AR :AR[ksr] */
71 INT32 evsd; /* envelope step for DR :DR[ksr] */
72 INT32 evsr; /* envelope step for RR :RR[ksr] */
73 /* LFO */
74 UINT8 ams; /* ams flag */
75 UINT8 vib; /* vibrate flag */
76 /* wave selector */
77 INT32 **wavetable;
78 }OPL_SLOT;
80 /* ---------- OPL one of channel ---------- */
81 typedef struct fm_opl_channel {
82 OPL_SLOT SLOT[2];
83 UINT8 CON; /* connection type */
84 UINT8 FB; /* feed back :(shift down bit) */
85 INT32 *connect1; /* slot1 output pointer */
86 INT32 *connect2; /* slot2 output pointer */
87 INT32 op1_out[2]; /* slot1 output for selfeedback */
88 /* phase generator state */
89 UINT32 block_fnum; /* block+fnum : */
90 UINT8 kcode; /* key code : KeyScaleCode */
91 UINT32 fc; /* Freq. Increment base */
92 UINT32 ksl_base; /* KeyScaleLevel Base step */
93 UINT8 keyon; /* key on/off flag */
94 } OPL_CH;
96 /* OPL state */
97 typedef struct fm_opl_f {
98 UINT8 type; /* chip type */
99 int clock; /* master clock (Hz) */
100 int rate; /* sampling rate (Hz) */
101 double freqbase; /* frequency base */
102 double TimerBase; /* Timer base time (==sampling time) */
103 UINT8 address; /* address register */
104 UINT8 status; /* status flag */
105 UINT8 statusmask; /* status mask */
106 UINT32 mode; /* Reg.08 : CSM , notesel,etc. */
107 /* Timer */
108 int T[2]; /* timer counter */
109 UINT8 st[2]; /* timer enable */
110 /* FM channel slots */
111 OPL_CH *P_CH; /* pointer of CH */
112 int max_ch; /* maximum channel */
113 /* Rythm sention */
114 UINT8 rythm; /* Rythm mode , key flag */
115 #if BUILD_Y8950
116 /* Delta-T ADPCM unit (Y8950) */
117 YM_DELTAT *deltat; /* DELTA-T ADPCM */
118 #endif
119 /* Keyboard / I/O interface unit (Y8950) */
120 UINT8 portDirection;
121 UINT8 portLatch;
122 OPL_PORTHANDLER_R porthandler_r;
123 OPL_PORTHANDLER_W porthandler_w;
124 int port_param;
125 OPL_PORTHANDLER_R keyboardhandler_r;
126 OPL_PORTHANDLER_W keyboardhandler_w;
127 int keyboard_param;
128 /* time tables */
129 INT32 AR_TABLE[75]; /* atttack rate tables */
130 INT32 DR_TABLE[75]; /* decay rate tables */
131 UINT32 FN_TABLE[1024]; /* fnumber -> increment counter */
132 /* LFO */
133 INT32 *ams_table;
134 INT32 *vib_table;
135 INT32 amsCnt;
136 INT32 amsIncr;
137 INT32 vibCnt;
138 INT32 vibIncr;
139 /* wave selector enable flag */
140 UINT8 wavesel;
141 /* external event callback handler */
142 OPL_TIMERHANDLER TimerHandler; /* TIMER handler */
143 int TimerParam; /* TIMER parameter */
144 OPL_IRQHANDLER IRQHandler; /* IRQ handler */
145 int IRQParam; /* IRQ parameter */
146 OPL_UPDATEHANDLER UpdateHandler; /* stream update handler */
147 int UpdateParam; /* stream update parameter */
148 } FM_OPL;
150 /* ---------- Generic interface section ---------- */
151 #define OPL_TYPE_YM3526 (0)
152 #define OPL_TYPE_YM3812 (OPL_TYPE_WAVESEL)
153 #define OPL_TYPE_Y8950 (OPL_TYPE_ADPCM|OPL_TYPE_KEYBOARD|OPL_TYPE_IO)
155 FM_OPL *OPLCreate(int type, int clock, int rate);
156 void OPLDestroy(FM_OPL *OPL);
157 void OPLSetTimerHandler(FM_OPL *OPL,OPL_TIMERHANDLER TimerHandler,int channelOffset);
158 void OPLSetIRQHandler(FM_OPL *OPL,OPL_IRQHANDLER IRQHandler,int param);
159 void OPLSetUpdateHandler(FM_OPL *OPL,OPL_UPDATEHANDLER UpdateHandler,int param);
160 /* Y8950 port handlers */
161 void OPLSetPortHandler(FM_OPL *OPL,OPL_PORTHANDLER_W PortHandler_w,OPL_PORTHANDLER_R PortHandler_r,int param);
162 void OPLSetKeyboardHandler(FM_OPL *OPL,OPL_PORTHANDLER_W KeyboardHandler_w,OPL_PORTHANDLER_R KeyboardHandler_r,int param);
164 void OPLResetChip(FM_OPL *OPL);
165 int OPLWrite(FM_OPL *OPL,int a,int v);
166 unsigned char OPLRead(FM_OPL *OPL,int a);
167 int OPLTimerOver(FM_OPL *OPL,int c);
169 /* YM3626/YM3812 local section */
170 void YM3812UpdateOne(FM_OPL *OPL, INT16 *buffer, int length);
172 void Y8950UpdateOne(FM_OPL *OPL, INT16 *buffer, int length);
174 #endif