Skip to content

Commit

Permalink
Low Ram has also a column/row mechanism - Impact on row change is a b…
Browse files Browse the repository at this point in the history
…it longer
  • Loading branch information
Francois CARON committed Dec 1, 2024
1 parent dcf2170 commit 8407d66
Showing 1 changed file with 33 additions and 1 deletion.
34 changes: 33 additions & 1 deletion yabause/src/sys/memory/src/memory.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand Down Expand Up @@ -388,43 +388,75 @@ 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);
}

//////////////////////////////////////////////////////////////////////////////

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);
}

//////////////////////////////////////////////////////////////////////////////

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);
}

//////////////////////////////////////////////////////////////////////////////

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);
}

//////////////////////////////////////////////////////////////////////////////

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);
}

//////////////////////////////////////////////////////////////////////////////

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);
}

Expand Down

0 comments on commit 8407d66

Please sign in to comment.