summaryrefslogtreecommitdiffstatshomepage
path: root/src/devices/machine/cs4031.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/devices/machine/cs4031.cpp')
-rw-r--r--src/devices/machine/cs4031.cpp111
1 files changed, 44 insertions, 67 deletions
diff --git a/src/devices/machine/cs4031.cpp b/src/devices/machine/cs4031.cpp
index 4cc990b43df..30712c02059 100644
--- a/src/devices/machine/cs4031.cpp
+++ b/src/devices/machine/cs4031.cpp
@@ -1,4 +1,4 @@
-// license:GPL-2.0+
+// license:BSD-3-Clause
// copyright-holders:Dirk Best
/***************************************************************************
@@ -16,7 +16,7 @@
- 2x 8257 DMA controller
- 2x 8259 interrupt controller
- 8254 timer
- - MC14818 RTC
+ - MC146818 RTC
TODO:
- No emulation of memory parity checks
@@ -26,11 +26,8 @@
***************************************************************************/
#include "emu.h"
-#include "machine/cs4031.h"
+#include "cs4031.h"
-#include "machine/ram.h"
-
-#define LOG_GENERAL (1U << 0)
#define LOG_REGISTER (1U << 1)
#define LOG_MEMORY (1U << 2)
#define LOG_IO (1U << 3)
@@ -164,7 +161,7 @@ void cs4031_device::device_add_mconfig(machine_config &config)
cs4031_device::cs4031_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) :
device_t(mconfig, CS4031, tag, owner, clock),
- m_read_ior(*this),
+ m_read_ior(*this, 0),
m_write_iow(*this),
m_write_tc(*this),
m_write_hold(*this),
@@ -186,6 +183,7 @@ cs4031_device::cs4031_device(const machine_config &mconfig, const char *tag, dev
m_intc2(*this, "intc2"),
m_ctc(*this, "ctc"),
m_rtc(*this, "rtc"),
+ m_ram_dev(*this, finder_base::DUMMY_TAG),
m_dma_eop(0),
m_dma_high_byte(0xff),
m_dma_channel(-1),
@@ -211,23 +209,10 @@ cs4031_device::cs4031_device(const machine_config &mconfig, const char *tag, dev
void cs4031_device::device_start()
{
- ram_device *ram_dev = machine().device<ram_device>(RAM_TAG);
-
// make sure the ram device is already running
- if (!ram_dev->started())
+ if (!m_ram_dev->started())
throw device_missing_dependencies();
- // resolve callbacks
- m_read_ior.resolve_safe(0);
- m_write_iow.resolve_safe();
- m_write_tc.resolve_safe();
- m_write_hold.resolve_safe();
- m_write_nmi.resolve_safe();
- m_write_intr.resolve_safe();
- m_write_cpureset.resolve_safe();
- m_write_a20m.resolve_safe();
- m_write_spkr.resolve_safe();
-
// register for state saving
save_item(NAME(m_dma_eop));
save_item(NAME(m_dma_page));
@@ -249,8 +234,8 @@ void cs4031_device::device_start()
m_space = &m_cpu->memory().space(AS_PROGRAM);
m_space_io = &m_cpu->memory().space(AS_IO);
- m_ram = ram_dev->pointer();
- uint32_t ram_size = ram_dev->size();
+ m_ram = m_ram_dev->pointer();
+ uint32_t ram_size = m_ram_dev->size();
// install base memory
m_space->install_ram(0x000000, 0x09ffff, m_ram);
@@ -271,7 +256,8 @@ void cs4031_device::device_start()
m_space_io->install_readwrite_handler(0x0060, 0x0063, read8smo_delegate(*this, FUNC(cs4031_device::keyb_data_r)), write8smo_delegate(*this, FUNC(cs4031_device::keyb_data_w)), 0x000000ff);
m_space_io->install_readwrite_handler(0x0060, 0x0063, read8smo_delegate(*this, FUNC(cs4031_device::portb_r)), write8smo_delegate(*this, FUNC(cs4031_device::portb_w)), 0x0000ff00);
m_space_io->install_readwrite_handler(0x0064, 0x0067, read8smo_delegate(*this, FUNC(cs4031_device::keyb_status_r)), write8smo_delegate(*this, FUNC(cs4031_device::keyb_command_w)), 0x000000ff);
- m_space_io->install_readwrite_handler(0x0070, 0x0073, read8sm_delegate(*m_rtc, FUNC(mc146818_device::read)), write8sm_delegate(*this, FUNC(cs4031_device::rtc_w)), 0x0000ffff);
+ m_space_io->install_write_handler(0x0070, 0x0073, write8smo_delegate(*this, FUNC(cs4031_device::rtc_nmi_w)), 0x000000ff); // RTC address (84035) and NMI mask (84031) are both write-only
+ m_space_io->install_readwrite_handler(0x0070, 0x0073, read8smo_delegate(*m_rtc, FUNC(mc146818_device::data_r)), write8smo_delegate(*m_rtc, FUNC(mc146818_device::data_w)), 0x0000ff00);
m_space_io->install_readwrite_handler(0x0080, 0x008f, read8sm_delegate(*this, FUNC(cs4031_device::dma_page_r)), write8sm_delegate(*this, FUNC(cs4031_device::dma_page_w)), 0xffffffff);
m_space_io->install_readwrite_handler(0x0090, 0x0093, read8smo_delegate(*this, FUNC(cs4031_device::sysctrl_r)), write8smo_delegate(*this, FUNC(cs4031_device::sysctrl_w)), 0x00ff0000);
m_space_io->install_readwrite_handler(0x00a0, 0x00a3, read8sm_delegate(*m_intc2, FUNC(pic8259_device::read)), write8sm_delegate(*m_intc2, FUNC(pic8259_device::write)), 0x0000ffff);
@@ -363,12 +349,12 @@ void cs4031_device::dma_write_word(offs_t offset, uint8_t data)
m_space->write_word((page_offset() & 0xfe0000) | (offset << 1), (m_dma_high_byte << 8) | data);
}
-WRITE_LINE_MEMBER( cs4031_device::dma2_dack0_w )
+void cs4031_device::dma2_dack0_w(int state)
{
m_dma1->hack_w(state ? 0 : 1); // inverted?
}
-WRITE_LINE_MEMBER( cs4031_device::dma1_eop_w )
+void cs4031_device::dma1_eop_w(int state)
{
m_dma_eop = state;
if (m_dma_channel != -1)
@@ -439,7 +425,7 @@ uint8_t cs4031_device::intc1_slave_ack_r(offs_t offset)
return 0x00;
}
-WRITE_LINE_MEMBER( cs4031_device::iochck_w )
+void cs4031_device::iochck_w(int state)
{
LOGIO("cs4031_device::iochck_w: %u\n", state);
@@ -461,13 +447,13 @@ WRITE_LINE_MEMBER( cs4031_device::iochck_w )
// TIMER
//**************************************************************************
-WRITE_LINE_MEMBER( cs4031_device::ctc_out1_w )
+void cs4031_device::ctc_out1_w(int state)
{
m_refresh_toggle ^= state;
m_portb = (m_portb & 0xef) | (m_refresh_toggle << 4);
}
-WRITE_LINE_MEMBER( cs4031_device::ctc_out2_w )
+void cs4031_device::ctc_out2_w(int state)
{
m_write_spkr(!(state & BIT(m_portb, 1)));
m_portb = (m_portb & 0xdf) | (state << 5);
@@ -565,28 +551,25 @@ void cs4031_device::config_data_w(uint8_t data)
// MEMORY MAPPER
//**************************************************************************
-void cs4031_device::update_read_region(int index, const char *region, offs_t start, offs_t end)
+void cs4031_device::update_read_region(int index, offs_t start, offs_t end)
{
if (!BIT(m_registers[SHADOW_READ], index) && BIT(m_registers[ROMCS], index))
{
LOGMEMORY("ROM read from %x to %x\n", start, end);
- m_space->install_read_bank(start, end, region);
- machine().root_device().membank(region)->set_base(m_bios + start);
+ m_space->install_rom(start, end, m_bios + start);
}
else if (!BIT(m_registers[SHADOW_READ], index) && !BIT(m_registers[ROMCS], index))
{
LOGMEMORY("ISA read from %x to %x\n", start, end);
- m_space->install_read_bank(start, end, region);
- machine().root_device().membank(region)->set_base(m_isa + start - 0xc0000);
+ m_space->install_rom(start, end, m_isa + start - 0xc0000);
}
else if (BIT(m_registers[SHADOW_READ], index))
{
LOGMEMORY("RAM read from %x to %x\n", start, end);
- m_space->install_read_bank(start, end, region);
- machine().root_device().membank(region)->set_base(m_ram + start);
+ m_space->install_rom(start, end, m_ram + start);
}
else
{
@@ -596,28 +579,25 @@ void cs4031_device::update_read_region(int index, const char *region, offs_t sta
}
}
-void cs4031_device::update_write_region(int index, const char *region, offs_t start, offs_t end)
+void cs4031_device::update_write_region(int index, offs_t start, offs_t end)
{
if (!BIT(m_registers[SHADOW_WRITE], index) && BIT(m_registers[ROMCS], index) && BIT(m_registers[ROMCS], 7))
{
LOGMEMORY("ROM write from %x to %x\n", start, end);
- m_space->install_write_bank(start, end, region);
- machine().root_device().membank(region)->set_base(m_bios + start);
+ m_space->install_writeonly(start, end, m_bios + start);
}
else if (!BIT(m_registers[SHADOW_WRITE], index) && !BIT(m_registers[ROMCS], index))
{
LOGMEMORY("ISA write from %x to %x\n", start, end);
- m_space->install_write_bank(start, end, region);
- machine().root_device().membank(region)->set_base(m_isa + start - 0xc0000);
+ m_space->install_writeonly(start, end, m_isa + start - 0xc0000);
}
else if (BIT(m_registers[SHADOW_WRITE], index))
{
LOGMEMORY("RAM write from %x to %x\n", start, end);
- m_space->install_write_bank(start, end, region);
- machine().root_device().membank(region)->set_base(m_ram + start);
+ m_space->install_writeonly(start, end, m_ram + start);
}
else
{
@@ -629,24 +609,24 @@ void cs4031_device::update_write_region(int index, const char *region, offs_t st
void cs4031_device::update_read_regions()
{
- update_read_region(0, "read_c0000", 0xc0000, 0xc3fff);
- update_read_region(1, "read_c4000", 0xc4000, 0xc7fff);
- update_read_region(2, "read_c8000", 0xc8000, 0xcbfff);
- update_read_region(3, "read_cc000", 0xcc000, 0xcffff);
- update_read_region(4, "read_d0000", 0xd0000, 0xdffff);
- update_read_region(5, "read_e0000", 0xe0000, 0xeffff);
- update_read_region(6, "read_f0000", 0xf0000, 0xfffff);
+ update_read_region(0, 0xc0000, 0xc3fff);
+ update_read_region(1, 0xc4000, 0xc7fff);
+ update_read_region(2, 0xc8000, 0xcbfff);
+ update_read_region(3, 0xcc000, 0xcffff);
+ update_read_region(4, 0xd0000, 0xdffff);
+ update_read_region(5, 0xe0000, 0xeffff);
+ update_read_region(6, 0xf0000, 0xfffff);
}
void cs4031_device::update_write_regions()
{
- update_write_region(0, "write_c0000", 0xc0000, 0xc3fff);
- update_write_region(1, "write_c4000", 0xc4000, 0xc7fff);
- update_write_region(2, "write_c8000", 0xc8000, 0xcbfff);
- update_write_region(3, "write_cc000", 0xcc000, 0xcffff);
- update_write_region(4, "write_d0000", 0xd0000, 0xdffff);
- update_write_region(5, "write_e0000", 0xe0000, 0xeffff);
- update_write_region(6, "write_f0000", 0xf0000, 0xfffff);
+ update_write_region(0, 0xc0000, 0xc3fff);
+ update_write_region(1, 0xc4000, 0xc7fff);
+ update_write_region(2, 0xc8000, 0xcbfff);
+ update_write_region(3, 0xcc000, 0xcffff);
+ update_write_region(4, 0xd0000, 0xdffff);
+ update_write_region(5, 0xe0000, 0xeffff);
+ update_write_region(6, 0xf0000, 0xfffff);
}
@@ -804,14 +784,14 @@ void cs4031_device::keyb_data_w(uint8_t data)
}
}
-WRITE_LINE_MEMBER( cs4031_device::gatea20_w )
+void cs4031_device::gatea20_w(int state)
{
LOGKEYBOARD("cs4031_device::gatea20_w: %u\n", state);
keyboard_gatea20(state);
}
-WRITE_LINE_MEMBER( cs4031_device::kbrst_w )
+void cs4031_device::kbrst_w(int state)
{
LOGKEYBOARD("cs4031_device::kbrst_w: %u\n", state);
@@ -919,16 +899,13 @@ void cs4031_device::portb_w(uint8_t data)
7 - NMI mask
6:0 - RTC address
*/
-void cs4031_device::rtc_w(offs_t offset, uint8_t data)
+void cs4031_device::rtc_nmi_w(uint8_t data)
{
if (0)
- logerror("cs4031_device::rtc_w: %02x\n", data);
+ logerror("cs4031_device::rtc_nmi_w: %02x\n", data);
- if (offset == 0)
- {
- m_nmi_mask = !BIT(data, 7);
- data &= 0x7f;
- }
+ m_nmi_mask = !BIT(data, 7);
+ data &= 0x7f;
- m_rtc->write(offset, data);
+ m_rtc->address_w(data);
}