LMMS
Loading...
Searching...
No Matches
fmopl.h
Go to the documentation of this file.
1#ifndef __FMOPL_H_
2#define __FMOPL_H_
3
4/* --- select emulation chips --- */
5#define BUILD_YM3812 (HAS_YM3812)
6//#define BUILD_YM3526 (HAS_YM3526)
7//#define BUILD_Y8950 (HAS_Y8950)
8
9/* --- system optimize --- */
10/* select bit size of output : 8 or 16 */
11#define OPL_OUTPUT_BIT 16
12
13/* compiler dependence */
14#ifndef OSD_CPU_H
15#define OSD_CPU_H
16typedef unsigned char UINT8; /* unsigned 8bit */
17typedef unsigned short UINT16; /* unsigned 16bit */
18typedef unsigned int UINT32; /* unsigned 32bit */
19typedef signed char INT8; /* signed 8bit */
20typedef signed short INT16; /* signed 16bit */
21typedef signed int INT32; /* signed 32bit */
22#endif
23
24#if (OPL_OUTPUT_BIT==16)
26#endif
27#if (OPL_OUTPUT_BIT==8)
28typedef unsigned char OPLSAMPLE;
29#endif
30
31
32#if BUILD_Y8950
33#include "ymdeltat.h"
34#endif
35
36typedef void (*OPL_TIMERHANDLER)(int channel,double interval_Sec);
37typedef void (*OPL_IRQHANDLER)(int param,int irq);
38typedef void (*OPL_UPDATEHANDLER)(int param,int min_interval_us);
39typedef void (*OPL_PORTHANDLER_W)(int param,unsigned char data);
40typedef unsigned char (*OPL_PORTHANDLER_R)(int param);
41
42/* !!!!! here is private section , do not access there member direct !!!!! */
43
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 */
48
49/* Saving is necessary for member of the 'R' mark for suspend/resume */
50/* ---------- OPL one of slot ---------- */
51typedef 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 */
79
80/* ---------- OPL one of channel ---------- */
81typedef struct fm_opl_channel {
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 */
95
96/* OPL state */
97typedef 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) */
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 */
139 /* wave selector enable flag */
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 */
149
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)
154
155FM_OPL *OPLCreate(int type, int clock, int rate);
156void OPLDestroy(FM_OPL *OPL);
157void OPLSetTimerHandler(FM_OPL *OPL,OPL_TIMERHANDLER TimerHandler,int channelOffset);
158void OPLSetIRQHandler(FM_OPL *OPL,OPL_IRQHANDLER IRQHandler,int param);
159void OPLSetUpdateHandler(FM_OPL *OPL,OPL_UPDATEHANDLER UpdateHandler,int param);
160/* Y8950 port handlers */
161void OPLSetPortHandler(FM_OPL *OPL,OPL_PORTHANDLER_W PortHandler_w,OPL_PORTHANDLER_R PortHandler_r,int param);
162void OPLSetKeyboardHandler(FM_OPL *OPL,OPL_PORTHANDLER_W KeyboardHandler_w,OPL_PORTHANDLER_R KeyboardHandler_r,int param);
163
164void OPLResetChip(FM_OPL *OPL);
165int OPLWrite(FM_OPL *OPL,int a,int v);
166unsigned char OPLRead(FM_OPL *OPL,int a);
167int OPLTimerOver(FM_OPL *OPL,int c);
168
169/* YM3626/YM3812 local section */
170void YM3812UpdateOne(FM_OPL *OPL, INT16 *buffer, int length);
171
172void Y8950UpdateOne(FM_OPL *OPL, INT16 *buffer, int length);
173
174#endif
uint8_t a
Definition Spc_Cpu.h:141
CAdPlugDatabase::CRecord::RecordType type
Definition adplugdb.cpp:93
unsigned v[N_MAX]
Definition inflate.c:1584
void OPLSetTimerHandler(FM_OPL *OPL, OPL_TIMERHANDLER TimerHandler, int channelOffset)
Definition fmopl.c:1285
struct fm_opl_slot OPL_SLOT
signed int INT32
Definition fmopl.h:21
INT16 OPLSAMPLE
Definition fmopl.h:25
void(* OPL_PORTHANDLER_W)(int param, unsigned char data)
Definition fmopl.h:39
void OPLSetPortHandler(FM_OPL *OPL, OPL_PORTHANDLER_W PortHandler_w, OPL_PORTHANDLER_R PortHandler_r, int param)
void Y8950UpdateOne(FM_OPL *OPL, INT16 *buffer, int length)
void OPLSetIRQHandler(FM_OPL *OPL, OPL_IRQHANDLER IRQHandler, int param)
Definition fmopl.c:1290
struct fm_opl_channel OPL_CH
void OPLSetKeyboardHandler(FM_OPL *OPL, OPL_PORTHANDLER_W KeyboardHandler_w, OPL_PORTHANDLER_R KeyboardHandler_r, int param)
void YM3812UpdateOne(FM_OPL *OPL, INT16 *buffer, int length)
Definition fmopl.c:1048
void(* OPL_UPDATEHANDLER)(int param, int min_interval_us)
Definition fmopl.h:38
unsigned char(* OPL_PORTHANDLER_R)(int param)
Definition fmopl.h:40
signed char INT8
Definition fmopl.h:19
unsigned char OPLRead(FM_OPL *OPL, int a)
Definition fmopl.c:1338
void(* OPL_IRQHANDLER)(int param, int irq)
Definition fmopl.h:37
void OPLResetChip(FM_OPL *OPL)
Definition fmopl.c:1170
int OPLWrite(FM_OPL *OPL, int a, int v)
Definition fmopl.c:1316
struct fm_opl_f FM_OPL
FM_OPL * OPLCreate(int type, int clock, int rate)
Definition fmopl.c:1215
unsigned int UINT32
Definition fmopl.h:18
int OPLTimerOver(FM_OPL *OPL, int c)
Definition fmopl.c:1375
void OPLDestroy(FM_OPL *OPL)
Definition fmopl.c:1270
void OPLSetUpdateHandler(FM_OPL *OPL, OPL_UPDATEHANDLER UpdateHandler, int param)
Definition fmopl.c:1295
void(* OPL_TIMERHANDLER)(int channel, double interval_Sec)
Definition fmopl.h:36
long INT32
Definition jmorecfg.h:161
short INT16
Definition jmorecfg.h:155
unsigned int UINT16
Definition jmorecfg.h:149
short UINT8
Definition jmorecfg.h:140
JSAMPIMAGE data
Definition jpeglib.h:945
png_uint_32 length
Definition png.c:2247
Definition fmopl.h:81
UINT8 keyon
Definition fmopl.h:93
INT32 * connect1
Definition fmopl.h:85
UINT32 ksl_base
Definition fmopl.h:92
INT32 * connect2
Definition fmopl.h:86
UINT8 kcode
Definition fmopl.h:90
UINT8 FB
Definition fmopl.h:84
UINT32 block_fnum
Definition fmopl.h:89
UINT32 fc
Definition fmopl.h:91
UINT8 CON
Definition fmopl.h:83
OPL_SLOT SLOT[2]
Definition fmopl.h:82
INT32 op1_out[2]
Definition fmopl.h:87
Definition fmopl.h:97
INT32 AR_TABLE[75]
Definition fmopl.h:129
int clock
Definition fmopl.h:99
int port_param
Definition fmopl.h:124
OPL_PORTHANDLER_W porthandler_w
Definition fmopl.h:123
int T[2]
Definition fmopl.h:108
UINT8 rythm
Definition fmopl.h:114
UINT32 mode
Definition fmopl.h:106
INT32 amsIncr
Definition fmopl.h:136
double freqbase
Definition fmopl.h:101
UINT8 portLatch
Definition fmopl.h:121
OPL_IRQHANDLER IRQHandler
Definition fmopl.h:144
int IRQParam
Definition fmopl.h:145
UINT8 statusmask
Definition fmopl.h:105
UINT8 wavesel
Definition fmopl.h:140
INT32 vibCnt
Definition fmopl.h:137
OPL_UPDATEHANDLER UpdateHandler
Definition fmopl.h:146
OPL_PORTHANDLER_R keyboardhandler_r
Definition fmopl.h:125
INT32 vibIncr
Definition fmopl.h:138
int TimerParam
Definition fmopl.h:143
INT32 * vib_table
Definition fmopl.h:134
UINT8 type
Definition fmopl.h:98
INT32 * ams_table
Definition fmopl.h:133
UINT32 FN_TABLE[1024]
Definition fmopl.h:131
UINT8 portDirection
Definition fmopl.h:120
int rate
Definition fmopl.h:100
UINT8 address
Definition fmopl.h:103
OPL_PORTHANDLER_R porthandler_r
Definition fmopl.h:122
double TimerBase
Definition fmopl.h:102
INT32 DR_TABLE[75]
Definition fmopl.h:130
int keyboard_param
Definition fmopl.h:127
OPL_CH * P_CH
Definition fmopl.h:111
int UpdateParam
Definition fmopl.h:147
UINT8 status
Definition fmopl.h:104
UINT8 st[2]
Definition fmopl.h:109
OPL_TIMERHANDLER TimerHandler
Definition fmopl.h:142
INT32 amsCnt
Definition fmopl.h:135
int max_ch
Definition fmopl.h:112
OPL_PORTHANDLER_W keyboardhandler_w
Definition fmopl.h:126
Definition fmopl.h:51
UINT8 ksr
Definition fmopl.h:60
UINT8 eg_typ
Definition fmopl.h:65
INT32 * DR
Definition fmopl.h:56
INT32 eve
Definition fmopl.h:68
INT32 SL
Definition fmopl.h:57
UINT32 Incr
Definition fmopl.h:63
INT32 * RR
Definition fmopl.h:58
INT32 evsd
Definition fmopl.h:71
UINT8 KSR
Definition fmopl.h:54
INT32 evc
Definition fmopl.h:67
INT32 evsr
Definition fmopl.h:72
UINT8 ams
Definition fmopl.h:74
UINT32 Cnt
Definition fmopl.h:62
UINT8 ksl
Definition fmopl.h:59
INT32 TL
Definition fmopl.h:52
INT32 evs
Definition fmopl.h:69
INT32 * AR
Definition fmopl.h:55
UINT8 vib
Definition fmopl.h:75
INT32 evsa
Definition fmopl.h:70
UINT8 evm
Definition fmopl.h:66
INT32 ** wavetable
Definition fmopl.h:77
INT32 TLL
Definition fmopl.h:53
UINT32 mul
Definition fmopl.h:61
return c
Definition crypt.c:175
#define void
Definition unzip.h:396