mirror of
https://github.com/holub/mame
synced 2025-04-21 07:52:35 +03:00
fmtowns: don't overrun nvram buffer
This commit is contained in:
parent
6b41ddd4f3
commit
12e934c866
@ -1204,9 +1204,9 @@ uint8_t towns_state::towns_cmos_low_r(offs_t offset)
|
||||
return m_ram->pointer()[offset + 0xd8000];
|
||||
|
||||
if(m_nvram)
|
||||
return m_nvram[offset];
|
||||
return m_nvram[offset >> 2] >> ((offset & 3) << 3);
|
||||
else
|
||||
return m_nvram16[offset];
|
||||
return m_nvram16[offset >> 1] >> ((offset & 1) << 3);
|
||||
}
|
||||
|
||||
void towns_state::towns_cmos_low_w(offs_t offset, uint8_t data)
|
||||
@ -1215,25 +1215,41 @@ void towns_state::towns_cmos_low_w(offs_t offset, uint8_t data)
|
||||
m_ram->pointer()[offset+0xd8000] = data;
|
||||
else
|
||||
if(m_nvram)
|
||||
m_nvram[offset] = data;
|
||||
{
|
||||
uint8_t shift = (offset & 3) << 3;
|
||||
m_nvram[offset >> 2] &= ~(0xff << shift);
|
||||
m_nvram[offset >> 2] |= (uint32_t)data << shift;
|
||||
}
|
||||
else
|
||||
m_nvram16[offset] = data;
|
||||
{
|
||||
uint8_t shift = (offset & 1) << 3;
|
||||
m_nvram16[offset >> 1] &= ~(0xff << shift);
|
||||
m_nvram16[offset >> 1] |= (uint16_t)data << shift;
|
||||
}
|
||||
}
|
||||
|
||||
uint8_t towns_state::towns_cmos_r(offs_t offset)
|
||||
{
|
||||
if(m_nvram)
|
||||
return m_nvram[offset];
|
||||
return m_nvram[offset >> 2] >> ((offset & 3) << 3);
|
||||
else
|
||||
return m_nvram16[offset];
|
||||
return m_nvram16[offset >> 1] >> ((offset & 1) << 3);
|
||||
}
|
||||
|
||||
void towns_state::towns_cmos_w(offs_t offset, uint8_t data)
|
||||
{
|
||||
if(m_nvram)
|
||||
m_nvram[offset] = data;
|
||||
{
|
||||
uint8_t shift = (offset & 3) << 3;
|
||||
m_nvram[offset >> 2] &= ~(0xff << shift);
|
||||
m_nvram[offset >> 2] |= (uint32_t)data << shift;
|
||||
}
|
||||
else
|
||||
m_nvram16[offset] = data;
|
||||
{
|
||||
uint8_t shift = (offset & 1) << 3;
|
||||
m_nvram16[offset >> 1] &= ~(0xff << shift);
|
||||
m_nvram16[offset >> 1] |= (uint16_t)data << shift;
|
||||
}
|
||||
}
|
||||
|
||||
void towns_state::towns_update_video_banks()
|
||||
|
Loading…
Reference in New Issue
Block a user