mirror of
https://github.com/hrydgard/ppsspp.git
synced 2024-11-23 05:19:56 +00:00
Prevent hashes from coming out differently after replacement.
This commit is contained in:
parent
e9b4d431df
commit
a53a032120
@ -205,8 +205,13 @@ void WriteReplaceInstruction(u32 address, u64 hash, int size) {
|
||||
int index = GetReplacementFuncIndex(hash, size);
|
||||
if (index >= 0) {
|
||||
u32 prevInstr = Memory::Read_U32(address);
|
||||
if (MIPS_IS_REPLACEMENT(prevInstr))
|
||||
if (MIPS_IS_REPLACEMENT(prevInstr)) {
|
||||
return;
|
||||
}
|
||||
if (MIPS_IS_RUNBLOCK(prevInstr)) {
|
||||
// Likely already both replaced and jitted. Ignore.
|
||||
return;
|
||||
}
|
||||
replacedInstructions[address] = prevInstr;
|
||||
INFO_LOG(HLE, "Replaced %s at %08x", entries[index].name, address);
|
||||
Memory::Write_U32(MIPS_EMUHACK_CALL_REPLACEMENT | (int)index, address);
|
||||
@ -214,7 +219,7 @@ void WriteReplaceInstruction(u32 address, u64 hash, int size) {
|
||||
}
|
||||
|
||||
bool GetReplacedOpAt(u32 address, u32 *op) {
|
||||
u32 instr = Memory::Read_U32(address);
|
||||
u32 instr = Memory::Read_Opcode_JIT(address).encoding;
|
||||
if (MIPS_IS_REPLACEMENT(instr)) {
|
||||
auto iter = replacedInstructions.find(address);
|
||||
if (iter != replacedInstructions.end()) {
|
||||
@ -224,6 +229,5 @@ bool GetReplacedOpAt(u32 address, u32 *op) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
*op = instr;
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
@ -228,7 +228,12 @@ namespace MIPSAnalyst {
|
||||
size_t pos = 0;
|
||||
for (u32 addr = f.start; addr <= f.end; addr += 4) {
|
||||
u32 validbits = 0xFFFFFFFF;
|
||||
MIPSOpcode instr = Memory::Read_Instruction(addr);
|
||||
MIPSOpcode instr = Memory::Read_Instruction(addr, true);
|
||||
if (MIPS_IS_EMUHACK(instr)) {
|
||||
f.hasHash = false;
|
||||
goto skip;
|
||||
}
|
||||
|
||||
MIPSInfo flags = MIPSGetInfo(instr);
|
||||
if (flags & IN_IMM16)
|
||||
validbits &= ~0xFFFF;
|
||||
@ -239,6 +244,8 @@ namespace MIPSAnalyst {
|
||||
|
||||
f.hash = CityHash64((const char *) &buffer[0], buffer.size() * sizeof(u32));
|
||||
f.hasHash = true;
|
||||
skip:
|
||||
;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -171,9 +171,7 @@ void Clear()
|
||||
memset(m_pVRAM, 0, VRAM_SIZE);
|
||||
}
|
||||
|
||||
|
||||
|
||||
Opcode Read_Instruction(u32 address)
|
||||
Opcode Read_Instruction(u32 address, bool resolveReplacements)
|
||||
{
|
||||
Opcode inst = Opcode(Read_U32(address));
|
||||
if (MIPS_IS_RUNBLOCK(inst.encoding) && MIPSComp::jit) {
|
||||
@ -181,11 +179,19 @@ Opcode Read_Instruction(u32 address)
|
||||
int block_num = bc->GetBlockNumberFromEmuHackOp(inst, true);
|
||||
if (block_num >= 0) {
|
||||
inst = bc->GetOriginalFirstOp(block_num);
|
||||
/*
|
||||
u32 op;
|
||||
if (GetReplacedOpAt(address, &op)) {
|
||||
return Opcode(op);
|
||||
}*/
|
||||
if (resolveReplacements && MIPS_IS_REPLACEMENT(inst)) {
|
||||
u32 op;
|
||||
if (GetReplacedOpAt(address, &op)) {
|
||||
if (MIPS_IS_EMUHACK(op)) {
|
||||
ERROR_LOG(HLE,"WTF 1");
|
||||
return Opcode(op);
|
||||
} else {
|
||||
return Opcode(op);
|
||||
}
|
||||
} else {
|
||||
ERROR_LOG(HLE, "Replacement, but no replacement op? %08x", inst);
|
||||
}
|
||||
}
|
||||
return inst;
|
||||
} else {
|
||||
return inst;
|
||||
@ -193,7 +199,12 @@ Opcode Read_Instruction(u32 address)
|
||||
} else if (MIPS_IS_REPLACEMENT(inst.encoding)) {
|
||||
u32 op;
|
||||
if (GetReplacedOpAt(address, &op)) {
|
||||
return Opcode(op);
|
||||
if (MIPS_IS_EMUHACK(op)) {
|
||||
ERROR_LOG(HLE,"WTF 2");
|
||||
return Opcode(op);
|
||||
} else {
|
||||
return Opcode(op);
|
||||
}
|
||||
} else {
|
||||
return inst;
|
||||
}
|
||||
|
@ -139,7 +139,7 @@ Opcode Read_Opcode_JIT(const u32 _Address);
|
||||
void Write_Opcode_JIT(const u32 _Address, const Opcode _Value);
|
||||
|
||||
// Should be used by analyzers, disassemblers etc. Does resolve replacements.
|
||||
Opcode Read_Instruction(const u32 _Address);
|
||||
Opcode Read_Instruction(const u32 _Address, bool resolveReplacements = false);
|
||||
|
||||
u8 Read_U8(const u32 _Address);
|
||||
u16 Read_U16(const u32 _Address);
|
||||
|
Loading…
Reference in New Issue
Block a user