Update svn:eol-style=native ( r1442 ) for Source/*.cpp

git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@2384 8ced0084-cf51-0410-be5f-012b33b47a6e
This commit is contained in:
LPFaint99
2009-02-23 06:15:48 +00:00
parent 472582022b
commit 578c402d2c
41 changed files with 13757 additions and 13757 deletions
+56 -56
View File
@@ -1,56 +1,56 @@
// Copyright (C) 2003-2008 Dolphin Project.
// This program 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, version 2.0.
// This program 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 2.0 for more details.
// A copy of the GPL 2.0 should have been included with the program.
// If not, see http://www.gnu.org/licenses/
// Official SVN repository and contact information can be found at
// http://code.google.com/p/dolphin-emu/
#include "Common.h"
#include "ColorUtil.h"
namespace ColorUtil
{
const int lut5to8[] = { 0x00,0x08,0x10,0x18,0x20,0x29,0x31,0x39,
0x41,0x4A,0x52,0x5A,0x62,0x6A,0x73,0x7B,
0x83,0x8B,0x94,0x9C,0xA4,0xAC,0xB4,0xBD,
0xC5,0xCD,0xD5,0xDE,0xE6,0xEE,0xF6,0xFF };
const int lut4to8[] = { 0x00,0x11,0x22,0x33,0x44,0x55,0x66,0x77,
0x88,0x99,0xAA,0xBB,0xCC,0xDD,0xEE,0xFF };
const int lut3to8[] = { 0x00,0x24,0x48,0x6D,0x91,0xB6,0xDA,0xFF };
u32 Decode5A3(u16 val)
{
const u32 bg_color = 0x00000000;
int r, g, b, a;
if (val & 0x8000)
{
r = lut5to8[(val >> 10) & 0x1f];
g = lut5to8[(val >> 5) & 0x1f];
b = lut5to8[(val) & 0x1f];
a = 0xFF;
}
else
{
a = lut3to8[(val >> 12) & 0x7];
r = (lut4to8[(val >> 8) & 0xf] * a + (bg_color & 0xFF) * (255 - a)) / 255;
g = (lut4to8[(val >> 4) & 0xf] * a + ((bg_color >> 8) & 0xFF) * (255 - a)) / 255;
b = (lut4to8[(val) & 0xf] * a + ((bg_color >> 16) & 0xFF) * (255 - a)) / 255;
a = 0xFF;
}
return (a << 24) | (r << 16) | (g << 8) | b;
}
} // namespace
// Copyright (C) 2003-2008 Dolphin Project.
// This program 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, version 2.0.
// This program 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 2.0 for more details.
// A copy of the GPL 2.0 should have been included with the program.
// If not, see http://www.gnu.org/licenses/
// Official SVN repository and contact information can be found at
// http://code.google.com/p/dolphin-emu/
#include "Common.h"
#include "ColorUtil.h"
namespace ColorUtil
{
const int lut5to8[] = { 0x00,0x08,0x10,0x18,0x20,0x29,0x31,0x39,
0x41,0x4A,0x52,0x5A,0x62,0x6A,0x73,0x7B,
0x83,0x8B,0x94,0x9C,0xA4,0xAC,0xB4,0xBD,
0xC5,0xCD,0xD5,0xDE,0xE6,0xEE,0xF6,0xFF };
const int lut4to8[] = { 0x00,0x11,0x22,0x33,0x44,0x55,0x66,0x77,
0x88,0x99,0xAA,0xBB,0xCC,0xDD,0xEE,0xFF };
const int lut3to8[] = { 0x00,0x24,0x48,0x6D,0x91,0xB6,0xDA,0xFF };
u32 Decode5A3(u16 val)
{
const u32 bg_color = 0x00000000;
int r, g, b, a;
if (val & 0x8000)
{
r = lut5to8[(val >> 10) & 0x1f];
g = lut5to8[(val >> 5) & 0x1f];
b = lut5to8[(val) & 0x1f];
a = 0xFF;
}
else
{
a = lut3to8[(val >> 12) & 0x7];
r = (lut4to8[(val >> 8) & 0xf] * a + (bg_color & 0xFF) * (255 - a)) / 255;
g = (lut4to8[(val >> 4) & 0xf] * a + ((bg_color >> 8) & 0xFF) * (255 - a)) / 255;
b = (lut4to8[(val) & 0xf] * a + ((bg_color >> 16) & 0xFF) * (255 - a)) / 255;
a = 0xFF;
}
return (a << 24) | (r << 16) | (g << 8) | b;
}
} // namespace
+198 -198
View File
@@ -1,198 +1,198 @@
// Copyright (C) 2003-2008 Dolphin Project.
// This program 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, version 2.0.
// This program 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 2.0 for more details.
// A copy of the GPL 2.0 should have been included with the program.
// If not, see http://www.gnu.org/licenses/
// Official SVN repository and contact information can be found at
// http://code.google.com/p/dolphin-emu/
// Includes
#include <string> // System: To be able to add strings with "+"
#include <stdio.h>
#ifdef _WIN32
#include <windows.h>
#else
#include <stdarg.h>
#endif
#include "Common.h"
#include "ConsoleWindow.h" // Common
// Declarations and definitions
namespace Console
{
// Create handles
FILE* __fStdOut = NULL;
#ifdef _WIN32
HANDLE __hStdOut = NULL;
#endif
/* Start console window - width and height is the size of console window, if you enable
File the output will also be written to this file. */
void Open(int Width, int Height, char * Name, bool File)
{
#ifdef _WIN32
// Open the console window and create the window handle for GetStdHandle()
AllocConsole();
// Save the window handle that AllocConsole() created
__hStdOut = GetStdHandle(STD_OUTPUT_HANDLE);
// Set the console window title
SetConsoleTitle(Name);
// Set the total letter space
COORD co = {Width, Height};
SetConsoleScreenBufferSize(__hStdOut, co);
/* Set the window size in number of letters. The height is hardcoded here because it can
be changed with MoveWindow() later */
SMALL_RECT coo = {0,0, (Width - 1),50}; // Top, left, right, bottom
SetConsoleWindowInfo(__hStdOut, TRUE, &coo);
#endif
// Create a file and a file handle if File is enabled and we don't already have a file handle
if(File && !__fStdOut)
{
// Edit the log file name
std::string FileEnding = ".log";
std::string FileName = Name;
std::string FullFilename = (FileName + FileEnding);
// Open the file handle
__fStdOut = fopen(FullFilename.c_str(), "w");
}
}
/* Close the console window and close the eventual file handle */
void Close()
{
#ifdef _WIN32
FreeConsole(); // Close the console window
#endif
if(__fStdOut) fclose(__fStdOut); // Close the file handle
}
// Print to screen and file
int Print(const char *fmt, ...)
{
// Maximum bytes, mind this value to avoid an overrun
static const int MAX_BYTES = 1024*20;
#if defined(_WIN32)
if(__hStdOut)
{
#endif
char s[MAX_BYTES];
va_list argptr;
int cnt; // To store the vsnprintf return message
va_start(argptr, fmt);
cnt = vsnprintf(s, MAX_BYTES, fmt, argptr);
va_end(argptr);
#if defined(_WIN32)
DWORD cCharsWritten; // We will get a value back here
WriteConsole(__hStdOut, s, (DWORD)strlen(s), &cCharsWritten, NULL);
#else
fprintf(stderr, "%s", s);
#endif
// Write to the file
if(__fStdOut)
{
fprintf(__fStdOut, "%s", s);
fflush(__fStdOut); // Write file now, don't wait
}
return(cnt);
#if defined(_WIN32)
} else
{
return 0;
}
#endif
}
// Clear console screen
void ClearScreen()
{
#if defined(_WIN32)
if(__hStdOut) // Check that we have a window handle
{
COORD coordScreen = { 0, 0 };
DWORD cCharsWritten;
CONSOLE_SCREEN_BUFFER_INFO csbi;
DWORD dwConSize;
HANDLE hConsole = GetStdHandle(STD_OUTPUT_HANDLE);
GetConsoleScreenBufferInfo(hConsole, &csbi);
dwConSize = csbi.dwSize.X * csbi.dwSize.Y;
FillConsoleOutputCharacter(hConsole, TEXT(' '), dwConSize,
coordScreen, &cCharsWritten);
GetConsoleScreenBufferInfo(hConsole, &csbi);
FillConsoleOutputAttribute(hConsole, csbi.wAttributes, dwConSize,
coordScreen, &cCharsWritten);
SetConsoleCursorPosition(hConsole, coordScreen);
}
#endif
}
/* Get window handle of console window to be able to resize it. We use
GetConsoleTitle() and FindWindow() to locate the console window handle. */
#if defined(_WIN32)
HWND GetHwnd(void)
{
#define MY_BUFSIZE 1024 // Buffer size for console window titles
HWND hwndFound; // This is what is returned to the caller
char pszNewWindowTitle[MY_BUFSIZE]; // Contains fabricated WindowTitle
char pszOldWindowTitle[MY_BUFSIZE]; // Contains original WindowTitle
// Fetch current window title.
GetConsoleTitle(pszOldWindowTitle, MY_BUFSIZE);
// Format a "unique" NewWindowTitle
wsprintf(pszNewWindowTitle, "%d/%d", GetTickCount(), GetCurrentProcessId());
// Change current window title
SetConsoleTitle(pszNewWindowTitle);
// Ensure window title has been updated
Sleep(40);
// Look for NewWindowTitle
hwndFound = FindWindow(NULL, pszNewWindowTitle);
// Restore original window title
SetConsoleTitle(pszOldWindowTitle);
return(hwndFound);
}
#endif // _WIN32
} // namespace
// Copyright (C) 2003-2008 Dolphin Project.
// This program 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, version 2.0.
// This program 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 2.0 for more details.
// A copy of the GPL 2.0 should have been included with the program.
// If not, see http://www.gnu.org/licenses/
// Official SVN repository and contact information can be found at
// http://code.google.com/p/dolphin-emu/
// Includes
#include <string> // System: To be able to add strings with "+"
#include <stdio.h>
#ifdef _WIN32
#include <windows.h>
#else
#include <stdarg.h>
#endif
#include "Common.h"
#include "ConsoleWindow.h" // Common
// Declarations and definitions
namespace Console
{
// Create handles
FILE* __fStdOut = NULL;
#ifdef _WIN32
HANDLE __hStdOut = NULL;
#endif
/* Start console window - width and height is the size of console window, if you enable
File the output will also be written to this file. */
void Open(int Width, int Height, char * Name, bool File)
{
#ifdef _WIN32
// Open the console window and create the window handle for GetStdHandle()
AllocConsole();
// Save the window handle that AllocConsole() created
__hStdOut = GetStdHandle(STD_OUTPUT_HANDLE);
// Set the console window title
SetConsoleTitle(Name);
// Set the total letter space
COORD co = {Width, Height};
SetConsoleScreenBufferSize(__hStdOut, co);
/* Set the window size in number of letters. The height is hardcoded here because it can
be changed with MoveWindow() later */
SMALL_RECT coo = {0,0, (Width - 1),50}; // Top, left, right, bottom
SetConsoleWindowInfo(__hStdOut, TRUE, &coo);
#endif
// Create a file and a file handle if File is enabled and we don't already have a file handle
if(File && !__fStdOut)
{
// Edit the log file name
std::string FileEnding = ".log";
std::string FileName = Name;
std::string FullFilename = (FileName + FileEnding);
// Open the file handle
__fStdOut = fopen(FullFilename.c_str(), "w");
}
}
/* Close the console window and close the eventual file handle */
void Close()
{
#ifdef _WIN32
FreeConsole(); // Close the console window
#endif
if(__fStdOut) fclose(__fStdOut); // Close the file handle
}
// Print to screen and file
int Print(const char *fmt, ...)
{
// Maximum bytes, mind this value to avoid an overrun
static const int MAX_BYTES = 1024*20;
#if defined(_WIN32)
if(__hStdOut)
{
#endif
char s[MAX_BYTES];
va_list argptr;
int cnt; // To store the vsnprintf return message
va_start(argptr, fmt);
cnt = vsnprintf(s, MAX_BYTES, fmt, argptr);
va_end(argptr);
#if defined(_WIN32)
DWORD cCharsWritten; // We will get a value back here
WriteConsole(__hStdOut, s, (DWORD)strlen(s), &cCharsWritten, NULL);
#else
fprintf(stderr, "%s", s);
#endif
// Write to the file
if(__fStdOut)
{
fprintf(__fStdOut, "%s", s);
fflush(__fStdOut); // Write file now, don't wait
}
return(cnt);
#if defined(_WIN32)
} else
{
return 0;
}
#endif
}
// Clear console screen
void ClearScreen()
{
#if defined(_WIN32)
if(__hStdOut) // Check that we have a window handle
{
COORD coordScreen = { 0, 0 };
DWORD cCharsWritten;
CONSOLE_SCREEN_BUFFER_INFO csbi;
DWORD dwConSize;
HANDLE hConsole = GetStdHandle(STD_OUTPUT_HANDLE);
GetConsoleScreenBufferInfo(hConsole, &csbi);
dwConSize = csbi.dwSize.X * csbi.dwSize.Y;
FillConsoleOutputCharacter(hConsole, TEXT(' '), dwConSize,
coordScreen, &cCharsWritten);
GetConsoleScreenBufferInfo(hConsole, &csbi);
FillConsoleOutputAttribute(hConsole, csbi.wAttributes, dwConSize,
coordScreen, &cCharsWritten);
SetConsoleCursorPosition(hConsole, coordScreen);
}
#endif
}
/* Get window handle of console window to be able to resize it. We use
GetConsoleTitle() and FindWindow() to locate the console window handle. */
#if defined(_WIN32)
HWND GetHwnd(void)
{
#define MY_BUFSIZE 1024 // Buffer size for console window titles
HWND hwndFound; // This is what is returned to the caller
char pszNewWindowTitle[MY_BUFSIZE]; // Contains fabricated WindowTitle
char pszOldWindowTitle[MY_BUFSIZE]; // Contains original WindowTitle
// Fetch current window title.
GetConsoleTitle(pszOldWindowTitle, MY_BUFSIZE);
// Format a "unique" NewWindowTitle
wsprintf(pszNewWindowTitle, "%d/%d", GetTickCount(), GetCurrentProcessId());
// Change current window title
SetConsoleTitle(pszNewWindowTitle);
// Ensure window title has been updated
Sleep(40);
// Look for NewWindowTitle
hwndFound = FindWindow(NULL, pszNewWindowTitle);
// Restore original window title
SetConsoleTitle(pszOldWindowTitle);
return(hwndFound);
}
#endif // _WIN32
} // namespace
+82 -82
View File
@@ -1,82 +1,82 @@
// Copyright (C) 2003-2008 Dolphin Project.
// This program 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, version 2.0.
// This program 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 2.0 for more details.
// A copy of the GPL 2.0 should have been included with the program.
// If not, see http://www.gnu.org/licenses/
// Official SVN repository and contact information can be found at
// http://code.google.com/p/dolphin-emu/
//////////////////////////////////////////////////////////////////////////////////////
// Include and declarations
// ¯¯¯¯¯¯¯¯¯
#include <stdio.h> // System
#include "Common.h" // Local
#include "StringUtil.h"
bool DefaultMsgHandler(const char* caption, const char* text, bool yes_no, int Style);
static MsgAlertHandler msg_handler = DefaultMsgHandler;
/////////////////////////////
/* Select which of these functions that are used for message boxes. If wxWidgets is enabled
we will use wxMsgAlert() that is defined in main.cpp */
void RegisterMsgAlertHandler(MsgAlertHandler handler)
{
msg_handler = handler;
}
/////////////////////////////////////////////////////////////
/* This is the first stop for messages where the log is updated and the correct windows
is shown */
// ¯¯¯¯¯¯¯¯¯
bool MsgAlert(const char* caption, bool yes_no, int Style, const char* format, ...)
{
// ---------------------------------
// Read message and write it to the log
// -----------
char buffer[2048];
bool ret = false;
va_list args;
va_start(args, format);
CharArrayFromFormatV(buffer, 2047, format, args);
va_end(args);
LOG(MASTER_LOG, "%s: %s", caption, buffer);
// -----------
if (msg_handler) {
ret = msg_handler(caption, buffer, yes_no, Style);
}
return ret;
}
/////////////////////////////////////////////////////////////
/* This is used in the No-GUI build */
// ¯¯¯¯¯¯¯¯¯
bool DefaultMsgHandler(const char* caption, const char* text, bool yes_no, int Style)
{
#ifdef _WIN32
int STYLE = MB_ICONINFORMATION;
if (Style == QUESTION) STYLE = MB_ICONQUESTION;
if (Style == WARNING) STYLE = MB_ICONWARNING;
return IDYES == MessageBox(0, text, caption, STYLE | (yes_no ? MB_YESNO : MB_OK));
#else
printf("%s\n", text);
return true;
#endif
}
// Copyright (C) 2003-2008 Dolphin Project.
// This program 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, version 2.0.
// This program 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 2.0 for more details.
// A copy of the GPL 2.0 should have been included with the program.
// If not, see http://www.gnu.org/licenses/
// Official SVN repository and contact information can be found at
// http://code.google.com/p/dolphin-emu/
//////////////////////////////////////////////////////////////////////////////////////
// Include and declarations
// ¯¯¯¯¯¯¯¯¯
#include <stdio.h> // System
#include "Common.h" // Local
#include "StringUtil.h"
bool DefaultMsgHandler(const char* caption, const char* text, bool yes_no, int Style);
static MsgAlertHandler msg_handler = DefaultMsgHandler;
/////////////////////////////
/* Select which of these functions that are used for message boxes. If wxWidgets is enabled
we will use wxMsgAlert() that is defined in main.cpp */
void RegisterMsgAlertHandler(MsgAlertHandler handler)
{
msg_handler = handler;
}
/////////////////////////////////////////////////////////////
/* This is the first stop for messages where the log is updated and the correct windows
is shown */
// ¯¯¯¯¯¯¯¯¯
bool MsgAlert(const char* caption, bool yes_no, int Style, const char* format, ...)
{
// ---------------------------------
// Read message and write it to the log
// -----------
char buffer[2048];
bool ret = false;
va_list args;
va_start(args, format);
CharArrayFromFormatV(buffer, 2047, format, args);
va_end(args);
LOG(MASTER_LOG, "%s: %s", caption, buffer);
// -----------
if (msg_handler) {
ret = msg_handler(caption, buffer, yes_no, Style);
}
return ret;
}
/////////////////////////////////////////////////////////////
/* This is used in the No-GUI build */
// ¯¯¯¯¯¯¯¯¯
bool DefaultMsgHandler(const char* caption, const char* text, bool yes_no, int Style)
{
#ifdef _WIN32
int STYLE = MB_ICONINFORMATION;
if (Style == QUESTION) STYLE = MB_ICONQUESTION;
if (Style == WARNING) STYLE = MB_ICONWARNING;
return IDYES == MessageBox(0, text, caption, STYLE | (yes_no ? MB_YESNO : MB_OK));
#else
printf("%s\n", text);
return true;
#endif
}
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
+97 -97
View File
@@ -1,97 +1,97 @@
// Copyright (C) 2003-2009 Dolphin Project.
// This program 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, version 2.0.
// This program 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 2.0 for more details.
// A copy of the GPL 2.0 should have been included with the program.
// If not, see http://www.gnu.org/licenses/
// Official SVN repository and contact information can be found at
// http://code.google.com/p/dolphin-emu/
#include "SI_Device.h"
#include "SI_DeviceGCController.h"
#include "SI_DeviceGBA.h"
//////////////////////////////////////////////////////////////////////////
// --- interface ISIDevice ---
//////////////////////////////////////////////////////////////////////////
int ISIDevice::RunBuffer(u8* _pBuffer, int _iLength)
{
#ifdef _DEBUG
LOG(SERIALINTERFACE, "Send Data Device(%i) - Length(%i) ", ISIDevice::m_iDeviceNumber,_iLength);
char szTemp[256] = "";
int num = 0;
while(num < _iLength)
{
char szTemp2[128] = "";
sprintf(szTemp2, "0x%02x ", _pBuffer[num^3]);
strcat(szTemp, szTemp2);
num++;
if ((num % 8) == 0)
{
LOG(SERIALINTERFACE, szTemp);
szTemp[0] = '\0';
}
}
LOG(SERIALINTERFACE, szTemp);
#endif
return 0;
};
//////////////////////////////////////////////////////////////////////////
// --- class CSIDummy ---
//////////////////////////////////////////////////////////////////////////
// Just a dummy that logs reads and writes
// to be used for SI devices we haven't emulated
class CSIDevice_Dummy : public ISIDevice
{
public:
CSIDevice_Dummy(int _iDeviceNumber) :
ISIDevice(_iDeviceNumber)
{}
virtual ~CSIDevice_Dummy(){}
int RunBuffer(u8* _pBuffer, int _iLength)
{
// (shuffle2) Logging of this function will be done above, in ISIDevice::RunBuffer
// No device. (shuffle2) Maybe this should be SI_ERROR_NO_RESPONSE?
reinterpret_cast<u32*>(_pBuffer)[0] = 0x00000000;
return 4;
}
bool GetData(u32& _Hi, u32& _Low) {LOG(SERIALINTERFACE, "SI DUMMY %i GetData", this->m_iDeviceNumber); return false;}
void SendCommand(u32 _Cmd) {LOG(SERIALINTERFACE, "SI DUMMY %i SendCommand: %08x", this->m_iDeviceNumber, _Cmd);}
};
//////////////////////////////////////////////////////////////////////////
// F A C T O R Y /////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////
ISIDevice* SIDevice_Create(TSIDevices _SIDevice, int _iDeviceNumber)
{
switch(_SIDevice)
{
case SI_DUMMY:
return new CSIDevice_Dummy(_iDeviceNumber);
break;
case SI_GC_CONTROLLER:
return new CSIDevice_GCController(_iDeviceNumber);
break;
case SI_GBA:
return new CSIDevice_GBA(_iDeviceNumber);
break;
}
return NULL;
}
// Copyright (C) 2003-2009 Dolphin Project.
// This program 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, version 2.0.
// This program 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 2.0 for more details.
// A copy of the GPL 2.0 should have been included with the program.
// If not, see http://www.gnu.org/licenses/
// Official SVN repository and contact information can be found at
// http://code.google.com/p/dolphin-emu/
#include "SI_Device.h"
#include "SI_DeviceGCController.h"
#include "SI_DeviceGBA.h"
//////////////////////////////////////////////////////////////////////////
// --- interface ISIDevice ---
//////////////////////////////////////////////////////////////////////////
int ISIDevice::RunBuffer(u8* _pBuffer, int _iLength)
{
#ifdef _DEBUG
LOG(SERIALINTERFACE, "Send Data Device(%i) - Length(%i) ", ISIDevice::m_iDeviceNumber,_iLength);
char szTemp[256] = "";
int num = 0;
while(num < _iLength)
{
char szTemp2[128] = "";
sprintf(szTemp2, "0x%02x ", _pBuffer[num^3]);
strcat(szTemp, szTemp2);
num++;
if ((num % 8) == 0)
{
LOG(SERIALINTERFACE, szTemp);
szTemp[0] = '\0';
}
}
LOG(SERIALINTERFACE, szTemp);
#endif
return 0;
};
//////////////////////////////////////////////////////////////////////////
// --- class CSIDummy ---
//////////////////////////////////////////////////////////////////////////
// Just a dummy that logs reads and writes
// to be used for SI devices we haven't emulated
class CSIDevice_Dummy : public ISIDevice
{
public:
CSIDevice_Dummy(int _iDeviceNumber) :
ISIDevice(_iDeviceNumber)
{}
virtual ~CSIDevice_Dummy(){}
int RunBuffer(u8* _pBuffer, int _iLength)
{
// (shuffle2) Logging of this function will be done above, in ISIDevice::RunBuffer
// No device. (shuffle2) Maybe this should be SI_ERROR_NO_RESPONSE?
reinterpret_cast<u32*>(_pBuffer)[0] = 0x00000000;
return 4;
}
bool GetData(u32& _Hi, u32& _Low) {LOG(SERIALINTERFACE, "SI DUMMY %i GetData", this->m_iDeviceNumber); return false;}
void SendCommand(u32 _Cmd) {LOG(SERIALINTERFACE, "SI DUMMY %i SendCommand: %08x", this->m_iDeviceNumber, _Cmd);}
};
//////////////////////////////////////////////////////////////////////////
// F A C T O R Y /////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////
ISIDevice* SIDevice_Create(TSIDevices _SIDevice, int _iDeviceNumber)
{
switch(_SIDevice)
{
case SI_DUMMY:
return new CSIDevice_Dummy(_iDeviceNumber);
break;
case SI_GC_CONTROLLER:
return new CSIDevice_GCController(_iDeviceNumber);
break;
case SI_GBA:
return new CSIDevice_GBA(_iDeviceNumber);
break;
}
return NULL;
}
+173 -173
View File
@@ -1,173 +1,173 @@
// Copyright (C) 2003-2009 Dolphin Project.
// This program 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, version 2.0.
// This program 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 2.0 for more details.
// A copy of the GPL 2.0 should have been included with the program.
// If not, see http://www.gnu.org/licenses/
// Official SVN repository and contact information can be found at
// http://code.google.com/p/dolphin-emu/
#include <stdio.h>
#include <stdlib.h>
#include "SI_Device.h"
#include "SI_DeviceGCController.h"
#include "../PluginManager.h"
#include "EXI_Device.h"
#include "EXI_DeviceMic.h"
//////////////////////////////////////////////////////////////////////////
// --- standard gamecube controller ---
//////////////////////////////////////////////////////////////////////////
CSIDevice_GCController::CSIDevice_GCController(int _iDeviceNumber) :
ISIDevice(_iDeviceNumber)
{
memset(&m_origin, 0, sizeof(SOrigin));
m_origin.uCommand = 0x41;
m_origin.uOriginStickX = 0x80;
m_origin.uOriginStickY = 0x80;
m_origin.uSubStickStickX = 0x80;
m_origin.uSubStickStickY = 0x80;
m_origin.uTrigger_L = 0x1F;
m_origin.uTrigger_R = 0x1F;
}
int CSIDevice_GCController::RunBuffer(u8* _pBuffer, int _iLength)
{
// For debug logging only
ISIDevice::RunBuffer(_pBuffer, _iLength);
int iPosition = 0;
while(iPosition < _iLength)
{
// Read the command
EBufferCommands command = static_cast<EBufferCommands>(_pBuffer[iPosition ^ 3]);
iPosition++;
// Handle it
switch(command)
{
case CMD_RESET:
{
*(u32*)&_pBuffer[0] = SI_GC_CONTROLLER; // | SI_GC_NOMOTOR;
iPosition = _iLength; // Break the while loop
}
break;
case CMD_ORIGIN:
{
LOG(SERIALINTERFACE, "PAD - Get Origin");
u8* pCalibration = reinterpret_cast<u8*>(&m_origin);
for (int i = 0; i < (int)sizeof(SOrigin); i++)
{
_pBuffer[i ^ 3] = *pCalibration++;
}
}
iPosition = _iLength;
break;
// Recalibrate (FiRES: i am not 100 percent sure about this)
case CMD_RECALIBRATE:
{
LOG(SERIALINTERFACE, "PAD - Recalibrate");
u8* pCalibration = reinterpret_cast<u8*>(&m_origin);
for (int i = 0; i < (int)sizeof(SOrigin); i++)
{
_pBuffer[i ^ 3] = *pCalibration++;
}
}
iPosition = _iLength;
break;
// WII Something
case 0xCE:
LOG(SERIALINTERFACE, "Unknown Wii SI Command");
break;
// DEFAULT
default:
{
LOG(SERIALINTERFACE, "unknown SI command (0x%x)", command);
PanicAlert("SI: Unknown command");
iPosition = _iLength;
}
break;
}
}
return iPosition;
}
//////////////////////////////////////////////////////////////////////////
// GetData
//////////////////////////////////////////////////////////////////////////
// Return true on new data (max 7 Bytes and 6 bits ;)
bool
CSIDevice_GCController::GetData(u32& _Hi, u32& _Low)
{
SPADStatus PadStatus;
memset(&PadStatus, 0 ,sizeof(PadStatus));
Common::PluginPAD* pad = CPluginManager::GetInstance().GetPad(ISIDevice::m_iDeviceNumber);
pad->PAD_GetStatus(ISIDevice::m_iDeviceNumber, &PadStatus);
_Hi = (u32)((u8)PadStatus.stickY);
_Hi |= (u32)((u8)PadStatus.stickX << 8);
_Hi |= (u32)((u16)PadStatus.button << 16);
_Low = (u8)PadStatus.triggerRight;
_Low |= (u32)((u8)PadStatus.triggerLeft << 8);
_Low |= (u32)((u8)PadStatus.substickY << 16);
_Low |= (u32)((u8)PadStatus.substickX << 24);
SetMic(PadStatus.MicButton); // This is dumb and should not be here
// F|RES:
// i dunno if i should force it here
// means that the pad must be "combined" with the origin to math the "final" OSPad-Struct
_Hi |= 0x00800000;
return true;
}
//////////////////////////////////////////////////////////////////////////
// SendCommand
//////////////////////////////////////////////////////////////////////////
void
CSIDevice_GCController::SendCommand(u32 _Cmd)
{
Common::PluginPAD* pad = CPluginManager::GetInstance().GetPad(ISIDevice::m_iDeviceNumber);
UCommand command(_Cmd);
switch(command.Command)
{
// Costis sent it in some demos :)
case 0x00:
break;
case CMD_RUMBLE:
{
unsigned int uType = command.Parameter1; // 0 = stop, 1 = rumble, 2 = stop hard
unsigned int uStrength = command.Parameter2;
if (pad->PAD_Rumble)
pad->PAD_Rumble(ISIDevice::m_iDeviceNumber, uType, uStrength);
}
break;
default:
{
LOG(SERIALINTERFACE, "unknown direct command (0x%x)", _Cmd);
PanicAlert("SI: Unknown direct command");
}
break;
}
}
// Copyright (C) 2003-2009 Dolphin Project.
// This program 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, version 2.0.
// This program 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 2.0 for more details.
// A copy of the GPL 2.0 should have been included with the program.
// If not, see http://www.gnu.org/licenses/
// Official SVN repository and contact information can be found at
// http://code.google.com/p/dolphin-emu/
#include <stdio.h>
#include <stdlib.h>
#include "SI_Device.h"
#include "SI_DeviceGCController.h"
#include "../PluginManager.h"
#include "EXI_Device.h"
#include "EXI_DeviceMic.h"
//////////////////////////////////////////////////////////////////////////
// --- standard gamecube controller ---
//////////////////////////////////////////////////////////////////////////
CSIDevice_GCController::CSIDevice_GCController(int _iDeviceNumber) :
ISIDevice(_iDeviceNumber)
{
memset(&m_origin, 0, sizeof(SOrigin));
m_origin.uCommand = 0x41;
m_origin.uOriginStickX = 0x80;
m_origin.uOriginStickY = 0x80;
m_origin.uSubStickStickX = 0x80;
m_origin.uSubStickStickY = 0x80;
m_origin.uTrigger_L = 0x1F;
m_origin.uTrigger_R = 0x1F;
}
int CSIDevice_GCController::RunBuffer(u8* _pBuffer, int _iLength)
{
// For debug logging only
ISIDevice::RunBuffer(_pBuffer, _iLength);
int iPosition = 0;
while(iPosition < _iLength)
{
// Read the command
EBufferCommands command = static_cast<EBufferCommands>(_pBuffer[iPosition ^ 3]);
iPosition++;
// Handle it
switch(command)
{
case CMD_RESET:
{
*(u32*)&_pBuffer[0] = SI_GC_CONTROLLER; // | SI_GC_NOMOTOR;
iPosition = _iLength; // Break the while loop
}
break;
case CMD_ORIGIN:
{
LOG(SERIALINTERFACE, "PAD - Get Origin");
u8* pCalibration = reinterpret_cast<u8*>(&m_origin);
for (int i = 0; i < (int)sizeof(SOrigin); i++)
{
_pBuffer[i ^ 3] = *pCalibration++;
}
}
iPosition = _iLength;
break;
// Recalibrate (FiRES: i am not 100 percent sure about this)
case CMD_RECALIBRATE:
{
LOG(SERIALINTERFACE, "PAD - Recalibrate");
u8* pCalibration = reinterpret_cast<u8*>(&m_origin);
for (int i = 0; i < (int)sizeof(SOrigin); i++)
{
_pBuffer[i ^ 3] = *pCalibration++;
}
}
iPosition = _iLength;
break;
// WII Something
case 0xCE:
LOG(SERIALINTERFACE, "Unknown Wii SI Command");
break;
// DEFAULT
default:
{
LOG(SERIALINTERFACE, "unknown SI command (0x%x)", command);
PanicAlert("SI: Unknown command");
iPosition = _iLength;
}
break;
}
}
return iPosition;
}
//////////////////////////////////////////////////////////////////////////
// GetData
//////////////////////////////////////////////////////////////////////////
// Return true on new data (max 7 Bytes and 6 bits ;)
bool
CSIDevice_GCController::GetData(u32& _Hi, u32& _Low)
{
SPADStatus PadStatus;
memset(&PadStatus, 0 ,sizeof(PadStatus));
Common::PluginPAD* pad = CPluginManager::GetInstance().GetPad(ISIDevice::m_iDeviceNumber);
pad->PAD_GetStatus(ISIDevice::m_iDeviceNumber, &PadStatus);
_Hi = (u32)((u8)PadStatus.stickY);
_Hi |= (u32)((u8)PadStatus.stickX << 8);
_Hi |= (u32)((u16)PadStatus.button << 16);
_Low = (u8)PadStatus.triggerRight;
_Low |= (u32)((u8)PadStatus.triggerLeft << 8);
_Low |= (u32)((u8)PadStatus.substickY << 16);
_Low |= (u32)((u8)PadStatus.substickX << 24);
SetMic(PadStatus.MicButton); // This is dumb and should not be here
// F|RES:
// i dunno if i should force it here
// means that the pad must be "combined" with the origin to math the "final" OSPad-Struct
_Hi |= 0x00800000;
return true;
}
//////////////////////////////////////////////////////////////////////////
// SendCommand
//////////////////////////////////////////////////////////////////////////
void
CSIDevice_GCController::SendCommand(u32 _Cmd)
{
Common::PluginPAD* pad = CPluginManager::GetInstance().GetPad(ISIDevice::m_iDeviceNumber);
UCommand command(_Cmd);
switch(command.Command)
{
// Costis sent it in some demos :)
case 0x00:
break;
case CMD_RUMBLE:
{
unsigned int uType = command.Parameter1; // 0 = stop, 1 = rumble, 2 = stop hard
unsigned int uStrength = command.Parameter2;
if (pad->PAD_Rumble)
pad->PAD_Rumble(ISIDevice::m_iDeviceNumber, uType, uStrength);
}
break;
default:
{
LOG(SERIALINTERFACE, "unknown direct command (0x%x)", _Cmd);
PanicAlert("SI: Unknown direct command");
}
break;
}
}
+42 -42
View File
@@ -1,43 +1,43 @@
// Copyright (C) 2003-2008 Dolphin Project.
// This program 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, version 2.0.
// This program 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 2.0 for more details.
// A copy of the GPL 2.0 should have been included with the program.
// If not, see http://www.gnu.org/licenses/
// Official SVN repository and contact information can be found at
// http://code.google.com/p/dolphin-emu/
// HW Address: 0d07xxxx
#include "SDInterface.h"
namespace SDInterface
{
bool g_bIsCardInserted = false;
bool g_bIsDumpFile = false;
std::string sourcePath = "";
bool IsCardInserted()
{
return g_bIsCardInserted;
}
void SetSourceType(bool isDumpFile)
{
g_bIsDumpFile = isDumpFile;
}
void SetSourcePath(const std::string path)
{
sourcePath = path;
}
// Copyright (C) 2003-2008 Dolphin Project.
// This program 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, version 2.0.
// This program 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 2.0 for more details.
// A copy of the GPL 2.0 should have been included with the program.
// If not, see http://www.gnu.org/licenses/
// Official SVN repository and contact information can be found at
// http://code.google.com/p/dolphin-emu/
// HW Address: 0d07xxxx
#include "SDInterface.h"
namespace SDInterface
{
bool g_bIsCardInserted = false;
bool g_bIsDumpFile = false;
std::string sourcePath = "";
bool IsCardInserted()
{
return g_bIsCardInserted;
}
void SetSourceType(bool isDumpFile)
{
g_bIsDumpFile = isDumpFile;
}
void SetSourcePath(const std::string path)
{
sourcePath = path;
}
}
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
+145 -145
View File
@@ -1,145 +1,145 @@
// Copyright (C) 2003-2008 Dolphin Project.
// This program 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, version 2.0.
// This program 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 2.0 for more details.
// A copy of the GPL 2.0 should have been included with the program.
// If not, see http://www.gnu.org/licenses/
// Official SVN repository and contact information can be found at
// http://code.google.com/p/dolphin-emu/
#include "ARCodeAddEdit.h"
extern std::vector<ActionReplay::ARCode> arCodes;
BEGIN_EVENT_TABLE(CARCodeAddEdit, wxDialog)
EVT_CLOSE(CARCodeAddEdit::OnClose)
EVT_BUTTON(wxID_OK, CARCodeAddEdit::SaveCheatData)
EVT_SPIN(ID_ENTRY_SELECT, CARCodeAddEdit::ChangeEntry)
END_EVENT_TABLE()
CARCodeAddEdit::CARCodeAddEdit(int _selection, wxWindow* parent, wxWindowID id, const wxString& title, const wxPoint& position, const wxSize& size, long style)
: wxDialog(parent, id, title, position, size, style)
{
selection = _selection;
CreateGUIControls(selection);
}
CARCodeAddEdit::~CARCodeAddEdit()
{
}
void CARCodeAddEdit::CreateGUIControls(int _selection)
{
wxString currentName = wxT("<Insert name here>");
if (_selection == -1)
{
tempEntries.name = "";
}
else
{
currentName = wxString::FromAscii(arCodes.at(_selection).name.c_str());
tempEntries = arCodes.at(_selection);
}
wxBoxSizer* sEditCheat = new wxBoxSizer(wxVERTICAL);
wxStaticBoxSizer* sbEntry = new wxStaticBoxSizer(wxVERTICAL, this, _("Code"));
wxStaticText* EditCheatNameText = new wxStaticText(this, ID_EDITCHEAT_NAME_TEXT, _("Name:"), wxDefaultPosition, wxDefaultSize);
EditCheatName = new wxTextCtrl(this, ID_EDITCHEAT_NAME, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0);
EditCheatName->SetValue(currentName);
EntrySelection = new wxSpinButton(this, ID_ENTRY_SELECT, wxDefaultPosition, wxDefaultSize, wxVERTICAL);
EntrySelection->SetRange(0, (int)arCodes.size()-1);
EntrySelection->SetValue((int)arCodes.size()-1 - _selection);
EditCheatCode = new wxTextCtrl(this, ID_EDITCHEAT_CODE, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxTE_MULTILINE);
UpdateTextCtrl(tempEntries);
wxGridBagSizer* sgEntry = new wxGridBagSizer(0, 0);
sgEntry->AddGrowableCol(1);
sgEntry->AddGrowableRow(1);
sgEntry->Add(EditCheatNameText, wxGBPosition(0, 0), wxGBSpan(1, 1), wxALIGN_CENTER_VERTICAL|wxEXPAND|wxALL, 5);
sgEntry->Add(EditCheatName, wxGBPosition(0, 1), wxGBSpan(1, 1), wxEXPAND|wxALL, 5);
sgEntry->Add(EntrySelection, wxGBPosition(0, 2), wxGBSpan(2, 1), wxEXPAND|wxALL, 5);
sgEntry->Add(EditCheatCode, wxGBPosition(1, 0), wxGBSpan(1, 2), wxEXPAND|wxALL, 5);
sbEntry->Add(sgEntry, 1, wxEXPAND);
sEditCheat->Add(sbEntry, 1, wxEXPAND|wxALL, 5);
wxBoxSizer* sEditCheatButtons = new wxBoxSizer(wxHORIZONTAL);
wxButton* bOK = new wxButton(this, wxID_OK, _("OK"), wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator);
wxButton* bCancel = new wxButton(this, wxID_CANCEL, _("Cancel"), wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator);
sEditCheatButtons->Add(0, 0, 1, wxEXPAND, 5);
sEditCheatButtons->Add(bOK, 0, wxALL, 5);
sEditCheatButtons->Add(bCancel, 0, wxALL, 5);
sEditCheat->Add(sEditCheatButtons, 0, wxEXPAND, 5);
this->SetSizer(sEditCheat);
sEditCheat->Layout();
}
void CARCodeAddEdit::OnClose(wxCloseEvent& WXUNUSED (event))
{
Destroy();
}
void CARCodeAddEdit::ChangeEntry(wxSpinEvent& event)
{
ActionReplay::ARCode currentCode = arCodes.at((int)arCodes.size()-1 - event.GetPosition());
EditCheatName->SetValue(wxString::FromAscii(currentCode.name.c_str()));
UpdateTextCtrl(currentCode);
}
void CARCodeAddEdit::SaveCheatData(wxCommandEvent& WXUNUSED (event))
{
std::vector<ActionReplay::AREntry> tempEntries;
std::string cheatValues = std::string(EditCheatCode->GetValue().mb_str());
bool bWhile = true; size_t line = 0;
while (bWhile)
{
bWhile = false;
u32 addr, value;
addr = strtol(std::string(cheatValues.substr(line, line+8)).c_str(), NULL, 16); // cmd_addr of ArCode
value = strtol(std::string(cheatValues.substr(line+9, line+17)).c_str(), NULL, 16); // value of ArCode
tempEntries.push_back(ActionReplay::AREntry(addr, value));
line = cheatValues.find("\n", line);
if (line != std::string::npos && cheatValues.length() > (line+17))
bWhile = true; // newline found, if not empty, go on
line++;
}
if (selection == -1)
{
ActionReplay::ARCode newCheat;
newCheat.name = std::string(EditCheatName->GetValue().mb_str());
newCheat.ops = tempEntries;
newCheat.active = true;
arCodes.push_back(newCheat);
}
else
{
arCodes.at(selection).name = std::string(EditCheatName->GetValue().mb_str());
arCodes.at(selection).ops = tempEntries;
}
AcceptAndClose();
}
void CARCodeAddEdit::UpdateTextCtrl(ActionReplay::ARCode arCode)
{
EditCheatCode->Clear();
for (u32 i = 0; i < arCode.ops.size(); i++)
EditCheatCode->AppendText(wxString::Format(wxT("%08X %08X\n"), arCode.ops.at(i).cmd_addr, arCode.ops.at(i).value));
}
// Copyright (C) 2003-2008 Dolphin Project.
// This program 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, version 2.0.
// This program 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 2.0 for more details.
// A copy of the GPL 2.0 should have been included with the program.
// If not, see http://www.gnu.org/licenses/
// Official SVN repository and contact information can be found at
// http://code.google.com/p/dolphin-emu/
#include "ARCodeAddEdit.h"
extern std::vector<ActionReplay::ARCode> arCodes;
BEGIN_EVENT_TABLE(CARCodeAddEdit, wxDialog)
EVT_CLOSE(CARCodeAddEdit::OnClose)
EVT_BUTTON(wxID_OK, CARCodeAddEdit::SaveCheatData)
EVT_SPIN(ID_ENTRY_SELECT, CARCodeAddEdit::ChangeEntry)
END_EVENT_TABLE()
CARCodeAddEdit::CARCodeAddEdit(int _selection, wxWindow* parent, wxWindowID id, const wxString& title, const wxPoint& position, const wxSize& size, long style)
: wxDialog(parent, id, title, position, size, style)
{
selection = _selection;
CreateGUIControls(selection);
}
CARCodeAddEdit::~CARCodeAddEdit()
{
}
void CARCodeAddEdit::CreateGUIControls(int _selection)
{
wxString currentName = wxT("<Insert name here>");
if (_selection == -1)
{
tempEntries.name = "";
}
else
{
currentName = wxString::FromAscii(arCodes.at(_selection).name.c_str());
tempEntries = arCodes.at(_selection);
}
wxBoxSizer* sEditCheat = new wxBoxSizer(wxVERTICAL);
wxStaticBoxSizer* sbEntry = new wxStaticBoxSizer(wxVERTICAL, this, _("Code"));
wxStaticText* EditCheatNameText = new wxStaticText(this, ID_EDITCHEAT_NAME_TEXT, _("Name:"), wxDefaultPosition, wxDefaultSize);
EditCheatName = new wxTextCtrl(this, ID_EDITCHEAT_NAME, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0);
EditCheatName->SetValue(currentName);
EntrySelection = new wxSpinButton(this, ID_ENTRY_SELECT, wxDefaultPosition, wxDefaultSize, wxVERTICAL);
EntrySelection->SetRange(0, (int)arCodes.size()-1);
EntrySelection->SetValue((int)arCodes.size()-1 - _selection);
EditCheatCode = new wxTextCtrl(this, ID_EDITCHEAT_CODE, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxTE_MULTILINE);
UpdateTextCtrl(tempEntries);
wxGridBagSizer* sgEntry = new wxGridBagSizer(0, 0);
sgEntry->AddGrowableCol(1);
sgEntry->AddGrowableRow(1);
sgEntry->Add(EditCheatNameText, wxGBPosition(0, 0), wxGBSpan(1, 1), wxALIGN_CENTER_VERTICAL|wxEXPAND|wxALL, 5);
sgEntry->Add(EditCheatName, wxGBPosition(0, 1), wxGBSpan(1, 1), wxEXPAND|wxALL, 5);
sgEntry->Add(EntrySelection, wxGBPosition(0, 2), wxGBSpan(2, 1), wxEXPAND|wxALL, 5);
sgEntry->Add(EditCheatCode, wxGBPosition(1, 0), wxGBSpan(1, 2), wxEXPAND|wxALL, 5);
sbEntry->Add(sgEntry, 1, wxEXPAND);
sEditCheat->Add(sbEntry, 1, wxEXPAND|wxALL, 5);
wxBoxSizer* sEditCheatButtons = new wxBoxSizer(wxHORIZONTAL);
wxButton* bOK = new wxButton(this, wxID_OK, _("OK"), wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator);
wxButton* bCancel = new wxButton(this, wxID_CANCEL, _("Cancel"), wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator);
sEditCheatButtons->Add(0, 0, 1, wxEXPAND, 5);
sEditCheatButtons->Add(bOK, 0, wxALL, 5);
sEditCheatButtons->Add(bCancel, 0, wxALL, 5);
sEditCheat->Add(sEditCheatButtons, 0, wxEXPAND, 5);
this->SetSizer(sEditCheat);
sEditCheat->Layout();
}
void CARCodeAddEdit::OnClose(wxCloseEvent& WXUNUSED (event))
{
Destroy();
}
void CARCodeAddEdit::ChangeEntry(wxSpinEvent& event)
{
ActionReplay::ARCode currentCode = arCodes.at((int)arCodes.size()-1 - event.GetPosition());
EditCheatName->SetValue(wxString::FromAscii(currentCode.name.c_str()));
UpdateTextCtrl(currentCode);
}
void CARCodeAddEdit::SaveCheatData(wxCommandEvent& WXUNUSED (event))
{
std::vector<ActionReplay::AREntry> tempEntries;
std::string cheatValues = std::string(EditCheatCode->GetValue().mb_str());
bool bWhile = true; size_t line = 0;
while (bWhile)
{
bWhile = false;
u32 addr, value;
addr = strtol(std::string(cheatValues.substr(line, line+8)).c_str(), NULL, 16); // cmd_addr of ArCode
value = strtol(std::string(cheatValues.substr(line+9, line+17)).c_str(), NULL, 16); // value of ArCode
tempEntries.push_back(ActionReplay::AREntry(addr, value));
line = cheatValues.find("\n", line);
if (line != std::string::npos && cheatValues.length() > (line+17))
bWhile = true; // newline found, if not empty, go on
line++;
}
if (selection == -1)
{
ActionReplay::ARCode newCheat;
newCheat.name = std::string(EditCheatName->GetValue().mb_str());
newCheat.ops = tempEntries;
newCheat.active = true;
arCodes.push_back(newCheat);
}
else
{
arCodes.at(selection).name = std::string(EditCheatName->GetValue().mb_str());
arCodes.at(selection).ops = tempEntries;
}
AcceptAndClose();
}
void CARCodeAddEdit::UpdateTextCtrl(ActionReplay::ARCode arCode)
{
EditCheatCode->Clear();
for (u32 i = 0; i < arCode.ops.size(); i++)
EditCheatCode->AppendText(wxString::Format(wxT("%08X %08X\n"), arCode.ops.at(i).cmd_addr, arCode.ops.at(i).value));
}
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
+62 -62
View File
@@ -1,63 +1,63 @@
// Copyright (C) 2003-2008 Dolphin Project.
// This program 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, version 2.0.
// This program 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 2.0 for more details.
// A copy of the GPL 2.0 should have been included with the program.
// If not, see http://www.gnu.org/licenses/
// Official SVN repository and contact information can be found at
// http://code.google.com/p/dolphin-emu/
#include "SDCardWindow.h"
#include "Globals.h"
#include "IPC_HLE/HW/SDInterface.h"
BEGIN_EVENT_TABLE(wxSDCardWindow, wxWindow)
EVT_CLOSE( wxSDCardWindow::OnEvent_Window_Close)
EVT_BUTTON(ID_BUTTON_CLOSE, wxSDCardWindow::OnEvent_ButtonClose_Press)
END_EVENT_TABLE()
wxSDCardWindow::wxSDCardWindow(wxWindow* parent) :
wxDialog(parent, wxID_ANY, _T("SDCard Mounter"), wxDefaultPosition, wxSize(400, 400), wxDEFAULT_FRAME_STYLE | wxNO_FULL_REPAINT_ON_RESIZE)
{
Init_ChildControls();
Layout();
Show();
}
wxSDCardWindow::~wxSDCardWindow()
{
// On Disposal
}
void wxSDCardWindow::Init_ChildControls()
{
// Button Strip
m_Button_Close = new wxButton(this, ID_BUTTON_CLOSE, _T("Close"), wxDefaultPosition, wxDefaultSize);
wxBoxSizer* sButtons = new wxBoxSizer(wxHORIZONTAL);
sButtons->Add(m_Button_Close, 0, wxALL, 5);
wxBoxSizer* sMain = new wxBoxSizer(wxVERTICAL);
sMain->Add(sButtons, 0, wxALL, 5);
SetSizer(sMain);
Layout();
Fit();
}
void wxSDCardWindow::OnEvent_Window_Close(wxCloseEvent& WXUNUSED(event))
{
EndModal(0);
}
void wxSDCardWindow::OnEvent_ButtonClose_Press(wxCommandEvent& WXUNUSED(event))
{
EndModal(0);
// Copyright (C) 2003-2008 Dolphin Project.
// This program 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, version 2.0.
// This program 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 2.0 for more details.
// A copy of the GPL 2.0 should have been included with the program.
// If not, see http://www.gnu.org/licenses/
// Official SVN repository and contact information can be found at
// http://code.google.com/p/dolphin-emu/
#include "SDCardWindow.h"
#include "Globals.h"
#include "IPC_HLE/HW/SDInterface.h"
BEGIN_EVENT_TABLE(wxSDCardWindow, wxWindow)
EVT_CLOSE( wxSDCardWindow::OnEvent_Window_Close)
EVT_BUTTON(ID_BUTTON_CLOSE, wxSDCardWindow::OnEvent_ButtonClose_Press)
END_EVENT_TABLE()
wxSDCardWindow::wxSDCardWindow(wxWindow* parent) :
wxDialog(parent, wxID_ANY, _T("SDCard Mounter"), wxDefaultPosition, wxSize(400, 400), wxDEFAULT_FRAME_STYLE | wxNO_FULL_REPAINT_ON_RESIZE)
{
Init_ChildControls();
Layout();
Show();
}
wxSDCardWindow::~wxSDCardWindow()
{
// On Disposal
}
void wxSDCardWindow::Init_ChildControls()
{
// Button Strip
m_Button_Close = new wxButton(this, ID_BUTTON_CLOSE, _T("Close"), wxDefaultPosition, wxDefaultSize);
wxBoxSizer* sButtons = new wxBoxSizer(wxHORIZONTAL);
sButtons->Add(m_Button_Close, 0, wxALL, 5);
wxBoxSizer* sMain = new wxBoxSizer(wxVERTICAL);
sMain->Add(sButtons, 0, wxALL, 5);
SetSizer(sMain);
Layout();
Fit();
}
void wxSDCardWindow::OnEvent_Window_Close(wxCloseEvent& WXUNUSED(event))
{
EndModal(0);
}
void wxSDCardWindow::OnEvent_ButtonClose_Press(wxCommandEvent& WXUNUSED(event))
{
EndModal(0);
}
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
+135 -135
View File
@@ -1,136 +1,136 @@
//////////////////////////////////////////////////////////////////////////////////////////
//
// Licensetype: GNU General Public License (GPL)
//
// This program 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, version 2.0.
//
// This program 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 2.0 for more details.
//
// A copy of the GPL 2.0 should have been included with the program.
// If not, see http://www.gnu.org/licenses/
//
// Official SVN repository and contact information can be found at
// http://code.google.com/p/dolphin-emu/
//
//////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////
// File description
/* ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
Function: This file will get the status of the analog triggers of any connected XInput device.
This code was made with the help of SimpleController.cpp in the June 2008 Microsoft DirectX SDK
Samples.
///////////////////////////////////////////////////// */
#ifdef _WIN32
//////////////////////////////////////////////////////////////////////////////////////////
// Includes
// ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
#include <windows.h>
#include <XInput.h> // XInput API
#include "SDL.h" // Local
///////////////////////////////////////////////
namespace XInput
{
//////////////////////////////////////////////////////////////////////////////////////////
// Declarations
// ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
#define MAX_CONTROLLERS 4 // XInput handles up to 4 controllers
struct CONTROLER_STATE
{
XINPUT_STATE state;
bool bConnected;
};
CONTROLER_STATE g_Controllers[MAX_CONTROLLERS];
///////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////
// Init
// ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
/* Function: Calculate the number of connected XInput devices
Todo: Implement this to figure out if there are multiple XInput controllers connected,
we currently only try to connect to XInput device 0 */
void Init()
{
// Init state
//ZeroMemory( g_Controllers, sizeof( CONTROLER_STATE ) * MAX_CONTROLLERS );
// Declaration
DWORD dwResult;
// Calculate the number of connected XInput devices
for( DWORD i = 0; i < MAX_CONTROLLERS; i++ )
{
// Simply get the state of the controller from XInput.
dwResult = XInputGetState( i, &g_Controllers[i].state );
if( dwResult == ERROR_SUCCESS )
g_Controllers[i].bConnected = true;
else
g_Controllers[i].bConnected = false;
}
}
///////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////
// Get the trigger status
// ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
int GetXI(int Controller, int Button)
{
// Update the internal status
DWORD dwResult;
dwResult = XInputGetState( Controller, &g_Controllers[Controller].state );
if( dwResult != ERROR_SUCCESS ) return -1;
switch(Button)
{
case InputCommon::XI_TRIGGER_L:
return g_Controllers[0].state.Gamepad.bLeftTrigger;
case InputCommon::XI_TRIGGER_R:
return g_Controllers[0].state.Gamepad.bRightTrigger;
default:
return 0;
}
}
///////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////
// Check if a certain controller is connected
// ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
bool IsConnected(int Controller)
{
DWORD dwResult = XInputGetState( Controller, &g_Controllers[Controller].state );
// Update the connected status
if( dwResult == ERROR_SUCCESS )
return true;
else
return false;
}
///////////////////////////////////////////
} // XInput
//////////////////////////////////////////////////////////////////////////////////////////
//
// Licensetype: GNU General Public License (GPL)
//
// This program 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, version 2.0.
//
// This program 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 2.0 for more details.
//
// A copy of the GPL 2.0 should have been included with the program.
// If not, see http://www.gnu.org/licenses/
//
// Official SVN repository and contact information can be found at
// http://code.google.com/p/dolphin-emu/
//
//////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////
// File description
/* ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
Function: This file will get the status of the analog triggers of any connected XInput device.
This code was made with the help of SimpleController.cpp in the June 2008 Microsoft DirectX SDK
Samples.
///////////////////////////////////////////////////// */
#ifdef _WIN32
//////////////////////////////////////////////////////////////////////////////////////////
// Includes
// ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
#include <windows.h>
#include <XInput.h> // XInput API
#include "SDL.h" // Local
///////////////////////////////////////////////
namespace XInput
{
//////////////////////////////////////////////////////////////////////////////////////////
// Declarations
// ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
#define MAX_CONTROLLERS 4 // XInput handles up to 4 controllers
struct CONTROLER_STATE
{
XINPUT_STATE state;
bool bConnected;
};
CONTROLER_STATE g_Controllers[MAX_CONTROLLERS];
///////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////
// Init
// ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
/* Function: Calculate the number of connected XInput devices
Todo: Implement this to figure out if there are multiple XInput controllers connected,
we currently only try to connect to XInput device 0 */
void Init()
{
// Init state
//ZeroMemory( g_Controllers, sizeof( CONTROLER_STATE ) * MAX_CONTROLLERS );
// Declaration
DWORD dwResult;
// Calculate the number of connected XInput devices
for( DWORD i = 0; i < MAX_CONTROLLERS; i++ )
{
// Simply get the state of the controller from XInput.
dwResult = XInputGetState( i, &g_Controllers[i].state );
if( dwResult == ERROR_SUCCESS )
g_Controllers[i].bConnected = true;
else
g_Controllers[i].bConnected = false;
}
}
///////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////
// Get the trigger status
// ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
int GetXI(int Controller, int Button)
{
// Update the internal status
DWORD dwResult;
dwResult = XInputGetState( Controller, &g_Controllers[Controller].state );
if( dwResult != ERROR_SUCCESS ) return -1;
switch(Button)
{
case InputCommon::XI_TRIGGER_L:
return g_Controllers[0].state.Gamepad.bLeftTrigger;
case InputCommon::XI_TRIGGER_R:
return g_Controllers[0].state.Gamepad.bRightTrigger;
default:
return 0;
}
}
///////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////
// Check if a certain controller is connected
// ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
bool IsConnected(int Controller)
{
DWORD dwResult = XInputGetState( Controller, &g_Controllers[Controller].state );
// Update the connected status
if( dwResult == ERROR_SUCCESS )
return true;
else
return false;
}
///////////////////////////////////////////
} // XInput
#endif
@@ -1,26 +1,26 @@
// Copyright (C) 2003-2008 Dolphin Project.
// This program 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, version 2.0.
// This program 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 2.0 for more details.
// A copy of the GPL 2.0 should have been included with the program.
// If not, see http://www.gnu.org/licenses/
// Official SVN repository and contact information can be found at
// http://code.google.com/p/dolphin-emu/
#include "Common.h"
#include "NativeVertexWriter.h"
namespace VertexManager
{
u8* s_pCurBufferPointer = NULL;
// Copyright (C) 2003-2008 Dolphin Project.
// This program 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, version 2.0.
// This program 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 2.0 for more details.
// A copy of the GPL 2.0 should have been included with the program.
// If not, see http://www.gnu.org/licenses/
// Official SVN repository and contact information can be found at
// http://code.google.com/p/dolphin-emu/
#include "Common.h"
#include "NativeVertexWriter.h"
namespace VertexManager
{
u8* s_pCurBufferPointer = NULL;
}
@@ -1,117 +1,117 @@
// Copyright (C) 2003-2008 Dolphin Project.
// This program 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, version 2.0.
// This program 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 2.0 for more details.
// A copy of the GPL 2.0 should have been included with the program.
// If not, see http://www.gnu.org/licenses/
// Official SVN repository and contact information can be found at
// http://code.google.com/p/dolphin-emu/
// --------------------
// Includes
#include <string>
#include <stdio.h>
#include "Common.h"
#ifdef _WIN32
#include <windows.h>
#endif
#if defined(HAVE_WX) && HAVE_WX
#include "../Debugger/Debugger.h"
extern CDebugger* m_frame;
#endif
#include "../Debugger/File.h"
// --------------------
// On and off
bool g_consoleEnable = true;
//int gSaveFile = 0;
#define DEBUG_HLE
// --------------------
// Create file handles
#ifdef DEBUG_HLE
FILE* __fStdOut[nFiles];
#endif
// =======================================================================================
/* Open file handles */
// -------------
void StartFile(int width, int height, char* fname)
{
#if defined(DEBUG_HLE) && defined(_WIN32)
if(fname)
{
for(int i = 0; i < nFiles; i++)
{
// Edit the log file name
std::string FileEnding = ".log";
std::string FileName = fname;
char buffer[33]; _itoa(i, buffer, 10); // convert number to string
std::string FullFilename = (FileName + buffer + FileEnding);
__fStdOut[i] = fopen(FullFilename.c_str(), "w");
}
}
#endif
}
// ======================
//////////////////////////////////////////////////////////////////////////////////////////
/* Close the file handles */
// -------------
void CloseFile()
{
// Close the file handles
for(int i = 0; i < nFiles; i++)
{
if(__fStdOut[i]) fclose(__fStdOut[i]);
}
}
//////////////////////////////
// ---------------------------------------------------------------------------------------
// File printf function
// -------------
int PrintFile(int a, char *fmt, ...)
{
#if defined(DEBUG_HLE) && defined(_WIN32)
if(m_frame->gSaveFile)
{
char s[StringSize];
va_list argptr;
int cnt;
va_start(argptr, fmt);
cnt = vsnprintf(s, StringSize, fmt, argptr);
va_end(argptr);
// ---------------------------------------------------------------------------------------
if(__fStdOut[a]) // TODO: make this work, we have to set all default values to NULL
// to make it work
fprintf(__fStdOut[a], s);
// -------------
return(cnt);
}
else
{
return 0;
}
#else
return 0;
#endif
}
// Copyright (C) 2003-2008 Dolphin Project.
// This program 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, version 2.0.
// This program 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 2.0 for more details.
// A copy of the GPL 2.0 should have been included with the program.
// If not, see http://www.gnu.org/licenses/
// Official SVN repository and contact information can be found at
// http://code.google.com/p/dolphin-emu/
// --------------------
// Includes
#include <string>
#include <stdio.h>
#include "Common.h"
#ifdef _WIN32
#include <windows.h>
#endif
#if defined(HAVE_WX) && HAVE_WX
#include "../Debugger/Debugger.h"
extern CDebugger* m_frame;
#endif
#include "../Debugger/File.h"
// --------------------
// On and off
bool g_consoleEnable = true;
//int gSaveFile = 0;
#define DEBUG_HLE
// --------------------
// Create file handles
#ifdef DEBUG_HLE
FILE* __fStdOut[nFiles];
#endif
// =======================================================================================
/* Open file handles */
// -------------
void StartFile(int width, int height, char* fname)
{
#if defined(DEBUG_HLE) && defined(_WIN32)
if(fname)
{
for(int i = 0; i < nFiles; i++)
{
// Edit the log file name
std::string FileEnding = ".log";
std::string FileName = fname;
char buffer[33]; _itoa(i, buffer, 10); // convert number to string
std::string FullFilename = (FileName + buffer + FileEnding);
__fStdOut[i] = fopen(FullFilename.c_str(), "w");
}
}
#endif
}
// ======================
//////////////////////////////////////////////////////////////////////////////////////////
/* Close the file handles */
// -------------
void CloseFile()
{
// Close the file handles
for(int i = 0; i < nFiles; i++)
{
if(__fStdOut[i]) fclose(__fStdOut[i]);
}
}
//////////////////////////////
// ---------------------------------------------------------------------------------------
// File printf function
// -------------
int PrintFile(int a, char *fmt, ...)
{
#if defined(DEBUG_HLE) && defined(_WIN32)
if(m_frame->gSaveFile)
{
char s[StringSize];
va_list argptr;
int cnt;
va_start(argptr, fmt);
cnt = vsnprintf(s, StringSize, fmt, argptr);
va_end(argptr);
// ---------------------------------------------------------------------------------------
if(__fStdOut[a]) // TODO: make this work, we have to set all default values to NULL
// to make it work
fprintf(__fStdOut[a], s);
// -------------
return(cnt);
}
else
{
return 0;
}
#else
return 0;
#endif
}

Some files were not shown because too many files have changed in this diff Show More