Changed both video plugins to save PNG screenshots. Made GCPad New default in trunk (it already is in stable). Fixed a hack in new wiimote plugin. Other minor changes.

git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@5532 8ced0084-cf51-0410-be5f-012b33b47a6e
This commit is contained in:
Jordan Woyak 2010-05-29 10:09:24 +00:00
parent 4f10ded2b6
commit 05ef8231b8
12 changed files with 107 additions and 82 deletions

View File

@ -132,7 +132,7 @@
// Plugin files
#define DEFAULT_GFX_PLUGIN PLUGIN_PREFIX "Plugin_VideoOGL" PLUGIN_SUFFIX
#define DEFAULT_DSP_PLUGIN PLUGIN_PREFIX "Plugin_DSP_HLE" PLUGIN_SUFFIX
#define DEFAULT_PAD_PLUGIN PLUGIN_PREFIX "Plugin_GCPad" PLUGIN_SUFFIX
#define DEFAULT_PAD_PLUGIN PLUGIN_PREFIX "Plugin_GCPadNew" PLUGIN_SUFFIX
#define DEFAULT_WIIMOTE_PLUGIN PLUGIN_PREFIX "Plugin_Wiimote" PLUGIN_SUFFIX
// Sys files

View File

@ -168,8 +168,7 @@ void LogContainer::removeListener(LogListener *listener) {
}
bool LogContainer::isListener(LogListener *listener) const {
std::vector<LogListener *>::const_iterator i = std::find(listeners.begin(), listeners.end(), listener);
return listeners.end() != i;
return listeners.end() != std::find(listeners.begin(), listeners.end(), listener);
}
void LogContainer::trigger(LogTypes::LOG_LEVELS level, const char *msg) {

View File

@ -581,9 +581,9 @@ static inline std::string GenerateScreenshotName()
//append gameId, tempname only contains the folder here.
tempname += gameId;
name = StringFromFormat("%s-%d.bmp", tempname.c_str(), index);
while(File::Exists(name.c_str()))
name = StringFromFormat("%s-%d.bmp", tempname.c_str(), ++index);
do
name = StringFromFormat("%s-%d.png", tempname.c_str(), index++);
while (File::Exists(name.c_str()));
return name;
}

View File

@ -6,7 +6,7 @@
inline bool operator<(const GUID & lhs, const GUID & rhs)
{
return memcmp(&lhs, &rhs, sizeof(GUID)) < 0 ? true : false;
return memcmp(&lhs, &rhs, sizeof(GUID)) < 0;
}
namespace ciface

View File

@ -1133,7 +1133,19 @@ void Renderer::Swap(u32 xfbAddr, FieldType field, u32 fbWidth, u32 fbHeight)
if(s_bScreenshot)
{
s_criticalScreenshot.Enter();
D3DXSaveSurfaceToFileA(s_sScreenshotName, D3DXIFF_BMP, D3D::GetBackBufferSurface(), NULL, NULL);
// create a R8G8B8 surface for the screenshot (no alpha channel)
// otherwise funky screenshots get saved
LPDIRECT3DSURFACE9 screenshot_surface;
if (D3D_OK == D3D::dev->CreateOffscreenPlainSurface(s_backbuffer_width, s_backbuffer_height, D3DFMT_R8G8B8, D3DPOOL_SCRATCH, &screenshot_surface, NULL))
{
D3DXLoadSurfaceFromSurface(screenshot_surface, NULL, NULL, D3D::GetBackBufferSurface(), NULL, NULL, D3DX_DEFAULT, 0);
D3DXSaveSurfaceToFileA(s_sScreenshotName, D3DXIFF_PNG, screenshot_surface, NULL, NULL);
screenshot_surface->Release();
}
else
PanicAlert("Failed to create surface for screenshot!");
s_bScreenshot = false;
s_criticalScreenshot.Leave();
}

View File

@ -1458,7 +1458,7 @@ THREAD_RETURN TakeScreenshot(void *pArgs)
// Save the screenshot and finally kill the wxImage object
// This is really expensive when saving to PNG, but not at all when using BMP
threadStruct->img->SaveFile(wxString::FromAscii(threadStruct->filename.c_str()), wxBITMAP_TYPE_BMP);
threadStruct->img->SaveFile(wxString::FromAscii(threadStruct->filename.c_str()), wxBITMAP_TYPE_PNG);
threadStruct->img->Destroy();
// Show success messages

View File

