assorted housekeeping: gocha's spu streaming patch for all platforms, driver system, copyrights, credits, wav writer in, sndfile spu core out (wav writer is better, it will need to be added to ports)

This commit is contained in:
zeromus 2009-05-27 06:46:58 +00:00
parent e81787b703
commit df666957da
28 changed files with 549 additions and 714 deletions

View File

@ -7,11 +7,6 @@ Current team
Guillaume Duhamel
Normmatt
Bernat Muñoz (shash)
thoduv
Tim Seidel (Mighty Max)
Pascal Giard (evilynux)
Ben Jaques (masscat)
Jeff Bland
Riccardo Magliocchetti
Max Tabachenko (CrazyMax)
zeromus
@ -19,6 +14,7 @@ Luigi__
adelikat
matusz
pa__
gocha
Contributors
------------
@ -31,3 +27,15 @@ delfare
Romain Vallet
snkmad
Theo Berkau
thoduv
Tim Seidel (Mighty Max)
Pascal Giard (evilynux)
Ben Jaques (masscat)
Jeff Bland
Thanks to our super testers for this release
------------
nash679
pokefan999
dottorleo
lbalbalba

View File

@ -1596,16 +1596,15 @@ void NDS_SkipNextFrame() { SkipNext2DFrame = true; SkipCur3DFrame = true; }
template<bool FORCE>
u32 NDS_exec(s32 nb)
void NDS_exec(s32 nb)
{
int i, j;
nb = 560190<<1;
LagFrameFlag=1;
//increase this to execute more instructions in each batch (reducing overhead)
//the value of 4 seems to optimize speed.. do lower values increase precision?
//answer: YES, MAYBE. and after 0.9.3 we need to study it (spider-man)
const int INSTRUCTIONS_PER_BATCH = 4;
//decreasing this should increase precision at the cost of speed
@ -1733,7 +1732,9 @@ u32 NDS_exec(s32 nb)
T1WriteWord(MMU.ARM7_REG, 4, T1ReadWord(MMU.ARM7_REG, 4) | 2);
NDS_ARM9HBlankInt();
NDS_ARM7HBlankInt();
SPU_Emulate_core();
driver->AVI_SoundUpdate(SPU_core->outbuf,spu_core_samples);
WAV_WavSoundUpdate(SPU_core->outbuf,spu_core_samples);
if(nds.VCount<192)
{
if(!SkipCur2DFrame)
@ -2421,8 +2422,6 @@ u32 NDS_exec(s32 nb)
lastLag = lagframecounter;
lagframecounter = 0;
}
return nds.cycles;
}
static std::string MakeInputDisplayString(u16 pad, const std::string* Buttons, int count) {
@ -2640,5 +2639,5 @@ void emu_halt() {
}
//these templates needed to be instantiated manually
template u32 NDS_exec<FALSE>(s32 nb);
template u32 NDS_exec<TRUE>(s32 nb);
template void NDS_exec<FALSE>(s32 nb);
template void NDS_exec<TRUE>(s32 nb);

View File

@ -2,6 +2,8 @@
yopyop156@ifrance.com
yopyop156.ifrance.com
Copyright (C) 2008-2009 DeSmuME team
This file is part of DeSmuME
DeSmuME is free software; you can redistribute it and/or modify
@ -16,7 +18,7 @@
You should have received a copy of the GNU General Public License
along with DeSmuME; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
#ifndef NDSSYSTEM_H
@ -25,10 +27,9 @@
#include <string.h>
#include "armcpu.h"
#include "MMU.h"
#include "driver.h"
#include "GPU.h"
#include "SPU.h"
#include "mem.h"
#include "wifi.h"
@ -290,13 +291,10 @@ void NDS_Sleep();
void NDS_SkipNextFrame();
#define NDS_SkipFrame(s) if(s) NDS_SkipNext2DFrame();
template<bool FORCE>
u32 NDS_exec(s32 nb);
template<bool FORCE> void NDS_exec(s32 nb = 560190<<1);
extern int lagframecounter;
inline u32 NDS_exec(s32 nb) { return NDS_exec<false>(nb); }
static INLINE void NDS_ARM9HBlankInt(void)
{
if(T1ReadWord(ARM9Mem.ARM9_REG, 4) & 0x10)
@ -388,17 +386,7 @@ extern struct TCommonSettings {
extern char ROMserial[20];
//this should be moved to a driver.h later, but for now, here they are.
//each platform needs to implement this, although it doesnt need to implement any functions
class Driver {
public:
virtual BOOL WIFI_Host_InitSystem() { return FALSE; }
virtual void WIFI_Host_ShutdownSystem() {}
virtual BOOL AVI_IsRecording() { return FALSE; }
virtual BOOL WAV_IsRecording() { return FALSE; }
virtual void USR_InfoMessage(const char *message) { printf("%s\n", message); }
};
extern Driver* driver;
extern std::string InputDisplayString;
extern int LagFrameFlag;

View File

@ -1,22 +1,26 @@
/* Copyright (C) 2006 Theo Berkau
/* Copyright (C) 2006 yopyop
yopyop156@ifrance.com
yopyop156.ifrance.com
Copyright (C) 2006 Theo Berkau
Copyright (C) 2008-2009 DeSmuME team
Ideas borrowed from Stephane Dallongeville's SCSP core
Ideas borrowed from Stephane Dallongeville's SCSP core
This file is part of DeSmuME
This file is part of DeSmuME
DeSmuME is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
DeSmuME is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
DeSmuME 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 General Public License for more details.
DeSmuME 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 General Public License for more details.
You should have received a copy of the GNU General Public License
along with DeSmuME; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
You should have received a copy of the GNU General Public License
along with DeSmuME; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
#include <stdlib.h>
@ -24,6 +28,9 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
#define _USE_MATH_DEFINES
#include <math.h>
#ifndef M_PI
#define M_PI 3.1415926535897932386
#endif
#include "debug.h"
#include "ARM9.h"
@ -93,7 +100,7 @@ static const s16 wavedutytbl[8][8] = {
static s32 precalcdifftbl[89][16];
static u8 precalcindextbl[89][8];
static FILE *spufp=NULL;
static const double ARM7_CLOCK = 33513982;
//////////////////////////////////////////////////////////////////////////////
@ -454,8 +461,7 @@ void SPU_struct::ShutUp()
static FORCEINLINE void adjust_channel_timer(channel_struct *chan)
{
//chan->sampinc = (((double)33512000) / (44100 * 2)) / (double)(0x10000 - chan->timer);
chan->sampinc = (16777216 / (0x10000 - (double)chan->timer)) / 44100;
chan->sampinc = (((double)ARM7_CLOCK) / (44100 * 2)) / (double)(0x10000 - chan->timer);
}
void SPU_struct::KeyOn(int channel)
@ -669,7 +675,7 @@ template<SPUInterpolationMode INTERPOLATE_MODE> static FORCEINLINE s32 Interpola
{
//why did we change it away from the lookup table? somebody should research that
ratio = ratio - (int)ratio;
double ratio2 = ((1.0 - cos(ratio * 3.14)) * 0.5);
double ratio2 = ((1.0 - cos(ratio * M_PI)) * 0.5);
//double ratio2 = (1.0f - cos_lut[((int)(ratio*256.0))&0xFF]) / 2.0f;
return (((1-ratio2)*a) + (ratio2*b));
}
@ -823,7 +829,9 @@ template<int FORMAT> static FORCEINLINE void TestForLoop(SPU_struct *SPU, channe
// Do we loop? Or are we done?
if (chan->repeat == 1)
{
chan->sampcnt = (double)(chan->loopstart << shift); // Is this correct?
while (chan->sampcnt > chan->double_totlength_shifted)
chan->sampcnt -= chan->double_totlength_shifted - (double)(chan->loopstart << shift);
//chan->sampcnt = (double)(chan->loopstart << shift);
}
else
{
@ -845,7 +853,9 @@ static FORCEINLINE void TestForLoop2(SPU_struct *SPU, channel_struct *chan)
// Do we loop? Or are we done?
if (chan->repeat == 1)
{
chan->sampcnt = (double)(chan->loopstart << 3); // Is this correct?
while (chan->sampcnt > chan->double_totlength_shifted)
chan->sampcnt -= chan->double_totlength_shifted - (double)(chan->loopstart << 3);
//chan->sampcnt = (double)(chan->loopstart << 3);
chan->pcm16b = (s16)((chan->buf8[1] << 8) | chan->buf8[0]);
chan->index = chan->buf8[2] & 0x7F;
chan->lastsampcnt = 7;
@ -999,9 +1009,9 @@ static void SPU_MixAudio(SPU_struct *SPU, int length)
//emulates one frame of the cpu core.
//this will produce a variable number of samples, calculated to keep a 44100hz output
//in sync with the emulator framerate
static float samples = 0;
static const float time_per_frame = 1.0f/59.8261f;
static const float samples_per_frame = time_per_frame * 44100;
static double samples = 0;
static const double time_per_frame = (double)1.0/((double)ARM7_CLOCK/6/355); //(double)1.0/(double)59.8261; // ((double)ARM7_CLOCK/6/355/263)
static const double samples_per_frame = time_per_frame * 44100;
int spu_core_samples = 0;
void SPU_Emulate_core()
{
@ -1103,30 +1113,6 @@ void SNDDummySetVolume(int volume)
{
}
//////////////////////////////////////////////////////////////////////////////
// WAV Write Interface
//////////////////////////////////////////////////////////////////////////////
int SNDFileInit(int buffersize);
void SNDFileDeInit();
void SNDFileUpdateAudio(s16 *buffer, u32 num_samples);
u32 SNDFileGetAudioSpace();
void SNDFileMuteAudio();
void SNDFileUnMuteAudio();
void SNDFileSetVolume(int volume);
SoundInterface_struct SNDFile = {
SNDCORE_FILEWRITE,
"WAV Write Sound Interface",
SNDFileInit,
SNDFileDeInit,
SNDFileUpdateAudio,
SNDFileGetAudioSpace,
SNDFileMuteAudio,
SNDFileUnMuteAudio,
SNDFileSetVolume
};
//////////////////////////////////////////////////////////////////////////////
typedef struct {
@ -1149,17 +1135,19 @@ typedef struct {
u16 bitspersample;
} fmt_struct;
//////////////////////////////////////////////////////////////////////////////
int SNDFileInit(int buffersize)
WavWriter::WavWriter()
: spufp(NULL)
{
}
bool WavWriter::open(const std::string & fname)
{
waveheader_struct waveheader;
fmt_struct fmt;
chunk_struct data;
size_t elems_written = 0;
if ((spufp = fopen("ndsaudio.wav", "wb")) == NULL)
return -1;
if ((spufp = fopen(fname.c_str(), "wb")) == NULL)
return false;
// Do wave header
memcpy(waveheader.riff.id, "RIFF", 4);
@ -1183,66 +1171,71 @@ int SNDFileInit(int buffersize)
data.size = 0; // we'll fix this at the end
elems_written += fwrite((void *)&data, 1, sizeof(chunk_struct), spufp);
return 0;
return true;
}
//////////////////////////////////////////////////////////////////////////////
void SNDFileDeInit()
void WavWriter::close()
{
if(!spufp) return;
size_t elems_written = 0;
if (spufp)
{
long length = ftell(spufp);
long length = ftell(spufp);
// Let's fix the riff chunk size and the data chunk size
fseek(spufp, sizeof(waveheader_struct)-0x8, SEEK_SET);
length -= 0x8;
elems_written += fwrite((void *)&length, 1, 4, spufp);
// Let's fix the riff chunk size and the data chunk size
fseek(spufp, sizeof(waveheader_struct)-0x8, SEEK_SET);
length -= 0x8;
elems_written += fwrite((void *)&length, 1, 4, spufp);
fseek(spufp, sizeof(waveheader_struct)+sizeof(fmt_struct)+0x4, SEEK_SET);
length -= sizeof(waveheader_struct)+sizeof(fmt_struct);
elems_written += fwrite((void *)&length, 1, 4, spufp);
fclose(spufp);
}
fseek(spufp, sizeof(waveheader_struct)+sizeof(fmt_struct)+0x4, SEEK_SET);
length -= sizeof(waveheader_struct)+sizeof(fmt_struct);
elems_written += fwrite((void *)&length, 1, 4, spufp);
fclose(spufp);
spufp = NULL;
}
//////////////////////////////////////////////////////////////////////////////
void SNDFileUpdateAudio(s16 *buffer, u32 num_samples)
void WavWriter::update(void* soundData, int numSamples)
{
size_t elems_written;
if (spufp) {
elems_written = fwrite((void *)buffer, num_samples*2, 2, spufp);
//INFO("%i written\n", elems_written);
}
if(!spufp) return;
//TODO - big endian for the s16 samples??
size_t elems_written = fwrite(soundData, numSamples*2, 2, spufp);
}
//////////////////////////////////////////////////////////////////////////////
u32 SNDFileGetAudioSpace()
bool WavWriter::isRecording() const
{
return 740;
return spufp != NULL;
}
//////////////////////////////////////////////////////////////////////////////
void SNDFileMuteAudio()
static WavWriter wavWriter;
void WAV_End()
{
wavWriter.close();
}
//////////////////////////////////////////////////////////////////////////////
void SNDFileUnMuteAudio()
bool WAV_Begin(const char* fname)
{
WAV_End();
if(!wavWriter.open(fname))
return false;
driver->USR_InfoMessage("WAV recording started.");
return true;
}
//////////////////////////////////////////////////////////////////////////////
void SNDFileSetVolume(int volume)
bool WAV_IsRecording()
{
return wavWriter.isRecording();
}
void WAV_WavSoundUpdate(void* soundData, int numSamples)
{
wavWriter.update(soundData, numSamples);
}
//////////////////////////////////////////////////////////////////////////////
void spu_savestate(std::ostream* os)

View File

@ -1,4 +1,7 @@
/* Copyright (C) 2006 Theo Berkau
/* SPU.h
Copyright 2006 Theo Berkau
Copyright (C) 2006-2009 DeSmuME team
This file is part of DeSmuME
@ -14,7 +17,7 @@
You should have received a copy of the GNU General Public License
along with DeSmuME; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
#ifndef SPU_H
@ -22,10 +25,10 @@
#include "types.h"
#include <iosfwd>
#include <string>
#define SNDCORE_DEFAULT -1
#define SNDCORE_DUMMY 0
#define SNDCORE_FILEWRITE 1
enum SPUInterpolationMode
{
@ -132,4 +135,22 @@ extern int spu_core_samples;
void spu_savestate(std::ostream* os);
bool spu_loadstate(std::istream* is, int size);
class WavWriter
{
public:
WavWriter();
bool open(const std::string & fname);
void close();
void update(void* soundData, int numSamples);
bool isRecording() const;
private:
FILE *spufp;
};
void WAV_End();
bool WAV_Begin(const char* fname);
bool WAV_IsRecording();
void WAV_WavSoundUpdate(void* soundData, int numSamples);
#endif

View File

@ -877,4 +877,4 @@ cflash_close( void) {
}
}
#endif
#endif

View File

@ -81,7 +81,7 @@ static int sdl_videoFlags = 0;
SoundInterface_struct *SNDCoreList[] = {
&SNDDummy,
&SNDFile,
&SNDDummy,
&SNDSDL,
NULL
};
@ -618,7 +618,6 @@ Draw( void) {
int main(int argc, char ** argv) {
static unsigned short keypad = 0;
struct my_config my_config;
u32 last_cycle = 0;
#ifdef GDB_STUB
gdbstub_handle_t arm9_gdb_stub;
gdbstub_handle_t arm7_gdb_stub;
@ -852,9 +851,8 @@ int main(int argc, char ** argv) {
}
update_keypad(keypad); /* Update keypad */
last_cycle = NDS_exec<false>((560190 << 1) - last_cycle);
NDS_exec<false>();
SPU_Emulate_user();
SPU_Emulate_core();
#ifdef INCLUDE_OPENGL_2D
if ( my_config.opengl_2d) {

View File

@ -1,8 +1,8 @@
/* Copyright (C) 2006 yopyop
yopyop156@ifrance.com
yopyop156.ifrance.com
yopyop156.ifrance.com
Copyright (C) 2008-2009 DeSmuME team
Copyright (C) 2008-2009 DeSmuME team
This file is part of DeSmuME
@ -23,7 +23,7 @@
//This file implements the geometry engine hardware component.
//This handles almost all of the work of 3d rendering, leaving the renderer
// plugin responsible only for drawing primitives.
//plugin responsible only for drawing primitives.
#include <algorithm>
#include <assert.h>

View File

@ -116,9 +116,8 @@ INLINE void desmume_cycle()
/* Update keypad value */
update_keypad(keypad);
desmume_last_cycle = NDS_exec<false>((560190 << 1) - desmume_last_cycle);
NDS_exec<false>();
SPU_Emulate_user();
SPU_Emulate_core();
}

View File

@ -64,7 +64,7 @@ const u16 gtk_kb_cfg[NB_KEYS] =
SoundInterface_struct *SNDCoreList[] = {
&SNDDummy,
&SNDFile,
&SNDDummy,
&SNDSDL,
NULL
};

View File

@ -74,7 +74,6 @@ BOOL desmume_running( void)
void desmume_cycle( void)
{
static u32 desmume_last_cycle;
u16 keypad;
/* Joystick events */
@ -85,8 +84,7 @@ void desmume_cycle( void)
/* Update keypad value */
update_keypad(keypad);
desmume_last_cycle = NDS_exec<false>((560190 << 1) - desmume_last_cycle);
NDS_exec<false>();
SPU_Emulate_user();
SPU_Emulate_core();
}

View File

@ -302,7 +302,7 @@ static const GtkRadioActionEntry savet_entries[] = {
SoundInterface_struct *SNDCoreList[] = {
&SNDDummy,
&SNDFile,
&SNDDummy,
&SNDSDL,
NULL
};

View File

@ -1,5 +1,6 @@
/* Copyright (C) 2006 thoduv
Copyright (C) 2006-2007 Theo Berkau
Copyright (C) 2008-2009 DeSmuME team
This file is part of DeSmuME

View File

@ -1,22 +1,22 @@
/* readwrite.cpp
*
* Copyright (C) 2006-2008 Zeromus
*
* This file is part of DeSmuME
*
* DeSmuME is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* DeSmuME 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with DeSmuME; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
/* readwrite.cpp
Copyright (C) 2006-2009 DeSmuME team
This file is part of DeSmuME
DeSmuME is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
DeSmuME 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 General Public License for more details.
You should have received a copy of the GNU General Public License
along with DeSmuME; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
#include "readwrite.h"
@ -170,4 +170,4 @@ int writebuffer(std::vector<u8>& vec, std::ostream* os)
write32le(size,os);
if(size>0) os->write((char*)&vec[0],size);
return 1;
}
}

View File

@ -1,22 +1,22 @@
/* guid.cpp
*
* Copyright (C) 2008 Zeromus
*
* This file is part of DeSmuME
*
* DeSmuME is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* DeSmuME 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with DeSmuME; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
/* guid.cpp
Copyright (C) 2008-2009 DeSmuME team
This file is part of DeSmuME
DeSmuME is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
DeSmuME 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 General Public License for more details.
You should have received a copy of the GNU General Public License
along with DeSmuME; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
#include <stdlib.h>

View File

@ -1,5 +1,6 @@
/*
Copyright (C) 2008 shash
/* AboutBox.cpp
Copyright (C) 2008-2009 shash
This file is part of DeSmuME
@ -15,7 +16,7 @@
You should have received a copy of the GNU General Public License
along with DeSmuME; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
@ -26,36 +27,52 @@
#define ABOUT_TIMER_ID 110222
#define PER_PAGE_TEAM 23
#define TEAM 27
#define SIZE_SCROLL_BUFFER PER_PAGE_TEAM + TEAM
const char *team[TEAM] = { "Guillaume Duhamel",
"Normmatt",
"Bernat Muñoz (shash)",
"thoduv",
"Tim Seidel (Mighty Max)",
"Pascal Giard (evilynux)",
"Ben Jaques (masscat)",
"Jeff Bland",
"Riccardo Magliocchetti",
"Max Tabachenko (CrazyMax)",
"zeromus",
"Luigi__",
"adelikat",
"matusz",
"pa__",
"",
"Contributors",
"------------",
"Allustar",
"amponzi",
"Anthony Molinaro",
"ape",
"Damien Nozay (damdoum)",
"delfare",
"Romain Vallet",
"snkmad",
"Theo Berkau"};
const char *team[] = {
"Current Team",
"------------",
"Guillaume Duhamel",
"Normmatt",
"Bernat Muñoz (shash)",
"Riccardo Magliocchetti",
"Max Tabachenko (CrazyMax)",
"zeromus",
"Luigi__",
"adelikat",
"matusz",
"pa__",
"gocha",
"",
"Contributors",
"------------",
"Allustar",
"amponzi",
"Anthony Molinaro",
"ape",
"Damien Nozay (damdoum)",
"delfare",
"Romain Vallet",
"snkmad",
"Theo Berkau",
"thoduv",
"Tim Seidel (Mighty Max)",
"Pascal Giard (evilynux)",
"Ben Jaques (masscat)",
"Jeff Bland",
"",
"Honorary Nagmasters",
"(Thanks to our super testers for this release!)",
"------------",
"nash679",
"pokefan999",
"dottorleo",
"lbalbalba",
"",
"average time from bug checkin to bugreport:",
"23 seconds",
};
const int TEAM = ARRAY_SIZE(team);
u8 scroll_start;
u8 scroll_buffer[SIZE_SCROLL_BUFFER][255];

View File

@ -321,6 +321,10 @@
RelativePath=".\aviout.cpp"
>
</File>
<File
RelativePath=".\aviout.h"
>
</File>
<File
RelativePath=".\buildconfig.h"
>
@ -550,11 +554,7 @@
>
</File>
<File
RelativePath=".\wavout.cpp"
>
</File>
<File
RelativePath=".\wavout.h"
RelativePath=".\windriver.h"
>
</File>
<Filter
@ -813,10 +813,6 @@
RelativePath="..\debug.h"
>
</File>
<File
RelativePath=".\VTune\DeSmuME_VS2005.vpj"
>
</File>
<File
RelativePath="..\Disassembler.cpp"
>
@ -825,6 +821,10 @@
RelativePath="..\Disassembler.h"
>
</File>
<File
RelativePath="..\driver.h"
>
</File>
<File
RelativePath="..\dscard.h"
>

View File

@ -772,10 +772,6 @@
RelativePath=".\tileView.cpp"
>
</File>
<File
RelativePath=".\wavout.cpp"
>
</File>
</Filter>
</Filter>
<Filter
@ -910,10 +906,6 @@
RelativePath=".\tileView.h"
>
</File>
<File
RelativePath=".\wavout.h"
>
</File>
<Filter
Name="userconfig"
>
@ -974,6 +966,10 @@
RelativePath="..\Disassembler.h"
>
</File>
<File
RelativePath="..\driver.h"
>
</File>
<File
RelativePath="..\dscard.h"
>

View File

@ -1,28 +1,30 @@
/* aviout.cpp
*
* Copyright (C) 2006-2008 Zeromus
*
* This file is part of DeSmuME
*
* DeSmuME is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* DeSmuME 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with DeSmuME; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
/* aviout.cpp
Copyright (C) 2006-2009 DeSmuME team
This file is part of DeSmuME
DeSmuME is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
DeSmuME 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 General Public License for more details.
You should have received a copy of the GNU General Public License
along with DeSmuME; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
#include "main.h" //I added this so that this file could gain access to SetMessageToDisplay.
#include "main.h"
#include "types.h"
#include "windriver.h"
#include "console.h"
#include "gfx3d.h"
#include "aviout.h"
#include <assert.h>
#include <vfw.h>
@ -38,12 +40,6 @@ static void EMU_PrintMessage(const char* msg) {
LOG(msg);
}
bool DRV_AviBegin(const char* fname);
void DRV_AviEnd();
void DRV_AviSoundUpdate(void* soundData, int soundLen);
bool DRV_AviIsRecording();
void DRV_AviVideoUpdate(const u16* buffer);
//extern PALETTEENTRY *color_palette;
//extern WAVEFORMATEX wf;
//extern int soundo;
@ -414,7 +410,7 @@ void DRV_AviVideoUpdate(const u16* buffer)
AviNextSegment();
}
BOOL AVI_IsRecording()
bool AVI_IsRecording()
{
return avi_file && avi_file->valid;
}
@ -451,11 +447,3 @@ void DRV_AviEnd()
avi_destroy(&avi_file);
}
bool DRV_AviIsRecording()
{
if(avi_file)
return true;
return false;
}

View File

@ -1,5 +1,31 @@
/* aviout.h
Copyright (C) 2006-2009 DeSmuME team
This file is part of DeSmuME
DeSmuME is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
DeSmuME 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 General Public License for more details.
You should have received a copy of the GNU General Public License
along with DeSmuME; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
#ifndef _AVIOUT_H_
#define _AVIOUT_H_
bool DRV_AviBegin(const char* fname);
void DRV_AviEnd();
void DRV_AviSoundUpdate(void* soundData, int soundLen);
bool DRV_AviIsRecording();
void DRV_AviVideoUpdate(const u16* buffer);
bool AVI_IsRecording();
void DRV_AviVideoUpdate(const u16* buffer);
#endif

View File

@ -32,7 +32,7 @@
#include "ram_search.h" //In order to call UpdateRamSearch (for loadstate functions)
#include "replay.h"
#include "aviout.h"
#include "wavout.h"
#include "spu.h"
extern LRESULT OpenFile(); //adelikat: Made this an extern here instead of main.h Seemed icky not to limit the scope of this function
@ -178,8 +178,8 @@ void HK_AutoHoldClearKeyDown(int) {
void HK_Reset(int) {ResetGame();}
void HK_RecordAVI(int) { if (DRV_AviIsRecording()) AviEnd(); else AviRecordTo(); }
void HK_RecordWAV(int) { if (DRV_WavIsRecording()) WavEnd(); else WavRecordTo(); }
void HK_RecordAVI(int) { if (AVI_IsRecording()) AviEnd(); else AviRecordTo(); }
void HK_RecordWAV(int) { if (WAV_IsRecording()) WavEnd(); else WavRecordTo(); }
void HK_ToggleFrame(int) {frameCounterDisplay ^= true;}
void HK_ToggleFPS(int) {FpsDisplay ^= true;}

View File

@ -1,25 +1,25 @@
/* Copyright (C) 2006 yopyop
yopyop156@ifrance.com
yopyop156.ifrance.com
/* aviout.cpp
Copyright 2006 Theo Berkau
Copyright 2006 Theo Berkau
Copyright (C) 2006-2009 DeSmuME team
This file is part of DeSmuME
This file is part of DeSmuME
DeSmuME is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
DeSmuME is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
DeSmuME 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 General Public License for more details.
DeSmuME 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 General Public License for more details.
You should have received a copy of the GNU General Public License
along with DeSmuME; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
You should have received a copy of the GNU General Public License
along with DeSmuME; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
#include "windriver.h"
#include <algorithm>
#include <shellapi.h>
@ -80,7 +80,6 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
#include "ramwatch.h"
#include "ram_search.h"
#include "aviout.h"
#include "wavout.h"
#include "soundView.h"
#include "directx/ddraw.h"
@ -242,7 +241,6 @@ int sndvolume=100;
SoundInterface_struct *SNDCoreList[] = {
&SNDDummy,
&SNDFile,
&SNDDIRECTX,
NULL
};
@ -1159,25 +1157,10 @@ DWORD WINAPI run()
{
Lock lock;
NDS_exec(0);
NDS_exec<false>();
win_sound_samplecounter = 735;
}
SPU_Emulate_core();
//we are driving the dsound output from another thread
//but there is no thread for the filewriter. so we need to do it here
if(sndcoretype == SNDCORE_FILEWRITE)
SPU_Emulate_user();
//avi writing
DRV_AviSoundUpdate(SPU_core->outbuf,spu_core_samples);
DRV_AviVideoUpdate((u16*)GPU_screen);
//wav writing
DRV_WavSoundUpdate(SPU_core->outbuf,spu_core_samples);
// if (!skipnextframe)
// {
static int fps3d = 0;
@ -1192,7 +1175,7 @@ DWORD WINAPI run()
osd->addFixed(Hud.FrameCounter.x, Hud.FrameCounter.y, "%d (no movie)",currFrameCounter);
}
if(!DRV_AviIsRecording()) osd->update();
if(!AVI_IsRecording()) osd->update();
Display();
osd->clear();
@ -1572,11 +1555,9 @@ static void ExitRunLoop()
emu_halt();
}
BOOL AVI_IsRecording();
BOOL WAV_IsRecording();
class WinDriver : public Driver
{
virtual BOOL WIFI_Host_InitSystem() {
virtual bool WIFI_Host_InitSystem() {
#ifdef EXPERIMENTAL_WIFI
//require winsock initialization
WSADATA wsaData ;
@ -1584,18 +1565,18 @@ class WinDriver : public Driver
if (WSAStartup(version,&wsaData))
{
printf("Failed initializing WSAStartup - softAP support disabled\n");
return FALSE ;
return false ;
}
//require wpcap.dll
HMODULE temp = LoadLibrary("wpcap.dll");
if(temp == NULL) {
printf("Failed initializing wpcap.dll - softAP support disabled\n");
return FALSE;
return false;
}
FreeLibrary(temp);
return TRUE;
return true;
#else
return FALSE ;
return false ;
#endif
}
virtual void WIFI_Host_ShutdownSystem() {
@ -1604,20 +1585,25 @@ class WinDriver : public Driver
#endif
}
virtual BOOL AVI_IsRecording()
virtual bool AVI_IsRecording()
{
return ::AVI_IsRecording();
}
virtual BOOL WAV_IsRecording()
virtual bool WAV_IsRecording()
{
return ::WAV_IsRecording();
}
virtual void USR_InfoMessage(const char *message)
{
LOG("%s\n", message);
SetMessageToDisplay(message);
}
virtual void AVI_SoundUpdate(void* soundData, int soundLen) {
::DRV_AviSoundUpdate(soundData, soundLen);
}
};
int WINAPI WinMain (HINSTANCE hThisInstance,
@ -1887,7 +1873,7 @@ int WINAPI WinMain (HINSTANCE hThisInstance,
EnableMenuItem (mainMenu, IDM_SUBMITBUGREPORT, MF_GRAYED);
#endif
LOG("Init sound core\n");
sndcoretype = GetPrivateProfileInt("Sound","SoundCore", SNDCORE_DIRECTX, IniName);
sndcoretype = GetPrivateProfileInt("Sound","SoundCore2", SNDCORE_DIRECTX, IniName);
sndbuffersize = GetPrivateProfileInt("Sound","SoundBufferSize", 735 * 4, IniName);
CommonSettings.spuInterpolationMode = (SPUInterpolationMode)GetPrivateProfileInt("Sound","SPUInterpolation", 1, IniName);
CommonSettings.spuAdpcmCache = GetPrivateProfileInt("Sound","SPUAdpcmCache",0,IniName)!=0;
@ -1973,7 +1959,7 @@ int WINAPI WinMain (HINSTANCE hThisInstance,
SaveRecentRoms();
NDS_DeInit();
DRV_AviEnd();
DRV_WavEnd();
WAV_End();
//------SHUTDOWN
@ -2333,7 +2319,7 @@ void AviRecordTo()
void WavEnd()
{
NDS_Pause();
DRV_WavEnd();
WAV_End();
NDS_UnPause();
}
@ -2380,7 +2366,7 @@ void WavRecordTo()
if(GetSaveFileName(&ofn))
{
DRV_WavBegin(szChoice);
WAV_Begin(szChoice);
}
NDS_UnPause();
@ -2641,11 +2627,11 @@ LRESULT CALLBACK WindowProcedure (HWND hwnd, UINT message, WPARAM wParam, LPARAM
//Check if AVI is recording
mii.cbSize = sizeof(MENUITEMINFO);
mii.fMask = MIIM_STRING;
LoadString(hAppInst, !DRV_AviIsRecording() ? IDM_FILE_RECORDAVI : IDM_FILE_STOPAVI, menuItemString, 256);
LoadString(hAppInst, !AVI_IsRecording() ? IDM_FILE_RECORDAVI : IDM_FILE_STOPAVI, menuItemString, 256);
mii.dwTypeData = menuItemString;
SetMenuItemInfo(mainMenu, IDM_FILE_RECORDAVI, FALSE, &mii);
//Check if WAV is recording
LoadString(hAppInst, !DRV_WavIsRecording() ? IDM_FILE_RECORDWAV : IDM_FILE_STOPWAV, menuItemString, 256);
LoadString(hAppInst, !AVI_IsRecording() ? IDM_FILE_RECORDWAV : IDM_FILE_STOPWAV, menuItemString, 256);
SetMenuItemInfo(mainMenu, IDM_FILE_RECORDWAV, FALSE, &mii);
//Menu items dependent on a ROM loaded
@ -2987,14 +2973,14 @@ LRESULT CALLBACK WindowProcedure (HWND hwnd, UINT message, WPARAM wParam, LPARAM
}
return 0;
case IDM_FILE_RECORDAVI:
if (DRV_AviIsRecording())
if (AVI_IsRecording())
AviEnd();
else
AviRecordTo();
break;
case IDM_FILE_RECORDWAV:
if (DRV_WavIsRecording())
WavEnd();
if (WAV_IsRecording())
WAV_End();
else
WavRecordTo();
break;
@ -4105,7 +4091,7 @@ LRESULT CALLBACK SoundSettingsDlgProc(HWND hDlg, UINT uMsg, WPARAM wParam, LPARA
// Write Sound core type
sndcoretype = SNDCoreList[SendDlgItemMessage(hDlg, IDC_SOUNDCORECB, CB_GETCURSEL, 0, 0)]->id;
sprintf(tempstr, "%d", sndcoretype);
WritePrivateProfileString("Sound", "SoundCore", tempstr, IniName);
WritePrivateProfileString("Sound", "SoundCore2", tempstr, IniName);
// Write Sound Buffer size
GetDlgItemText(hDlg, IDC_SOUNDBUFFERET, tempstr, 6);

View File

@ -1,22 +1,22 @@
/* ogl.cpp
*
* Copyright (C) 2006-2008 Zeromus
*
* This file is part of DeSmuME
*
* DeSmuME is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* DeSmuME 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with DeSmuME; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
/* ogl.cpp
Copyright (C) 2006-2009 DeSmuME team
This file is part of DeSmuME
DeSmuME is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
DeSmuME 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 General Public License for more details.
You should have received a copy of the GNU General Public License
along with DeSmuME; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
#define WIN32_LEAN_AND_MEAN

View File

@ -677,19 +677,18 @@ FONT 8, "MS Sans Serif"
LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US
IDD_ABOUT_BOX DIALOGEX 0, 0, 212, 298
IDD_ABOUT_BOX DIALOGEX 0, 0, 212, 288
STYLE DS_CENTER | DS_MODALFRAME | DS_SHELLFONT | WS_BORDER | WS_CAPTION | WS_DLGFRAME | WS_POPUP
CAPTION "About DeSmuME..."
FONT 8, "MS Shell Dlg", 400, 0, 1
{
CTEXT "", IDC_AUTHORS_LIST, 7, 75, 198, 188, SS_CENTER, WS_EX_CLIENTEDGE
DEFPUSHBUTTON "Close", IDC_FERMER, 86, 277, 50, 14, BS_DEFPUSHBUTTON
CTEXT "", IDC_AUTHORS_LIST, 7, 60, 198, 188, SS_CENTER, WS_EX_CLIENTEDGE
DEFPUSHBUTTON "Close", IDC_FERMER, 86, 267, 50, 14, BS_DEFPUSHBUTTON
CTEXT "DeSmuME", IDC_STATIC, 7, 7, 198, 10, SS_CENTER
CTEXT "version", IDC_TXT_VERSION, 7, 18, 198, 8, SS_CENTER
RTEXT "compiled", IDC_TXT_COMPILED, 7, 265, 198, 8, SS_RIGHT
RTEXT "compiled", IDC_TXT_COMPILED, 7, 255, 198, 8, SS_RIGHT
CTEXT "Original author", IDC_STATIC, 7, 36, 198, 10, SS_CENTER
CTEXT "yopyop", IDC_STATIC, 9, 45, 196, 10, SS_CENTER
CTEXT "current team", IDC_STATIC, 8, 63, 198, 10, SS_CENTER
}

View File

@ -1,4 +1,7 @@
/* Copyright (C) 2005-2007 Theo Berkau
/* snddx.cpp
Copyright (C) 2005-2007 Theo Berkau
Copyright (C) 2008-2009 DeSmuME team
This file is part of DeSmuME
@ -14,7 +17,7 @@
You should have received a copy of the GNU General Public License
along with DeSmuME; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
#include <winsock2.h>
@ -43,15 +46,15 @@ void SNDDXUnMuteAudio();
void SNDDXSetVolume(int volume);
SoundInterface_struct SNDDIRECTX = {
SNDCORE_DIRECTX,
"Direct Sound Interface",
SNDDXInit,
SNDDXDeInit,
SNDDXUpdateAudio,
SNDDXGetAudioSpace,
SNDDXMuteAudio,
SNDDXUnMuteAudio,
SNDDXSetVolume
SNDCORE_DIRECTX,
"Direct Sound Interface",
SNDDXInit,
SNDDXDeInit,
SNDDXUpdateAudio,
SNDDXGetAudioSpace,
SNDDXMuteAudio,
SNDDXUnMuteAudio,
SNDDXSetVolume
};
LPDIRECTSOUND8 lpDS8;
@ -67,7 +70,7 @@ static int issoundmuted;
//////////////////////////////////////////////////////////////////////////////
static volatile bool terminate;
static volatile bool doterminate;
static volatile bool terminated;
extern CRITICAL_SECTION win_sync;
@ -76,7 +79,7 @@ extern volatile int win_sound_samplecounter;
DWORD WINAPI SNDDXThread( LPVOID )
{
for(;;) {
if(terminate) break;
if(doterminate) break;
{
Lock lock;
SPU_Emulate_user();
@ -89,229 +92,229 @@ DWORD WINAPI SNDDXThread( LPVOID )
int SNDDXInit(int buffersize)
{
DSBUFFERDESC dsbdesc;
WAVEFORMATEX wfx;
HRESULT ret;
char tempstr[512];
DSBUFFERDESC dsbdesc;
WAVEFORMATEX wfx;
HRESULT ret;
char tempstr[512];
if ((ret = DirectSoundCreate8(NULL, &lpDS8, NULL)) != DS_OK)
{
sprintf(tempstr, "DirectSound8Create error: %s - %s", DXGetErrorString8(ret), DXGetErrorDescription8(ret));
MessageBox (NULL, tempstr, "Error", MB_OK | MB_ICONINFORMATION);
return -1;
}
if ((ret = DirectSoundCreate8(NULL, &lpDS8, NULL)) != DS_OK)
{
sprintf(tempstr, "DirectSound8Create error: %s - %s", DXGetErrorString8(ret), DXGetErrorDescription8(ret));
MessageBox (NULL, tempstr, "Error", MB_OK | MB_ICONINFORMATION);
return -1;
}
if ((ret = IDirectSound8_SetCooperativeLevel(lpDS8, MainWindow->getHWnd(), DSSCL_PRIORITY)) != DS_OK)
{
sprintf(tempstr, "IDirectSound8_SetCooperativeLevel error: %s - %s", DXGetErrorString8(ret), DXGetErrorDescription8(ret));
MessageBox (NULL, tempstr, "Error", MB_OK | MB_ICONINFORMATION);
return -1;
}
if ((ret = IDirectSound8_SetCooperativeLevel(lpDS8, MainWindow->getHWnd(), DSSCL_PRIORITY)) != DS_OK)
{
sprintf(tempstr, "IDirectSound8_SetCooperativeLevel error: %s - %s", DXGetErrorString8(ret), DXGetErrorDescription8(ret));
MessageBox (NULL, tempstr, "Error", MB_OK | MB_ICONINFORMATION);
return -1;
}
memset(&dsbdesc, 0, sizeof(dsbdesc));
dsbdesc.dwSize = sizeof(DSBUFFERDESC);
dsbdesc.dwFlags = DSBCAPS_PRIMARYBUFFER;
dsbdesc.dwBufferBytes = 0;
dsbdesc.lpwfxFormat = NULL;
memset(&dsbdesc, 0, sizeof(dsbdesc));
dsbdesc.dwSize = sizeof(DSBUFFERDESC);
dsbdesc.dwFlags = DSBCAPS_PRIMARYBUFFER;
dsbdesc.dwBufferBytes = 0;
dsbdesc.lpwfxFormat = NULL;
if ((ret = IDirectSound8_CreateSoundBuffer(lpDS8, &dsbdesc, &lpDSB, NULL)) != DS_OK)
{
sprintf(tempstr, "Error when creating primary sound buffer: %s - %s", DXGetErrorString8(ret), DXGetErrorDescription8(ret));
MessageBox (NULL, tempstr, "Error", MB_OK | MB_ICONINFORMATION);
return -1;
}
if ((ret = IDirectSound8_CreateSoundBuffer(lpDS8, &dsbdesc, &lpDSB, NULL)) != DS_OK)
{
sprintf(tempstr, "Error when creating primary sound buffer: %s - %s", DXGetErrorString8(ret), DXGetErrorDescription8(ret));
MessageBox (NULL, tempstr, "Error", MB_OK | MB_ICONINFORMATION);
return -1;
}
soundbufsize = buffersize * 2 * 2;
soundbufsize = buffersize * 2 * 2;
memset(&wfx, 0, sizeof(wfx));
wfx.wFormatTag = WAVE_FORMAT_PCM;
wfx.nChannels = 2;
wfx.nSamplesPerSec = 44100;
wfx.wBitsPerSample = 16;
wfx.nBlockAlign = (wfx.wBitsPerSample / 8) * wfx.nChannels;
wfx.nAvgBytesPerSec = wfx.nSamplesPerSec * wfx.nBlockAlign;
memset(&wfx, 0, sizeof(wfx));
wfx.wFormatTag = WAVE_FORMAT_PCM;
wfx.nChannels = 2;
wfx.nSamplesPerSec = 44100;
wfx.wBitsPerSample = 16;
wfx.nBlockAlign = (wfx.wBitsPerSample / 8) * wfx.nChannels;
wfx.nAvgBytesPerSec = wfx.nSamplesPerSec * wfx.nBlockAlign;
if ((ret = IDirectSoundBuffer8_SetFormat(lpDSB, &wfx)) != DS_OK)
{
sprintf(tempstr, "IDirectSoundBuffer8_SetFormat error: %s - %s", DXGetErrorString8(ret), DXGetErrorDescription8(ret));
MessageBox (NULL, tempstr, "Error", MB_OK | MB_ICONINFORMATION);
return -1;
}
if ((ret = IDirectSoundBuffer8_SetFormat(lpDSB, &wfx)) != DS_OK)
{
sprintf(tempstr, "IDirectSoundBuffer8_SetFormat error: %s - %s", DXGetErrorString8(ret), DXGetErrorDescription8(ret));
MessageBox (NULL, tempstr, "Error", MB_OK | MB_ICONINFORMATION);
return -1;
}
memset(&dsbdesc, 0, sizeof(dsbdesc));
dsbdesc.dwSize = sizeof(DSBUFFERDESC);
dsbdesc.dwFlags = DSBCAPS_GLOBALFOCUS | DSBCAPS_STICKYFOCUS |
DSBCAPS_CTRLVOLUME | DSBCAPS_GETCURRENTPOSITION2 |
DSBCAPS_LOCHARDWARE;
dsbdesc.dwBufferBytes = soundbufsize;
dsbdesc.lpwfxFormat = &wfx;
memset(&dsbdesc, 0, sizeof(dsbdesc));
dsbdesc.dwSize = sizeof(DSBUFFERDESC);
dsbdesc.dwFlags = DSBCAPS_GLOBALFOCUS | DSBCAPS_STICKYFOCUS |
DSBCAPS_CTRLVOLUME | DSBCAPS_GETCURRENTPOSITION2 |
DSBCAPS_LOCHARDWARE;
dsbdesc.dwBufferBytes = soundbufsize;
dsbdesc.lpwfxFormat = &wfx;
if ((ret = IDirectSound8_CreateSoundBuffer(lpDS8, &dsbdesc, &lpDSB2, NULL)) != DS_OK)
{
if (ret == DSERR_CONTROLUNAVAIL ||
ret == DSERR_INVALIDCALL ||
ret == E_FAIL ||
ret == E_NOTIMPL)
{
// Try using a software buffer instead
dsbdesc.dwFlags = DSBCAPS_GLOBALFOCUS | DSBCAPS_STICKYFOCUS |
DSBCAPS_CTRLVOLUME | DSBCAPS_GETCURRENTPOSITION2 |
DSBCAPS_LOCSOFTWARE;
if ((ret = IDirectSound8_CreateSoundBuffer(lpDS8, &dsbdesc, &lpDSB2, NULL)) != DS_OK)
{
if (ret == DSERR_CONTROLUNAVAIL ||
ret == DSERR_INVALIDCALL ||
ret == E_FAIL ||
ret == E_NOTIMPL)
{
// Try using a software buffer instead
dsbdesc.dwFlags = DSBCAPS_GLOBALFOCUS | DSBCAPS_STICKYFOCUS |
DSBCAPS_CTRLVOLUME | DSBCAPS_GETCURRENTPOSITION2 |
DSBCAPS_LOCSOFTWARE;
if ((ret = IDirectSound8_CreateSoundBuffer(lpDS8, &dsbdesc, &lpDSB2, NULL)) != DS_OK)
{
sprintf(tempstr, "Error when creating secondary sound buffer: %s - %s", DXGetErrorString8(ret), DXGetErrorDescription8(ret));
MessageBox (NULL, tempstr, "Error", MB_OK | MB_ICONINFORMATION);
return -1;
}
}
else
{
sprintf(tempstr, "Error when creating secondary sound buffer: %s - %s", DXGetErrorString8(ret), DXGetErrorDescription8(ret));
MessageBox (NULL, tempstr, "Error", MB_OK | MB_ICONINFORMATION);
return -1;
}
}
if ((ret = IDirectSound8_CreateSoundBuffer(lpDS8, &dsbdesc, &lpDSB2, NULL)) != DS_OK)
{
sprintf(tempstr, "Error when creating secondary sound buffer: %s - %s", DXGetErrorString8(ret), DXGetErrorDescription8(ret));
MessageBox (NULL, tempstr, "Error", MB_OK | MB_ICONINFORMATION);
return -1;
}
}
else
{
sprintf(tempstr, "Error when creating secondary sound buffer: %s - %s", DXGetErrorString8(ret), DXGetErrorDescription8(ret));
MessageBox (NULL, tempstr, "Error", MB_OK | MB_ICONINFORMATION);
return -1;
}
}
IDirectSoundBuffer8_Play(lpDSB2, 0, 0, DSBPLAY_LOOPING);
IDirectSoundBuffer8_Play(lpDSB2, 0, 0, DSBPLAY_LOOPING);
if ((stereodata16 = (s16 *)malloc(soundbufsize)) == NULL)
return -1;
if ((stereodata16 = (s16 *)malloc(soundbufsize)) == NULL)
return -1;
memset(stereodata16, 0, soundbufsize);
memset(stereodata16, 0, soundbufsize);
soundvolume = DSBVOLUME_MAX;
issoundmuted = 0;
soundvolume = DSBVOLUME_MAX;
issoundmuted = 0;
terminate = false;
doterminate = false;
terminated = false;
CreateThread(0,0,SNDDXThread,0,0,0);
CreateThread(0,0,SNDDXThread,0,0,0);
return 0;
return 0;
}
//////////////////////////////////////////////////////////////////////////////
void SNDDXDeInit()
{
DWORD status=0;
terminate = true;
while(!terminated) {
Sleep(1);
}
DWORD status=0;
if (lpDSB2)
{
IDirectSoundBuffer8_GetStatus(lpDSB2, &status);
doterminate = true;
while(!terminated) {
Sleep(1);
}
if(status == DSBSTATUS_PLAYING)
IDirectSoundBuffer8_Stop(lpDSB2);
if (lpDSB2)
{
IDirectSoundBuffer8_GetStatus(lpDSB2, &status);
IDirectSoundBuffer8_Release(lpDSB2);
lpDSB2 = NULL;
}
if(status == DSBSTATUS_PLAYING)
IDirectSoundBuffer8_Stop(lpDSB2);
if (lpDSB)
{
IDirectSoundBuffer8_Release(lpDSB);
lpDSB = NULL;
}
IDirectSoundBuffer8_Release(lpDSB2);
lpDSB2 = NULL;
}
if (lpDS8)
{
IDirectSound8_Release(lpDS8);
lpDS8 = NULL;
}
if (lpDSB)
{
IDirectSoundBuffer8_Release(lpDSB);
lpDSB = NULL;
}
if (lpDS8)
{
IDirectSound8_Release(lpDS8);
lpDS8 = NULL;
}
}
//////////////////////////////////////////////////////////////////////////////
void SNDDXUpdateAudio(s16 *buffer, u32 num_samples)
{
LPVOID buffer1;
LPVOID buffer2;
DWORD buffer1_size, buffer2_size;
DWORD status;
LPVOID buffer1;
LPVOID buffer2;
DWORD buffer1_size, buffer2_size;
DWORD status;
int samplecounter;
{
int samplecounter;
{
Lock lock;
samplecounter = win_sound_samplecounter -= num_samples;
}
bool silence = (samplecounter<-44100*15/60); //behind by more than a quarter second -> silence
samplecounter = win_sound_samplecounter -= num_samples;
}
IDirectSoundBuffer8_GetStatus(lpDSB2, &status);
bool silence = (samplecounter<-44100*15/60); //behind by more than a quarter second -> silence
if (status & DSBSTATUS_BUFFERLOST)
return; // fix me
IDirectSoundBuffer8_GetStatus(lpDSB2, &status);
IDirectSoundBuffer8_Lock(lpDSB2, soundoffset, num_samples * sizeof(s16) * 2, &buffer1, &buffer1_size, &buffer2, &buffer2_size, 0);
if (status & DSBSTATUS_BUFFERLOST)
return; // fix me
if(silence) {
memset(buffer1, 0, buffer1_size);
if(buffer2)
memset(buffer2, 0, buffer2_size);
}
else
{
memcpy(buffer1, buffer, buffer1_size);
IDirectSoundBuffer8_Lock(lpDSB2, soundoffset, num_samples * sizeof(s16) * 2, &buffer1, &buffer1_size, &buffer2, &buffer2_size, 0);
if(silence) {
memset(buffer1, 0, buffer1_size);
if(buffer2)
memset(buffer2, 0, buffer2_size);
}
else
{
memcpy(buffer1, buffer, buffer1_size);
if (buffer2)
memcpy(buffer2, ((u8 *)buffer)+buffer1_size, buffer2_size);
}
memcpy(buffer2, ((u8 *)buffer)+buffer1_size, buffer2_size);
}
soundoffset += buffer1_size + buffer2_size;
soundoffset %= soundbufsize;
soundoffset += buffer1_size + buffer2_size;
soundoffset %= soundbufsize;
IDirectSoundBuffer8_Unlock(lpDSB2, buffer1, buffer1_size, buffer2, buffer2_size);
IDirectSoundBuffer8_Unlock(lpDSB2, buffer1, buffer1_size, buffer2, buffer2_size);
}
//////////////////////////////////////////////////////////////////////////////
u32 SNDDXGetAudioSpace()
{
DWORD playcursor, writecursor;
u32 freespace=0;
DWORD playcursor, writecursor;
u32 freespace=0;
if (IDirectSoundBuffer8_GetCurrentPosition (lpDSB2, &playcursor, &writecursor) != DS_OK)
return 0;
if (IDirectSoundBuffer8_GetCurrentPosition (lpDSB2, &playcursor, &writecursor) != DS_OK)
return 0;
if (soundoffset > playcursor)
freespace = soundbufsize - soundoffset + playcursor;
else
freespace = playcursor - soundoffset;
if (soundoffset > playcursor)
freespace = soundbufsize - soundoffset + playcursor;
else
freespace = playcursor - soundoffset;
// if (freespace > 512)
return (freespace / 2 / 2);
// else
// return 0;
// if (freespace > 512)
return (freespace / 2 / 2);
// else
// return 0;
}
//////////////////////////////////////////////////////////////////////////////
void SNDDXMuteAudio()
{
issoundmuted = 1;
IDirectSoundBuffer8_SetVolume (lpDSB2, DSBVOLUME_MIN);
issoundmuted = 1;
IDirectSoundBuffer8_SetVolume (lpDSB2, DSBVOLUME_MIN);
}
//////////////////////////////////////////////////////////////////////////////
void SNDDXUnMuteAudio()
{
issoundmuted = 0;
IDirectSoundBuffer8_SetVolume (lpDSB2, soundvolume);
issoundmuted = 0;
IDirectSoundBuffer8_SetVolume (lpDSB2, soundvolume);
}
//////////////////////////////////////////////////////////////////////////////
void SNDDXSetVolume(int volume)
{
if (!lpDSB2) return ; /* might happen when changing sounddevice on the fly, caused a gpf */
soundvolume = (((LONG)volume) - 100) * 100;
if (!issoundmuted)
IDirectSoundBuffer8_SetVolume (lpDSB2, soundvolume);
if (!lpDSB2) return ; /* might happen when changing sounddevice on the fly, caused a gpf */
soundvolume = (((LONG)volume) - 100) * 100;
if (!issoundmuted)
IDirectSoundBuffer8_SetVolume (lpDSB2, soundvolume);
}
//////////////////////////////////////////////////////////////////////////////

View File

@ -1,202 +0,0 @@
/* wavout.cpp
*
* Copyright (C) 2006-2008 Zeromus
*
* This file is part of DeSmuME
*
* DeSmuME is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* DeSmuME 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with DeSmuME; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
#include "main.h" //I added this so that this file could gain access to SetMessageToDisplay.
#include "types.h"
#include "windriver.h"
#include "console.h"
#include "gfx3d.h"
#include <assert.h>
#include <vfw.h>
#include <stdio.h>
#include "debug.h"
static void EMU_PrintError(const char* msg) {
LOG(msg);
}
static void EMU_PrintMessage(const char* msg) {
LOG(msg);
}
bool DRV_WavBegin(const char* fname);
void DRV_WavEnd();
void DRV_WavSoundUpdate(void* soundData, int soundLen);
bool DRV_WavIsRecording();
static struct WAVFile
{
bool valid;
WAVEFORMATEX wav_format_master;
WAVEFORMATEX wav_format;
HMMIO wav_file;
MMCKINFO waveChunk;
MMCKINFO fmtChunk;
MMCKINFO dataChunk;
} *wav_file = NULL;
static void wav_create(struct WAVFile** wav_out)
{
*wav_out = (struct WAVFile*)malloc(sizeof(struct WAVFile));
memset(*wav_out, 0, sizeof(struct WAVFile));
}
static void wav_destroy(struct WAVFile** wav_out)
{
if(!(*wav_out))
return;
if((*wav_out)->wav_file)
{
mmioAscend((*wav_out)->wav_file, &(*wav_out)->dataChunk, 0);
mmioAscend((*wav_out)->wav_file, &(*wav_out)->waveChunk, 0);
// mmioFlush((*wav_out)->wav_file, 0);
mmioClose((*wav_out)->wav_file, 0);
(*wav_out)->wav_file = NULL;
}
free(*wav_out);
*wav_out = NULL;
}
static void set_sound_format(const WAVEFORMATEX* wave_format, struct WAVFile* wav_out)
{
memcpy(&((*wav_out).wav_format_master), wave_format, sizeof(WAVEFORMATEX));
}
static int wav_open(const char* filename, const WAVEFORMATEX* pwfex)
{
int error = 1;
int result = 0;
do
{
// close existing first
DRV_WavEnd();
// create the object
wav_create(&wav_file);
if(!wav_file)
break;
// add audio format
set_sound_format(pwfex, wav_file);
// open the file
if(!(wav_file->wav_file = mmioOpen((LPSTR)filename, NULL, MMIO_CREATE|MMIO_WRITE)))
break;
// create WAVE chunk
wav_file->waveChunk.fccType = mmioFOURCC('W', 'A', 'V', 'E');
mmioCreateChunk(wav_file->wav_file, &wav_file->waveChunk, MMIO_CREATERIFF);
// create Format chunk
wav_file->fmtChunk.ckid = mmioFOURCC('f', 'm', 't', ' ');
mmioCreateChunk(wav_file->wav_file, &wav_file->fmtChunk, 0);
// then write header
memcpy(&wav_file->wav_format, &wav_file->wav_format_master, sizeof(WAVEFORMATEX));
wav_file->wav_format.cbSize = 0;
mmioWrite(wav_file->wav_file, (HPSTR) &wav_file->wav_format, sizeof(WAVEFORMATEX));
mmioAscend(wav_file->wav_file, &wav_file->fmtChunk, 0);
// create Data chunk
wav_file->dataChunk.ckid = mmioFOURCC('d', 'a', 't', 'a');
mmioCreateChunk(wav_file->wav_file, &wav_file->dataChunk, 0);
// success
error = 0;
result = 1;
wav_file->valid = true;
} while(false);
if(!result)
{
wav_destroy(&wav_file);
if(error)
EMU_PrintError("Error writing WAV file");
}
return result;
}
bool DRV_WavBegin(const char* fname)
{
DRV_WavEnd();
WAVEFORMATEX wf;
wf.cbSize = sizeof(WAVEFORMATEX);
wf.nAvgBytesPerSec = 44100 * 4;
wf.nBlockAlign = 4;
wf.nChannels = 2;
wf.nSamplesPerSec = 44100;
wf.wBitsPerSample = 16;
wf.wFormatTag = WAVE_FORMAT_PCM;
WAVEFORMATEX* pwf = &wf;
if(!wav_open(fname, pwf))
return 0;
EMU_PrintMessage("WAV recording started.");
SetMessageToDisplay("WAV recording started.");
return 1;
}
BOOL WAV_IsRecording()
{
return wav_file && wav_file->valid;
}
void DRV_WavSoundUpdate(void* soundData, int soundLen)
{
int nBytes;
if(!WAV_IsRecording())
return;
nBytes = soundLen * wav_file->wav_format.nBlockAlign;
// assumes mmio system has been opened data chunk
mmioWrite(wav_file->wav_file, (HPSTR) soundData, nBytes);
// mmioFlush(wav_file->wav_file, 0);
}
void DRV_WavEnd()
{
if(!wav_file)
return;
EMU_PrintMessage("WAV recording ended.");
SetMessageToDisplay("WAV recording ended.");
wav_destroy(&wav_file);
}
bool DRV_WavIsRecording()
{
if(wav_file)
return true;
return false;
}

View File

@ -1,4 +0,0 @@
bool DRV_WavBegin(const char* fname);
void DRV_WavEnd();
void DRV_WavSoundUpdate(void* soundData, int soundLen);
bool DRV_WavIsRecording();

View File

@ -1,3 +1,24 @@
/* windriver.h
Copyright (C) 2008-2009 DeSmuME team
This file is part of DeSmuME
DeSmuME is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
DeSmuME 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 General Public License for more details.
You should have received a copy of the GNU General Public License
along with DeSmuME; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
#ifndef _WINDRIVER_H_
#define _WINDRIVER_H_