OpenCores
URL https://opencores.org/ocsvn/sqmusic/sqmusic/trunk

Subversion Repositories sqmusic

[/] [sqmusic/] [trunk/] [mame/] [fm.h] - Blame information for rev 19

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 11 gryzor
/*
2
  File: fm.h -- header file for software emulation for FM sound generator
3
 
4
*/
5
 
6
#pragma once
7
 
8
#ifndef __FM_H__
9
#define __FM_H__
10
 
11
/* --- select emulation chips --- */
12
#define BUILD_YM2203  (1)       /* build YM2203(OPN)   emulator */
13
#define BUILD_YM2608  (1)       /* build YM2608(OPNA)  emulator */
14
#define BUILD_YM2610  (1)       /* build YM2610(OPNB)  emulator */
15
#define BUILD_YM2610B (1)       /* build YM2610B(OPNB?)emulator */
16
#define BUILD_YM2612  (1)       /* build YM2612(OPN2)  emulator */
17
#define BUILD_YM3438  (1)       /* build YM3438(OPN) emulator */
18
 
19
/* select bit size of output : 8 or 16 */
20
#define FM_SAMPLE_BITS 16
21
 
22
/* select timer system internal or external */
23
#define FM_INTERNAL_TIMER 0
24
 
25
/* --- speedup optimize --- */
26
/* busy flag enulation , The definition of FM_GET_TIME_NOW() is necessary. */
27
#define FM_BUSY_FLAG_SUPPORT 1
28
 
29
/* --- external SSG(YM2149/AY-3-8910)emulator interface port */
30
/* used by YM2203,YM2608,and YM2610 */
31
struct ssg_callbacks
32
{
33
        void (*set_clock)(void *param, int clock);
34
        void (*write)(void *param, int address, int data);
35
        int (*read)(void *param);
36
        void (*reset)(void *param);
37
};
38
 
39
/* --- external callback funstions for realtime update --- */
40
 
41
#if FM_BUSY_FLAG_SUPPORT
42
#define TIME_TYPE                   attotime
43
#define UNDEFINED_TIME              attotime::zero
44
#define FM_GET_TIME_NOW(machine)    (machine)->time()
45
#define ADD_TIMES(t1, t2)           ((t1) + (t2))
46
#define COMPARE_TIMES(t1, t2)       (((t1) == (t2)) ? 0 : ((t1) < (t2)) ? -1 : 1)
47
#define MULTIPLY_TIME_BY_INT(t,i)   ((t) * (i))
48
#endif
49
 
50
#if BUILD_YM2203
51
        /* in 2203intf.c */
52
        void ym2203_update_request(void *param);
53
        #define ym2203_update_req(chip) ym2203_update_request(chip)
54
#endif /* BUILD_YM2203 */
55
 
56
#if BUILD_YM2608
57
        /* in 2608intf.c */
58
        void ym2608_update_request(void *param);
59
        #define ym2608_update_req(chip) ym2608_update_request(chip);
60
#endif /* BUILD_YM2608 */
61
 
62
#if (BUILD_YM2610||BUILD_YM2610B)
63
        /* in 2610intf.c */
64
        void ym2610_update_request(void *param);
65
        #define ym2610_update_req(chip) ym2610_update_request(chip);
66
#endif /* (BUILD_YM2610||BUILD_YM2610B) */
67
 
68
#if (BUILD_YM2612||BUILD_YM3438)
69
        /* in 2612intf.c */
70
        void ym2612_update_request(void *param);
71
        #define ym2612_update_req(chip) ym2612_update_request(chip);
72
#endif /* (BUILD_YM2612||BUILD_YM3438) */
73
 
74
/* compiler dependence */
75
#if 0
76
#ifndef OSD_CPU_H
77
#define OSD_CPU_H
78
typedef unsigned char   UINT8;   /* unsigned  8bit */
79
typedef unsigned short  UINT16;  /* unsigned 16bit */
80
typedef unsigned int    UINT32;  /* unsigned 32bit */
81
typedef signed char     INT8;    /* signed  8bit   */
82
typedef signed short    INT16;   /* signed 16bit   */
83
typedef signed int      INT32;   /* signed 32bit   */
84
#endif /* OSD_CPU_H */
85
#endif
86
 
87
 
88
 
89
typedef stream_sample_t FMSAMPLE;
90
/*
91
#if (FM_SAMPLE_BITS==16)
92
typedef INT16 FMSAMPLE;
93
#endif
94
#if (FM_SAMPLE_BITS==8)
95
typedef unsigned char  FMSAMPLE;
96
#endif
97
*/
98
 
99
typedef void (*FM_TIMERHANDLER)(void *param,int c,int cnt,int clock);
100
typedef void (*FM_IRQHANDLER)(void *param,int irq);
101
/* FM_TIMERHANDLER : Stop or Start timer         */
102
/* int n          = chip number                  */
103
/* int c          = Channel 0=TimerA,1=TimerB    */
104
/* int count      = timer count (0=stop)         */
105
/* doube stepTime = step time of one count (sec.)*/
106
 
