mirror of
https://github.com/RPCS3/rpcs3.git
synced 2025-02-19 12:40:29 +00:00
Don't ask twice if MemoryBlocks can read mem.
They already check on Read32(), so just use that to iterate.
This commit is contained in:
parent
db1ca2f89f
commit
e4c0b0310c
@ -3,7 +3,9 @@
|
||||
|
||||
u8 PPCDecoder::DecodeMemory(const u64 address)
|
||||
{
|
||||
Decode(Memory.Read32(address));
|
||||
u32 instr;
|
||||
Memory.Read32ByAddr(address, &instr);
|
||||
Decode(instr);
|
||||
|
||||
return 4;
|
||||
}
|
@ -498,35 +498,35 @@ bool MemoryBase::Write128NN(u64 addr, const u128 data)
|
||||
u8 MemoryBase::Read8(u64 addr)
|
||||
{
|
||||
u8 res;
|
||||
GetMemByAddr(addr).Read8(addr, &res);
|
||||
Read8ByAddr(addr, &res);
|
||||
return res;
|
||||
}
|
||||
|
||||
u16 MemoryBase::Read16(u64 addr)
|
||||
{
|
||||
u16 res;
|
||||
GetMemByAddr(addr).Read16(addr, &res);
|
||||
Read16ByAddr(addr, &res);
|
||||
return res;
|
||||
}
|
||||
|
||||
u32 MemoryBase::Read32(u64 addr)
|
||||
{
|
||||
u32 res;
|
||||
GetMemByAddr(addr).Read32(addr, &res);
|
||||
Read32ByAddr(addr, &res);
|
||||
return res;
|
||||
}
|
||||
|
||||
u64 MemoryBase::Read64(u64 addr)
|
||||
{
|
||||
u64 res;
|
||||
GetMemByAddr(addr).Read64(addr, &res);
|
||||
Read64ByAddr(addr, &res);
|
||||
return res;
|
||||
}
|
||||
|
||||
u128 MemoryBase::Read128(u64 addr)
|
||||
{
|
||||
u128 res;
|
||||
GetMemByAddr(addr).Read128(addr, &res);
|
||||
Read128ByAddr(addr, &res);
|
||||
return res;
|
||||
}
|
||||
|
||||
@ -655,9 +655,11 @@ bool VirtualMemoryBlock::Read16(const u64 addr, u16* value)
|
||||
|
||||
bool VirtualMemoryBlock::Read32(const u64 addr, u32* value)
|
||||
{
|
||||
u64 realAddr;
|
||||
*value = Memory.Read32(realAddr = getRealAddr(addr));
|
||||
return realAddr != 0;
|
||||
u64 realAddr = getRealAddr(addr);
|
||||
if (realAddr == 0)
|
||||
return false;
|
||||
*value = Memory.Read32(realAddr);
|
||||
return true;
|
||||
}
|
||||
|
||||
bool VirtualMemoryBlock::Read64(const u64 addr, u64* value)
|
||||
|
@ -105,7 +105,7 @@ public:
|
||||
|
||||
MemoryBlock& GetMemByAddr(const u64 addr)
|
||||
{
|
||||
for(uint i=0; i<MemoryBlocks.size(); ++i)
|
||||
for (size_t i = 0, end = MemoryBlocks.size(); i < end; ++i)
|
||||
{
|
||||
if(MemoryBlocks[i]->IsMyAddress(addr)) return *MemoryBlocks[i];
|
||||
}
|
||||
@ -113,6 +113,61 @@ public:
|
||||
return NullMem;
|
||||
}
|
||||
|
||||
bool Read8ByAddr(const u64 addr, u8 *value)
|
||||
{
|
||||
for (size_t i = 0, end = MemoryBlocks.size(); i < end; ++i)
|
||||
{
|
||||
if (MemoryBlocks[i]->Read8(addr, value))
|
||||
return true;
|
||||
}
|
||||
|
||||
return NullMem.Read8(addr, value);
|
||||
}
|
||||
|
||||
bool Read16ByAddr(const u64 addr, u16 *value)
|
||||
{
|
||||
for (size_t i = 0, end = MemoryBlocks.size(); i < end; ++i)
|
||||
{
|
||||
if (MemoryBlocks[i]->Read16(addr, value))
|
||||
return true;
|
||||
}
|
||||
|
||||
return NullMem.Read16(addr, value);
|
||||
}
|
||||
|
||||
bool Read32ByAddr(const u64 addr, u32 *value)
|
||||
{
|
||||
for (size_t i = 0, end = MemoryBlocks.size(); i < end; ++i)
|
||||
{
|
||||
if (MemoryBlocks[i]->Read32(addr, value))
|
||||
return true;
|
||||
}
|
||||
|
||||
return NullMem.Read32(addr, value);
|
||||
}
|
||||
|
||||
bool Read64ByAddr(const u64 addr, u64 *value)
|
||||
{
|
||||
for (size_t i = 0, end = MemoryBlocks.size(); i < end; ++i)
|
||||
{
|
||||
if (MemoryBlocks[i]->Read64(addr, value))
|
||||
return true;
|
||||
}
|
||||
|
||||
return NullMem.Read64(addr, value);
|
||||
}
|
||||
|
||||
bool Read128ByAddr(const u64 addr, u128 *value)
|
||||
{
|
||||
for (size_t i = 0, end = MemoryBlocks.size(); i < end; ++i)
|
||||
{
|
||||
if (MemoryBlocks[i]->Read128(addr, value))
|
||||
return true;
|
||||
}
|
||||
|
||||
return NullMem.Read128(addr, value);
|
||||
}
|
||||
|
||||
u8* GetMemFromAddr(const u64 addr)
|
||||
{
|
||||
return GetMemByAddr(addr).GetMemFromAddr(addr);
|
||||
@ -188,7 +243,7 @@ public:
|
||||
|
||||
bool IsGoodAddr(const u64 addr)
|
||||
{
|
||||
for(uint i=0; i<MemoryBlocks.size(); ++i)
|
||||
for (size_t i = 0, end = MemoryBlocks.size(); i < end; ++i)
|
||||
{
|
||||
if(MemoryBlocks[i]->IsMyAddress(addr)) return true;
|
||||
}
|
||||
@ -198,7 +253,7 @@ public:
|
||||
|
||||
bool IsGoodAddr(const u64 addr, const u32 size)
|
||||
{
|
||||
for(uint i=0; i<MemoryBlocks.size(); ++i)
|
||||
for (size_t i = 0, end = MemoryBlocks.size(); i < end; ++i)
|
||||
{
|
||||
if( MemoryBlocks[i]->IsMyAddress(addr) &&
|
||||
MemoryBlocks[i]->IsMyAddress(addr + size - 1) ) return true;
|
||||
@ -214,7 +269,7 @@ public:
|
||||
|
||||
ConLog.Write("Closing memory...");
|
||||
|
||||
for(uint i=0; i<MemoryBlocks.size(); ++i)
|
||||
for (size_t i = 0, end = MemoryBlocks.size(); i < end; ++i)
|
||||
{
|
||||
MemoryBlocks[i]->Delete();
|
||||
}
|
||||
|
@ -187,6 +187,7 @@ public:
|
||||
|
||||
class NullMemoryBlock : public MemoryBlock
|
||||
{
|
||||
public:
|
||||
virtual bool IsNULL() { return true; }
|
||||
virtual bool IsMyAddress(const u64 addr) { return true; }
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user