SPU2-X: These aren't the buildfiles you're looking for. Move along now.

git-svn-id: http://pcsx2.googlecode.com/svn/trunk@556 96395faa-99c1-11dd-bbfe-3dabce05a288
This commit is contained in:
arcum42 2009-02-20 21:48:59 +00:00
parent 95498f4689
commit 1745eb2013
34 changed files with 899 additions and 43 deletions

View File

@ -19,7 +19,7 @@
*
*/
#include "spu2.h"
#include "Spu2.h"
static const s32 ADSR_MAX_VOL = 0x7fffffff;

View File

@ -20,7 +20,7 @@
#define _DPLII_H_
#include "PS2Etypes.h"
#include "lowpass.h"
#include "Lowpass.h"
class DPLII
{

View File

@ -16,7 +16,7 @@
//Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
#include "spu2.h"
#include "Spu2.h"
int crazy_debug=0;
@ -94,6 +94,7 @@ void V_VolumeLR::DebugDump( FILE* dump, const char* title )
void DoFullDump()
{
#ifdef _MSC_VER
#ifdef SPU2_LOG
FILE *dump;
u8 c=0, v=0;
@ -258,4 +259,5 @@ void DoFullDump()
fclose(dump);
}
#endif
#endif
}

View File

@ -19,7 +19,7 @@
*
*/
#include "spu2.h"
#include "Spu2.h"
#include "DPLII.h"
#include <string.h>

View File

