diff --git a/yabause/src/sys/memory/src/memory.c b/yabause/src/sys/memory/src/memory.c index 4d440dfdd..c5eb4e61a 100644 --- a/yabause/src/sys/memory/src/memory.c +++ b/yabause/src/sys/memory/src/memory.c @@ -314,7 +314,7 @@ static void FASTCALL UnhandledMemoryWriteLong(SH2_struct *context, UNUSED u8* me ////////////////////////////////////////////////////////////////////////////// -u32 lastHWRamBankCol = 0; +static u32 lastHWRamBankCol = 0; static u8 FASTCALL HighWramMemoryReadByte(SH2_struct *context, u8* mem, u32 addr) { @@ -388,8 +388,15 @@ static void FASTCALL HighWramMemoryWriteLong(SH2_struct *context, u8* mem, u32 a ////////////////////////////////////////////////////////////////////////////// +static u32 lastLWRamBankCol = 0; + static u8 FASTCALL LowWramMemoryReadByte(SH2_struct *context, UNUSED u8* memory, u32 addr) { + int rowBank = ((addr>>11)&0x1FF); + if (rowBank != lastLWRamBankCol) { + lastLWRamBankCol = rowBank; + if ((context) && (!context->cacheOn)) context->cycles += 4; + } return T2ReadByte(memory, addr & 0xFFFFF); } @@ -397,6 +404,11 @@ static u8 FASTCALL LowWramMemoryReadByte(SH2_struct *context, UNUSED u8* memory, static u16 FASTCALL LowWramMemoryReadWord(SH2_struct *context, UNUSED u8* memory, u32 addr) { + int rowBank = ((addr>>11)&0x1FF); + if (rowBank != lastLWRamBankCol) { + lastLWRamBankCol = rowBank; + if ((context) && (!context->cacheOn)) context->cycles += 4; + } return T2ReadWord(memory, addr & 0xFFFFF); } @@ -404,6 +416,11 @@ static u16 FASTCALL LowWramMemoryReadWord(SH2_struct *context, UNUSED u8* memory static u32 FASTCALL LowWramMemoryReadLong(SH2_struct *context, UNUSED u8* memory, u32 addr) { + int rowBank = ((addr>>11)&0x1FF); + if (rowBank != lastLWRamBankCol) { + lastLWRamBankCol = rowBank; + if ((context) && (!context->cacheOn)) context->cycles += 4; + } return T2ReadLong(memory, addr & 0xFFFFF); } @@ -411,6 +428,11 @@ static u32 FASTCALL LowWramMemoryReadLong(SH2_struct *context, UNUSED u8* memory static void FASTCALL LowWramMemoryWriteByte(SH2_struct *context, UNUSED u8* memory, u32 addr, u8 val) { + int rowBank = ((addr>>11)&0x1FF); + if (rowBank != lastLWRamBankCol) { + lastLWRamBankCol = rowBank; + if (context) context->cycles += 4; + } T2WriteByte(memory, addr & 0xFFFFF, val); } @@ -418,6 +440,11 @@ static void FASTCALL LowWramMemoryWriteByte(SH2_struct *context, UNUSED u8* memo static void FASTCALL LowWramMemoryWriteWord(SH2_struct *context, UNUSED u8* memory, u32 addr, u16 val) { + int rowBank = ((addr>>11)&0x1FF); + if (rowBank != lastLWRamBankCol) { + lastLWRamBankCol = rowBank; + if (context) context->cycles += 4; + } T2WriteWord(memory, addr & 0xFFFFF, val); } @@ -425,6 +452,11 @@ static void FASTCALL LowWramMemoryWriteWord(SH2_struct *context, UNUSED u8* memo static void FASTCALL LowWramMemoryWriteLong(SH2_struct *context, UNUSED u8* memory, u32 addr, u32 val) { + int rowBank = ((addr>>11)&0x1FF); + if (rowBank != lastLWRamBankCol) { + lastLWRamBankCol = rowBank; + if (context) context->cycles += 4; + } T2WriteLong(memory, addr & 0xFFFFF, val); }