1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
/**
* @ingroup io68_ym_devel
* @file io68/ymemul.h
* @author Benjamin Gerard
* @date 1998/06/24
* @brief YM-2149 emulator header.
*
*/
/* Copyright (C) 1998-2011 Benjamin Gerard */
/* Need these defines in ymemul.c and ym_puls.c */
/** @defgroup io68_ym_devel YM-2149 emulator
* @ingroup io68_devel
*
* The YM-2149 (Atari-ST soundchip) emulator.
*
* @{
*/
/** @name YM-2149 registers.
* @{
*/
/** @} */
/** @name YM-2149 internal register access.
* @{
*/
/** YM write access structure. */
;
/** YM write access type. */
typedef struct ym_waccess_s ym_waccess_t;
/** Sorted list of YM write access. */
typedef struct
ym_waccess_list_t;
/** @} */
/** YM-2149 internal register mapping. */
;
/** Access YM-2149 internal register by name or by index. */
typedef union ym_reg_u ym_reg_t;
/** Toggle table/calculated envelop emulation. */
/** YM-2149 emulation engines. */
;
/** YM-2149 volume models. */
;
/** Sampling rate. */
;
/** YM master clock frequency. */
;
/* struct ym_s; */
typedef struct ym_s ym_t;
;
/** YM-2149 setup structure.
*
* This structure is passed to the ym_init() and ym_setup()
* functions. The caller have to fill it with desired values before
* calling these functions. Each field can be set to a nul value in
* order to use the default value. The function will set the actual
* values before returning.
*
*/
typedef struct
ym_parms_t;
/** @name Initialization functions
* @{
*/
/** Create an Yamaha-2149 emulator instance.
*
* @param ym
* @param params
*
* @return error-code
* @retval 0 Success
* @retval -1 Failure
*
* @see ym_destroy()
*/
int ;
/** Destroy an Yamaha-2149 emulator instance.
*
* @param ym ym emulator instance to destroy
*/
void ;
/** Perform an Yamaha-2149 hardware reset.
*
* The ym_reset() reset function perform a YM-2149 reset. It
* performs following operations :
* - all register zeroed
* - mixer is set to 077 (no sound and no noise)
* - envelop shape is set to 0xA (/\)
* - control register is set to 0
* - internal periods counter are zeroed
*
* @param ym YM-2149 emulator instance.
* @param ymcycle ym cycle the reset has occured.
*
* @return error-code (always success)
* @retval 0 Success
* @retval -1 Failure
*/
int ;
/** Yamaha-2149 first one first initialization.
*
* The ym_init() function must be call before any other ym_
* function. If params is non nul then all non nul fields will be
* used as the new default value for this field at ym_setup()
* function call.
*
* @param params Default parameters for ym_setup().
*
* @return error-code (always success)
* @retval 0 Success
*
* @see ym_reset()
*/
int ;
/** Shutdown the ym-2149 library.
*
* The ym_shutdown() function should be call after all created ym
* emulator instances have been clean up.
*
*/
void ;
/** @} */
/** @name Emulation functions
* @{
*/
/** Execute Yamaha-2149 emulation.
*
* The ym_run() function execute Yamaha-2149 emulation for a given
* number of cycle. The output buffer
*
* @warning The requested output buffer size may seem larger than
* neccessary but it is not. Internally the emulator may need some
* extra place (for oversampling...). Always call ym_buffersize()
* to allocate this buffer large enough.
*
* @param ym YM-2149 emulator instance.
* @param output Output sample buffer.
* @param ymcycles Number of cycle to mix.
*
* @return Number of sample in output mix-buffer
* @retval -1 Failure
*
* @see ym_buffersize()
*/
int ;
/** Get required output buffer size.
*
* The ym_buffersize() function returns the minimum size in
* PCM(32bit) of the output buffer for generating ymcycles
* cycles. It should be use to ensure the buffer is large enough
* before calling ym_run() function.
*
* @param ym YM-2149 emulator instance.
* @param ymcycles Number of ym-cycles to generate
*
* @return Minimum size in PCM (32bit) of output buffer to generate
* ymcycles samples.
*
*/
uint68_t ;
/** Change YM cycle counter base.
*
* The ym_adjest() function allow to corrige the internal cycle
* counter to prevent overflow. Because the number of cycle could
* grow very quickly, it is neccessary to get it down from time to
* time.
*
* @param ym YM-2149 emulator instance.
* @param ymcycles Number of cpu cycle to substract to current the
* cycle counter.
*
*/
void ;
/** @} */
/** @name YM-2149 register access functions
* @{
*/
/** Write in YM-2149 register.
*
* The ym_writereg() function performs a write access to an YM-2149
* internal register. The YM-2149 emulator does not really write
* register but store changes in separate list depending of the
* register nature and dependencies. There are 3 lists of update
* (sound, noise and envelop). This method allow to perform a very
* efficient cycle precise emulation. For this reason the YM-2149
* registers should be read by ym_readreg() function.
*
* @param ym YM-2149 emulator instance.
* @param val Value to write.
* @param ymcycle YM cycle this access has occurred.
*
* @see ym_readreg();
*/
void ;
static inline
/** Read a YM-2119 register.
*
* The ym_readreg() function must be call to read an YM-2149
* register. For the reasons explained in YM_writereg(), register
* must not be read directly.
*
* @param ym YM-2149 emulator instance.
* @param ymcycle CPU cycle number this access has occurred.
*
* @return Register value at given cycle
*
* @see ym_writereg();
*/
int
/** @} */
/** @name YM-2149 emulator configuration functions.
* @{
*/
/** Get/Set active channels status.
*
* The ym_active_channels() function allows to activate/desactivate
* separarely channels (voices) of the YM-2149.
*
* For both on and off parameters:
* -bit#0: canal A (0:no change 1:change to on or off)
* -bit#1: canal B (0:no change 1:change to on or off)
* -bit#2: canal C (0:no change 1:change to on or off)
*
* How it works:
*
* The ym_active_channels() function performs off parameter before on
* parameter. The formula looks like ``result=(current&^off)|on''.
*
* How to use:
*
* -Get current value : ym_active_channels(ym,0,0);
* -Mute all channels : ym_active_channels(ym,7,0);
* -Active all channels : ym_active_channels(ym,0,7);
* -Active some channel channels : ym_active_channels(ym,0,x);
*
* @param ym YM-2149 emulator instance
* @param off Mute the channels for bit set to 1
* @param on Active the channels for bit set to 1
*
* @return new active-voices status
* @retval -1 Failure
* @retval 0 All voice muted
* @retval 1 Only channel A
* @retval 7 all channels active
*
*/
int ;
/** Set/Get configuration.
*/
int ;
/** Get/Set sampling rate.
*
* @param ym YM-2149 emulator instance
* @param hz frequency in hz or @ref ym_hz_e "special values".
*
* @return Actual sampling rate (may differs from requested).
* @retval -1 on error
*/
int ;
/** Set or get Yamaha-2149 emulator engine.
*
* @param engine @ref ym_engine_e "special values"
* @return @ref ym_engine_e "engine value".
* @retval -1 on error
*/
int ;
int ;
int ;
/** @} */
/**
* @}
*/
/* #ifndef _IO68_YM_EMUL_H_ */