m68000: Do what the real M68K does on byte writes. Fix the debugger so watchpoints continue to work as expected [Alex Jackson]

This commit is contained in:
Alex W. Jackson 2014-05-30 04:05:49 +00:00
parent 9e224031ab
commit b025f698a1
3 changed files with 21 additions and 1 deletions

View File

@ -296,6 +296,7 @@ public:
UINT16 read_immediate_16(offs_t address);
UINT16 simple_read_immediate_16(offs_t address);
void m68000_write_byte(offs_t address, UINT8 data);
UINT8 read_byte_32_mmu(offs_t address);
void write_byte_32_mmu(offs_t address, UINT8 data);

View File

@ -1289,6 +1289,13 @@ UINT16 m68000_base_device::simple_read_immediate_16(offs_t address)
return m_direct->read_decrypted_word(address);
}
void m68000_base_device::m68000_write_byte(offs_t address, UINT8 data)
{
static const UINT16 masks[] = {0xff00, 0x00ff};
m_space->write_word(address & ~1, data | (data << 8), masks[address & 1]);
}
void m68000_base_device::init16(address_space &space)
{
m_space = &space;
@ -1299,7 +1306,7 @@ void m68000_base_device::init16(address_space &space)
read8 = m68k_read8_delegate(FUNC(address_space::read_byte), &space);
read16 = m68k_read16_delegate(FUNC(address_space::read_word), &space);
read32 = m68k_read32_delegate(FUNC(address_space::read_dword), &space);
write8 = m68k_write8_delegate(FUNC(address_space::write_byte), &space);
write8 = m68k_write8_delegate(FUNC(m68000_base_device::m68000_write_byte), this);
write16 = m68k_write16_delegate(FUNC(address_space::write_word), &space);
write32 = m68k_write32_delegate(FUNC(address_space::write_dword), &space);
}

View File

@ -3006,6 +3006,18 @@ void device_debug::watchpoint_check(address_space &space, int type, offs_t addre
mem_mask >>= 8;
}
// (1<<(size*8))-1 won't work when size is 8; let's just use a lut
static const UINT64 masks[] = {0,
0xff,
0xffff,
0xffffff,
0xffffffff,
U64(0xffffffffff),
U64(0xffffffffffff),
U64(0xffffffffffffff),
U64(0xffffffffffffffff)};
value_to_write &= masks[size];
if (space.endianness() == ENDIANNESS_LITTLE)
address += address_offset;
else