summaryrefslogtreecommitdiffstatshomepage
path: root/src/devices/cpu/m6805/m68705.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/devices/cpu/m6805/m68705.cpp')
-rw-r--r--src/devices/cpu/m6805/m68705.cpp81
1 files changed, 52 insertions, 29 deletions
diff --git a/src/devices/cpu/m6805/m68705.cpp b/src/devices/cpu/m6805/m68705.cpp
index 067cd06b811..30f498980c6 100644
--- a/src/devices/cpu/m6805/m68705.cpp
+++ b/src/devices/cpu/m6805/m68705.cpp
@@ -6,7 +6,7 @@
*
* TODO
* - INT2 and miscellaneous register
- * - A/D peripheral
+ * - improve A/D peripheral
* - SPI peripheral
* - multiple timer variants
*/
@@ -20,13 +20,13 @@
* Configurable logging
****************************************************************************/
-#define LOG_GENERAL (1U << 0)
-#define LOG_INT (1U << 1)
-#define LOG_IOPORT (1U << 2)
-#define LOG_TIMER (1U << 3)
-#define LOG_EPROM (1U << 4)
+#define LOG_INT (1U << 1)
+#define LOG_IOPORT (1U << 2)
+#define LOG_TIMER (1U << 3)
+#define LOG_EPROM (1U << 4)
+#define LOG_AD (1U << 5)
-//#define VERBOSE (LOG_GENERAL | LOG_IOPORT | LOG_TIMER | LOG_EPROM)
+//#define VERBOSE (LOG_GENERAL | LOG_IOPORT | LOG_TIMER | LOG_EPROM | LOG_AD)
//#define LOG_OUTPUT_FUNC printf
#include "logmacro.h"
@@ -34,6 +34,7 @@
#define LOGIOPORT(...) LOGMASKED(LOG_IOPORT, __VA_ARGS__)
#define LOGTIMER(...) LOGMASKED(LOG_TIMER, __VA_ARGS__)
#define LOGEPROM(...) LOGMASKED(LOG_EPROM, __VA_ARGS__)
+#define LOGAD(...) LOGMASKED(LOG_AD, __VA_ARGS__)
namespace {
@@ -222,8 +223,9 @@ m6805_hmos_device::m6805_hmos_device(machine_config const &mconfig, char const *
, m_port_input{ 0xff, 0xff, 0xff, 0xff }
, m_port_latch{ 0xff, 0xff, 0xff, 0xff }
, m_port_ddr{ 0x00, 0x00, 0x00, 0x00 }
- , m_port_cb_r(*this)
+ , m_port_cb_r(*this, 0xff)
, m_port_cb_w(*this)
+ , m_portan_cb_r(*this, 0xff)
, m_ram_size(ram_size)
{
}
@@ -231,7 +233,7 @@ m6805_hmos_device::m6805_hmos_device(machine_config const &mconfig, char const *
m68705_device::m68705_device(machine_config const &mconfig, char const *tag, device_t *owner, u32 clock, device_type type, u32 addr_width, unsigned ram_size)
: m6805_hmos_device(mconfig, tag, owner, clock, type, addr_width, ram_size)
, device_nvram_interface(mconfig, *this)
- , m_user_rom(*this, DEVICE_SELF, u32(1) << addr_width)
+ , m_user_rom(*this, DEVICE_SELF)
, m_vihtp(CLEAR_LINE)
, m_pcr(0xff)
, m_pl_data(0xff)
@@ -283,7 +285,7 @@ template <std::size_t N> void m6805_hmos_device::set_port_mask(u8 mask)
template <std::size_t N> u8 m6805_hmos_device::port_r()
{
- if (!m_port_cb_r[N].isnull())
+ if (!m_port_cb_r[N].isunset())
{
u8 const newval(m_port_cb_r[N](0, ~m_port_ddr[N] & ~m_port_mask[N]) & ~m_port_mask[N]);
if (newval != m_port_input[N])
@@ -320,7 +322,7 @@ template <std::size_t N> void m6805_hmos_device::port_ddr_w(u8 data)
template <std::size_t N> void m6805_hmos_device::port_cb_w()
{
- u8 const data(m_port_open_drain[N] ? m_port_latch[N] | ~m_port_ddr[N] : m_port_latch[N]);
+ u8 const data(m_port_open_drain[N] ? (m_port_latch[N] | ~m_port_ddr[N]) : m_port_latch[N]);
u8 const mask(m_port_open_drain[N] ? (~m_port_latch[N] & m_port_ddr[N]) : m_port_ddr[N]);
m_port_cb_w[N](0, data, mask);
}
@@ -360,8 +362,7 @@ void m68705_device::pcr_w(u8 data)
u8 m6805_hmos_device::acr_r()
{
- logerror("unsupported read ACR\n");
- return 0xff;
+ return m_acr_mux | 0x80 | 0x78;
}
void m6805_hmos_device::acr_w(u8 data)
@@ -389,18 +390,27 @@ void m6805_hmos_device::acr_w(u8 data)
// on completion, ACR7 is set, result is placed in ARR, and new conversion starts
// writing to ACR aborts current conversion, clears ACR7, and starts new conversion
- logerror("unsupported write ACR = %02X\n", data);
+ m_acr_mux = data & 7;
+ LOGAD("write ACR MUX = %d\n", m_acr_mux);
}
u8 m6805_hmos_device::arr_r()
{
- logerror("unsupported read ARR\n");
- return 0xff;
+ if (m_acr_mux < 4)
+ {
+ u8 val = m_portan_cb_r[m_acr_mux]();
+ LOGAD("read ARR AN%d = %02X\n", m_acr_mux, val);
+ return val;
+ }
+ else
+ {
+ logerror("unsupported read ARR VR, MUX = %d\n", m_acr_mux);
+ return 0xff;
+ }
}
void m6805_hmos_device::arr_w(u8 data)
{
- logerror("unsupported write ARR = %02X\n", data);
}
void m6805_hmos_device::device_start()
@@ -410,11 +420,11 @@ void m6805_hmos_device::device_start()
save_item(NAME(m_port_input));
save_item(NAME(m_port_latch));
save_item(NAME(m_port_ddr));
+ save_item(NAME(m_acr_mux));
+ save_item(NAME(m_mr));
// initialise digital I/O
for (u8 &input : m_port_input) input = 0xff;
- m_port_cb_r.resolve_all();
- m_port_cb_w.resolve_all_safe();
add_port_latch_state<0>();
add_port_latch_state<1>();
@@ -424,6 +434,10 @@ void m6805_hmos_device::device_start()
add_port_ddr_state<1>();
add_port_ddr_state<2>();
+ // initialise misc
+ m_acr_mux = 0;
+ m_mr = 0;
+
m_timer.start(M6805_PS);
}
@@ -536,14 +550,16 @@ void m68705_device::nvram_default()
{
}
-void m68705_device::nvram_read(emu_file &file)
+bool m68705_device::nvram_read(util::read_stream &file)
{
- file.read(&m_user_rom[0], m_user_rom.bytes());
+ auto const [err, actual] = read(file, &m_user_rom[0], m_user_rom.bytes());
+ return !err && (actual == m_user_rom.bytes());
}
-void m68705_device::nvram_write(emu_file &file)
+bool m68705_device::nvram_write(util::write_stream &file)
{
- file.write(&m_user_rom[0], m_user_rom.bytes());
+ auto const [err, actual] = write(file, &m_user_rom[0], m_user_rom.bytes());
+ return !err;
}
void m6805_hmos_device::interrupt()
@@ -566,11 +582,11 @@ void m6805_hmos_device::interrupt()
pushbyte<false>(m_cc);
}
SEI;
- standard_irq_callback(0);
if (BIT(m_pending_interrupts, M6805_IRQ_LINE))
{
LOGINT("servicing /INT interrupt\n");
+ standard_irq_callback(0, m_pc.w.l);
m_pending_interrupts &= ~(1 << M6805_IRQ_LINE);
if (m_params.m_addr_width > 13)
rm16<true>(M6805_VECTOR_INT, m_pc);
@@ -580,6 +596,7 @@ void m6805_hmos_device::interrupt()
else if (BIT(m_pending_interrupts, M6805_INT_TIMER))
{
LOGINT("servicing timer/counter interrupt\n");
+ standard_irq_callback(1, m_pc.w.l);
if (m_params.m_addr_width > 13)
rm16<true>(M6805_VECTOR_TIMER, m_pc);
else
@@ -711,8 +728,6 @@ m68705r_device::m68705r_device(machine_config const &mconfig, char const *tag, d
void m68705r_device::device_start()
{
m68705u_device::device_start();
-
- // TODO: ADC
}
std::unique_ptr<util::disasm_interface> m68705r_device::create_disassembler()
@@ -807,7 +822,8 @@ m6805p2_device::m6805p2_device(machine_config const &mconfig, char const *tag, d
* support prescalar clear, however the 1988 databook indicates the
* M6805P2 does?
*/
- //m_timer.set_options(m6805_timer::TIMER_NPC);
+ m_timer.set_options(m6805_timer::TIMER_MOR /* | m6805::TIMER_NPC */);
+ m_timer.set_source(m6805_timer::CLOCK_TIMER);
set_port_mask<2>(0xf0); // Port C is four bits wide
set_port_mask<3>(0xff); // Port D isn't present
@@ -816,6 +832,9 @@ m6805p2_device::m6805p2_device(machine_config const &mconfig, char const *tag, d
m6805p6_device::m6805p6_device(machine_config const &mconfig, char const *tag, device_t *owner, uint32_t clock)
: m6805_mrom_device(mconfig, tag, owner, clock, M6805P6, 11, 64)
{
+ m_timer.set_options(m6805_timer::TIMER_MOR /* | m6805::TIMER_NPC */);
+ m_timer.set_source(m6805_timer::CLOCK_TIMER);
+
set_port_mask<2>(0xf0); // Port C is four bits wide
set_port_mask<3>(0xff); // Port D isn't present
}
@@ -823,6 +842,8 @@ m6805p6_device::m6805p6_device(machine_config const &mconfig, char const *tag, d
m6805r2_device::m6805r2_device(machine_config const &mconfig, char const *tag, device_t *owner, uint32_t clock)
: m6805_mrom_device(mconfig, tag, owner, clock, M6805R2, 12, 64)
{
+ m_timer.set_options(m6805_timer::TIMER_MOR);
+ m_timer.set_source(m6805_timer::CLOCK_TIMER);
}
m6805r3_device::m6805r3_device(machine_config const &mconfig, char const *tag, device_t *owner, uint32_t clock)
@@ -834,6 +855,8 @@ m6805r3_device::m6805r3_device(machine_config const &mconfig, char const *tag, d
m6805u2_device::m6805u2_device(machine_config const &mconfig, char const *tag, device_t *owner, uint32_t clock)
: m6805_mrom_device(mconfig, tag, owner, clock, M6805U2, 12, 64)
{
+ m_timer.set_options(m6805_timer::TIMER_MOR);
+ m_timer.set_source(m6805_timer::CLOCK_TIMER);
}
m6805u3_device::m6805u3_device(machine_config const &mconfig, char const *tag, device_t *owner, uint32_t clock)
@@ -922,7 +945,7 @@ void m6805_mrom_device::internal_map(address_map &map)
void m6805r2_device::internal_map(address_map &map)
{
- m6805_hmos_device::internal_map(map);
+ m6805_mrom_device::internal_map(map);
map(0x000e, 0x000e).rw(FUNC(m6805r2_device::acr_r), FUNC(m6805r2_device::acr_w));
map(0x000f, 0x000f).rw(FUNC(m6805r2_device::arr_r), FUNC(m6805r2_device::arr_w));
@@ -930,7 +953,7 @@ void m6805r2_device::internal_map(address_map &map)
void m6805r3_device::internal_map(address_map &map)
{
- m6805_hmos_device::internal_map(map);
+ m6805_mrom_device::internal_map(map);
map(0x000e, 0x000e).rw(FUNC(m6805r3_device::acr_r), FUNC(m6805r3_device::acr_w));
map(0x000f, 0x000f).rw(FUNC(m6805r3_device::arr_r), FUNC(m6805r3_device::arr_w));