Fix compiling with ndk r11 >
[pcsx_rearmed.git] / plugins / dfsound / externals.h
CommitLineData
ef79bbde
P
1/***************************************************************************\r
2 externals.h - description\r
3 -------------------\r
4 begin : Wed May 15 2002\r
5 copyright : (C) 2002 by Pete Bernert\r
6 email : BlackDove@addcom.de\r
7 ***************************************************************************/\r
8/***************************************************************************\r
9 * *\r
10 * This program is free software; you can redistribute it and/or modify *\r
11 * it under the terms of the GNU General Public License as published by *\r
12 * the Free Software Foundation; either version 2 of the License, or *\r
13 * (at your option) any later version. See also the license.txt file for *\r
14 * additional informations. *\r
15 * *\r
16 ***************************************************************************/\r
17\r
18#include <stdint.h>\r
19\r
20/////////////////////////////////////////////////////////\r
21// generic defines\r
22/////////////////////////////////////////////////////////\r
23\r
f05d6ca2 24#ifdef __GNUC__\r
b72f17a1 25#define noinline __attribute__((noinline))\r
26#define unlikely(x) __builtin_expect((x), 0)\r
27#else\r
28#define noinline\r
29#define unlikely(x) x\r
30#endif\r
05c7cec7 31#if defined(__GNUC__) && !defined(_TMS320C6X)\r
32#define preload __builtin_prefetch\r
33#else\r
34#define preload(...)\r
35#endif\r
b72f17a1 36\r
ef79bbde
P
37#define PSE_LT_SPU 4\r
38#define PSE_SPU_ERR_SUCCESS 0\r
39#define PSE_SPU_ERR -60\r
40#define PSE_SPU_ERR_NOTCONFIGURED PSE_SPU_ERR - 1\r
41#define PSE_SPU_ERR_INIT PSE_SPU_ERR - 2\r
42#ifndef max\r
43#define max(a,b) (((a) > (b)) ? (a) : (b))\r
44#define min(a,b) (((a) < (b)) ? (a) : (b))\r
45#endif\r
46\r
47////////////////////////////////////////////////////////////////////////\r
48// spu defines\r
49////////////////////////////////////////////////////////////////////////\r
50\r
ef79bbde
P
51// num of channels\r
52#define MAXCHAN 24\r
53\r
1775933a 54// note: must be even due to the way reverb works now\r
650adfd2 55#define NSSIZE ((44100 / 50 + 16) & ~1)\r
ef79bbde
P
56\r
57///////////////////////////////////////////////////////////\r
58// struct defines\r
59///////////////////////////////////////////////////////////\r
60\r
9ad8abfa 61enum ADSR_State {\r
62 ADSR_ATTACK = 0,\r
63 ADSR_DECAY = 1,\r
64 ADSR_SUSTAIN = 2,\r
65 ADSR_RELEASE = 3,\r
66};\r
67\r
ef79bbde 68// ADSR INFOS PER CHANNEL\r
ef79bbde
P
69typedef struct\r
70{\r
9ad8abfa 71 unsigned char State:2; // ADSR_State\r
6d866bb7 72 unsigned char AttackModeExp:1;\r
73 unsigned char SustainModeExp:1;\r
74 unsigned char SustainIncrease:1;\r
75 unsigned char ReleaseModeExp:1;\r
76 unsigned char AttackRate;\r
77 unsigned char DecayRate;\r
78 unsigned char SustainLevel;\r
79 unsigned char SustainRate;\r
80 unsigned char ReleaseRate;\r
ef79bbde 81 int EnvelopeVol;\r
ef79bbde
P
82} ADSRInfoEx;\r
83 \r
84///////////////////////////////////////////////////////////\r
85\r
86// Tmp Flags\r
87\r
88// used for debug channel muting\r
89#define FLAG_MUTE 1\r
90\r
91// used for simple interpolation\r
92#define FLAG_IPOL0 2\r
93#define FLAG_IPOL1 4\r
94\r
95///////////////////////////////////////////////////////////\r
96\r
97// MAIN CHANNEL STRUCT\r
98typedef struct\r
99{\r
ef79bbde
P
100 int iSBPos; // mixing stuff\r
101 int spos;\r
102 int sinc;\r
650adfd2 103 int sinc_inv;\r
ef79bbde 104\r
ef79bbde
P
105 unsigned char * pCurr; // current pos in sound mem\r
106 unsigned char * pLoop; // loop ptr in sound mem\r
107\r
6d866bb7 108 unsigned int bReverb:1; // can we do reverb on this channel? must have ctrl register bit, to get active\r
6d866bb7 109 unsigned int bRVBActive:1; // reverb active flag\r
110 unsigned int bNoise:1; // noise active flag\r
111 unsigned int bFMod:2; // freq mod (0=off, 1=sound channel, 2=freq channel)\r
e4f075af 112 unsigned int prevflags:3; // flags from previous block\r
6d866bb7 113\r
ef79bbde 114 int iLeftVolume; // left volume\r
ef79bbde 115 int iRightVolume; // right volume\r
6d866bb7 116 ADSRInfoEx ADSRX;\r
117 int iRawPitch; // raw pitch (0...3fff)\r
ef79bbde
P
118} SPUCHAN;\r
119\r
120///////////////////////////////////////////////////////////\r
121\r
122typedef struct\r
123{\r
124 int StartAddr; // reverb area start addr in samples\r
125 int CurrAddr; // reverb area curr addr in samples\r
126\r
127 int VolLeft;\r
128 int VolRight;\r
ef79bbde
P
129\r
130 int FB_SRC_A; // (offset)\r
131 int FB_SRC_B; // (offset)\r
132 int IIR_ALPHA; // (coef.)\r
133 int ACC_COEF_A; // (coef.)\r
134 int ACC_COEF_B; // (coef.)\r
135 int ACC_COEF_C; // (coef.)\r
136 int ACC_COEF_D; // (coef.)\r
137 int IIR_COEF; // (coef.)\r
138 int FB_ALPHA; // (coef.)\r
139 int FB_X; // (coef.)\r
140 int IIR_DEST_A0; // (offset)\r
141 int IIR_DEST_A1; // (offset)\r
142 int ACC_SRC_A0; // (offset)\r
143 int ACC_SRC_A1; // (offset)\r
144 int ACC_SRC_B0; // (offset)\r
145 int ACC_SRC_B1; // (offset)\r
146 int IIR_SRC_A0; // (offset)\r
147 int IIR_SRC_A1; // (offset)\r
148 int IIR_DEST_B0; // (offset)\r
149 int IIR_DEST_B1; // (offset)\r
150 int ACC_SRC_C0; // (offset)\r
151 int ACC_SRC_C1; // (offset)\r
152 int ACC_SRC_D0; // (offset)\r
153 int ACC_SRC_D1; // (offset)\r
154 int IIR_SRC_B1; // (offset)\r
155 int IIR_SRC_B0; // (offset)\r
156 int MIX_DEST_A0; // (offset)\r
157 int MIX_DEST_A1; // (offset)\r
158 int MIX_DEST_B0; // (offset)\r
159 int MIX_DEST_B1; // (offset)\r
160 int IN_COEF_L; // (coef.)\r
161 int IN_COEF_R; // (coef.)\r
1775933a 162\r
163 int dirty; // registers changed\r
164\r
1775933a 165 // MIX_DEST_xx - FB_SRC_x\r
7b2c4897 166 int FB_SRC_A0, FB_SRC_A1, FB_SRC_B0, FB_SRC_B1;\r
ef79bbde
P
167} REVERBInfo;\r
168\r
ef79bbde
P
169///////////////////////////////////////////////////////////\r
170\r
ef79bbde
P
171// psx buffers / addresses\r
172\r
de4a0279 173#define SB_SIZE (32 + 4)\r
174\r
3154bfab 175typedef struct\r
176{\r
177 unsigned short spuCtrl;\r
178 unsigned short spuStat;\r
ef79bbde 179\r
3154bfab 180 unsigned int spuAddr;\r
5514a050 181 union {\r
182 unsigned char *spuMemC;\r
183 unsigned short *spuMem;\r
184 };\r
3154bfab 185 unsigned char * pSpuIrq;\r
77d6fd63 186\r
3154bfab 187 unsigned int cycles_played;\r
188 int decode_pos;\r
189 int decode_dirty_ch;\r
190 unsigned int bSpuInit:1;\r
191 unsigned int bSPUIsOpen:1;\r
0c1151fe 192 unsigned int bMemDirty:1; // had external write to SPU RAM\r
ef79bbde 193\r
3154bfab 194 unsigned int dwNoiseVal; // global noise generator\r
195 unsigned int dwNoiseCount;\r
196 unsigned int dwNewChannel; // flags for faster testing, if new channel starts\r
197 unsigned int dwChannelOn; // not silent channels\r
198 unsigned int dwChannelDead; // silent+not useful channels\r
ef79bbde 199\r
3154bfab 200 unsigned char * pSpuBuffer;\r
201 short * pS;\r
ef79bbde 202\r
3154bfab 203 void (CALLBACK *irqCallback)(void); // func of main emu, called on spu irq\r
204 void (CALLBACK *cddavCallback)(unsigned short,unsigned short);\r
205 void (CALLBACK *scheduleCallback)(unsigned int);\r
ef79bbde 206\r
3154bfab 207 xa_decode_t * xapGlobal;\r
208 unsigned int * XAFeed;\r
209 unsigned int * XAPlay;\r
210 unsigned int * XAStart;\r
211 unsigned int * XAEnd;\r
ef79bbde 212\r
3154bfab 213 unsigned int * CDDAFeed;\r
214 unsigned int * CDDAPlay;\r
215 unsigned int * CDDAStart;\r
216 unsigned int * CDDAEnd;\r
ef79bbde 217\r
3154bfab 218 unsigned int XARepeat;\r
219 unsigned int XALastVal;\r
650adfd2 220\r
3154bfab 221 int iLeftXAVol;\r
222 int iRightXAVol;\r
650adfd2 223\r
5514a050 224 SPUCHAN * s_chan;\r
05c7cec7 225 REVERBInfo * rvb;\r
5514a050 226\r
05c7cec7 227 // buffers\r
228 int * SB;\r
3bd31caf 229 int * SSumLR;\r
230\r
231 int pad[29];\r
3154bfab 232 unsigned short regArea[0x400];\r
3154bfab 233} SPUInfo;\r
ef79bbde
P
234\r
235///////////////////////////////////////////////////////////\r
3154bfab 236// SPU.C globals\r
ef79bbde
P
237///////////////////////////////////////////////////////////\r
238\r
3154bfab 239#ifndef _IN_SPU\r
ef79bbde 240\r
3154bfab 241extern SPUInfo spu;\r
ef79bbde 242\r
63a4f6b6 243void do_samples(unsigned int cycles_to, int do_sync);\r
3154bfab 244void schedule_next_irq(void);\r
ef79bbde 245\r
3154bfab 246#define regAreaGet(ch,offset) \\r
247 spu.regArea[((ch<<4)|(offset))>>1]\r
ef79bbde 248\r
63a4f6b6 249#define do_samples_if_needed(c, sync) \\r
3154bfab 250 do { \\r
63a4f6b6 251 if (sync || (int)((c) - spu.cycles_played) >= 16 * 768) \\r
252 do_samples(c, sync); \\r
3154bfab 253 } while (0)\r
ef79bbde
P
254\r
255#endif\r
256\r