summaryrefslogtreecommitdiffstatshomepage
path: root/src/mame/machine/m2comm.h
blob: 0c717e1c2ed32075111302f998dc8b91195598b5 (plain) (blame)
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
// license:BSD-3-Clause
// copyright-holders:Ariane Fugmann
#pragma once

#ifndef __M2COMM_H__
#define __M2COMM_H__

#define __M2COMM_SIMULATION__

#include "emu.h"

#define MCFG_M2COMM_ADD(_tag ) \
	MCFG_DEVICE_ADD(_tag, M2COMM, 0)
	
//**************************************************************************
//  TYPE DEFINITIONS
//**************************************************************************

class m2comm_device : public device_t
{
public:
	// construction/destruction
	m2comm_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);

	// optional information overrides
	virtual machine_config_constructor device_mconfig_additions() const;

	// single bit registers (74LS74)
	DECLARE_READ8_MEMBER(zfg_r);
	DECLARE_WRITE8_MEMBER(zfg_w);
	// shared memory 2k
	DECLARE_READ8_MEMBER(share_r);
	DECLARE_WRITE8_MEMBER(share_w);

	// public API - stuff that gets called from host
	// shared memory 16k
	// reads/writes at I/O 0x01a10000-0x01a13fff
	// - share_r
	// - share_w
	// single bit registers (74LS74)
	// reads/writes at I/O 0x01a14000
	DECLARE_READ8_MEMBER(cn_r);
	DECLARE_WRITE8_MEMBER(cn_w);
	// reads/writes at I/O 0x01a14002
	DECLARE_READ8_MEMBER(fg_r);
	DECLARE_WRITE8_MEMBER(fg_w);

  // IRQ logic - 5 = VINT, 7 = DLC
	void check_vint_irq();
#ifdef __M2COMM_SIMULATION__
	void set_linktype(UINT16 linktype);
#endif

protected:
	// device-level overrides
	virtual void device_start();
	virtual void device_reset();

private:
	UINT8 m_shared[0x4000]; // 16k shared memory
	UINT8	m_zfg;						// z80 flip gate? purpose unknown, bit0 is stored
	UINT8	m_cn;							// bit0 is used to enable/disable the comm board
	UINT8	m_fg;							// flip gate? purpose unknown, bit0 is stored, bit7 is connected to ZFG bit 0
	
	emu_file m_line_rx;    // rx line - can be either differential, simple serial or toslink
	emu_file m_line_tx;    // tx line - is differential, simple serial and toslink
	char m_localhost[256];
	char m_remotehost[256];
	UINT8 m_buffer[0x4000];
	
#ifdef __M2COMM_SIMULATION__
	UINT8 m_linkenable;
	UINT16 m_linktimer;
	UINT8 m_linkalive;
	UINT8 m_linkid;
	UINT8 m_linkcount;

	UINT16 m_linktype;
	
	void comm_tick();
	
	void comm_tick_16726();
#endif
};

// device type definition
extern const device_type M2COMM;

#endif  /* __M2COMM_H__ */