Bus: Properly handle byte/word reads of DMA registers
Fixes FF7 locking up on game start.
This commit is contained in:
parent
73ab741d4c
commit
ec85ae7a40
|
@ -16,6 +16,9 @@
|
||||||
#include <cstdio>
|
#include <cstdio>
|
||||||
Log_SetChannel(Bus);
|
Log_SetChannel(Bus);
|
||||||
|
|
||||||
|
#define FIXUP_WORD_READ_OFFSET(offset) ((offset) & ~u32(3))
|
||||||
|
#define FIXUP_WORD_READ_VALUE(offset, value) ((value) >> (((offset) & u32(3)) * 8))
|
||||||
|
|
||||||
// Offset and value remapping for (w32) registers from nocash docs.
|
// Offset and value remapping for (w32) registers from nocash docs.
|
||||||
void FixupUnalignedWordAccessW32(u32& offset, u32& value)
|
void FixupUnalignedWordAccessW32(u32& offset, u32& value)
|
||||||
{
|
{
|
||||||
|
@ -505,21 +508,7 @@ void Bus::DoWriteSPU(MemoryAccessSize size, u32 offset, u32 value)
|
||||||
|
|
||||||
u32 Bus::DoReadDMA(MemoryAccessSize size, u32 offset)
|
u32 Bus::DoReadDMA(MemoryAccessSize size, u32 offset)
|
||||||
{
|
{
|
||||||
u32 value = m_dma->ReadRegister(offset);
|
return FIXUP_WORD_READ_VALUE(offset, m_dma->ReadRegister(FIXUP_WORD_READ_OFFSET(offset)));
|
||||||
switch (size)
|
|
||||||
{
|
|
||||||
case MemoryAccessSize::Byte:
|
|
||||||
case MemoryAccessSize::HalfWord:
|
|
||||||
{
|
|
||||||
if ((offset & u32(0xF0)) >= 7 || (offset & u32(0x0F)) != 0x4)
|
|
||||||
FixupUnalignedWordAccessW32(offset, value);
|
|
||||||
}
|
|
||||||
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
return value;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Bus::DoWriteDMA(MemoryAccessSize size, u32 offset, u32 value)
|
void Bus::DoWriteDMA(MemoryAccessSize size, u32 offset, u32 value)
|
||||||
|
|
Loading…
Reference in New Issue