mirror of
https://github.com/holub/mame
synced 2025-05-04 21:43:05 +03:00
cpu/apexc: Replace single-location tape I/O space with callbacks (nw)
This commit is contained in:
parent
3f90200e4f
commit
183b56a7d1
@ -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));
|
||||
|
@ -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
|
||||
|
@ -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)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user