summaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
author AJR <ajrhacker@users.noreply.github.com>2018-01-14 17:43:28 -0500
committer AJR <ajrhacker@users.noreply.github.com>2018-01-14 17:43:30 -0500
commit183b56a7d10c967e0911edc088cab508cb8adb8d (patch)
tree3aa96dab7727c86303a8690617ccca65e9ae546f
parent3f90200e4f41d792d9d8a27771be202538839732 (diff)
cpu/apexc: Replace single-location tape I/O space with callbacks (nw)
-rw-r--r--src/devices/cpu/apexc/apexc.cpp14
-rw-r--r--src/devices/cpu/apexc/apexc.h23
-rw-r--r--src/mame/drivers/apexc.cpp8
3 files changed, 31 insertions, 14 deletions
diff --git a/src/devices/cpu/apexc/apexc.cpp b/src/devices/cpu/apexc/apexc.cpp
index 4278d5b2d48..9f74a019fff 100644
--- a/src/devices/cpu/apexc/apexc.cpp
+++ b/src/devices/cpu/apexc/apexc.cpp
@@ -341,7 +341,8 @@ DEFINE_DEVICE_TYPE(APEXC, apexc_cpu_device, "apexc_cpu", "APEXC")
apexc_cpu_device::apexc_cpu_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock)
: cpu_device(mconfig, APEXC, tag, owner, clock)
, m_program_config("program", ENDIANNESS_BIG, 32, 15, 0)
- , m_io_config("io", ENDIANNESS_BIG, 8, 1, 0)
+ , m_tape_read_cb(*this)
+ , m_tape_punch_cb(*this)
, m_a(0)
, m_r(0)
, m_cr(0)
@@ -355,8 +356,7 @@ apexc_cpu_device::apexc_cpu_device(const machine_config &mconfig, const char *ta
device_memory_interface::space_config_vector apexc_cpu_device::memory_space_config() const
{
return space_config_vector {
- std::make_pair(AS_PROGRAM, &m_program_config),
- std::make_pair(AS_IO, &m_io_config)
+ std::make_pair(AS_PROGRAM, &m_program_config)
};
}
@@ -440,12 +440,12 @@ void apexc_cpu_device::word_write(uint32_t address, uint32_t data, uint32_t mask
uint8_t apexc_cpu_device::papertape_read()
{
- return m_io->read_byte(0) & 0x1f;
+ return m_tape_read_cb() & 0x1f;
}
void apexc_cpu_device::papertape_punch(uint8_t data)
{
- m_io->write_byte(0, data);
+ m_tape_punch_cb(data);
}
/*
@@ -764,8 +764,10 @@ special_fetch:
void apexc_cpu_device::device_start()
{
+ m_tape_read_cb.resolve_safe(0);
+ m_tape_punch_cb.resolve_safe();
+
m_program = &space(AS_PROGRAM);
- m_io = &space(AS_IO);
save_item(NAME(m_a));
save_item(NAME(m_r));
diff --git a/src/devices/cpu/apexc/apexc.h b/src/devices/cpu/apexc/apexc.h
index 92cc60d7f09..46b45e7bc2c 100644
--- a/src/devices/cpu/apexc/apexc.h
+++ b/src/devices/cpu/apexc/apexc.h
@@ -6,6 +6,12 @@
#pragma once
+#define MCFG_APEXC_TAPE_READ_CB(_devcb) \
+ devcb = &apexc_cpu_device::set_tape_read_cb(*device, DEVCB_##_devcb);
+
+#define MCFG_APEXC_TAPE_PUNCH_CB(_devcb) \
+ devcb = &apexc_cpu_device::set_tape_punch_cb(*device, DEVCB_##_devcb);
+
enum
{
APEXC_CR =1, /* control register */
@@ -22,6 +28,18 @@ public:
// construction/destruction
apexc_cpu_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock);
+ // static configuration
+ template<class Object>
+ static devcb_base &set_tape_read_cb(device_t &device, Object &&object)
+ {
+ return downcast<apexc_cpu_device &>(device).m_tape_read_cb.set_callback(std::forward<Object>(object));
+ }
+ template<class Object>
+ static devcb_base &set_tape_punch_cb(device_t &device, Object &&object)
+ {
+ return downcast<apexc_cpu_device &>(device).m_tape_punch_cb.set_callback(std::forward<Object>(object));
+ }
+
protected:
// device-level overrides
virtual void device_start() override;
@@ -56,7 +74,9 @@ protected:
void execute();
address_space_config m_program_config;
- address_space_config m_io_config;
+
+ devcb_read8 m_tape_read_cb;
+ devcb_write8 m_tape_punch_cb;
uint32_t m_a; /* accumulator */
uint32_t m_r; /* register */
@@ -70,7 +90,6 @@ protected:
uint32_t m_pc; /* address of next instruction for the disassembler */
address_space *m_program;
- address_space *m_io;
int m_icount;
// For state
diff --git a/src/mame/drivers/apexc.cpp b/src/mame/drivers/apexc.cpp
index fb4c5f6ca9e..4335bad4df0 100644
--- a/src/mame/drivers/apexc.cpp
+++ b/src/mame/drivers/apexc.cpp
@@ -852,11 +852,6 @@ static ADDRESS_MAP_START(apexc_mem_map, AS_PROGRAM, 32, apexc_state )
#endif
ADDRESS_MAP_END
-static ADDRESS_MAP_START(apexc_io_map, AS_IO, 8, apexc_state )
- AM_RANGE(0x00, 0x00) AM_READ(tape_read)
- AM_RANGE(0x00, 0x00) AM_WRITE(tape_write)
-ADDRESS_MAP_END
-
static MACHINE_CONFIG_START( apexc )
@@ -864,7 +859,8 @@ static MACHINE_CONFIG_START( apexc )
/* APEXC CPU @ 2.0 kHz (memory word clock frequency) */
MCFG_CPU_ADD("maincpu", APEXC, 2000)
MCFG_CPU_PROGRAM_MAP(apexc_mem_map)
- MCFG_CPU_IO_MAP(apexc_io_map)
+ MCFG_APEXC_TAPE_READ_CB(READ8(apexc_state, tape_read))
+ MCFG_APEXC_TAPE_PUNCH_CB(WRITE8(apexc_state, tape_write))
/* dummy interrupt: handles the control panel */
MCFG_CPU_VBLANK_INT_DRIVER("screen", apexc_state, apexc_interrupt)