Merge git://github.com/notaz/pcsx_rearmed
[pcsx_rearmed.git] / plugins / dfsound / externals.h
... / ...
CommitLineData
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
24#ifdef __GNUC__\r
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
31\r
32#define PSE_LT_SPU 4\r
33#define PSE_SPU_ERR_SUCCESS 0\r
34#define PSE_SPU_ERR -60\r
35#define PSE_SPU_ERR_NOTCONFIGURED PSE_SPU_ERR - 1\r
36#define PSE_SPU_ERR_INIT PSE_SPU_ERR - 2\r
37#ifndef max\r
38#define max(a,b) (((a) > (b)) ? (a) : (b))\r
39#define min(a,b) (((a) < (b)) ? (a) : (b))\r
40#endif\r
41\r
42////////////////////////////////////////////////////////////////////////\r
43// spu defines\r
44////////////////////////////////////////////////////////////////////////\r
45\r
46// num of channels\r
47#define MAXCHAN 24\r
48\r
49// ~ FRAG_MSECS ms of data\r
50// note: must be even due to the way reverb works now\r
51#define FRAG_MSECS 2\r
52#define NSSIZE ((44100 * FRAG_MSECS / 1000 + 1) & ~1)\r
53\r
54///////////////////////////////////////////////////////////\r
55// struct defines\r
56///////////////////////////////////////////////////////////\r
57\r
58// ADSR INFOS PER CHANNEL\r
59typedef struct\r
60{\r
61 unsigned char State:2;\r
62 unsigned char AttackModeExp:1;\r
63 unsigned char SustainModeExp:1;\r
64 unsigned char SustainIncrease:1;\r
65 unsigned char ReleaseModeExp:1;\r
66 unsigned char AttackRate;\r
67 unsigned char DecayRate;\r
68 unsigned char SustainLevel;\r
69 unsigned char SustainRate;\r
70 unsigned char ReleaseRate;\r
71 int EnvelopeVol;\r
72} ADSRInfoEx;\r
73 \r
74///////////////////////////////////////////////////////////\r
75\r
76// Tmp Flags\r
77\r
78// used for debug channel muting\r
79#define FLAG_MUTE 1\r
80\r
81// used for simple interpolation\r
82#define FLAG_IPOL0 2\r
83#define FLAG_IPOL1 4\r
84\r
85///////////////////////////////////////////////////////////\r
86\r
87// MAIN CHANNEL STRUCT\r
88typedef struct\r
89{\r
90 int iSBPos; // mixing stuff\r
91 int spos;\r
92 int sinc;\r
93\r
94 unsigned char * pCurr; // current pos in sound mem\r
95 unsigned char * pLoop; // loop ptr in sound mem\r
96\r
97 unsigned int bStop:1; // is channel stopped (sample _can_ still be playing, ADSR Release phase)\r
98 unsigned int bReverb:1; // can we do reverb on this channel? must have ctrl register bit, to get active\r
99 unsigned int bRVBActive:1; // reverb active flag\r
100 unsigned int bNoise:1; // noise active flag\r
101 unsigned int bFMod:2; // freq mod (0=off, 1=sound channel, 2=freq channel)\r
102 unsigned int prevflags:3; // flags from previous block\r
103\r
104 int iLeftVolume; // left volume\r
105 int iRightVolume; // right volume\r
106 ADSRInfoEx ADSRX;\r
107 int iRawPitch; // raw pitch (0...3fff)\r
108\r
109 int SB[32+4];\r
110} SPUCHAN;\r
111\r
112///////////////////////////////////////////////////////////\r
113\r
114typedef struct\r
115{\r
116 int StartAddr; // reverb area start addr in samples\r
117 int CurrAddr; // reverb area curr addr in samples\r
118\r
119 int VolLeft;\r
120 int VolRight;\r
121 int iRVBLeft;\r
122 int iRVBRight;\r
123\r
124 int FB_SRC_A; // (offset)\r
125 int FB_SRC_B; // (offset)\r
126 int IIR_ALPHA; // (coef.)\r
127 int ACC_COEF_A; // (coef.)\r
128 int ACC_COEF_B; // (coef.)\r
129 int ACC_COEF_C; // (coef.)\r
130 int ACC_COEF_D; // (coef.)\r
131 int IIR_COEF; // (coef.)\r
132 int FB_ALPHA; // (coef.)\r
133 int FB_X; // (coef.)\r
134 int IIR_DEST_A0; // (offset)\r
135 int IIR_DEST_A1; // (offset)\r
136 int ACC_SRC_A0; // (offset)\r
137 int ACC_SRC_A1; // (offset)\r
138 int ACC_SRC_B0; // (offset)\r
139 int ACC_SRC_B1; // (offset)\r
140 int IIR_SRC_A0; // (offset)\r
141 int IIR_SRC_A1; // (offset)\r
142 int IIR_DEST_B0; // (offset)\r
143 int IIR_DEST_B1; // (offset)\r
144 int ACC_SRC_C0; // (offset)\r
145 int ACC_SRC_C1; // (offset)\r
146 int ACC_SRC_D0; // (offset)\r
147 int ACC_SRC_D1; // (offset)\r
148 int IIR_SRC_B1; // (offset)\r
149 int IIR_SRC_B0; // (offset)\r
150 int MIX_DEST_A0; // (offset)\r
151 int MIX_DEST_A1; // (offset)\r
152 int MIX_DEST_B0; // (offset)\r
153 int MIX_DEST_B1; // (offset)\r
154 int IN_COEF_L; // (coef.)\r
155 int IN_COEF_R; // (coef.)\r
156\r
157 int dirty; // registers changed\r
158\r
159 // normalized offsets\r
160 int nIIR_DEST_A0, nIIR_DEST_A1, nIIR_DEST_B0, nIIR_DEST_B1,\r
161 nACC_SRC_A0, nACC_SRC_A1, nACC_SRC_B0, nACC_SRC_B1, \r
162 nIIR_SRC_A0, nIIR_SRC_A1, nIIR_SRC_B0, nIIR_SRC_B1,\r
163 nACC_SRC_C0, nACC_SRC_C1, nACC_SRC_D0, nACC_SRC_D1,\r
164 nMIX_DEST_A0, nMIX_DEST_A1, nMIX_DEST_B0, nMIX_DEST_B1;\r
165 // MIX_DEST_xx - FB_SRC_x\r
166 int nFB_SRC_A0, nFB_SRC_A1, nFB_SRC_B0, nFB_SRC_B1;\r
167} REVERBInfo;\r
168\r
169///////////////////////////////////////////////////////////\r
170// SPU.C globals\r
171///////////////////////////////////////////////////////////\r
172\r
173#ifndef _IN_SPU\r
174\r
175// psx buffers / addresses\r
176\r
177extern unsigned short regArea[]; \r
178extern unsigned short spuMem[];\r
179extern unsigned char * spuMemC;\r
180extern unsigned char * pSpuIrq;\r
181extern unsigned char * pSpuBuffer;\r
182\r
183#define regAreaGet(ch,offset) \\r
184 regArea[((ch<<4)|(offset))>>1]\r
185\r
186// user settings\r
187\r
188extern int iVolume;\r
189extern int iXAPitch;\r
190extern int iUseReverb;\r
191extern int iUseInterpolation;\r
192// MISC\r
193\r
194extern int had_dma;\r
195extern int decode_pos;\r
196\r
197extern SPUCHAN s_chan[];\r
198extern REVERBInfo rvb;\r
199\r
200extern unsigned short spuCtrl;\r
201extern unsigned short spuStat;\r
202extern unsigned short spuIrq;\r
203extern unsigned int spuAddr;\r
204extern int bSpuInit;\r
205extern unsigned int dwNewChannel;\r
206extern unsigned int dwChannelOn;\r
207extern unsigned int dwPendingChanOff;\r
208extern unsigned int dwChannelDead;\r
209\r
210extern int SSumR[];\r
211extern int SSumL[];\r
212extern int iCycle;\r
213extern short * pS;\r
214\r
215extern void (CALLBACK *cddavCallback)(unsigned short,unsigned short);\r
216\r
217#endif\r
218\r
219///////////////////////////////////////////////////////////\r
220// XA.C globals\r
221///////////////////////////////////////////////////////////\r
222\r
223#ifndef _IN_XA\r
224\r
225extern xa_decode_t * xapGlobal;\r
226\r
227extern uint32_t * XAFeed;\r
228extern uint32_t * XAPlay;\r
229extern uint32_t * XAStart;\r
230extern uint32_t * XAEnd;\r
231\r
232extern uint32_t * CDDAFeed;\r
233extern uint32_t * CDDAPlay;\r
234extern uint32_t * CDDAStart;\r
235extern uint32_t * CDDAEnd;\r
236\r
237extern int iLeftXAVol;\r
238extern int iRightXAVol;\r
239\r
240#endif\r
241\r
242///////////////////////////////////////////////////////////\r
243// REVERB.C globals\r
244///////////////////////////////////////////////////////////\r
245\r
246#ifndef _IN_REVERB\r
247\r
248extern int * sRVBPlay;\r
249extern int * sRVBEnd;\r
250extern int * sRVBStart;\r
251\r
252#endif\r