@ -15,7 +15,7 @@
//License along with this library; if not, write to the Free Software
//Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
#include "spu2.h"
#include "Spu2.h"
extern "C" {
#include "liba52/inttypes.h"

View File

@ -19,11 +19,16 @@
*
*/
#include "spu2.h"
#include "regtable.h"
#include "dialogs.h"
#include "Spu2.h"
#include "RegTable.h"
#include "Dialogs.h"
#ifdef _MSC_VER
#include "svnrev.h"
#else
#include <stdio.h>
#include <string.h>
#endif
// [Air]: Adding the spu2init boolean wasn't necessary except to help me in
// debugging the spu2 suspend/resume behavior (when user hits escape).
@ -36,12 +41,14 @@ static u32 pClocks=0;
// Pcsx2 expects ASNI, not unicode, so this MUST always be char...
static char libraryName[256];
#ifdef _MSC_VER
BOOL WINAPI DllMain(HINSTANCE hinstDLL,DWORD dwReason,LPVOID lpvReserved)
{
if( dwReason == DLL_PROCESS_ATTACH )
hInstance = hinstDLL;
return TRUE;
}
#endif
static void InitLibraryName()
{
@ -137,7 +144,11 @@ EXPORT_C_(s32) SPU2init()
#ifdef SPU2_LOG
if(AccessLog())
{
#ifdef _MSC_VER
spu2Log = _wfopen( AccessLogFileName, _T("w") );
#else
spu2Log = fopen((char*)AccessLogFileName, "w");
#endif
setvbuf(spu2Log, NULL, _IONBF, 0);
FileLog("SPU2init\n");
}

View File

@ -19,7 +19,7 @@
*
*/
#include "spu2.h"
#include "Spu2.h"
extern u8 callirq;
@ -40,8 +40,13 @@ u16* DMABaseAddr;
void DMALogOpen()
{
if(!DMALog()) return;
#ifdef _MSC_VER
DMA4LogFile = _wfopen( DMA4LogFileName, _T("wb") );
DMA7LogFile = _wfopen( DMA7LogFileName, _T("wb") );
#else
DMA4LogFile = fopen((char*)DMA4LogFileName, "wb");
DMA7LogFile = fopen((char*)DMA7LogFileName, "wb");
#endif
ADMA4LogFile = fopen( "logs/adma4.raw", "wb" );
ADMA7LogFile = fopen( "logs/adma7.raw", "wb" );
ADMAOutLogFile = fopen( "logs/admaOut.raw", "wb" );

View File

@ -0,0 +1,162 @@
/* SPU2-X, A plugin for Emulating the Sound Processing Unit of the Playstation 2
* Developed and maintained by the Pcsx2 Development Team.
*
* Original portions from SPU2ghz are (c) 2008 by David Quintana [gigaherz]
*
* 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 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
* 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
*
*/
// Adapted from ZeroSPU2 code by Zerofrog. Heavily modified by Arcum42.
#include <alsa/asoundlib.h>
#define ALSA_MEM_DEF
#include "Alsa.h"
static snd_pcm_t *handle = NULL;
static snd_pcm_uframes_t buffer_size;
int AlsaSetupSound()
{
snd_pcm_hw_params_t *hwparams;
snd_pcm_sw_params_t *swparams;
snd_pcm_status_t *status;
unsigned int pspeed = SAMPLE_RATE;
int pchannels = 2;
snd_pcm_format_t format = SND_PCM_FORMAT_S16_LE;
unsigned int buffer_time = SOUNDSIZE;
unsigned int period_time= buffer_time / 4;
int err;
err = snd_pcm_open(&handle, "default", SND_PCM_STREAM_PLAYBACK, SND_PCM_NONBLOCK);
if(err < 0)
{
ERROR_LOG("Audio open error: %s\n", snd_strerror(err));
return -1;
}
err = snd_pcm_nonblock(handle, 0);
if(err < 0)
{
ERROR_LOG("Can't set blocking mode: %s\n", snd_strerror(err));
return -1;
}
snd_pcm_hw_params_alloca(&hwparams);
snd_pcm_sw_params_alloca(&swparams);
err = snd_pcm_hw_params_any(handle, hwparams);
if (err < 0)
{
ERROR_LOG("Broken configuration for this PCM: %s\n", snd_strerror(err));
return -1;
}
err = snd_pcm_hw_params_set_access(handle, hwparams, SND_PCM_ACCESS_RW_INTERLEAVED);
if (err < 0)
{
ERROR_LOG("Access type not available: %s\n", snd_strerror(err));
return -1;
}
err = snd_pcm_hw_params_set_format(handle, hwparams, format);
if (err < 0)
{
ERROR_LOG("Sample format not available: %s\n", snd_strerror(err));
return -1;
}
err = snd_pcm_hw_params_set_channels(handle, hwparams, pchannels);
if (err < 0)
{
ERROR_LOG("Channels count not available: %s\n", snd_strerror(err));
return -1;
}
err = snd_pcm_hw_params_set_rate_near(handle, hwparams, &pspeed, 0);
if (err < 0)
{
ERROR_LOG("Rate not available: %s\n", snd_strerror(err));
return -1;
}
err = snd_pcm_hw_params_set_buffer_time_near(handle, hwparams, &buffer_time, 0);
if(err < 0) {
ERROR_LOG("Buffer time error: %s\n", snd_strerror(err));
return -1;
}
err = snd_pcm_hw_params_set_period_time_near(handle, hwparams, &period_time, 0);
if (err < 0)
{
ERROR_LOG("Period time error: %s\n", snd_strerror(err));
return -1;
}
err = snd_pcm_hw_params(handle, hwparams);
if (err < 0)
{
ERROR_LOG("Unable to install hw params: %s\n", snd_strerror(err));
return -1;
}
snd_pcm_status_alloca(&status);
err = snd_pcm_status(handle, status);
if(err < 0)
{
ERROR_LOG("Unable to get status: %s\n", snd_strerror(err));
return -1;
}
buffer_size=snd_pcm_status_get_avail(status);
return 0;
}
void AlsaRemoveSound()
{
if(handle != NULL) {
snd_pcm_drop(handle);
snd_pcm_close(handle);
handle = NULL;
}
}
int AlsaSoundGetBytesBuffered()
{
int l;
// failed to open?
if(handle == NULL) return SOUNDSIZE;
l = snd_pcm_avail_update(handle);
if (l<0)
return 0;
else if (l<buffer_size/2) // can we write in at least the half of fragments?
l=SOUNDSIZE; // -> no? wait
else
l=0; // -> else go on
return l;
}
void AlsaSoundFeedVoiceData(unsigned char* pSound,long lBytes)
{
if (handle == NULL) return;
if (snd_pcm_state(handle) == SND_PCM_STATE_XRUN)
snd_pcm_prepare(handle);
snd_pcm_writei(handle,pSound, lBytes/4);
}

View File

@ -0,0 +1,78 @@
/* SPU2-X, A plugin for Emulating the Sound Processing Unit of the Playstation 2
* Developed and maintained by the Pcsx2 Development Team.
*
* Original portions from SPU2ghz are (c) 2008 by David Quintana [gigaherz]
*
* 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 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
* 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
*
*/
#include "Spu2.h"
#include "Dialogs.h"
#ifdef SPU2X_DEVBUILD
static const int LATENCY_MAX = 3000;
#else
static const int LATENCY_MAX = 750;
#endif
static const int LATENCY_MIN = 40;
int AutoDMAPlayRate[2] = {0,0};
// MIXING
int Interpolation = 1;
/* values:
0: no interpolation (use nearest)
1. linear interpolation
2. cubic interpolation
*/
bool EffectsDisabled = false;
// OUTPUT
int SndOutLatencyMS = 160;
bool timeStretchDisabled = false;
u32 OutputModule = 0;
CONFIG_DSOUNDOUT Config_DSoundOut;
CONFIG_WAVEOUT Config_WaveOut;
CONFIG_XAUDIO2 Config_XAudio2;
// DSP
bool dspPluginEnabled = false;
int dspPluginModule = 0;
wchar_t dspPlugin[256];
bool StereoExpansionDisabled = true;
/*****************************************************************************/
void ReadSettings()
{
}
/*****************************************************************************/
void WriteSettings()
{
}
void configure()
{
ReadSettings();
}

View File

@ -0,0 +1,168 @@
/* SPU2-X, A plugin for Emulating the Sound Processing Unit of the Playstation 2
* Developed and maintained by the Pcsx2 Development Team.
*
* Original portions from SPU2ghz are (c) 2008 by David Quintana [gigaherz]
*
* 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 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
* 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 CONFIG_H_INCLUDED
#define CONFIG_H_INCLUDED
#include <string>
extern bool DebugEnabled;
extern bool _MsgToConsole;
extern bool _MsgKeyOnOff;
extern bool _MsgVoiceOff;
extern bool _MsgDMA;
extern bool _MsgAutoDMA;
extern bool _MsgOverruns;
extern bool _MsgCache;
extern bool _AccessLog;
extern bool _DMALog;
extern bool _WaveLog;
extern bool _CoresDump;
extern bool _MemDump;
extern bool _RegDump;
static __forceinline bool MsgToConsole() { return _MsgToConsole & DebugEnabled; }
static __forceinline bool MsgKeyOnOff() { return _MsgKeyOnOff & MsgToConsole(); }
static __forceinline bool MsgVoiceOff() { return _MsgVoiceOff & MsgToConsole(); }
static __forceinline bool MsgDMA() { return _MsgDMA & MsgToConsole(); }
static __forceinline bool MsgAutoDMA() { return _MsgAutoDMA & MsgDMA(); }
static __forceinline bool MsgOverruns() { return _MsgOverruns & MsgToConsole(); }
static __forceinline bool MsgCache() { return _MsgCache & MsgToConsole(); }
static __forceinline bool AccessLog() { return _AccessLog & DebugEnabled; }
static __forceinline bool DMALog() { return _DMALog & DebugEnabled; }
static __forceinline bool WaveLog() { return _WaveLog & DebugEnabled; }
static __forceinline bool CoresDump() { return _CoresDump & DebugEnabled; }
static __forceinline bool MemDump() { return _MemDump & DebugEnabled; }
static __forceinline bool RegDump() { return _RegDump & DebugEnabled; }
extern wchar_t AccessLogFileName[255];
extern wchar_t WaveLogFileName[255];
extern wchar_t DMA4LogFileName[255];
extern wchar_t DMA7LogFileName[255];
extern wchar_t CoresDumpFileName[255];
extern wchar_t MemDumpFileName[255];
extern wchar_t RegDumpFileName[255];
extern int Interpolation;
extern bool EffectsDisabled;
extern int AutoDMAPlayRate[2];
extern u32 OutputModule;
extern int SndOutLatencyMS;
extern wchar_t dspPlugin[];
extern int dspPluginModule;
extern bool dspPluginEnabled;
extern bool timeStretchDisabled;
extern bool StereoExpansionDisabled;
class SoundtouchCfg
{
// Timestretch Slider Bounds, Min/Max
static const int SequenceLen_Min = 30;
static const int SequenceLen_Max = 90;
static const int SeekWindow_Min = 10;
static const int SeekWindow_Max = 32;
static const int Overlap_Min = 3;
static const int Overlap_Max = 15;
public:
static int SequenceLenMS;
static int SeekWindowMS;
static int OverlapMS;
static void ReadSettings();
static void WriteSettings();
//static void OpenDialog( HWND hWnd );
protected:
static void ClampValues();
//static BOOL CALLBACK DialogProc(HWND hWnd,UINT uMsg,WPARAM wParam,LPARAM lParam);
};
// *** BEGIN DRIVER-SPECIFIC CONFIGURATION ***
// -------------------------------------------
// DSOUND
struct CONFIG_XAUDIO2
{
std::wstring Device;
s8 NumBuffers;
CONFIG_XAUDIO2() :
Device(),
NumBuffers( 2 )
{
}
};
// DSOUND
struct CONFIG_DSOUNDOUT
{
std::wstring Device;
s8 NumBuffers;
CONFIG_DSOUNDOUT() :
Device(),
NumBuffers( 3 )
{
}
};
// WAVEOUT
struct CONFIG_WAVEOUT
{
std::wstring Device;
s8 NumBuffers;
CONFIG_WAVEOUT() :
Device(),
NumBuffers( 4 )
{
}
};
extern CONFIG_DSOUNDOUT Config_DSoundOut;
extern CONFIG_WAVEOUT Config_WaveOut;
extern CONFIG_XAUDIO2 Config_XAudio2;
//////
void ReadSettings();
void WriteSettings();
void configure();
void AboutBox();
#endif // CONFIG_H_INCLUDED

View File

@ -0,0 +1,22 @@
/* SPU2-X, A plugin for Emulating the Sound Processing Unit of the Playstation 2
* Developed and maintained by the Pcsx2 Development Team.
*
* Original portions from SPU2ghz are (c) 2008 by David Quintana [gigaherz]
*
* 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 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
* 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
*
*/
// To be continued...

View File

@ -0,0 +1,25 @@
/* SPU2-X, A plugin for Emulating the Sound Processing Unit of the Playstation 2
* Developed and maintained by the Pcsx2 Development Team.
*
* Original portions from SPU2ghz are (c) 2008 by David Quintana [gigaherz]
*
* 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 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
* 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 DIALOG_H_INCLUDED
#define DIALOG_H_INCLUDED
#endif

View File

@ -0,0 +1,63 @@
/* SPU2-X, A plugin for Emulating the Sound Processing Unit of the Playstation 2
* Developed and maintained by the Pcsx2 Development Team.
*
* Original portions from SPU2ghz are (c) 2008 by David Quintana [gigaherz]
*
* 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 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
* 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
*
*/
#include "Linux.h"
void SysMessage(char *fmt, ...) {
GtkWidget *Ok,*Txt;
GtkWidget *Box,*Box1;
va_list list;
char msg[512];
va_start(list, fmt);
vsprintf(msg, fmt, list);
va_end(list);
if (msg[strlen(msg)-1] == '\n') msg[strlen(msg)-1] = 0;
MsgDlg = gtk_window_new (GTK_WINDOW_TOPLEVEL);
gtk_window_set_position(GTK_WINDOW(MsgDlg), GTK_WIN_POS_CENTER);
gtk_window_set_title(GTK_WINDOW(MsgDlg), "SPU2null Msg");
gtk_container_set_border_width(GTK_CONTAINER(MsgDlg), 5);
Box = gtk_vbox_new(5, 0);
gtk_container_add(GTK_CONTAINER(MsgDlg), Box);
gtk_widget_show(Box);
Txt = gtk_label_new(msg);
gtk_box_pack_start(GTK_BOX(Box), Txt, FALSE, FALSE, 5);
gtk_widget_show(Txt);
Box1 = gtk_hbutton_box_new();
gtk_box_pack_start(GTK_BOX(Box), Box1, FALSE, FALSE, 0);
gtk_widget_show(Box1);
Ok = gtk_button_new_with_label("Ok");
gtk_signal_connect (GTK_OBJECT(Ok), "clicked", GTK_SIGNAL_FUNC(OnMsg_Ok), NULL);
gtk_container_add(GTK_CONTAINER(Box1), Ok);
GTK_WIDGET_SET_FLAGS(Ok, GTK_CAN_DEFAULT);
gtk_widget_show(Ok);
gtk_widget_show(MsgDlg);
gtk_main();
}

View File

@ -0,0 +1,40 @@
/* SPU2-X, A plugin for Emulating the Sound Processing Unit of the Playstation 2
* Developed and maintained by the Pcsx2 Development Team.
*
* Original portions from SPU2ghz are (c) 2008 by David Quintana [gigaherz]
*
* 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 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
* 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 __LINUX_H__
#define __LINUX_H__
#include "Spu2.h"
#include "Dialogs.h"
#include "stdio.h"
#include "string.h"
#include <assert.h>
#include <stdlib.h>
// Make it easier to check and set checkmarks in the gui
#define is_checked(main_widget, widget_name) (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(lookup_widget(main_widget, widget_name))))
#define set_checked(main_widget,widget_name, state) gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON(lookup_widget(main_widget, widget_name)), state)
void SysMessage(char *fmt, ...);
#endif

View File

@ -19,7 +19,7 @@
*
*/
#include "lowpass.h"
#include "Lowpass.h"
#include <math.h>
#include <float.h>

View File

@ -0,0 +1,33 @@
# Create a shared library libSPU2X
AUTOMAKE_OPTIONS = foreign
noinst_LIBRARIES = libSPU2X.a
INCLUDES = -I@srcdir@/common -I@srcdir@/3rdparty -I@srcdir@/Linux
libSPU2X_a_CXXFLAGS = $(shell pkg-config --cflags gtk+-2.0)
libSPU2X_a_CFLAGS = $(shell pkg-config --cflags gtk+-2.0)
# Create a shared object by faking an exe (thanks to ODE makefiles)
traplibdir=$(prefix)
if DEBUGBUILD
preext=d
endif
EXEEXT=$(preext)@so_ext@
traplib_PROGRAMS=libSPU2X
libSPU2X_SOURCES=
libSPU2X_DEPENDENCIES = libSPU2X.a
libSPU2X_LDFLAGS= @SHARED_LDFLAGS@
libSPU2X_LDFLAGS+=-Wl,-soname,@SPU2X_SONAME@
libSPU2X_LDADD=$(llibSPU2X_a_OBJECTS) 3rdparty/SoundTouch/libSoundTouch.a
libSPU2X_a_SOURCES = ADSR.cpp DllInterface.cpp Mixer.cpp RegTable.cpp SaveStateSPU.cpp \
Spu2.cpp Timestretcher.cpp utf8.cpp Debug.cpp Decoder.cpp \
Dma.cpp Lowpass.cpp RegLog.cpp Reverb.cpp SndOut.cpp Spu2replay.cpp Wavedump_wav.cpp ReadInput.cpp
libSPU2X_a_SOURCES += BaseTypes.h Debug.h Dma.h Lowpass.h RegTable.h SndOut.h \
Spu2.h Spu2replay.h defs.h regs.h spdif.h utf8.h
libSPU2X_a_SOURCES += Linux/Config.h Linux/Config.cpp Linux/Linux.h Linux/Alsa.cpp Linux/Alsa.h Linux/Dialogs.cpp Linux/Dialogs.h
SUBDIRS = 3rdparty/SoundTouch

View File

@ -19,7 +19,7 @@
*
*/
#include "spu2.h"
#include "Spu2.h"
#include <float.h>
extern void spdif_update();
@ -274,10 +274,13 @@ static s32 __forceinline GetNoiseValues()
{
static s32 Seed = 0x41595321;
s32 retval = 0x8000;
if( Seed&0x100 )
retval = (Seed&0xff) << 8;
else if( Seed&0xffff )
retval = 0x7fff;
if( Seed&0x100 ) retval = (Seed&0xff) << 8;
else if( Seed&0xffff ) retval = 0x7fff;
#ifdef _WIN32
__asm {
MOV eax,Seed
ROR eax,5
@ -289,6 +292,20 @@ static s32 __forceinline GetNoiseValues()
ROR eax,3
MOV Seed,eax
}
#else
__asm__ (
".intel_syntax\n"
"MOV %%eax,%0\n"
"ROR %%eax,5\n"
"XOR %%eax,0x9a\n"
"MOV %%ebx,%%eax\n"
"ROL %%eax,2\n"
"ADD %%eax,%%ebx\n"
"XOR %%eax,%%ebx\n"
"ROR %%eax,3\n"
"MOV %0,%%eax\n"
".att_syntax\n" : :"r"(Seed));
#endif
return retval;
}

View File

@ -19,7 +19,7 @@
*
*/
#include "spu2.h"
#include "Spu2.h"
void __fastcall ReadInput( uint core, StereoOut32& PData )
{

View File

@ -16,8 +16,8 @@
//Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
#include "SPU2.h"
#include "regtable.h"
#include "Spu2.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"};

View File

@ -16,19 +16,27 @@
//Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
#include "spu2.h"
#include "regtable.h"
#include "Spu2.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;
#ifdef __LINUX__
#define PCORE(c,p) \
U16P(Cores[c].p)
#define PVCP(c,v,p) \
PCORE(c,Voices[v].p)
#else
#define PCORE(c,p) \
U16P(Cores[c].##p)
#define PVCP(c,v,p) \
PCORE(c,Voices[v].##p)
#endif
#define PVC(c,v) \
PVCP(c,v,Volume.Left.Reg_VOL), \
@ -51,9 +59,15 @@ const u16 zero=0;
#define PRAW(a) \
((u16*)NULL)
#ifdef __LINUX__
#define PREVB_REG(c,n) \
PCORE(c,Revb.n)+1, \
PCORE(c,Revb.n)
#else
#define PREVB_REG(c,n) \
PCORE(c,Revb.##n)+1, \
PCORE(c,Revb.##n)
#endif
#pragma pack(1)
u16* regtable[0x800] =

View File

@ -19,7 +19,7 @@
*
*/
#include "spu2.h"
#include "Spu2.h"
static LPF_data lowpass_left( 11000, SampleRate );
static LPF_data lowpass_right( 11000, SampleRate );

View File

@ -19,7 +19,7 @@
*
*/
#include "SPU2.h"
#include "Spu2.h"
namespace Savestate {

View File

@ -19,7 +19,7 @@
*
*/
#include "spu2.h"
#include "Spu2.h"
StereoOut32 StereoOut32::Empty( 0, 0 );
@ -60,18 +60,30 @@ public:
s32 Init() { return 0; }
void Close() { }
s32 Test() const { return 0; }
#ifdef _MSC_VER
void Configure(HWND parent) { }
#else
void Configure(uptr parent) { }
#endif
bool Is51Out() const { return false; }
int GetEmptySampleCount() const { return 0; }
const wchar_t* GetIdent() const
{
#ifdef _MSC_VER
return _T("nullout");
#else
return ((wchar_t*)"nullout");
#endif
}
const wchar_t* GetLongName() const
{
#ifdef _MSC_VER
return _T("No Sound (Emulate SPU2 only)");
#else
return((wchar_t*)"No Sound (Emulate SPU2 only)");
#endif
}
} NullOut;
@ -352,7 +364,11 @@ s32 SndBuffer::Test()
return mods[OutputModule]->Test();
}
#ifdef _MSC_VER
void SndBuffer::Configure(HWND parent, u32 module )
#else
void SndBuffer::Configure(uptr parent, u32 module )
#endif
{
if( mods[module] == NULL )
return;

View File

@ -19,7 +19,7 @@
#define SNDOUT_H_INCLUDE
#include "BaseTypes.h"
#include "lowpass.h"
#include "Lowpass.h"
// Number of stereo samples per SndOut block.
// All drivers must work in units of this size when communicating with
@ -272,7 +272,12 @@ public:
static void Cleanup();
static void Write( const StereoOut32& Sample );
static s32 Test();
#ifdef _MSC_VER
static void Configure(HWND parent, u32 module );
#else
static void Configure(uptr parent, u32 module );
#endif
// Note: When using with 32 bit output buffers, the user of this function is responsible
// for shifting the values to where they need to be manually. The fixed point depth of
@ -347,7 +352,11 @@ public:
virtual s32 Init()=0;
virtual void Close()=0;
virtual s32 Test() const=0;
#ifdef _MSC_VER
virtual void Configure(HWND parent)=0;
#else
virtual void Configure(uptr parent)=0;
#endif
virtual bool Is51Out() const=0;
// Returns the number of empty samples in the output buffer.

View File

@ -21,15 +21,20 @@
#include "Spu2.h"
#include "regtable.h"
#include "RegTable.h"
#ifdef __LINUX__
#include "Linux.h"
#endif
void StartVoices(int core, u32 value);
void StopVoices(int core, u32 value);
void InitADSR();
#ifdef _MSC_VER
DWORD CALLBACK TimeThread(PVOID /* unused param */);
#endif
// [Air]: fixed the hacky part of UpdateTimer with this:
bool resetClock = true;
@ -48,9 +53,6 @@ s32 uTicks;
u8 callirq;
HANDLE hThreadFunc;
u32 ThreadFuncID;
V_CoreDebug DebugCores[2];
V_Core Cores[2];
V_SPDIF Spdif;
@ -68,9 +70,12 @@ int PlayMode;
s16 attrhack[2]={0,0};
#ifdef _MSC_VER
HINSTANCE hInstance;
CRITICAL_SECTION threadSync;
HANDLE hThreadFunc;
u32 ThreadFuncID;
#endif
bool has_to_call_irq=false;
@ -79,6 +84,7 @@ void SetIrqCall()
has_to_call_irq=true;
}
#ifdef _MSC_VER
void SysMessage(const char *fmt, ...)
{
va_list list;
@ -91,6 +97,9 @@ void SysMessage(const char *fmt, ...)
swprintf_s(wtmp, _T("%S"), tmp);
MessageBox(0, wtmp, _T("SPU2-X System Message"), 0);
}
#else
extern void SysMessage(const char *fmt, ...);
#endif
__forceinline s16 * __fastcall GetMemPtr(u32 addr)
{

View File

@ -25,6 +25,14 @@
#include "BaseTypes.h"
#include "PS2Edefs.h"
#ifdef __LINUX__
#include <stdio.h>
#include <string.h>
//Until I get around to putting in Linux svn code, this is an unknown svn version.
#define SVN_REV_UNKNOWN
#endif
namespace VersionInfo
{
static const u8 PluginApi = PS2E_SPU2_VERSION;
@ -32,8 +40,11 @@ namespace VersionInfo
static const u8 Revision = 0; // increase that with each version
}
#define EXPORT_C_(type) extern "C" __declspec(dllexport) type __stdcall
#ifdef _MSC_VER
#define EXPORT_C_(type) extern "C" __declspec(dllexport) type CALLBACK
#else
#define EXPORT_C_(type) extern "C" type
#endif
// We have our own versions that have the DLLExport attribute configured:
@ -76,17 +87,17 @@ EXPORT_C_(s32) SPU2test();
//#define EFFECTS_DUMP
//Plugin parts
#include "config.h"
#include "Config.h"
#include "defs.h"
#include "regs.h"
#include "dma.h"
#include "sndout.h"
#include "Dma.h"
#include "SndOut.h"
#include "spu2replay.h"
#include "Spu2replay.h"
#define SPU2_LOG
#include "debug.h"
#include "Debug.h"
//--------------------------------------------------------------------------------------
// Helper macros

View File

@ -18,7 +18,7 @@
#include <stdio.h>
#include "spu2.h"
#include "Spu2.h"
FILE* s2rfile;
@ -114,6 +114,7 @@ void dummy7()
#define Cread(a,b,c,d) if(fread(a,b,c,d)<b) break;
#ifdef _MSC_VER
void CALLBACK s2r_replay(HWND hwnd, HINSTANCE hinst, LPSTR filename, int nCmdShow)
{
// load file
@ -190,3 +191,4 @@ void CALLBACK s2r_replay(HWND hwnd, HINSTANCE hinst, LPSTR filename, int nCmdSho
replay_mode=false;
}
#endif

View File

@ -27,8 +27,12 @@ void s2r_writedma4(u32 ticks,u16*data,u32 len);
void s2r_writedma7(u32 ticks,u16*data,u32 len);
void s2r_close();
#ifdef _MSC_VER
// s2r playing
void CALLBACK s2r_replay(HWND hwnd, HINSTANCE hinst, LPSTR filename, int nCmdShow);
#else
#define s2r_replay 0&&
#endif
extern bool replay_mode;

View File

@ -19,7 +19,7 @@
*
*/
#include "spu2.h"
#include "Spu2.h"
#include "SoundTouch/SoundTouch.h"
#include "SoundTouch/WavFile.h"

View File

@ -19,7 +19,7 @@
#include <stdexcept>
#include <new>
#include "spu2.h"
#include "Spu2.h"
#include "SoundTouch/WavFile.h"

View File

@ -0,0 +1,36 @@
#!/bin/sh
curdir=`pwd`
echo -----------------
echo Building SPU2-X
echo -----------------
if test "${SPU2XOPTIONS+set}" != set ; then
export SPU2XOPTIONS=""
fi
echo SPU2-X is Windows only. Aborting.
if [ 1 == 0 ]
then
if [ $# -gt 0 ] && [ $1 = "all" ]
then
aclocal
automake -a
autoconf
./configure ${SPU2XOPTIONS} --prefix=${PCSX2PLUGINS}
make clean
make install
else
make $@
fi
if [ $? -ne 0 ]
then
exit 1
fi
#cp libSPU2X*.so* ${PCSX2PLUGINS}
fi

View File

@ -0,0 +1,117 @@
AC_INIT(SPU2X, 0.1,Jake.Stine@gmail.com)
AM_INIT_AUTOMAKE(SPU2X,0.1)
AC_PROG_CC([gcc g++ cl KCC CC cxx cc++ xlC aCC c++])
AC_PROG_CXX([gcc g++ cl KCC CC cxx cc++ xlC aCC c++])
AC_PROG_CPP([gcc g++ cl KCC CC cxx cc++ xlC aCC c++])
AC_PROG_INSTALL
AC_PROG_RANLIB
dnl necessary for compiling assembly
AM_PROG_AS
SPU2X_CURRENT=0
SPU2X_REVISION=1
SPU2X_AGE=0
SPU2X_SONAME=libSPU2X.so.[$SPU2X_CURRENT].[$SPU2X_REVISION].[$SPU2X_AGE]
SPU2X_RELEASE=[$SPU2X_CURRENT].[$SPU2X_REVISION].[$SPU2X_AGE]
AC_SUBST(SPU2X_CURRENT)
AC_SUBST(SPU2X_REVISION)
AC_SUBST(SPU2X_AGE)
AC_SUBST(SPU2X_RELEASE)
AC_SUBST(SPU2X_SONAME)
CFLAGS=
CPPFLAGS=
CXXFLAGS=
dnl Check for debug build
AC_MSG_CHECKING(debug build)
AC_ARG_ENABLE(debug, AC_HELP_STRING([--enable-debug], [debug build]),
debug=$enableval,debug=no)
if test "x$debug" == xyes
then
AC_DEFINE(_DEBUG,1,[_DEBUG])
CFLAGS+="-g -fPIC -Wall -Wno-unused-value "
CPPFLAGS+="-g -fPIC -Wall -Wno-unused-value "
CXXFLAGS+="-g -fPIC -Wall -Wno-unused-value "
else
AC_DEFINE(NDEBUG,1,[NDEBUG])
CFLAGS+="-O3 -fomit-frame-pointer -fPIC -Wall -Wno-unused-value "
CPPFLAGS+="-O3 -fomit-frame-pointer -fPIC -Wall -Wno-unused-value "
CXXFLAGS+="-O3 -fomit-frame-pointer -fPIC -Wall -Wno-unused-value "
fi
AM_CONDITIONAL(DEBUGBUILD, test x$debug = xyes)
AC_MSG_RESULT($debug)
AC_DEFINE(__LINUX__,1,[__LINUX__])
dnl Check for dev build
AC_MSG_CHECKING(for development build...)
AC_ARG_ENABLE(devbuild, AC_HELP_STRING([--enable-devbuild], [Special Build for developers that simplifies testing and adds extra checks]),
devbuild=$enableval,devbuild=no)
if test "x$devbuild" == xyes
then
AC_DEFINE(SPU2X_DEVBUILD,1,[SPU2X_DEVBUILD])
fi
AC_MSG_RESULT($devbuild)
AM_CONDITIONAL(RELEASE_TO_PUBLIC, test x$devbuild = xno)
AC_CHECK_FUNCS([ _aligned_malloc _aligned_free ], AC_DEFINE(HAVE_ALIGNED_MALLOC))
dnl gtk
AC_MSG_CHECKING(gtk2+)
AC_CHECK_PROG(GTK_CONFIG, pkg-config, pkg-config)
LIBS+=$(pkg-config --libs gtk+-2.0)
dnl bindir = pcsx2exe
dnl Check for 64bit CPU
AC_MSG_CHECKING(for a x86-64 CPU)
dnl if test "$build_os" == "target_os"
dnl then
AC_TRY_RUN([
int main()
{
int a = 0;
int*pa = &a;
asm(".intel_syntax\n"
"mov %%rax, %0\n"
"mov %%eax, [%%rax]\n"
".att_syntax\n"
: : "r"(pa) : "%rax");
return 0;
}
],cpu64=yes,cpu64=no,)
dnl else
dnl cpu64=no
dnl fi
if test "x$cpu64" == xyes
then
AC_DEFINE(__x86_64__,1,[__x86_64__])
fi
AC_MSG_RESULT($cpu64)
AM_CONDITIONAL(X86_64, test x$cpu64 = xyes)
dnl assuming linux environment
so_ext=".so.$SPU2X_RELEASE"
SHARED_LDFLAGS="-shared"
AC_SUBST(so_ext)
AC_SUBST(SHARED_LDFLAGS)
AC_CHECK_FUNCS(iconv, [ have_iconv="1" ], [ have_iconv="0" ])
AC_CHECK_LIB(stdc++,main,[LIBS="$LIBS -lstdc++"])
AC_CHECK_LIB(dl,main,[LIBS="$LIBS -ldl"])
AC_CHECK_LIB(asound,main,[LIBS="$LIBS -lasound"])
AC_OUTPUT([
3rdparty/SoundTouch/Makefile
Makefile
])
echo "Configuration:"
echo " Debug build? $debug"
echo " Dev build? $devbuild"

View File

@ -427,5 +427,17 @@ extern s16 InputPos;
// SPU Mixing Cycles ("Ticks mixed" counter)
extern u32 Cycles;
#ifdef __LINUX__
#include <sys/types.h>
#include <sys/timeb.h>
static __forceinline u32 timeGetTime()
{
struct timeb t;
ftime(&t);
return (u32)(t.time*1000+t.millitm);
}
#endif
#endif // DEFS_H_INCLUDED //

View File

@ -280,7 +280,7 @@ static int convert_string(const char *fromcode, const char *tocode,
if (ret != -1)
return ret;
s = malloc(fromlen + 1);
s = (char*)malloc(fromlen + 1);
if (!s)
return -1;
strcpy(s, from);
@ -297,7 +297,7 @@ int utf8_encode(const char *from, char **to)
if (!current_charset)
convert_set_charset(0);
charset = current_charset ? current_charset : "US-ASCII";
charset = current_charset ? current_charset : (char *)"US-ASCII";
return convert_string(charset, "UTF-8", from, to, '#');
}
@ -306,14 +306,14 @@ int utf8_decode(const char *from, char **to)
char *charset;
if(*from == 0) {
*to = malloc(1);
*to = (char*)malloc(1);
**to = 0;
return 1;
}
if (!current_charset)
convert_set_charset(0);
charset = current_charset ? current_charset : "US-ASCII";
charset = current_charset ? current_charset : (char*)"US-ASCII";
return convert_string("UTF-8", charset, from, to, '?');
}