107
/* FM_IRQHHANDLER : IRQ level changing sense     */
108
/* int n       = chip number                     */
109
/* int irq     = IRQ level 0=OFF,1=ON            */
110
 
111
#if BUILD_YM2203
112
/* -------------------- YM2203(OPN) Interface -------------------- */
113
 
114
/*
115
** Initialize YM2203 emulator(s).
116
**
117
** 'num'           is the number of virtual YM2203's to allocate
118
** 'baseclock'
119
** 'rate'          is sampling rate
120
** 'TimerHandler'  timer callback handler when timer start and clear
121
** 'IRQHandler'    IRQ callback handler when changed IRQ level
122
** return      0 = success
123
*/
124
void * ym2203_init(void *param, device_t *device, int baseclock, int rate,
125
                                FM_TIMERHANDLER TimerHandler,FM_IRQHANDLER IRQHandler, const ssg_callbacks *ssg);
126
 
127
/*
128
** shutdown the YM2203 emulators
129
*/
130
void ym2203_shutdown(void *chip);
131
 
132
/*
133
** reset all chip registers for YM2203 number 'num'
134
*/
135
void ym2203_reset_chip(void *chip);
136
 
137
/*
138
** update one of chip
139
*/
140
void ym2203_update_one(void *chip, FMSAMPLE *buffer, int length);
141
 
142
/*
143
** Write
144
** return : InterruptLevel
145
*/
146
int ym2203_write(void *chip,int a,unsigned char v);
147
 
148
/*
149
** Read
150
** return : InterruptLevel
151
*/
152
unsigned char ym2203_read(void *chip,int a);
153
 
154
/*
155
**  Timer OverFlow
156
*/
157
int ym2203_timer_over(void *chip, int c);
158
 
159
/*
160
**  State Save
161
*/
162
void ym2203_postload(void *chip);
163
#endif /* BUILD_YM2203 */
164
 
165
#if BUILD_YM2608
166
/* -------------------- YM2608(OPNA) Interface -------------------- */
167
void * ym2608_init(void *param, device_t *device, int baseclock, int rate,
168
                                void *pcmroma,int pcmsizea,
169
                                FM_TIMERHANDLER TimerHandler,FM_IRQHANDLER IRQHandler, const ssg_callbacks *ssg);
170
void ym2608_shutdown(void *chip);
171
void ym2608_reset_chip(void *chip);
172
void ym2608_update_one(void *chip, FMSAMPLE **buffer, int length);
173
 
174
int ym2608_write(void *chip, int a,unsigned char v);
175
unsigned char ym2608_read(void *chip,int a);
176
int ym2608_timer_over(void *chip, int c );
177
void ym2608_postload(void *chip);
178
#endif /* BUILD_YM2608 */
179
 
180
#if (BUILD_YM2610||BUILD_YM2610B)
181
/* -------------------- YM2610(OPNB) Interface -------------------- */
182
void * ym2610_init(void *param, device_t *device, int baseclock, int rate,
183
                                void *pcmroma,int pcmasize,void *pcmromb,int pcmbsize,
184
                                FM_TIMERHANDLER TimerHandler,FM_IRQHANDLER IRQHandler, const ssg_callbacks *ssg);
185
void ym2610_shutdown(void *chip);
186
void ym2610_reset_chip(void *chip);
187
void ym2610_update_one(void *chip, FMSAMPLE **buffer, int length);
188
 
189
#if BUILD_YM2610B
190
void ym2610b_update_one(void *chip, FMSAMPLE **buffer, int length);
191
#endif /* BUILD_YM2610B */
192
 
193
int ym2610_write(void *chip, int a,unsigned char v);
194
unsigned char ym2610_read(void *chip,int a);
195
int ym2610_timer_over(void *chip, int c );
196
void ym2610_postload(void *chip);
197
#endif /* (BUILD_YM2610||BUILD_YM2610B) */
198
 
199
#if (BUILD_YM2612||BUILD_YM3438)
200
void * ym2612_init(void *param, device_t *device, int baseclock, int rate,
201
                                FM_TIMERHANDLER TimerHandler,FM_IRQHANDLER IRQHandler);
202
void ym2612_shutdown(void *chip);
203
void ym2612_reset_chip(void *chip);
204
void ym2612_update_one(void *chip, FMSAMPLE **buffer, int length);
205
 
206
int ym2612_write(void *chip, int a,unsigned char v);
207
unsigned char ym2612_read(void *chip,int a);
208
int ym2612_timer_over(void *chip, int c );
209
void ym2612_postload(void *chip);
210
#endif /* (BUILD_YM2612||BUILD_YM3438) */
211
 
212
 
213
#endif /* __FM_H__ */

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.