Interpreter: Cleanup constants, casts, formatting.

This commit is contained in:
lightningterror 2023-06-27 11:28:12 +02:00
parent 9254403a51
commit 7ebc04bc34
1 changed files with 42 additions and 36 deletions

View File

@ -1,5 +1,5 @@
/* PCSX2 - PS2 Emulator for PCs /* PCSX2 - PS2 Emulator for PCs
* Copyright (C) 2002-2010 PCSX2 Dev Team * Copyright (C) 2002-2023 PCSX2 Dev Team
* *
* PCSX2 is free software: you can redistribute it and/or modify it under the terms * PCSX2 is free software: you can redistribute it and/or modify it under the terms
* of the GNU Lesser General Public License as published by the Free Software Found- * of the GNU Lesser General Public License as published by the Free Software Found-
@ -43,7 +43,7 @@ static void intEventTest();
void intBreakpoint(bool memcheck) void intBreakpoint(bool memcheck)
{ {
u32 pc = cpuRegs.pc; const u32 pc = cpuRegs.pc;
if (CBreakPoints::CheckSkipFirst(BREAKPOINT_EE, pc) != 0) if (CBreakPoints::CheckSkipFirst(BREAKPOINT_EE, pc) != 0)
return; return;
@ -63,13 +63,13 @@ void intMemcheck(u32 op, u32 bits, bool store)
{ {
// compute accessed address // compute accessed address
u32 start = cpuRegs.GPR.r[(op >> 21) & 0x1F].UD[0]; u32 start = cpuRegs.GPR.r[(op >> 21) & 0x1F].UD[0];
if ((s16)op != 0) if (static_cast<s16>(op) != 0)
start += (s16)op; start += static_cast<s16>(op);
if (bits == 128) if (bits == 128)
start &= ~0x0F; start &= ~0x0F;
start = standardizeBreakpointAddress(start); start = standardizeBreakpointAddress(start);
u32 end = start + bits/8; const u32 end = start + bits/8;
auto checks = CBreakPoints::GetMemChecks(BREAKPOINT_EE); auto checks = CBreakPoints::GetMemChecks(BREAKPOINT_EE);
for (size_t i = 0; i < checks.size(); i++) for (size_t i = 0; i < checks.size(); i++)
@ -90,32 +90,32 @@ void intMemcheck(u32 op, u32 bits, bool store)
void intCheckMemcheck() void intCheckMemcheck()
{ {
u32 pc = cpuRegs.pc; const u32 pc = cpuRegs.pc;
int needed = isMemcheckNeeded(pc); const int needed = isMemcheckNeeded(pc);
if (needed == 0) if (needed == 0)
return; return;
u32 op = memRead32(needed == 2 ? pc+4 : pc); const u32 op = memRead32(needed == 2 ? pc + 4 : pc);
const OPCODE& opcode = GetInstruction(op); const OPCODE& opcode = GetInstruction(op);
bool store = (opcode.flags & IS_STORE) != 0; const bool store = (opcode.flags & IS_STORE) != 0;
switch (opcode.flags & MEMTYPE_MASK) switch (opcode.flags & MEMTYPE_MASK)
{ {
case MEMTYPE_BYTE: case MEMTYPE_BYTE:
intMemcheck(op,8,store); intMemcheck(op, 8, store);
break; break;
case MEMTYPE_HALF: case MEMTYPE_HALF:
intMemcheck(op,16,store); intMemcheck(op, 16, store);
break; break;
case MEMTYPE_WORD: case MEMTYPE_WORD:
intMemcheck(op,32,store); intMemcheck(op, 32, store);
break; break;
case MEMTYPE_DWORD: case MEMTYPE_DWORD:
intMemcheck(op,64,store); intMemcheck(op, 64, store);
break; break;
case MEMTYPE_QWORD: case MEMTYPE_QWORD:
intMemcheck(op,128,store); intMemcheck(op, 128, store);
break; break;
} }
} }
@ -135,7 +135,7 @@ static void execI()
intCheckMemcheck(); intCheckMemcheck();
#endif #endif
u32 pc = cpuRegs.pc; const u32 pc = cpuRegs.pc;
// We need to increase the pc before executing the memRead32. An exception could appears // We need to increase the pc before executing the memRead32. An exception could appears
// and it expects the PC counter to be pre-incremented // and it expects the PC counter to be pre-incremented
cpuRegs.pc += 4; cpuRegs.pc += 4;
@ -148,8 +148,12 @@ static void execI()
static long int runs = 0; static long int runs = 0;
//use this to find out what opcodes your game uses. very slow! (rama) //use this to find out what opcodes your game uses. very slow! (rama)
runs++; runs++;
if (runs > 1599999999){ //leave some time to startup the testgame //leave some time to startup the testgame
if (opcode.Name[0] == 'L') { //find all opcodes beginning with "L" if (runs > 1599999999)
{
//find all opcodes beginning with "L"
if (opcode.Name[0] == 'L')
{
Console.WriteLn ("Load %s", opcode.Name); Console.WriteLn ("Load %s", opcode.Name);
} }
} }
@ -160,10 +164,12 @@ static void execI()
// Based on cycle // Based on cycle
// if( cpuRegs.cycle > 0x4f24d714 ) // if( cpuRegs.cycle > 0x4f24d714 )
// Or dump from a particular PC (useful to debug handler/syscall) // Or dump from a particular PC (useful to debug handler/syscall)
if (pc == 0x80000000) { if (pc == 0x80000000)
{
print_me = 2000; print_me = 2000;
} }
if (print_me) { if (print_me)
{
print_me--; print_me--;
disOut.clear(); disOut.clear();
disR5900Fasm(disOut, cpuRegs.code, pc); disR5900Fasm(disOut, cpuRegs.code, pc);
@ -449,7 +455,7 @@ void JR()
{ {
// 0x33ad48 and 0x35060c are the return address of the function (0x356250) that populate the TLB cache // 0x33ad48 and 0x35060c are the return address of the function (0x356250) that populate the TLB cache
if (EmuConfig.Gamefixes.GoemonTlbHack) { if (EmuConfig.Gamefixes.GoemonTlbHack) {
u32 add = cpuRegs.GPR.r[_Rs_].UL[0]; const u32 add = cpuRegs.GPR.r[_Rs_].UL[0];
if (add == 0x33ad48 || add == 0x35060c) if (add == 0x33ad48 || add == 0x35060c)
GoemonPreloadTlb(); GoemonPreloadTlb();
} }
@ -458,7 +464,7 @@ void JR()
void JALR() void JALR()
{ {
u32 temp = cpuRegs.GPR.r[_Rs_].UL[0]; const u32 temp = cpuRegs.GPR.r[_Rs_].UL[0];
if (_Rd_) _SetLink(_Rd_); if (_Rd_) _SetLink(_Rd_);
@ -534,7 +540,7 @@ static void intExecute()
if (cpuRegs.pc == EELOAD_START) if (cpuRegs.pc == EELOAD_START)
{ {
// The EELOAD _start function is the same across all BIOS versions afaik // The EELOAD _start function is the same across all BIOS versions afaik
u32 mainjump = memRead32(EELOAD_START + 0x9c); const u32 mainjump = memRead32(EELOAD_START + 0x9c);
if (mainjump >> 26 == 3) // JAL if (mainjump >> 26 == 3) // JAL
g_eeloadMain = ((EELOAD_START + 0xa0) & 0xf0000000U) | (mainjump << 2 & 0x0fffffffU); g_eeloadMain = ((EELOAD_START + 0xa0) & 0xf0000000U) | (mainjump << 2 & 0x0fffffffU);
@ -546,10 +552,10 @@ static void intExecute()
if (VMManager::Internal::IsFastBootInProgress()) if (VMManager::Internal::IsFastBootInProgress())
{ {
// See comments on this code in iR5900-32.cpp's recRecompile() // See comments on this code in iR5900-32.cpp's recRecompile()
u32 typeAexecjump = memRead32(EELOAD_START + 0x470); const u32 typeAexecjump = memRead32(EELOAD_START + 0x470);
u32 typeBexecjump = memRead32(EELOAD_START + 0x5B0); const u32 typeBexecjump = memRead32(EELOAD_START + 0x5B0);
u32 typeCexecjump = memRead32(EELOAD_START + 0x618); const u32 typeCexecjump = memRead32(EELOAD_START + 0x618);
u32 typeDexecjump = memRead32(EELOAD_START + 0x600); const u32 typeDexecjump = memRead32(EELOAD_START + 0x600);
if ((typeBexecjump >> 26 == 3) || (typeCexecjump >> 26 == 3) || (typeDexecjump >> 26 == 3)) // JAL to 0x822B8 if ((typeBexecjump >> 26 == 3) || (typeCexecjump >> 26 == 3) || (typeDexecjump >> 26 == 3)) // JAL to 0x822B8
g_eeloadExec = EELOAD_START + 0x2B8; g_eeloadExec = EELOAD_START + 0x2B8;
else if (typeAexecjump >> 26 == 3) // JAL to 0x82170 else if (typeAexecjump >> 26 == 3) // JAL to 0x82170