@ -400,7 +400,11 @@ void Wiimote_Update(int _number)
unsigned int Wiimote_GetAttachedControllers()
{
return 1;
unsigned int attached = 0;
for (unsigned int i=0; i<4; ++i)
if (WiiMoteEmu::WiiMapping[i].Source)
attached |= (1 << i);
return attached;
}

View File

@ -65,10 +65,8 @@ void Wiimote::ReportMode(const u16 _channelID, wm_report_mode* dr)
m_reporting_mode = dr->mode;
m_reporting_channel = _channelID;
// some hax to skip a few Update() cycles to fix a nunchuk prob in ztp and wii sports
// skipping 10 seems to work
// probably like 1/6th of a second that the user won't have control :/
m_skip_update = 10;
// reset IR camera
memset(m_reg_ir, 0, sizeof(*m_reg_ir));
if (0 == dr->all_the_time)
PanicAlert("Wiimote: Reporting Always is set to OFF! Everything should be fine, but games never do this.");
@ -154,8 +152,8 @@ void Wiimote::HidOutputReport(const u16 _channelID, wm_report* sr)
//PanicAlert( "WM Speaker Mute: %d", sr->data[0] & 0x04 );
#ifdef USE_WIIMOTE_EMU_SPEAKER
// testing
if (sr->data[0] ^ 0x04)
m_channel_status.step = 0;
if (sr->data[0] & 0x04)
memset(&m_channel_status, 0, sizeof(m_channel_status));
#endif
m_speaker_mute = (sr->data[0] & 0x04) ? 1 : 0;
break;
@ -418,6 +416,7 @@ void Wiimote::ReadData(const u16 _channelID, wm_read_data* rd)
// want the requested address, not the above modified one
rr.address = convert24bit(rd->address);
rr.size = size;
//rr.channel = _channelID;
rr.position = 0;
rr.data = block;
@ -490,4 +489,15 @@ void Wiimote::SendReadDataReply(const u16 _channelID, ReadRequest& _request)
g_WiimoteInitialize.pWiimoteInput(m_index, _channelID, data, sizeof(data));
}
void Wiimote::DoState(PointerWrap& p)
{
// not working :(
//if (p.MODE_READ == p.GetMode())
//{
// // LOAD
// Reset(); // should cause a status report to be sent, then wii should re-setup wiimote
//}
//p.Do(m_reporting_channel);
}
}

View File

@ -1,39 +1,39 @@
#include "WiimoteEmu.h"
#ifdef USE_WIIMOTE_EMU_SPEAKER
namespace WiimoteEmu
{
void Wiimote::SpeakerData(wm_speaker_data* sd)
{
SoundBuffer sb;
sb.samples = new s16[sd->length * 2];
s16* s = sb.samples;
const u8* const e = sd->data + sd->length;
for ( const u8* i = sd->data; i<e; ++i )
{
*s++ = adpcm_yamaha_expand_nibble( &m_channel_status, *i & 0x0F );
*s++ = adpcm_yamaha_expand_nibble( &m_channel_status, *i >> 4 );
}
alGenBuffers(1, &sb.buffer);
// TODO make this not always 3000
alBufferData(sb.buffer, AL_FORMAT_MONO16, sb.samples, (sd->length * sizeof(short) * 2), 3360);
// testing
//alBufferData(sb.buffer, AL_FORMAT_MONO16, sb.samples, (sd->length * sizeof(short) * 2), 48000/m_reg_speaker->sample_rate);
alSourceQueueBuffers(m_audio_source, 1, &sb.buffer);
ALint state;
alGetSourcei(m_audio_source, AL_SOURCE_STATE, &state);
if (AL_PLAYING != state)
alSourcePlay(m_audio_source);
m_audio_buffers.push(sb);
}
}
#endif
#include "WiimoteEmu.h"
#ifdef USE_WIIMOTE_EMU_SPEAKER
namespace WiimoteEmu
{
void Wiimote::SpeakerData(wm_speaker_data* sd)
{
SoundBuffer sb;
sb.samples = new s16[sd->length * 2];
s16* s = sb.samples;
const u8* const e = sd->data + sd->length;
for ( const u8* i = sd->data; i<e; ++i )
{
*s++ = NGCADPCM::ADPDecodeSample(*i & 0x0F, sd->data[0] & 0x0F, &m_channel_status.hist1p, &m_channel_status.hist2p);
*s++ = NGCADPCM::ADPDecodeSample(*i >> 4, sd->data[0] >> 4, &m_channel_status.hist1p, &m_channel_status.hist2p);
}
alGenBuffers(1, &sb.buffer);
// TODO make this not always 3000
alBufferData(sb.buffer, AL_FORMAT_MONO16, sb.samples, (sd->length * sizeof(short) * 2), 3360);
// testing
//alBufferData(sb.buffer, AL_FORMAT_MONO16, sb.samples, (sd->length * sizeof(short) * 2), 48000/m_reg_speaker->sample_rate);
alSourceQueueBuffers(m_audio_source, 1, &sb.buffer);
ALint state;
alGetSourcei(m_audio_source, AL_SOURCE_STATE, &state);
if (AL_PLAYING != state)
alSourcePlay(m_audio_source);
m_audio_buffers.push(sb);
}
}
#endif

