RSP: Get the code to conform to clang-format

This commit is contained in:
zilmar 2023-06-01 21:16:23 +09:30
parent 90fefed579
commit 98b96a60cb
35 changed files with 20444 additions and 17521 deletions

View File

@ -1,18 +1,18 @@
#include <windows.h>
#include <stdio.h>
#include <float.h>
#include "Rsp.h"
#include "Cpu.h" #include "Cpu.h"
#include "RSP registers.h"
#include "RSP Command.h"
#include "Recompiler CPU.h"
#include "memory.h"
#include "OpCode.h" #include "OpCode.h"
#include "log.h"
#include "Profiling.h" #include "Profiling.h"
#include "breakpoint.h" #include "RSP Command.h"
#include "x86.h" #include "RSP registers.h"
#include "Recompiler CPU.h"
#include "Rsp.h"
#include "Types.h" #include "Types.h"
#include "breakpoint.h"
#include "log.h"
#include "memory.h"
#include "x86.h"
#include <float.h>
#include <stdio.h>
#include <windows.h>
UDWORD EleSpec[32], Indx[32]; UDWORD EleSpec[32], Indx[32];
OPCODE RSPOpC; OPCODE RSPOpC;

View File

@ -1,4 +1,5 @@
#include "OpCode.h" #include "OpCode.h"
#include <Windows.h>
extern UDWORD EleSpec[32], Indx[32]; extern UDWORD EleSpec[32], Indx[32];

View File

