Merge git://github.com/notaz/pcsx_rearmed
[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
31\r
ef79bbde
P
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
ef79bbde
P
46// num of channels\r
47#define MAXCHAN 24\r
48\r
fb552464 49// ~ FRAG_MSECS ms of data\r
1775933a 50// note: must be even due to the way reverb works now\r
381ea103 51#define FRAG_MSECS 2\r
52#define NSSIZE ((44100 * FRAG_MSECS / 1000 + 1) & ~1)\r
ef79bbde
P
53\r
54///////////////////////////////////////////////////////////\r
55// struct defines\r
56///////////////////////////////////////////////////////////\r
57\r
58// ADSR INFOS PER CHANNEL\r
ef79bbde
P
59typedef struct\r
60{\r
6d866bb7 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
ef79bbde 71 int EnvelopeVol;\r
ef79bbde
P
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
ef79bbde
P
90 int iSBPos; // mixing stuff\r
91 int spos;\r
92 int sinc;\r
ef79bbde 93\r
ef79bbde
P
94 unsigned char * pCurr; // current pos in sound mem\r
95 unsigned char * pLoop; // loop ptr in sound mem\r
96\r
6d866bb7 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
6d866bb7 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
e4f075af 102 unsigned int prevflags:3; // flags from previous block\r
6d866bb7 103\r
ef79bbde 104 int iLeftVolume; // left volume\r
ef79bbde 105 int iRightVolume; // right volume\r
6d866bb7 106 ADSRInfoEx ADSRX;\r
107 int iRawPitch; // raw pitch (0...3fff)\r
108\r
381ea103 109 int SB[32+4];\r
ef79bbde
P
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
ef79bbde
P
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
1775933a 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
ef79bbde
P
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
77d6fd63 183#define regAreaGet(ch,offset) \\r
184 regArea[((ch<<4)|(offset))>>1]\r
185\r
ef79bbde
P
186// user settings\r
187\r
188extern int iVolume;\r
189extern int iXAPitch;\r
ef79bbde
P
190extern int iUseReverb;\r
191extern int iUseInterpolation;\r
ef79bbde
P
192// MISC\r
193\r
fb552464 194extern int had_dma;\r
b72f17a1 195extern int decode_pos;\r
ef79bbde
P
196\r
197extern SPUCHAN s_chan[];\r
198extern REVERBInfo rvb;\r
199\r
ef79bbde
P
200extern unsigned short spuCtrl;\r
201extern unsigned short spuStat;\r
202extern unsigned short spuIrq;\r
c668f248 203extern unsigned int spuAddr;\r
ef79bbde 204extern int bSpuInit;\r
6d866bb7 205extern unsigned int dwNewChannel;\r
206extern unsigned int dwChannelOn;\r
3fc2a4c2 207extern unsigned int dwPendingChanOff;\r
174c454a 208extern unsigned int dwChannelDead;\r
ef79bbde
P
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
ef79bbde
P
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
ef79bbde
P
251\r
252#endif\r