View File

@ -208,9 +208,6 @@ void Wiimote::Reset()
m_rumble_on = false;
m_speaker_mute = false;
// used for some hax in Update()
m_skip_update = 0;
// will make the first Update() call send a status request
// the first call to RequestStatus() will then set up the status struct extension bit
m_extension->active_extension = -1;
@ -393,7 +390,7 @@ void Wiimote::Update()
}
// check if there is a read data request
if ( m_read_requests.size() )
if (m_read_requests.size())
{
ReadRequest& rr = m_read_requests.front();
// send up to 16 bytes to the wii
@ -428,15 +425,6 @@ void Wiimote::Update()
if (false == m_reporting_auto)
return;
// Some hax to skip a few update cycles after a change in reporting mode
// It fixes the nunchuk prob in ztp and wii sports. I have no idea why
// maybe its an m_reporting_channel problem?
if (m_skip_update)
{
--m_skip_update;
return;
}
// figure out what data we need
const ReportFeatures& rpt = reporting_mode_features[m_reporting_mode - WM_REPORT_CORE];
@ -512,7 +500,10 @@ void Wiimote::Update()
}
// ----ir----
if (rpt.ir)
// only if camera is fully enabled.
// should send 0xFF if camera isn't enabled maybe,
// 0x00 is working fine though
if (rpt.ir && 0x08 == m_reg_ir->data[0x30])
{
float xx = 10000, yy = 0, zz = 0;

View File

@ -3,10 +3,13 @@
//#define USE_WIIMOTE_EMU_SPEAKER
//#include <Core.h>
//#include <HW/StreamADPCM.h>
// just used to get the OpenAL includes :p
//#include <OpenALStream.h>
#include <ControllerEmu.h>
#include "ChunkFile.h"
#include "WiimoteHid.h"
#include "Encryption.h"
@ -47,9 +50,12 @@ public:
void InterruptChannel(const u16 _channelID, const void* _pData, u32 _Size);
void ControlChannel(const u16 _channelID, const void* _pData, u32 _Size);
void DoState(PointerWrap& p);
private:
struct ReadRequest
{
//u16 channel;
unsigned int address, size, position;
u8* data;
};
@ -86,12 +92,9 @@ private:
bool m_rumble_on;
bool m_speaker_mute;
bool m_reporting_auto;
unsigned int m_reporting_mode;
unsigned int m_reporting_channel;
// hax
unsigned int m_skip_update;
bool m_reporting_auto;
u8 m_reporting_mode;
u16 m_reporting_channel;
unsigned int m_shake_step[3];
unsigned int m_swing_step[3];
@ -120,7 +123,10 @@ private:
};
std::queue<SoundBuffer> m_audio_buffers;
ALuint m_audio_source;
ADPCMChannelStatus m_channel_status;
struct
{
int hist1p, hist2p;
} m_channel_status;
#endif
u8 m_eeprom[WIIMOTE_EEPROM_SIZE];
@ -129,7 +135,7 @@ private:
struct IrReg
{
u8 unknown1[0x33];
u8 data[0x33];
u8 mode;
} *m_reg_ir;

View File

@ -191,10 +191,11 @@ void Wiimote_Update(int _number)
//
unsigned int Wiimote_GetAttachedControllers()
{
//PanicAlert( "Wiimote_GetAttachedControllers" );
// temporary
//return 0x0F;
return 1;
unsigned int attached = 0;
for (unsigned int i=0; i<4; ++i)
if (g_plugin.controllers[i]->default_device.ToString().length())
attached |= (1 << i);
return attached;
}
// GLOBAL I N T E R F A C E
@ -325,7 +326,9 @@ void Shutdown(void)
//
void DoState(unsigned char **ptr, int mode)
{
// do this later
PointerWrap p(ptr, mode);
for (unsigned int i=0; i<4; ++i)
((WiimoteEmu::Wiimote*)g_plugin.controllers[i])->DoState(p);
}
// ___________________________________________________________________________