@ -1,20 +1,21 @@
#include <windows.h> #include "Interpreter CPU.h"
#include <stdio.h>
#include <float.h>
#include "breakpoint.h"
#include "Rsp.h"
#include "Cpu.h" #include "Cpu.h"
#include "Interpreter Ops.h" #include "Interpreter Ops.h"
#include "Interpreter CPU.h"
#include "RSP registers.h"
#include "RSP Command.h" #include "RSP Command.h"
#include "RSP registers.h"
#include "Rsp.h"
#include "breakpoint.h"
#include "log.h"
#include "memory.h" #include "memory.h"
#include "opcode.h" #include "opcode.h"
#include "log.h" #include <float.h>
#include <stdio.h>
#include <windows.h>
DWORD RSP_NextInstruction, RSP_JumpTo; DWORD RSP_NextInstruction, RSP_JumpTo;
void BuildInterpreterCPU(void) { void BuildInterpreterCPU(void)
{
RSP_Opcode[0] = RSP_Opcode_SPECIAL; RSP_Opcode[0] = RSP_Opcode_SPECIAL;
RSP_Opcode[1] = RSP_Opcode_REGIMM; RSP_Opcode[1] = RSP_Opcode_REGIMM;
RSP_Opcode[2] = RSP_Opcode_J; RSP_Opcode[2] = RSP_Opcode_J;
@ -376,38 +377,51 @@ void BuildInterpreterCPU(void) {
RSP_Sc2[31] = rsp_UnknownOpcode; RSP_Sc2[31] = rsp_UnknownOpcode;
} }
DWORD RunInterpreterCPU(DWORD Cycles) { DWORD RunInterpreterCPU(DWORD Cycles)
{
DWORD CycleCount; DWORD CycleCount;
RSP_Running = TRUE; RSP_Running = TRUE;
Enable_RSP_Commands_Window(); Enable_RSP_Commands_Window();
CycleCount = 0; CycleCount = 0;
while (RSP_Running) { while (RSP_Running)
if (NoOfBpoints != 0) { {
if (CheckForRSPBPoint(*PrgCount)) { if (NoOfBpoints != 0)
if (InRSPCommandsWindow) { {
if (CheckForRSPBPoint(*PrgCount))
{
if (InRSPCommandsWindow)
{
Enter_RSP_Commands_Window(); Enter_RSP_Commands_Window();
if (Stepping_Commands) { if (Stepping_Commands)
{
DisplayError("Encountered an R4300i breakpoint"); DisplayError("Encountered an R4300i breakpoint");
} else { }
else
{
DisplayError("Encountered an R4300i breakpoint\n\nNow stepping"); DisplayError("Encountered an R4300i breakpoint\n\nNow stepping");
SetRSPCommandViewto(*PrgCount); SetRSPCommandViewto(*PrgCount);
SetRSPCommandToStepping(); SetRSPCommandToStepping();
} }
} else { }
else
{
DisplayError("Encountered an RSP breakpoint\n\nEntering command window"); DisplayError("Encountered an RSP breakpoint\n\nEntering command window");
Enter_RSP_Commands_Window(); Enter_RSP_Commands_Window();
} }
} }
} }
if (Stepping_Commands) { if (Stepping_Commands)
{
WaitingForStep = TRUE; WaitingForStep = TRUE;
SetRSPCommandViewto(*PrgCount); SetRSPCommandViewto(*PrgCount);
UpdateRSPRegistersScreen(); UpdateRSPRegistersScreen();
while ( WaitingForStep == TRUE ){ while (WaitingForStep == TRUE)
{
Sleep(20); Sleep(20);
if (!Stepping_Commands) { if (!Stepping_Commands)
{
WaitingForStep = FALSE; WaitingForStep = FALSE;
} }
} }
@ -419,7 +433,8 @@ DWORD RunInterpreterCPU(DWORD Cycles) {
RSP_Opcode[RSPOpC.op](); RSP_Opcode[RSPOpC.op]();
RSP_GPR[0].W = 0x00000000; // MIPS $zero hard-wired to 0 RSP_GPR[0].W = 0x00000000; // MIPS $zero hard-wired to 0
switch (RSP_NextInstruction) { switch (RSP_NextInstruction)
{
case NORMAL: case NORMAL:
*PrgCount = (*PrgCount + 4) & 0xFFC; *PrgCount = (*PrgCount + 4) & 0xFFC;
break; break;

View File

@ -1,3 +1,6 @@
#include <Windows.h>
#include <stdint.h>
#define NORMAL 0 #define NORMAL 0
#define DO_DELAY_SLOT 1 #define DO_DELAY_SLOT 1
#define DELAY_SLOT 2 #define DELAY_SLOT 2

File diff suppressed because it is too large Load Diff

View File

@ -1,7 +1,7 @@
#ifdef _WIN32 #ifdef _WIN32
#include <Windows.h> #include <Windows.h>
#include <windowsx.h>
#include <commctrl.h> #include <commctrl.h>
#include <windowsx.h>
#endif #endif
#if defined(_MSC_VER) && _MSC_VER >= 1910 #if defined(_MSC_VER) && _MSC_VER >= 1910
#include <intrin.h> #include <intrin.h>
@ -10,22 +10,22 @@
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
#include "../Settings/Settings.h"
#include <Common/StdString.h> #include <Common/StdString.h>
#include <stdint.h> #include <stdint.h>
#include "../Settings/Settings.h"
#include "Rsp.h"
#include "Cpu.h" #include "Cpu.h"
#include "Recompiler CPU.h" #include "Profiling.h"
#include "RSP Command.h" #include "RSP Command.h"
#include "RSP Registers.h" #include "RSP Registers.h"
#include "memory.h" #include "Recompiler CPU.h"
#include "breakpoint.h" #include "Rsp.h"
#include "Profiling.h"
#include "log.h"
#include "resource.h"
#include "Version.h"
#include "Types.h" #include "Types.h"
#include "Version.h"
#include "breakpoint.h"
#include "log.h"
#include "memory.h"
#include "resource.h"
void ClearAllx86Code(void); void ClearAllx86Code(void);
void ProcessMenuItem(int ID); void ProcessMenuItem(int ID);
@ -52,16 +52,32 @@ void * hinstDLL;
extern uint8_t * pLastSecondary; extern uint8_t * pLastSecondary;
enum { enum
Set_BreakOnStart, Set_CPUCore, Set_LogRDP, Set_LogX86Code, Set_Profiling, Set_IndvidualBlock, {
Set_BreakOnStart,
Set_CPUCore,
Set_LogRDP,
Set_LogX86Code,
Set_Profiling,
Set_IndvidualBlock,
Set_ShowErrors, Set_ShowErrors,
// Compiler settings // Compiler settings
Set_CheckDest, Set_Accum, Set_Mmx, Set_Mmx2, Set_Sse, Set_Sections, Set_CheckDest,
Set_ReOrdering, Set_GPRConstants, Set_Flags, Set_AlignVector, Set_Accum,
Set_Mmx,
Set_Mmx2,
Set_Sse,
Set_Sections,
Set_ReOrdering,
Set_GPRConstants,
Set_Flags,
Set_AlignVector,
// Game settings // Game settings
Set_JumpTableSize, Set_Mfc0Count, Set_SemaphoreExit Set_JumpTableSize,
Set_Mfc0Count,
Set_SemaphoreExit
}; };
short Set_AudioHle = 0, Set_GraphicsHle = 0; short Set_AudioHle = 0, Set_GraphicsHle = 0;
@ -86,7 +102,10 @@ uint32_t AsciiToHex(char * HexValue)
uint32_t Value = 0; uint32_t Value = 0;
Finish = strlen(HexValue); Finish = strlen(HexValue);
if (Finish > 8 ) { Finish = 8; } if (Finish > 8)
{
Finish = 8;
}
for (Count = 0; Count < Finish; Count++) for (Count = 0; Count < Finish; Count++)
{ {
@ -273,7 +292,8 @@ void DetectCpuSpecs(void)
DWORD AMD_Features = 0; DWORD AMD_Features = 0;
#if defined(_MSC_VER) #if defined(_MSC_VER)
__try { __try
{
#ifdef _M_IX86 #ifdef _M_IX86
_asm { _asm {
// Intel features // Intel features
@ -294,7 +314,8 @@ void DetectCpuSpecs(void)
AMD_Features = cpuInfo[3]; AMD_Features = cpuInfo[3];
#endif #endif
} }
__except (EXCEPTION_EXECUTE_HANDLER) { __except (EXCEPTION_EXECUTE_HANDLER)
{
AMD_Features = Intel_Features = 0; AMD_Features = Intel_Features = 0;
} }
#else #else
@ -382,14 +403,20 @@ void ProcessMenuItem(int ID)
CheckMenuItem(hRSPMenu, ID_PROFILING_ON, MF_BYCOMMAND | MFS_UNCHECKED); CheckMenuItem(hRSPMenu, ID_PROFILING_ON, MF_BYCOMMAND | MFS_UNCHECKED);
CheckMenuItem(hRSPMenu, ID_PROFILING_OFF, MF_BYCOMMAND | MFS_CHECKED); CheckMenuItem(hRSPMenu, ID_PROFILING_OFF, MF_BYCOMMAND | MFS_CHECKED);
SetSetting(Set_Profiling, FALSE); SetSetting(Set_Profiling, FALSE);
if (DebuggingEnabled) { Profiling = FALSE; } if (DebuggingEnabled)
{
Profiling = FALSE;
}
} }
else else
{ {
CheckMenuItem(hRSPMenu, ID_PROFILING_ON, MF_BYCOMMAND | MFS_CHECKED); CheckMenuItem(hRSPMenu, ID_PROFILING_ON, MF_BYCOMMAND | MFS_CHECKED);
CheckMenuItem(hRSPMenu, ID_PROFILING_OFF, MF_BYCOMMAND | MFS_UNCHECKED); CheckMenuItem(hRSPMenu, ID_PROFILING_OFF, MF_BYCOMMAND | MFS_UNCHECKED);
SetSetting(Set_Profiling, TRUE); SetSetting(Set_Profiling, TRUE);
if (DebuggingEnabled) { Profiling = TRUE; } if (DebuggingEnabled)
{
Profiling = TRUE;
}
} }
} }
break; break;
@ -403,13 +430,19 @@ void ProcessMenuItem(int ID)
{ {
CheckMenuItem(hRSPMenu, ID_PROFILING_LOGINDIVIDUALBLOCKS, MF_BYCOMMAND | MFS_UNCHECKED); CheckMenuItem(hRSPMenu, ID_PROFILING_LOGINDIVIDUALBLOCKS, MF_BYCOMMAND | MFS_UNCHECKED);
SetSetting(Set_IndvidualBlock, FALSE); SetSetting(Set_IndvidualBlock, FALSE);
if (DebuggingEnabled) { IndvidualBlock = FALSE; } if (DebuggingEnabled)
{
IndvidualBlock = FALSE;
}
} }
else else
{ {
CheckMenuItem(hRSPMenu, ID_PROFILING_LOGINDIVIDUALBLOCKS, MF_BYCOMMAND | MFS_CHECKED); CheckMenuItem(hRSPMenu, ID_PROFILING_LOGINDIVIDUALBLOCKS, MF_BYCOMMAND | MFS_CHECKED);
SetSetting(Set_IndvidualBlock, TRUE); SetSetting(Set_IndvidualBlock, TRUE);
if (DebuggingEnabled) { IndvidualBlock = TRUE; } if (DebuggingEnabled)
{
IndvidualBlock = TRUE;
}
} }
} }
break; break;
@ -421,13 +454,19 @@ void ProcessMenuItem(int ID)
{ {
CheckMenuItem(hRSPMenu, ID_SHOWCOMPILERERRORS, MF_BYCOMMAND | MFS_UNCHECKED); CheckMenuItem(hRSPMenu, ID_SHOWCOMPILERERRORS, MF_BYCOMMAND | MFS_UNCHECKED);
SetSetting(Set_ShowErrors, FALSE); SetSetting(Set_ShowErrors, FALSE);
if (DebuggingEnabled) { ShowErrors = FALSE; } if (DebuggingEnabled)
{
ShowErrors = FALSE;
}
} }
else else
{ {
CheckMenuItem(hRSPMenu, ID_SHOWCOMPILERERRORS, MF_BYCOMMAND | MFS_CHECKED); CheckMenuItem(hRSPMenu, ID_SHOWCOMPILERERRORS, MF_BYCOMMAND | MFS_CHECKED);
SetSetting(Set_ShowErrors, TRUE); SetSetting(Set_ShowErrors, TRUE);
if (DebuggingEnabled) { ShowErrors = TRUE; } if (DebuggingEnabled)
{
ShowErrors = TRUE;
}
} }
} }
break; break;
@ -442,13 +481,19 @@ void ProcessMenuItem(int ID)
{ {
CheckMenuItem(hRSPMenu, ID_BREAKONSTARTOFTASK, MF_BYCOMMAND | MFS_UNCHECKED); CheckMenuItem(hRSPMenu, ID_BREAKONSTARTOFTASK, MF_BYCOMMAND | MFS_UNCHECKED);
SetSetting(Set_BreakOnStart, FALSE); SetSetting(Set_BreakOnStart, FALSE);
if (DebuggingEnabled) { BreakOnStart = FALSE; } if (DebuggingEnabled)
{
BreakOnStart = FALSE;
}
} }
else else
{ {
CheckMenuItem(hRSPMenu, ID_BREAKONSTARTOFTASK, MF_BYCOMMAND | MFS_CHECKED); CheckMenuItem(hRSPMenu, ID_BREAKONSTARTOFTASK, MF_BYCOMMAND | MFS_CHECKED);
SetSetting(Set_BreakOnStart, TRUE); SetSetting(Set_BreakOnStart, TRUE);
if (DebuggingEnabled) { BreakOnStart = TRUE; } if (DebuggingEnabled)
{
BreakOnStart = TRUE;
}
} }
} }
break; break;
@ -768,7 +813,6 @@ EXPORT void PluginLoaded(void)
Compiler.bGPRConstants = TRUE; Compiler.bGPRConstants = TRUE;
DetectCpuSpecs(); DetectCpuSpecs();
SetModuleName("RSP"); SetModuleName("RSP");
Set_GraphicsHle = FindSystemSettingId("HLE GFX"); Set_GraphicsHle = FindSystemSettingId("HLE GFX");
Set_AudioHle = FindSystemSettingId("HLE Audio"); Set_AudioHle = FindSystemSettingId("HLE Audio");

View File

@ -1,36 +1,44 @@
#include <windows.h>
#include <stdio.h>
#include "Rsp.h"
#include "x86.h"
#include "memory.h"
#include "RSP registers.h" #include "RSP registers.h"
#include "Rsp.h"
#include "log.h" #include "log.h"
#include "memory.h"
#include "x86.h"
#include <stdio.h>
#include <windows.h>
#define PUTDST8(dest,value) (*((BYTE *)(dest))=(BYTE)(value)); dest += 1; #define PUTDST8(dest, value) \
#define PUTDST16(dest,value) (*((WORD *)(dest))=(WORD)(value)); dest += 2; (*((BYTE *)(dest)) = (BYTE)(value)); \
#define PUTDST32(dest,value) (*((DWORD *)(dest))=(DWORD)(value)); dest += 4; dest += 1;
#define PUTDST16(dest, value) \
(*((WORD *)(dest)) = (WORD)(value)); \
dest += 2;
#define PUTDST32(dest, value) \
(*((DWORD *)(dest)) = (DWORD)(value)); \
dest += 4;
#define PUTDSTPTR(dest, value) \ #define PUTDSTPTR(dest, value) \
*(void **)(dest) = (void *)(value); dest += sizeof(void *); *(void **)(dest) = (void *)(value); \
dest += sizeof(void *);
char * mmx_Strings[8] = { char * mmx_Strings[8] = {
"mm0", "mm1", "mm2", "mm3", "mm0", "mm1", "mm2", "mm3",
"mm4", "mm5", "mm6", "mm7" "mm4", "mm5", "mm6", "mm7"};
};
#define mmx_Name(Reg) (mmx_Strings[(Reg)]) #define mmx_Name(Reg) (mmx_Strings[(Reg)])
void MmxEmptyMultimediaState(void)
void MmxEmptyMultimediaState(void) { {
CPU_Message(" emms"); CPU_Message(" emms");
PUTDST16(RecompPos, 0x770f); PUTDST16(RecompPos, 0x770f);
} }
void MmxMoveRegToReg(int Dest, int Source) { void MmxMoveRegToReg(int Dest, int Source)
{
BYTE x86Command = 0; BYTE x86Command = 0;
CPU_Message(" movq %s, %s", mmx_Name(Dest), mmx_Name(Source)); CPU_Message(" movq %s, %s", mmx_Name(Dest), mmx_Name(Source));
switch (Dest) { switch (Dest)
{
case x86_MM0: x86Command = 0; break; case x86_MM0: x86Command = 0; break;
case x86_MM1: x86Command = 1; break; case x86_MM1: x86Command = 1; break;
case x86_MM2: x86Command = 2; break; case x86_MM2: x86Command = 2; break;
@ -40,7 +48,8 @@ void MmxMoveRegToReg(int Dest, int Source) {
case x86_MM6: x86Command = 6; break; case x86_MM6: x86Command = 6; break;
case x86_MM7: x86Command = 7; break; case x86_MM7: x86Command = 7; break;
} }
switch (Source) { switch (Source)
{
case x86_MM0: x86Command |= 0 << 3; break; case x86_MM0: x86Command |= 0 << 3; break;
case x86_MM1: x86Command |= 1 << 3; break; case x86_MM1: x86Command |= 1 << 3; break;
case x86_MM2: x86Command |= 2 << 3; break; case x86_MM2: x86Command |= 2 << 3; break;
@ -54,12 +63,14 @@ void MmxMoveRegToReg(int Dest, int Source) {
PUTDST8(RecompPos, 0xC0 | x86Command); PUTDST8(RecompPos, 0xC0 | x86Command);
} }
void MmxMoveQwordVariableToReg(int Dest, void *Variable, char *VariableName) { void MmxMoveQwordVariableToReg(int Dest, void * Variable, char * VariableName)
{
BYTE x86Command = 0; BYTE x86Command = 0;
CPU_Message(" movq %s, qword ptr [%s]", mmx_Name(Dest), VariableName); CPU_Message(" movq %s, qword ptr [%s]", mmx_Name(Dest), VariableName);
switch (Dest) { switch (Dest)
{
case x86_MM0: x86Command = 0x05; break; case x86_MM0: x86Command = 0x05; break;
case x86_MM1: x86Command = 0x0D; break; case x86_MM1: x86Command = 0x0D; break;
case x86_MM2: x86Command = 0x15; break; case x86_MM2: x86Command = 0x15; break;
@ -75,12 +86,14 @@ void MmxMoveQwordVariableToReg(int Dest, void *Variable, char *VariableName) {
PUTDSTPTR(RecompPos, Variable); PUTDSTPTR(RecompPos, Variable);
} }
void MmxMoveQwordRegToVariable(int Dest, void *Variable, char *VariableName) { void MmxMoveQwordRegToVariable(int Dest, void * Variable, char * VariableName)
{
BYTE x86Command = 0; BYTE x86Command = 0;
CPU_Message(" movq qword ptr [%s], %s", VariableName, mmx_Name(Dest)); CPU_Message(" movq qword ptr [%s], %s", VariableName, mmx_Name(Dest));
switch (Dest) { switch (Dest)
{
case x86_MM0: x86Command = 0x05; break; case x86_MM0: x86Command = 0x05; break;
case x86_MM1: x86Command = 0x0D; break; case x86_MM1: x86Command = 0x0D; break;
case x86_MM2: x86Command = 0x15; break; case x86_MM2: x86Command = 0x15; break;
@ -96,12 +109,14 @@ void MmxMoveQwordRegToVariable(int Dest, void *Variable, char *VariableName) {
PUTDSTPTR(RecompPos, Variable); PUTDSTPTR(RecompPos, Variable);
} }
void MmxPorRegToReg(int Dest, int Source) { void MmxPorRegToReg(int Dest, int Source)
{
BYTE x86Command = 0; BYTE x86Command = 0;
CPU_Message(" por %s, %s", mmx_Name(Dest), mmx_Name(Source)); CPU_Message(" por %s, %s", mmx_Name(Dest), mmx_Name(Source));
switch (Dest) { switch (Dest)
{
case x86_MM0: x86Command = 0 << 3; break; case x86_MM0: x86Command = 0 << 3; break;
case x86_MM1: x86Command = 1 << 3; break; case x86_MM1: x86Command = 1 << 3; break;
case x86_MM2: x86Command = 2 << 3; break; case x86_MM2: x86Command = 2 << 3; break;
@ -111,7 +126,8 @@ void MmxPorRegToReg(int Dest, int Source) {
case x86_MM6: x86Command = 6 << 3; break; case x86_MM6: x86Command = 6 << 3; break;
case x86_MM7: x86Command = 7 << 3; break; case x86_MM7: x86Command = 7 << 3; break;
} }
switch (Source) { switch (Source)
{
case x86_MM0: x86Command |= 0; break; case x86_MM0: x86Command |= 0; break;
case x86_MM1: x86Command |= 1; break; case x86_MM1: x86Command |= 1; break;
case x86_MM2: x86Command |= 2; break; case x86_MM2: x86Command |= 2; break;
@ -125,12 +141,14 @@ void MmxPorRegToReg(int Dest, int Source) {
PUTDST8(RecompPos, 0xC0 | x86Command); PUTDST8(RecompPos, 0xC0 | x86Command);
} }
void MmxPorVariableToReg(void * Variable, char * VariableName, int Dest) { void MmxPorVariableToReg(void * Variable, char * VariableName, int Dest)
{
BYTE x86Command = 0; BYTE x86Command = 0;
CPU_Message(" por %s, qword ptr [%s]", mmx_Name(Dest), VariableName); CPU_Message(" por %s, qword ptr [%s]", mmx_Name(Dest), VariableName);
switch (Dest) { switch (Dest)
{
case x86_MM0: x86Command = 0x05; break; case x86_MM0: x86Command = 0x05; break;
case x86_MM1: x86Command = 0x0D; break; case x86_MM1: x86Command = 0x0D; break;
case x86_MM2: x86Command = 0x15; break; case x86_MM2: x86Command = 0x15; break;
@ -146,12 +164,14 @@ void MmxPorVariableToReg(void * Variable, char * VariableName, int Dest) {
PUTDSTPTR(RecompPos, Variable); PUTDSTPTR(RecompPos, Variable);
} }
void MmxPandRegToReg(int Dest, int Source) { void MmxPandRegToReg(int Dest, int Source)
{
BYTE x86Command = 0; BYTE x86Command = 0;
CPU_Message(" pand %s, %s", mmx_Name(Dest), mmx_Name(Source)); CPU_Message(" pand %s, %s", mmx_Name(Dest), mmx_Name(Source));
switch (Dest) { switch (Dest)
{
case x86_MM0: x86Command = 0 << 3; break; case x86_MM0: x86Command = 0 << 3; break;
case x86_MM1: x86Command = 1 << 3; break; case x86_MM1: x86Command = 1 << 3; break;
case x86_MM2: x86Command = 2 << 3; break; case x86_MM2: x86Command = 2 << 3; break;
@ -161,7 +181,8 @@ void MmxPandRegToReg(int Dest, int Source) {
case x86_MM6: x86Command = 6 << 3; break; case x86_MM6: x86Command = 6 << 3; break;
case x86_MM7: x86Command = 7 << 3; break; case x86_MM7: x86Command = 7 << 3; break;
} }
switch (Source) { switch (Source)
{
case x86_MM0: x86Command |= 0; break; case x86_MM0: x86Command |= 0; break;
case x86_MM1: x86Command |= 1; break; case x86_MM1: x86Command |= 1; break;
case x86_MM2: x86Command |= 2; break; case x86_MM2: x86Command |= 2; break;
@ -175,12 +196,14 @@ void MmxPandRegToReg(int Dest, int Source) {
PUTDST8(RecompPos, 0xC0 | x86Command); PUTDST8(RecompPos, 0xC0 | x86Command);
} }
void MmxPandVariableToReg(void * Variable, char * VariableName, int Dest) { void MmxPandVariableToReg(void * Variable, char * VariableName, int Dest)
{
BYTE x86Command = 0; BYTE x86Command = 0;
CPU_Message(" pand %s, qword ptr [%s]", mmx_Name(Dest), VariableName); CPU_Message(" pand %s, qword ptr [%s]", mmx_Name(Dest), VariableName);
switch (Dest) { switch (Dest)
{
case x86_MM0: x86Command = 0x05; break; case x86_MM0: x86Command = 0x05; break;
case x86_MM1: x86Command = 0x0D; break; case x86_MM1: x86Command = 0x0D; break;
case x86_MM2: x86Command = 0x15; break; case x86_MM2: x86Command = 0x15; break;
@ -196,12 +219,14 @@ void MmxPandVariableToReg(void * Variable, char * VariableName, int Dest) {
PUTDSTPTR(RecompPos, Variable); PUTDSTPTR(RecompPos, Variable);
} }
void MmxPandnRegToReg(int Dest, int Source) { void MmxPandnRegToReg(int Dest, int Source)
{
BYTE x86Command = 0; BYTE x86Command = 0;
CPU_Message(" pandn %s, %s", mmx_Name(Dest), mmx_Name(Source)); CPU_Message(" pandn %s, %s", mmx_Name(Dest), mmx_Name(Source));
switch (Dest) { switch (Dest)
{
case x86_MM0: x86Command = 0 << 3; break; case x86_MM0: x86Command = 0 << 3; break;
case x86_MM1: x86Command = 1 << 3; break; case x86_MM1: x86Command = 1 << 3; break;
case x86_MM2: x86Command = 2 << 3; break; case x86_MM2: x86Command = 2 << 3; break;
@ -211,7 +236,8 @@ void MmxPandnRegToReg(int Dest, int Source) {
case x86_MM6: x86Command = 6 << 3; break; case x86_MM6: x86Command = 6 << 3; break;
case x86_MM7: x86Command = 7 << 3; break; case x86_MM7: x86Command = 7 << 3; break;
} }
switch (Source) { switch (Source)
{
case x86_MM0: x86Command |= 0; break; case x86_MM0: x86Command |= 0; break;
case x86_MM1: x86Command |= 1; break; case x86_MM1: x86Command |= 1; break;
case x86_MM2: x86Command |= 2; break; case x86_MM2: x86Command |= 2; break;
@ -225,12 +251,14 @@ void MmxPandnRegToReg(int Dest, int Source) {
PUTDST8(RecompPos, 0xC0 | x86Command); PUTDST8(RecompPos, 0xC0 | x86Command);
} }
void MmxXorRegToReg(int Dest, int Source) { void MmxXorRegToReg(int Dest, int Source)
{
BYTE x86Command = 0; BYTE x86Command = 0;
CPU_Message(" pxor %s, %s", mmx_Name(Dest), mmx_Name(Source)); CPU_Message(" pxor %s, %s", mmx_Name(Dest), mmx_Name(Source));
switch (Dest) { switch (Dest)
{
case x86_MM0: x86Command = 0x00; break; case x86_MM0: x86Command = 0x00; break;
case x86_MM1: x86Command = 0x08; break; case x86_MM1: x86Command = 0x08; break;
case x86_MM2: x86Command = 0x10; break; case x86_MM2: x86Command = 0x10; break;
@ -240,7 +268,8 @@ void MmxXorRegToReg(int Dest, int Source) {
case x86_MM6: x86Command = 0x30; break; case x86_MM6: x86Command = 0x30; break;
case x86_MM7: x86Command = 0x38; break; case x86_MM7: x86Command = 0x38; break;
} }
switch (Source) { switch (Source)
{
case x86_MM0: x86Command += 0x00; break; case x86_MM0: x86Command += 0x00; break;
case x86_MM1: x86Command += 0x01; break; case x86_MM1: x86Command += 0x01; break;
case x86_MM2: x86Command += 0x02; break; case x86_MM2: x86Command += 0x02; break;
@ -254,12 +283,14 @@ void MmxXorRegToReg(int Dest, int Source) {
PUTDST8(RecompPos, 0xC0 | x86Command); PUTDST8(RecompPos, 0xC0 | x86Command);
} }
void MmxShuffleMemoryToReg(int Dest, void * Variable, char * VariableName, BYTE Immed) { void MmxShuffleMemoryToReg(int Dest, void * Variable, char * VariableName, BYTE Immed)
{
BYTE x86Command = 0; BYTE x86Command = 0;
CPU_Message(" pshufw %s, [%s], %02X", mmx_Name(Dest), VariableName, Immed); CPU_Message(" pshufw %s, [%s], %02X", mmx_Name(Dest), VariableName, Immed);
switch (Dest) { switch (Dest)
{
case x86_MM0: x86Command = 0x05; break; case x86_MM0: x86Command = 0x05; break;
case x86_MM1: x86Command = 0x0D; break; case x86_MM1: x86Command = 0x0D; break;
case x86_MM2: x86Command = 0x15; break; case x86_MM2: x86Command = 0x15; break;
@ -276,12 +307,14 @@ void MmxShuffleMemoryToReg(int Dest, void * Variable, char * VariableName, BYTE
PUTDST8(RecompPos, Immed); PUTDST8(RecompPos, Immed);
} }
void MmxPcmpeqwRegToReg(int Dest, int Source){ void MmxPcmpeqwRegToReg(int Dest, int Source)
{
BYTE x86Command = 0; BYTE x86Command = 0;
CPU_Message(" pcmpeqw %s, %s", mmx_Name(Dest), mmx_Name(Source)); CPU_Message(" pcmpeqw %s, %s", mmx_Name(Dest), mmx_Name(Source));
switch (Dest) { switch (Dest)
{
case x86_MM0: x86Command = 0 << 3; break; case x86_MM0: x86Command = 0 << 3; break;
case x86_MM1: x86Command = 1 << 3; break; case x86_MM1: x86Command = 1 << 3; break;
case x86_MM2: x86Command = 2 << 3; break; case x86_MM2: x86Command = 2 << 3; break;
@ -291,7 +324,8 @@ void MmxPcmpeqwRegToReg(int Dest, int Source){
case x86_MM6: x86Command = 6 << 3; break; case x86_MM6: x86Command = 6 << 3; break;
case x86_MM7: x86Command = 7 << 3; break; case x86_MM7: x86Command = 7 << 3; break;
} }
switch (Source) { switch (Source)
{
case x86_MM0: x86Command |= 0; break; case x86_MM0: x86Command |= 0; break;
case x86_MM1: x86Command |= 1; break; case x86_MM1: x86Command |= 1; break;
case x86_MM2: x86Command |= 2; break; case x86_MM2: x86Command |= 2; break;
@ -305,12 +339,14 @@ void MmxPcmpeqwRegToReg(int Dest, int Source){
PUTDST8(RecompPos, 0xC0 | x86Command); PUTDST8(RecompPos, 0xC0 | x86Command);
} }
void MmxPmullwRegToReg(int Dest, int Source) { void MmxPmullwRegToReg(int Dest, int Source)
{
BYTE x86Command = 0; BYTE x86Command = 0;
CPU_Message(" pmullw %s, %s", mmx_Name(Dest), mmx_Name(Source)); CPU_Message(" pmullw %s, %s", mmx_Name(Dest), mmx_Name(Source));
switch (Dest) { switch (Dest)
{
case x86_MM0: x86Command = 0 << 3; break; case x86_MM0: x86Command = 0 << 3; break;
case x86_MM1: x86Command = 1 << 3; break; case x86_MM1: x86Command = 1 << 3; break;
case x86_MM2: x86Command = 2 << 3; break; case x86_MM2: x86Command = 2 << 3; break;
@ -320,7 +356,8 @@ void MmxPmullwRegToReg(int Dest, int Source) {
case x86_MM6: x86Command = 6 << 3; break; case x86_MM6: x86Command = 6 << 3; break;
case x86_MM7: x86Command = 7 << 3; break; case x86_MM7: x86Command = 7 << 3; break;
} }
switch (Source) { switch (Source)
{
case x86_MM0: x86Command |= 0; break; case x86_MM0: x86Command |= 0; break;
case x86_MM1: x86Command |= 1; break; case x86_MM1: x86Command |= 1; break;
case x86_MM2: x86Command |= 2; break; case x86_MM2: x86Command |= 2; break;
@ -334,12 +371,14 @@ void MmxPmullwRegToReg(int Dest, int Source) {
PUTDST8(RecompPos, 0xC0 | x86Command); PUTDST8(RecompPos, 0xC0 | x86Command);
} }
void MmxPmullwVariableToReg(int Dest, void * Variable, char * VariableName) { void MmxPmullwVariableToReg(int Dest, void * Variable, char * VariableName)
{
BYTE x86Command = 0; BYTE x86Command = 0;
CPU_Message(" pmullw %s, [%s]", mmx_Name(Dest), VariableName); CPU_Message(" pmullw %s, [%s]", mmx_Name(Dest), VariableName);
switch (Dest) { switch (Dest)
{
case x86_MM0: x86Command = 0x05; break; case x86_MM0: x86Command = 0x05; break;
case x86_MM1: x86Command = 0x0D; break; case x86_MM1: x86Command = 0x0D; break;
case x86_MM2: x86Command = 0x15; break; case x86_MM2: x86Command = 0x15; break;
@ -354,12 +393,14 @@ void MmxPmullwVariableToReg(int Dest, void * Variable, char * VariableName) {
PUTDSTPTR(RecompPos, Variable); PUTDSTPTR(RecompPos, Variable);
} }
void MmxPmulhuwRegToReg(int Dest, int Source) { void MmxPmulhuwRegToReg(int Dest, int Source)
{
BYTE x86Command = 0; BYTE x86Command = 0;
CPU_Message(" pmulhuw %s, %s", mmx_Name(Dest), mmx_Name(Source)); CPU_Message(" pmulhuw %s, %s", mmx_Name(Dest), mmx_Name(Source));
switch (Dest) { switch (Dest)
{
case x86_MM0: x86Command = 0 << 3; break; case x86_MM0: x86Command = 0 << 3; break;
case x86_MM1: x86Command = 1 << 3; break; case x86_MM1: x86Command = 1 << 3; break;
case x86_MM2: x86Command = 2 << 3; break; case x86_MM2: x86Command = 2 << 3; break;
@ -369,7 +410,8 @@ void MmxPmulhuwRegToReg(int Dest, int Source) {
case x86_MM6: x86Command = 6 << 3; break; case x86_MM6: x86Command = 6 << 3; break;
case x86_MM7: x86Command = 7 << 3; break; case x86_MM7: x86Command = 7 << 3; break;
} }
switch (Source) { switch (Source)
{
case x86_MM0: x86Command |= 0; break; case x86_MM0: x86Command |= 0; break;
case x86_MM1: x86Command |= 1; break; case x86_MM1: x86Command |= 1; break;
case x86_MM2: x86Command |= 2; break; case x86_MM2: x86Command |= 2; break;
@ -383,12 +425,14 @@ void MmxPmulhuwRegToReg(int Dest, int Source) {
PUTDST8(RecompPos, 0xC0 | x86Command); PUTDST8(RecompPos, 0xC0 | x86Command);
} }
void MmxPmulhwRegToReg(int Dest, int Source) { void MmxPmulhwRegToReg(int Dest, int Source)
{
BYTE x86Command = 0; BYTE x86Command = 0;
CPU_Message(" pmulhw %s, %s", mmx_Name(Dest), mmx_Name(Source)); CPU_Message(" pmulhw %s, %s", mmx_Name(Dest), mmx_Name(Source));
switch (Dest) { switch (Dest)
{
case x86_MM0: x86Command = 0 << 3; break; case x86_MM0: x86Command = 0 << 3; break;
case x86_MM1: x86Command = 1 << 3; break; case x86_MM1: x86Command = 1 << 3; break;
case x86_MM2: x86Command = 2 << 3; break; case x86_MM2: x86Command = 2 << 3; break;
@ -398,7 +442,8 @@ void MmxPmulhwRegToReg(int Dest, int Source) {
case x86_MM6: x86Command = 6 << 3; break; case x86_MM6: x86Command = 6 << 3; break;
case x86_MM7: x86Command = 7 << 3; break; case x86_MM7: x86Command = 7 << 3; break;
} }
switch (Source) { switch (Source)
{
case x86_MM0: x86Command |= 0; break; case x86_MM0: x86Command |= 0; break;
case x86_MM1: x86Command |= 1; break; case x86_MM1: x86Command |= 1; break;
case x86_MM2: x86Command |= 2; break; case x86_MM2: x86Command |= 2; break;
@ -412,12 +457,14 @@ void MmxPmulhwRegToReg(int Dest, int Source) {
PUTDST8(RecompPos, 0xC0 | x86Command); PUTDST8(RecompPos, 0xC0 | x86Command);
} }
void MmxPmulhwRegToVariable(int Dest, void * Variable, char * VariableName) { void MmxPmulhwRegToVariable(int Dest, void * Variable, char * VariableName)
{
BYTE x86Command = 0; BYTE x86Command = 0;
CPU_Message(" pmulhw %s, [%s]", mmx_Name(Dest), VariableName); CPU_Message(" pmulhw %s, [%s]", mmx_Name(Dest), VariableName);
switch (Dest) { switch (Dest)
{
case x86_MM0: x86Command = 0x05; break; case x86_MM0: x86Command = 0x05; break;
case x86_MM1: x86Command = 0x0D; break; case x86_MM1: x86Command = 0x0D; break;
case x86_MM2: x86Command = 0x15; break; case x86_MM2: x86Command = 0x15; break;
@ -432,13 +479,14 @@ void MmxPmulhwRegToVariable(int Dest, void * Variable, char * VariableName) {
PUTDSTPTR(RecompPos, Variable); PUTDSTPTR(RecompPos, Variable);
} }
void MmxPsrlwImmed(int Dest, BYTE Immed)
void MmxPsrlwImmed(int Dest, BYTE Immed) { {
BYTE x86Command = 0; BYTE x86Command = 0;
CPU_Message(" psrlw %s, %i", mmx_Name(Dest), Immed); CPU_Message(" psrlw %s, %i", mmx_Name(Dest), Immed);
switch (Dest) { switch (Dest)
{
case x86_MM0: x86Command = 0xD0; break; case x86_MM0: x86Command = 0xD0; break;
case x86_MM1: x86Command = 0xD1; break; case x86_MM1: x86Command = 0xD1; break;
case x86_MM2: x86Command = 0xD2; break; case x86_MM2: x86Command = 0xD2; break;
@ -454,12 +502,14 @@ void MmxPsrlwImmed(int Dest, BYTE Immed) {
PUTDST8(RecompPos, Immed); PUTDST8(RecompPos, Immed);
} }
void MmxPsrawImmed(int Dest, BYTE Immed) { void MmxPsrawImmed(int Dest, BYTE Immed)
{
BYTE x86Command = 0; BYTE x86Command = 0;
CPU_Message(" psraw %s, %i", mmx_Name(Dest), Immed); CPU_Message(" psraw %s, %i", mmx_Name(Dest), Immed);
switch (Dest) { switch (Dest)
{
case x86_MM0: x86Command = 0xE0; break; case x86_MM0: x86Command = 0xE0; break;
case x86_MM1: x86Command = 0xE1; break; case x86_MM1: x86Command = 0xE1; break;
case x86_MM2: x86Command = 0xE2; break; case x86_MM2: x86Command = 0xE2; break;
@ -475,12 +525,14 @@ void MmxPsrawImmed(int Dest, BYTE Immed) {
PUTDST8(RecompPos, Immed); PUTDST8(RecompPos, Immed);
} }
void MmxPsllwImmed(int Dest, BYTE Immed) { void MmxPsllwImmed(int Dest, BYTE Immed)
{
BYTE x86Command = 0; BYTE x86Command = 0;
CPU_Message(" psllw %s, %i", mmx_Name(Dest), Immed); CPU_Message(" psllw %s, %i", mmx_Name(Dest), Immed);
switch (Dest) { switch (Dest)
{
case x86_MM0: x86Command = 0xF0; break; case x86_MM0: x86Command = 0xF0; break;
case x86_MM1: x86Command = 0xF1; break; case x86_MM1: x86Command = 0xF1; break;
case x86_MM2: x86Command = 0xF2; break; case x86_MM2: x86Command = 0xF2; break;
@ -496,12 +548,14 @@ void MmxPsllwImmed(int Dest, BYTE Immed) {
PUTDST8(RecompPos, Immed); PUTDST8(RecompPos, Immed);
} }
void MmxPaddswRegToReg(int Dest, int Source) { void MmxPaddswRegToReg(int Dest, int Source)
{
BYTE x86Command = 0; BYTE x86Command = 0;
CPU_Message(" paddsw %s, %s", mmx_Name(Dest), mmx_Name(Source)); CPU_Message(" paddsw %s, %s", mmx_Name(Dest), mmx_Name(Source));
switch (Dest) { switch (Dest)
{
case x86_MM0: x86Command = 0 << 3; break; case x86_MM0: x86Command = 0 << 3; break;
case x86_MM1: x86Command = 1 << 3; break; case x86_MM1: x86Command = 1 << 3; break;
case x86_MM2: x86Command = 2 << 3; break; case x86_MM2: x86Command = 2 << 3; break;
@ -511,7 +565,8 @@ void MmxPaddswRegToReg(int Dest, int Source) {
case x86_MM6: x86Command = 6 << 3; break; case x86_MM6: x86Command = 6 << 3; break;
case x86_MM7: x86Command = 7 << 3; break; case x86_MM7: x86Command = 7 << 3; break;
} }
switch (Source) { switch (Source)
{
case x86_MM0: x86Command |= 0; break; case x86_MM0: x86Command |= 0; break;
case x86_MM1: x86Command |= 1; break; case x86_MM1: x86Command |= 1; break;
case x86_MM2: x86Command |= 2; break; case x86_MM2: x86Command |= 2; break;
@ -525,12 +580,14 @@ void MmxPaddswRegToReg(int Dest, int Source) {
PUTDST8(RecompPos, 0xC0 | x86Command); PUTDST8(RecompPos, 0xC0 | x86Command);
} }
void MmxPsubswRegToReg(int Dest, int Source) { void MmxPsubswRegToReg(int Dest, int Source)
{
BYTE x86Command = 0; BYTE x86Command = 0;
CPU_Message(" psubsw %s, %s", mmx_Name(Dest), mmx_Name(Source)); CPU_Message(" psubsw %s, %s", mmx_Name(Dest), mmx_Name(Source));
switch (Dest) { switch (Dest)
{
case x86_MM0: x86Command = 0 << 3; break; case x86_MM0: x86Command = 0 << 3; break;
case x86_MM1: x86Command = 1 << 3; break; case x86_MM1: x86Command = 1 << 3; break;
case x86_MM2: x86Command = 2 << 3; break; case x86_MM2: x86Command = 2 << 3; break;
@ -540,7 +597,8 @@ void MmxPsubswRegToReg(int Dest, int Source) {
case x86_MM6: x86Command = 6 << 3; break; case x86_MM6: x86Command = 6 << 3; break;
case x86_MM7: x86Command = 7 << 3; break; case x86_MM7: x86Command = 7 << 3; break;
} }
switch (Source) { switch (Source)
{
case x86_MM0: x86Command |= 0; break; case x86_MM0: x86Command |= 0; break;
case x86_MM1: x86Command |= 1; break; case x86_MM1: x86Command |= 1; break;
case x86_MM2: x86Command |= 2; break; case x86_MM2: x86Command |= 2; break;
@ -554,12 +612,14 @@ void MmxPsubswRegToReg(int Dest, int Source) {
PUTDST8(RecompPos, 0xC0 | x86Command); PUTDST8(RecompPos, 0xC0 | x86Command);
} }
void MmxPaddswVariableToReg(int Dest, void * Variable, char * VariableName) { void MmxPaddswVariableToReg(int Dest, void * Variable, char * VariableName)
{
BYTE x86Command = 0; BYTE x86Command = 0;
CPU_Message(" paddsw %s, [%s]", mmx_Name(Dest), VariableName); CPU_Message(" paddsw %s, [%s]", mmx_Name(Dest), VariableName);
switch (Dest) { switch (Dest)
{
case x86_MM0: x86Command = 0x05; break; case x86_MM0: x86Command = 0x05; break;
case x86_MM1: x86Command = 0x0D; break; case x86_MM1: x86Command = 0x0D; break;
case x86_MM2: x86Command = 0x15; break; case x86_MM2: x86Command = 0x15; break;
@ -575,12 +635,14 @@ void MmxPaddswVariableToReg(int Dest, void * Variable, char * VariableName) {
PUTDSTPTR(RecompPos, Variable); PUTDSTPTR(RecompPos, Variable);
} }
void MmxPsubswVariableToReg(int Dest, void * Variable, char * VariableName) { void MmxPsubswVariableToReg(int Dest, void * Variable, char * VariableName)
{
BYTE x86Command = 0; BYTE x86Command = 0;
CPU_Message(" psubsw %s, [%s]", mmx_Name(Dest), VariableName); CPU_Message(" psubsw %s, [%s]", mmx_Name(Dest), VariableName);
switch (Dest) { switch (Dest)
{
case x86_MM0: x86Command = 0x05; break; case x86_MM0: x86Command = 0x05; break;
case x86_MM1: x86Command = 0x0D; break; case x86_MM1: x86Command = 0x0D; break;
case x86_MM2: x86Command = 0x15; break; case x86_MM2: x86Command = 0x15; break;
@ -596,12 +658,14 @@ void MmxPsubswVariableToReg(int Dest, void * Variable, char * VariableName) {
PUTDSTPTR(RecompPos, Variable); PUTDSTPTR(RecompPos, Variable);
} }
void MmxPaddwRegToReg(int Dest, int Source) { void MmxPaddwRegToReg(int Dest, int Source)
{
BYTE x86Command = 0; BYTE x86Command = 0;
CPU_Message(" paddw %s, %s", mmx_Name(Dest), mmx_Name(Source)); CPU_Message(" paddw %s, %s", mmx_Name(Dest), mmx_Name(Source));
switch (Dest) { switch (Dest)
{
case x86_MM0: x86Command = 0 << 3; break; case x86_MM0: x86Command = 0 << 3; break;
case x86_MM1: x86Command = 1 << 3; break; case x86_MM1: x86Command = 1 << 3; break;
case x86_MM2: x86Command = 2 << 3; break; case x86_MM2: x86Command = 2 << 3; break;
@ -611,7 +675,8 @@ void MmxPaddwRegToReg(int Dest, int Source) {
case x86_MM6: x86Command = 6 << 3; break; case x86_MM6: x86Command = 6 << 3; break;
case x86_MM7: x86Command = 7 << 3; break; case x86_MM7: x86Command = 7 << 3; break;
} }
switch (Source) { switch (Source)
{
case x86_MM0: x86Command |= 0; break; case x86_MM0: x86Command |= 0; break;
case x86_MM1: x86Command |= 1; break; case x86_MM1: x86Command |= 1; break;
case x86_MM2: x86Command |= 2; break; case x86_MM2: x86Command |= 2; break;
@ -625,12 +690,14 @@ void MmxPaddwRegToReg(int Dest, int Source) {
PUTDST8(RecompPos, 0xC0 | x86Command); PUTDST8(RecompPos, 0xC0 | x86Command);
} }
void MmxPackSignedDwords(int Dest, int Source) { void MmxPackSignedDwords(int Dest, int Source)
{
BYTE x86Command = 0; BYTE x86Command = 0;
CPU_Message(" packssdw %s, %s", mmx_Name(Dest), mmx_Name(Source)); CPU_Message(" packssdw %s, %s", mmx_Name(Dest), mmx_Name(Source));
switch (Dest) { switch (Dest)
{
case x86_MM0: x86Command = 0 << 3; break; case x86_MM0: x86Command = 0 << 3; break;
case x86_MM1: x86Command = 1 << 3; break; case x86_MM1: x86Command = 1 << 3; break;
case x86_MM2: x86Command = 2 << 3; break; case x86_MM2: x86Command = 2 << 3; break;
@ -640,7 +707,8 @@ void MmxPackSignedDwords(int Dest, int Source) {
case x86_MM6: x86Command = 6 << 3; break; case x86_MM6: x86Command = 6 << 3; break;
case x86_MM7: x86Command = 7 << 3; break; case x86_MM7: x86Command = 7 << 3; break;
} }
switch (Source) { switch (Source)
{
case x86_MM0: x86Command |= 0; break; case x86_MM0: x86Command |= 0; break;
case x86_MM1: x86Command |= 1; break; case x86_MM1: x86Command |= 1; break;
case x86_MM2: x86Command |= 2; break; case x86_MM2: x86Command |= 2; break;
@ -654,12 +722,14 @@ void MmxPackSignedDwords(int Dest, int Source) {
PUTDST8(RecompPos, 0xC0 | x86Command); PUTDST8(RecompPos, 0xC0 | x86Command);
} }
void MmxUnpackLowWord(int Dest, int Source) { void MmxUnpackLowWord(int Dest, int Source)
{
BYTE x86Command = 0; BYTE x86Command = 0;
CPU_Message(" punpcklwd %s, %s", mmx_Name(Dest), mmx_Name(Source)); CPU_Message(" punpcklwd %s, %s", mmx_Name(Dest), mmx_Name(Source));
switch (Dest) { switch (Dest)
{
case x86_MM0: x86Command = 0 << 3; break; case x86_MM0: x86Command = 0 << 3; break;
case x86_MM1: x86Command = 1 << 3; break; case x86_MM1: x86Command = 1 << 3; break;
case x86_MM2: x86Command = 2 << 3; break; case x86_MM2: x86Command = 2 << 3; break;
@ -669,7 +739,8 @@ void MmxUnpackLowWord(int Dest, int Source) {
case x86_MM6: x86Command = 6 << 3; break; case x86_MM6: x86Command = 6 << 3; break;
case x86_MM7: x86Command = 7 << 3; break; case x86_MM7: x86Command = 7 << 3; break;
} }
switch (Source) { switch (Source)
{
case x86_MM0: x86Command |= 0; break; case x86_MM0: x86Command |= 0; break;
case x86_MM1: x86Command |= 1; break; case x86_MM1: x86Command |= 1; break;
case x86_MM2: x86Command |= 2; break; case x86_MM2: x86Command |= 2; break;
@ -683,12 +754,14 @@ void MmxUnpackLowWord(int Dest, int Source) {
PUTDST8(RecompPos, 0xC0 | x86Command); PUTDST8(RecompPos, 0xC0 | x86Command);
} }
void MmxUnpackHighWord(int Dest, int Source) { void MmxUnpackHighWord(int Dest, int Source)
{
BYTE x86Command = 0; BYTE x86Command = 0;
CPU_Message(" punpckhwd %s, %s", mmx_Name(Dest), mmx_Name(Source)); CPU_Message(" punpckhwd %s, %s", mmx_Name(Dest), mmx_Name(Source));
switch (Dest) { switch (Dest)
{
case x86_MM0: x86Command = 0 << 3; break; case x86_MM0: x86Command = 0 << 3; break;
case x86_MM1: x86Command = 1 << 3; break; case x86_MM1: x86Command = 1 << 3; break;
case x86_MM2: x86Command = 2 << 3; break; case x86_MM2: x86Command = 2 << 3; break;
@ -698,7 +771,8 @@ void MmxUnpackHighWord(int Dest, int Source) {
case x86_MM6: x86Command = 6 << 3; break; case x86_MM6: x86Command = 6 << 3; break;
case x86_MM7: x86Command = 7 << 3; break; case x86_MM7: x86Command = 7 << 3; break;
} }
switch (Source) { switch (Source)
{
case x86_MM0: x86Command |= 0; break; case x86_MM0: x86Command |= 0; break;
case x86_MM1: x86Command |= 1; break; case x86_MM1: x86Command |= 1; break;
case x86_MM2: x86Command |= 2; break; case x86_MM2: x86Command |= 2; break;
@ -712,12 +786,14 @@ void MmxUnpackHighWord(int Dest, int Source) {
PUTDST8(RecompPos, 0xC0 | x86Command); PUTDST8(RecompPos, 0xC0 | x86Command);
} }
void MmxCompareGreaterWordRegToReg(int Dest, int Source) { void MmxCompareGreaterWordRegToReg(int Dest, int Source)
{
BYTE x86Command = 0; BYTE x86Command = 0;
CPU_Message(" pcmpgtw %s, %s", mmx_Name(Dest), mmx_Name(Source)); CPU_Message(" pcmpgtw %s, %s", mmx_Name(Dest), mmx_Name(Source));
switch (Dest) { switch (Dest)
{
case x86_MM0: x86Command = 0 << 3; break; case x86_MM0: x86Command = 0 << 3; break;
case x86_MM1: x86Command = 1 << 3; break; case x86_MM1: x86Command = 1 << 3; break;
case x86_MM2: x86Command = 2 << 3; break; case x86_MM2: x86Command = 2 << 3; break;
@ -727,7 +803,8 @@ void MmxCompareGreaterWordRegToReg(int Dest, int Source) {
case x86_MM6: x86Command = 6 << 3; break; case x86_MM6: x86Command = 6 << 3; break;
case x86_MM7: x86Command = 7 << 3; break; case x86_MM7: x86Command = 7 << 3; break;
} }
switch (Source) { switch (Source)
{
case x86_MM0: x86Command |= 0; break; case x86_MM0: x86Command |= 0; break;
case x86_MM1: x86Command |= 1; break; case x86_MM1: x86Command |= 1; break;
case x86_MM2: x86Command |= 2; break; case x86_MM2: x86Command |= 2; break;

View File

@ -4,30 +4,35 @@
#pragma warning(push) #pragma warning(push)
#pragma warning(disable : 4201) // Non-standard extension used: nameless struct/union #pragma warning(disable : 4201) // Non-standard extension used: nameless struct/union
typedef union tagOPCODE { typedef union tagOPCODE
{
uint32_t Hex; uint32_t Hex;
unsigned char Ascii[4]; unsigned char Ascii[4];
struct { struct
{
unsigned immediate : 16; unsigned immediate : 16;
unsigned rt : 5; unsigned rt : 5;
unsigned rs : 5; unsigned rs : 5;
unsigned op : 6; unsigned op : 6;
}; };
struct { struct
{
unsigned offset : 16; unsigned offset : 16;
unsigned : 5; unsigned : 5;
unsigned base : 5; unsigned base : 5;
unsigned : 6; unsigned : 6;
}; };
struct { struct
{
unsigned target : 26; unsigned target : 26;
unsigned : 6; unsigned : 6;
}; };
struct { struct
{
unsigned funct : 6; unsigned funct : 6;
unsigned sa : 5; unsigned sa : 5;
unsigned rd : 5; unsigned rd : 5;
@ -36,7 +41,8 @@ typedef union tagOPCODE {
unsigned : 6; unsigned : 6;
}; };
struct { struct
{
signed voffset : 7; signed voffset : 7;
unsigned del : 4; unsigned del : 4;
unsigned : 5; unsigned : 5;

View File

@ -1,11 +1,13 @@
#include <stdio.h> #include <stdio.h>
#include <windows.h> #include <windows.h>
#include <shellapi.h> #include <shellapi.h>
#include "profiling.h" #include "profiling.h"
#pragma warning(disable : 4786) #pragma warning(disable : 4786)
#include <Common/StdString.h>
#include <Common/File.h> #include <Common/File.h>
#include <Common/Log.h> #include <Common/Log.h>
#include <Common/StdString.h>
#include <map> #include <map>
#include <vector> #include <vector>
@ -14,7 +16,11 @@ class CProfiling
typedef std::map<DWORD, __int64> PROFILE_ENRTIES; typedef std::map<DWORD, __int64> PROFILE_ENRTIES;
typedef PROFILE_ENRTIES::iterator PROFILE_ENRTY; typedef PROFILE_ENRTIES::iterator PROFILE_ENRTY;
typedef PROFILE_ENRTIES::value_type PROFILE_VALUE; typedef PROFILE_ENRTIES::value_type PROFILE_VALUE;
typedef struct { SPECIAL_TIMERS Timer; char * Name; } TIMER_NAME; typedef struct
{
SPECIAL_TIMERS Timer;
char * Name;
} TIMER_NAME;
DWORD m_CurrentTimerAddr, CurrentDisplayCount; DWORD m_CurrentTimerAddr, CurrentDisplayCount;
DWORD m_StartTimeHi, m_StartTimeLo; // The current timer start time DWORD m_StartTimeHi, m_StartTimeLo; // The current timer start time
@ -50,7 +56,10 @@ public:
} }
DWORD StopTimer(void) DWORD StopTimer(void)
{ {
if (m_CurrentTimerAddr == Timer_None) { return m_CurrentTimerAddr; } if (m_CurrentTimerAddr == Timer_None)
{
return m_CurrentTimerAddr;
}
#if defined(_M_IX86) && defined(_MSC_VER) #if defined(_M_IX86) && defined(_MSC_VER)
DWORD HiValue, LoValue; DWORD HiValue, LoValue;
@ -142,7 +151,10 @@ public:
char Buffer[255]; char Buffer[255];
float CpuUsage = (float)(((double)ItemList[count]->second / (double)TotalTime) * 100); float CpuUsage = (float)(((double)ItemList[count]->second / (double)TotalTime) * 100);
if (CpuUsage <= 0.2) { continue; } if (CpuUsage <= 0.2)
{
continue;
}
sprintf(Buffer, "Function 0x%08X", ItemList[count]->first); sprintf(Buffer, "Function 0x%08X", ItemList[count]->first);
for (int NameID = 0; NameID < (sizeof(TimerNames) / sizeof(TIMER_NAME)); NameID++) for (int NameID = 0; NameID < (sizeof(TimerNames) / sizeof(TIMER_NAME)); NameID++)
{ {
@ -161,7 +173,6 @@ public:
} }
}; };
CProfiling & GetProfiler(void) CProfiling & GetProfiler(void)
{ {
static CProfiling Profile; static CProfiling Profile;
@ -189,10 +200,11 @@ void GenerateTimerResults (void)
} }
#ifdef todelete #ifdef todelete
#include <windows.h>
#include <stdio.h> #include <stdio.h>
#include <windows.h>
typedef struct { typedef struct
{
char Label[100]; char Label[100];
__int64 TimeTotal; __int64 TimeTotal;
} TIME_STAMP_ENTRY; } TIME_STAMP_ENTRY;
@ -203,7 +215,10 @@ char LastLabel[100];
void ResetTimerList(void) void ResetTimerList(void)
{ {
if (TS_Entries) { free(TS_Entries); } if (TS_Entries)
{
free(TS_Entries);
}
TS_Entries = NULL; TS_Entries = NULL;
TSE_Count = 0; TSE_Count = 0;
TSE_Max = 0; TSE_Max = 0;
@ -230,7 +245,10 @@ void StopTimer (void)
mov StopTimeLo, eax mov StopTimeLo, eax
popad popad
} }
if (strlen(LastLabel) == 0) { return; } if (strlen(LastLabel) == 0)
{
return;
}
{ {
DWORD count; DWORD count;
@ -309,8 +327,7 @@ void GenerateTimerResults (void)
{ {
sprintf(buffer, "%s - %0.2f%c\r\n", sprintf(buffer, "%s - %0.2f%c\r\n",
TS_Entries[count].Label, TS_Entries[count].Label,
(((double)TS_Entries[count].TimeTotal / (double)TotalTime) * 100),'%' (((double)TS_Entries[count].TimeTotal / (double)TotalTime) * 100), '%');
);
WriteFile(hLogFile, buffer, strlen(buffer), &dwWritten, NULL); WriteFile(hLogFile, buffer, strlen(buffer), &dwWritten, NULL);
} }
CloseHandle(hLogFile); CloseHandle(hLogFile);

View File

@ -1,8 +1,16 @@
enum SPECIAL_TIMERS { enum SPECIAL_TIMERS
Timer_None = 0, Timer_Compiling = -1, Timer_RSP_Running = -2, {
Timer_R4300_Running = -3, Timer_RDP_Running = -5, Timer_RefreshScreen = -6, Timer_None = 0,
Timer_UpdateScreen = -7, Timer_UpdateFPS = -9, Timer_Idel = -10, Timer_Compiling = -1,
Timer_FuncLookup = -11,Timer_Done = -13, Timer_RSP_Running = -2,
Timer_R4300_Running = -3,
Timer_RDP_Running = -5,
Timer_RefreshScreen = -6,
Timer_UpdateScreen = -7,
Timer_UpdateFPS = -9,
Timer_Idel = -10,
Timer_FuncLookup = -11,
Timer_Done = -13,
}; };
void ResetTimerList(void); void ResetTimerList(void);

View File

@ -1,15 +1,15 @@
#include <windows.h>
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include <windows.h>
#include "opcode.h"
#include "Rsp.h"
#include "CPU.h" #include "CPU.h"
#include "RSP Registers.h"
#include "RSP Command.h" #include "RSP Command.h"
#include "memory.h" #include "RSP Registers.h"
#include "breakpoint.h" #include "Rsp.h"
#include "Types.h" #include "Types.h"
#include "breakpoint.h"
#include "memory.h"
#include "opcode.h"
#define RSP_MaxCommandLines 30 #define RSP_MaxCommandLines 30
@ -34,7 +34,8 @@ void Paint_RSP_Commands (HWND hDlg);
void RSP_Commands_Setup(HWND hDlg); void RSP_Commands_Setup(HWND hDlg);
LRESULT CALLBACK RSP_Commands_Proc(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam); LRESULT CALLBACK RSP_Commands_Proc(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam);
typedef struct { typedef struct
{
DWORD Location; DWORD Location;
DWORD opcode; DWORD opcode;
char String[150]; char String[150];
@ -72,7 +73,8 @@ void Create_RSP_Commands_Window ( int Child )
} }
else else
{ {
if (IsIconic((HWND)RSPCommandshWnd)) { if (IsIconic((HWND)RSPCommandshWnd))
{
SendMessage(RSPCommandshWnd, WM_SYSCOMMAND, SC_RESTORE, 0); SendMessage(RSPCommandshWnd, WM_SYSCOMMAND, SC_RESTORE, 0);
} }
SetForegroundWindow(RSPCommandshWnd); SetForegroundWindow(RSPCommandshWnd);
@ -84,7 +86,10 @@ void Disable_RSP_Commands_Window ( void )
{ {
SCROLLINFO si; SCROLLINFO si;
if (!InRSPCommandsWindow) { return; } if (!InRSPCommandsWindow)
{
return;
}
EnableWindow(hList, FALSE); EnableWindow(hList, FALSE);
EnableWindow(hAddress, FALSE); EnableWindow(hAddress, FALSE);
EnableWindow(hScrlBar, FALSE); EnableWindow(hScrlBar, FALSE);
@ -114,11 +119,26 @@ int DisplayRSPCommand (DWORD location, int InsertPos)
RSP_LW_IMEM(location, &OpCode); RSP_LW_IMEM(location, &OpCode);
status = 0; status = 0;
if (location == *PrgCount) {status = RSP_Status_PC; } if (location == *PrgCount)
if (CheckForRSPBPoint(location)) { status |= RSP_Status_BP; } {
if (RSPCommandLine[InsertPos].opcode != OpCode) { Redraw = TRUE; } status = RSP_Status_PC;
if (RSPCommandLine[InsertPos].Location != location) { Redraw = TRUE; } }
if (RSPCommandLine[InsertPos].status != status) { Redraw = TRUE; } 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].Location = location;
@ -173,7 +193,8 @@ void DumpRSPCode (void)
FILE_ATTRIBUTE_NORMAL | FILE_FLAG_SEQUENTIAL_SCAN, NULL); FILE_ATTRIBUTE_NORMAL | FILE_FLAG_SEQUENTIAL_SCAN, NULL);
SetFilePointer(hLogFile, 0, NULL, FILE_BEGIN); SetFilePointer(hLogFile, 0, NULL, FILE_BEGIN);
for (location = 0; location < 0x1000; location += 4) { for (location = 0; location < 0x1000; location += 4)
{
unsigned int characters_to_write; unsigned int characters_to_write;
int characters_converted; int characters_converted;
@ -182,10 +203,10 @@ void DumpRSPCode (void)
&string[0], &string[0],
" 0x%03X\t%s\r\n", " 0x%03X\t%s\r\n",
location, location,
RSPOpcodeName(OpCode, location) RSPOpcodeName(OpCode, location));
);
if (characters_converted < 0) { if (characters_converted < 0)
{
DisplayError("Failed to sprintf IMEM from 0x%03X.", location); DisplayError("Failed to sprintf IMEM from 0x%03X.", location);
break; break;
} }
@ -213,7 +234,8 @@ void DumpRSPData (void)
if (strchr(LogFileName, '\\')) if (strchr(LogFileName, '\\'))
{ {
p = LogFileName; p = LogFileName;
while (strchr(p,'\\')) { while (strchr(p, '\\'))
{
p = strchr(p, '\\'); p = strchr(p, '\\');
p++; p++;
} }
@ -237,10 +259,10 @@ void DumpRSPData (void)
&string[0], &string[0],
" 0x%03X\t0x%08X\r\n", " 0x%03X\t0x%08X\r\n",
location, location,
value value);
);
if (characters_converted < 0) { if (characters_converted < 0)
{
DisplayError("Failed to sprintf DMEM from 0x%03X.", location); DisplayError("Failed to sprintf DMEM from 0x%03X.", location);
break; break;
} }
@ -330,8 +352,7 @@ void DrawRSPCommand ( LPARAM lParam )
ditem->hDC, ditem->hDC,
&Offset[0], printed_offset, &Offset[0], printed_offset,
&TextRect, &TextRect,
DT_SINGLELINE | DT_VCENTER DT_SINGLELINE | DT_VCENTER);
);
SetRect(&TextRect, ditem->rcItem.left + 83, ditem->rcItem.top, ditem->rcItem.left + 165, SetRect(&TextRect, ditem->rcItem.left + 83, ditem->rcItem.top, ditem->rcItem.left + 165,
ditem->rcItem.bottom); ditem->rcItem.bottom);
@ -339,8 +360,7 @@ void DrawRSPCommand ( LPARAM lParam )
ditem->hDC, ditem->hDC,
&Instruction[0], printed_instruction, &Instruction[0], printed_instruction,
&TextRect, &TextRect,
DT_SINGLELINE | DT_VCENTER DT_SINGLELINE | DT_VCENTER);
);
SetRect(&TextRect, ditem->rcItem.left + 165, ditem->rcItem.top, ditem->rcItem.right, SetRect(&TextRect, ditem->rcItem.left + 165, ditem->rcItem.top, ditem->rcItem.right,
ditem->rcItem.bottom); ditem->rcItem.bottom);
@ -348,8 +368,7 @@ void DrawRSPCommand ( LPARAM lParam )
ditem->hDC, ditem->hDC,
&Arguments[0], printed_arguments, &Arguments[0], printed_arguments,
&TextRect, &TextRect,
DT_SINGLELINE | DT_VCENTER DT_SINGLELINE | DT_VCENTER);
);
} }
else else
{ {
@ -357,11 +376,11 @@ void DrawRSPCommand ( LPARAM lParam )
ditem->hDC, ditem->hDC,
&Command[0], (signed int)strlen(Command), &Command[0], (signed int)strlen(Command),
&ditem->rcItem, &ditem->rcItem,
DT_SINGLELINE | DT_VCENTER DT_SINGLELINE | DT_VCENTER);
);
} }
if (ResetColor == TRUE) { if (ResetColor == TRUE)
{
SetTextColor(ditem->hDC, oldColor); SetTextColor(ditem->hDC, oldColor);
} }
} }
@ -370,7 +389,10 @@ void Enable_RSP_Commands_Window ( void )
{ {
SCROLLINFO si; SCROLLINFO si;
if (!InRSPCommandsWindow) { return; } if (!InRSPCommandsWindow)
{
return;
}
EnableWindow(hList, TRUE); EnableWindow(hList, TRUE);
EnableWindow(hAddress, TRUE); EnableWindow(hAddress, TRUE);
EnableWindow(hScrlBar, TRUE); EnableWindow(hScrlBar, TRUE);
@ -385,7 +407,8 @@ void Enable_RSP_Commands_Window ( void )
SendMessage(hStepButton, BM_SETSTYLE, BS_DEFPUSHBUTTON, TRUE); SendMessage(hStepButton, BM_SETSTYLE, BS_DEFPUSHBUTTON, TRUE);
SendMessage(RSPCommandshWnd, DM_SETDEFID, IDC_STEP_BUTTON, 0); SendMessage(RSPCommandshWnd, DM_SETDEFID, IDC_STEP_BUTTON, 0);
if (Stepping_Commands) { if (Stepping_Commands)
{
si.cbSize = sizeof(si); si.cbSize = sizeof(si);
si.fMask = SIF_RANGE | SIF_POS | SIF_PAGE; si.fMask = SIF_RANGE | SIF_POS | SIF_PAGE;
si.nMin = 0; si.nMin = 0;
@ -413,32 +436,46 @@ void Paint_RSP_Commands (HWND hDlg)
BeginPaint(hDlg, &ps); BeginPaint(hDlg, &ps);
rcBox.left = 5; rcBox.top = 5; rcBox.left = 5;
rcBox.right = 343; rcBox.bottom = 463; rcBox.top = 5;
rcBox.right = 343;
rcBox.bottom = 463;
DrawEdge(ps.hdc, &rcBox, EDGE_RAISED, BF_RECT); DrawEdge(ps.hdc, &rcBox, EDGE_RAISED, BF_RECT);
rcBox.left = 8; rcBox.top = 8; rcBox.left = 8;
rcBox.right = 340; rcBox.bottom = 460; rcBox.top = 8;
rcBox.right = 340;
rcBox.bottom = 460;
DrawEdge(ps.hdc, &rcBox, EDGE_ETCHED, BF_RECT); DrawEdge(ps.hdc, &rcBox, EDGE_ETCHED, BF_RECT);
rcBox.left = 347; rcBox.top = 7; rcBox.left = 347;
rcBox.right = 446; rcBox.bottom = 42; rcBox.top = 7;
rcBox.right = 446;
rcBox.bottom = 42;
DrawEdge(ps.hdc, &rcBox, EDGE_ETCHED, BF_RECT); DrawEdge(ps.hdc, &rcBox, EDGE_ETCHED, BF_RECT);
rcBox.left = 352; rcBox.top = 2; rcBox.left = 352;
rcBox.right = 400; rcBox.bottom = 15; rcBox.top = 2;
rcBox.right = 400;
rcBox.bottom = 15;
FillRect(ps.hdc, &rcBox, (HBRUSH)COLOR_WINDOW); FillRect(ps.hdc, &rcBox, (HBRUSH)COLOR_WINDOW);
rcBox.left = 14; rcBox.top = 14; rcBox.left = 14;
rcBox.right = 88; rcBox.bottom = 32; rcBox.top = 14;
rcBox.right = 88;
rcBox.bottom = 32;
DrawEdge(ps.hdc, &rcBox, EDGE_ETCHED, BF_RECT); DrawEdge(ps.hdc, &rcBox, EDGE_ETCHED, BF_RECT);
rcBox.left = 86; rcBox.top = 14; rcBox.left = 86;
rcBox.right = 173; rcBox.bottom = 32; rcBox.top = 14;
rcBox.right = 173;
rcBox.bottom = 32;
DrawEdge(ps.hdc, &rcBox, EDGE_ETCHED, BF_RECT); DrawEdge(ps.hdc, &rcBox, EDGE_ETCHED, BF_RECT);
rcBox.left = 171; rcBox.top = 14; rcBox.left = 171;
rcBox.right = 320; rcBox.bottom = 32; rcBox.top = 14;
rcBox.right = 320;
rcBox.bottom = 32;
DrawEdge(ps.hdc, &rcBox, EDGE_ETCHED, BF_RECT); DrawEdge(ps.hdc, &rcBox, EDGE_ETCHED, BF_RECT);
hOldFont = (HFONT)SelectObject(ps.hdc, GetStockObject(DEFAULT_GUI_FONT)); hOldFont = (HFONT)SelectObject(ps.hdc, GetStockObject(DEFAULT_GUI_FONT));
@ -462,12 +499,18 @@ void RefreshRSPCommands ( void )
char AsciiAddress[20]; char AsciiAddress[20];
int count; int count;
if (InRSPCommandsWindow == FALSE) { return; } if (InRSPCommandsWindow == FALSE)
{
return;
}
GetWindowTextA(hAddress, AsciiAddress, sizeof(AsciiAddress)); GetWindowTextA(hAddress, AsciiAddress, sizeof(AsciiAddress));
location = AsciiToHex(AsciiAddress) & ~3; location = AsciiToHex(AsciiAddress) & ~3;
if (location > 0xF88) { location = 0xF88; } 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); LinesUsed = DisplayRSPCommand(location, count);
@ -688,8 +731,7 @@ void RSP_Commands_Setup ( HWND hDlg )
char Location[10]; char Location[10];
DWORD X, Y, WndPos; DWORD X, Y, WndPos;
hList = CreateWindowExA(WS_EX_STATICEDGE, "LISTBOX","", WS_CHILD | WS_VISIBLE | hList = CreateWindowExA(WS_EX_STATICEDGE, "LISTBOX", "", WS_CHILD | WS_VISIBLE | LBS_OWNERDRAWFIXED | LBS_NOTIFY, 14, 30, 303, 445, hDlg,
LBS_OWNERDRAWFIXED | LBS_NOTIFY,14,30,303,445, hDlg,
(HMENU)IDC_LIST, (HINSTANCE)hinstDLL, NULL); (HMENU)IDC_LIST, (HINSTANCE)hinstDLL, NULL);
if (hList) if (hList)
{ {
@ -698,48 +740,42 @@ void RSP_Commands_Setup ( HWND hDlg )
} }
sprintf(Location, "%03X", PrgCount ? *PrgCount : 0); sprintf(Location, "%03X", PrgCount ? *PrgCount : 0);
hAddress = CreateWindowExA(0,"EDIT",Location, WS_CHILD | ES_UPPERCASE | WS_VISIBLE | hAddress = CreateWindowExA(0, "EDIT", Location, WS_CHILD | ES_UPPERCASE | WS_VISIBLE | WS_BORDER | WS_TABSTOP, 375, 17, 36, 18, hDlg, (HMENU)IDC_ADDRESS, (HINSTANCE)hinstDLL, NULL);
WS_BORDER | WS_TABSTOP,375,17,36,18, hDlg,(HMENU)IDC_ADDRESS, (HINSTANCE)hinstDLL, NULL );
if (hAddress) if (hAddress)
{ {
SendMessage(hAddress, WM_SETFONT, (WPARAM)GetStockObject(DEFAULT_GUI_FONT), 0); SendMessage(hAddress, WM_SETFONT, (WPARAM)GetStockObject(DEFAULT_GUI_FONT), 0);
SendMessage(hAddress, EM_SETLIMITTEXT, (WPARAM)3, (LPARAM)0); SendMessage(hAddress, EM_SETLIMITTEXT, (WPARAM)3, (LPARAM)0);
} }
hFunctionlist = CreateWindowExA(0,"COMBOBOX","", WS_CHILD | WS_VSCROLL | hFunctionlist = CreateWindowExA(0, "COMBOBOX", "", WS_CHILD | WS_VSCROLL | CBS_DROPDOWNLIST | CBS_SORT | WS_TABSTOP, 352, 56, 89, 150, hDlg,
CBS_DROPDOWNLIST | CBS_SORT | WS_TABSTOP,352,56,89,150,hDlg,
(HMENU)IDC_FUNCTION_COMBO, (HINSTANCE)hinstDLL, NULL); (HMENU)IDC_FUNCTION_COMBO, (HINSTANCE)hinstDLL, NULL);
if (hFunctionlist) if (hFunctionlist)
{ {
SendMessage(hFunctionlist, WM_SETFONT, (WPARAM)GetStockObject(DEFAULT_GUI_FONT), 0); SendMessage(hFunctionlist, WM_SETFONT, (WPARAM)GetStockObject(DEFAULT_GUI_FONT), 0);
} }
hGoButton = CreateWindowExA(WS_EX_STATICEDGE, "BUTTON","&Go", WS_CHILD | hGoButton = CreateWindowExA(WS_EX_STATICEDGE, "BUTTON", "&Go", WS_CHILD | BS_DEFPUSHBUTTON | WS_VISIBLE | WS_TABSTOP, 347, 56, 100, 24, hDlg, (HMENU)IDC_GO_BUTTON,
BS_DEFPUSHBUTTON | WS_VISIBLE | WS_TABSTOP, 347,56,100,24, hDlg,(HMENU)IDC_GO_BUTTON,
(HINSTANCE)hinstDLL, NULL); (HINSTANCE)hinstDLL, NULL);
if (hGoButton) if (hGoButton)
{ {
SendMessage(hGoButton, WM_SETFONT, (WPARAM)GetStockObject(DEFAULT_GUI_FONT), 0); SendMessage(hGoButton, WM_SETFONT, (WPARAM)GetStockObject(DEFAULT_GUI_FONT), 0);
} }
hBreakButton = CreateWindowExA(WS_EX_STATICEDGE, "BUTTON","&Break", WS_DISABLED | hBreakButton = CreateWindowExA(WS_EX_STATICEDGE, "BUTTON", "&Break", WS_DISABLED | WS_CHILD | BS_PUSHBUTTON | WS_VISIBLE | WS_TABSTOP | BS_TEXT, 347, 85, 100, 24, hDlg,
WS_CHILD | BS_PUSHBUTTON | WS_VISIBLE | WS_TABSTOP | BS_TEXT, 347,85,100,24,hDlg,
(HMENU)IDC_BREAK_BUTTON, (HINSTANCE)hinstDLL, NULL); (HMENU)IDC_BREAK_BUTTON, (HINSTANCE)hinstDLL, NULL);
if (hBreakButton) if (hBreakButton)
{ {
SendMessage(hBreakButton, WM_SETFONT, (WPARAM)GetStockObject(DEFAULT_GUI_FONT), 0); SendMessage(hBreakButton, WM_SETFONT, (WPARAM)GetStockObject(DEFAULT_GUI_FONT), 0);
} }
hStepButton = CreateWindowExA(WS_EX_STATICEDGE, "BUTTON","&Step", WS_CHILD | hStepButton = CreateWindowExA(WS_EX_STATICEDGE, "BUTTON", "&Step", WS_CHILD | BS_PUSHBUTTON | WS_VISIBLE | WS_TABSTOP | BS_TEXT, 347, 114, 100, 24, hDlg,
BS_PUSHBUTTON | WS_VISIBLE | WS_TABSTOP | BS_TEXT, 347,114,100,24,hDlg,
(HMENU)IDC_STEP_BUTTON, (HINSTANCE)hinstDLL, NULL); (HMENU)IDC_STEP_BUTTON, (HINSTANCE)hinstDLL, NULL);
if (hStepButton) if (hStepButton)
{ {
SendMessage(hStepButton, WM_SETFONT, (WPARAM)GetStockObject(DEFAULT_GUI_FONT), 0); SendMessage(hStepButton, WM_SETFONT, (WPARAM)GetStockObject(DEFAULT_GUI_FONT), 0);
} }
hSkipButton = CreateWindowExA(WS_EX_STATICEDGE, "BUTTON","&Skip", WS_CHILD | hSkipButton = CreateWindowExA(WS_EX_STATICEDGE, "BUTTON", "&Skip", WS_CHILD | BS_PUSHBUTTON | WS_VISIBLE | WS_TABSTOP | BS_TEXT, 347, 143, 100, 24, hDlg,
BS_PUSHBUTTON | WS_VISIBLE | WS_TABSTOP | BS_TEXT, 347,143,100,24,hDlg,
(HMENU)IDC_SKIP_BUTTON, (HINSTANCE)hinstDLL, NULL); (HMENU)IDC_SKIP_BUTTON, (HINSTANCE)hinstDLL, NULL);
if (hSkipButton) if (hSkipButton)
{ {
@ -747,15 +783,26 @@ void RSP_Commands_Setup ( HWND hDlg )
} }
WndPos = 324; WndPos = 324;
if (DebugInfo.Enter_BPoint_Window == NULL) { WndPos += 29;} if (DebugInfo.Enter_BPoint_Window == NULL)
if (DebugInfo.Enter_R4300i_Commands_Window == NULL) { WndPos += 29;} {
if (DebugInfo.Enter_R4300i_Register_Window == NULL) { WndPos += 29;} WndPos += 29;
if (DebugInfo.Enter_Memory_Window == NULL) { WndPos += 29;} }
if (DebugInfo.Enter_R4300i_Commands_Window == NULL)
{
WndPos += 29;
}
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 = CreateWindowExA(WS_EX_STATICEDGE, "BUTTON","&Break Points", WS_CHILD | hBPButton = CreateWindowExA(WS_EX_STATICEDGE, "BUTTON", "&Break Points", WS_CHILD | BS_PUSHBUTTON | WS_VISIBLE | WS_TABSTOP | BS_TEXT, 347, WndPos, 100, 24, hDlg,
BS_PUSHBUTTON | WS_VISIBLE | WS_TABSTOP | BS_TEXT, 347,WndPos,100,24,hDlg,
(HMENU)IDC_BP_BUTTON, (HINSTANCE)hinstDLL, NULL); (HMENU)IDC_BP_BUTTON, (HINSTANCE)hinstDLL, NULL);
if (hBPButton) if (hBPButton)
{ {
@ -799,8 +846,7 @@ void RSP_Commands_Setup ( HWND hDlg )
WndPos += 29; WndPos += 29;
if (DebugInfo.Enter_Memory_Window != NULL) if (DebugInfo.Enter_Memory_Window != NULL)
{ {
hMemory = CreateWindowExA(WS_EX_STATICEDGE,"BUTTON", "&Memory...", WS_CHILD | hMemory = CreateWindowExA(WS_EX_STATICEDGE, "BUTTON", "&Memory...", WS_CHILD | BS_PUSHBUTTON | WS_VISIBLE | WS_TABSTOP | BS_TEXT, 347, WndPos, 100, 24, hDlg,
BS_PUSHBUTTON | WS_VISIBLE | WS_TABSTOP | BS_TEXT, 347,WndPos,100,24,hDlg,
(HMENU)IDC_MEMORY_BUTTON, (HINSTANCE)hinstDLL, NULL); (HMENU)IDC_MEMORY_BUTTON, (HINSTANCE)hinstDLL, NULL);
if (hMemory) if (hMemory)
{ {
@ -808,8 +854,7 @@ void RSP_Commands_Setup ( HWND hDlg )
} }
} }
hScrlBar = CreateWindowExA(WS_EX_STATICEDGE, "SCROLLBAR","", WS_CHILD | WS_VISIBLE | hScrlBar = CreateWindowExA(WS_EX_STATICEDGE, "SCROLLBAR", "", WS_CHILD | WS_VISIBLE | WS_TABSTOP | SBS_VERT, 318, 14, 18, 439, hDlg, (HMENU)IDC_SCRL_BAR, (HINSTANCE)hinstDLL, NULL);
WS_TABSTOP | SBS_VERT, 318,14,18,439, hDlg, (HMENU)IDC_SCRL_BAR, (HINSTANCE)hinstDLL, NULL );
if (RSP_Running) if (RSP_Running)
{ {
@ -829,6 +874,7 @@ void RSP_Commands_Setup ( HWND hDlg )
SetWindowPos(hDlg, NULL, X, Y, WindowWidth, WindowHeight, SWP_NOZORDER | SWP_SHOWWINDOW); SetWindowPos(hDlg, NULL, X, Y, WindowWidth, WindowHeight, SWP_NOZORDER | SWP_SHOWWINDOW);
} }
// clang-format off
static const char unused_op[] = "invalid"; static const char unused_op[] = "invalid";
static const char* mnemonics_primary[8 << 3] = { static const char* mnemonics_primary[8 << 3] = {
"SPECIAL","REGIMM" ,"J" ,"JAL" ,"BEQ" ,"BNE" ,"BLEZ" ,"BGTZ" , "SPECIAL","REGIMM" ,"J" ,"JAL" ,"BEQ" ,"BNE" ,"BLEZ" ,"BGTZ" ,
@ -890,7 +936,7 @@ static const char* mnemonics_swc2[8 << 2] = {
unused_op,unused_op,unused_op,unused_op,unused_op,unused_op,unused_op,unused_op, unused_op,unused_op,unused_op,unused_op,unused_op,unused_op,unused_op,unused_op,
unused_op,unused_op,unused_op,unused_op,unused_op,unused_op,unused_op,unused_op, unused_op,unused_op,unused_op,unused_op,unused_op,unused_op,unused_op,unused_op,
};/* 000 | 001 | 010 | 011 | 100 | 101 | 110 | 111 */ };/* 000 | 001 | 010 | 011 | 100 | 101 | 110 | 111 */
// clang-format on
char * RSPSpecialName(DWORD OpCode, DWORD PC) char * RSPSpecialName(DWORD OpCode, DWORD PC)
{ {
@ -905,8 +951,7 @@ char * RSPSpecialName ( DWORD OpCode, DWORD PC )
command.Ascii[3], command.Ascii[3],
command.Ascii[2], command.Ascii[2],
command.Ascii[1], command.Ascii[1],
command.Ascii[0] command.Ascii[0]);
);
} }
else if (command.Hex == 0x00000000) else if (command.Hex == 0x00000000)
{ {
@ -918,8 +963,7 @@ char * RSPSpecialName ( DWORD OpCode, DWORD PC )
mnemonics_special[command.funct], mnemonics_special[command.funct],
GPR_Name(command.rd), GPR_Name(command.rd),
GPR_Name(command.rt), GPR_Name(command.rt),
command.sa command.sa);
);
} }
else if (command.funct >= RSP_SPECIAL_SLLV && command.funct < RSP_SPECIAL_JR) else if (command.funct >= RSP_SPECIAL_SLLV && command.funct < RSP_SPECIAL_JR)
{ {
@ -927,23 +971,20 @@ char * RSPSpecialName ( DWORD OpCode, DWORD PC )
mnemonics_special[command.funct], mnemonics_special[command.funct],
GPR_Name(command.rd), GPR_Name(command.rd),
GPR_Name(command.rt), GPR_Name(command.rt),
GPR_Name(command.rs) GPR_Name(command.rs));
);
} }
else if (command.funct == RSP_SPECIAL_JR) else if (command.funct == RSP_SPECIAL_JR)
{ {
sprintf(CommandName, "%s\t%s", sprintf(CommandName, "%s\t%s",
mnemonics_special[command.funct], mnemonics_special[command.funct],
GPR_Name(command.rs) GPR_Name(command.rs));
);
} }
else if (command.funct == RSP_SPECIAL_JALR) else if (command.funct == RSP_SPECIAL_JALR)
{ {
sprintf(CommandName, "%s\t%s, %s", sprintf(CommandName, "%s\t%s, %s",
mnemonics_special[command.funct], mnemonics_special[command.funct],
GPR_Name(command.rd), GPR_Name(command.rd),
GPR_Name(command.rs) GPR_Name(command.rs));
);
} }
else if (command.funct == RSP_SPECIAL_BREAK) else if (command.funct == RSP_SPECIAL_BREAK)
{ {
@ -955,8 +996,7 @@ char * RSPSpecialName ( DWORD OpCode, DWORD PC )
mnemonics_special[command.funct], mnemonics_special[command.funct],
GPR_Name(command.rd), GPR_Name(command.rd),
GPR_Name(command.rs), GPR_Name(command.rs),
GPR_Name(command.rt) GPR_Name(command.rt));
);
} }
return CommandName; return CommandName;
} }
@ -974,16 +1014,14 @@ char * RSPRegimmName ( DWORD OpCode, DWORD PC )
command.Ascii[3], command.Ascii[3],
command.Ascii[2], command.Ascii[2],
command.Ascii[1], command.Ascii[1],
command.Ascii[0] command.Ascii[0]);
);
} }
else if (command.rt == RSP_REGIMM_BGEZAL && command.rs == 0) else if (command.rt == RSP_REGIMM_BGEZAL && command.rs == 0)
{ // MIPS pseudo-instruction: BAL (branch and link) { // MIPS pseudo-instruction: BAL (branch and link)
sprintf( sprintf(
CommandName, CommandName,
"BAL\t0x%04X", "BAL\t0x%04X",
(PC + ((short)command.offset << 2) + 4) & 0x1FFC (PC + ((short)command.offset << 2) + 4) & 0x1FFC);
);
} }
else else
{ {
@ -992,8 +1030,7 @@ char * RSPRegimmName ( DWORD OpCode, DWORD PC )
"%s\t%s, 0x%04X", "%s\t%s, 0x%04X",
mnemonics_regimm[command.rt], mnemonics_regimm[command.rt],
GPR_Name(command.rs), GPR_Name(command.rs),
(PC + ((short)command.offset << 2) + 4) & 0x1FFC (PC + ((short)command.offset << 2) + 4) & 0x1FFC);
);
} }
return CommandName; return CommandName;
} }
@ -1013,8 +1050,7 @@ char * RSPCop0Name ( DWORD OpCode, DWORD PC )
command.Ascii[3], command.Ascii[3],
command.Ascii[2], command.Ascii[2],
command.Ascii[1], command.Ascii[1],
command.Ascii[0] command.Ascii[0]);
);
} }
else else
{ {
@ -1023,8 +1059,7 @@ char * RSPCop0Name ( DWORD OpCode, DWORD PC )
"%s\t%s, %s", "%s\t%s, %s",
mnemonics_cop0[command.rs], mnemonics_cop0[command.rs],
GPR_Name(command.rt), GPR_Name(command.rt),
COP0_Name(command.rd) COP0_Name(command.rd));
);
} }
return CommandName; return CommandName;
} }
@ -1044,16 +1079,14 @@ char * RSPCop2Name ( DWORD OpCode, DWORD PC )
command.Ascii[3], command.Ascii[3],
command.Ascii[2], command.Ascii[2],
command.Ascii[1], command.Ascii[1],
command.Ascii[0] command.Ascii[0]);
);
} }
else if (command.rs & 002) // CFC2 or CTC2 else if (command.rs & 002) // CFC2 or CTC2
{ {
sprintf(CommandName, "%s\t%s, %d", sprintf(CommandName, "%s\t%s, %d",
mnemonics_cop2[command.rs], mnemonics_cop2[command.rs],
GPR_Name(command.rt), GPR_Name(command.rt),
command.rd % 4 command.rd % 4);
);
} }
else else
{ {
@ -1061,8 +1094,7 @@ char * RSPCop2Name ( DWORD OpCode, DWORD PC )
mnemonics_cop2[command.rs], mnemonics_cop2[command.rs],
GPR_Name(command.rt), GPR_Name(command.rt),
command.rd, command.rd,
command.sa >> 1 command.sa >> 1);
);
} }
} }
else else
@ -1073,8 +1105,7 @@ char * RSPCop2Name ( DWORD OpCode, DWORD PC )
command.Ascii[3], command.Ascii[3],
command.Ascii[2], command.Ascii[2],
command.Ascii[1], command.Ascii[1],
command.Ascii[0] command.Ascii[0]);
);
} }
else if (command.funct >= RSP_VECTOR_VRCP && command.funct < RSP_VECTOR_VNOOP) else if (command.funct >= RSP_VECTOR_VRCP && command.funct < RSP_VECTOR_VNOOP)
{ // RSP division -- VRCP[L,H], VRSQ[L,H], and VMOV { // RSP division -- VRCP[L,H], VRSQ[L,H], and VMOV
@ -1083,8 +1114,7 @@ char * RSPCop2Name ( DWORD OpCode, DWORD PC )
command.sa, command.sa,
command.rd & 0x7, command.rd & 0x7,
command.rt, command.rt,
ElementSpecifier(command.rs & 0xF) ElementSpecifier(command.rs & 0xF));
);
} }
else if (command.funct == RSP_VECTOR_VNOOP) else if (command.funct == RSP_VECTOR_VNOOP)
{ {
@ -1097,8 +1127,7 @@ char * RSPCop2Name ( DWORD OpCode, DWORD PC )
command.sa, command.sa,
command.rd, command.rd,
command.rt, command.rt,
ElementSpecifier(command.rs & 0xF) ElementSpecifier(command.rs & 0xF));
);
} }
} }
return CommandName; return CommandName;
@ -1119,8 +1148,7 @@ char * RSPLc2Name ( DWORD OpCode, DWORD PC )
command.Ascii[3], command.Ascii[3],
command.Ascii[2], command.Ascii[2],
command.Ascii[1], command.Ascii[1],
command.Ascii[0] command.Ascii[0]);
);
} }
else else
{ {
@ -1132,8 +1160,7 @@ char * RSPLc2Name ( DWORD OpCode, DWORD PC )
command.del, command.del,
(command.voffset < 0) ? '-' : '+', (command.voffset < 0) ? '-' : '+',
abs(command.voffset), abs(command.voffset),
GPR_Name(command.base) GPR_Name(command.base));
);
} }
return CommandName; return CommandName;
} }
@ -1153,8 +1180,7 @@ char * RSPSc2Name ( DWORD OpCode, DWORD PC )
command.Ascii[3], command.Ascii[3],
command.Ascii[2], command.Ascii[2],
command.Ascii[1], command.Ascii[1],
command.Ascii[0] command.Ascii[0]);
);
} }
else else
{ {
@ -1166,8 +1192,7 @@ char * RSPSc2Name ( DWORD OpCode, DWORD PC )
command.del, command.del,
(command.voffset < 0) ? '-' : '+', (command.voffset < 0) ? '-' : '+',
abs(command.voffset), abs(command.voffset),
GPR_Name(command.base) GPR_Name(command.base));
);
} }
return CommandName; return CommandName;
} }
@ -1189,16 +1214,14 @@ char * RSPOpcodeName ( DWORD OpCode, DWORD PC )
case RSP_JAL: case RSP_JAL:
sprintf(CommandName, "%s\t0x%04X", sprintf(CommandName, "%s\t0x%04X",
mnemonics_primary[command.op], mnemonics_primary[command.op],
(command.target << 2) & 0x1FFC (command.target << 2) & 0x1FFC);
);
break; break;
case RSP_BEQ: case RSP_BEQ:
if (command.rs == 0 && command.rt == 0) if (command.rs == 0 && command.rt == 0)
{ {
sprintf(CommandName, "%s\t0x%04X", sprintf(CommandName, "%s\t0x%04X",
"B", "B",
(PC + ((short)command.offset << 2) + 4) & 0x1FFC (PC + ((short)command.offset << 2) + 4) & 0x1FFC);
);
break; break;
} }
else if (command.rs == 0 || command.rt == 0) else if (command.rs == 0 || command.rt == 0)
@ -1206,8 +1229,7 @@ char * RSPOpcodeName ( DWORD OpCode, DWORD PC )
sprintf(CommandName, "%s\t%s, 0x%04X", sprintf(CommandName, "%s\t%s, 0x%04X",
"BEQZ", "BEQZ",
GPR_Name(command.rs == 0 ? command.rt : command.rs), GPR_Name(command.rs == 0 ? command.rt : command.rs),
(PC + ((short)command.offset << 2) + 4) & 0x1FFC (PC + ((short)command.offset << 2) + 4) & 0x1FFC);
);
break; break;
} }
// TODO: add example code? // TODO: add example code?
@ -1217,16 +1239,14 @@ char * RSPOpcodeName ( DWORD OpCode, DWORD PC )
mnemonics_primary[command.op], mnemonics_primary[command.op],
GPR_Name(command.rs), GPR_Name(command.rs),
GPR_Name(command.rt), GPR_Name(command.rt),
(PC + ((short)command.offset << 2) + 4) & 0x1FFC (PC + ((short)command.offset << 2) + 4) & 0x1FFC);
);
break; break;
case RSP_BLEZ: case RSP_BLEZ:
case RSP_BGTZ: case RSP_BGTZ:
sprintf(CommandName, "%s\t%s, 0x%04X", sprintf(CommandName, "%s\t%s, 0x%04X",
mnemonics_primary[command.op], mnemonics_primary[command.op],
GPR_Name(command.rs), GPR_Name(command.rs),
(PC + ((short)command.offset << 2) + 4) & 0x1FFC (PC + ((short)command.offset << 2) + 4) & 0x1FFC);
);
break; break;
case RSP_ADDI: case RSP_ADDI:
case RSP_ADDIU: case RSP_ADDIU:
@ -1239,15 +1259,13 @@ char * RSPOpcodeName ( DWORD OpCode, DWORD PC )
mnemonics_primary[command.op], mnemonics_primary[command.op],
GPR_Name(command.rt), GPR_Name(command.rt),
GPR_Name(command.rs), GPR_Name(command.rs),
command.immediate command.immediate);
);
break; break;
case RSP_LUI: case RSP_LUI:
sprintf(CommandName, "%s\t%s, 0x%04X", sprintf(CommandName, "%s\t%s, 0x%04X",
mnemonics_primary[RSP_LUI], mnemonics_primary[RSP_LUI],
GPR_Name(command.rt), GPR_Name(command.rt),
command.immediate command.immediate);
);
break; break;
case RSP_CP0: case RSP_CP0:
return RSPCop0Name(OpCode, PC); return RSPCop0Name(OpCode, PC);
@ -1268,8 +1286,7 @@ char * RSPOpcodeName ( DWORD OpCode, DWORD PC )
GPR_Name(command.rt), GPR_Name(command.rt),
((int16_t)command.offset < 0) ? '-' : '+', ((int16_t)command.offset < 0) ? '-' : '+',
abs((int16_t)command.offset), abs((int16_t)command.offset),
GPR_Name(command.base) GPR_Name(command.base));
);
break; break;
case RSP_LC2: case RSP_LC2:
return RSPLc2Name(OpCode, PC); return RSPLc2Name(OpCode, PC);
@ -1282,8 +1299,7 @@ char * RSPOpcodeName ( DWORD OpCode, DWORD PC )
command.Ascii[3], command.Ascii[3],
command.Ascii[2], command.Ascii[2],
command.Ascii[1], command.Ascii[1],
command.Ascii[0] command.Ascii[0]);
);
} }
return CommandName; return CommandName;
} }
@ -1291,7 +1307,10 @@ char * RSPOpcodeName ( DWORD OpCode, DWORD PC )
void SetRSPCommandToRunning(void) void SetRSPCommandToRunning(void)
{ {
Stepping_Commands = FALSE; Stepping_Commands = FALSE;
if (InRSPCommandsWindow == FALSE) { return; } if (InRSPCommandsWindow == FALSE)
{
return;
}
EnableWindow(hGoButton, FALSE); EnableWindow(hGoButton, FALSE);
EnableWindow(hBreakButton, TRUE); EnableWindow(hBreakButton, TRUE);
EnableWindow(hStepButton, FALSE); EnableWindow(hStepButton, FALSE);
@ -1304,7 +1323,10 @@ void SetRSPCommandToRunning ( void )
void SetRSPCommandToStepping(void) void SetRSPCommandToStepping(void)
{ {
if (InRSPCommandsWindow == FALSE) { return; } if (InRSPCommandsWindow == FALSE)
{
return;
}
EnableWindow(hGoButton, TRUE); EnableWindow(hGoButton, TRUE);
EnableWindow(hBreakButton, FALSE); EnableWindow(hBreakButton, FALSE);
EnableWindow(hStepButton, TRUE); EnableWindow(hStepButton, TRUE);
@ -1321,7 +1343,10 @@ void SetRSPCommandViewto ( UINT NewLocation )
unsigned int location; unsigned int location;
char Value[20]; char Value[20];
if (InRSPCommandsWindow == FALSE) { return; } if (InRSPCommandsWindow == FALSE)
{
return;
}
GetWindowTextA(hAddress, Value, sizeof(Value)); GetWindowTextA(hAddress, Value, sizeof(Value));
location = AsciiToHex(Value) & ~3; location = AsciiToHex(Value) & ~3;

View File

@ -1,8 +1,9 @@
#include <windows.h> #include <windows.h>
#include <commctrl.h>
#include <stdio.h>
#include "Rsp.h" #include "Rsp.h"
#include "Types.h" #include "Types.h"
#include <commctrl.h>
#include <stdio.h>
#define GeneralPurpose 1 #define GeneralPurpose 1
#define ControlProcessor0 2 #define ControlProcessor0 2
@ -45,21 +46,28 @@ char * GPR_Strings[32] = {
"R0", "AT", "V0", "V1", "A0", "A1", "A2", "A3", "R0", "AT", "V0", "V1", "A0", "A1", "A2", "A3",
"T0", "T1", "T2", "T3", "T4", "T5", "T6", "T7", "T0", "T1", "T2", "T3", "T4", "T5", "T6", "T7",
"S0", "S1", "S2", "S3", "S4", "S5", "S6", "S7", "S0", "S1", "S2", "S3", "S4", "S5", "S6", "S7",
"T8", "T9", "K0", "K1", "GP", "SP", "S8", "RA" "T8", "T9", "K0", "K1", "GP", "SP", "S8", "RA"};
};
void Create_RSP_Register_Window ( int Child ) { void Create_RSP_Register_Window(int Child)
{
DWORD ThreadID; DWORD ThreadID;
if ( Child ) { if (Child)
{
InRSPRegisterWindow = TRUE; InRSPRegisterWindow = TRUE;
DialogBoxA((HINSTANCE)hinstDLL, "RSPREGISTERS", NULL, (DLGPROC)RSP_Registers_Proc); DialogBoxA((HINSTANCE)hinstDLL, "RSPREGISTERS", NULL, (DLGPROC)RSP_Registers_Proc);
InRSPRegisterWindow = FALSE; InRSPRegisterWindow = FALSE;
} else { }
if (!InRSPRegisterWindow) { else
{
if (!InRSPRegisterWindow)
{
CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE)Create_RSP_Register_Window, CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE)Create_RSP_Register_Window,
(LPVOID)TRUE, 0, &ThreadID); (LPVOID)TRUE, 0, &ThreadID);
} else { }
if (IsIconic((HWND)RSP_Registers_hDlg)) { else
{
if (IsIconic((HWND)RSP_Registers_hDlg))
{
SendMessage(RSP_Registers_hDlg, WM_SYSCOMMAND, SC_RESTORE, 0); SendMessage(RSP_Registers_hDlg, WM_SYSCOMMAND, SC_RESTORE, 0);
} }
SetForegroundWindow(RSP_Registers_hDlg); SetForegroundWindow(RSP_Registers_hDlg);
@ -67,58 +75,86 @@ void Create_RSP_Register_Window ( int Child ) {
} }
} }
void Enter_RSP_Register_Window ( void ) { void Enter_RSP_Register_Window(void)
{
Create_RSP_Register_Window(FALSE); Create_RSP_Register_Window(FALSE);
} }
void HideRSP_RegisterPanel ( int Panel) { void HideRSP_RegisterPanel(int Panel)
{
int count; int count;
switch( Panel ) { switch (Panel)
{
case GeneralPurpose: case GeneralPurpose:
for (count = 0; count < 32;count ++) { ShowWindow(hGPR[count], FALSE ); } for (count = 0; count < 32; count++)
{
ShowWindow(hGPR[count], FALSE);
}
break; break;
case ControlProcessor0: case ControlProcessor0:
for (count = 0; count < 16;count ++) { ShowWindow(hCP0[count], FALSE ); } for (count = 0; count < 16; count++)
{
ShowWindow(hCP0[count], FALSE);
}
break; break;
case HiddenRegisters: case HiddenRegisters:
for (count = 0; count < 12;count ++) { ShowWindow(hHIDDEN[count], FALSE ); } for (count = 0; count < 12; count++)
{
ShowWindow(hHIDDEN[count], FALSE);
}
break; break;
case Vector1: case Vector1:
for (count = 0; count < 16;count ++) { ShowWindow(hVECT1[count], FALSE ); } for (count = 0; count < 16; count++)
{
ShowWindow(hVECT1[count], FALSE);
}
break; break;
case Vector2: case Vector2:
for (count = 0; count < 16;count ++) { ShowWindow(hVECT2[count], FALSE ); } for (count = 0; count < 16; count++)
{
ShowWindow(hVECT2[count], FALSE);
}
break; break;
} }
} }
void InitilizeRSPRegisters (void) { void InitilizeRSPRegisters(void)
{
memset(RSP_GPR, 0, sizeof(RSP_GPR)); memset(RSP_GPR, 0, sizeof(RSP_GPR));
memset(RSP_Vect, 0, sizeof(RSP_Vect)); memset(RSP_Vect, 0, sizeof(RSP_Vect));
} }
void PaintRSP_HiddenPanel (HWND hWnd) { void PaintRSP_HiddenPanel(HWND hWnd)
{
PAINTSTRUCT ps; PAINTSTRUCT ps;
RECT rcBox; RECT rcBox;
HFONT hOldFont; HFONT hOldFont;
int OldBkMode; int OldBkMode;
BeginPaint(hWnd, &ps); BeginPaint(hWnd, &ps);
rcBox.left = 66; rcBox.top = 39; rcBox.left = 66;
rcBox.right = 320; rcBox.bottom = 265; rcBox.top = 39;
rcBox.right = 320;
rcBox.bottom = 265;
DrawEdge(ps.hdc, &rcBox, EDGE_ETCHED, BF_RECT); DrawEdge(ps.hdc, &rcBox, EDGE_ETCHED, BF_RECT);
rcBox.left = 350; rcBox.top = 39; rcBox.left = 350;
rcBox.right = 510; rcBox.bottom = 265; rcBox.top = 39;
rcBox.right = 510;
rcBox.bottom = 265;
DrawEdge(ps.hdc, &rcBox, EDGE_ETCHED, BF_RECT); DrawEdge(ps.hdc, &rcBox, EDGE_ETCHED, BF_RECT);
rcBox.left = 75; rcBox.top = 35; rcBox.left = 75;
rcBox.right = 150; rcBox.bottom = 50; rcBox.top = 35;
rcBox.right = 150;
rcBox.bottom = 50;
FillRect(ps.hdc, &rcBox, (HBRUSH)COLOR_WINDOW); FillRect(ps.hdc, &rcBox, (HBRUSH)COLOR_WINDOW);
rcBox.left = 365; rcBox.top = 35; rcBox.left = 365;
rcBox.right = 425; rcBox.bottom = 50; rcBox.top = 35;
rcBox.right = 425;
rcBox.bottom = 50;
FillRect(ps.hdc, &rcBox, (HBRUSH)COLOR_WINDOW); FillRect(ps.hdc, &rcBox, (HBRUSH)COLOR_WINDOW);
hOldFont = (HFONT)SelectObject(ps.hdc, hOldFont = (HFONT)SelectObject(ps.hdc,
@ -146,7 +182,8 @@ void PaintRSP_HiddenPanel (HWND hWnd) {
EndPaint(hWnd, &ps); EndPaint(hWnd, &ps);
} }
void PaintRSP_CP0Panel (HWND hWnd) { void PaintRSP_CP0Panel(HWND hWnd)
{
PAINTSTRUCT ps; PAINTSTRUCT ps;
RECT rcBox; RECT rcBox;
HFONT hOldFont; HFONT hOldFont;
@ -185,7 +222,8 @@ void PaintRSP_CP0Panel (HWND hWnd) {
EndPaint(hWnd, &ps); EndPaint(hWnd, &ps);
} }
void PaintRSP_GPRPanel (HWND hWnd) { void PaintRSP_GPRPanel(HWND hWnd)
{
PAINTSTRUCT ps; PAINTSTRUCT ps;
RECT rcBox; RECT rcBox;
HFONT hOldFont; HFONT hOldFont;
@ -240,7 +278,8 @@ void PaintRSP_GPRPanel (HWND hWnd) {
EndPaint(hWnd, &ps); EndPaint(hWnd, &ps);
} }
void PaintRSP_Vector1_Panel (HWND hWnd) { void PaintRSP_Vector1_Panel(HWND hWnd)
{
PAINTSTRUCT ps; PAINTSTRUCT ps;
RECT rcBox; RECT rcBox;
HFONT hOldFont; HFONT hOldFont;
@ -279,7 +318,8 @@ void PaintRSP_Vector1_Panel (HWND hWnd) {
EndPaint(hWnd, &ps); EndPaint(hWnd, &ps);
} }
void PaintRSP_Vector2_Panel (HWND hWnd) { void PaintRSP_Vector2_Panel(HWND hWnd)
{
PAINTSTRUCT ps; PAINTSTRUCT ps;
RECT rcBox; RECT rcBox;
HFONT hOldFont; HFONT hOldFont;
@ -318,17 +358,21 @@ void PaintRSP_Vector2_Panel (HWND hWnd) {
EndPaint(hWnd, &ps); EndPaint(hWnd, &ps);
} }
LRESULT CALLBACK RefreshRSP_RegProc ( HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam ) { LRESULT CALLBACK RefreshRSP_RegProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
int nSel; int nSel;
TC_ITEM item; TC_ITEM item;
switch( uMsg ) { switch (uMsg)
{
case WM_PAINT: case WM_PAINT:
nSel = TabCtrl_GetCurSel(hTab); nSel = TabCtrl_GetCurSel(hTab);
if ( nSel > -1 ) { if (nSel > -1)
{
item.mask = TCIF_PARAM; item.mask = TCIF_PARAM;
TabCtrl_GetItem(hTab, nSel, &item); TabCtrl_GetItem(hTab, nSel, &item);
switch( item.lParam ) { switch (item.lParam)
{
case GeneralPurpose: case GeneralPurpose:
PaintRSP_GPRPanel(hWnd); PaintRSP_GPRPanel(hWnd);
break; break;
@ -352,12 +396,14 @@ LRESULT CALLBACK RefreshRSP_RegProc ( HWND hWnd, UINT uMsg, WPARAM wParam, LPARA
return CallWindowProc(RefreshProc, hWnd, uMsg, wParam, lParam); return CallWindowProc(RefreshProc, hWnd, uMsg, wParam, lParam);
} }
LRESULT CALLBACK RSP_Registers_Proc (HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam) { LRESULT CALLBACK RSP_Registers_Proc(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
static RECT rcDisp; static RECT rcDisp;
static int CurrentPanel = GeneralPurpose; static int CurrentPanel = GeneralPurpose;
TC_ITEM item; TC_ITEM item;
switch (uMsg) { switch (uMsg)
{
case WM_INITDIALOG: case WM_INITDIALOG:
RSP_Registers_hDlg = hDlg; RSP_Registers_hDlg = hDlg;
SetupRSP_RegistersMain(hDlg); SetupRSP_RegistersMain(hDlg);
@ -370,7 +416,8 @@ LRESULT CALLBACK RSP_Registers_Proc (HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM
TabCtrl_AdjustRect(hTab, FALSE, &rcDisp); TabCtrl_AdjustRect(hTab, FALSE, &rcDisp);
break; break;
case WM_NOTIFY: case WM_NOTIFY:
switch (((NMHDR *)lParam)->code) { switch (((NMHDR *)lParam)->code)
{
case TCN_SELCHANGE: case TCN_SELCHANGE:
InvalidateRect(hTab, &rcDisp, TRUE); InvalidateRect(hTab, &rcDisp, TRUE);
HideRSP_RegisterPanel(CurrentPanel); HideRSP_RegisterPanel(CurrentPanel);
@ -384,7 +431,8 @@ LRESULT CALLBACK RSP_Registers_Proc (HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM
} }
break; break;
case WM_COMMAND: case WM_COMMAND:
switch (LOWORD(wParam)) { switch (LOWORD(wParam))
{
case IDCANCEL: case IDCANCEL:
CurrentPanel = GeneralPurpose; CurrentPanel = GeneralPurpose;
EndDialog(hDlg, IDCANCEL); EndDialog(hDlg, IDCANCEL);
@ -396,71 +444,76 @@ LRESULT CALLBACK RSP_Registers_Proc (HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM
return TRUE; return TRUE;
} }
void SetupRSP_HiddenPanel (HWND hDlg) { void SetupRSP_HiddenPanel(HWND hDlg)
{
int count; int count;
for (count = 0; count < 8;count ++) { for (count = 0; count < 8; count++)
hHIDDEN[count] = CreateWindowExA(WS_EX_CLIENTEDGE,"EDIT","", WS_CHILD | {
ES_READONLY | WS_BORDER | WS_TABSTOP,170,(count*25) + 60,140,19, hHIDDEN[count] = CreateWindowExA(WS_EX_CLIENTEDGE, "EDIT", "", WS_CHILD | ES_READONLY | WS_BORDER | WS_TABSTOP, 170, (count * 25) + 60, 140, 19,
hDlg, 0, (HINSTANCE)hinstDLL, NULL); hDlg, 0, (HINSTANCE)hinstDLL, NULL);
SendMessage(hHIDDEN[count], WM_SETFONT, (WPARAM)GetStockObject(DEFAULT_GUI_FONT), 0); SendMessage(hHIDDEN[count], WM_SETFONT, (WPARAM)GetStockObject(DEFAULT_GUI_FONT), 0);
} }
for (count = 0; count < 4;count ++) { for (count = 0; count < 4; count++)
hHIDDEN[count + 8] = CreateWindowExA(WS_EX_CLIENTEDGE,"EDIT","", WS_CHILD | {
ES_READONLY | WS_BORDER | WS_TABSTOP,425,(count*30) + 90,55,19, hHIDDEN[count + 8] = CreateWindowExA(WS_EX_CLIENTEDGE, "EDIT", "", WS_CHILD | ES_READONLY | WS_BORDER | WS_TABSTOP, 425, (count * 30) + 90, 55, 19,
hDlg, 0, (HINSTANCE)hinstDLL, NULL); hDlg, 0, (HINSTANCE)hinstDLL, NULL);
SendMessage(hHIDDEN[count + 8], WM_SETFONT, (WPARAM)GetStockObject(DEFAULT_GUI_FONT), 0); SendMessage(hHIDDEN[count + 8], WM_SETFONT, (WPARAM)GetStockObject(DEFAULT_GUI_FONT), 0);
} }
} }
void SetupRSP_CP0Panel (HWND hDlg) { void SetupRSP_CP0Panel(HWND hDlg)
{
int count; int count;
for (count = 0; count < 8;count ++) { for (count = 0; count < 8; count++)
hCP0[count] = CreateWindowExA(WS_EX_CLIENTEDGE,"EDIT","", WS_CHILD | {
ES_READONLY | WS_BORDER | WS_TABSTOP,225,(count*28) + 53,75,19, hCP0[count] = CreateWindowExA(WS_EX_CLIENTEDGE, "EDIT", "", WS_CHILD | ES_READONLY | WS_BORDER | WS_TABSTOP, 225, (count * 28) + 53, 75, 19,
hDlg, 0, (HINSTANCE)hinstDLL, NULL); hDlg, 0, (HINSTANCE)hinstDLL, NULL);
SendMessage(hCP0[count], WM_SETFONT, (WPARAM)GetStockObject(DEFAULT_GUI_FONT), 0); SendMessage(hCP0[count], WM_SETFONT, (WPARAM)GetStockObject(DEFAULT_GUI_FONT), 0);
} }
for (count = 0; count < 8;count ++) { for (count = 0; count < 8; count++)
hCP0[count + 8] = CreateWindowExA(WS_EX_CLIENTEDGE,"EDIT","", WS_CHILD | {
ES_READONLY | WS_BORDER | WS_TABSTOP,485,(count*28) + 53,75,19, hCP0[count + 8] = CreateWindowExA(WS_EX_CLIENTEDGE, "EDIT", "", WS_CHILD | ES_READONLY | WS_BORDER | WS_TABSTOP, 485, (count * 28) + 53, 75, 19,
hDlg, 0, (HINSTANCE)hinstDLL, NULL); hDlg, 0, (HINSTANCE)hinstDLL, NULL);
SendMessage(hCP0[count + 8], WM_SETFONT, (WPARAM)GetStockObject(DEFAULT_GUI_FONT), 0); SendMessage(hCP0[count + 8], WM_SETFONT, (WPARAM)GetStockObject(DEFAULT_GUI_FONT), 0);
} }
} }
void SetupRSP_GPRPanel (HWND hDlg) { void SetupRSP_GPRPanel(HWND hDlg)
{
int count; int count;
for (count = 0; count < 11;count ++) { for (count = 0; count < 11; count++)
hGPR[count] = CreateWindowExA(WS_EX_CLIENTEDGE,"EDIT","", WS_CHILD | {
ES_READONLY | WS_BORDER | WS_TABSTOP,135,(count*20) + 50,75,19, hGPR[count] = CreateWindowExA(WS_EX_CLIENTEDGE, "EDIT", "", WS_CHILD | ES_READONLY | WS_BORDER | WS_TABSTOP, 135, (count * 20) + 50, 75, 19,
hDlg, 0, (HINSTANCE)hinstDLL, NULL); hDlg, 0, (HINSTANCE)hinstDLL, NULL);
SendMessage(hGPR[count], WM_SETFONT, (WPARAM)GetStockObject(DEFAULT_GUI_FONT), 0); SendMessage(hGPR[count], WM_SETFONT, (WPARAM)GetStockObject(DEFAULT_GUI_FONT), 0);
} }
for (count = 0; count < 11;count ++) { for (count = 0; count < 11; count++)
hGPR[count + 11] = CreateWindowExA(WS_EX_CLIENTEDGE,"EDIT","", WS_CHILD | {
ES_READONLY | WS_BORDER | WS_TABSTOP,315,(count*20) + 50,75,19, hGPR[count + 11] = CreateWindowExA(WS_EX_CLIENTEDGE, "EDIT", "", WS_CHILD | ES_READONLY | WS_BORDER | WS_TABSTOP, 315, (count * 20) + 50, 75, 19,
hDlg, 0, (HINSTANCE)hinstDLL, NULL); hDlg, 0, (HINSTANCE)hinstDLL, NULL);
SendMessage(hGPR[count + 11], WM_SETFONT, (WPARAM)GetStockObject(DEFAULT_GUI_FONT), 0); SendMessage(hGPR[count + 11], WM_SETFONT, (WPARAM)GetStockObject(DEFAULT_GUI_FONT), 0);
} }
for (count = 0; count < 10;count ++) { for (count = 0; count < 10; count++)
hGPR[count + 22] = CreateWindowExA(WS_EX_CLIENTEDGE,"EDIT","", WS_CHILD | {
ES_READONLY | WS_BORDER | WS_TABSTOP,485,(count*20) + 50,75,19, hGPR[count + 22] = CreateWindowExA(WS_EX_CLIENTEDGE, "EDIT", "", WS_CHILD | ES_READONLY | WS_BORDER | WS_TABSTOP, 485, (count * 20) + 50, 75, 19,
hDlg, 0, (HINSTANCE)hinstDLL, NULL); hDlg, 0, (HINSTANCE)hinstDLL, NULL);
SendMessage(hGPR[count + 22], WM_SETFONT, (WPARAM)GetStockObject(DEFAULT_GUI_FONT), 0); SendMessage(hGPR[count + 22], WM_SETFONT, (WPARAM)GetStockObject(DEFAULT_GUI_FONT), 0);
} }
} }
void SetupRSP_RegistersMain (HWND hDlg) { void SetupRSP_RegistersMain(HWND hDlg)
{
#define WindowWidth 630 #define WindowWidth 630
#define WindowHeight 325 #define WindowHeight 325
DWORD X, Y; DWORD X, Y;
hTab = CreateWindowExA(0, WC_TABCONTROLA, "", WS_TABSTOP | WS_CHILD | WS_VISIBLE, 5, 6, 616, 290, hTab = CreateWindowExA(0, WC_TABCONTROLA, "", WS_TABSTOP | WS_CHILD | WS_VISIBLE, 5, 6, 616, 290,
hDlg, (HMENU)IDC_TAB_CONTROL, (HINSTANCE)hinstDLL, NULL); hDlg, (HMENU)IDC_TAB_CONTROL, (HINSTANCE)hinstDLL, NULL);
if ( hTab ) { if (hTab)
{
TC_ITEMA item; TC_ITEMA item;
SendMessage(hTab, WM_SETFONT, (WPARAM)GetStockObject(DEFAULT_GUI_FONT), 0); SendMessage(hTab, WM_SETFONT, (WPARAM)GetStockObject(DEFAULT_GUI_FONT), 0);
item.mask = TCIF_TEXT | TCIF_PARAM; item.mask = TCIF_TEXT | TCIF_PARAM;
@ -505,75 +558,101 @@ void SetupRSP_RegistersMain (HWND hDlg) {
SetWindowPos(hDlg, NULL, X, Y, WindowWidth, WindowHeight, SWP_NOZORDER | SWP_SHOWWINDOW); SetWindowPos(hDlg, NULL, X, Y, WindowWidth, WindowHeight, SWP_NOZORDER | SWP_SHOWWINDOW);
} }
void SetupRSP_Vect1Panel (HWND hDlg) { void SetupRSP_Vect1Panel(HWND hDlg)
{
int count; int count;
for (count = 0; count < 8;count ++) { for (count = 0; count < 8; count++)
hVECT1[count] = CreateWindowExA(WS_EX_CLIENTEDGE,"EDIT","", WS_CHILD | {
ES_READONLY | WS_BORDER | WS_TABSTOP,55,(count*28) + 52,254,19, hVECT1[count] = CreateWindowExA(WS_EX_CLIENTEDGE, "EDIT", "", WS_CHILD | ES_READONLY | WS_BORDER | WS_TABSTOP, 55, (count * 28) + 52, 254, 19,
hDlg, 0, (HINSTANCE)hinstDLL, NULL); hDlg, 0, (HINSTANCE)hinstDLL, NULL);
SendMessage(hVECT1[count], WM_SETFONT, (WPARAM)GetStockObject(DEFAULT_GUI_FONT), 0); SendMessage(hVECT1[count], WM_SETFONT, (WPARAM)GetStockObject(DEFAULT_GUI_FONT), 0);
} }
for (count = 0; count < 8;count ++) { for (count = 0; count < 8; count++)
hVECT1[count + 8] = CreateWindowExA(WS_EX_CLIENTEDGE,"EDIT","", WS_CHILD | {
ES_READONLY | WS_BORDER | WS_TABSTOP,345,(count*28) + 52,254,19, hVECT1[count + 8] = CreateWindowExA(WS_EX_CLIENTEDGE, "EDIT", "", WS_CHILD | ES_READONLY | WS_BORDER | WS_TABSTOP, 345, (count * 28) + 52, 254, 19,
hDlg, 0, (HINSTANCE)hinstDLL, NULL); hDlg, 0, (HINSTANCE)hinstDLL, NULL);
SendMessage(hVECT1[count + 8], WM_SETFONT, (WPARAM)GetStockObject(DEFAULT_GUI_FONT), 0); SendMessage(hVECT1[count + 8], WM_SETFONT, (WPARAM)GetStockObject(DEFAULT_GUI_FONT), 0);
} }
} }
void SetupRSP_Vect2Panel (HWND hDlg) { void SetupRSP_Vect2Panel(HWND hDlg)
{
int count; int count;
for (count = 0; count < 8;count ++) { for (count = 0; count < 8; count++)
hVECT2[count] = CreateWindowExA(WS_EX_CLIENTEDGE,"EDIT","", WS_CHILD | {
ES_READONLY | WS_BORDER | WS_TABSTOP,55,(count*28) + 52,254,19, hVECT2[count] = CreateWindowExA(WS_EX_CLIENTEDGE, "EDIT", "", WS_CHILD | ES_READONLY | WS_BORDER | WS_TABSTOP, 55, (count * 28) + 52, 254, 19,
hDlg, 0, (HINSTANCE)hinstDLL, NULL); hDlg, 0, (HINSTANCE)hinstDLL, NULL);
SendMessage(hVECT2[count], WM_SETFONT, (WPARAM)GetStockObject(DEFAULT_GUI_FONT), 0); SendMessage(hVECT2[count], WM_SETFONT, (WPARAM)GetStockObject(DEFAULT_GUI_FONT), 0);
} }
for (count = 0; count < 8;count ++) { for (count = 0; count < 8; count++)
hVECT2[count + 8] = CreateWindowExA(WS_EX_CLIENTEDGE,"EDIT","", WS_CHILD | {
ES_READONLY | WS_BORDER | WS_TABSTOP,345,(count*28) + 52,254,19, hVECT2[count + 8] = CreateWindowExA(WS_EX_CLIENTEDGE, "EDIT", "", WS_CHILD | ES_READONLY | WS_BORDER | WS_TABSTOP, 345, (count * 28) + 52, 254, 19,
hDlg, 0, (HINSTANCE)hinstDLL, NULL); hDlg, 0, (HINSTANCE)hinstDLL, NULL);
SendMessage(hVECT2[count + 8], WM_SETFONT, (WPARAM)GetStockObject(DEFAULT_GUI_FONT), 0); SendMessage(hVECT2[count + 8], WM_SETFONT, (WPARAM)GetStockObject(DEFAULT_GUI_FONT), 0);
} }
} }
void ShowRSP_RegisterPanel ( int Panel) { void ShowRSP_RegisterPanel(int Panel)
{
int count; int count;
switch( Panel ) { switch (Panel)
{
case GeneralPurpose: case GeneralPurpose:
for (count = 0; count < 32;count ++) { ShowWindow(hGPR[count], TRUE ); } for (count = 0; count < 32; count++)
{
ShowWindow(hGPR[count], TRUE);
}
break; break;
case ControlProcessor0: case ControlProcessor0:
for (count = 0; count < 16;count ++) { ShowWindow(hCP0[count], TRUE ); } for (count = 0; count < 16; count++)
{
ShowWindow(hCP0[count], TRUE);
}
break; break;
case HiddenRegisters: case HiddenRegisters:
for (count = 0; count < 12;count ++) { ShowWindow(hHIDDEN[count], TRUE ); } for (count = 0; count < 12; count++)
{
ShowWindow(hHIDDEN[count], TRUE);
}
break; break;
case Vector1: case Vector1:
for (count = 0; count < 16;count ++) { ShowWindow(hVECT1[count], TRUE ); } for (count = 0; count < 16; count++)
{
ShowWindow(hVECT1[count], TRUE);
}
break; break;
case Vector2: case Vector2:
for (count = 0; count < 16;count ++) { ShowWindow(hVECT2[count], TRUE ); } for (count = 0; count < 16; count++)
{
ShowWindow(hVECT2[count], TRUE);
}
break; break;
} }
} }
void UpdateRSPRegistersScreen ( void ) { void UpdateRSPRegistersScreen(void)
{
char RegisterValue[100]; char RegisterValue[100];
int count, nSel; int count, nSel;
TC_ITEM item; TC_ITEM item;
if (!InRSPRegisterWindow) { return; } if (!InRSPRegisterWindow)
{
return;
}
nSel = TabCtrl_GetCurSel(hTab); nSel = TabCtrl_GetCurSel(hTab);
if ( nSel > -1 ) { if (nSel > -1)
{
item.mask = TCIF_PARAM; item.mask = TCIF_PARAM;
TabCtrl_GetItem(hTab, nSel, &item); TabCtrl_GetItem(hTab, nSel, &item);
switch( item.lParam ) { switch (item.lParam)
{
case GeneralPurpose: case GeneralPurpose:
for (count = 0; count < 32;count ++) { for (count = 0; count < 32; count++)
{
sprintf(RegisterValue, " 0x%08X", RSP_GPR[count].UW); sprintf(RegisterValue, " 0x%08X", RSP_GPR[count].UW);
SetWindowTextA(hGPR[count], RegisterValue); SetWindowTextA(hGPR[count], RegisterValue);
} }
@ -616,11 +695,13 @@ void UpdateRSPRegistersScreen ( void ) {
} }
break; break;
case HiddenRegisters: case HiddenRegisters:
for (count = 0; count < 8;count ++) { for (count = 0; count < 8; count++)
{
sprintf(RegisterValue, " 0x%08X - %08X", RSP_ACCUM[count].W[1], RSP_ACCUM[count].W[0]); sprintf(RegisterValue, " 0x%08X - %08X", RSP_ACCUM[count].W[1], RSP_ACCUM[count].W[0]);
SetWindowTextA(hHIDDEN[count], RegisterValue); SetWindowTextA(hHIDDEN[count], RegisterValue);
} }
for (count = 0; count < 3;count ++) { for (count = 0; count < 3; count++)
{
sprintf(RegisterValue, " 0x%04X", RSP_Flags[count].UHW[0]); sprintf(RegisterValue, " 0x%04X", RSP_Flags[count].UHW[0]);
SetWindowTextA(hHIDDEN[count + 8], RegisterValue); SetWindowTextA(hHIDDEN[count + 8], RegisterValue);
} }
@ -628,14 +709,16 @@ void UpdateRSPRegistersScreen ( void ) {
SetWindowTextA(hHIDDEN[11], RegisterValue); SetWindowTextA(hHIDDEN[11], RegisterValue);
break; break;
case Vector1: case Vector1:
for (count = 0; count < 16;count ++) { for (count = 0; count < 16; count++)
{
sprintf(RegisterValue, " 0x%08X - %08X - %08X - %08X", RSP_Vect[count].W[3], sprintf(RegisterValue, " 0x%08X - %08X - %08X - %08X", RSP_Vect[count].W[3],
RSP_Vect[count].W[2], RSP_Vect[count].W[1], RSP_Vect[count].W[0]); RSP_Vect[count].W[2], RSP_Vect[count].W[1], RSP_Vect[count].W[0]);
SetWindowTextA(hVECT1[count], RegisterValue); SetWindowTextA(hVECT1[count], RegisterValue);
} }
break; break;
case Vector2: case Vector2:
for (count = 0; count < 16;count ++) { for (count = 0; count < 16; count++)
{
sprintf(RegisterValue, " 0x%08X - %08X - %08X - %08X", RSP_Vect[count + 16].W[3], sprintf(RegisterValue, " 0x%08X - %08X - %08X - %08X", RSP_Vect[count + 16].W[3],
RSP_Vect[count + 16].W[2], RSP_Vect[count + 16].W[1], RSP_Vect[count + 16].W[0]); RSP_Vect[count + 16].W[2], RSP_Vect[count + 16].W[1], RSP_Vect[count + 16].W[0]);
SetWindowTextA(hVECT2[count], RegisterValue); SetWindowTextA(hVECT2[count], RegisterValue);

View File

@ -87,31 +87,40 @@ extern char * GPR_Strings[32];
*/ */
#define COP0_Name(Reg) \ #define COP0_Name(Reg) \
(Reg) == 0 ? "SP memory address" :\ (Reg) == 0 ? "SP memory address" : (Reg) == 1 ? "SP DRAM DMA address" \
(Reg) == 1 ? "SP DRAM DMA address" :\ : (Reg) == 2 ? "SP read DMA length" \
(Reg) == 2 ? "SP read DMA length" :\ : (Reg) == 3 ? "SP write DMA length" \
(Reg) == 3 ? "SP write DMA length" :\ : (Reg) == 4 ? "SP status" \
(Reg) == 4 ? "SP status" :\ : (Reg) == 5 ? "SP DMA full" \
(Reg) == 5 ? "SP DMA full" :\ : (Reg) == 6 ? "SP DMA busy" \
(Reg) == 6 ? "SP DMA busy" :\ : (Reg) == 7 ? "SP semaphore" \
(Reg) == 7 ? "SP semaphore" :\ : (Reg) == 8 ? "DP CMD DMA start" \
(Reg) == 8 ? "DP CMD DMA start" :\ : (Reg) == 9 ? "DP CMD DMA end" \
(Reg) == 9 ? "DP CMD DMA end" :\ : (Reg) == 10 ? "DP CMD DMA current" \
(Reg) == 10 ? "DP CMD DMA current" :\ : (Reg) == 11 ? "DP CMD status" \
(Reg) == 11 ? "DP CMD status" :\ : (Reg) == 12 ? "DP clock counter" \
(Reg) == 12 ? "DP clock counter" :\ : (Reg) == 13 ? "DP buffer busy counter" \
(Reg) == 13 ? "DP buffer busy counter" :\ : (Reg) == 14 ? "DP pipe busy counter" \
(Reg) == 14 ? "DP pipe busy counter" :\ : (Reg) == 15 ? "DP TMEM load counter" \
(Reg) == 15 ? "DP TMEM load counter" :\ : "Unknown Register"
"Unknown Register"
#define ElementSpecifier(Elem) \ #define ElementSpecifier(Elem) \
(Elem) == 0 ? "" : (Elem) == 1 ? "" : (Elem) == 2 ? " [0q]" :\ (Elem) == 0 ? "" : (Elem) == 1 ? "" \
(Elem) == 3 ? " [1q]" : (Elem) == 4 ? " [0h]" : (Elem) == 5 ? " [1h]" :\ : (Elem) == 2 ? " [0q]" \
(Elem) == 6 ? " [2h]" : (Elem) == 7 ? " [3h]" : (Elem) == 8 ? " [0]" :\ : (Elem) == 3 ? " [1q]" \
(Elem) == 9 ? " [1]" : (Elem) == 10 ? " [2]" : (Elem) == 11 ? " [3]" :\ : (Elem) == 4 ? " [0h]" \
(Elem) == 12 ? " [4]" : (Elem) == 13 ? " [5]" : (Elem) == 14 ? " [6]" :\ : (Elem) == 5 ? " [1h]" \
(Elem) == 15 ? " [7]" : "Unknown Element" : (Elem) == 6 ? " [2h]" \
: (Elem) == 7 ? " [3h]" \
: (Elem) == 8 ? " [0]" \
: (Elem) == 9 ? " [1]" \
: (Elem) == 10 ? " [2]" \
: (Elem) == 11 ? " [3]" \
: (Elem) == 12 ? " [4]" \
: (Elem) == 13 ? " [5]" \
: (Elem) == 14 ? " [6]" \
: (Elem) == 15 ? " [7]" \
: "Unknown Element"
void Enter_RSP_Register_Window(void); void Enter_RSP_Register_Window(void);
void InitilizeRSPRegisters(void); void InitilizeRSPRegisters(void);

File diff suppressed because it is too large Load Diff

View File

@ -1,21 +1,21 @@
#include <windows.h>
#include <stdio.h>
#include <float.h> #include <float.h>
#include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include <windows.h>
#include "Rsp.h"
#include "Cpu.h" #include "Cpu.h"
#include "Interpreter CPU.h" #include "Interpreter CPU.h"
#include "Profiling.h"
#include "RSP Command.h"
#include "RSP registers.h"
#include "Recompiler CPU.h" #include "Recompiler CPU.h"
#include "Recompiler Ops.h" #include "Recompiler Ops.h"
#include "RSP registers.h" #include "Rsp.h"
#include "RSP Command.h" #include "Types.h"
#include "log.h"
#include "memory.h" #include "memory.h"
#include "opcode.h" #include "opcode.h"
#include "log.h"
#include "Profiling.h"
#include "x86.h" #include "x86.h"
#include "Types.h"
#pragma warning(disable : 4152) // Non-standard extension, function/data pointer conversion in expression #pragma warning(disable : 4152) // Non-standard extension, function/data pointer conversion in expression
@ -33,7 +33,8 @@ RSP_CODE RspCode;
BYTE *pLastSecondary = NULL, *pLastPrimary = NULL; BYTE *pLastSecondary = NULL, *pLastPrimary = NULL;
void BuildRecompilerCPU ( void ) { void BuildRecompilerCPU(void)
{
RSP_Opcode[0] = Compile_SPECIAL; RSP_Opcode[0] = Compile_SPECIAL;
RSP_Opcode[1] = Compile_REGIMM; RSP_Opcode[1] = Compile_REGIMM;
RSP_Opcode[2] = Compile_J; RSP_Opcode[2] = Compile_J;
@ -409,45 +410,61 @@ between branches labels, and actual branches, whichever
occurs first in code occurs first in code
*/ */
void ReOrderInstructions(DWORD StartPC, DWORD EndPC) { void ReOrderInstructions(DWORD StartPC, DWORD EndPC)
{
DWORD InstructionCount = EndPC - StartPC; DWORD InstructionCount = EndPC - StartPC;
DWORD Count, ReorderedOps, CurrentPC; DWORD Count, ReorderedOps, CurrentPC;
OPCODE PreviousOp, CurrentOp, RspOp; OPCODE PreviousOp, CurrentOp, RspOp;
PreviousOp.Hex = *(DWORD *)(RSPInfo.IMEM + StartPC); PreviousOp.Hex = *(DWORD *)(RSPInfo.IMEM + StartPC);
if (TRUE == IsOpcodeBranch(StartPC, PreviousOp)) { if (TRUE == IsOpcodeBranch(StartPC, PreviousOp))
{
// The sub block ends here anyway // The sub block ends here anyway
return; return;
} }
if (IsOpcodeNop(StartPC) && IsOpcodeNop(StartPC + 4) && IsOpcodeNop(StartPC + 8)) { if (IsOpcodeNop(StartPC) && IsOpcodeNop(StartPC + 4) && IsOpcodeNop(StartPC + 8))
{
// Don't even bother // Don't even bother
return; return;
} }
CPU_Message("***** Doing reorder (%X to %X) *****", StartPC, EndPC); CPU_Message("***** Doing reorder (%X to %X) *****", StartPC, EndPC);
if (InstructionCount < 0x0010) { return; } if (InstructionCount < 0x0010)
if (InstructionCount > 0x0A00) { return; } {
return;
}
if (InstructionCount > 0x0A00)
{
return;
}
CPU_Message(" Before:"); CPU_Message(" Before:");
for (Count = StartPC; Count < EndPC; Count += 4) { for (Count = StartPC; Count < EndPC; Count += 4)
{
RSP_LW_IMEM(Count, &RspOp.Hex); RSP_LW_IMEM(Count, &RspOp.Hex);
CPU_Message(" %X %s", Count, RSPOpcodeName(RspOp.Hex, Count)); CPU_Message(" %X %s", Count, RSPOpcodeName(RspOp.Hex, Count));
} }
for (Count = 0; Count < InstructionCount; Count += 4) { for (Count = 0; Count < InstructionCount; Count += 4)
{
CurrentPC = StartPC; CurrentPC = StartPC;
PreviousOp.Hex = *(DWORD *)(RSPInfo.IMEM + CurrentPC); PreviousOp.Hex = *(DWORD *)(RSPInfo.IMEM + CurrentPC);
ReorderedOps = 0; ReorderedOps = 0;
for (;;) { for (;;)
{
CurrentPC += 4; CurrentPC += 4;
if (CurrentPC >= EndPC) { break; } if (CurrentPC >= EndPC)
{
break;
}
CurrentOp.Hex = *(DWORD *)(RSPInfo.IMEM + CurrentPC); CurrentOp.Hex = *(DWORD *)(RSPInfo.IMEM + CurrentPC);
if (TRUE == CompareInstructions(CurrentPC, &PreviousOp, &CurrentOp)) { if (TRUE == CompareInstructions(CurrentPC, &PreviousOp, &CurrentOp))
{
// Move current opcode up // Move current opcode up
*(DWORD *)(RSPInfo.IMEM + CurrentPC - 4) = CurrentOp.Hex; *(DWORD *)(RSPInfo.IMEM + CurrentPC - 4) = CurrentOp.Hex;
*(DWORD *)(RSPInfo.IMEM + CurrentPC) = PreviousOp.Hex; *(DWORD *)(RSPInfo.IMEM + CurrentPC) = PreviousOp.Hex;
@ -460,46 +477,58 @@ void ReOrderInstructions(DWORD StartPC, DWORD EndPC) {
} }
PreviousOp.Hex = *(DWORD *)(RSPInfo.IMEM + CurrentPC); PreviousOp.Hex = *(DWORD *)(RSPInfo.IMEM + CurrentPC);
if (IsOpcodeNop(CurrentPC) && IsOpcodeNop(CurrentPC + 4) && IsOpcodeNop(CurrentPC + 8)) { if (IsOpcodeNop(CurrentPC) && IsOpcodeNop(CurrentPC + 4) && IsOpcodeNop(CurrentPC + 8))
{
CurrentPC = EndPC; CurrentPC = EndPC;
} }
} }
if (ReorderedOps == 0) { if (ReorderedOps == 0)
{
Count = InstructionCount; Count = InstructionCount;
} }
} }
CPU_Message(" After:"); CPU_Message(" After:");
for (Count = StartPC; Count < EndPC; Count += 4) { for (Count = StartPC; Count < EndPC; Count += 4)
{
RSP_LW_IMEM(Count, &RspOp.Hex); RSP_LW_IMEM(Count, &RspOp.Hex);
CPU_Message(" %X %s", Count, RSPOpcodeName(RspOp.Hex, Count)); CPU_Message(" %X %s", Count, RSPOpcodeName(RspOp.Hex, Count));
} }
CPU_Message(""); CPU_Message("");
} }
void ReOrderSubBlock(RSP_BLOCK * Block) { void ReOrderSubBlock(RSP_BLOCK * Block)
{
DWORD end = 0x0ffc; DWORD end = 0x0ffc;
DWORD count; DWORD count;
if (!Compiler.bReOrdering) { if (!Compiler.bReOrdering)
{
return; return;
} }
if (Block->CurrPC > 0xFF0) { if (Block->CurrPC > 0xFF0)
{
return; return;
} }
// Find the label or jump closest to us // Find the label or jump closest to us
if (RspCode.LabelCount) { if (RspCode.LabelCount)
for (count = 0; count < RspCode.LabelCount; count++) { {
if (RspCode.BranchLabels[count] < end && RspCode.BranchLabels[count] > Block->CurrPC) { for (count = 0; count < RspCode.LabelCount; count++)
{
if (RspCode.BranchLabels[count] < end && RspCode.BranchLabels[count] > Block->CurrPC)
{
end = RspCode.BranchLabels[count]; end = RspCode.BranchLabels[count];
} }
} }
} }
if (RspCode.BranchCount) { if (RspCode.BranchCount)
for (count = 0; count < RspCode.BranchCount; count++) { {
if (RspCode.BranchLocations[count] < end && RspCode.BranchLocations[count] > Block->CurrPC) { for (count = 0; count < RspCode.BranchCount; count++)
{
if (RspCode.BranchLocations[count] < end && RspCode.BranchLocations[count] > Block->CurrPC)
{
end = RspCode.BranchLocations[count]; end = RspCode.BranchLocations[count];
} }
} }
@ -515,13 +544,15 @@ This needs to be called on a sub-block basis, like
after every time we hit a branch and delay slot after every time we hit a branch and delay slot
*/ */
void DetectGPRConstants(RSP_CODE * code) { void DetectGPRConstants(RSP_CODE * code)
{
DWORD Count, Constant = 0; DWORD Count, Constant = 0;
memset(&code->bIsRegConst, 0, sizeof(Boolean) * 0x20); memset(&code->bIsRegConst, 0, sizeof(Boolean) * 0x20);
memset(&code->MipsRegConst, 0, sizeof(DWORD) * 0x20); memset(&code->MipsRegConst, 0, sizeof(DWORD) * 0x20);
if (!Compiler.bGPRConstants) { if (!Compiler.bGPRConstants)
{
return; return;
} }
CPU_Message("***** Detecting constants *****"); CPU_Message("***** Detecting constants *****");
@ -531,8 +562,10 @@ void DetectGPRConstants(RSP_CODE * code) {
code->MipsRegConst[0] = 0; code->MipsRegConst[0] = 0;
// Do your global search for them // Do your global search for them
for (Count = 1; Count < 31; Count++) { for (Count = 1; Count < 31; Count++)
if (IsRegisterConstant(Count, &Constant) == TRUE) { {
if (IsRegisterConstant(Count, &Constant) == TRUE)
{
CPU_Message("Global: %s is a constant of: %08X", GPR_Name(Count), Constant); CPU_Message("Global: %s is a constant of: %08X", GPR_Name(Count), Constant);
code->bIsRegConst[Count] = TRUE; code->bIsRegConst[Count] = TRUE;
code->MipsRegConst[Count] = Constant; code->MipsRegConst[Count] = Constant;
@ -549,22 +582,28 @@ taken branches like alignment
2: Clears all the x86 code, jump tables etc. 2: Clears all the x86 code, jump tables etc.
*/ */
void CompilerToggleBuffer(void) { void CompilerToggleBuffer(void)
if (dwBuffer == MainBuffer) { {
if (dwBuffer == MainBuffer)
{
dwBuffer = SecondaryBuffer; dwBuffer = SecondaryBuffer;
pLastPrimary = RecompPos; pLastPrimary = RecompPos;
if (pLastSecondary == NULL) { if (pLastSecondary == NULL)
{
pLastSecondary = RecompCodeSecondary; pLastSecondary = RecompCodeSecondary;
} }
RecompPos = pLastSecondary; RecompPos = pLastSecondary;
CPU_Message(" (Secondary buffer active 0x%08X)", pLastSecondary); CPU_Message(" (Secondary buffer active 0x%08X)", pLastSecondary);
} else { }
else
{
dwBuffer = MainBuffer; dwBuffer = MainBuffer;
pLastSecondary = RecompPos; pLastSecondary = RecompPos;
if (pLastPrimary == NULL) { if (pLastPrimary == NULL)
{
pLastPrimary = RecompCode; pLastPrimary = RecompCode;
} }
@ -573,7 +612,8 @@ void CompilerToggleBuffer(void) {
} }
} }
void ClearAllx86Code (void) { void ClearAllx86Code(void)
{
extern DWORD NoOfMaps, MapsCRC[32]; extern DWORD NoOfMaps, MapsCRC[32];
extern BYTE * JumpTables; extern BYTE * JumpTables;
@ -593,23 +633,27 @@ Description:
Resolves all the collected branches, x86 style Resolves all the collected branches, x86 style
*/ */
void LinkBranches(RSP_BLOCK * Block) { void LinkBranches(RSP_BLOCK * Block)
{
DWORD OrigPrgCount = *PrgCount; DWORD OrigPrgCount = *PrgCount;
DWORD Count, Target; DWORD Count, Target;
DWORD * JumpWord; DWORD * JumpWord;
BYTE * X86Code; BYTE * X86Code;
RSP_BLOCK Save; RSP_BLOCK Save;
if (!CurrentBlock.ResolveCount) { if (!CurrentBlock.ResolveCount)
{
return; return;
} }
CPU_Message("***** Linking branches (%i) *****", CurrentBlock.ResolveCount); CPU_Message("***** Linking branches (%i) *****", CurrentBlock.ResolveCount);
for (Count = 0; Count < CurrentBlock.ResolveCount; Count++) { for (Count = 0; Count < CurrentBlock.ResolveCount; Count++)
{
Target = CurrentBlock.BranchesToResolve[Count].TargetPC; Target = CurrentBlock.BranchesToResolve[Count].TargetPC;
X86Code = (BYTE *)*(JumpTable + (Target >> 2)); X86Code = (BYTE *)*(JumpTable + (Target >> 2));
if (!X86Code) { if (!X86Code)
{
*PrgCount = Target; *PrgCount = Target;
CPU_Message(""); CPU_Message("");
CPU_Message("===== (Generate code: %04X) =====", Target); CPU_Message("===== (Generate code: %04X) =====", Target);
@ -644,7 +688,8 @@ sections as well as set the jump table to points
within a block that are safe. within a block that are safe.
*/ */
void BuildBranchLabels(void) { void BuildBranchLabels(void)
{
OPCODE RspOp; OPCODE RspOp;
DWORD i, Dest; DWORD i, Dest;
@ -652,23 +697,30 @@ void BuildBranchLabels(void) {
CPU_Message("***** Building branch labels *****"); CPU_Message("***** Building branch labels *****");
#endif #endif
for (i = 0; i < 0x1000; i += 4) { for (i = 0; i < 0x1000; i += 4)
{
RspOp.Hex = *(DWORD *)(RSPInfo.IMEM + i); RspOp.Hex = *(DWORD *)(RSPInfo.IMEM + i);
if (TRUE == IsOpcodeBranch(i, RspOp)) { if (TRUE == IsOpcodeBranch(i, RspOp))
if (RspCode.LabelCount >= (sizeof(RspCode.BranchLabels) / sizeof(RspCode.BranchLabels[0])) - 1) { {
if (RspCode.LabelCount >= (sizeof(RspCode.BranchLabels) / sizeof(RspCode.BranchLabels[0])) - 1)
{
CompilerWarning("Out of space for branch labels"); CompilerWarning("Out of space for branch labels");
return; return;
} }
if (RspCode.BranchCount >= (sizeof(RspCode.BranchLocations) / sizeof(RspCode.BranchLocations[0])) - 1) { if (RspCode.BranchCount >= (sizeof(RspCode.BranchLocations) / sizeof(RspCode.BranchLocations[0])) - 1)
{
CompilerWarning("Out of space for branch locations"); CompilerWarning("Out of space for branch locations");
return; return;
} }
RspCode.BranchLocations[RspCode.BranchCount++] = i; RspCode.BranchLocations[RspCode.BranchCount++] = i;
if (RspOp.op == RSP_SPECIAL) { if (RspOp.op == RSP_SPECIAL)
{
// Register jump not predictable // Register jump not predictable
} else if (RspOp.op == RSP_J || RspOp.op == RSP_JAL) { }
else if (RspOp.op == RSP_J || RspOp.op == RSP_JAL)
{
// For JAL its a sub-block for returns // For JAL its a sub-block for returns
Dest = (RspOp.target << 2) & 0xFFC; Dest = (RspOp.target << 2) & 0xFFC;
RspCode.BranchLabels[RspCode.LabelCount] = Dest; RspCode.BranchLabels[RspCode.LabelCount] = Dest;
@ -676,7 +728,9 @@ void BuildBranchLabels(void) {
#ifdef BUILD_BRANCHLABELS_VERBOSE #ifdef BUILD_BRANCHLABELS_VERBOSE
CPU_Message("[%02i] Added branch at %X to %X", RspCode.LabelCount, i, Dest); CPU_Message("[%02i] Added branch at %X to %X", RspCode.LabelCount, i, Dest);
#endif #endif
} else { }
else
{
Dest = (i + ((short)RspOp.offset << 2) + 4) & 0xFFC; Dest = (i + ((short)RspOp.offset << 2) + 4) & 0xFFC;
RspCode.BranchLabels[RspCode.LabelCount] = Dest; RspCode.BranchLabels[RspCode.LabelCount] = Dest;
RspCode.LabelCount += 1; RspCode.LabelCount += 1;
@ -697,19 +751,23 @@ Boolean IsJumpLabel(DWORD PC)
{ {
DWORD Count; DWORD Count;
if (!RspCode.LabelCount) { if (!RspCode.LabelCount)
{
return FALSE; return FALSE;
} }
for (Count = 0; Count < RspCode.LabelCount; Count++) { for (Count = 0; Count < RspCode.LabelCount; Count++)
if (PC == RspCode.BranchLabels[Count]) { {
if (PC == RspCode.BranchLabels[Count])
{
return TRUE; return TRUE;
} }
} }
return FALSE; return FALSE;
} }
void CompilerLinkBlocks(void) { void CompilerLinkBlocks(void)
{
BYTE * KnownCode = (BYTE *)*(JumpTable + (CompilePC >> 2)); BYTE * KnownCode = (BYTE *)*(JumpTable + (CompilePC >> 2));
CPU_Message("***** Linking block to X86: %08X *****", KnownCode); CPU_Message("***** Linking block to X86: %08X *****", KnownCode);
@ -738,7 +796,8 @@ void CompilerRSPBlock(void)
register size_t Count; register size_t Count;
const size_t Padding = (8 - (X86BaseAddress & 7)) & 7; const size_t Padding = (8 - (X86BaseAddress & 7)) & 7;
for (Count = 0; Count < Padding; Count++) { for (Count = 0; Count < Padding; Count++)
{
CPU_Message("%08X: nop", RecompPos); CPU_Message("%08X: nop", RecompPos);
*(RecompPos++) = 0x90; *(RecompPos++) = 0x90;
} }
@ -750,7 +809,8 @@ void CompilerRSPBlock(void)
CPU_Message("Start of block: %X", CurrentBlock.StartPC); CPU_Message("Start of block: %X", CurrentBlock.StartPC);
CPU_Message("====== Recompiled code ======"); CPU_Message("====== Recompiled code ======");
if (Compiler.bReOrdering == TRUE) { if (Compiler.bReOrdering == TRUE)
{
memcpy(IMEM_SAVE, RSPInfo.IMEM, 0x1000); memcpy(IMEM_SAVE, RSPInfo.IMEM, 0x1000);
ReOrderSubBlock(&CurrentBlock); ReOrderSubBlock(&CurrentBlock);
} }
@ -758,14 +818,17 @@ void CompilerRSPBlock(void)
// This is for the block about to be compiled // This is for the block about to be compiled
*(JumpTable + (CompilePC >> 2)) = RecompPos; *(JumpTable + (CompilePC >> 2)) = RecompPos;
do { do
{
// Reordering is setup to allow us to have loop labels // Reordering is setup to allow us to have loop labels
// so here we see if this is one and put it in the jump table // so here we see if this is one and put it in the jump table
if (NextInstruction == NORMAL && IsJumpLabel(CompilePC)) { if (NextInstruction == NORMAL && IsJumpLabel(CompilePC))
{
// Jumps come around twice // Jumps come around twice
if (NULL == *(JumpTable + (CompilePC >> 2))) { if (NULL == *(JumpTable + (CompilePC >> 2)))
{
CPU_Message("***** Adding jump table entry for PC: %04X at X86: %08X *****", CompilePC, RecompPos); CPU_Message("***** Adding jump table entry for PC: %04X at X86: %08X *****", CompilePC, RecompPos);
CPU_Message(""); CPU_Message("");
*(JumpTable + (CompilePC >> 2)) = RecompPos; *(JumpTable + (CompilePC >> 2)) = RecompPos;
@ -773,28 +836,33 @@ void CompilerRSPBlock(void)
// Reorder from here to next label or branch // Reorder from here to next label or branch
CurrentBlock.CurrPC = CompilePC; CurrentBlock.CurrPC = CompilePC;
ReOrderSubBlock(&CurrentBlock); ReOrderSubBlock(&CurrentBlock);
} else if (NextInstruction != DELAY_SLOT_DONE) { }
else if (NextInstruction != DELAY_SLOT_DONE)
{
// We could link the blocks here, but performance-wise it might be better to just let it run // We could link the blocks here, but performance-wise it might be better to just let it run
} }
} }
if (Compiler.bSections == TRUE) { if (Compiler.bSections == TRUE)
if (TRUE == RSP_DoSections()) { {
if (TRUE == RSP_DoSections())
{
continue; continue;
} }
} }
#ifdef X86_RECOMP_VERBOSE #ifdef X86_RECOMP_VERBOSE
if (FALSE == IsOpcodeNop(CompilePC)) { if (FALSE == IsOpcodeNop(CompilePC))
{
CPU_Message("X86 Address: %08X", RecompPos); CPU_Message("X86 Address: %08X", RecompPos);
} }
#endif #endif
RSP_LW_IMEM(CompilePC, &RSPOpC.Hex); RSP_LW_IMEM(CompilePC, &RSPOpC.Hex);
if (LogRDP && NextInstruction != DELAY_SLOT_DONE){ if (LogRDP && NextInstruction != DELAY_SLOT_DONE)
{
char str[40]; char str[40];
sprintf(str, "%X", CompilePC); sprintf(str, "%X", CompilePC);
PushImm32(str, CompilePC); PushImm32(str, CompilePC);
@ -802,14 +870,18 @@ void CompilerRSPBlock(void)
AddConstToX86Reg(x86_ESP, 4); AddConstToX86Reg(x86_ESP, 4);
} }
if (RSPOpC.Hex == 0xFFFFFFFF) { if (RSPOpC.Hex == 0xFFFFFFFF)
{
// I think this pops up an unknown OP dialog // I think this pops up an unknown OP dialog
// NextInstruction = FINISH_BLOCK; // NextInstruction = FINISH_BLOCK;
} else { }
else
{
RSP_Opcode[RSPOpC.op](); RSP_Opcode[RSPOpC.op]();
} }
switch (NextInstruction) { switch (NextInstruction)
{
case NORMAL: case NORMAL:
CompilePC += 4; CompilePC += 4;
break; break;
@ -828,9 +900,12 @@ void CompilerRSPBlock(void)
case FINISH_SUB_BLOCK: case FINISH_SUB_BLOCK:
NextInstruction = NORMAL; NextInstruction = NORMAL;
CompilePC += 8; CompilePC += 8;
if (CompilePC >= 0x1000) { if (CompilePC >= 0x1000)
{
NextInstruction = FINISH_BLOCK; NextInstruction = FINISH_BLOCK;
} else if (NULL == *(JumpTable + (CompilePC >> 2))) { }
else if (NULL == *(JumpTable + (CompilePC >> 2)))
{
// This is for the new block being compiled now // This is for the new block being compiled now
CPU_Message("***** Continuing static SubBlock (jump table entry added for PC: %04X at X86: %08X) *****", CompilePC, RecompPos); CPU_Message("***** Continuing static SubBlock (jump table entry added for PC: %04X at X86: %08X) *****", CompilePC, RecompPos);
*(JumpTable + (CompilePC >> 2)) = RecompPos; *(JumpTable + (CompilePC >> 2)) = RecompPos;
@ -838,7 +913,9 @@ void CompilerRSPBlock(void)
CurrentBlock.CurrPC = CompilePC; CurrentBlock.CurrPC = CompilePC;
// Reorder from after delay to next label or branch // Reorder from after delay to next label or branch
ReOrderSubBlock(&CurrentBlock); ReOrderSubBlock(&CurrentBlock);
} else { }
else
{
CompilerLinkBlocks(); CompilerLinkBlocks();
} }
break; break;
@ -852,13 +929,15 @@ void CompilerRSPBlock(void)
} while (NextInstruction != FINISH_BLOCK && (CompilePC < 0x1000 || NextInstruction == DELAY_SLOT)); } while (NextInstruction != FINISH_BLOCK && (CompilePC < 0x1000 || NextInstruction == DELAY_SLOT));
CPU_Message("===== End of recompiled code ====="); CPU_Message("===== End of recompiled code =====");
if (Compiler.bReOrdering == TRUE) { if (Compiler.bReOrdering == TRUE)
{
memcpy(RSPInfo.IMEM, IMEM_SAVE, 0x1000); memcpy(RSPInfo.IMEM, IMEM_SAVE, 0x1000);
} }
free(IMEM_SAVE); free(IMEM_SAVE);
} }
DWORD RunRecompilerCPU ( DWORD Cycles ) { DWORD RunRecompilerCPU(DWORD Cycles)
{
BYTE * Block; BYTE * Block;
RSP_Running = TRUE; RSP_Running = TRUE;
@ -868,18 +947,23 @@ DWORD RunRecompilerCPU ( DWORD Cycles ) {
{ {
Block = (BYTE *)*(JumpTable + (*PrgCount >> 2)); Block = (BYTE *)*(JumpTable + (*PrgCount >> 2));
if (Block == NULL) { if (Block == NULL)
if (Profiling && !IndvidualBlock) { {
if (Profiling && !IndvidualBlock)
{
StartTimer((DWORD)Timer_Compiling); StartTimer((DWORD)Timer_Compiling);
} }
memset(&RspCode, 0, sizeof(RspCode)); memset(&RspCode, 0, sizeof(RspCode));
#if defined(_MSC_VER) #if defined(_MSC_VER)
__try { __try
{
BuildBranchLabels(); BuildBranchLabels();
DetectGPRConstants(&RspCode); DetectGPRConstants(&RspCode);
CompilerRSPBlock(); CompilerRSPBlock();
} __except(EXCEPTION_EXECUTE_HANDLER) { }
__except (EXCEPTION_EXECUTE_HANDLER)
{
DisplayError("Error CompilePC = %08X", CompilePC); DisplayError("Error CompilePC = %08X", CompilePC);
ClearAllx86Code(); ClearAllx86Code();
continue; continue;
@ -897,12 +981,14 @@ DWORD RunRecompilerCPU ( DWORD Cycles ) {
// that go out of it, let's rock // that go out of it, let's rock
LinkBranches(&CurrentBlock); LinkBranches(&CurrentBlock);
if (Profiling && !IndvidualBlock) { if (Profiling && !IndvidualBlock)
{
StopTimer(); StopTimer();
} }
} }
if (Profiling && IndvidualBlock) { if (Profiling && IndvidualBlock)
{
StartTimer(*PrgCount); StartTimer(*PrgCount);
} }
@ -915,7 +1001,8 @@ DWORD RunRecompilerCPU ( DWORD Cycles ) {
#else #else
DebugBreak(); DebugBreak();
#endif #endif
if (Profiling && IndvidualBlock) { if (Profiling && IndvidualBlock)
{
StopTimer(); StopTimer();
} }
if (RSP_NextInstruction == SINGLE_STEP) if (RSP_NextInstruction == SINGLE_STEP)
@ -924,7 +1011,8 @@ DWORD RunRecompilerCPU ( DWORD Cycles ) {
} }
} }
if (IsMmxEnabled == TRUE) { if (IsMmxEnabled == TRUE)
{
#if defined(_M_IX86) && defined(_MSC_VER) #if defined(_M_IX86) && defined(_MSC_VER)
_asm emms _asm emms
#else #else

View File

@ -4,7 +4,8 @@
extern uint32_t CompilePC, NextInstruction, JumpTableSize; extern uint32_t CompilePC, NextInstruction, JumpTableSize;
extern Boolean ChangedPC; extern Boolean ChangedPC;
#define CompilerWarning if (ShowErrors) DisplayError #define CompilerWarning \
if (ShowErrors) DisplayError
#define High16BitAccum 1 #define High16BitAccum 1
#define Middle16BitAccum 2 #define Middle16BitAccum 2
@ -36,10 +37,12 @@ void CompilerRSPBlock ( void );
void CompilerToggleBuffer(void); void CompilerToggleBuffer(void);
Boolean RSP_DoSections(void); Boolean RSP_DoSections(void);
typedef struct { typedef struct
{
DWORD StartPC, CurrPC; // Block start DWORD StartPC, CurrPC; // Block start
struct { struct
{
DWORD TargetPC; // Target for this unknown branch DWORD TargetPC; // Target for this unknown branch
DWORD * X86JumpLoc; // Our x86 DWORD to fill DWORD * X86JumpLoc; // Our x86 DWORD to fill
} BranchesToResolve[200]; // Branches inside or outside block } BranchesToResolve[200]; // Branches inside or outside block
@ -49,7 +52,8 @@ typedef struct {
extern RSP_BLOCK CurrentBlock; extern RSP_BLOCK CurrentBlock;
typedef struct { typedef struct
{
Boolean bIsRegConst[32]; // Boolean toggle for constant Boolean bIsRegConst[32]; // Boolean toggle for constant
DWORD MipsRegConst[32]; // Value of register 32-bit DWORD MipsRegConst[32]; // Value of register 32-bit
DWORD BranchLabels[250]; DWORD BranchLabels[250];
@ -63,7 +67,8 @@ extern RSP_CODE RspCode;
#define IsRegConst(i) (RspCode.bIsRegConst[i]) #define IsRegConst(i) (RspCode.bIsRegConst[i])
#define MipsRegConst(i) (RspCode.MipsRegConst[i]) #define MipsRegConst(i) (RspCode.MipsRegConst[i])
typedef struct { typedef struct
{
Boolean mmx, mmx2, sse; // CPU specs and compiling Boolean mmx, mmx2, sse; // CPU specs and compiling
Boolean bFlags; // RSP flag analysis Boolean bFlags; // RSP flag analysis
Boolean bReOrdering; // Instruction reordering Boolean bReOrdering; // Instruction reordering

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -1,8 +1,8 @@
#pragma once #pragma once
#include <Project64-plugin-spec/Rsp.h> #include <Project64-plugin-spec/Rsp.h>
#include <stdint.h>
#include "Types.h" #include "Types.h"
#include <stdint.h>
// Profiling // Profiling
#define Default_ProfilingOn FALSE #define Default_ProfilingOn FALSE

View File

@ -1,30 +1,38 @@
#include <windows.h>
#include <stdio.h>
#include "Rsp.h"
#include "x86.h"
#include "memory.h"
#include "RSP registers.h" #include "RSP registers.h"
#include "Rsp.h"
#include "log.h" #include "log.h"
#include "memory.h"
#include "x86.h"
#include <stdio.h>
#include <windows.h>
#define PUTDST8(dest,value) (*((BYTE *)(dest))=(BYTE)(value)); dest += 1; #define PUTDST8(dest, value) \
#define PUTDST16(dest,value) (*((WORD *)(dest))=(WORD)(value)); dest += 2; (*((BYTE *)(dest)) = (BYTE)(value)); \
#define PUTDST32(dest,value) (*((DWORD *)(dest))=(DWORD)(value)); dest += 4; dest += 1;
#define PUTDST16(dest, value) \
(*((WORD *)(dest)) = (WORD)(value)); \
dest += 2;
#define PUTDST32(dest, value) \
(*((DWORD *)(dest)) = (DWORD)(value)); \
dest += 4;
#define PUTDSTPTR(dest, value) \ #define PUTDSTPTR(dest, value) \
*(void **)(dest) = (void *)(value); dest += sizeof(void *); *(void **)(dest) = (void *)(value); \
dest += sizeof(void *);
char * sse_Strings[8] = { char * sse_Strings[8] = {
"xmm0", "xmm1", "xmm2", "xmm3", "xmm0", "xmm1", "xmm2", "xmm3",
"xmm4", "xmm5", "xmm6", "xmm7" "xmm4", "xmm5", "xmm6", "xmm7"};
};
#define sse_Name(Reg) (sse_Strings[(Reg)]) #define sse_Name(Reg) (sse_Strings[(Reg)])
void SseMoveAlignedVariableToReg(void *Variable, char *VariableName, int sseReg) { void SseMoveAlignedVariableToReg(void * Variable, char * VariableName, int sseReg)
{
BYTE x86Command = 0; BYTE x86Command = 0;
CPU_Message(" movaps %s, xmmword ptr [%s]", sse_Name(sseReg), VariableName); CPU_Message(" movaps %s, xmmword ptr [%s]", sse_Name(sseReg), VariableName);
switch (sseReg) { switch (sseReg)
{
case x86_XMM0: x86Command = 0x05; break; case x86_XMM0: x86Command = 0x05; break;
case x86_XMM1: x86Command = 0x0D; break; case x86_XMM1: x86Command = 0x0D; break;
case x86_XMM2: x86Command = 0x15; break; case x86_XMM2: x86Command = 0x15; break;
@ -40,12 +48,14 @@ void SseMoveAlignedVariableToReg(void *Variable, char *VariableName, int sseReg)
PUTDSTPTR(RecompPos, Variable); PUTDSTPTR(RecompPos, Variable);
} }
void SseMoveAlignedN64MemToReg(int sseReg, int AddrReg) { void SseMoveAlignedN64MemToReg(int sseReg, int AddrReg)
{
BYTE x86Command = 0; BYTE x86Command = 0;
CPU_Message(" movaps %s, xmmword ptr [Dmem+%s]", sse_Name(sseReg), x86_Name(AddrReg)); CPU_Message(" movaps %s, xmmword ptr [Dmem+%s]", sse_Name(sseReg), x86_Name(AddrReg));
switch (sseReg) { switch (sseReg)
{
case x86_XMM0: x86Command = 0x80; break; case x86_XMM0: x86Command = 0x80; break;
case x86_XMM1: x86Command = 0x88; break; case x86_XMM1: x86Command = 0x88; break;
case x86_XMM2: x86Command = 0x90; break; case x86_XMM2: x86Command = 0x90; break;
@ -55,7 +65,8 @@ void SseMoveAlignedN64MemToReg(int sseReg, int AddrReg) {
case x86_XMM6: x86Command = 0xB0; break; case x86_XMM6: x86Command = 0xB0; break;
case x86_XMM7: x86Command = 0xB8; break; case x86_XMM7: x86Command = 0xB8; break;
} }
switch (AddrReg) { switch (AddrReg)
{
case x86_EAX: x86Command += 0x00; break; case x86_EAX: x86Command += 0x00; break;
case x86_EBX: x86Command += 0x03; break; case x86_EBX: x86Command += 0x03; break;
case x86_ECX: x86Command += 0x01; break; case x86_ECX: x86Command += 0x01; break;
@ -71,12 +82,14 @@ void SseMoveAlignedN64MemToReg(int sseReg, int AddrReg) {
PUTDSTPTR(RecompPos, RSPInfo.DMEM); PUTDSTPTR(RecompPos, RSPInfo.DMEM);
} }
void SseMoveAlignedRegToVariable(int sseReg, void *Variable, char *VariableName) { void SseMoveAlignedRegToVariable(int sseReg, void * Variable, char * VariableName)
{
BYTE x86Command = 0; BYTE x86Command = 0;
CPU_Message(" movaps xmmword ptr [%s], %s", VariableName, sse_Name(sseReg)); CPU_Message(" movaps xmmword ptr [%s], %s", VariableName, sse_Name(sseReg));
switch (sseReg) { switch (sseReg)
{
case x86_XMM0: x86Command = 0x05; break; case x86_XMM0: x86Command = 0x05; break;
case x86_XMM1: x86Command = 0x0D; break; case x86_XMM1: x86Command = 0x0D; break;
case x86_XMM2: x86Command = 0x15; break; case x86_XMM2: x86Command = 0x15; break;
@ -92,12 +105,14 @@ void SseMoveAlignedRegToVariable(int sseReg, void *Variable, char *VariableName)
PUTDSTPTR(RecompPos, Variable); PUTDSTPTR(RecompPos, Variable);
} }
void SseMoveAlignedRegToN64Mem(int sseReg, int AddrReg) { void SseMoveAlignedRegToN64Mem(int sseReg, int AddrReg)
{
BYTE x86Command = 0; BYTE x86Command = 0;
CPU_Message(" movaps xmmword ptr [Dmem+%s], %s", x86_Name(AddrReg), sse_Name(sseReg)); CPU_Message(" movaps xmmword ptr [Dmem+%s], %s", x86_Name(AddrReg), sse_Name(sseReg));
switch (sseReg) { switch (sseReg)
{
case x86_XMM0: x86Command = 0x80; break; case x86_XMM0: x86Command = 0x80; break;
case x86_XMM1: x86Command = 0x88; break; case x86_XMM1: x86Command = 0x88; break;
case x86_XMM2: x86Command = 0x90; break; case x86_XMM2: x86Command = 0x90; break;
@ -107,7 +122,8 @@ void SseMoveAlignedRegToN64Mem(int sseReg, int AddrReg) {
case x86_XMM6: x86Command = 0xB0; break; case x86_XMM6: x86Command = 0xB0; break;
case x86_XMM7: x86Command = 0xB8; break; case x86_XMM7: x86Command = 0xB8; break;
} }
switch (AddrReg) { switch (AddrReg)
{
case x86_EAX: x86Command += 0x00; break; case x86_EAX: x86Command += 0x00; break;
case x86_EBX: x86Command += 0x03; break; case x86_EBX: x86Command += 0x03; break;
case x86_ECX: x86Command += 0x01; break; case x86_ECX: x86Command += 0x01; break;
@ -123,12 +139,14 @@ void SseMoveAlignedRegToN64Mem(int sseReg, int AddrReg) {
PUTDSTPTR(RecompPos, RSPInfo.DMEM); PUTDSTPTR(RecompPos, RSPInfo.DMEM);
} }
void SseMoveUnalignedVariableToReg(void *Variable, char *VariableName, int sseReg) { void SseMoveUnalignedVariableToReg(void * Variable, char * VariableName, int sseReg)
{
BYTE x86Command = 0; BYTE x86Command = 0;
CPU_Message(" movups %s, xmmword ptr [%s]", sse_Name(sseReg), VariableName); CPU_Message(" movups %s, xmmword ptr [%s]", sse_Name(sseReg), VariableName);
switch (sseReg) { switch (sseReg)
{
case x86_XMM0: x86Command = 0x05; break; case x86_XMM0: x86Command = 0x05; break;
case x86_XMM1: x86Command = 0x0D; break; case x86_XMM1: x86Command = 0x0D; break;
case x86_XMM2: x86Command = 0x15; break; case x86_XMM2: x86Command = 0x15; break;
@ -144,12 +162,14 @@ void SseMoveUnalignedVariableToReg(void *Variable, char *VariableName, int sseRe
PUTDSTPTR(RecompPos, Variable); PUTDSTPTR(RecompPos, Variable);
} }
void SseMoveUnalignedN64MemToReg(int sseReg, int AddrReg) { void SseMoveUnalignedN64MemToReg(int sseReg, int AddrReg)
{
BYTE x86Command = 0; BYTE x86Command = 0;
CPU_Message(" movups %s, xmmword ptr [Dmem+%s]", sse_Name(sseReg), x86_Name(AddrReg)); CPU_Message(" movups %s, xmmword ptr [Dmem+%s]", sse_Name(sseReg), x86_Name(AddrReg));
switch (sseReg) { switch (sseReg)
{
case x86_XMM0: x86Command = 0x80; break; case x86_XMM0: x86Command = 0x80; break;
case x86_XMM1: x86Command = 0x88; break; case x86_XMM1: x86Command = 0x88; break;
case x86_XMM2: x86Command = 0x90; break; case x86_XMM2: x86Command = 0x90; break;
@ -159,7 +179,8 @@ void SseMoveUnalignedN64MemToReg(int sseReg, int AddrReg) {
case x86_XMM6: x86Command = 0xB0; break; case x86_XMM6: x86Command = 0xB0; break;
case x86_XMM7: x86Command = 0xB8; break; case x86_XMM7: x86Command = 0xB8; break;
} }
switch (AddrReg) { switch (AddrReg)
{
case x86_EAX: x86Command += 0x00; break; case x86_EAX: x86Command += 0x00; break;
case x86_EBX: x86Command += 0x03; break; case x86_EBX: x86Command += 0x03; break;
case x86_ECX: x86Command += 0x01; break; case x86_ECX: x86Command += 0x01; break;
@ -175,12 +196,14 @@ void SseMoveUnalignedN64MemToReg(int sseReg, int AddrReg) {
PUTDSTPTR(RecompPos, RSPInfo.DMEM); PUTDSTPTR(RecompPos, RSPInfo.DMEM);
} }
void SseMoveUnalignedRegToVariable(int sseReg, void *Variable, char *VariableName) { void SseMoveUnalignedRegToVariable(int sseReg, void * Variable, char * VariableName)
{
BYTE x86Command = 0; BYTE x86Command = 0;
CPU_Message(" movups xmmword ptr [%s], %s", VariableName, sse_Name(sseReg)); CPU_Message(" movups xmmword ptr [%s], %s", VariableName, sse_Name(sseReg));
switch (sseReg) { switch (sseReg)
{
case x86_XMM0: x86Command = 0x05; break; case x86_XMM0: x86Command = 0x05; break;
case x86_XMM1: x86Command = 0x0D; break; case x86_XMM1: x86Command = 0x0D; break;
case x86_XMM2: x86Command = 0x15; break; case x86_XMM2: x86Command = 0x15; break;
@ -196,12 +219,14 @@ void SseMoveUnalignedRegToVariable(int sseReg, void *Variable, char *VariableNam
PUTDSTPTR(RecompPos, Variable); PUTDSTPTR(RecompPos, Variable);
} }
void SseMoveUnalignedRegToN64Mem(int sseReg, int AddrReg) { void SseMoveUnalignedRegToN64Mem(int sseReg, int AddrReg)
{
BYTE x86Command = 0; BYTE x86Command = 0;
CPU_Message(" movups xmmword ptr [Dmem+%s], %s", x86_Name(AddrReg), sse_Name(sseReg)); CPU_Message(" movups xmmword ptr [Dmem+%s], %s", x86_Name(AddrReg), sse_Name(sseReg));
switch (sseReg) { switch (sseReg)
{
case x86_XMM0: x86Command = 0x80; break; case x86_XMM0: x86Command = 0x80; break;
case x86_XMM1: x86Command = 0x88; break; case x86_XMM1: x86Command = 0x88; break;
case x86_XMM2: x86Command = 0x90; break; case x86_XMM2: x86Command = 0x90; break;
@ -211,7 +236,8 @@ void SseMoveUnalignedRegToN64Mem(int sseReg, int AddrReg) {
case x86_XMM6: x86Command = 0xB0; break; case x86_XMM6: x86Command = 0xB0; break;
case x86_XMM7: x86Command = 0xB8; break; case x86_XMM7: x86Command = 0xB8; break;
} }
switch (AddrReg) { switch (AddrReg)
{
case x86_EAX: x86Command += 0x00; break; case x86_EAX: x86Command += 0x00; break;
case x86_EBX: x86Command += 0x03; break; case x86_EBX: x86Command += 0x03; break;
case x86_ECX: x86Command += 0x01; break; case x86_ECX: x86Command += 0x01; break;
@ -227,12 +253,14 @@ void SseMoveUnalignedRegToN64Mem(int sseReg, int AddrReg) {
PUTDSTPTR(RecompPos, RSPInfo.DMEM); PUTDSTPTR(RecompPos, RSPInfo.DMEM);
} }
void SseMoveRegToReg(int Dest, int Source) { void SseMoveRegToReg(int Dest, int Source)
{
BYTE x86Command = 0; BYTE x86Command = 0;
CPU_Message(" movaps %s, %s", sse_Name(Dest), sse_Name(Source)); CPU_Message(" movaps %s, %s", sse_Name(Dest), sse_Name(Source));
switch (Dest) { switch (Dest)
{
case x86_XMM0: x86Command = 0x00; break; case x86_XMM0: x86Command = 0x00; break;
case x86_XMM1: x86Command = 0x08; break; case x86_XMM1: x86Command = 0x08; break;
case x86_XMM2: x86Command = 0x10; break; case x86_XMM2: x86Command = 0x10; break;
@ -242,7 +270,8 @@ void SseMoveRegToReg(int Dest, int Source) {
case x86_XMM6: x86Command = 0x30; break; case x86_XMM6: x86Command = 0x30; break;
case x86_XMM7: x86Command = 0x38; break; case x86_XMM7: x86Command = 0x38; break;
} }
switch (Source) { switch (Source)
{
case x86_XMM0: x86Command += 0x00; break; case x86_XMM0: x86Command += 0x00; break;
case x86_XMM1: x86Command += 0x01; break; case x86_XMM1: x86Command += 0x01; break;
case x86_XMM2: x86Command += 0x02; break; case x86_XMM2: x86Command += 0x02; break;
@ -257,12 +286,14 @@ void SseMoveRegToReg(int Dest, int Source) {
PUTDST8(RecompPos, 0xC0 | x86Command); PUTDST8(RecompPos, 0xC0 | x86Command);
} }
void SseXorRegToReg(int Dest, int Source) { void SseXorRegToReg(int Dest, int Source)
{
BYTE x86Command = 0; BYTE x86Command = 0;
CPU_Message(" xorps %s, %s", sse_Name(Dest), sse_Name(Source)); CPU_Message(" xorps %s, %s", sse_Name(Dest), sse_Name(Source));
switch (Dest) { switch (Dest)
{
case x86_XMM0: x86Command = 0x00; break; case x86_XMM0: x86Command = 0x00; break;
case x86_XMM1: x86Command = 0x08; break; case x86_XMM1: x86Command = 0x08; break;
case x86_XMM2: x86Command = 0x10; break; case x86_XMM2: x86Command = 0x10; break;
@ -272,7 +303,8 @@ void SseXorRegToReg(int Dest, int Source) {
case x86_XMM6: x86Command = 0x30; break; case x86_XMM6: x86Command = 0x30; break;
case x86_XMM7: x86Command = 0x38; break; case x86_XMM7: x86Command = 0x38; break;
} }
switch (Source) { switch (Source)
{
case x86_XMM0: x86Command += 0x00; break; case x86_XMM0: x86Command += 0x00; break;
case x86_XMM1: x86Command += 0x01; break; case x86_XMM1: x86Command += 0x01; break;
case x86_XMM2: x86Command += 0x02; break; case x86_XMM2: x86Command += 0x02; break;
@ -286,12 +318,14 @@ void SseXorRegToReg(int Dest, int Source) {
PUTDST8(RecompPos, 0xC0 | x86Command); PUTDST8(RecompPos, 0xC0 | x86Command);
} }
void SseShuffleReg(int Dest, int Source, BYTE Immed) { void SseShuffleReg(int Dest, int Source, BYTE Immed)
{
BYTE x86Command = 0; BYTE x86Command = 0;
CPU_Message(" shufps %s, %s, %02X", sse_Name(Dest), sse_Name(Source), Immed); CPU_Message(" shufps %s, %s, %02X", sse_Name(Dest), sse_Name(Source), Immed);
switch (Dest) { switch (Dest)
{
case x86_XMM0: x86Command = 0x00; break; case x86_XMM0: x86Command = 0x00; break;
case x86_XMM1: x86Command = 0x08; break; case x86_XMM1: x86Command = 0x08; break;
case x86_XMM2: x86Command = 0x10; break; case x86_XMM2: x86Command = 0x10; break;
@ -301,7 +335,8 @@ void SseShuffleReg(int Dest, int Source, BYTE Immed) {
case x86_XMM6: x86Command = 0x30; break; case x86_XMM6: x86Command = 0x30; break;
case x86_XMM7: x86Command = 0x38; break; case x86_XMM7: x86Command = 0x38; break;
} }
switch (Source) { switch (Source)
{
case x86_XMM0: x86Command += 0x00; break; case x86_XMM0: x86Command += 0x00; break;
case x86_XMM1: x86Command += 0x01; break; case x86_XMM1: x86Command += 0x01; break;
case x86_XMM2: x86Command += 0x02; break; case x86_XMM2: x86Command += 0x02; break;

View File

@ -25,7 +25,8 @@ typedef int Boolean;
#define TRUE 1 #define TRUE 1
#endif #endif
typedef union tagUWORD { typedef union tagUWORD
{
int32_t W; int32_t W;
uint32_t UW; uint32_t UW;
int16_t HW[2]; int16_t HW[2];
@ -36,7 +37,8 @@ typedef union tagUWORD {
float F; float F;
} UWORD32; } UWORD32;
typedef union tagUDWORD { typedef union tagUDWORD
{
int64_t DW; int64_t DW;
uint64_t UDW; uint64_t UDW;
int32_t W[2]; int32_t W[2];
@ -50,7 +52,8 @@ typedef union tagUDWORD {
float F[2]; float F[2];
} UDWORD; } UDWORD;
typedef union tagVect { typedef union tagVect
{
int64_t DW[2]; int64_t DW[2];
uint64_t UDW[2]; uint64_t UDW[2];
int32_t W[4]; int32_t W[4];

File diff suppressed because it is too large Load Diff

View File

@ -1,16 +1,37 @@
enum x86RegValues { enum x86RegValues
x86_EAX = 0, x86_EBX = 1, x86_ECX = 2, x86_EDX = 3, {
x86_ESI = 4, x86_EDI = 5, x86_EBP = 6, x86_ESP = 7 x86_EAX = 0,
x86_EBX = 1,
x86_ECX = 2,
x86_EDX = 3,
x86_ESI = 4,
x86_EDI = 5,
x86_EBP = 6,
x86_ESP = 7
}; };
enum mmxRegValues { enum mmxRegValues
x86_MM0 = 0, x86_MM1 = 1, x86_MM2 = 2, x86_MM3 = 3, {
x86_MM4 = 4, x86_MM5 = 5, x86_MM6 = 6, x86_MM7 = 7 x86_MM0 = 0,
x86_MM1 = 1,
x86_MM2 = 2,
x86_MM3 = 3,
x86_MM4 = 4,
x86_MM5 = 5,
x86_MM6 = 6,
x86_MM7 = 7
}; };
enum sseRegValues { enum sseRegValues
x86_XMM0 = 0, x86_XMM1 = 1, x86_XMM2 = 2, x86_XMM3 = 3, {
x86_XMM4 = 4, x86_XMM5 = 5, x86_XMM6 = 6, x86_XMM7 = 7 x86_XMM0 = 0,
x86_XMM1 = 1,
x86_XMM2 = 2,
x86_XMM3 = 3,
x86_XMM4 = 4,
x86_XMM5 = 5,
x86_XMM6 = 6,
x86_XMM7 = 7
}; };
void AdcX86RegToX86Reg(int Destination, int Source); void AdcX86RegToX86Reg(int Destination, int Source);
@ -226,8 +247,10 @@ void SseXorRegToReg ( int Dest, int Source );
#pragma warning(push) #pragma warning(push)
#pragma warning(disable : 4201) // Non-standard extension used: nameless struct/union #pragma warning(disable : 4201) // Non-standard extension used: nameless struct/union
typedef union { typedef union
struct { {
struct
{
unsigned Reg0 : 2; unsigned Reg0 : 2;
unsigned Reg1 : 2; unsigned Reg1 : 2;
unsigned Reg2 : 2; unsigned Reg2 : 2;

View File

@ -1,8 +1,8 @@
#include <windows.h>
#include <stdio.h>
#include "Rsp.h"
#include "CPU.h"
#include "breakpoint.h" #include "breakpoint.h"
#include "CPU.h"
#include "Rsp.h"
#include <stdio.h>
#include <windows.h>
#define IDC_LOCATION_EDIT 105 #define IDC_LOCATION_EDIT 105
HWND BPoint_Win_hDlg, hRSPLocation = NULL; HWND BPoint_Win_hDlg, hRSPLocation = NULL;
@ -15,7 +15,8 @@ void Add_BPoint ( void )
char Title[10]; char Title[10];
GetWindowTextA(hRSPLocation, Title, sizeof(Title)); GetWindowTextA(hRSPLocation, Title, sizeof(Title));
if (!AddRSP_BPoint(AsciiToHex(Title),TRUE )) { if (!AddRSP_BPoint(AsciiToHex(Title), TRUE))
{
SendMessage(hRSPLocation, EM_SETSEL, (WPARAM)0, (LPARAM)-1); SendMessage(hRSPLocation, EM_SETSEL, (WPARAM)0, (LPARAM)-1);
SetFocus(hRSPLocation); SetFocus(hRSPLocation);
} }
@ -78,7 +79,10 @@ int CheckForRSPBPoint ( DWORD Location )
void CreateBPPanel(void * hDlg, rectangle rcBox) void CreateBPPanel(void * hDlg, rectangle rcBox)
{ {
if (hRSPLocation != NULL) { return; } if (hRSPLocation != NULL)
{
return;
}
rcBox = rcBox; // Remove warning of unused rcBox = rcBox; // Remove warning of unused
@ -118,15 +122,15 @@ void RefreshBpoints ( void * hList )
LRESULT location; LRESULT location;
int count; int count;
for (count = 0; count < NoOfBpoints; count ++ ) { for (count = 0; count < NoOfBpoints; count++)
{
sprintf(Message, " at 0x%03X (RSP)", BPoint[count].Location); sprintf(Message, " at 0x%03X (RSP)", BPoint[count].Location);
location = SendMessageA((HWND)hList, LB_ADDSTRING, 0, (LPARAM)Message); location = SendMessageA((HWND)hList, LB_ADDSTRING, 0, (LPARAM)Message);
SendMessageA( SendMessageA(
(HWND)hList, (HWND)hList,
LB_SETITEMDATA, LB_SETITEMDATA,
(WPARAM)location, (WPARAM)location,
(LPARAM)BPoint[count].Location (LPARAM)BPoint[count].Location);
);
} }
} }
@ -145,8 +149,7 @@ void RemoveBpoint (void * hList, int index )
{ {
DisplayError( DisplayError(
"LB_GETITEMDATA response for %i out of DWORD range.", "LB_GETITEMDATA response for %i out of DWORD range.",
index index);
);
} }
location = (uint32_t)response; location = (uint32_t)response;
RemoveRSPBreakPoint(location); RemoveRSPBreakPoint(location);

View File

@ -1,8 +1,10 @@
#include "Rsp.h" #include "Rsp.h"
#include <Windows.h>
#define MaxBPoints 0x30 #define MaxBPoints 0x30
typedef struct { typedef struct
{
unsigned int Location; unsigned int Location;
} BPOINT; } BPOINT;

View File

@ -1,9 +1,9 @@
#include <stdint.h>
#include <stdio.h> #include <stdio.h>
#include <string.h> #include <string.h>
#include <stdint.h>
#include "Rsp.h"
#include "RSP Registers.h" #include "RSP Registers.h"
#include "Rsp.h"
#include "memory.h" #include "memory.h"
// #define RSP_SAFE_DMA // Unoptimized DMA transfers // #define RSP_SAFE_DMA // Unoptimized DMA transfers

View File

@ -1,14 +1,13 @@
#include <stdio.h>
#include <windows.h>
#include <Common/StdString.h>
#include <Common/File.h> #include <Common/File.h>
#include <Common/Log.h> #include <Common/Log.h>
#include <Common/StdString.h>
#include <Common/path.h> #include <Common/path.h>
#include <stdio.h>
#include <windows.h>
#include "Log.h" #include "Log.h"
#include "Rsp.h"
#include "Rsp Registers.h" #include "Rsp Registers.h"
#include "Rsp.h"
CLog * RDPLog = NULL; CLog * RDPLog = NULL;
CLog * CPULog = NULL; CLog * CPULog = NULL;
@ -101,7 +100,8 @@ void RDP_LogMT0 ( DWORD PC, int Reg, DWORD Value )
{ {
return; return;
} }
switch (Reg) { switch (Reg)
{
case 0: RDP_Message("%03X: Stored 0x%08X into SP_MEM_ADDR_REG", PC, Value); break; case 0: RDP_Message("%03X: Stored 0x%08X into SP_MEM_ADDR_REG", PC, Value); break;
case 1: RDP_Message("%03X: Stored 0x%08X into SP_DRAM_ADDR_REG", PC, Value); break; case 1: RDP_Message("%03X: Stored 0x%08X into SP_DRAM_ADDR_REG", PC, Value); break;
case 2: RDP_Message("%03X: Stored 0x%08X into SP_RD_LEN_REG", PC, Value); break; case 2: RDP_Message("%03X: Stored 0x%08X into SP_RD_LEN_REG", PC, Value); break;
@ -120,7 +120,8 @@ void RDP_LogMT0 ( DWORD PC, int Reg, DWORD Value )
void RDP_LogMF0(DWORD PC, int Reg) void RDP_LogMF0(DWORD PC, int Reg)
{ {
switch (Reg) { switch (Reg)
{
case 8: RDP_Message("%03X: Read 0x%08X from DPC_START_REG", PC, *RSPInfo.DPC_START_REG); break; case 8: RDP_Message("%03X: Read 0x%08X from DPC_START_REG", PC, *RSPInfo.DPC_START_REG); break;
case 9: RDP_Message("%03X: Read 0x%08X from DPC_END_REG", PC, *RSPInfo.DPC_END_REG); break; case 9: RDP_Message("%03X: Read 0x%08X from DPC_END_REG", PC, *RSPInfo.DPC_END_REG); break;
case 10: RDP_Message("%03X: Read 0x%08X from DPC_CURRENT_REG", PC, *RSPInfo.DPC_CURRENT_REG); break; case 10: RDP_Message("%03X: Read 0x%08X from DPC_CURRENT_REG", PC, *RSPInfo.DPC_CURRENT_REG); break;
@ -129,7 +130,6 @@ void RDP_LogMF0 ( DWORD PC, int Reg )
} }
} }
void RDP_LogDlist(void) void RDP_LogDlist(void)
{ {
if (RDPLog == NULL) if (RDPLog == NULL)
@ -154,22 +154,28 @@ void RDP_LogDlist ( void )
Mem = RSPInfo.RDRAM; Mem = RSPInfo.RDRAM;
} }
for (count = 0; count < 0x10; count ++, Pos++ ) { for (count = 0; count < 0x10; count++, Pos++)
{
char tmp[3]; char tmp[3];
if ((count % 4) != 0 || count == 0) { if ((count % 4) != 0 || count == 0)
{
sprintf(tmp, "%02X", Mem[Pos]); sprintf(tmp, "%02X", Mem[Pos]);
strcat(Hex, " "); strcat(Hex, " ");
strcat(Hex, tmp); strcat(Hex, tmp);
} else { }
else
{
sprintf(tmp, "%02X", Mem[Pos]); sprintf(tmp, "%02X", Mem[Pos]);
strcat(Hex, " - "); strcat(Hex, " - ");
strcat(Hex, tmp); strcat(Hex, tmp);
} }
if (Mem[Pos] < 30 || Mem[Pos] > 127)
if (Mem[Pos] < 30 || Mem[Pos] > 127) { {
strcat(Ascii, "."); strcat(Ascii, ".");
} else { }
else
{
sprintf(tmp, "%c", Mem[Pos]); sprintf(tmp, "%c", Mem[Pos]);
strcat(Ascii, tmp); strcat(Ascii, tmp);
} }
@ -185,12 +191,11 @@ void RDP_LogLoc ( DWORD /*PC*/ )
// RSP_Vect[28].UW[0],RSP_Vect[28].UW[1],RSP_Vect[28].UW[2],RSP_Vect[28].UW[3],RSP_Vect[31].UW[0]); // RSP_Vect[28].UW[0],RSP_Vect[28].UW[1],RSP_Vect[28].UW[2],RSP_Vect[28].UW[3],RSP_Vect[31].UW[0]);
} }
#ifdef old #ifdef old
#include <windows.h>
#include "RSP Registers.h" #include "RSP Registers.h"
#include "log.h" #include "log.h"
#include <windows.h>
#ifdef Log_x86Code #ifdef Log_x86Code
static HANDLE hCPULogFile = NULL; static HANDLE hCPULogFile = NULL;
@ -201,7 +206,8 @@ static HANDLE hLogFile = NULL;
#endif #endif
#ifdef Log_x86Code #ifdef Log_x86Code
void CPU_Message (char * Message, ...) { void CPU_Message(char * Message, ...)
{
DWORD dwWritten; DWORD dwWritten;
char Msg[400]; char Msg[400];
va_list ap; va_list ap;
@ -216,7 +222,8 @@ void CPU_Message (char * Message, ...) {
#endif #endif
#ifdef GenerateLog #ifdef GenerateLog
void Log_Message (char * Message, ...) { void Log_Message(char * Message, ...)
{
DWORD dwWritten; DWORD dwWritten;
char Msg[400]; char Msg[400];
va_list ap; va_list ap;
@ -232,7 +239,8 @@ void Log_Message (char * Message, ...) {
#endif #endif
#ifdef Log_x86Code #ifdef Log_x86Code
void Start_x86_Log (void) { void Start_x86_Log(void)
{
char path_buffer[_MAX_PATH], drive[_MAX_DRIVE], dir[_MAX_DIR]; char path_buffer[_MAX_PATH], drive[_MAX_DRIVE], dir[_MAX_DIR];
char File[_MAX_PATH]; char File[_MAX_PATH];
@ -248,8 +256,10 @@ void Start_x86_Log (void) {
#endif #endif
#ifdef GenerateLog #ifdef GenerateLog
void Log_MT_CP0 ( unsigned int PC, int CP0Reg, int Value ) { void Log_MT_CP0(unsigned int PC, int CP0Reg, int Value)
switch (CP0Reg) { {
switch (CP0Reg)
{
//case 0: Log_Message("%03X: Stored 0x%08X in SP_MEM_ADDR_REG",PC,Value); break; //case 0: Log_Message("%03X: Stored 0x%08X in SP_MEM_ADDR_REG",PC,Value); break;
//case 1: Log_Message("%03X: Stored 0x%08X in SP_DRAM_ADDR_REG",PC,Value); break; //case 1: Log_Message("%03X: Stored 0x%08X in SP_DRAM_ADDR_REG",PC,Value); break;
//case 2: Log_Message("%03X: Stored 0x%08X in SP_RD_LEN_REG",PC,Value); break; //case 2: Log_Message("%03X: Stored 0x%08X in SP_RD_LEN_REG",PC,Value); break;
@ -276,7 +286,8 @@ void Log_MT_CP0 ( unsigned int PC, int CP0Reg, int Value ) {
} }
} }
void Start_Log (void) { void Start_Log(void)
{
char path_buffer[_MAX_PATH], drive[_MAX_DRIVE], dir[_MAX_DIR]; char path_buffer[_MAX_PATH], drive[_MAX_DRIVE], dir[_MAX_DIR];
char File[_MAX_PATH]; char File[_MAX_PATH];
@ -290,8 +301,10 @@ void Start_Log (void) {
SetFilePointer(hLogFile, 0, NULL, FILE_BEGIN); SetFilePointer(hLogFile, 0, NULL, FILE_BEGIN);
} }
void Stop_Log (void) { void Stop_Log(void)
if (hLogFile) { {
if (hLogFile)
{
CloseHandle(hLogFile); CloseHandle(hLogFile);
hLogFile = NULL; hLogFile = NULL;
} }
@ -299,8 +312,10 @@ void Stop_Log (void) {
#endif #endif
#ifdef Log_x86Code #ifdef Log_x86Code
void Stop_x86_Log (void) { void Stop_x86_Log(void)
if (hCPULogFile) { {
if (hCPULogFile)
{
CloseHandle(hCPULogFile); CloseHandle(hCPULogFile);
hCPULogFile = NULL; hCPULogFile = NULL;
} }

View File

@ -1,3 +1,5 @@
#include <windows.h>
void StartCPULog(void); void StartCPULog(void);
void StopCPULog(void); void StopCPULog(void);
void CPU_Message(const char * Message, ...); void CPU_Message(const char * Message, ...);

View File

@ -1,36 +1,46 @@
enum { MaxMaps = 32 }; enum
{
MaxMaps = 32
};
#include <windows.h>
#include "Rsp.h"
#include "RSP Registers.h" #include "RSP Registers.h"
#include "Rsp.h"
#include <windows.h>
DWORD NoOfMaps, MapsCRC[MaxMaps]; DWORD NoOfMaps, MapsCRC[MaxMaps];
uint32_t Table; uint32_t Table;
BYTE *RecompCode, *RecompCodeSecondary, *RecompPos, *JumpTables; BYTE *RecompCode, *RecompCodeSecondary, *RecompPos, *JumpTables;
void ** JumpTable; void ** JumpTable;
int AllocateMemory (void) { int AllocateMemory(void)
if (RecompCode == NULL){ {
if (RecompCode == NULL)
{
RecompCode = (BYTE *)VirtualAlloc(NULL, 0x00400004, MEM_RESERVE, PAGE_EXECUTE_READWRITE); RecompCode = (BYTE *)VirtualAlloc(NULL, 0x00400004, MEM_RESERVE, PAGE_EXECUTE_READWRITE);
RecompCode = (BYTE *)VirtualAlloc(RecompCode, 0x00400000, MEM_COMMIT, PAGE_EXECUTE_READWRITE); RecompCode = (BYTE *)VirtualAlloc(RecompCode, 0x00400000, MEM_COMMIT, PAGE_EXECUTE_READWRITE);
if(RecompCode == NULL) { if (RecompCode == NULL)
{
DisplayError("Not enough memory for RSP RecompCode!"); DisplayError("Not enough memory for RSP RecompCode!");
return FALSE; return FALSE;
} }
} }
if (RecompCodeSecondary == NULL){ if (RecompCodeSecondary == NULL)
{
RecompCodeSecondary = (BYTE *)VirtualAlloc(NULL, 0x00200000, MEM_COMMIT, PAGE_EXECUTE_READWRITE); RecompCodeSecondary = (BYTE *)VirtualAlloc(NULL, 0x00200000, MEM_COMMIT, PAGE_EXECUTE_READWRITE);
if(RecompCodeSecondary == NULL) { if (RecompCodeSecondary == NULL)
{
DisplayError("Not enough memory for RSP RecompCode Secondary!"); DisplayError("Not enough memory for RSP RecompCode Secondary!");
return FALSE; return FALSE;
} }
} }
if (JumpTables == NULL){ if (JumpTables == NULL)
{
JumpTables = (BYTE *)VirtualAlloc(NULL, 0x1000 * MaxMaps, MEM_COMMIT, PAGE_READWRITE); JumpTables = (BYTE *)VirtualAlloc(NULL, 0x1000 * MaxMaps, MEM_COMMIT, PAGE_READWRITE);
if( JumpTables == NULL ) { if (JumpTables == NULL)
{
DisplayError("Not enough memory for jump table!"); DisplayError("Not enough memory for jump table!");
return FALSE; return FALSE;
} }
@ -42,7 +52,8 @@ int AllocateMemory (void) {
return TRUE; return TRUE;
} }
void FreeMemory (void) { void FreeMemory(void)
{
VirtualFree(RecompCode, 0, MEM_RELEASE); VirtualFree(RecompCode, 0, MEM_RELEASE);
VirtualFree(JumpTable, 0, MEM_RELEASE); VirtualFree(JumpTable, 0, MEM_RELEASE);
VirtualFree(RecompCodeSecondary, 0, MEM_RELEASE); VirtualFree(RecompCodeSecondary, 0, MEM_RELEASE);
@ -59,7 +70,8 @@ void ResetJumpTables ( void )
NoOfMaps = 0; NoOfMaps = 0;
} }
void SetJumpTable (uint32_t End) { void SetJumpTable(uint32_t End)
{
DWORD CRC, count; DWORD CRC, count;
CRC = 0; CRC = 0;
@ -73,19 +85,23 @@ void SetJumpTable (uint32_t End) {
End = 0x800; End = 0x800;
} }
for (count = 0; count < End; count += 0x40) { for (count = 0; count < End; count += 0x40)
{
CRC += *(DWORD *)(RSPInfo.IMEM + count); CRC += *(DWORD *)(RSPInfo.IMEM + count);
} }
for (count = 0; count < NoOfMaps; count++ ) { for (count = 0; count < NoOfMaps; count++)
if (CRC == MapsCRC[count]) { {
if (CRC == MapsCRC[count])
{
JumpTable = (void **)(JumpTables + count * 0x1000); JumpTable = (void **)(JumpTables + count * 0x1000);
Table = count; Table = count;
return; return;
} }
} }
//DisplayError("%X %X",NoOfMaps,CRC); //DisplayError("%X %X",NoOfMaps,CRC);
if (NoOfMaps == MaxMaps) { if (NoOfMaps == MaxMaps)
{
ResetJumpTables(); ResetJumpTables();
} }
MapsCRC[NoOfMaps] = CRC; MapsCRC[NoOfMaps] = CRC;
@ -94,34 +110,40 @@ void SetJumpTable (uint32_t End) {
NoOfMaps += 1; NoOfMaps += 1;
} }
void RSP_LB_DMEM ( uint32_t Addr, uint8_t * Value ) { void RSP_LB_DMEM(uint32_t Addr, uint8_t * Value)
{
*Value = *(uint8_t *)(RSPInfo.DMEM + ((Addr ^ 3) & 0xFFF)); *Value = *(uint8_t *)(RSPInfo.DMEM + ((Addr ^ 3) & 0xFFF));
} }
void RSP_LBV_DMEM ( uint32_t Addr, int vect, int element ) { void RSP_LBV_DMEM(uint32_t Addr, int vect, int element)
{
RSP_Vect[vect].B[15 - element] = *(RSPInfo.DMEM + ((Addr ^ 3) & 0xFFF)); RSP_Vect[vect].B[15 - element] = *(RSPInfo.DMEM + ((Addr ^ 3) & 0xFFF));
} }
void RSP_LDV_DMEM ( uint32_t Addr, int vect, int element ) { void RSP_LDV_DMEM(uint32_t Addr, int vect, int element)
{
int length, Count; int length, Count;
length = 8; length = 8;
if (length > 16 - element) { if (length > 16 - element)
{
length = 16 - element; length = 16 - element;
} }
for (Count = element; Count < (length + element); Count ++ ){ for (Count = element; Count < (length + element); Count++)
{
RSP_Vect[vect].B[15 - Count] = *(RSPInfo.DMEM + ((Addr ^ 3) & 0xFFF)); RSP_Vect[vect].B[15 - Count] = *(RSPInfo.DMEM + ((Addr ^ 3) & 0xFFF));
Addr += 1; Addr += 1;
} }
} }
void RSP_LFV_DMEM ( uint32_t Addr, int vect, int element ) { void RSP_LFV_DMEM(uint32_t Addr, int vect, int element)
{
int length, count; int length, count;
VECTOR Temp; VECTOR Temp;
length = 8; length = 8;
if (length > 16 - element) { if (length > 16 - element)
{
length = 16 - element; length = 16 - element;
} }
@ -134,14 +156,18 @@ void RSP_LFV_DMEM ( uint32_t Addr, int vect, int element ) {
Temp.HW[1] = *(RSPInfo.DMEM + (((Addr + ((0x10 - element) ^ 3) & 0xf)) & 0xFFF)) << 7; Temp.HW[1] = *(RSPInfo.DMEM + (((Addr + ((0x10 - element) ^ 3) & 0xf)) & 0xFFF)) << 7;
Temp.HW[0] = *(RSPInfo.DMEM + (((Addr + ((0x4 - element) ^ 3) & 0xf)) & 0xFFF)) << 7; Temp.HW[0] = *(RSPInfo.DMEM + (((Addr + ((0x4 - element) ^ 3) & 0xf)) & 0xFFF)) << 7;
for (count = element; count < (length + element); count ++ ){ for (count = element; count < (length + element); count++)
{
RSP_Vect[vect].B[15 - count] = Temp.B[15 - count]; RSP_Vect[vect].B[15 - count] = Temp.B[15 - count];
} }
} }
void RSP_LH_DMEM ( uint32_t Addr, uint16_t * Value ) { void RSP_LH_DMEM(uint32_t Addr, uint16_t * Value)
if ((Addr & 0x1) != 0) { {
if (Addr > 0xFFE) { if ((Addr & 0x1) != 0)
{
if (Addr > 0xFFE)
{
DisplayError("There is a problem with:\nRSP_LH_DMEM"); DisplayError("There is a problem with:\nRSP_LH_DMEM");
return; return;
} }
@ -153,7 +179,8 @@ void RSP_LH_DMEM ( uint32_t Addr, uint16_t * Value ) {
*Value = *(uint16_t *)(RSPInfo.DMEM + ((Addr ^ 2) & 0xFFF)); *Value = *(uint16_t *)(RSPInfo.DMEM + ((Addr ^ 2) & 0xFFF));
} }
void RSP_LHV_DMEM ( uint32_t Addr, int vect, int element ) { void RSP_LHV_DMEM(uint32_t Addr, int vect, int element)
{
RSP_Vect[vect].HW[7] = *(RSPInfo.DMEM + ((Addr + ((0x10 - element) & 0xF) ^ 3) & 0xFFF)) << 7; RSP_Vect[vect].HW[7] = *(RSPInfo.DMEM + ((Addr + ((0x10 - element) & 0xF) ^ 3) & 0xFFF)) << 7;
RSP_Vect[vect].HW[6] = *(RSPInfo.DMEM + ((Addr + ((0x10 - element + 2) & 0xF) ^ 3) & 0xFFF)) << 7; RSP_Vect[vect].HW[6] = *(RSPInfo.DMEM + ((Addr + ((0x10 - element + 2) & 0xF) ^ 3) & 0xFFF)) << 7;
RSP_Vect[vect].HW[5] = *(RSPInfo.DMEM + ((Addr + ((0x10 - element + 4) & 0xF) ^ 3) & 0xFFF)) << 7; RSP_Vect[vect].HW[5] = *(RSPInfo.DMEM + ((Addr + ((0x10 - element + 4) & 0xF) ^ 3) & 0xFFF)) << 7;
@ -164,21 +191,24 @@ void RSP_LHV_DMEM ( uint32_t Addr, int vect, int element ) {
RSP_Vect[vect].HW[0] = *(RSPInfo.DMEM + ((Addr + ((0x10 - element + 14) & 0xF) ^ 3) & 0xFFF)) << 7; RSP_Vect[vect].HW[0] = *(RSPInfo.DMEM + ((Addr + ((0x10 - element + 14) & 0xF) ^ 3) & 0xFFF)) << 7;
} }
void RSP_LLV_DMEM ( uint32_t Addr, int vect, int element ) { void RSP_LLV_DMEM(uint32_t Addr, int vect, int element)
{
int length, Count; int length, Count;
length = 4; length = 4;
if (length > 16 - element) { if (length > 16 - element)
{
length = 16 - element; length = 16 - element;
} }
for (Count = element; Count < (length + element); Count ++ ){ for (Count = element; Count < (length + element); Count++)
{
RSP_Vect[vect].B[15 - Count] = *(RSPInfo.DMEM + ((Addr ^ 3) & 0xFFF)); RSP_Vect[vect].B[15 - Count] = *(RSPInfo.DMEM + ((Addr ^ 3) & 0xFFF));
Addr += 1; Addr += 1;
} }
} }
void RSP_LPV_DMEM ( uint32_t Addr, int vect, int element ) { void RSP_LPV_DMEM(uint32_t Addr, int vect, int element)
{
RSP_Vect[vect].HW[7] = *(RSPInfo.DMEM + ((Addr + ((0x10 - element) & 0xF) ^ 3) & 0xFFF)) << 8; RSP_Vect[vect].HW[7] = *(RSPInfo.DMEM + ((Addr + ((0x10 - element) & 0xF) ^ 3) & 0xFFF)) << 8;
RSP_Vect[vect].HW[6] = *(RSPInfo.DMEM + ((Addr + ((0x10 - element + 1) & 0xF) ^ 3) & 0xFFF)) << 8; RSP_Vect[vect].HW[6] = *(RSPInfo.DMEM + ((Addr + ((0x10 - element + 1) & 0xF) ^ 3) & 0xFFF)) << 8;
RSP_Vect[vect].HW[5] = *(RSPInfo.DMEM + ((Addr + ((0x10 - element + 2) & 0xF) ^ 3) & 0xFFF)) << 8; RSP_Vect[vect].HW[5] = *(RSPInfo.DMEM + ((Addr + ((0x10 - element + 2) & 0xF) ^ 3) & 0xFFF)) << 8;
@ -189,56 +219,65 @@ void RSP_LPV_DMEM ( uint32_t Addr, int vect, int element ) {
RSP_Vect[vect].HW[0] = *(RSPInfo.DMEM + ((Addr + ((0x10 - element + 7) & 0xF) ^ 3) & 0xFFF)) << 8; RSP_Vect[vect].HW[0] = *(RSPInfo.DMEM + ((Addr + ((0x10 - element + 7) & 0xF) ^ 3) & 0xFFF)) << 8;
} }
void RSP_LRV_DMEM ( uint32_t Addr, int vect, int element ) { void RSP_LRV_DMEM(uint32_t Addr, int vect, int element)
{
int length, Count, offset; int length, Count, offset;
offset = (Addr & 0xF) - 1; offset = (Addr & 0xF) - 1;
length = (Addr & 0xF) - element; length = (Addr & 0xF) - element;
Addr &= 0xFF0; Addr &= 0xFF0;
for (Count = element; Count < (length + element); Count ++ ){ for (Count = element; Count < (length + element); Count++)
{
RSP_Vect[vect].B[offset - Count] = *(RSPInfo.DMEM + ((Addr ^ 3) & 0xFFF)); RSP_Vect[vect].B[offset - Count] = *(RSPInfo.DMEM + ((Addr ^ 3) & 0xFFF));
Addr += 1; Addr += 1;
} }
} }
void RSP_LQV_DMEM ( uint32_t Addr, int vect, int element ) { void RSP_LQV_DMEM(uint32_t Addr, int vect, int element)
{
int length, Count; int length, Count;
length = ((Addr + 0x10) & ~0xF) - Addr; length = ((Addr + 0x10) & ~0xF) - Addr;
if (length > 16 - element) { if (length > 16 - element)
{
length = 16 - element; length = 16 - element;
} }
for (Count = element; Count < (length + element); Count ++ ){ for (Count = element; Count < (length + element); Count++)
{
RSP_Vect[vect].B[15 - Count] = *(RSPInfo.DMEM + ((Addr ^ 3) & 0xFFF)); RSP_Vect[vect].B[15 - Count] = *(RSPInfo.DMEM + ((Addr ^ 3) & 0xFFF));
Addr += 1; Addr += 1;
} }
} }
void RSP_LSV_DMEM ( uint32_t Addr, int vect, int element ) { void RSP_LSV_DMEM(uint32_t Addr, int vect, int element)
{
int length, Count; int length, Count;
length = 2; length = 2;
if (length > 16 - element) { if (length > 16 - element)
{
length = 16 - element; length = 16 - element;
} }
for (Count = element; Count < (length + element); Count ++ ){ for (Count = element; Count < (length + element); Count++)
{
RSP_Vect[vect].B[15 - Count] = *(RSPInfo.DMEM + ((Addr ^ 3) & 0xFFF)); RSP_Vect[vect].B[15 - Count] = *(RSPInfo.DMEM + ((Addr ^ 3) & 0xFFF));
Addr += 1; Addr += 1;
} }
} }
void RSP_LTV_DMEM ( uint32_t Addr, int vect, int element ) { void RSP_LTV_DMEM(uint32_t Addr, int vect, int element)
{
int del, count, length; int del, count, length;
length = 8; length = 8;
if (length > 32 - vect) { if (length > 32 - vect)
{
length = 32 - vect; length = 32 - vect;
} }
Addr = ((Addr + 8) & 0xFF0) + (element & 0x1); Addr = ((Addr + 8) & 0xFF0) + (element & 0x1);
for (count = 0; count < length; count ++) { for (count = 0; count < length; count++)
{
del = ((8 - (element >> 1) + count) << 1) & 0xF; del = ((8 - (element >> 1) + count) << 1) & 0xF;
RSP_Vect[vect + count].B[15 - del] = *(RSPInfo.DMEM + (Addr ^ 3)); RSP_Vect[vect + count].B[15 - del] = *(RSPInfo.DMEM + (Addr ^ 3));
RSP_Vect[vect + count].B[14 - del] = *(RSPInfo.DMEM + ((Addr + 1) ^ 3)); RSP_Vect[vect + count].B[14 - del] = *(RSPInfo.DMEM + ((Addr + 1) ^ 3));
@ -246,7 +285,8 @@ void RSP_LTV_DMEM ( uint32_t Addr, int vect, int element ) {
} }
} }
void RSP_LUV_DMEM ( uint32_t Addr, int vect, int element ) { void RSP_LUV_DMEM(uint32_t Addr, int vect, int element)
{
RSP_Vect[vect].HW[7] = *(RSPInfo.DMEM + ((Addr + ((0x10 - element) & 0xF) ^ 3) & 0xFFF)) << 7; RSP_Vect[vect].HW[7] = *(RSPInfo.DMEM + ((Addr + ((0x10 - element) & 0xF) ^ 3) & 0xFFF)) << 7;
RSP_Vect[vect].HW[6] = *(RSPInfo.DMEM + ((Addr + ((0x10 - element + 1) & 0xF) ^ 3) & 0xFFF)) << 7; RSP_Vect[vect].HW[6] = *(RSPInfo.DMEM + ((Addr + ((0x10 - element + 1) & 0xF) ^ 3) & 0xFFF)) << 7;
RSP_Vect[vect].HW[5] = *(RSPInfo.DMEM + ((Addr + ((0x10 - element + 2) & 0xF) ^ 3) & 0xFFF)) << 7; RSP_Vect[vect].HW[5] = *(RSPInfo.DMEM + ((Addr + ((0x10 - element + 2) & 0xF) ^ 3) & 0xFFF)) << 7;
@ -257,10 +297,13 @@ void RSP_LUV_DMEM ( uint32_t Addr, int vect, int element ) {
RSP_Vect[vect].HW[0] = *(RSPInfo.DMEM + ((Addr + ((0x10 - element + 7) & 0xF) ^ 3) & 0xFFF)) << 7; RSP_Vect[vect].HW[0] = *(RSPInfo.DMEM + ((Addr + ((0x10 - element + 7) & 0xF) ^ 3) & 0xFFF)) << 7;
} }
void RSP_LW_DMEM ( uint32_t Addr, uint32_t * Value ) { void RSP_LW_DMEM(uint32_t Addr, uint32_t * Value)
if ((Addr & 0x3) != 0) { {
if ((Addr & 0x3) != 0)
{
Addr &= 0xFFF; Addr &= 0xFFF;
if (Addr > 0xFFC) { if (Addr > 0xFFC)
{
DisplayError("There is a problem with:\nRSP_LW_DMEM"); DisplayError("There is a problem with:\nRSP_LW_DMEM");
return; return;
} }
@ -273,35 +316,43 @@ void RSP_LW_DMEM ( uint32_t Addr, uint32_t * Value ) {
*Value = *(uint32_t *)(RSPInfo.DMEM + (Addr & 0xFFF)); *Value = *(uint32_t *)(RSPInfo.DMEM + (Addr & 0xFFF));
} }
void RSP_LW_IMEM ( uint32_t Addr, uint32_t * Value ) { void RSP_LW_IMEM(uint32_t Addr, uint32_t * Value)
if ((Addr & 0x3) != 0) { {
if ((Addr & 0x3) != 0)
{
DisplayError("Unaligned RSP_LW_IMEM"); DisplayError("Unaligned RSP_LW_IMEM");
} }
*Value = *(uint32_t *)(RSPInfo.IMEM + (Addr & 0xFFF)); *Value = *(uint32_t *)(RSPInfo.IMEM + (Addr & 0xFFF));
} }
void RSP_SB_DMEM ( uint32_t Addr, uint8_t Value ) { void RSP_SB_DMEM(uint32_t Addr, uint8_t Value)
{
*(uint8_t *)(RSPInfo.DMEM + ((Addr ^ 3) & 0xFFF)) = Value; *(uint8_t *)(RSPInfo.DMEM + ((Addr ^ 3) & 0xFFF)) = Value;
} }
void RSP_SBV_DMEM ( uint32_t Addr, int vect, int element ) { void RSP_SBV_DMEM(uint32_t Addr, int vect, int element)
{
*(RSPInfo.DMEM + ((Addr ^ 3) & 0xFFF)) = RSP_Vect[vect].B[15 - element]; *(RSPInfo.DMEM + ((Addr ^ 3) & 0xFFF)) = RSP_Vect[vect].B[15 - element];
} }
void RSP_SDV_DMEM ( uint32_t Addr, int vect, int element ) { void RSP_SDV_DMEM(uint32_t Addr, int vect, int element)
{
int Count; int Count;
for (Count = element; Count < (8 + element); Count ++ ){ for (Count = element; Count < (8 + element); Count++)
{
*(RSPInfo.DMEM + ((Addr ^ 3) & 0xFFF)) = RSP_Vect[vect].B[15 - (Count & 0xF)]; *(RSPInfo.DMEM + ((Addr ^ 3) & 0xFFF)) = RSP_Vect[vect].B[15 - (Count & 0xF)];
Addr += 1; Addr += 1;
} }
} }
void RSP_SFV_DMEM ( uint32_t Addr, int vect, int element ) { void RSP_SFV_DMEM(uint32_t Addr, int vect, int element)
{
int offset = Addr & 0xF; int offset = Addr & 0xF;
Addr &= 0xFF0; Addr &= 0xFF0;
switch (element) { switch (element)
{
case 0: case 0:
*(RSPInfo.DMEM + ((Addr + offset) ^ 3)) = (RSP_Vect[vect].UHW[7] >> 7) & 0xFF; *(RSPInfo.DMEM + ((Addr + offset) ^ 3)) = (RSP_Vect[vect].UHW[7] >> 7) & 0xFF;
*(RSPInfo.DMEM + ((Addr + ((offset + 4) & 0xF)) ^ 3)) = (RSP_Vect[vect].UHW[6] >> 7) & 0xFF; *(RSPInfo.DMEM + ((Addr + ((offset + 4) & 0xF)) ^ 3)) = (RSP_Vect[vect].UHW[6] >> 7) & 0xFF;
@ -401,15 +452,18 @@ void RSP_SFV_DMEM ( uint32_t Addr, int vect, int element ) {
} }
} }
void RSP_SH_DMEM ( uint32_t Addr, uint16_t Value ) { void RSP_SH_DMEM(uint32_t Addr, uint16_t Value)
if ((Addr & 0x1) != 0) { {
if ((Addr & 0x1) != 0)
{
DisplayError("Unaligned RSP_SH_DMEM"); DisplayError("Unaligned RSP_SH_DMEM");
return; return;
} }
*(uint16_t *)(RSPInfo.DMEM + ((Addr ^ 2) & 0xFFF)) = Value; *(uint16_t *)(RSPInfo.DMEM + ((Addr ^ 2) & 0xFFF)) = Value;
} }
void RSP_SHV_DMEM ( uint32_t Addr, int vect, int element ) { void RSP_SHV_DMEM(uint32_t Addr, int vect, int element)
{
*(RSPInfo.DMEM + ((Addr ^ 3) & 0xFFF)) = (RSP_Vect[vect].UB[(15 - element) & 0xF] << 1) + *(RSPInfo.DMEM + ((Addr ^ 3) & 0xFFF)) = (RSP_Vect[vect].UB[(15 - element) & 0xF] << 1) +
(RSP_Vect[vect].UB[(14 - element) & 0xF] >> 7); (RSP_Vect[vect].UB[(14 - element) & 0xF] >> 7);
*(RSPInfo.DMEM + (((Addr + 2) ^ 3) & 0xFFF)) = (RSP_Vect[vect].UB[(13 - element) & 0xF] << 1) + *(RSPInfo.DMEM + (((Addr + 2) ^ 3) & 0xFFF)) = (RSP_Vect[vect].UB[(13 - element) & 0xF] << 1) +
@ -428,22 +482,29 @@ void RSP_SHV_DMEM ( uint32_t Addr, int vect, int element ) {
(RSP_Vect[vect].UB[(0 - element) & 0xF] >> 7); (RSP_Vect[vect].UB[(0 - element) & 0xF] >> 7);
} }
void RSP_SLV_DMEM ( uint32_t Addr, int vect, int element ) { void RSP_SLV_DMEM(uint32_t Addr, int vect, int element)
{
int Count; int Count;
for (Count = element; Count < (4 + element); Count ++ ){ for (Count = element; Count < (4 + element); Count++)
{
*(RSPInfo.DMEM + ((Addr ^ 3) & 0xFFF)) = RSP_Vect[vect].B[15 - (Count & 0xF)]; *(RSPInfo.DMEM + ((Addr ^ 3) & 0xFFF)) = RSP_Vect[vect].B[15 - (Count & 0xF)];
Addr += 1; Addr += 1;
} }
} }
void RSP_SPV_DMEM ( uint32_t Addr, int vect, int element ) { void RSP_SPV_DMEM(uint32_t Addr, int vect, int element)
{
int Count; int Count;
for (Count = element; Count < (8 + element); Count ++ ){ for (Count = element; Count < (8 + element); Count++)
if (((Count) & 0xF) < 8) { {
if (((Count)&0xF) < 8)
{
*(RSPInfo.DMEM + ((Addr ^ 3) & 0xFFF)) = RSP_Vect[vect].UB[15 - ((Count & 0xF) << 1)]; *(RSPInfo.DMEM + ((Addr ^ 3) & 0xFFF)) = RSP_Vect[vect].UB[15 - ((Count & 0xF) << 1)];
} else { }
else
{
*(RSPInfo.DMEM + ((Addr ^ 3) & 0xFFF)) = (RSP_Vect[vect].UB[15 - ((Count & 0x7) << 1)] << 1) + *(RSPInfo.DMEM + ((Addr ^ 3) & 0xFFF)) = (RSP_Vect[vect].UB[15 - ((Count & 0x7) << 1)] << 1) +
(RSP_Vect[vect].UB[14 - ((Count & 0x7) << 1)] >> 7); (RSP_Vect[vect].UB[14 - ((Count & 0x7) << 1)] >> 7);
} }
@ -451,47 +512,56 @@ void RSP_SPV_DMEM ( uint32_t Addr, int vect, int element ) {
} }
} }
void RSP_SQV_DMEM ( uint32_t Addr, int vect, int element ) { void RSP_SQV_DMEM(uint32_t Addr, int vect, int element)
{
int length, Count; int length, Count;
length = ((Addr + 0x10) & ~0xF) - Addr; length = ((Addr + 0x10) & ~0xF) - Addr;
for (Count = element; Count < (length + element); Count ++ ){ for (Count = element; Count < (length + element); Count++)
{
*(RSPInfo.DMEM + ((Addr ^ 3) & 0xFFF)) = RSP_Vect[vect].B[15 - (Count & 0xF)]; *(RSPInfo.DMEM + ((Addr ^ 3) & 0xFFF)) = RSP_Vect[vect].B[15 - (Count & 0xF)];
Addr += 1; Addr += 1;
} }
} }
void RSP_SRV_DMEM ( uint32_t Addr, int vect, int element ) { void RSP_SRV_DMEM(uint32_t Addr, int vect, int element)
{
int length, Count, offset; int length, Count, offset;
length = (Addr & 0xF); length = (Addr & 0xF);
offset = (0x10 - length) & 0xF; offset = (0x10 - length) & 0xF;
Addr &= 0xFF0; Addr &= 0xFF0;
for (Count = element; Count < (length + element); Count ++ ){ for (Count = element; Count < (length + element); Count++)
{
*(RSPInfo.DMEM + ((Addr ^ 3) & 0xFFF)) = RSP_Vect[vect].B[15 - ((Count + offset) & 0xF)]; *(RSPInfo.DMEM + ((Addr ^ 3) & 0xFFF)) = RSP_Vect[vect].B[15 - ((Count + offset) & 0xF)];
Addr += 1; Addr += 1;
} }
} }
void RSP_SSV_DMEM ( uint32_t Addr, int vect, int element ) { void RSP_SSV_DMEM(uint32_t Addr, int vect, int element)
{
int Count; int Count;
for (Count = element; Count < (2 + element); Count ++ ){ for (Count = element; Count < (2 + element); Count++)
{
*(RSPInfo.DMEM + ((Addr ^ 3) & 0xFFF)) = RSP_Vect[vect].B[15 - (Count & 0xF)]; *(RSPInfo.DMEM + ((Addr ^ 3) & 0xFFF)) = RSP_Vect[vect].B[15 - (Count & 0xF)];
Addr += 1; Addr += 1;
} }
} }
void RSP_STV_DMEM ( uint32_t Addr, int vect, int element ) { void RSP_STV_DMEM(uint32_t Addr, int vect, int element)
{
int del, count, length; int del, count, length;
length = 8; length = 8;
if (length > 32 - vect) { if (length > 32 - vect)
{
length = 32 - vect; length = 32 - vect;
} }
length = length << 1; length = length << 1;
del = element >> 1; del = element >> 1;
for (count = 0; count < length; count += 2) { for (count = 0; count < length; count += 2)
{
*(RSPInfo.DMEM + ((Addr ^ 3) & 0xFFF)) = RSP_Vect[vect + del].UB[15 - count]; *(RSPInfo.DMEM + ((Addr ^ 3) & 0xFFF)) = RSP_Vect[vect + del].UB[15 - count];
*(RSPInfo.DMEM + (((Addr + 1) ^ 3) & 0xFFF)) = RSP_Vect[vect + del].UB[14 - count]; *(RSPInfo.DMEM + (((Addr + 1) ^ 3) & 0xFFF)) = RSP_Vect[vect + del].UB[14 - count];
del = (del + 1) & 7; del = (del + 1) & 7;
@ -499,24 +569,33 @@ void RSP_STV_DMEM ( uint32_t Addr, int vect, int element ) {
} }
} }
void RSP_SUV_DMEM ( uint32_t Addr, int vect, int element ) { void RSP_SUV_DMEM(uint32_t Addr, int vect, int element)
{
int Count; int Count;
for (Count = element; Count < (8 + element); Count ++ ){ for (Count = element; Count < (8 + element); Count++)
if (((Count) & 0xF) < 8) { {
if (((Count)&0xF) < 8)
{
*(RSPInfo.DMEM + ((Addr ^ 3) & 0xFFF)) = ((RSP_Vect[vect].UB[15 - ((Count & 0x7) << 1)] << 1) + *(RSPInfo.DMEM + ((Addr ^ 3) & 0xFFF)) = ((RSP_Vect[vect].UB[15 - ((Count & 0x7) << 1)] << 1) +
(RSP_Vect[vect].UB[14 - ((Count & 0x7) << 1)] >> 7)) & 0xFF; (RSP_Vect[vect].UB[14 - ((Count & 0x7) << 1)] >> 7)) &
} else { 0xFF;
}
else
{
*(RSPInfo.DMEM + ((Addr ^ 3) & 0xFFF)) = RSP_Vect[vect].UB[15 - ((Count & 0x7) << 1)]; *(RSPInfo.DMEM + ((Addr ^ 3) & 0xFFF)) = RSP_Vect[vect].UB[15 - ((Count & 0x7) << 1)];
} }
Addr += 1; Addr += 1;
} }
} }
void RSP_SW_DMEM ( uint32_t Addr, uint32_t Value ) { void RSP_SW_DMEM(uint32_t Addr, uint32_t Value)
{
Addr &= 0xFFF; Addr &= 0xFFF;
if ((Addr & 0x3) != 0) { if ((Addr & 0x3) != 0)
if (Addr > 0xFFC) { {
if (Addr > 0xFFC)
{
DisplayError("There is a problem with:\nRSP_SW_DMEM"); DisplayError("There is a problem with:\nRSP_SW_DMEM");
return; return;
} }
@ -529,12 +608,14 @@ void RSP_SW_DMEM ( uint32_t Addr, uint32_t Value ) {
*(uint32_t *)(RSPInfo.DMEM + Addr) = Value; *(uint32_t *)(RSPInfo.DMEM + Addr) = Value;
} }
void RSP_SWV_DMEM ( uint32_t Addr, int vect, int element ) { void RSP_SWV_DMEM(uint32_t Addr, int vect, int element)
{
int Count, offset; int Count, offset;
offset = Addr & 0xF; offset = Addr & 0xF;
Addr &= 0xFF0; Addr &= 0xFF0;
for (Count = element; Count < (16 + element); Count ++ ){ for (Count = element; Count < (16 + element); Count++)
{
*(RSPInfo.DMEM + ((Addr + (offset & 0xF)) ^ 3)) = RSP_Vect[vect].B[15 - (Count & 0xF)]; *(RSPInfo.DMEM + ((Addr + (offset & 0xF)) ^ 3)) = RSP_Vect[vect].B[15 - (Count & 0xF)];
offset += 1; offset += 1;
} }

View File

@ -9,12 +9,15 @@ cd /d %origdir%
set ScanDir[0]="%base_dir%\Source\Common" set ScanDir[0]="%base_dir%\Source\Common"
set ScanDir[1]="%base_dir%\Source\Project64" set ScanDir[1]="%base_dir%\Source\Project64"
set ScanDir[2]="%base_dir%\Source\Project64-core" set ScanDir[2]="%base_dir%\Source\Project64-core"
set ScanDir[3]="%base_dir%\Source\RSP"
set ScanFiles[0]="*.cpp" set ScanFiles[0]="*.cpp"
set ScanFiles[1]="*.h" set ScanFiles[1]="*.h"
set Exclude[0]="%base_dir%\Source\Project64-core\Version.h" set Exclude[0]="%base_dir%\Source\Project64-core\Version.h"
set Exclude[1]="%base_dir%\Source\Project64\UserInterface\resource.h" set Exclude[1]="%base_dir%\Source\Project64\UserInterface\resource.h"
set Exclude[2]="%base_dir%\Source\RSP\Version.h"
set Exclude[3]="%base_dir%\Source\RSP\resource.h"
set ValidParam=0 set ValidParam=0
if "%1" == "check" set ValidParam=1 if "%1" == "check" set ValidParam=1