mirror of
https://github.com/holub/mame
synced 2025-05-31 01:51:46 +03:00
Next-gen config: make address map config not look like arse
This commit is contained in:
parent
f5e90f3e04
commit
befb02ba66
@ -14,8 +14,8 @@
|
||||
#error Dont include this file directly; include emu.h instead.
|
||||
#endif
|
||||
|
||||
#ifndef __ADDRMAP_H__
|
||||
#define __ADDRMAP_H__
|
||||
#ifndef MAME_EMU_ADDRMAP_H
|
||||
#define MAME_EMU_ADDRMAP_H
|
||||
|
||||
|
||||
|
||||
@ -47,16 +47,12 @@ enum map_handler_type
|
||||
class map_handler_data
|
||||
{
|
||||
public:
|
||||
map_handler_data()
|
||||
: m_type(AMH_NONE),
|
||||
m_bits(0),
|
||||
m_name(nullptr),
|
||||
m_tag(nullptr) { }
|
||||
map_handler_data() { }
|
||||
|
||||
map_handler_type m_type; // type of the handler
|
||||
u8 m_bits; // width of the handler in bits, or 0 for default
|
||||
const char * m_name; // name of the handler
|
||||
const char * m_tag; // tag for I/O ports and banks
|
||||
map_handler_type m_type = AMH_NONE; // type of the handler
|
||||
u8 m_bits = 0; // width of the handler in bits, or 0 for default
|
||||
const char * m_name = nullptr; // name of the handler
|
||||
const char * m_tag = nullptr; // tag for I/O ports and banks
|
||||
};
|
||||
|
||||
|
||||
@ -485,4 +481,4 @@ public:
|
||||
void map_validity_check(validity_checker &valid, int spacenum) const;
|
||||
};
|
||||
|
||||
#endif /* __ADDRMAP_H__ */
|
||||
#endif // MAME_EMU_ADDRMAP_H
|
||||
|
@ -90,4 +90,18 @@ inline void device_t::logerror(Format &&fmt, Params &&... args) const
|
||||
}
|
||||
}
|
||||
|
||||
template <typename T, typename Ret, typename... Params>
|
||||
std::enable_if_t<device_memory_interface::is_related_class<device_t, T>::value> device_memory_interface::set_addrmap(int spacenum, Ret (T::*func)(Params... args))
|
||||
{
|
||||
device_t &dev(device().mconfig().current_device());
|
||||
set_addrmap(spacenum, address_map_constructor(func, dev.tag(), &downcast<T &>(dev)));
|
||||
}
|
||||
|
||||
template <typename T, typename Ret, typename... Params>
|
||||
std::enable_if_t<!device_memory_interface::is_related_class<device_t, T>::value> device_memory_interface::set_addrmap(int spacenum, Ret (T::*func)(Params... args))
|
||||
{
|
||||
device_t &dev(device().mconfig().current_device());
|
||||
set_addrmap(spacenum, address_map_constructor(func, dev.tag(), &dynamic_cast<T &>(dev)));
|
||||
}
|
||||
|
||||
#endif // MAME_EMU_DEVICE_IPP
|
||||
|
@ -140,10 +140,10 @@ public:
|
||||
|
||||
// inline configuration helpers
|
||||
void set_disable() { m_disabled = true; }
|
||||
template <typename Object> void set_vblank_int(Object &&cb, const char *tag, int rate = 0)
|
||||
template <typename Object> void set_vblank_int(Object &&cb, const char *tag, int rate = 0)
|
||||
{
|
||||
m_vblank_interrupt = std::forward<Object>(cb);
|
||||
m_vblank_interrupt_screen = tag;
|
||||
m_vblank_interrupt_screen = tag;
|
||||
}
|
||||
template <typename Object> void set_periodic_int(Object &&cb, const attotime &rate)
|
||||
{
|
||||
@ -290,7 +290,7 @@ private:
|
||||
// configuration
|
||||
bool m_disabled; // disabled from executing?
|
||||
device_interrupt_delegate m_vblank_interrupt; // for interrupts tied to VBLANK
|
||||
const char * m_vblank_interrupt_screen; // the screen that causes the VBLANK interrupt
|
||||
const char * m_vblank_interrupt_screen; // the screen that causes the VBLANK interrupt
|
||||
device_interrupt_delegate m_timed_interrupt; // for interrupts not tied to VBLANK
|
||||
attotime m_timed_interrupt_period; // period for periodic interrupts
|
||||
|
||||
|
@ -17,6 +17,8 @@
|
||||
#ifndef MAME_EMU_DIMEMORY_H
|
||||
#define MAME_EMU_DIMEMORY_H
|
||||
|
||||
#include <type_traits>
|
||||
|
||||
|
||||
//**************************************************************************
|
||||
// CONSTANTS
|
||||
@ -72,6 +74,11 @@ constexpr int TRANSLATE_FETCH_DEBUG = (TRANSLATE_FETCH | TRANSLATE_DEBUG_MAS
|
||||
class device_memory_interface : public device_interface
|
||||
{
|
||||
friend class device_scheduler;
|
||||
template <typename T, typename U> struct is_related_class { static constexpr bool value = std::is_convertible<std::add_pointer_t<T>, std::add_pointer_t<U> >::value; };
|
||||
template <typename T, typename U> struct is_related_device { static constexpr bool value = emu::detail::is_device_implementation<T>::value && is_related_class<T, U>::value; };
|
||||
template <typename T, typename U> struct is_related_interface { static constexpr bool value = emu::detail::is_device_interface<T>::value && is_related_class<T, U>::value; };
|
||||
template <typename T, typename U> struct is_unrelated_device { static constexpr bool value = emu::detail::is_device_implementation<T>::value && !is_related_class<T, U>::value; };
|
||||
template <typename T, typename U> struct is_unrelated_interface { static constexpr bool value = emu::detail::is_device_interface<T>::value && !is_related_class<T, U>::value; };
|
||||
|
||||
public:
|
||||
// construction/destruction
|
||||
@ -83,7 +90,19 @@ public:
|
||||
const address_space_config *space_config(int spacenum = 0) const { return spacenum >= 0 && spacenum < int(m_address_config.size()) ? m_address_config[spacenum] : nullptr; }
|
||||
int max_space_count() const { return m_address_config.size(); }
|
||||
|
||||
// static inline configuration helpers
|
||||
// configuration helpers
|
||||
template <typename T, typename U, typename Ret, typename... Params>
|
||||
std::enable_if_t<is_related_device<T, U>::value> set_addrmap(int spacenum, T &obj, Ret (U::*func)(Params... args)) { set_addrmap(spacenum, address_map_constructor(func, obj.tag(), &downcast<U &>(obj))); }
|
||||
template <typename T, typename U, typename Ret, typename... Params>
|
||||
std::enable_if_t<is_related_interface<T, U>::value> set_addrmap(int spacenum, T &obj, Ret (U::*func)(Params... args)) { set_addrmap(spacenum, address_map_constructor(func, obj.device().tag(), &downcast<U &>(obj))); }
|
||||
template <typename T, typename U, typename Ret, typename... Params>
|
||||
std::enable_if_t<is_unrelated_device<T, U>::value> set_addrmap(int spacenum, T &obj, Ret (U::*func)(Params... args)) { set_addrmap(spacenum, address_map_constructor(func, obj.tag(), &dynamic_cast<U &>(obj))); }
|
||||
template <typename T, typename U, typename Ret, typename... Params>
|
||||
std::enable_if_t<is_unrelated_interface<T, U>::value> set_addrmap(int spacenum, T &obj, Ret (U::*func)(Params... args)) { set_addrmap(spacenum, address_map_constructor(func, obj.device().tag(), &dynamic_cast<U &>(obj))); }
|
||||
template <typename T, typename Ret, typename... Params>
|
||||
std::enable_if_t<is_related_class<device_t, T>::value> set_addrmap(int spacenum, Ret (T::*func)(Params... args));
|
||||
template <typename T, typename Ret, typename... Params>
|
||||
std::enable_if_t<!is_related_class<device_t, T>::value> set_addrmap(int spacenum, Ret (T::*func)(Params... args));
|
||||
void set_addrmap(int spacenum, address_map_constructor map);
|
||||
|
||||
// basic information getters
|
||||
|
@ -6,6 +6,18 @@
|
||||
|
||||
Speaker output sound device.
|
||||
|
||||
Speakers have (x, y, z) coordinates in 3D space:
|
||||
* Observer is at position (0, 0, 0)
|
||||
* Positive x is to the right of the observer
|
||||
* Negative x is to the left of the observer
|
||||
* Positive y is above the observer
|
||||
* Negative y is below the observer
|
||||
* Positive z is in front of the observer
|
||||
* Negative z is behind the observer
|
||||
|
||||
Currently, MAME only considers the sign of the x coordinate (not its
|
||||
magnitude), and completely ignores the y and z coordinates.
|
||||
|
||||
***************************************************************************/
|
||||
#ifndef MAME_EMU_SPEAKER_H
|
||||
#define MAME_EMU_SPEAKER_H
|
||||
|
@ -2144,14 +2144,14 @@ MACHINE_CONFIG_END
|
||||
// Variants with additional digital sound board
|
||||
MACHINE_CONFIG_START(ksys573_state::k573d)
|
||||
konami573(config);
|
||||
m_maincpu->set_addrmap(AS_PROGRAM, address_map_constructor(&std::remove_pointer_t<decltype(this)>::konami573d_map, tag(), this));
|
||||
m_maincpu->set_addrmap(AS_PROGRAM, &ksys573_state::konami573d_map);
|
||||
MCFG_KONAMI_573_DIGITAL_IO_BOARD_ADD( "k573dio", XTAL(19'660'800) )
|
||||
MACHINE_CONFIG_END
|
||||
|
||||
// Variants with additional analogue i/o board
|
||||
MACHINE_CONFIG_START(ksys573_state::k573a)
|
||||
konami573(config);
|
||||
m_maincpu->set_addrmap(AS_PROGRAM, address_map_constructor(&std::remove_pointer_t<decltype(this)>::konami573a_map, tag(), this));
|
||||
m_maincpu->set_addrmap(AS_PROGRAM, &ksys573_state::konami573a_map);
|
||||
MACHINE_CONFIG_END
|
||||
|
||||
MACHINE_CONFIG_START(ksys573_state::pccard1_16mb)
|
||||
@ -2409,7 +2409,7 @@ MACHINE_CONFIG_END
|
||||
|
||||
MACHINE_CONFIG_START(ksys573_state::fbaitbc)
|
||||
konami573(config);
|
||||
m_maincpu->set_addrmap(AS_PROGRAM, address_map_constructor(&std::remove_pointer_t<decltype(this)>::fbaitbc_map, tag(), this));
|
||||
m_maincpu->set_addrmap(AS_PROGRAM, &ksys573_state::fbaitbc_map);
|
||||
|
||||
MCFG_DEVICE_ADD(m_upd4701, UPD4701A, 0)
|
||||
MCFG_UPD4701_PORTY("uPD4701_y")
|
||||
@ -2449,7 +2449,7 @@ MACHINE_CONFIG_END
|
||||
|
||||
MACHINE_CONFIG_START(ksys573_state::pnchmn)
|
||||
konami573(config);
|
||||
m_maincpu->set_addrmap(AS_PROGRAM, address_map_constructor(&std::remove_pointer_t<decltype(this)>::konami573a_map, tag(), this));
|
||||
m_maincpu->set_addrmap(AS_PROGRAM, &ksys573_state::konami573a_map);
|
||||
|
||||
cassxi(config);
|
||||
pccard1_32mb(config);
|
||||
@ -2465,7 +2465,7 @@ MACHINE_CONFIG_END
|
||||
|
||||
MACHINE_CONFIG_START(ksys573_state::gunmania)
|
||||
konami573(config);
|
||||
m_maincpu->set_addrmap(AS_PROGRAM, address_map_constructor(&std::remove_pointer_t<decltype(this)>::gunmania_map, tag(), this));
|
||||
m_maincpu->set_addrmap(AS_PROGRAM, &ksys573_state::gunmania_map);
|
||||
|
||||
DS2401( config, "gunmania_id" );
|
||||
pccard2_32mb(config);
|
||||
|
@ -143,8 +143,8 @@ static const z80_daisy_config tranz330_daisy_chain[] =
|
||||
void tranz330_state::tranz330(machine_config &config)
|
||||
{
|
||||
Z80(config, m_cpu, XTAL(7'159'090)/2); //*
|
||||
m_cpu->set_addrmap(AS_PROGRAM, address_map_constructor(&tranz330_state::tranz330_mem, tag(), this));
|
||||
m_cpu->set_addrmap(AS_IO, address_map_constructor(&tranz330_state::tranz330_io, tag(), this));
|
||||
m_cpu->set_addrmap(AS_PROGRAM, &tranz330_state::tranz330_mem);
|
||||
m_cpu->set_addrmap(AS_IO, &tranz330_state::tranz330_io);
|
||||
m_cpu->set_daisy_config(tranz330_daisy_chain);
|
||||
|
||||
CLOCK(config, "ctc_clock", XTAL(7'159'090)/4) // ?
|
||||
|
@ -137,9 +137,9 @@ GFXDECODE_END
|
||||
|
||||
MACHINE_CONFIG_START(zorba_state::zorba)
|
||||
// basic machine hardware
|
||||
MCFG_DEVICE_ADD(m_maincpu, Z80, 24_MHz_XTAL / 6)
|
||||
MCFG_DEVICE_PROGRAM_MAP(zorba_mem)
|
||||
MCFG_DEVICE_IO_MAP(zorba_io)
|
||||
Z80(config, m_maincpu, 24_MHz_XTAL / 6);
|
||||
m_maincpu->set_addrmap(AS_PROGRAM, &zorba_state::zorba_mem);
|
||||
m_maincpu->set_addrmap(AS_IO, &zorba_state::zorba_io);
|
||||
|
||||
/* video hardware */
|
||||
MCFG_SCREEN_ADD_MONOCHROME("screen", RASTER, rgb_t::green())
|
||||
|
Loading…
Reference in New Issue
Block a user