summaryrefslogtreecommitdiffstatshomepage
path: root/src/devices/cpu/h8/gt913.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/devices/cpu/h8/gt913.cpp')
-rw-r--r--src/devices/cpu/h8/gt913.cpp123
1 files changed, 63 insertions, 60 deletions
diff --git a/src/devices/cpu/h8/gt913.cpp b/src/devices/cpu/h8/gt913.cpp
index 6819ecb400f..e32ad3f679e 100644
--- a/src/devices/cpu/h8/gt913.cpp
+++ b/src/devices/cpu/h8/gt913.cpp
@@ -1,6 +1,7 @@
// license:BSD-3-Clause
// copyright-holders:Devin Acker
/***************************************************************************
+
Casio GT913 (uPD913)
This chip powers several late-90s/early-2000s Casio keyboards.
@@ -25,19 +26,18 @@
DEFINE_DEVICE_TYPE(GT913, gt913_device, "gt913", "Casio GT913F")
-gt913_device::gt913_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) :
+gt913_device::gt913_device(const machine_config &mconfig, const char *tag, device_t *owner, u32 clock) :
h8_device(mconfig, GT913, tag, owner, clock, address_map_constructor(FUNC(gt913_device::map), this)),
device_mixer_interface(mconfig, *this, 2),
m_rom(*this, DEVICE_SELF),
- data_config("data", ENDIANNESS_BIG, 16, 22, 0),
+ m_data_config("data", ENDIANNESS_BIG, 16, 22, 0),
m_intc(*this, "intc"),
m_sound(*this, "gt_sound"),
m_kbd(*this, "kbd"),
m_io_hle(*this, "io_hle"),
- m_sci(*this, "sci%u", 0),
m_port(*this, "port%u", 1)
{
- has_hc = false;
+ m_has_hc = false;
}
std::unique_ptr<util::disasm_interface> gt913_device::create_disassembler()
@@ -50,6 +50,12 @@ void gt913_device::map(address_map &map)
map(0x0000, 0x7fff).rom();
map(0x8000, 0xbfff).rw(FUNC(gt913_device::data_r), FUNC(gt913_device::data_w));
map(0xc000, 0xf7ff).rom();
+
+ /* ctk530 writes here to latch LED matrix data, which generates an active high strobe on pin 99 (PLE/P16)
+ there's otherwise no external address decoding (or the usual read/write strobes) used for the LED latches.
+ just treat as a 16-bit write-only port for now */
+ map(0xe000, 0xe001).lw16(NAME([this](u16 data) { do_write_port(h8_device::PORT_4, data, ~0); }));
+
map(0xfac0, 0xffbf).ram();
/* ffc0-ffcb: sound */
@@ -82,7 +88,7 @@ void gt913_device::map(address_map &map)
map(0xfff0, 0xfff0).rw(m_port[0], FUNC(h8_port_device::ddr_r), FUNC(h8_port_device::ddr_w));
// port 2 DDR - ctk601 and gz70sp both seem to use only bit 0 to indicate either all inputs or all outputs
// map(0xfff1, 0xfff1).rw(m_port[1], FUNC(h8_port_device::ddr_r), FUNC(h8_port_device::ddr_w));
- map(0xfff1, 0xfff1).lw8(NAME([this](uint8_t data) { m_port[1]->ddr_w(BIT(data, 0) ? 0xff : 0x00); }));
+ map(0xfff1, 0xfff1).lw8(NAME([this](u8 data) { m_port[1]->ddr_w(BIT(data, 0) ? 0xff : 0x00); }));
map(0xfff2, 0xfff2).rw(m_port[0], FUNC(h8_port_device::port_r), FUNC(h8_port_device::dr_w));
map(0xfff3, 0xfff3).rw(m_port[1], FUNC(h8_port_device::port_r), FUNC(h8_port_device::dr_w));
map(0xfff4, 0xfff4).rw(m_port[2], FUNC(h8_port_device::port_r), FUNC(h8_port_device::dr_w));
@@ -91,7 +97,7 @@ void gt913_device::map(address_map &map)
void gt913_device::device_add_mconfig(machine_config &config)
{
- GT913_INTC(config, "intc");
+ GT913_INTC(config, m_intc, *this);
GT913_SOUND(config, m_sound, DERIVED_CLOCK(1, 1));
m_sound->set_device_rom_tag(m_rom);
@@ -99,24 +105,23 @@ void gt913_device::device_add_mconfig(machine_config &config)
m_sound->add_route(1, *this, 1.0, AUTO_ALLOC_INPUT, 1);
GT913_KBD_HLE(config, m_kbd, 0);
- m_kbd->irq_cb().set([this] (int val)
- {
- if (val)
- m_intc->internal_interrupt(5);
- else
- m_intc->clear_interrupt(5);
- });
- GT913_IO_HLE(config, m_io_hle, "intc", 6, 7);
- H8_SCI(config, m_sci[0], "intc", 8, 9, 10, 0);
- H8_SCI(config, m_sci[1], "intc", 11, 12, 13, 0);
-
- H8_PORT(config, m_port[0], h8_device::PORT_1, 0x00, 0x00);
- H8_PORT(config, m_port[1], h8_device::PORT_2, 0x00, 0x00);
- H8_PORT(config, m_port[2], h8_device::PORT_3, 0x00, 0x00);
+ m_kbd->irq_cb().set([this] (int val) {
+ if(val)
+ m_intc->internal_interrupt(5);
+ else
+ m_intc->clear_interrupt(5);
+ });
+ GT913_IO_HLE(config, m_io_hle, *this, m_intc, 6, 7);
+ H8_SCI(config, m_sci[0], 0, *this, m_intc, 8, 9, 10, 0);
+ H8_SCI(config, m_sci[1], 1, *this, m_intc, 11, 12, 13, 0);
+
+ H8_PORT(config, m_port[0], *this, h8_device::PORT_1, 0x00, 0x00);
+ H8_PORT(config, m_port[1], *this, h8_device::PORT_2, 0x00, 0x00);
+ H8_PORT(config, m_port[2], *this, h8_device::PORT_3, 0x00, 0x00);
}
-void gt913_device::uart_rate_w(uint8_t data)
+void gt913_device::uart_rate_w(u8 data)
{
// TODO: how is SCI1 baud rate actually selected?
// gz70sp writes 0x7e to ffe4 to select 31250 baud for MIDI, which doesn't seem right
@@ -124,7 +129,7 @@ void gt913_device::uart_rate_w(uint8_t data)
m_sci[1]->brr_w(data >> 2);
}
-void gt913_device::uart_control_w(offs_t offset, uint8_t data)
+void gt913_device::uart_control_w(offs_t offset, u8 data)
{
const unsigned num = BIT(offset, 2);
/*
@@ -135,42 +140,41 @@ void gt913_device::uart_control_w(offs_t offset, uint8_t data)
m_sci[num]->scr_w((data & 0x0f) << 4);
}
-uint8_t gt913_device::uart_control_r(offs_t offset)
+u8 gt913_device::uart_control_r(offs_t offset)
{
const unsigned num = BIT(offset, 2);
return (m_sci[num]->ssr_r() & 0xf0) | (m_sci[num]->scr_r() >> 4);
}
-void gt913_device::syscr_w(uint8_t data)
+void gt913_device::syscr_w(u8 data)
{
- if (BIT(m_syscr ^ data, 2))
- // NMI active edge has changed
- m_intc->set_input(INPUT_LINE_NMI, CLEAR_LINE);
+ // NMI active edge
+ m_intc->set_nmi_edge(BIT(data, 2));
m_syscr = data;
}
-uint8_t gt913_device::syscr_r()
+u8 gt913_device::syscr_r()
{
return m_syscr;
}
-void gt913_device::data_w(offs_t offset, uint8_t data)
+void gt913_device::data_w(offs_t offset, u8 data)
{
m_data.write_byte(offset | (m_banknum & 0xff) << 14, data);
}
-uint8_t gt913_device::data_r(offs_t offset)
+u8 gt913_device::data_r(offs_t offset)
{
return m_data.read_byte(offset | (m_banknum & 0xff) << 14);
}
-uint8_t gt913_device::read8ib(uint32_t adr)
+u8 gt913_device::read8ib(u32 adr)
{
- if (BIT(m_syscr, 0))
+ if(BIT(m_syscr, 0))
// indirect bank disabled
- return program.read_byte(adr);
- else if ((IR[0] & 0x0070) == 0)
+ return m_program.read_byte(adr);
+ else if((m_IR[0] & 0x0070) == 0)
// indirect bank enabled, using bankh for r0
return m_data.read_byte(adr | ((m_banknum >> 6) << 16));
else
@@ -178,12 +182,12 @@ uint8_t gt913_device::read8ib(uint32_t adr)
return m_data.read_byte(adr | ((m_banknum & 0x3f) << 16));
}
-void gt913_device::write8ib(uint32_t adr, uint8_t data)
+void gt913_device::write8ib(u32 adr, u8 data)
{
- if (BIT(m_syscr, 0))
+ if(BIT(m_syscr, 0))
// indirect bank disabled
- program.write_byte(adr, data);
- else if ((IR[0] & 0x0070) == 0)
+ m_program.write_byte(adr, data);
+ else if((m_IR[0] & 0x0070) == 0)
// indirect bank enabled, using bankh for r0
m_data.write_byte(adr | ((m_banknum >> 6) << 16), data);
else
@@ -191,14 +195,14 @@ void gt913_device::write8ib(uint32_t adr, uint8_t data)
m_data.write_byte(adr | ((m_banknum & 0x3f) << 16), data);
}
-uint16_t gt913_device::read16ib(uint32_t adr)
+u16 gt913_device::read16ib(u32 adr)
{
adr &= ~1;
- if (BIT(m_syscr, 0))
+ if(BIT(m_syscr, 0))
// indirect bank disabled
- return program.read_word(adr);
- else if ((IR[0] & 0x0070) == 0)
+ return m_program.read_word(adr);
+ else if((m_IR[0] & 0x0070) == 0)
// indirect bank enabled, using bankh for r0
return m_data.read_word(adr | ((m_banknum >> 6) << 16));
else
@@ -206,14 +210,14 @@ uint16_t gt913_device::read16ib(uint32_t adr)
return m_data.read_word(adr | ((m_banknum & 0x3f) << 16));
}
-void gt913_device::write16ib(uint32_t adr, uint16_t data)
+void gt913_device::write16ib(u32 adr, u16 data)
{
adr &= ~1;
- if (BIT(m_syscr, 0))
+ if(BIT(m_syscr, 0))
// indirect bank disabled
- program.write_word(adr, data);
- else if ((IR[0] & 0x0070) == 0)
+ m_program.write_word(adr, data);
+ else if((m_IR[0] & 0x0070) == 0)
// indirect bank enabled, using bankh for r0
m_data.write_word(adr | ((m_banknum >> 6) << 16), data);
else
@@ -223,12 +227,12 @@ void gt913_device::write16ib(uint32_t adr, uint16_t data)
void gt913_device::irq_setup()
{
- CCR |= F_H;
+ m_CCR |= F_H;
}
void gt913_device::update_irq_filter()
{
- if (CCR & F_H)
+ if(m_CCR & F_H)
m_intc->set_filter(2, -1);
else
m_intc->set_filter(0, -1);
@@ -236,12 +240,12 @@ void gt913_device::update_irq_filter()
void gt913_device::interrupt_taken()
{
- standard_irq_callback(m_intc->interrupt_taken(taken_irq_vector));
+ standard_irq_callback(m_intc->interrupt_taken(m_taken_irq_vector), m_NPC);
}
-void gt913_device::internal_update(uint64_t current_time)
+void gt913_device::internal_update(u64 current_time)
{
- uint64_t event_time = 0;
+ u64 event_time = 0;
add_event(event_time, m_sci[0]->internal_update(current_time));
add_event(event_time, m_sci[1]->internal_update(current_time));
@@ -249,23 +253,22 @@ void gt913_device::internal_update(uint64_t current_time)
recompute_bcount(event_time);
}
-void gt913_device::execute_set_input(int inputnum, int state)
+void gt913_device::notify_standby(int state)
{
- if (inputnum == INPUT_LINE_NMI)
- {
- if (BIT(m_syscr, 2))
- state ^= ASSERT_LINE;
- }
+ m_sci[0]->notify_standby(state);
+ m_sci[1]->notify_standby(state);
+}
+void gt913_device::execute_set_input(int inputnum, int state)
+{
m_intc->set_input(inputnum, state);
}
device_memory_interface::space_config_vector gt913_device::memory_space_config() const
{
return space_config_vector{
- std::make_pair(AS_PROGRAM, &program_config),
- std::make_pair(AS_IO, &io_config),
- std::make_pair(AS_DATA, &data_config)
+ std::make_pair(AS_PROGRAM, &m_program_config),
+ std::make_pair(AS_DATA, &m_data_config)
};
}