X-Git-Url: https://notaz.gp2x.de/cgi-bin/gitweb.cgi?p=pcsx_rearmed.git;a=blobdiff_plain;f=plugins%2Fdfsound%2Fexternals.h;h=5ec941525c234a4963471cee79f11853ac1c2092;hp=3047afc81ed5a94b10b29ea6c87e7c250ae1d59c;hb=HEAD;hpb=5514a050f4e936f5c333fa1271b11bf5a6a9ea39 diff --git a/plugins/dfsound/externals.h b/plugins/dfsound/externals.h index 3047afc8..6dbbac67 100644 --- a/plugins/dfsound/externals.h +++ b/plugins/dfsound/externals.h @@ -15,12 +15,18 @@ * * ***************************************************************************/ +#ifndef __P_SOUND_EXTERNALS_H__ +#define __P_SOUND_EXTERNALS_H__ + #include ///////////////////////////////////////////////////////// // generic defines ///////////////////////////////////////////////////////// +//#define log_unhandled printf +#define log_unhandled(...) + #ifdef __GNUC__ #define noinline __attribute__((noinline)) #define unlikely(x) __builtin_expect((x), 0) @@ -28,6 +34,11 @@ #define noinline #define unlikely(x) x #endif +#if defined(__GNUC__) && !defined(_TMS320C6X) +#define preload __builtin_prefetch +#else +#define preload(...) +#endif #define PSE_LT_SPU 4 #define PSE_SPU_ERR_SUCCESS 0 @@ -47,7 +58,7 @@ #define MAXCHAN 24 // note: must be even due to the way reverb works now -#define NSSIZE ((44100 / 50 + 16) & ~1) +#define NSSIZE ((44100 / 50 + 32) & ~1) /////////////////////////////////////////////////////////// // struct defines @@ -78,17 +89,6 @@ typedef struct /////////////////////////////////////////////////////////// -// Tmp Flags - -// used for debug channel muting -#define FLAG_MUTE 1 - -// used for simple interpolation -#define FLAG_IPOL0 2 -#define FLAG_IPOL1 4 - -/////////////////////////////////////////////////////////// - // MAIN CHANNEL STRUCT typedef struct { @@ -105,13 +105,17 @@ typedef struct unsigned int bNoise:1; // noise active flag unsigned int bFMod:2; // freq mod (0=off, 1=sound channel, 2=freq channel) unsigned int prevflags:3; // flags from previous block - - int iLeftVolume; // left volume - int iRightVolume; // right volume + unsigned int bIgnoreLoop:1; // Ignore loop + unsigned int bStarting:1; // starting after keyon + union { + struct { + int iLeftVolume; // left volume + int iRightVolume; // right volume + }; + int iVolume[2]; + }; ADSRInfoEx ADSRX; int iRawPitch; // raw pitch (0...3fff) - - int SB[32+4]; } SPUCHAN; /////////////////////////////////////////////////////////// @@ -123,8 +127,6 @@ typedef struct int VolLeft; int VolRight; - int iRVBLeft; - int iRVBRight; int FB_SRC_A; // (offset) int FB_SRC_B; // (offset) @@ -161,54 +163,83 @@ typedef struct int dirty; // registers changed - // normalized offsets - int nIIR_DEST_A0, nIIR_DEST_A1, nIIR_DEST_B0, nIIR_DEST_B1, - nACC_SRC_A0, nACC_SRC_A1, nACC_SRC_B0, nACC_SRC_B1, - nIIR_SRC_A0, nIIR_SRC_A1, nIIR_SRC_B0, nIIR_SRC_B1, - nACC_SRC_C0, nACC_SRC_C1, nACC_SRC_D0, nACC_SRC_D1, - nMIX_DEST_A0, nMIX_DEST_A1, nMIX_DEST_B0, nMIX_DEST_B1; // MIX_DEST_xx - FB_SRC_x - int nFB_SRC_A0, nFB_SRC_A1, nFB_SRC_B0, nFB_SRC_B1; + int FB_SRC_A0, FB_SRC_A1, FB_SRC_B0, FB_SRC_B1; } REVERBInfo; /////////////////////////////////////////////////////////// // psx buffers / addresses +typedef union +{ + int SB[28 + 4 + 4]; + struct { + int sample[28]; + union { + struct { + int pos; + int val[4]; + } gauss; + int simple[5]; // 28-32 + } interp; + int sinc_old; + }; +} sample_buf; + typedef struct { unsigned short spuCtrl; unsigned short spuStat; unsigned int spuAddr; - union { - unsigned char *spuMemC; - unsigned short *spuMem; - }; - unsigned char * pSpuIrq; unsigned int cycles_played; + unsigned int cycles_dma_end; int decode_pos; int decode_dirty_ch; unsigned int bSpuInit:1; unsigned int bSPUIsOpen:1; + unsigned int bMemDirty:1; // had external write to SPU RAM unsigned int dwNoiseVal; // global noise generator unsigned int dwNoiseCount; unsigned int dwNewChannel; // flags for faster testing, if new channel starts - unsigned int dwChannelOn; // not silent channels + unsigned int dwChannelsAudible; // not silent channels unsigned int dwChannelDead; // silent+not useful channels + unsigned int XARepeat; + unsigned int XALastVal; + + int iLeftXAVol; + int iRightXAVol; + + int cdClearSamples; // extra samples to clear the capture buffers + struct { // channel volume in the cd controller + unsigned char ll, lr, rl, rr; // see cdr.Attenuator* in cdrom.c + } cdv; // applied on spu side for easier emulation + + unsigned int last_keyon_cycles; + + union { + unsigned char *spuMemC; + unsigned short *spuMem; + }; + unsigned char * pSpuIrq; + unsigned char * pSpuBuffer; short * pS; - void (CALLBACK *irqCallback)(void); // func of main emu, called on spu irq - void (CALLBACK *cddavCallback)(unsigned short,unsigned short); - void (CALLBACK *scheduleCallback)(unsigned int); + SPUCHAN * s_chan; + REVERBInfo * rvb; + + int * SSumLR; - int * sRVBStart; + void (CALLBACK *irqCallback)(int); + //void (CALLBACK *cddavCallback)(short, short); + void (CALLBACK *scheduleCallback)(unsigned int); - xa_decode_t * xapGlobal; + const xa_decode_t * xapGlobal; unsigned int * XAFeed; unsigned int * XAPlay; unsigned int * XAStart; @@ -219,18 +250,22 @@ typedef struct unsigned int * CDDAStart; unsigned int * CDDAEnd; - unsigned int XARepeat; - unsigned int XALastVal; - - int iLeftXAVol; - int iRightXAVol; + unsigned short regArea[0x400]; - SPUCHAN * s_chan; + sample_buf sb[MAXCHAN]; + int interpolation; - int pad[31]; - unsigned short regArea[0x400]; +#if P_HAVE_PTHREAD || defined(WANT_THREAD_CODE) + sample_buf * sb_thread; + sample_buf sb_thread_[MAXCHAN]; +#endif } SPUInfo; +#define regAreaGet(offset) \ + spu.regArea[((offset) - 0xc00) >> 1] +#define regAreaGetCh(ch, offset) \ + spu.regArea[(((ch) << 4) | (offset)) >> 1] + /////////////////////////////////////////////////////////// // SPU.C globals /////////////////////////////////////////////////////////// @@ -238,19 +273,21 @@ typedef struct #ifndef _IN_SPU extern SPUInfo spu; -extern REVERBInfo rvb; -void do_samples(unsigned int cycles_to, int do_sync); +void do_samples(unsigned int cycles_to, int force_no_thread); void schedule_next_irq(void); +void check_irq_io(unsigned int addr); +void do_irq_io(int cycles_after); -#define regAreaGet(ch,offset) \ - spu.regArea[((ch<<4)|(offset))>>1] - -#define do_samples_if_needed(c, sync) \ +#define do_samples_if_needed(c, no_thread, samples) \ do { \ - if (sync || (int)((c) - spu.cycles_played) >= 16 * 768) \ - do_samples(c, sync); \ + if ((no_thread) || (int)((c) - spu.cycles_played) >= (samples) * 768) \ + do_samples(c, no_thread); \ } while (0) #endif +void FeedXA(const xa_decode_t *xap); +void FeedCDDA(unsigned char *pcm, int nBytes); + +#endif /* __P_SOUND_EXTERNALS_H__ */