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