updated bords/mappers/stuff to 0.98.15, lots of them got broken, asmcore support...
[fceu.git] / mappers / emu2413.h
1 #ifndef _EMU2413_H_
2 #define _EMU2413_H_
3
4 #include "emutypes.h"
5
6 #ifdef EMU2413_DLL_EXPORTS
7   #define EMU2413_API __declspec(dllexport)
8 #elif defined(EMU2413_DLL_IMPORTS)
9   #define EMU2413_API __declspec(dllimport)
10 #else
11   #define EMU2413_API
12 #endif
13
14 #ifdef __cplusplus
15 extern "C" {
16 #endif
17
18 #define PI 3.14159265358979323846
19
20 enum {OPLL_VRC7_TONE=0} ;
21
22 /* voice data */
23 typedef struct {
24   e_uint32 TL,FB,EG,ML,AR,DR,SL,RR,KR,KL,AM,PM,WF ;
25 } OPLL_PATCH ;
26
27 /* slot */
28 typedef struct {
29
30   OPLL_PATCH patch;
31
32   e_int32 type ;          /* 0 : modulator 1 : carrier */
33
34   /* OUTPUT */
35   e_int32 feedback ;
36   e_int32 output[2] ;   /* Output value of slot */
37
38   /* for Phase Generator (PG) */
39   e_uint16 *sintbl ;    /* Wavetable */
40   e_uint32 phase ;      /* Phase */
41   e_uint32 dphase ;     /* Phase increment amount */
42   e_uint32 pgout ;      /* output */
43
44   /* for Envelope Generator (EG) */
45   e_int32 fnum ;          /* F-Number */
46   e_int32 block ;         /* Block */
47   e_int32 volume ;        /* Current volume */
48   e_int32 sustine ;       /* Sustine 1 = ON, 0 = OFF */
49   e_uint32 tll ;              /* Total Level + Key scale level*/
50   e_uint32 rks ;        /* Key scale offset (Rks) */
51   e_int32 eg_mode ;       /* Current state */
52   e_uint32 eg_phase ;   /* Phase */
53   e_uint32 eg_dphase ;  /* Phase increment amount */
54   e_uint32 egout ;      /* output */
55
56 } OPLL_SLOT ;
57
58 /* Mask */
59 #define OPLL_MASK_CH(x) (1<<(x))
60
61 /* opll */
62 typedef struct {
63
64   e_uint32 adr ;
65   e_int32 out ;
66
67 #ifndef EMU2413_COMPACTION
68   e_uint32 realstep ;
69   e_uint32 oplltime ;
70   e_uint32 opllstep ;
71   e_int32 prev, next ;
72 #endif
73
74   /* Register */
75   e_uint8 LowFreq[6];
76   e_uint8 HiFreq[6];
77   e_uint8 InstVol[6];
78
79   e_uint8 CustInst[8];
80
81   e_int32 slot_on_flag[6 * 2] ;
82
83   /* Pitch Modulator */
84   e_uint32 pm_phase ;
85   e_int32 lfo_pm ;
86
87   /* Amp Modulator */
88   e_int32 am_phase ;
89   e_int32 lfo_am ;
90
91   e_uint32 quality;
92
93   /* Channel Data */
94   e_int32 patch_number[6];
95   e_int32 key_status[6] ;
96
97   /* Slot */
98   OPLL_SLOT slot[6 * 2] ;
99
100   e_uint32 mask ;
101
102 } OPLL ;
103
104 /* Create Object */
105 EMU2413_API OPLL *OPLL_new(e_uint32 clk, e_uint32 rate) ;
106 EMU2413_API void OPLL_delete(OPLL *) ;
107
108 /* Setup */
109 EMU2413_API void OPLL_reset(OPLL *) ;
110 EMU2413_API void OPLL_set_rate(OPLL *opll, e_uint32 r) ;
111 EMU2413_API void OPLL_set_quality(OPLL *opll, e_uint32 q) ;
112
113 /* Port/Register access */
114 EMU2413_API void OPLL_writeIO(OPLL *, e_uint32 reg, e_uint32 val) ;
115 EMU2413_API void OPLL_writeReg(OPLL *, e_uint32 reg, e_uint32 val) ;
116
117 /* Synthsize */
118 EMU2413_API e_int16 OPLL_calc(OPLL *) ;
119
120 /* Misc */
121 EMU2413_API void OPLL_forceRefresh(OPLL *) ;
122
123 /* Channel Mask */
124 EMU2413_API e_uint32 OPLL_setMask(OPLL *, e_uint32 mask) ;
125 EMU2413_API e_uint32 OPLL_toggleMask(OPLL *, e_uint32 mask) ;
126
127
128 void moocow(OPLL* opll, e_int32 *buf, e_int32 len, int shift);
129
130 #ifdef __cplusplus
131 }
132 #endif
133
134 #endif