1 /*
2 **
3 ** File: ym2151.h - header file for software implementation of YM2151
4 **                                            FM Operator Type-M(OPM)
5 **
6 ** (c) 1997-2002 Jarek Burczynski (s0246@poczta.onet.pl, bujar@mame.net)
7 ** Some of the optimizing ideas by Tatsuyuki Satoh
8 **
9 ** Version 2.150 final beta May, 11th 2002
10 **
11 **
12 ** I would like to thank following people for making this project possible:
13 **
14 ** Beauty Planets - for making a lot of real YM2151 samples and providing
15 ** additional informations about the chip. Also for the time spent making
16 ** the samples and the speed of replying to my endless requests.
17 **
18 ** Shigeharu Isoda - for general help, for taking time to scan his YM2151
19 ** Japanese Manual first of all, and answering MANY of my questions.
20 **
21 ** Nao - for giving me some info about YM2151 and pointing me to Shigeharu.
22 ** Also for creating fmemu (which I still use to test the emulator).
23 **
24 ** Aaron Giles and Chris Hardy - they made some samples of one of my favourite
25 ** arcade games so I could compare it to my emulator.
26 **
27 ** Bryan McPhail and Tim (powerjaw) - for making some samples.
28 **
29 ** Ishmair - for the datasheet and motivation.
30 */
31 
32 #ifndef _H_YM2151_
33 #define _H_YM2151_
34 
35 /* 16- and 8-bit samples (signed) are supported*/
36 #define SAMPLE_BITS 16
37 
38 #if (SAMPLE_BITS==16)
39 	typedef INT16 SAMP;
40 #endif
41 #if (SAMPLE_BITS==8)
42 	typedef signed char SAMP;
43 #endif
44 
45 /*
46 ** Initialize YM2151 emulator(s).
47 **
48 ** 'num' is the number of virtual YM2151's to allocate
49 ** 'clock' is the chip clock in Hz
50 ** 'rate' is sampling rate
51 */
52 //int YM2151Init(int num, int clock, int rate);
53 int YM2151Init(int num, int clock, int rate, void (*timer_cb)(INT32, double));
54 
55 int ym2151_timer_over(int num, int timer); // for fm timer
56 
57 /* shutdown the YM2151 emulators*/
58 void YM2151Shutdown(void);
59 void YM2151SetTimerInterleave(double d);
60 
61 /* reset all chip registers for YM2151 number 'num'*/
62 void YM2151ResetChip(int num);
63 
64 /*
65 ** Generate samples for one of the YM2151's
66 **
67 ** 'num' is the number of virtual YM2151
68 ** '**buffers' is table of pointers to the buffers: left and right
69 ** 'length' is the number of samples that should be generated
70 */
71 void YM2151UpdateOne(int num, INT16 **buffers, int length);
72 
73 /* write 'v' to register 'r' on YM2151 chip number 'n'*/
74 void YM2151WriteReg(int n, int r, int v);
75 
76 /* read status register on YM2151 chip number 'n'*/
77 int YM2151ReadStatus(int n);
78 
79 /* set interrupt handler on YM2151 chip number 'n'*/
80 void YM2151SetIrqHandler(int n, void (*handler)(int irq));
81 
82 /* set port write handler on YM2151 chip number 'n'*/
83 void YM2151SetPortWriteHandler(int n, write8_handler handler);
84 
85 /* FBAlpha-style savestate function for ym2151.c internal registers & operators */
86 void BurnYM2151Scan_int(INT32 nAction);
87 
88 #endif /*_H_YM2151_*/
89