mirror of https://github.com/PCSX2/pcsx2.git
SPU2-X: Fixed a huge bug in my last commit that broke most everything except the bios -- Core indexes were set to -1 instead of 0 and 1 (heh). Also a Speedup: Switched to a lookup table for dispatching SPU hardware register writes.
git-svn-id: http://pcsx2.googlecode.com/svn/trunk@1933 96395faa-99c1-11dd-bbfe-3dabce05a288
This commit is contained in:
parent
3d789c5da3
commit
03972b07de
|
@ -177,8 +177,8 @@ void DoFullDump()
|
|||
" - Rm: %x\n"
|
||||
" - Phase: %x\n"
|
||||
" - Value: %x\n",
|
||||
Cores[c].Voices[v].ADSR.Reg_ADSR1,
|
||||
Cores[c].Voices[v].ADSR.Reg_ADSR2,
|
||||
Cores[c].Voices[v].ADSR.regADSR1,
|
||||
Cores[c].Voices[v].ADSR.regADSR2,
|
||||
Cores[c].Voices[v].ADSR.AttackRate,
|
||||
Cores[c].Voices[v].ADSR.AttackMode,
|
||||
Cores[c].Voices[v].ADSR.DecayRate,
|
||||
|
|
|
@ -19,7 +19,6 @@
|
|||
#include "PS2E-spu2.h"
|
||||
#include "dma.h"
|
||||
#include "Dialogs.h"
|
||||
#include "RegTable.h"
|
||||
|
||||
#ifdef _MSC_VER
|
||||
# include "svnrev.h"
|
||||
|
@ -216,11 +215,7 @@ EXPORT_C_(void) CALLBACK SPU2interruptDMA7()
|
|||
|
||||
EXPORT_C_(s32) SPU2init()
|
||||
{
|
||||
#define MAKESURE(a,b) \
|
||||
/*fprintf(stderr,"%08p: %08p == %08p\n",&(regtable[a>>1]),regtable[a>>1],U16P(b));*/ \
|
||||
assert(regtable[(a)>>1]==U16P(b))
|
||||
|
||||
MAKESURE(0x800,zero);
|
||||
assert( regtable[0x400] == NULL );
|
||||
|
||||
s32 c=0,v=0;
|
||||
ReadSettings();
|
||||
|
@ -271,6 +266,8 @@ EXPORT_C_(s32) SPU2init()
|
|||
|
||||
memset(spu2regs, 0, 0x010000);
|
||||
memset(_spu2mem, 0, 0x200000);
|
||||
Cores[0].Index = 0;
|
||||
Cores[1].Index = 1;
|
||||
Cores[0].Reset();
|
||||
Cores[1].Reset();
|
||||
|
||||
|
|
|
@ -16,7 +16,6 @@
|
|||
*/
|
||||
|
||||
#include "Global.h"
|
||||
#include "RegTable.h"
|
||||
|
||||
const char *ParamNames[8]={"VOLL","VOLR","PITCH","ADSR1","ADSR2","ENVX","VOLXL","VOLXR"};
|
||||
const char *AddressNames[6]={"SSAH","SSAL","LSAH","LSAL","NAXH","NAXL"};
|
||||
|
@ -89,8 +88,8 @@ void SPU2writeLog( const char* action, u32 rmem, u16 value )
|
|||
case SPDIF_OUT:
|
||||
RegLog(2,"SPDIF_OUT",rmem,-1,value);
|
||||
break;
|
||||
case IRQINFO:
|
||||
RegLog(2,"IRQINFO",rmem,-1,value);
|
||||
case SPDIF_IRQINFO:
|
||||
RegLog(2,"SPDIF_IRQINFO",rmem,-1,value);
|
||||
break;
|
||||
case 0x7c4:
|
||||
if(Spdif.Unknown1 != value) ConLog(" * SPU2: SPDIF Unknown Register 1 set to %04x\n",value);
|
||||
|
|
|
@ -16,12 +16,6 @@
|
|||
*/
|
||||
|
||||
#include "Global.h"
|
||||
#include "RegTable.h"
|
||||
|
||||
// This var is used to confirm that our lookup table is "correct"
|
||||
// If the assertion in DllMain fails, it means the table has too too few entries.
|
||||
// (it can't have too many because that would generate a compiler error).
|
||||
const u16 zero = 0;
|
||||
|
||||
#define PCORE(c,p) \
|
||||
U16P(Cores[c].p)
|
||||
|
@ -33,8 +27,8 @@ const u16 zero = 0;
|
|||
PVCP(c,v,Volume.Left.Reg_VOL), \
|
||||
PVCP(c,v,Volume.Right.Reg_VOL), \
|
||||
PVCP(c,v,Pitch), \
|
||||
PVCP(c,v,ADSR.Reg_ADSR1), \
|
||||
PVCP(c,v,ADSR.Reg_ADSR2), \
|
||||
PVCP(c,v,ADSR.regADSR1), \
|
||||
PVCP(c,v,ADSR.regADSR2), \
|
||||
PVCP(c,v,ADSR.Value)+1, \
|
||||
PVCP(c,v,Volume.Left.Value)+1, \
|
||||
PVCP(c,v,Volume.Right.Value)+1
|
||||
|
@ -54,8 +48,7 @@ const u16 zero = 0;
|
|||
PCORE(c,Revb.n)+1, \
|
||||
PCORE(c,Revb.n)
|
||||
|
||||
#pragma pack(1)
|
||||
u16* regtable[0x800] =
|
||||
u16* regtable[0x401] =
|
||||
{
|
||||
// Voice Params: 8 params, 24 voices = 0x180 bytes
|
||||
PVC(0, 0),PVC(0, 1),PVC(0, 2),PVC(0, 3),PVC(0, 4),PVC(0, 5),
|
||||
|
@ -75,22 +68,20 @@ u16* regtable[0x800] =
|
|||
PCORE(0,Regs.VMIXR)+1,
|
||||
PCORE(0,Regs.VMIXER),
|
||||
PCORE(0,Regs.VMIXER)+1,
|
||||
PCORE(0,Regs.MMIX),
|
||||
|
||||
PCORE(0,Regs.MMIX),
|
||||
PCORE(0,Regs.ATTR),
|
||||
|
||||
PCORE(0,IRQA)+1,
|
||||
PCORE(0,IRQA),
|
||||
|
||||
U16P(zero),
|
||||
U16P(zero),
|
||||
U16P(zero),
|
||||
U16P(zero),
|
||||
NULL, NULL,
|
||||
NULL, NULL,
|
||||
|
||||
PCORE(0,TSA)+1,
|
||||
PCORE(0,TSA),
|
||||
|
||||
PRAW(0x1ac), PRAW(0x1ae),
|
||||
PRAW(REG__1AC), PRAW(REG__1AE),
|
||||
|
||||
PCORE(0,AutoDMACtrl),
|
||||
|
||||
|
@ -129,7 +120,7 @@ u16* regtable[0x800] =
|
|||
PREVB_REG(0,MIX_DEST_B1),
|
||||
|
||||
PCORE(0,EffectsEndA)+1,
|
||||
U16P(zero),
|
||||
NULL,
|
||||
|
||||
PCORE(0,Regs.ENDX),
|
||||
PCORE(0,Regs.ENDX)+1,
|
||||
|
@ -187,10 +178,8 @@ u16* regtable[0x800] =
|
|||
PCORE(1,IRQA)+1,
|
||||
PCORE(1,IRQA),
|
||||
|
||||
U16P(zero),
|
||||
U16P(zero),
|
||||
U16P(zero),
|
||||
U16P(zero),
|
||||
NULL, NULL,
|
||||
NULL, NULL,
|
||||
|
||||
PCORE(1,TSA)+1,
|
||||
PCORE(1,TSA),
|
||||
|
@ -234,7 +223,7 @@ u16* regtable[0x800] =
|
|||
PREVB_REG(1,MIX_DEST_B1),
|
||||
|
||||
PCORE(1,EffectsEndA)+1,
|
||||
U16P(zero),
|
||||
NULL,
|
||||
|
||||
PCORE(1,Regs.ENDX),
|
||||
PCORE(1,Regs.ENDX)+1,
|
||||
|
@ -308,6 +297,5 @@ u16* regtable[0x800] =
|
|||
PRAW(0x7F0),PRAW(0x7F2),PRAW(0x7F4),PRAW(0x7F6),
|
||||
PRAW(0x7F8),PRAW(0x7FA),PRAW(0x7FC),PRAW(0x7FE),
|
||||
|
||||
U16P(zero)
|
||||
NULL
|
||||
};
|
||||
#pragma pack()
|
|
@ -1,32 +0,0 @@
|
|||
//GiGaHeRz's SPU2 Driver
|
||||
//Copyright (c) 2003-2008, David Quintana <gigaherz@gmail.com>
|
||||
//
|
||||
//This library is free software; you can redistribute it and/or
|
||||
//modify it under the terms of the GNU Lesser General Public
|
||||
//License as published by the Free Software Foundation; either
|
||||
//version 2.1 of the License, or (at your option) any later version.
|
||||
//
|
||||
//This library is distributed in the hope that it will be useful,
|
||||
//but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
//MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
//Lesser General Public License for more details.
|
||||
//
|
||||
//You should have received a copy of the GNU Lesser General Public
|
||||
//License along with this library; if not, write to the Free Software
|
||||
//Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
//
|
||||
|
||||
#ifndef _REGTABLE_H_
|
||||
#define _REGTABLE_H_
|
||||
|
||||
#define U16P(x) ( (u16*)&(x) )
|
||||
|
||||
// Returns the hiword of a 32 bit integer.
|
||||
#define U16P_HI(x) ( ((u16*)&(x))+1 )
|
||||
|
||||
// Yay! Global namespace pollution 101!
|
||||
extern const u16 zero;
|
||||
|
||||
extern u16* regtable[0x800];
|
||||
|
||||
#endif
|
|
@ -18,7 +18,6 @@
|
|||
|
||||
#include "Global.h"
|
||||
#include "Dialogs.h"
|
||||
#include "../RegTable.h"
|
||||
|
||||
|
||||
static bool debugDialogOpen=false;
|
||||
|
|
|
@ -990,10 +990,6 @@
|
|||
RelativePath="..\RegTable.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\RegTable.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\spu2freeze.cpp"
|
||||
>
|
||||
|
|
|
@ -99,24 +99,35 @@ public:
|
|||
void DebugDump( FILE* dump, const char* title );
|
||||
};
|
||||
|
||||
|
||||
struct V_ADSR
|
||||
{
|
||||
u16 Reg_ADSR1;
|
||||
u16 Reg_ADSR2;
|
||||
union
|
||||
{
|
||||
u32 reg32;
|
||||
|
||||
struct
|
||||
{
|
||||
u16 regADSR1;
|
||||
u16 regADSR2;
|
||||
};
|
||||
|
||||
struct
|
||||
{
|
||||
u32 SustainLevel:4,
|
||||
DecayRate:4,
|
||||
AttackRate:7,
|
||||
AttackMode:1, // 0 for linear (+lin), 1 for pseudo exponential (+exp)
|
||||
|
||||
s32 Value; // Ranges from 0 to 0x7fffffff (signed values are clamped to 0) [Reg_ENVX]
|
||||
u8 Phase;
|
||||
u8 AttackRate; // Ar
|
||||
u8 AttackMode; // Am
|
||||
u8 DecayRate; // Dr
|
||||
u8 SustainLevel; // Sl
|
||||
u8 SustainRate; // Sr
|
||||
u8 SustainMode; // Sm
|
||||
u8 ReleaseRate; // Rr
|
||||
u8 ReleaseMode; // Rm
|
||||
ReleaseRate:5,
|
||||
ReleaseMode:1, // 0 for linear (-lin), 1 for exponential (-exp)
|
||||
SustainRate:7,
|
||||
SustainMode:3; // 0 = +lin, 1 = -lin, 2 = +exp, 3 = -exp
|
||||
};
|
||||
};
|
||||
|
||||
bool Releasing; // Ready To Release, triggered by Voice.Stop();
|
||||
s32 Value; // Ranges from 0 to 0x7fffffff (signed values are clamped to 0) [Reg_ENVX]
|
||||
u8 Phase; // monitors current phase of ADSR envelope
|
||||
bool Releasing; // Ready To Release, triggered by Voice.Stop();
|
||||
|
||||
public:
|
||||
bool Calculate();
|
||||
|
@ -133,10 +144,6 @@ struct V_Voice
|
|||
V_ADSR ADSR;
|
||||
// Pitch (also Reg_PITCH)
|
||||
s16 Pitch;
|
||||
// Pitch Modulated by previous voice
|
||||
s8 Modulated;
|
||||
// Source (Wave/Noise)
|
||||
s8 Noise;
|
||||
// Loop Start address (also Reg_LSAH/L)
|
||||
u32 LoopStartA;
|
||||
// Sound Start address (also Reg_SSAH/L)
|
||||
|
@ -147,15 +154,14 @@ struct V_Voice
|
|||
s32 Prev1;
|
||||
s32 Prev2;
|
||||
|
||||
// Pitch Modulated by previous voice
|
||||
bool Modulated;
|
||||
// Source (Wave/Noise)
|
||||
bool Noise;
|
||||
|
||||
s8 LoopMode;
|
||||
s8 LoopFlags;
|
||||
|
||||
// [Air] : Replaced loop flags read from the ADPCM header with
|
||||
// a single LoopFlags value (above) -- more cache-friendly.
|
||||
//s8 LoopStart;
|
||||
//s8 Loop;
|
||||
//s8 LoopEnd;
|
||||
|
||||
// Sample pointer (19:12 bit fixed point)
|
||||
s32 SP;
|
||||
|
||||
|
@ -303,8 +309,9 @@ struct V_CoreRegs
|
|||
u32 VMIXR;
|
||||
u32 VMIXEL;
|
||||
u32 VMIXER;
|
||||
u16 MMIX;
|
||||
u32 ENDX;
|
||||
|
||||
u16 MMIX;
|
||||
u16 STATX;
|
||||
u16 ATTR;
|
||||
u16 _1AC;
|
||||
|
@ -374,17 +381,18 @@ struct V_Core
|
|||
u32 TSA; // DMA Transfer Start Address
|
||||
u32 TDA; // DMA Transfer Data Address (Internal...)
|
||||
|
||||
s8 IRQEnable; // Interrupt Enable
|
||||
bool IRQEnable; // Interrupt Enable
|
||||
bool FxEnable; // Effect Enable
|
||||
bool Mute; // Mute
|
||||
bool AdmaInProgress;
|
||||
|
||||
s8 DMABits; // DMA related?
|
||||
s8 FxEnable; // Effect Enable
|
||||
s8 NoiseClk; // Noise Clock
|
||||
u16 AutoDMACtrl; // AutoDMA Status
|
||||
s32 DMAICounter; // DMA Interrupt Counter
|
||||
s8 Mute; // Mute
|
||||
u32 InputDataLeft; // Input Buffer
|
||||
u32 InputPos;
|
||||
u32 InputDataProgress;
|
||||
u8 AdmaInProgress;
|
||||
|
||||
V_Reverb Revb; // Reverb Registers
|
||||
V_ReverbBuffers RevBuffers; // buffer pointers for reverb, pre-calculated and pre-clipped.
|
||||
|
|
|
@ -127,10 +127,10 @@
|
|||
|
||||
// SPDIF interface
|
||||
#define SPDIF_OUT 0x07C0 // SPDIF Out: OFF/'PCM'/Bitstream/Bypass
|
||||
#define IRQINFO 0x07C2
|
||||
#define SPDIF_IRQINFO 0x07C2
|
||||
#define SPDIF_MODE 0x07C6
|
||||
#define SPDIF_MEDIA 0x07C8 // SPDIF Media: 'CD'/DVD
|
||||
#define SPDIF_PROTECT 0x07CC // SPDIF Copy Protection
|
||||
#define SPDIF_PROTECT 0x07CC // SPDIF Copy Protection
|
||||
|
||||
|
||||
/*********************************************************************
|
||||
|
@ -180,3 +180,16 @@ Core attributes (SD_C)
|
|||
#define VOICE_ADDR_LSAX 0x4 // Loop point address
|
||||
#define VOICE_ADDR_NAX 0x8 // Waveform data that should be read next
|
||||
|
||||
|
||||
|
||||
// --------------------------------------------------------------------------------------
|
||||
// SPU2-X Register Table LUT
|
||||
// --------------------------------------------------------------------------------------
|
||||
|
||||
#define U16P(x) ( (u16*)&(x) )
|
||||
|
||||
// Returns the hiword of a 32 bit integer.
|
||||
#define U16P_HI(x) ( ((u16*)&(x))+1 )
|
||||
|
||||
extern u16* regtable[0x401];
|
||||
|
||||
|
|
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue