RSP: Remove PrgCount as a global
This commit is contained in:
parent
d9ae43b69d
commit
29c49a2063
Source
Project64-rsp-core
Project64-rsp
|
@ -663,7 +663,7 @@ Resolves all the collected branches, x86 style
|
|||
|
||||
void CRSPRecompiler::LinkBranches(RSP_BLOCK * Block)
|
||||
{
|
||||
uint32_t OrigPrgCount = *PrgCount;
|
||||
uint32_t OrigPrgCount = *m_System.m_SP_PC_REG;
|
||||
uint32_t Count, Target;
|
||||
uint32_t * JumpWord;
|
||||
uint8_t * X86Code;
|
||||
|
@ -682,7 +682,7 @@ void CRSPRecompiler::LinkBranches(RSP_BLOCK * Block)
|
|||
|
||||
if (!X86Code)
|
||||
{
|
||||
*PrgCount = Target;
|
||||
*m_System.m_SP_PC_REG = Target;
|
||||
CPU_Message("");
|
||||
CPU_Message("===== (Generate code: %04X) =====", Target);
|
||||
Save = *Block;
|
||||
|
@ -703,7 +703,7 @@ void CRSPRecompiler::LinkBranches(RSP_BLOCK * Block)
|
|||
CPU_Message("Linked RSP branch from x86: %08X, to RSP: %X / x86: %08X",
|
||||
JumpWord, Target, X86Code);
|
||||
}
|
||||
*PrgCount = OrigPrgCount;
|
||||
*m_System.m_SP_PC_REG = OrigPrgCount;
|
||||
CPU_Message("***** Done linking branches *****");
|
||||
CPU_Message("");
|
||||
}
|
||||
|
@ -813,7 +813,7 @@ void CRSPRecompiler::CompilerRSPBlock(void)
|
|||
uint8_t * IMEM_SAVE = (uint8_t *)malloc(0x1000);
|
||||
const size_t X86BaseAddress = (size_t)RecompPos;
|
||||
NextInstruction = RSPPIPELINE_NORMAL;
|
||||
CompilePC = *PrgCount;
|
||||
CompilePC = *m_System.m_SP_PC_REG;
|
||||
|
||||
memset(&m_CurrentBlock, 0, sizeof(m_CurrentBlock));
|
||||
m_CurrentBlock.StartPC = CompilePC;
|
||||
|
@ -946,15 +946,15 @@ void CRSPRecompiler::CompilerRSPBlock(void)
|
|||
break;
|
||||
}
|
||||
|
||||
if (CompilePC >= EndPC && *PrgCount != 0 && EndPC != *PrgCount)
|
||||
if (CompilePC >= EndPC && *m_System.m_SP_PC_REG != 0 && EndPC != *m_System.m_SP_PC_REG)
|
||||
{
|
||||
CompilePC = 0;
|
||||
EndPC = *PrgCount;
|
||||
EndPC = *m_System.m_SP_PC_REG;
|
||||
}
|
||||
} while (NextInstruction != RSPPIPELINE_FINISH_BLOCK && (CompilePC < EndPC || NextInstruction == RSPPIPELINE_DELAY_SLOT || NextInstruction == RSPPIPELINE_DELAY_SLOT_DONE));
|
||||
if (CompilePC >= EndPC)
|
||||
{
|
||||
MoveConstToVariable((CompilePC & 0xFFC), PrgCount, "RSP PC");
|
||||
MoveConstToVariable((CompilePC & 0xFFC), m_System.m_SP_PC_REG, "RSP PC");
|
||||
Ret();
|
||||
}
|
||||
CPU_Message("===== End of recompiled code =====");
|
||||
|
@ -979,7 +979,7 @@ void CRSPRecompiler::RunCPU(void)
|
|||
|
||||
while (RSP_Running)
|
||||
{
|
||||
Block = (uint8_t *)*(JumpTable + (*PrgCount >> 2));
|
||||
Block = (uint8_t *)*(JumpTable + (*m_System.m_SP_PC_REG >> 2));
|
||||
|
||||
if (Block == NULL)
|
||||
{
|
||||
|
@ -1010,7 +1010,7 @@ void CRSPRecompiler::RunCPU(void)
|
|||
CompilerRSPBlock();
|
||||
#endif
|
||||
|
||||
Block = (uint8_t *)*(JumpTable + (*PrgCount >> 2));
|
||||
Block = (uint8_t *)*(JumpTable + (*m_System.m_SP_PC_REG >> 2));
|
||||
|
||||
// We are done compiling, but we may have references
|
||||
// to fill in still either from this block, or jumps
|
||||
|
@ -1025,7 +1025,7 @@ void CRSPRecompiler::RunCPU(void)
|
|||
|
||||
if (Profiling && IndvidualBlock)
|
||||
{
|
||||
StartTimer(*PrgCount);
|
||||
StartTimer(*m_System.m_SP_PC_REG);
|
||||
}
|
||||
|
||||
#if defined(_M_IX86) && defined(_MSC_VER)
|
||||
|
|
|
@ -141,7 +141,7 @@ void BreakPoint()
|
|||
*(RecompPos++) = 0xCC;
|
||||
}
|
||||
|
||||
void CompileBranchExit(uint32_t TargetPC, uint32_t ContinuePC)
|
||||
void CRSPRecompilerOps::CompileBranchExit(uint32_t TargetPC, uint32_t ContinuePC)
|
||||
{
|
||||
uint32_t * X86Loc = NULL;
|
||||
|
||||
|
@ -149,12 +149,12 @@ void CompileBranchExit(uint32_t TargetPC, uint32_t ContinuePC)
|
|||
CompConstToVariable(true, &BranchCompare, "BranchCompare");
|
||||
JeLabel32("BranchEqual", 0);
|
||||
X86Loc = (uint32_t *)(RecompPos - 4);
|
||||
MoveConstToVariable(ContinuePC, PrgCount, "RSP PC");
|
||||
MoveConstToVariable(ContinuePC, m_System.m_SP_PC_REG, "RSP PC");
|
||||
Ret();
|
||||
|
||||
CPU_Message("BranchEqual:");
|
||||
x86_SetBranch32b(X86Loc, RecompPos);
|
||||
MoveConstToVariable(TargetPC, PrgCount, "RSP PC");
|
||||
MoveConstToVariable(TargetPC, m_System.m_SP_PC_REG, "RSP PC");
|
||||
Ret();
|
||||
}
|
||||
|
||||
|
@ -198,7 +198,7 @@ void CRSPRecompilerOps::J(void)
|
|||
}
|
||||
else if (NextInstruction == RSPPIPELINE_DELAY_SLOT_EXIT_DONE)
|
||||
{
|
||||
MoveConstToVariable((m_OpCode.target << 2) & 0xFFC, PrgCount, "RSP PC");
|
||||
MoveConstToVariable((m_OpCode.target << 2) & 0xFFC, m_System.m_SP_PC_REG, "RSP PC");
|
||||
NextInstruction = RSPPIPELINE_FINISH_SUB_BLOCK;
|
||||
Ret();
|
||||
}
|
||||
|
@ -225,7 +225,7 @@ void CRSPRecompilerOps::JAL(void)
|
|||
char Str[40];
|
||||
sprintf(Str, "%03X", (m_OpCode.target << 2) & 0xFFC);
|
||||
Push(x86_EAX);
|
||||
PushImm32(Str, *PrgCount);
|
||||
PushImm32(Str, *m_System.m_SP_PC_REG);
|
||||
Call_Direct((void *)StartTimer, "StartTimer");
|
||||
AddConstToX86Reg(x86_ESP, 4);
|
||||
Pop(x86_EAX);
|
||||
|
@ -236,7 +236,7 @@ void CRSPRecompilerOps::JAL(void)
|
|||
}
|
||||
else if (NextInstruction == RSPPIPELINE_DELAY_SLOT_EXIT_DONE)
|
||||
{
|
||||
MoveConstToVariable((m_OpCode.target << 2) & 0xFFC, PrgCount, "RSP PC");
|
||||
MoveConstToVariable((m_OpCode.target << 2) & 0xFFC, m_System.m_SP_PC_REG, "RSP PC");
|
||||
NextInstruction = RSPPIPELINE_FINISH_SUB_BLOCK;
|
||||
Ret();
|
||||
}
|
||||
|
@ -1480,7 +1480,7 @@ void CRSPRecompilerOps::Special_SRAV(void)
|
|||
void UpdateAudioTimer()
|
||||
{
|
||||
/* char Label[100];
|
||||
sprintf(Label,"COMMAND: %02X (PC = %08X)",m_GPR[1].UW >> 1, *PrgCount);
|
||||
sprintf(Label,"COMMAND: %02X (PC = %08X)",m_GPR[1].UW >> 1, *m_System.m_SP_PC_REG);
|
||||
StartTimer(Label);*/
|
||||
}
|
||||
|
||||
|
@ -1491,16 +1491,16 @@ void CRSPRecompilerOps::Special_JR(void)
|
|||
if (NextInstruction == RSPPIPELINE_NORMAL)
|
||||
{
|
||||
CPU_Message(" %X %s", CompilePC, RSPInstruction(CompilePC, m_OpCode.Value).NameAndParam().c_str());
|
||||
// Transfer destination to location pointed to by PrgCount
|
||||
// Transfer destination to location pointed to by m_System.m_SP_PC_REG
|
||||
MoveVariableToX86reg(&m_GPR[m_OpCode.rs].W, GPR_Name(m_OpCode.rs), x86_EAX);
|
||||
AndConstToX86Reg(x86_EAX, 0xFFC);
|
||||
MoveX86regToVariable(x86_EAX, PrgCount, "RSP PC");
|
||||
MoveX86regToVariable(x86_EAX, m_System.m_SP_PC_REG, "RSP PC");
|
||||
ChangedPC = true;
|
||||
NextInstruction = RSPPIPELINE_DO_DELAY_SLOT;
|
||||
}
|
||||
else if (NextInstruction == RSPPIPELINE_DELAY_SLOT_DONE)
|
||||
{
|
||||
MoveVariableToX86reg(PrgCount, "RSP PC", x86_EAX);
|
||||
MoveVariableToX86reg(m_System.m_SP_PC_REG, "RSP PC", x86_EAX);
|
||||
if (Profiling && IndvidualBlock)
|
||||
{
|
||||
Push(x86_EAX);
|
||||
|
@ -1552,13 +1552,13 @@ void CRSPRecompilerOps::Special_JALR(void)
|
|||
CPU_Message(" %X %s", CompilePC, RSPInstruction(CompilePC, m_OpCode.Value).NameAndParam().c_str());
|
||||
MoveVariableToX86reg(&m_GPR[m_OpCode.rs].W, GPR_Name(m_OpCode.rs), x86_EAX);
|
||||
AndConstToX86Reg(x86_EAX, 0xFFC);
|
||||
MoveX86regToVariable(x86_EAX, PrgCount, "RSP PC");
|
||||
MoveX86regToVariable(x86_EAX, m_System.m_SP_PC_REG, "RSP PC");
|
||||
MoveConstToVariable(Const, &m_GPR[m_OpCode.rd].W, GPR_Name(m_OpCode.rd));
|
||||
NextInstruction = RSPPIPELINE_DO_DELAY_SLOT;
|
||||
}
|
||||
else if (NextInstruction == RSPPIPELINE_DELAY_SLOT_DONE)
|
||||
{
|
||||
MoveVariableToX86reg(PrgCount, "RSP PC", x86_EAX);
|
||||
MoveVariableToX86reg(m_System.m_SP_PC_REG, "RSP PC", x86_EAX);
|
||||
AddVariableToX86reg(x86_EAX, &JumpTable, "JumpTable");
|
||||
MoveX86regPointerToX86reg(x86_EAX, x86_EAX);
|
||||
|
||||
|
@ -1589,7 +1589,7 @@ void CRSPRecompilerOps::Special_BREAK(void)
|
|||
Cheat_r4300iOpcode(&RSPOp::Special_BREAK, "RSPOp::Special_BREAK");
|
||||
if (NextInstruction == RSPPIPELINE_NORMAL)
|
||||
{
|
||||
MoveConstToVariable(CompilePC + 4, PrgCount, "RSP PC");
|
||||
MoveConstToVariable(CompilePC + 4, m_System.m_SP_PC_REG, "RSP PC");
|
||||
Ret();
|
||||
NextInstruction = RSPPIPELINE_FINISH_SUB_BLOCK;
|
||||
}
|
||||
|
@ -2181,7 +2181,7 @@ void CRSPRecompilerOps::Cop0_MF(void)
|
|||
Cheat_r4300iOpcode(RSP_Cop0_MF, "RSP_Cop0_MF");
|
||||
if (NextInstruction == RSPPIPELINE_NORMAL)
|
||||
{
|
||||
MoveConstToVariable(CompilePC + 4, PrgCount, "RSP PC");
|
||||
MoveConstToVariable(CompilePC + 4, m_System.m_SP_PC_REG, "RSP PC");
|
||||
Ret();
|
||||
NextInstruction = RSPPIPELINE_FINISH_SUB_BLOCK;
|
||||
}
|
||||
|
@ -2249,7 +2249,7 @@ void CRSPRecompilerOps::Cop0_MF(void)
|
|||
MoveX86regToVariable(x86_EAX, &m_GPR[m_OpCode.rt].W, GPR_Name(m_OpCode.rt));
|
||||
if (NextInstruction == RSPPIPELINE_NORMAL)
|
||||
{
|
||||
MoveConstToVariable(CompilePC + 4, PrgCount, "RSP PC");
|
||||
MoveConstToVariable(CompilePC + 4, m_System.m_SP_PC_REG, "RSP PC");
|
||||
Ret();
|
||||
NextInstruction = RSPPIPELINE_FINISH_SUB_BLOCK;
|
||||
}
|
||||
|
@ -2317,7 +2317,7 @@ void CRSPRecompilerOps::Cop0_MT(void)
|
|||
{
|
||||
if (NextInstruction == RSPPIPELINE_NORMAL)
|
||||
{
|
||||
MoveConstToVariable(CompilePC + 4, PrgCount, "RSP PC");
|
||||
MoveConstToVariable(CompilePC + 4, m_System.m_SP_PC_REG, "RSP PC");
|
||||
Ret();
|
||||
NextInstruction = RSPPIPELINE_FINISH_BLOCK;
|
||||
}
|
||||
|
@ -2370,7 +2370,7 @@ void CRSPRecompilerOps::Cop0_MT(void)
|
|||
Call_Direct(AddressOf(&RSPRegisterHandlerPlugin::WriteReg), "RSPRegisterHandlerPlugin::WriteReg");
|
||||
if (NextInstruction == RSPPIPELINE_NORMAL)
|
||||
{
|
||||
MoveConstToVariable(CompilePC + 4, PrgCount, "RSP PC");
|
||||
MoveConstToVariable(CompilePC + 4, m_System.m_SP_PC_REG, "RSP PC");
|
||||
Ret();
|
||||
NextInstruction = RSPPIPELINE_FINISH_BLOCK;
|
||||
}
|
||||
|
@ -2440,7 +2440,7 @@ void CRSPRecompilerOps::Cop0_MT(void)
|
|||
JeLabel8("DontExit", 0);
|
||||
Jump = RecompPos - 1;
|
||||
|
||||
MoveConstToVariable(CompilePC + 4, PrgCount, "RSP PC");
|
||||
MoveConstToVariable(CompilePC + 4, m_System.m_SP_PC_REG, "RSP PC");
|
||||
Ret();
|
||||
|
||||
CPU_Message("DontExit:");
|
||||
|
@ -7242,7 +7242,7 @@ void CRSPRecompilerOps::UnknownOpcode(void)
|
|||
{
|
||||
CPU_Message(" %X Unhandled Opcode: %s", CompilePC, RSPInstruction(CompilePC, m_OpCode.Value).NameAndParam().c_str());
|
||||
NextInstruction = RSPPIPELINE_FINISH_BLOCK;
|
||||
MoveConstToVariable(CompilePC, PrgCount, "RSP PC");
|
||||
MoveConstToVariable(CompilePC, m_System.m_SP_PC_REG, "RSP PC");
|
||||
MoveConstToVariable(m_OpCode.Value, &m_OpCode.Value, "m_OpCode.Value");
|
||||
MoveConstToX86reg((uint32_t) & (RSPSystem.m_Op), x86_ECX);
|
||||
Call_Direct(AddressOf(&RSPOp::UnknownOpcode), "&RSPOp::UnknownOpcode");
|
||||
|
|
|
@ -168,6 +168,7 @@ private:
|
|||
|
||||
void RSP_Element2Mmx(int MmxReg);
|
||||
void RSP_MultiElement2Mmx(int MmxReg1, int MmxReg2);
|
||||
void CompileBranchExit(uint32_t TargetPC, uint32_t ContinuePC);
|
||||
bool Compile_Vector_VMULF_MMX(void);
|
||||
bool Compile_Vector_VMUDL_MMX(void);
|
||||
bool Compile_Vector_VMUDM_MMX(void);
|
||||
|
|
|
@ -12,7 +12,7 @@
|
|||
class RSPRegisterHandler;
|
||||
|
||||
UDWORD EleSpec[16], Indx[16];
|
||||
uint32_t *PrgCount, NextInstruction, RSP_Running;
|
||||
uint32_t NextInstruction, RSP_Running;
|
||||
|
||||
void BuildRecompilerCPU(void);
|
||||
|
||||
|
@ -97,7 +97,6 @@ void Build_RSP(void)
|
|||
Indx[i].B[7 - z] = Temp;
|
||||
}
|
||||
}
|
||||
PrgCount = RSPInfo.SP_PC_REG;
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
|
@ -13,7 +13,7 @@ enum RSPCpuType
|
|||
|
||||
extern UDWORD EleSpec[16], Indx[16];
|
||||
|
||||
extern uint32_t *PrgCount, RSP_Running;
|
||||
extern uint32_t RSP_Running;
|
||||
|
||||
void SetCPU(RSPCpuType core);
|
||||
void Build_RSP(void);
|
||||
|
|
|
@ -123,7 +123,7 @@ int DisplayRSPCommand(DWORD location, int InsertPos)
|
|||
RSP_LW_IMEM(location, &OpCode);
|
||||
|
||||
status = 0;
|
||||
if (location == *PrgCount)
|
||||
if (location == *RSPInfo.SP_PC_REG)
|
||||
{
|
||||
status = RSP_Status_PC;
|
||||
}
|
||||
|
@ -320,7 +320,7 @@ void DrawRSPCommand(LPARAM lParam)
|
|||
DisplayError("Failed to sprintf from item %u.", ditem->itemID);
|
||||
}
|
||||
|
||||
if (*PrgCount == RSPCommandLine[ditem->itemID].Location)
|
||||
if (*RSPInfo.SP_PC_REG == RSPCommandLine[ditem->itemID].Location)
|
||||
{
|
||||
ResetColor = true;
|
||||
hBrush = (HBRUSH)(COLOR_HIGHLIGHT + 1);
|
||||
|
@ -335,7 +335,7 @@ void DrawRSPCommand(LPARAM lParam)
|
|||
if (CheckForRSPBPoint(RSPCommandLine[ditem->itemID].Location))
|
||||
{
|
||||
ResetColor = true;
|
||||
if (*PrgCount == RSPCommandLine[ditem->itemID].Location)
|
||||
if (*RSPInfo.SP_PC_REG == RSPCommandLine[ditem->itemID].Location)
|
||||
{
|
||||
SetTextColor(ditem->hDC, RGB(255, 0, 0));
|
||||
}
|
||||
|
@ -417,11 +417,11 @@ void Enable_RSP_Commands_Window(void)
|
|||
si.fMask = SIF_RANGE | SIF_POS | SIF_PAGE;
|
||||
si.nMin = 0;
|
||||
si.nMax = (0x1000 >> 2) - 1;
|
||||
si.nPos = (*PrgCount >> 2);
|
||||
si.nPos = (*RSPInfo.SP_PC_REG >> 2);
|
||||
si.nPage = 30;
|
||||
SetScrollInfo(hScrlBar, SB_CTL, &si, true);
|
||||
|
||||
SetRSPCommandViewto(*PrgCount);
|
||||
SetRSPCommandViewto(*RSPInfo.SP_PC_REG);
|
||||
SetForegroundWindow(RSPCommandshWnd);
|
||||
}
|
||||
}
|
||||
|
@ -743,7 +743,7 @@ void RSP_Commands_Setup(HWND hDlg)
|
|||
SendMessage(hList, LB_SETITEMHEIGHT, (WPARAM)0, (LPARAM)MAKELPARAM(14, 0));
|
||||
}
|
||||
|
||||
sprintf(Location, "%03X", PrgCount ? *PrgCount : 0);
|
||||
sprintf(Location, "%03X", RSPInfo.SP_PC_REG ? *RSPInfo.SP_PC_REG : 0);
|
||||
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);
|
||||
if (hAddress)
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue