1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
|
// license:BSD-3-Clause
// copyright-holders:Nigel Barnes
/**********************************************************************
MTX expansion emulation
**********************************************************************/
#ifndef MAME_BUS_MTX_EXP_H
#define MAME_BUS_MTX_EXP_H
#pragma once
#include "imagedev/cartrom.h"
//**************************************************************************
// TYPE DEFINITIONS
//**************************************************************************
// ======================> mtx_exp_slot_device
class device_mtx_exp_interface;
class mtx_exp_slot_device : public device_t, public device_single_card_slot_interface<device_mtx_exp_interface>, public device_cartrom_image_interface
{
friend class device_mtx_exp_interface;
public:
// construction/destruction
template <typename T>
mtx_exp_slot_device(machine_config const &mconfig, char const *tag, device_t *owner, T &&slot_options, const char *default_option)
: mtx_exp_slot_device(mconfig, tag, owner)
{
option_reset();
slot_options(*this);
set_default_option(default_option);
set_fixed(false);
}
mtx_exp_slot_device(machine_config const &mconfig, char const *tag, device_t *owner, const XTAL &clock = XTAL());
template <typename T> void set_program_space(T &&tag, int spacenum) { m_program.set_tag(std::forward<T>(tag), spacenum); }
template <typename T> void set_io_space(T &&tag, int spacenum) { m_io.set_tag(std::forward<T>(tag), spacenum); }
// callbacks
auto busreq_handler() { return m_busreq_handler.bind(); }
auto int_handler() { return m_int_handler.bind(); }
auto nmi_handler() { return m_nmi_handler.bind(); }
// for the card to use
DECLARE_WRITE_LINE_MEMBER( busreq_w ) { m_busreq_handler(state); }
DECLARE_WRITE_LINE_MEMBER( int_w ) { m_int_handler(state); }
DECLARE_WRITE_LINE_MEMBER( nmi_w ) { m_nmi_handler(state); }
virtual void bankswitch(uint8_t data);
protected:
// device-level overrides
virtual void device_start() override;
// image-level overrides
virtual image_init_result call_load() override;
virtual bool is_reset_on_load() const noexcept override { return true; }
virtual const char *image_interface() const noexcept override { return "mtx_cart"; }
virtual const char *file_extensions() const noexcept override { return "bin,rom"; }
// slot interface overrides
virtual std::string get_default_card_software(get_default_card_software_hook &hook) const override;
private:
// address spaces we are attached to
required_address_space m_program;
required_address_space m_io;
devcb_write_line m_busreq_handler;
devcb_write_line m_int_handler;
devcb_write_line m_nmi_handler;
device_mtx_exp_interface *m_card;
};
// ======================> device_mtx_exp_interface
class device_mtx_exp_interface : public device_interface
{
public:
virtual void bankswitch(uint8_t data) { }
void rom_alloc(uint32_t size, const char *tag);
uint8_t* get_rom_base() { return m_rom; }
uint32_t get_rom_size() { return m_rom_size; }
protected:
// construction/destruction
device_mtx_exp_interface(const machine_config &mconfig, device_t &device);
address_space &program_space() { return *m_slot->m_program; }
address_space &io_space() { return *m_slot->m_io; }
mtx_exp_slot_device *m_slot;
private:
// internal state
uint8_t *m_rom;
uint32_t m_rom_size;
};
// device type definition
DECLARE_DEVICE_TYPE(MTX_EXP_SLOT, mtx_exp_slot_device)
void mtx_int_expansion_devices(device_slot_interface &device);
void mtx_ext_expansion_devices(device_slot_interface &device);
#endif // MAME_BUS_MTX_EXP_H
|