X-Git-Url: https://notaz.gp2x.de/cgi-bin/gitweb.cgi?p=pcsx_rearmed.git;a=blobdiff_plain;f=plugins%2Fdfsound%2Fexternals.h;h=3a3ff68aad86b807f9072d920148fc86c62560cb;hp=2f3028eefba5de6c1a5cddef31b3da0e2b56a397;hb=63a4f6b6a3b0315590cd3009df2c92480ed2d98b;hpb=c668f24877c063db881fa8d1eeb8a6fbc649d5a0 diff --git a/plugins/dfsound/externals.h b/plugins/dfsound/externals.h index 2f3028ee..3a3ff68a 100644 --- a/plugins/dfsound/externals.h +++ b/plugins/dfsound/externals.h @@ -46,19 +46,24 @@ // num of channels #define MAXCHAN 24 -// ~ FRAG_MSECS ms of data // note: must be even due to the way reverb works now -#define FRAG_MSECS 2 -#define NSSIZE ((44100 * FRAG_MSECS / 1000 + 1) & ~1) +#define NSSIZE ((44100 / 50 + 16) & ~1) /////////////////////////////////////////////////////////// // struct defines /////////////////////////////////////////////////////////// +enum ADSR_State { + ADSR_ATTACK = 0, + ADSR_DECAY = 1, + ADSR_SUSTAIN = 2, + ADSR_RELEASE = 3, +}; + // ADSR INFOS PER CHANNEL typedef struct { - unsigned char State:2; + unsigned char State:2; // ADSR_State unsigned char AttackModeExp:1; unsigned char SustainModeExp:1; unsigned char SustainIncrease:1; @@ -90,11 +95,11 @@ typedef struct int iSBPos; // mixing stuff int spos; int sinc; + int sinc_inv; unsigned char * pCurr; // current pos in sound mem unsigned char * pLoop; // loop ptr in sound mem - unsigned int bStop:1; // is channel stopped (sample _can_ still be playing, ADSR Release phase) unsigned int bReverb:1; // can we do reverb on this channel? must have ctrl register bit, to get active unsigned int bRVBActive:1; // reverb active flag unsigned int bNoise:1; // noise active flag @@ -166,87 +171,83 @@ typedef struct int nFB_SRC_A0, nFB_SRC_A1, nFB_SRC_B0, nFB_SRC_B1; } REVERBInfo; -/////////////////////////////////////////////////////////// -// SPU.C globals /////////////////////////////////////////////////////////// -#ifndef _IN_SPU - // psx buffers / addresses -extern unsigned short regArea[]; -extern unsigned short spuMem[]; -extern unsigned char * spuMemC; -extern unsigned char * pSpuIrq; -extern unsigned char * pSpuBuffer; +typedef struct +{ + unsigned short spuCtrl; + unsigned short spuStat; + + unsigned int spuAddr; + unsigned char * spuMemC; + unsigned char * pSpuIrq; -#define regAreaGet(ch,offset) \ - regArea[((ch<<4)|(offset))>>1] + unsigned int cycles_played; + int decode_pos; + int decode_dirty_ch; + unsigned int bSpuInit:1; + unsigned int bSPUIsOpen:1; -// user settings + 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 dwChannelDead; // silent+not useful channels -extern int iVolume; -extern int iXAPitch; -extern int iUseReverb; -extern int iUseInterpolation; -// MISC + unsigned char * pSpuBuffer; + short * pS; -extern int had_dma; -extern int decode_pos; + void (CALLBACK *irqCallback)(void); // func of main emu, called on spu irq + void (CALLBACK *cddavCallback)(unsigned short,unsigned short); + void (CALLBACK *scheduleCallback)(unsigned int); -extern SPUCHAN s_chan[]; -extern REVERBInfo rvb; + int * sRVBStart; -extern unsigned short spuCtrl; -extern unsigned short spuStat; -extern unsigned short spuIrq; -extern unsigned int spuAddr; -extern int bSpuInit; -extern unsigned int dwNewChannel; -extern unsigned int dwChannelOn; -extern unsigned int dwPendingChanOff; -extern unsigned int dwChannelDead; + xa_decode_t * xapGlobal; + unsigned int * XAFeed; + unsigned int * XAPlay; + unsigned int * XAStart; + unsigned int * XAEnd; -extern int SSumR[]; -extern int SSumL[]; -extern int iCycle; -extern short * pS; + unsigned int * CDDAFeed; + unsigned int * CDDAPlay; + unsigned int * CDDAStart; + unsigned int * CDDAEnd; -extern void (CALLBACK *cddavCallback)(unsigned short,unsigned short); + unsigned int XARepeat; + unsigned int XALastVal; -#endif + int iLeftXAVol; + int iRightXAVol; + + int pad[32]; + unsigned short regArea[0x400]; + unsigned short spuMem[256*1024]; +} SPUInfo; /////////////////////////////////////////////////////////// -// XA.C globals +// SPU.C globals /////////////////////////////////////////////////////////// -#ifndef _IN_XA +#ifndef _IN_SPU -extern xa_decode_t * xapGlobal; +extern SPUInfo spu; +extern SPUCHAN s_chan[]; +extern REVERBInfo rvb; -extern uint32_t * XAFeed; -extern uint32_t * XAPlay; -extern uint32_t * XAStart; -extern uint32_t * XAEnd; +void do_samples(unsigned int cycles_to, int do_sync); +void schedule_next_irq(void); -extern uint32_t * CDDAFeed; -extern uint32_t * CDDAPlay; -extern uint32_t * CDDAStart; -extern uint32_t * CDDAEnd; +#define regAreaGet(ch,offset) \ + spu.regArea[((ch<<4)|(offset))>>1] -extern int iLeftXAVol; -extern int iRightXAVol; +#define do_samples_if_needed(c, sync) \ + do { \ + if (sync || (int)((c) - spu.cycles_played) >= 16 * 768) \ + do_samples(c, sync); \ + } while (0) #endif -/////////////////////////////////////////////////////////// -// REVERB.C globals -/////////////////////////////////////////////////////////// - -#ifndef _IN_REVERB - -extern int * sRVBPlay; -extern int * sRVBEnd; -extern int * sRVBStart; - -#endif