[RSP] some scope and spacing formatting clean-ups

This commit is contained in:
unknown 2015-03-18 00:50:48 -04:00
parent 86952f5cc6
commit b890afe78b
10 changed files with 549 additions and 286 deletions

View File

@ -57,10 +57,12 @@ void BuildRecompilerCPU(void);
extern HANDLE hMutex;
void SetCPU(DWORD core) {
void SetCPU(DWORD core)
{
WaitForSingleObjectEx(hMutex, 1000 * 100, FALSE);
CPUCore = core;
switch (core) {
switch (core)
{
case RecompilerCPU:
BuildRecompilerCPU();
break;
@ -71,7 +73,8 @@ void SetCPU(DWORD core) {
ReleaseMutex(hMutex);
}
void Build_RSP ( void ) {
void Build_RSP ( void )
{
int i;
extern UWORD32 Recp, RecpResult, SQroot, SQrootResult;
@ -150,16 +153,19 @@ void Build_RSP ( void ) {
Indx[30].DW = 0x0001020304050706; /* 6 */
Indx[31].DW = 0x0001020304050607; /* 7 */
for (i = 16; i < 32; i ++) {
for (i = 16; i < 32; i ++)
{
int count;
for (count = 0; count < 8; count ++) {
for (count = 0; count < 8; count ++)
{
Indx[i].B[count] = 7 - Indx[i].B[count];
EleSpec[i].B[count] = 7 - EleSpec[i].B[count];
}
for (count = 0; count < 4; count ++) {
for (count = 0; count < 4; count ++)
{
BYTE Temp;
Temp = Indx[i].B[count];
Indx[i].B[count] = Indx[i].B[7 - count];
Indx[i].B[7 - count] = Temp;
@ -182,44 +188,55 @@ void Build_RSP ( void ) {
*******************************************************************/
DWORD RunInterpreterCPU(DWORD Cycles);
DWORD RunRecompilerCPU ( DWORD Cycles );
DWORD RunRecompilerCPU (DWORD Cycles);
#define MI_INTR_SP 0x01 /* Bit 0: SP intr */
__declspec(dllexport) DWORD DoRspCycles ( DWORD Cycles ) {
__declspec(dllexport) DWORD DoRspCycles ( DWORD Cycles )
{
extern BOOL AudioHle, GraphicsHle;
DWORD TaskType = *(DWORD*)(RSPInfo.DMEM + 0xFC0);
/* if (*RSPInfo.SP_STATUS_REG & SP_STATUS_SIG0) {
/* if (*RSPInfo.SP_STATUS_REG & SP_STATUS_SIG0)
{
*RSPInfo.SP_STATUS_REG &= ~SP_STATUS_SIG0;
*RSPInfo.MI_INTR_REG |= MI_INTR_SP;
RSPInfo.CheckInterrupts();
return Cycles;
}
*/
if (TaskType == 1 && GraphicsHle && *(DWORD*)(RSPInfo.DMEM + 0x0ff0) != 0) {
if (RSPInfo.ProcessDList != NULL) {
if (TaskType == 1 && GraphicsHle && *(DWORD*)(RSPInfo.DMEM + 0x0ff0) != 0)
{
if (RSPInfo.ProcessDList != NULL)
{
RSPInfo.ProcessDList();
}
*RSPInfo.SP_STATUS_REG |= (0x0203 );
if ((*RSPInfo.SP_STATUS_REG & SP_STATUS_INTR_BREAK) != 0 ) {
if ((*RSPInfo.SP_STATUS_REG & SP_STATUS_INTR_BREAK) != 0 )
{
*RSPInfo.MI_INTR_REG |= R4300i_SP_Intr;
RSPInfo.CheckInterrupts();
}
*RSPInfo.DPC_STATUS_REG &= ~0x0002;
return Cycles;
} else if (TaskType == 2 && AudioHle) {
if (RSPInfo.ProcessAList != NULL) {
}
else if (TaskType == 2 && AudioHle)
{
if (RSPInfo.ProcessAList != NULL)
{
RSPInfo.ProcessAList();
}
*RSPInfo.SP_STATUS_REG |= (0x0203 );
if ((*RSPInfo.SP_STATUS_REG & SP_STATUS_INTR_BREAK) != 0 ) {
if ((*RSPInfo.SP_STATUS_REG & SP_STATUS_INTR_BREAK) != 0 )
{
*RSPInfo.MI_INTR_REG |= R4300i_SP_Intr;
RSPInfo.CheckInterrupts();
}
return Cycles;
} else if (TaskType == 7) {
}
else if (TaskType == 7)
{
RSPInfo.ShowCFB();
}
@ -227,14 +244,16 @@ __declspec(dllexport) DWORD DoRspCycles ( DWORD Cycles ) {
/*
*RSPInfo.SP_STATUS_REG |= (0x0203 );
if ((*RSPInfo.SP_STATUS_REG & SP_STATUS_INTR_BREAK) != 0 ) {
if ((*RSPInfo.SP_STATUS_REG & SP_STATUS_INTR_BREAK) != 0 )
{
*RSPInfo.MI_INTR_REG |= R4300i_SP_Intr;
RSPInfo.CheckInterrupts();
}
//return Cycles;
*/
if (Profiling && !IndvidualBlock) {
if (Profiling && !IndvidualBlock)
{
StartTimer((DWORD)Timer_RSP_Running);
}
@ -246,7 +265,8 @@ __declspec(dllexport) DWORD DoRspCycles ( DWORD Cycles ) {
}
RSP_MfStatusCount = 0;
switch (CPUCore) {
switch (CPUCore)
{
case RecompilerCPU:
RunRecompilerCPU(Cycles);
break;
@ -256,7 +276,8 @@ __declspec(dllexport) DWORD DoRspCycles ( DWORD Cycles ) {
}
ReleaseMutex(hMutex);
if (Profiling && !IndvidualBlock) {
if (Profiling && !IndvidualBlock)
{
StartTimer((DWORD)Timer_R4300_Running);
}

View File

@ -96,15 +96,18 @@ const char * AboutMsg ( void )
}
/************ Functions ***********/
DWORD AsciiToHex (char * HexValue) {
DWORD AsciiToHex (char * HexValue)
{
DWORD Count, Finish, Value = 0;
Finish = strlen(HexValue);
if (Finish > 8 ) { Finish = 8; }
for (Count = 0; Count < Finish; Count++){
for (Count = 0; Count < Finish; Count++)
{
Value = (Value << 4);
switch( HexValue[Count] ) {
switch( HexValue[Count] )
{
case '0': break;
case '1': Value += 1; break;
case '2': Value += 2; break;
@ -135,7 +138,8 @@ DWORD AsciiToHex (char * HexValue) {
return Value;
}
void DisplayError (char * Message, ...) {
void DisplayError (char * Message, ...)
{
char Msg[400];
va_list ap;
@ -152,7 +156,8 @@ void DisplayError (char * Message, ...) {
input: none
output: none
*******************************************************************/
__declspec(dllexport) void CloseDLL (void) {
__declspec(dllexport) void CloseDLL (void)
{
FreeMemory();
}
@ -163,11 +168,13 @@ __declspec(dllexport) void CloseDLL (void) {
input: a handle to the window that calls this function
output: none
*******************************************************************/
__declspec(dllexport) void DllAbout ( HWND hParent ) {
__declspec(dllexport) void DllAbout ( HWND hParent )
{
MessageBox(hParent,AboutMsg(),"About",MB_OK | MB_ICONINFORMATION );
}
BOOL WINAPI DllMain( HINSTANCE hinst, DWORD /*fdwReason*/, LPVOID /*lpvReserved*/ ){
BOOL WINAPI DllMain( HINSTANCE hinst, DWORD /*fdwReason*/, LPVOID /*lpvReserved*/ )
{
hinstDLL = hinst;
return TRUE;
}
@ -179,7 +186,8 @@ BOOL WINAPI DllMain( HINSTANCE hinst, DWORD /*fdwReason*/, LPVOID /*lpvReserved
filled by the function. (see def above)
output: none
*******************************************************************/
__declspec(dllexport) void GetDllInfo ( PLUGIN_INFO * PluginInfo ) {
__declspec(dllexport) void GetDllInfo ( PLUGIN_INFO * PluginInfo )
{
PluginInfo->Version = 0x0102;
PluginInfo->Type = PLUGIN_TYPE_RSP;
#ifdef _DEBUG
@ -259,7 +267,8 @@ __declspec(dllexport) void GetRspDebugInfo ( RSPDEBUG_INFO * DebugInfo )
RSP_COMPILER Compiler;
void DetectCpuSpecs(void) {
void DetectCpuSpecs(void)
{
DWORD Intel_Features = 0;
DWORD AMD_Features = 0;
@ -279,24 +288,31 @@ void DetectCpuSpecs(void) {
AMD_Features = Intel_Features = 0;
}
if (Intel_Features & 0x02000000) {
if (Intel_Features & 0x02000000)
{
Compiler.mmx2 = TRUE;
Compiler.sse = TRUE;
}
if (Intel_Features & 0x00800000) {
if (Intel_Features & 0x00800000)
{
Compiler.mmx = TRUE;
}
if (AMD_Features & 0x40000000) {
if (AMD_Features & 0x40000000)
{
Compiler.mmx2 = TRUE;
}
if (Intel_Features & 0x00008000) {
if (Intel_Features & 0x00008000)
{
ConditionalMove = TRUE;
} else {
}
else
{
ConditionalMove = FALSE;
}
}
__declspec(dllexport) void InitiateRSP ( RSP_INFO Rsp_Info, DWORD * CycleCount) {
__declspec(dllexport) void InitiateRSP ( RSP_INFO Rsp_Info, DWORD * CycleCount)
{
RSPInfo = Rsp_Info;
AudioHle = GetSystemSetting(Set_AudioHle);
GraphicsHle = GetSystemSetting(Set_GraphicsHle);
@ -320,14 +336,17 @@ __declspec(dllexport) void InitiateRSP ( RSP_INFO Rsp_Info, DWORD * CycleCount)
above.
output: none
*******************************************************************/
__declspec(dllexport) void InitiateRSPDebugger ( DEBUG_INFO Debug_Info) {
__declspec(dllexport) void InitiateRSPDebugger ( DEBUG_INFO Debug_Info)
{
DebugInfo = Debug_Info;
}
void ProcessMenuItem(int ID) {
void ProcessMenuItem(int ID)
{
UINT uState;
switch (ID) {
switch (ID)
{
case ID_RSPCOMMANDS: Enter_RSP_Commands_Window(); break;
case ID_RSPREGISTERS: Enter_RSP_Register_Window(); break;
case ID_DUMP_RSPCODE: DumpRSPCode(); break;
@ -337,12 +356,15 @@ void ProcessMenuItem(int ID) {
{
uState = GetMenuState(hRSPMenu, ID_PROFILING_ON, MF_BYCOMMAND);
if (uState & MFS_CHECKED) {
if (uState & MFS_CHECKED)
{
CheckMenuItem( hRSPMenu, ID_PROFILING_ON, MF_BYCOMMAND | MFS_UNCHECKED );
CheckMenuItem( hRSPMenu, ID_PROFILING_OFF, MF_BYCOMMAND | MFS_CHECKED );
SetSetting(Set_Profiling,FALSE);
if (DebuggingEnabled) { Profiling = FALSE; }
} else {
}
else
{
CheckMenuItem( hRSPMenu, ID_PROFILING_ON, MF_BYCOMMAND | MFS_CHECKED );
CheckMenuItem( hRSPMenu, ID_PROFILING_OFF, MF_BYCOMMAND | MFS_UNCHECKED );
SetSetting(Set_Profiling,TRUE);
@ -356,11 +378,14 @@ void ProcessMenuItem(int ID) {
{
uState = GetMenuState(hRSPMenu, ID_PROFILING_LOGINDIVIDUALBLOCKS, MF_BYCOMMAND);
if (uState & MFS_CHECKED) {
if (uState & MFS_CHECKED)
{
CheckMenuItem( hRSPMenu, ID_PROFILING_LOGINDIVIDUALBLOCKS, MF_BYCOMMAND | MFS_UNCHECKED );
SetSetting(Set_IndvidualBlock,FALSE);
if (DebuggingEnabled) { IndvidualBlock = FALSE; }
} else {
}
else
{
CheckMenuItem( hRSPMenu, ID_PROFILING_LOGINDIVIDUALBLOCKS, MF_BYCOMMAND | MFS_CHECKED );
SetSetting(Set_IndvidualBlock,TRUE);
if (DebuggingEnabled) { IndvidualBlock = TRUE; }
@ -371,11 +396,14 @@ void ProcessMenuItem(int ID) {
{
uState = GetMenuState(hRSPMenu, ID_SHOWCOMPILERERRORS, MF_BYCOMMAND);
if (uState & MFS_CHECKED) {
if (uState & MFS_CHECKED)
{
CheckMenuItem( hRSPMenu, ID_SHOWCOMPILERERRORS, MF_BYCOMMAND | MFS_UNCHECKED );
SetSetting(Set_ShowErrors,FALSE);
if (DebuggingEnabled) { ShowErrors = FALSE; }
} else {
}
else
{
CheckMenuItem( hRSPMenu, ID_SHOWCOMPILERERRORS, MF_BYCOMMAND | MFS_CHECKED );
SetSetting(Set_ShowErrors,TRUE);
if (DebuggingEnabled) { ShowErrors = TRUE; }
@ -389,11 +417,14 @@ void ProcessMenuItem(int ID) {
{
uState = GetMenuState(hRSPMenu, ID_BREAKONSTARTOFTASK, MF_BYCOMMAND);
if (uState & MFS_CHECKED) {
if (uState & MFS_CHECKED)
{
CheckMenuItem( hRSPMenu, ID_BREAKONSTARTOFTASK, MF_BYCOMMAND | MFS_UNCHECKED );
SetSetting(Set_BreakOnStart,FALSE);
if (DebuggingEnabled) { BreakOnStart = FALSE; }
} else {
}
else
{
CheckMenuItem( hRSPMenu, ID_BREAKONSTARTOFTASK, MF_BYCOMMAND | MFS_CHECKED );
SetSetting(Set_BreakOnStart,TRUE);
if (DebuggingEnabled) { BreakOnStart = TRUE; }
@ -404,7 +435,8 @@ void ProcessMenuItem(int ID) {
{
uState = GetMenuState(hRSPMenu, ID_LOGRDPCOMMANDS, MF_BYCOMMAND);
if (uState & MFS_CHECKED) {
if (uState & MFS_CHECKED)
{
CheckMenuItem( hRSPMenu, ID_LOGRDPCOMMANDS, MF_BYCOMMAND | MFS_UNCHECKED );
SetSetting(Set_LogRDP,FALSE);
if (DebuggingEnabled)
@ -412,7 +444,9 @@ void ProcessMenuItem(int ID) {
LogRDP = FALSE;
StopRDPLog();
}
} else {
}
else
{
CheckMenuItem( hRSPMenu, ID_LOGRDPCOMMANDS, MF_BYCOMMAND | MFS_CHECKED );
SetSetting(Set_LogRDP,TRUE);
if (DebuggingEnabled)
@ -427,7 +461,8 @@ void ProcessMenuItem(int ID) {
{
uState = GetMenuState(hRSPMenu, ID_SETTINGS_LOGX86CODE, MF_BYCOMMAND);
if (uState & MFS_CHECKED) {
if (uState & MFS_CHECKED)
{
CheckMenuItem( hRSPMenu, ID_SETTINGS_LOGX86CODE, MF_BYCOMMAND | MFS_UNCHECKED );
SetSetting(Set_LogX86Code,FALSE);
if (DebuggingEnabled)
@ -435,7 +470,9 @@ void ProcessMenuItem(int ID) {
LogX86Code = FALSE;
StopCPULog();
}
} else {
}
else
{
CheckMenuItem( hRSPMenu, ID_SETTINGS_LOGX86CODE, MF_BYCOMMAND | MFS_CHECKED );
SetSetting(Set_LogX86Code,TRUE);
if (DebuggingEnabled)
@ -488,7 +525,8 @@ __declspec(dllexport) void RomOpen (void)
output: none
*******************************************************************/
__declspec(dllexport) void RomClosed (void) {
if (Profiling) {
if (Profiling)
{
StopTimer();
GenerateTimerResults();
}
@ -501,14 +539,17 @@ __declspec(dllexport) void RomClosed (void) {
#endif
}
static BOOL GetBooleanCheck(HWND hDlg, DWORD DialogID) {
static BOOL GetBooleanCheck(HWND hDlg, DWORD DialogID)
{
return (IsDlgButtonChecked(hDlg, DialogID) == BST_CHECKED) ? TRUE : FALSE;
}
BOOL CALLBACK CompilerDlgProc(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM /*lParam*/) {
BOOL CALLBACK CompilerDlgProc(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM /*lParam*/)
{
char Buffer[256];
switch (uMsg) {
switch (uMsg)
{
case WM_INITDIALOG:
if (Compiler.bDest == TRUE)
CheckDlgButton(hDlg, IDC_COMPILER_DEST, BST_CHECKED);
@ -535,16 +576,15 @@ BOOL CALLBACK CompilerDlgProc(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM /*lPar
SetTimer(hDlg, 1, 250, NULL);
break;
case WM_TIMER:
sprintf(Buffer, "x86: %2.2f KB / %2.2f KB", (float)(RecompPos - RecompCode) / 1024.0F,
pLastSecondary?(float)((pLastSecondary - RecompCodeSecondary) / 1024.0F):0);
SetDlgItemText(hDlg, IDC_COMPILER_BUFFERS, Buffer);
break;
case WM_COMMAND:
switch (GET_WM_COMMAND_ID(wParam, lParam)) {
switch (GET_WM_COMMAND_ID(wParam, lParam))
{
case IDOK:
Compiler.bDest = GetBooleanCheck(hDlg, IDC_COMPILER_DEST);
Compiler.bAccum = GetBooleanCheck(hDlg, IDC_COMPILER_ACCUM);
@ -570,31 +610,32 @@ BOOL CALLBACK CompilerDlgProc(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM /*lPar
KillTimer(hDlg, 1);
EndDialog(hDlg, TRUE);
break;
case IDCANCEL:
KillTimer(hDlg, 1);
EndDialog(hDlg, TRUE);
break;
}
break;
default:
return FALSE;
}
return TRUE;
}
BOOL CALLBACK ConfigDlgProc(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM /*lParam*/) {
BOOL CALLBACK ConfigDlgProc(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM /*lParam*/)
{
HWND hWndItem;
DWORD value;
switch (uMsg) {
switch (uMsg)
{
case WM_INITDIALOG:
if (AudioHle == TRUE) {
if (AudioHle == TRUE)
{
CheckDlgButton(hDlg, IDC_AUDIOHLE, BST_CHECKED);
}
if (GraphicsHle == TRUE) {
if (GraphicsHle == TRUE)
{
CheckDlgButton(hDlg, IDC_GRAPHICSHLE, BST_CHECKED);
}
@ -603,9 +644,9 @@ BOOL CALLBACK ConfigDlgProc(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM /*lParam
ComboBox_AddString(hWndItem, "Recompiler");
ComboBox_SetCurSel(hWndItem, CPUCore);
break;
case WM_COMMAND:
switch (GET_WM_COMMAND_ID(wParam, lParam)) {
switch (GET_WM_COMMAND_ID(wParam, lParam))
{
case IDOK:
hWndItem = GetDlgItem(hDlg, IDC_COMPILER_SELECT);
value = ComboBox_GetCurSel(hWndItem);
@ -621,19 +662,20 @@ BOOL CALLBACK ConfigDlgProc(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM /*lParam
break;
}
break;
default:
return FALSE;
}
return TRUE;
}
/*__declspec(dllexport) void DllConfig (HWND hWnd) {
/*__declspec(dllexport) void DllConfig (HWND hWnd)
{
// DialogBox(hinstDLL, "RSPCONFIG", hWnd, ConfigDlgProc);
DialogBox(hinstDLL, "RSPCONFIG", GetForegroundWindow(), ConfigDlgProc);
}*/
__declspec(dllexport) void EnableDebugging (BOOL Enabled) {
__declspec(dllexport) void EnableDebugging (BOOL Enabled)
{
DebuggingEnabled = Enabled;
if (DebuggingEnabled)
{

View File

@ -36,7 +36,8 @@ extern "C" {
#include <map>
#include <vector>
class CProfiling {
class CProfiling
{
typedef std::map<DWORD, __int64 > PROFILE_ENRTIES;
typedef PROFILE_ENRTIES::iterator PROFILE_ENRTY;
typedef PROFILE_ENRTIES::value_type PROFILE_VALUE;
@ -89,9 +90,12 @@ public:
__int64 TimeTaken = StopTime - StartTime;
PROFILE_ENRTY Entry = m_Entries.find(m_CurrentTimerAddr);
if (Entry != m_Entries.end()) {
if (Entry != m_Entries.end())
{
Entry->second += TimeTaken;
} else {
}
else
{
m_Entries.insert(PROFILE_ENRTIES::value_type(m_CurrentTimerAddr,TimeTaken));
}
@ -117,22 +121,27 @@ public:
//Get the total time
__int64 TotalTime = 0;
for (PROFILE_ENRTY itemTime = m_Entries.begin(); itemTime != m_Entries.end(); itemTime++ ) {
for (PROFILE_ENRTY itemTime = m_Entries.begin(); itemTime != m_Entries.end(); itemTime++ )
{
TotalTime += itemTime->second;
}
//Create a sortable list of items
std::vector<PROFILE_VALUE *> ItemList;
for (PROFILE_ENRTY Entry = m_Entries.begin(); Entry != m_Entries.end(); Entry++ ) {
for (PROFILE_ENRTY Entry = m_Entries.begin(); Entry != m_Entries.end(); Entry++ )
{
ItemList.push_back(&(*Entry));
}
//sort the list with a basic bubble sort
if (ItemList.size() > 0)
{
for (size_t OuterPass = 0; OuterPass < (ItemList.size() - 1); OuterPass++ ) {
for (size_t InnerPass = 0; InnerPass < (ItemList.size() - 1); InnerPass++ ) {
if (ItemList[InnerPass]->second < ItemList[InnerPass + 1]->second) {
for (size_t OuterPass = 0; OuterPass < (ItemList.size() - 1); OuterPass++ )
{
for (size_t InnerPass = 0; InnerPass < (ItemList.size() - 1); InnerPass++ )
{
if (ItemList[InnerPass]->second < ItemList[InnerPass + 1]->second)
{
PROFILE_VALUE * TempPtr = ItemList[InnerPass];
ItemList[InnerPass] = ItemList[InnerPass + 1];
ItemList[InnerPass + 1] = TempPtr;
@ -147,14 +156,17 @@ public:
{Timer_R4300_Running, "R4300: Running"},
{Timer_RDP_Running, "RDP: Running"},
};
for (size_t count = 0; count < ItemList.size(); count++ ) {
for (size_t count = 0; count < ItemList.size(); count++ )
{
char Buffer[255];
float CpuUsage = (float)(((double)ItemList[count]->second / (double)TotalTime) * 100);
if (CpuUsage <= 0.2) { continue; }
sprintf(Buffer,"Func 0x%08X",ItemList[count]->first);
for (int NameID = 0; NameID < (sizeof(TimerNames) / sizeof(TIMER_NAME)); NameID++) {
if (ItemList[count]->first == (DWORD)TimerNames[NameID].Timer) {
for (int NameID = 0; NameID < (sizeof(TimerNames) / sizeof(TIMER_NAME)); NameID++)
{
if (ItemList[count]->first == (DWORD)TimerNames[NameID].Timer)
{
strcpy(Buffer,TimerNames[NameID].Name);
break;
}
@ -165,7 +177,6 @@ public:
ShellExecute(NULL,"open",LogFileName.c_str(),NULL,NULL,SW_SHOW);
ResetCounters();
}
};
@ -176,23 +187,26 @@ CProfiling& GetProfiler ( void )
return Profile;
}
void ResetTimerList (void) {
void ResetTimerList (void)
{
GetProfiler().ResetCounters();
}
DWORD StartTimer (DWORD Address) {
DWORD StartTimer (DWORD Address)
{
return GetProfiler().StartTimer(Address);
}
void StopTimer (void) {
void StopTimer (void)
{
GetProfiler().StopTimer();
}
void GenerateTimerResults (void) {
void GenerateTimerResults (void)
{
GetProfiler().GenerateLog();
}
#ifdef todelete
#include <windows.h>
#include <stdio.h>
@ -206,14 +220,16 @@ DWORD StartTimeHi, StartTimeLo, StopTimeHi, StopTimeLo, TSE_Count, TSE_Max;
TIME_STAMP_ENTRY * TS_Entries = NULL;
char LastLabel[100];
void ResetTimerList (void) {
void ResetTimerList (void)
{
if (TS_Entries) { free(TS_Entries); }
TS_Entries = NULL;
TSE_Count = 0;
TSE_Max = 0;
}
void StartTimer (char * Label) {
void StartTimer (char * Label)
{
strcpy(LastLabel,Label);
_asm {
pushad
@ -224,7 +240,8 @@ void StartTimer (char * Label) {
}
}
void StopTimer (void) {
void StopTimer (void)
{
_asm {
pushad
rdtsc
@ -236,8 +253,10 @@ void StopTimer (void) {
{
DWORD count;
for (count = 0; count < TSE_Count; count ++) {
if (strcmp(LastLabel,TS_Entries[count].Label) == 0) {
for (count = 0; count < TSE_Count; count ++)
{
if (strcmp(LastLabel,TS_Entries[count].Label) == 0)
{
__int64 Time = ((unsigned __int64)StopTimeHi << 32) + (unsigned __int64)StopTimeLo;
Time -= ((unsigned __int64)StartTimeHi << 32) + (unsigned __int64)StartTimeLo;
TS_Entries[count].TimeTotal += Time;
@ -245,16 +264,21 @@ void StopTimer (void) {
}
}
}
if (TSE_Count == 0) {
if (TSE_Count == 0)
{
TS_Entries = (TIME_STAMP_ENTRY *)malloc(sizeof(TIME_STAMP_ENTRY) * 100);
if (TS_Entries == NULL) {
if (TS_Entries == NULL)
{
MessageBox(NULL,"TIME_STAMP_ENTRY == NULL ??","ERROR",MB_OK|MB_ICONERROR|MB_SETFOREGROUND);
}
TSE_Max = 100;
} else if (TSE_Count == TSE_Max) {
}
else if (TSE_Count == TSE_Max)
{
TSE_Max += 100;
TS_Entries = (TIME_STAMP_ENTRY *)realloc(TS_Entries,sizeof(TIME_STAMP_ENTRY) * TSE_Max);
if (TS_Entries == NULL) {
if (TS_Entries == NULL)
{
MessageBox(NULL,"TIME_STAMP_ENTRY == NULL ??","ERROR",MB_OK|MB_ICONERROR|MB_SETFOREGROUND);
}
}
@ -264,7 +288,8 @@ void StopTimer (void) {
TSE_Count +=1;
}
void GenerateTimerResults (void) {
void GenerateTimerResults (void)
{
char buffer[_MAX_PATH], drive[_MAX_DRIVE] ,dir[_MAX_DIR];
char fname[_MAX_FNAME],ext[_MAX_EXT], LogFileName[_MAX_PATH];
DWORD dwWritten, count, count2;
@ -280,10 +305,13 @@ void GenerateTimerResults (void) {
hLogFile = CreateFile(LogFileName,GENERIC_WRITE, FILE_SHARE_READ|FILE_SHARE_WRITE,NULL,
CREATE_ALWAYS,FILE_ATTRIBUTE_NORMAL | FILE_FLAG_SEQUENTIAL_SCAN, NULL);
SetFilePointer(hLogFile,0,NULL,FILE_BEGIN);
for (count = 0; count < TSE_Count; count ++) {
for (count2 = 0; count2 < (TSE_Count - 1); count2 ++) {
if (TS_Entries[count2].TimeTotal < TS_Entries[count2 + 1].TimeTotal) {
for (count = 0; count < TSE_Count; count ++)
{
for (count2 = 0; count2 < (TSE_Count - 1); count2 ++)
{
if (TS_Entries[count2].TimeTotal < TS_Entries[count2 + 1].TimeTotal)
{
TIME_STAMP_ENTRY Temp;
memcpy(&Temp,&TS_Entries[count2],sizeof(TIME_STAMP_ENTRY));
memcpy(&TS_Entries[count2],&TS_Entries[count2 + 1],sizeof(TIME_STAMP_ENTRY));
@ -292,10 +320,12 @@ void GenerateTimerResults (void) {
}
}
TotalTime = 0;
for (count = 0; count < TSE_Count; count ++) {
for (count = 0; count < TSE_Count; count ++)
{
TotalTime += TS_Entries[count].TimeTotal;
}
for (count = 0; count < (TSE_Count < 50?TSE_Count:50); count ++) {
for (count = 0; count < (TSE_Count < 50?TSE_Count:50); count ++)
{
sprintf(buffer,"%s - %0.2f%c\r\n",
TS_Entries[count].Label,
(((double)TS_Entries[count].TimeTotal / (double)TotalTime) * 100),'%'

View File

@ -72,29 +72,36 @@ BOOL InRSPCommandsWindow;
char CommandName[100];
DWORD Stepping_Commands, WaitingForStep;
void Create_RSP_Commands_Window ( int Child ) {
void Create_RSP_Commands_Window ( int Child )
{
DWORD ThreadID;
if ( Child ) {
if ( Child )
{
InRSPCommandsWindow = TRUE;
DialogBox( hinstDLL, "RSPCOMMAND", NULL,(DLGPROC)RSP_Commands_Proc );
InRSPCommandsWindow = FALSE;
memset(RSPCommandLine,0,sizeof(RSPCommandLine));
SetRSPCommandToRunning();
} else {
if (!InRSPCommandsWindow) {
}
else
{
if (!InRSPCommandsWindow)
{
Stepping_Commands = TRUE;
CreateThread(NULL,0,(LPTHREAD_START_ROUTINE)Create_RSP_Commands_Window,
(LPVOID)TRUE,0, &ThreadID);
} else {
}
else
{
SetForegroundWindow(RSPCommandshWnd);
}
}
}
void Disable_RSP_Commands_Window ( void ) {
void Disable_RSP_Commands_Window ( void )
{
SCROLLINFO si;
if (!InRSPCommandsWindow) { return; }
@ -108,7 +115,7 @@ void Disable_RSP_Commands_Window ( void ) {
EnableWindow(hRSPRegisters, FALSE);
EnableWindow(hR4300iDebugger, FALSE);
EnableWindow(hMemory, FALSE);
si.cbSize = sizeof(si);
si.fMask = SIF_RANGE | SIF_POS | SIF_PAGE;
si.nMin = 0;
@ -118,28 +125,33 @@ void Disable_RSP_Commands_Window ( void ) {
SetScrollInfo(hScrlBar,SB_CTL,&si,TRUE);
}
int DisplayRSPCommand (DWORD location, int InsertPos) {
int DisplayRSPCommand (DWORD location, int InsertPos)
{
uint32_t OpCode;
DWORD LinesUsed = 1, status;
BOOL Redraw = FALSE;
RSP_LW_IMEM(location, &OpCode);
status = 0;
if (location == *PrgCount) {status = RSP_Status_PC; }
if (CheckForRSPBPoint(location)) { status |= RSP_Status_BP; }
if (RSPCommandLine[InsertPos].opcode != OpCode) { Redraw = TRUE; }
if (RSPCommandLine[InsertPos].Location != location) { Redraw = TRUE; }
if (RSPCommandLine[InsertPos].status != status) { Redraw = TRUE; }
if (Redraw) {
if (Redraw)
{
RSPCommandLine[InsertPos].Location = location;
RSPCommandLine[InsertPos].status = status;
RSPCommandLine[InsertPos].opcode = OpCode;
sprintf(RSPCommandLine[InsertPos].String," 0x%03X\t%s",location,
RSPOpcodeName ( OpCode, location ));
if ( SendMessage(hList,LB_GETCOUNT,0,0) <= InsertPos) {
if ( SendMessage(hList,LB_GETCOUNT,0,0) <= InsertPos)
{
SendMessage(hList,LB_INSERTSTRING,(WPARAM)InsertPos, (LPARAM)location);
} else {
}
else
{
RECT ItemRC;
SendMessage(hList,LB_GETITEMRECT,(WPARAM)InsertPos, (LPARAM)&ItemRC);
RedrawWindow(hList,&ItemRC,NULL, RDW_INVALIDATE );
@ -148,7 +160,8 @@ int DisplayRSPCommand (DWORD location, int InsertPos) {
return LinesUsed;
}
void DumpRSPCode (void) {
void DumpRSPCode (void)
{
char string[100], LogFileName[255], *p ;
uint32_t OpCode;
DWORD location, dwWritten;
@ -156,14 +169,17 @@ void DumpRSPCode (void) {
strcpy(LogFileName,GetCommandLine() + 1);
if (strchr(LogFileName,'\"')) {
if (strchr(LogFileName,'\"'))
{
p = strchr(LogFileName,'\"');
*p = '\0';
}
if (strchr(LogFileName,'\\')) {
if (strchr(LogFileName,'\\'))
{
p = LogFileName;
while (strchr(p,'\\')) {
while (strchr(p,'\\'))
{
p = strchr(p,'\\');
p++;
}
@ -185,20 +201,23 @@ void DumpRSPCode (void) {
CloseHandle(hLogFile);
}
void DumpRSPData (void) {
void DumpRSPData (void)
{
char string[100], LogFileName[255], *p ;
uint32_t value;
DWORD location, dwWritten;
HANDLE hLogFile = NULL;
strcpy(LogFileName,GetCommandLine() + 1);
if (strchr(LogFileName,'\"')) {
if (strchr(LogFileName,'\"'))
{
p = strchr(LogFileName,'\"');
*p = '\0';
}
if (strchr(LogFileName,'\\')) {
if (strchr(LogFileName,'\\'))
{
p = LogFileName;
while (strchr(p,'\\')) {
p = strchr(p,'\\');
@ -214,7 +233,8 @@ void DumpRSPData (void) {
FILE_ATTRIBUTE_NORMAL | FILE_FLAG_SEQUENTIAL_SCAN, NULL);
SetFilePointer(hLogFile,0,NULL,FILE_BEGIN);
for (location = 0; location < 0x1000; location += 4) {
for (location = 0; location < 0x1000; location += 4)
{
RSP_LW_DMEM(location, &value);
sprintf(string," 0x%03X\t0x%08X\r\n", location, value);
WriteFile( hLogFile,string,strlen(string),&dwWritten,NULL );
@ -222,7 +242,8 @@ void DumpRSPData (void) {
CloseHandle(hLogFile);
}
void DrawRSPCommand ( LPARAM lParam ) {
void DrawRSPCommand ( LPARAM lParam )
{
char Command[150], Offset[30], Instruction[30], Arguments[40];
LPDRAWITEMSTRUCT ditem;
COLORREF oldColor = {0};
@ -233,40 +254,53 @@ void DrawRSPCommand ( LPARAM lParam ) {
ditem = (LPDRAWITEMSTRUCT)lParam;
strcpy(Command, RSPCommandLine[ditem->itemID].String);
if (strchr(Command,'\t')) {
if (strchr(Command,'\t'))
{
p1 = strchr(Command,'\t');
sprintf(Offset,"%.*s",p1 - Command, Command);
p1++;
if (strchr(p1,'\t')) {
if (strchr(p1,'\t'))
{
p2 = strchr(p1,'\t');
sprintf(Instruction,"%.*s",p2 - p1, p1);
sprintf(Arguments,"%s",p2 + 1);
} else {
}
else
{
sprintf(Instruction,"%s",p1);
sprintf(Arguments,"\0");
}
sprintf(Command,"\0");
} else {
}
else
{
sprintf(Offset,"\0");
sprintf(Instruction,"\0");
sprintf(Arguments,"\0");
}
if (*PrgCount == RSPCommandLine[ditem->itemID].Location) {
if (*PrgCount == RSPCommandLine[ditem->itemID].Location)
{
ResetColor = TRUE;
hBrush = (HBRUSH)(COLOR_HIGHLIGHT + 1);
oldColor = SetTextColor(ditem->hDC,RGB(255,255,255));
} else {
}
else
{
ResetColor = FALSE;
hBrush = (HBRUSH)GetStockObject(WHITE_BRUSH);
}
if (CheckForRSPBPoint( RSPCommandLine[ditem->itemID].Location )) {
if (CheckForRSPBPoint( RSPCommandLine[ditem->itemID].Location ))
{
ResetColor = TRUE;
if (*PrgCount == RSPCommandLine[ditem->itemID].Location) {
if (*PrgCount == RSPCommandLine[ditem->itemID].Location)
{
SetTextColor(ditem->hDC,RGB(255,0,0));
} else {
}
else
{
oldColor = SetTextColor(ditem->hDC,RGB(255,0,0));
}
}
@ -274,11 +308,12 @@ void DrawRSPCommand ( LPARAM lParam ) {
FillRect( ditem->hDC, &ditem->rcItem,hBrush);
SetBkMode( ditem->hDC, TRANSPARENT );
if (strlen (Command) == 0 ) {
if (strlen (Command) == 0 )
{
SetRect(&TextRect,ditem->rcItem.left,ditem->rcItem.top, ditem->rcItem.left + 83,
ditem->rcItem.bottom);
DrawText(ditem->hDC,Offset,strlen(Offset), &TextRect,DT_SINGLELINE | DT_VCENTER);
SetRect(&TextRect,ditem->rcItem.left + 83,ditem->rcItem.top, ditem->rcItem.left + 165,
ditem->rcItem.bottom);
DrawText(ditem->hDC,Instruction,strlen(Instruction), &TextRect,DT_SINGLELINE | DT_VCENTER);
@ -286,18 +321,19 @@ void DrawRSPCommand ( LPARAM lParam ) {
SetRect(&TextRect,ditem->rcItem.left + 165,ditem->rcItem.top, ditem->rcItem.right,
ditem->rcItem.bottom);
DrawText(ditem->hDC,Arguments,strlen(Arguments), &TextRect,DT_SINGLELINE | DT_VCENTER);
} else {
}
else
{
DrawText(ditem->hDC,Command,strlen(Command), &ditem->rcItem,DT_SINGLELINE | DT_VCENTER);
}
if (ResetColor == TRUE) {
SetTextColor( ditem->hDC, oldColor );
}
}
void Enable_RSP_Commands_Window ( void ) {
void Enable_RSP_Commands_Window ( void )
{
SCROLLINFO si;
if (!InRSPCommandsWindow) { return; }
@ -314,7 +350,7 @@ void Enable_RSP_Commands_Window ( void ) {
SendMessage(hBPButton, BM_SETSTYLE, BS_PUSHBUTTON,TRUE);
SendMessage(hStepButton, BM_SETSTYLE, BS_DEFPUSHBUTTON,TRUE);
SendMessage(RSPCommandshWnd, DM_SETDEFID,IDC_STEP_BUTTON,0);
if (Stepping_Commands) {
si.cbSize = sizeof(si);
si.fMask = SIF_RANGE | SIF_POS | SIF_PAGE;
@ -323,24 +359,26 @@ void Enable_RSP_Commands_Window ( void ) {
si.nPos = (*PrgCount >> 2);
si.nPage = 30;
SetScrollInfo(hScrlBar,SB_CTL,&si,TRUE);
SetRSPCommandViewto( *PrgCount );
SetForegroundWindow(RSPCommandshWnd);
}
}
void Enter_RSP_Commands_Window ( void ) {
void Enter_RSP_Commands_Window ( void )
{
Create_RSP_Commands_Window ( FALSE );
}
void Paint_RSP_Commands (HWND hDlg) {
void Paint_RSP_Commands (HWND hDlg)
{
PAINTSTRUCT ps;
RECT rcBox;
HFONT hOldFont;
int OldBkMode;
BeginPaint( hDlg, &ps );
rcBox.left = 5; rcBox.top = 5;
rcBox.right = 343; rcBox.bottom = 463;
DrawEdge( ps.hdc, &rcBox, EDGE_RAISED, BF_RECT );
@ -384,7 +422,8 @@ void Paint_RSP_Commands (HWND hDlg) {
EndPaint( hDlg, &ps );
}
void RefreshRSPCommands ( void ) {
void RefreshRSPCommands ( void )
{
DWORD location, LinesUsed;
char AsciiAddress[20];
int count;
@ -395,14 +434,17 @@ void RefreshRSPCommands ( void ) {
location = AsciiToHex(AsciiAddress) & ~3;
if (location > 0xF88) { location = 0xF88; }
for (count = 0 ; count < RSP_MaxCommandLines; count += LinesUsed ){
for (count = 0 ; count < RSP_MaxCommandLines; count += LinesUsed )
{
LinesUsed = DisplayRSPCommand ( location, count );
location += 4;
}
}
LRESULT CALLBACK RSP_Commands_Proc (HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam) {
switch (uMsg) {
LRESULT CALLBACK RSP_Commands_Proc (HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
switch (uMsg)
{
case WM_INITDIALOG:
RSPCommandshWnd = hDlg;
RSP_Commands_Setup( hDlg );
@ -411,7 +453,8 @@ LRESULT CALLBACK RSP_Commands_Proc (HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM
//StoreCurrentWinPos("RSP Commands",hDlg);
break;
case WM_DRAWITEM:
if (wParam == IDC_LIST) {
if (wParam == IDC_LIST)
{
DrawRSPCommand (lParam);
}
break;
@ -420,16 +463,22 @@ LRESULT CALLBACK RSP_Commands_Proc (HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM
RedrawWindow(hScrlBar,NULL,NULL, RDW_INVALIDATE |RDW_ERASE);
return TRUE;
case WM_COMMAND:
switch (LOWORD(wParam)) {
switch (LOWORD(wParam))
{
case IDC_LIST:
if (HIWORD(wParam) == LBN_DBLCLK ) {
if (HIWORD(wParam) == LBN_DBLCLK )
{
DWORD Location, Selected;
Selected = SendMessage(hList,LB_GETCURSEL,(WPARAM)0, (LPARAM)0);
Location = RSPCommandLine[Selected].Location;
if (Location != (DWORD)-1) {
if (CheckForRSPBPoint(Location)) {
if (Location != (DWORD)-1)
{
if (CheckForRSPBPoint(Location))
{
RemoveRSPBreakPoint(Location);
} else {
}
else
{
AddRSP_BPoint(Location, FALSE);
}
RefreshRSPCommands();
@ -437,7 +486,8 @@ LRESULT CALLBACK RSP_Commands_Proc (HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM
}
break;
case IDC_ADDRESS:
if (HIWORD(wParam) == EN_CHANGE ) {
if (HIWORD(wParam) == EN_CHANGE )
{
RefreshRSPCommands();
}
break;
@ -455,7 +505,8 @@ LRESULT CALLBACK RSP_Commands_Proc (HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM
WaitingFor_RSPStep = FALSE;
break;*/
case IDC_BP_BUTTON:
if (DebugInfo.Enter_BPoint_Window != NULL) {
if (DebugInfo.Enter_BPoint_Window != NULL)
{
DebugInfo.Enter_BPoint_Window();
}
break;
@ -463,17 +514,20 @@ LRESULT CALLBACK RSP_Commands_Proc (HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM
Enter_RSP_Register_Window();
break;
case IDC_R4300I_DEBUGGER_BUTTON:
if (DebugInfo.Enter_R4300i_Commands_Window != NULL) {
if (DebugInfo.Enter_R4300i_Commands_Window != NULL)
{
DebugInfo.Enter_R4300i_Commands_Window();
}
break;
case IDC_R4300I_REGISTERS_BUTTON:
if (DebugInfo.Enter_R4300i_Register_Window != NULL) {
if (DebugInfo.Enter_R4300i_Register_Window != NULL)
{
DebugInfo.Enter_R4300i_Register_Window();
}
break;
case IDC_MEMORY_BUTTON:
if (DebugInfo.Enter_Memory_Window != NULL) {
if (DebugInfo.Enter_Memory_Window != NULL)
{
DebugInfo.Enter_Memory_Window();
}
break;
@ -483,15 +537,17 @@ LRESULT CALLBACK RSP_Commands_Proc (HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM
}
break;
case WM_VSCROLL:
if ((HWND)lParam == hScrlBar) {
if ((HWND)lParam == hScrlBar)
{
DWORD location;
char Value[20];
SCROLLINFO si;
GetWindowText(hAddress,Value,sizeof(Value));
location = AsciiToHex(Value) & ~3;
switch (LOWORD(wParam)) {
switch (LOWORD(wParam))
{
case SB_THUMBTRACK:
sprintf(Value,"%03X",((short int)HIWORD(wParam) << 2 ));
SetWindowText(hAddress,Value);
@ -501,14 +557,17 @@ LRESULT CALLBACK RSP_Commands_Proc (HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM
SetScrollInfo(hScrlBar,SB_CTL,&si,TRUE);
break;
case SB_LINEDOWN:
if (location < 0xF88) {
if (location < 0xF88)
{
sprintf(Value,"%03X",location + 0x4);
SetWindowText(hAddress,Value);
si.cbSize = sizeof(si);
si.fMask = SIF_POS;
si.nPos = ((location + 0x4) >> 2);
SetScrollInfo(hScrlBar,SB_CTL,&si,TRUE);
} else {
}
else
{
sprintf(Value,"%03X",0xF88);
SetWindowText(hAddress,Value);
si.cbSize = sizeof(si);
@ -518,14 +577,17 @@ LRESULT CALLBACK RSP_Commands_Proc (HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM
}
break;
case SB_LINEUP:
if (location > 0x4 ) {
if (location > 0x4 )
{
sprintf(Value,"%03X",location - 0x4);
SetWindowText(hAddress,Value);
si.cbSize = sizeof(si);
si.fMask = SIF_POS;
si.nPos = ((location - 0x4) >> 2);
SetScrollInfo(hScrlBar,SB_CTL,&si,TRUE);
} else {
}
else
{
sprintf(Value,"%03X",0);
SetWindowText(hAddress,Value);
si.cbSize = sizeof(si);
@ -535,14 +597,17 @@ LRESULT CALLBACK RSP_Commands_Proc (HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM
}
break;
case SB_PAGEDOWN:
if ((location + 0x74)< 0xF88) {
if ((location + 0x74)< 0xF88)
{
sprintf(Value,"%03X",location + 0x74);
SetWindowText(hAddress,Value);
si.cbSize = sizeof(si);
si.fMask = SIF_POS;
si.nPos = ((location + 0x74) >> 2);
SetScrollInfo(hScrlBar,SB_CTL,&si,TRUE);
} else {
}
else
{
sprintf(Value,"%03X",0xF88);
SetWindowText(hAddress,Value);
si.cbSize = sizeof(si);
@ -552,14 +617,17 @@ LRESULT CALLBACK RSP_Commands_Proc (HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM
}
break;
case SB_PAGEUP:
if ((location - 0x74) > 0x74 ) {
if ((location - 0x74) > 0x74 )
{
sprintf(Value,"%03X",location - 0x74);
SetWindowText(hAddress,Value);
si.cbSize = sizeof(si);
si.fMask = SIF_POS;
si.nPos = ((location - 0x74) >> 2);
SetScrollInfo(hScrlBar,SB_CTL,&si,TRUE);
} else {
}
else
{
sprintf(Value,"%03X",0);
SetWindowText(hAddress,Value);
si.cbSize = sizeof(si);
@ -577,7 +645,8 @@ LRESULT CALLBACK RSP_Commands_Proc (HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM
return TRUE;
}
void RSP_Commands_Setup ( HWND hDlg ) {
void RSP_Commands_Setup ( HWND hDlg )
{
#define WindowWidth 457
#define WindowHeight 494
char Location[10];
@ -586,7 +655,8 @@ void RSP_Commands_Setup ( HWND hDlg ) {
hList = CreateWindowEx(WS_EX_STATICEDGE, "LISTBOX","", WS_CHILD | WS_VISIBLE |
LBS_OWNERDRAWFIXED | LBS_NOTIFY,14,30,303,445, hDlg,
(HMENU)IDC_LIST, hinstDLL,NULL );
if ( hList) {
if ( hList)
{
SendMessage(hList,WM_SETFONT, (WPARAM)GetStockObject(DEFAULT_GUI_FONT),0);
SendMessage(hList,LB_SETITEMHEIGHT, (WPARAM)0,(LPARAM)MAKELPARAM(14, 0));
}
@ -594,43 +664,49 @@ void RSP_Commands_Setup ( HWND hDlg ) {
sprintf(Location,"%03X",*PrgCount);
hAddress = CreateWindowEx(0,"EDIT",Location, WS_CHILD | ES_UPPERCASE | WS_VISIBLE |
WS_BORDER | WS_TABSTOP,375,17,36,18, hDlg,(HMENU)IDC_ADDRESS,hinstDLL, NULL );
if (hAddress) {
if (hAddress)
{
SendMessage(hAddress,WM_SETFONT, (WPARAM)GetStockObject(DEFAULT_GUI_FONT),0);
SendMessage(hAddress,EM_SETLIMITTEXT, (WPARAM)3,(LPARAM)0);
}
}
hFunctionlist = CreateWindowEx(0,"COMBOBOX","", WS_CHILD | WS_VSCROLL |
CBS_DROPDOWNLIST | CBS_SORT | WS_TABSTOP,352,56,89,150,hDlg,
(HMENU)IDC_FUNCTION_COMBO,hinstDLL,NULL);
if (hFunctionlist) {
if (hFunctionlist)
{
SendMessage(hFunctionlist,WM_SETFONT, (WPARAM)GetStockObject(DEFAULT_GUI_FONT),0);
}
hGoButton = CreateWindowEx(WS_EX_STATICEDGE, "BUTTON","&Go", WS_CHILD |
BS_DEFPUSHBUTTON | WS_VISIBLE | WS_TABSTOP, 347,56,100,24, hDlg,(HMENU)IDC_GO_BUTTON,
hinstDLL,NULL );
if (hGoButton) {
if (hGoButton)
{
SendMessage(hGoButton,WM_SETFONT, (WPARAM)GetStockObject(DEFAULT_GUI_FONT),0);
}
hBreakButton = CreateWindowEx(WS_EX_STATICEDGE, "BUTTON","&Break", WS_DISABLED |
WS_CHILD | BS_PUSHBUTTON | WS_VISIBLE | WS_TABSTOP | BS_TEXT, 347,85,100,24,hDlg,
(HMENU)IDC_BREAK_BUTTON,hinstDLL,NULL );
if (hBreakButton) {
if (hBreakButton)
{
SendMessage(hBreakButton,WM_SETFONT,(WPARAM)GetStockObject(DEFAULT_GUI_FONT),0);
}
hStepButton = CreateWindowEx(WS_EX_STATICEDGE, "BUTTON","&Step", WS_CHILD |
BS_PUSHBUTTON | WS_VISIBLE | WS_TABSTOP | BS_TEXT, 347,114,100,24,hDlg,
(HMENU)IDC_STEP_BUTTON,hinstDLL,NULL );
if (hStepButton) {
if (hStepButton)
{
SendMessage(hStepButton,WM_SETFONT,(WPARAM)GetStockObject(DEFAULT_GUI_FONT),0);
}
hSkipButton = CreateWindowEx(WS_EX_STATICEDGE, "BUTTON","&Skip", WS_CHILD |
BS_PUSHBUTTON | WS_VISIBLE | WS_TABSTOP | BS_TEXT, 347,143,100,24,hDlg,
(HMENU)IDC_SKIP_BUTTON,hinstDLL,NULL );
if (hSkipButton) {
if (hSkipButton)
{
SendMessage(hSkipButton,WM_SETFONT,(WPARAM)GetStockObject(DEFAULT_GUI_FONT),0);
}
@ -640,11 +716,13 @@ void RSP_Commands_Setup ( HWND hDlg ) {
if (DebugInfo.Enter_R4300i_Register_Window == NULL) { WndPos += 29;}
if (DebugInfo.Enter_Memory_Window == NULL) { WndPos += 29;}
if (DebugInfo.Enter_BPoint_Window != NULL) {
if (DebugInfo.Enter_BPoint_Window != NULL)
{
hBPButton = CreateWindowEx(WS_EX_STATICEDGE, "BUTTON","&Break Points", WS_CHILD |
BS_PUSHBUTTON | WS_VISIBLE | WS_TABSTOP | BS_TEXT, 347,WndPos,100,24,hDlg,
(HMENU)IDC_BP_BUTTON,hinstDLL,NULL );
if (hBPButton) {
if (hBPButton)
{
SendMessage(hBPButton,WM_SETFONT,(WPARAM)GetStockObject(DEFAULT_GUI_FONT),0);
}
}
@ -653,49 +731,59 @@ void RSP_Commands_Setup ( HWND hDlg ) {
hRSPRegisters = CreateWindowEx(WS_EX_STATICEDGE,"BUTTON", "RSP &Registers...",
WS_CHILD | BS_PUSHBUTTON | WS_VISIBLE | WS_TABSTOP | BS_TEXT, 347,WndPos,100,24,hDlg,
(HMENU)IDC_RSP_REGISTERS_BUTTON,hinstDLL,NULL );
if (hRSPRegisters) {
if (hRSPRegisters)
{
SendMessage(hRSPRegisters,WM_SETFONT,(WPARAM)GetStockObject(DEFAULT_GUI_FONT),0);
}
WndPos += 29;
if (DebugInfo.Enter_R4300i_Commands_Window != NULL) {
if (DebugInfo.Enter_R4300i_Commands_Window != NULL)
{
hR4300iDebugger = CreateWindowEx(WS_EX_STATICEDGE,"BUTTON", "R4300i &Debugger...",
WS_CHILD | BS_PUSHBUTTON | WS_VISIBLE | WS_TABSTOP | BS_TEXT, 347,WndPos,100,24,hDlg,
(HMENU)IDC_R4300I_DEBUGGER_BUTTON,hinstDLL,NULL );
if (hR4300iDebugger) {
if (hR4300iDebugger)
{
SendMessage(hR4300iDebugger,WM_SETFONT,(WPARAM)GetStockObject(DEFAULT_GUI_FONT),0);
}
}
WndPos += 29;
if (DebugInfo.Enter_R4300i_Register_Window != NULL) {
if (DebugInfo.Enter_R4300i_Register_Window != NULL)
{
hR4300iRegisters = CreateWindowEx(WS_EX_STATICEDGE,"BUTTON","R4300i R&egisters...",
WS_CHILD | BS_PUSHBUTTON | WS_VISIBLE | WS_TABSTOP | BS_TEXT, 347,WndPos,100,24,hDlg,
(HMENU)IDC_R4300I_REGISTERS_BUTTON,hinstDLL,NULL );
if (hR4300iRegisters) {
if (hR4300iRegisters)
{
SendMessage(hR4300iRegisters,WM_SETFONT, (WPARAM)GetStockObject(DEFAULT_GUI_FONT),0);
}
}
WndPos += 29;
if (DebugInfo.Enter_Memory_Window != NULL) {
if (DebugInfo.Enter_Memory_Window != NULL)
{
hMemory = CreateWindowEx(WS_EX_STATICEDGE,"BUTTON", "&Memory...", WS_CHILD |
BS_PUSHBUTTON | WS_VISIBLE | WS_TABSTOP | BS_TEXT, 347,WndPos,100,24,hDlg,
(HMENU)IDC_MEMORY_BUTTON,hinstDLL,NULL );
if (hMemory) {
if (hMemory)
{
SendMessage(hMemory,WM_SETFONT,(WPARAM)GetStockObject(DEFAULT_GUI_FONT),0);
}
}
hScrlBar = CreateWindowEx(WS_EX_STATICEDGE, "SCROLLBAR","", WS_CHILD | WS_VISIBLE |
WS_TABSTOP | SBS_VERT, 318,14,18,439, hDlg, (HMENU)IDC_SCRL_BAR, hinstDLL, NULL );
if ( RSP_Running ) {
if ( RSP_Running )
{
Enable_RSP_Commands_Window();
} else {
}
else
{
Disable_RSP_Commands_Window();
}
//if ( !GetStoredWinPos("RSP Commands", &X, &Y ) ) {
X = (GetSystemMetrics( SM_CXSCREEN ) - WindowWidth) / 2;
Y = (GetSystemMetrics( SM_CYSCREEN ) - WindowHeight) / 2;
@ -705,18 +793,23 @@ void RSP_Commands_Setup ( HWND hDlg ) {
SetWindowPos(hDlg,NULL,X,Y,WindowWidth,WindowHeight, SWP_NOZORDER | SWP_SHOWWINDOW);
}
char * RSPSpecialName ( DWORD OpCode, DWORD PC ) {
char * RSPSpecialName ( DWORD OpCode, DWORD PC )
{
OPCODE command;
command.Hex = OpCode;
PC = PC; // unused
switch (command.funct) {
switch (command.funct)
{
case RSP_SPECIAL_SLL:
if (command.rd != 0) {
if (command.rd != 0)
{
sprintf(CommandName,"SLL\t%s, %s, 0x%X",GPR_Name(command.rd),
GPR_Name(command.rt), command.sa);
} else {
}
else
{
sprintf(CommandName,"NOP");
}
break;
@ -796,11 +889,13 @@ char * RSPSpecialName ( DWORD OpCode, DWORD PC ) {
return CommandName;
}
char * RSPRegimmName ( DWORD OpCode, DWORD PC ) {
char * RSPRegimmName ( DWORD OpCode, DWORD PC )
{
OPCODE command;
command.Hex = OpCode;
switch (command.rt) {
switch (command.rt)
{
case RSP_REGIMM_BLTZ:
sprintf(CommandName,"BLTZ\t%s, 0x%03X",GPR_Name(command.rs),
(PC + ((short)command.offset << 2) + 4) & 0xFFC);
@ -814,9 +909,12 @@ char * RSPRegimmName ( DWORD OpCode, DWORD PC ) {
(PC + ((short)command.offset << 2) + 4) & 0xFFC);
break;
case RSP_REGIMM_BGEZAL:
if (command.rs == 0) {
if (command.rs == 0)
{
sprintf(CommandName,"BAL\t0x%03X",(PC + ((short)command.offset << 2) + 4) & 0xFFC);
} else {
}
else
{
sprintf(CommandName,"BGEZAL\t%s, 0x%03X",GPR_Name(command.rs),
(PC + ((short)command.offset << 2) + 4) & 0xFFC);
}
@ -828,13 +926,15 @@ char * RSPRegimmName ( DWORD OpCode, DWORD PC ) {
return CommandName;
}
char * RSPCop0Name ( DWORD OpCode, DWORD PC ) {
char * RSPCop0Name ( DWORD OpCode, DWORD PC )
{
OPCODE command;
command.Hex = OpCode;
PC = PC; // unused
switch (command.rs) {
switch (command.rs)
{
case RSP_COP0_MF:
sprintf(CommandName,"MFC0\t%s, %s",GPR_Name(command.rt),COP0_Name(command.rd));
break;
@ -848,14 +948,17 @@ char * RSPCop0Name ( DWORD OpCode, DWORD PC ) {
return CommandName;
}
char * RSPCop2Name ( DWORD OpCode, DWORD PC ) {
char * RSPCop2Name ( DWORD OpCode, DWORD PC )
{
OPCODE command;
command.Hex = OpCode;
PC = PC; // unused
if ( ( command.rs & 0x10 ) == 0 ) {
switch (command.rs) {
if ( ( command.rs & 0x10 ) == 0 )
{
switch (command.rs)
{
case RSP_COP2_MF:
sprintf(CommandName,"MFC2\t%s, $v%d [%d]",GPR_Name(command.rt),
command.rd, command.sa >> 1);
@ -876,8 +979,11 @@ char * RSPCop2Name ( DWORD OpCode, DWORD PC ) {
sprintf(CommandName,"RSP: Unknown\t%02X %02X %02X %02X",
command.Ascii[3],command.Ascii[2],command.Ascii[1],command.Ascii[0]);
}
} else {
switch (command.funct) {
}
else
{
switch (command.funct)
{
case RSP_VECTOR_VMULF:
sprintf(CommandName,"VMULF\t$v%d, $v%d, $v%d%s",command.sa, command.rd,
command.rt, ElementSpecifier(command.rs & 0xF));
@ -1061,13 +1167,15 @@ char * RSPCop2Name ( DWORD OpCode, DWORD PC ) {
return CommandName;
}
char * RSPLc2Name ( DWORD OpCode, DWORD PC ) {
char * RSPLc2Name ( DWORD OpCode, DWORD PC )
{
OPCODE command;
command.Hex = OpCode;
PC = PC; // unused
switch (command.rd) {
switch (command.rd)
{
case RSP_LSC2_BV:
sprintf(CommandName,"LBV\t$v%d [%d], 0x%04X (%s)",command.rt, command.del,
command.voffset, GPR_Name(command.base));
@ -1123,13 +1231,15 @@ char * RSPLc2Name ( DWORD OpCode, DWORD PC ) {
return CommandName;
}
char * RSPSc2Name ( DWORD OpCode, DWORD PC ) {
char * RSPSc2Name ( DWORD OpCode, DWORD PC )
{
OPCODE command;
command.Hex = OpCode;
PC = PC; // unused
switch (command.rd) {
switch (command.rd)
{
case RSP_LSC2_BV:
sprintf(CommandName,"SBV\t$v%d [%d], 0x%04X (%s)",command.rt, command.del,
command.voffset, GPR_Name(command.base));
@ -1185,11 +1295,13 @@ char * RSPSc2Name ( DWORD OpCode, DWORD PC ) {
return CommandName;
}
char * RSPOpcodeName ( DWORD OpCode, DWORD PC ) {
char * RSPOpcodeName ( DWORD OpCode, DWORD PC )
{
OPCODE command;
command.Hex = OpCode;
switch (command.op) {
switch (command.op)
{
case RSP_SPECIAL:
return RSPSpecialName(OpCode,PC);
break;
@ -1203,12 +1315,17 @@ char * RSPOpcodeName ( DWORD OpCode, DWORD PC ) {
sprintf(CommandName,"JAL\t0x%03X",(command.target << 2) & 0xFFC);
break;
case RSP_BEQ:
if (command.rs == 0 && command.rt == 0) {
if (command.rs == 0 && command.rt == 0)
{
sprintf(CommandName,"B\t0x%03X",(PC + ((short)command.offset << 2) + 4) & 0xFFC);
} else if (command.rs == 0 || command.rt == 0){
}
else if (command.rs == 0 || command.rt == 0)
{
sprintf(CommandName,"BEQZ\t%s, 0x%03X",GPR_Name(command.rs == 0 ? command.rt : command.rs),
(PC + ((short)command.offset << 2) + 4) & 0xFFC);
} else {
}
else
{
sprintf(CommandName,"BEQ\t%s, %s, 0x%03X",GPR_Name(command.rs),GPR_Name(command.rt),
(PC + ((short)command.offset << 2) + 4) & 0xFFC);
}
@ -1305,7 +1422,8 @@ char * RSPOpcodeName ( DWORD OpCode, DWORD PC ) {
return CommandName;
}
void SetRSPCommandToRunning ( void ) {
void SetRSPCommandToRunning ( void )
{
Stepping_Commands = FALSE;
if (InRSPCommandsWindow == FALSE) { return; }
EnableWindow(hGoButton, FALSE);
@ -1318,7 +1436,8 @@ void SetRSPCommandToRunning ( void ) {
SetFocus(hBreakButton);
}
void SetRSPCommandToStepping ( void ) {
void SetRSPCommandToStepping ( void )
{
if (InRSPCommandsWindow == FALSE) { return; }
EnableWindow(hGoButton, TRUE);
EnableWindow(hBreakButton, FALSE);
@ -1331,7 +1450,8 @@ void SetRSPCommandToStepping ( void ) {
Stepping_Commands = TRUE;
}
void SetRSPCommandViewto ( UINT NewLocation ) {
void SetRSPCommandViewto ( UINT NewLocation )
{
unsigned int location;
char Value[20];
@ -1340,10 +1460,13 @@ void SetRSPCommandViewto ( UINT NewLocation ) {
GetWindowText(hAddress,Value,sizeof(Value));
location = AsciiToHex(Value) & ~3;
if ( NewLocation < location || NewLocation >= location + 120 ) {
if ( NewLocation < location || NewLocation >= location + 120 )
{
sprintf(Value,"%03X",NewLocation);
SetWindowText(hAddress,Value);
} else {
}
else
{
RefreshRSPCommands();
}
}

View File

@ -147,5 +147,3 @@ void UpdateRSPRegistersScreen ( void );
extern UWORD32 RSP_GPR[32], RSP_Flags[4];
extern UDWORD RSP_ACCUM[8];
extern VECTOR RSP_Vect[32];

View File

@ -24,8 +24,8 @@
*
*/
#ifndef __Types_h
#define __Types_h
#ifndef __Types_h
#define __Types_h
/*
* Some versions of Microsoft Visual C/++ compilers before Visual Studio 2010

View File

@ -23,6 +23,7 @@
* should be forwarded to them so if they want them.
*
*/
#define STRINGIZE2(s) #s
#define STRINGIZE(s) STRINGIZE2(s)

View File

@ -33,7 +33,8 @@
#define IDC_LOCATION_EDIT 105
HWND BPoint_Win_hDlg, hRSPLocation = NULL;
void Add_BPoint ( void ) {
void Add_BPoint ( void )
{
char Title[10];
GetWindowText(hRSPLocation,Title,sizeof(Title));
@ -43,29 +44,35 @@ void Add_BPoint ( void ) {
}
}
int AddRSP_BPoint( DWORD Location, int Confirm ) {
int AddRSP_BPoint( DWORD Location, int Confirm )
{
int count;
if (NoOfBpoints == MaxBPoints) {
if (NoOfBpoints == MaxBPoints)
{
DisplayError("Max amount of Break Points set");
return FALSE;
}
for (count = 0; count < NoOfBpoints; count ++) {
if (BPoint[count].Location == Location) {
for (count = 0; count < NoOfBpoints; count ++)
{
if (BPoint[count].Location == Location)
{
DisplayError("You already have this Break Point");
return FALSE;
}
}
if (Confirm) {
if (Confirm)
{
char Message[150];
int Response;
sprintf(Message,"Break when:\n\nRSP's Program Counter = 0x%03X\n\nIs this correct?",
Location);
Response = MessageBox(BPoint_Win_hDlg, Message, "Breakpoint", MB_YESNO | MB_ICONINFORMATION);
if (Response == IDNO) {
if (Response == IDNO)
{
return FALSE;
}
}
@ -78,18 +85,22 @@ int AddRSP_BPoint( DWORD Location, int Confirm ) {
return TRUE;
}
int CheckForRSPBPoint ( DWORD Location ) {
int CheckForRSPBPoint ( DWORD Location )
{
int count;
for (count = 0; count < NoOfBpoints; count ++){
if (BPoint[count].Location == Location) {
for (count = 0; count < NoOfBpoints; count ++)
{
if (BPoint[count].Location == Location)
{
return TRUE;
}
}
return FALSE;
}
void CreateBPPanel ( HWND hDlg, RECT rcBox ) {
void CreateBPPanel ( HWND hDlg, RECT rcBox )
{
if (hRSPLocation != NULL) { return; }
rcBox = rcBox; // remove warning of unused
@ -97,8 +108,9 @@ void CreateBPPanel ( HWND hDlg, RECT rcBox ) {
BPoint_Win_hDlg = hDlg;
hRSPLocation = CreateWindowEx(0,"EDIT","", WS_CHILD | WS_BORDER | ES_UPPERCASE | WS_TABSTOP,
83,90,100,17,hDlg,(HMENU)IDC_LOCATION_EDIT,RSPInfo.hInst,NULL);
if (hRSPLocation) {
83,90,100,17,hDlg,(HMENU)IDC_LOCATION_EDIT,RSPInfo.hInst,NULL);
if (hRSPLocation)
{
char Title[20];
SendMessage(hRSPLocation,WM_SETFONT,(WPARAM)GetStockObject(DEFAULT_GUI_FONT),0);
SendMessage(hRSPLocation,EM_SETLIMITTEXT,(WPARAM)3,(LPARAM)0);
@ -107,20 +119,24 @@ void CreateBPPanel ( HWND hDlg, RECT rcBox ) {
}
}
void HideBPPanel ( void ) {
void HideBPPanel ( void )
{
ShowWindow(hRSPLocation,FALSE);
}
void PaintBPPanel ( PAINTSTRUCT ps ) {
void PaintBPPanel ( PAINTSTRUCT ps )
{
TextOut( ps.hdc, 29,60,"Break when the Program Counter equals",37);
TextOut( ps.hdc, 59,85,"0x",2);
}
void ShowBPPanel ( void ) {
void ShowBPPanel ( void )
{
ShowWindow(hRSPLocation,TRUE);
}
void RefreshBpoints ( HWND hList ) {
void RefreshBpoints ( HWND hList )
{
char Message[100];
int count, location;
@ -131,29 +147,36 @@ void RefreshBpoints ( HWND hList ) {
}
}
void RemoveAllBpoint ( void ) {
void RemoveAllBpoint ( void )
{
NoOfBpoints = 0;
}
void RemoveBpoint ( HWND hList, int index ) {
void RemoveBpoint ( HWND hList, int index )
{
DWORD location;
location = SendMessage(hList,LB_GETITEMDATA,(WPARAM)index,0);
RemoveRSPBreakPoint(location);
}
void RemoveRSPBreakPoint (DWORD Location) {
void RemoveRSPBreakPoint (DWORD Location)
{
int count, location = -1;
for (count = 0; count < NoOfBpoints; count ++){
if (BPoint[count].Location == Location) {
for (count = 0; count < NoOfBpoints; count ++)
{
if (BPoint[count].Location == Location)
{
location = count;
count = NoOfBpoints;
}
}
if (location >= 0) {
for (count = location; count < NoOfBpoints - 1; count ++ ){
if (location >= 0)
{
for (count = location; count < NoOfBpoints - 1; count ++ )
{
BPoint[count].Location = BPoint[count + 1].Location;
}
NoOfBpoints -= 1;

View File

@ -32,18 +32,21 @@
// #define RSP_SAFE_DMA /* unoptimized dma transfers */
void SP_DMA_READ (void) {
void SP_DMA_READ (void)
{
DWORD i, j, Length, Skip, Count, End, addr;
BYTE *Dest, *Source;
addr = (*RSPInfo.SP_DRAM_ADDR_REG) & 0x00FFFFFF;
if (addr > 0x800000) {
if (addr > 0x800000)
{
MessageBox(NULL,"SP DMA READ\nSP_DRAM_ADDR_REG not in RDRam space","Error",MB_OK);
return;
}
if ((*RSPInfo.SP_RD_LEN_REG & 0xFFF) + 1 + (*RSPInfo.SP_MEM_ADDR_REG & 0xFFF) > 0x1000) {
if ((*RSPInfo.SP_RD_LEN_REG & 0xFFF) + 1 + (*RSPInfo.SP_MEM_ADDR_REG & 0xFFF) > 0x1000)
{
MessageBox(NULL,"SP DMA READ\ncould not fit copy in memory segement","Error",MB_OK);
return;
}
@ -53,29 +56,40 @@ void SP_DMA_READ (void) {
Count = ((*RSPInfo.SP_RD_LEN_REG >> 12) & 0xFF) + 1;
End = ((*RSPInfo.SP_MEM_ADDR_REG & 0x0FFF) & ~7) + (((Count - 1) * Skip) + Length);
if ((*RSPInfo.SP_MEM_ADDR_REG & 0x1000) != 0) {
if ((*RSPInfo.SP_MEM_ADDR_REG & 0x1000) != 0)
{
Dest = RSPInfo.IMEM + ((*RSPInfo.SP_MEM_ADDR_REG & 0x0FFF) & ~7);
} else {
}
else
{
Dest = RSPInfo.DMEM + ((*RSPInfo.SP_MEM_ADDR_REG & 0x0FFF) & ~7);
}
Source = RSPInfo.RDRAM + (addr & ~7);
#if defined(RSP_SAFE_DMA)
for (j = 0 ; j < Count; j++) {
for (i = 0 ; i < Length; i++) {
for (j = 0 ; j < Count; j++)
{
for (i = 0 ; i < Length; i++)
{
*(BYTE *)(((DWORD)Dest + j * Length + i) ^ 3) = *(BYTE *)(((DWORD)Source + j * Skip + i) ^ 3);
}
}
#else
if ((Skip & 0x3) == 0) {
for (j = 0; j < Count; j++) {
if ((Skip & 0x3) == 0)
{
for (j = 0; j < Count; j++)
{
memcpy(Dest, Source, Length);
Source += Skip;
Dest += Length;
}
} else {
for (j = 0 ; j < Count; j++) {
for (i = 0 ; i < Length; i++) {
}
else
{
for (j = 0 ; j < Count; j++)
{
for (i = 0 ; i < Length; i++)
{
*(BYTE *)(((DWORD)Dest + i) ^ 3) = *(BYTE *)(((DWORD)Source + i) ^ 3);
}
Source += Skip;
@ -85,7 +99,8 @@ void SP_DMA_READ (void) {
#endif
/* FIXME: could this be a problem DMEM to IMEM (?) */
if (CPUCore == RecompilerCPU && (*RSPInfo.SP_MEM_ADDR_REG & 0x1000) != 0) {
if (CPUCore == RecompilerCPU && (*RSPInfo.SP_MEM_ADDR_REG & 0x1000) != 0)
{
SetJumpTable(End);
}
@ -93,18 +108,21 @@ void SP_DMA_READ (void) {
*RSPInfo.SP_STATUS_REG &= ~SP_STATUS_DMA_BUSY;
}
void SP_DMA_WRITE (void) {
void SP_DMA_WRITE (void)
{
DWORD i, j, Length, Skip, Count, addr;
BYTE *Dest, *Source;
addr = (*RSPInfo.SP_DRAM_ADDR_REG) & 0x00FFFFFF;
if (addr > 0x800000) {
if (addr > 0x800000)
{
MessageBox(NULL,"SP DMA WRITE\nSP_DRAM_ADDR_REG not in RDRam space","Error",MB_OK);
return;
}
if ((*RSPInfo.SP_WR_LEN_REG & 0xFFF) + 1 + (*RSPInfo.SP_MEM_ADDR_REG & 0xFFF) > 0x1000) {
if ((*RSPInfo.SP_WR_LEN_REG & 0xFFF) + 1 + (*RSPInfo.SP_MEM_ADDR_REG & 0xFFF) > 0x1000)
{
MessageBox(NULL,"SP DMA WRITE\ncould not fit copy in memory segement","Error",MB_OK);
return;
}
@ -114,23 +132,31 @@ void SP_DMA_WRITE (void) {
Count = ((*RSPInfo.SP_WR_LEN_REG >> 12) & 0xFF) + 1;
Dest = RSPInfo.RDRAM + (addr & ~7);
Source = RSPInfo.DMEM + ((*RSPInfo.SP_MEM_ADDR_REG & 0x1FFF) & ~7);
#if defined(RSP_SAFE_DMA)
for (j = 0 ; j < Count; j++) {
for (i = 0 ; i < Length; i++) {
for (j = 0 ; j < Count; j++)
{
for (i = 0 ; i < Length; i++)
{
*(BYTE *)(((DWORD)Dest + j * Skip + i) ^ 3) = *(BYTE *)(((DWORD)Source + j * Length + i) ^ 3);
}
}
#else
if ((Skip & 0x3) == 0) {
for (j = 0; j < Count; j++) {
if ((Skip & 0x3) == 0)
{
for (j = 0; j < Count; j++)
{
memcpy(Dest, Source, Length);
Source += Length;
Dest += Skip;
}
} else {
for (j = 0 ; j < Count; j++) {
for (i = 0 ; i < Length; i++) {
}
else
{
for (j = 0 ; j < Count; j++)
{
for (i = 0 ; i < Length; i++)
{
*(BYTE *)(((DWORD)Dest + i) ^ 3) = *(BYTE *)(((DWORD)Source + i) ^ 3);
}
Source += Length;

View File

@ -26,4 +26,3 @@
void SP_DMA_READ ( void );
void SP_DMA_WRITE ( void );