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
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
|
// license:BSD-3-Clause
// copyright-holders:Olivier Galibert
#ifndef MAME_MACHINE_MIE_H
#define MAME_MACHINE_MIE_H
#pragma once
#include "machine/mapledev.h"
#include "cpu/z80/z80.h"
#include "machine/eepromser.h"
#include "machine/jvshost.h"
#define MCFG_MIE_ADD(_tag, _clock, _host_tag, _host_port, g0, g1, g2, g3, g4, g5, g6, g7) \
MCFG_MAPLE_DEVICE_ADD(_tag "_maple", MIE, _clock, _host_tag, _host_port) \
downcast<mie_device &>(*device).set_gpio_name(0, g0); \
downcast<mie_device &>(*device).set_gpio_name(1, g1); \
downcast<mie_device &>(*device).set_gpio_name(2, g2); \
downcast<mie_device &>(*device).set_gpio_name(3, g3); \
downcast<mie_device &>(*device).set_gpio_name(4, g4); \
downcast<mie_device &>(*device).set_gpio_name(5, g5); \
downcast<mie_device &>(*device).set_gpio_name(6, g6); \
downcast<mie_device &>(*device).set_gpio_name(7, g7); \
downcast<mie_device &>(*device).set_jvs_name(_tag); \
MCFG_DEVICE_ADD(_tag, MIE_JVS, _clock)
class mie_jvs_device;
// ======================> mie_device
class mie_device : public maple_device
{
public:
mie_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock);
void set_gpio_name(int entry, const char *name) { gpio_name[entry] = name; }
void set_jvs_name(const char *name) { jvs_name = name; }
DECLARE_READ8_MEMBER(control_r);
DECLARE_WRITE8_MEMBER(control_w);
DECLARE_READ8_MEMBER(lreg_r);
DECLARE_WRITE8_MEMBER(lreg_w);
DECLARE_READ8_MEMBER(tbuf_r);
DECLARE_WRITE8_MEMBER(tbuf_w);
DECLARE_READ8_MEMBER(gpio_r);
DECLARE_WRITE8_MEMBER(gpio_w);
DECLARE_READ8_MEMBER(gpiodir_r);
DECLARE_WRITE8_MEMBER(gpiodir_w);
DECLARE_READ8_MEMBER(adc_r);
DECLARE_WRITE8_MEMBER(adc_w);
DECLARE_READ8_MEMBER(irq_enable_r);
DECLARE_WRITE8_MEMBER(irq_enable_w);
DECLARE_READ8_MEMBER(maple_irqlevel_r);
DECLARE_WRITE8_MEMBER(maple_irqlevel_w);
DECLARE_READ8_MEMBER(irq_pending_r);
DECLARE_WRITE8_MEMBER(irq_pending_w);
DECLARE_READ8_MEMBER(jvs_r);
DECLARE_WRITE8_MEMBER(jvs_w);
DECLARE_WRITE8_MEMBER(jvs_dest_w);
DECLARE_READ8_MEMBER(jvs_status_r);
DECLARE_WRITE8_MEMBER(jvs_control_w);
DECLARE_READ8_MEMBER(jvs_sense_r);
DECLARE_WRITE8_MEMBER(jvs_lcr_w);
DECLARE_READ8_MEMBER(read_ff);
DECLARE_READ8_MEMBER(read_00);
DECLARE_READ8_MEMBER(read_78xx);
void maple_w(const uint32_t *data, uint32_t in_size) override;
virtual void maple_reset() override;
void mie_map(address_map &map);
void mie_port(address_map &map);
protected:
const char *gpio_name[8];
const char *jvs_name;
// device-level overrides
virtual void device_start() override;
virtual void device_reset() override;
virtual void device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr) override;
// optional information overrides
virtual const tiny_rom_entry *device_rom_region() const override;
virtual void device_add_mconfig(machine_config &config) override;
private:
enum { TBUF_SIZE = 8 };
enum {
CTRL_TXB = 0x000001, // Start transmit
CTRL_CTXB = 0x000002, // Continue transmit flag (when doing multipart)
CTRL_ENDP = 0x000004, // Add an end pattern
CTRL_EMP = 0x000100, // Empty flag
CTRL_PERR = 0x000200, // Parity error
CTRL_BFOV = 0x000800, // Set when overflow, cleared to 0 when starting send/receive
CTRL_RXB = 0x001000, // Receiving
CTRL_RFB = 0x002000, // Receive done
CTRL_TFB = 0x004000, // Transmit done
CTRL_HRES = 0x008000 // Reset pattern received
};
// internal state
z80_device *cpu;
emu_timer *timer;
mie_jvs_device *jvs;
ioport_port *gpio_port[8];
uint32_t tbuf[TBUF_SIZE];
uint32_t control, lreg, jvs_rpos;
uint8_t gpiodir, gpio_val[8];
uint8_t irq_enable, irq_pending, maple_irqlevel;
uint8_t jvs_control, jvs_dest;
uint8_t jvs_lcr;
void raise_irq(int level);
void recalc_irq();
IRQ_CALLBACK_MEMBER(irq_callback);
};
// Trampoline class, required for device discovery
class mie_jvs_device : public jvs_host
{
public:
friend class mie_device;
// construction/destruction
mie_jvs_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock);
};
// device type definition
DECLARE_DEVICE_TYPE(MIE, mie_device)
DECLARE_DEVICE_TYPE(MIE_JVS, mie_jvs_device)
#endif // MAME_MACHINE_MIE_H
|