diff options
author | AJR <ajrhacker@users.noreply.github.com> | 2018-09-24 15:03:22 -0400 |
---|---|---|
committer | AJR <ajrhacker@users.noreply.github.com> | 2018-09-24 15:11:36 -0400 |
commit | 44608e3c495ece9af7fae5c4d2ada8b8e425dfb1 (patch) | |
tree | 3e3702bab5c3c57068c500da93dee65dae8e6cc2 /src/mame/drivers/segas16a.cpp | |
parent | b671894849e1468b8c12fb3a38b4eee3488af795 (diff) |
i8243: Device overhaul (nw)
- Fix critical bugs with P4-P7 reads, both in this device and in the emulation of the MCS-48 MOVD A,Pp instruction
- Emulate the CS line, which will be useful for driving multiple 8243s
- Provide a separate callback for each 4-bit port
- Eliminate space and offset arguments from p2_r and p2_w
Diffstat (limited to 'src/mame/drivers/segas16a.cpp')
-rw-r--r-- | src/mame/drivers/segas16a.cpp | 17 |
1 files changed, 10 insertions, 7 deletions
diff --git a/src/mame/drivers/segas16a.cpp b/src/mame/drivers/segas16a.cpp index 74f1112d83c..df5b3c157d2 100644 --- a/src/mame/drivers/segas16a.cpp +++ b/src/mame/drivers/segas16a.cpp @@ -371,14 +371,15 @@ WRITE8_MEMBER( segas16a_state::n7751_control_w ) // n7751_rom_offset_w - post expander callback //------------------------------------------------- -WRITE8_MEMBER( segas16a_state::n7751_rom_offset_w ) +template<int Shift> +void segas16a_state::n7751_rom_offset_w(uint8_t data) { // P4 - address lines 0-3 // P5 - address lines 4-7 // P6 - address lines 8-11 // P7 - address lines 12-13 - int mask = (0xf << (4 * offset)) & 0x3fff; - int newdata = (data << (4 * offset)) & mask; + int mask = (0xf << Shift) & 0x3fff; + int newdata = (data << Shift) & mask; m_n7751_rom_address = (m_n7751_rom_address & ~mask) | newdata; } @@ -405,7 +406,7 @@ READ8_MEMBER( segas16a_state::n7751_p2_r ) { // read from P2 - 8255's PC0-2 connects to 7751's S0-2 (P24-P26 on an 8048) // bit 0x80 is an alternate way to control the sample on/off; doesn't appear to be used - return 0x80 | ((m_n7751_command & 0x07) << 4) | (m_n7751_i8243->p2_r(space, offset) & 0x0f); + return 0x80 | ((m_n7751_command & 0x07) << 4) | (m_n7751_i8243->p2_r() & 0x0f); } @@ -416,7 +417,7 @@ READ8_MEMBER( segas16a_state::n7751_p2_r ) WRITE8_MEMBER( segas16a_state::n7751_p2_w ) { // write to P2; low 4 bits go to 8243 - m_n7751_i8243->p2_w(space, offset, data & 0x0f); + m_n7751_i8243->p2_w(data & 0x0f); // output of bit $80 indicates we are ready (1) or busy (0) // no other outputs are used @@ -1982,8 +1983,10 @@ MACHINE_CONFIG_START(segas16a_state::system16a) MCFG_MCS48_PORT_PROG_OUT_CB(WRITELINE("n7751_8243", i8243_device, prog_w)) I8243(config, m_n7751_i8243); - m_n7751_i8243->read_handler().set_constant(0); - m_n7751_i8243->write_handler().set(FUNC(segas16a_state::n7751_rom_offset_w)); + m_n7751_i8243->p4_out_cb().set(FUNC(segas16a_state::n7751_rom_offset_w<0>)); + m_n7751_i8243->p5_out_cb().set(FUNC(segas16a_state::n7751_rom_offset_w<4>)); + m_n7751_i8243->p6_out_cb().set(FUNC(segas16a_state::n7751_rom_offset_w<8>)); + m_n7751_i8243->p7_out_cb().set(FUNC(segas16a_state::n7751_rom_offset_w<12>)); NVRAM(config, "nvram", nvram_device::DEFAULT_ALL_0); |