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