summaryrefslogtreecommitdiffstatshomepage
path: root/src/emu/bus/chanf/rom.h
blob: 272f0301012f84286dc216625e64751b67045c66 (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
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
139
140
141
142
143
144
// license:BSD-3-Clause
// copyright-holders:etabeta
#ifndef __CHANF_ROM_H
#define __CHANF_ROM_H

#include "slot.h"


// ======================> chanf_rom_device

class chanf_rom_device : public device_t,
						public device_channelf_cart_interface
{
public:
	// construction/destruction
	chanf_rom_device(const machine_config &mconfig, device_type type, const char *name, const char *tag, device_t *owner, UINT32 clock, const char *shortname, const char *source);
	chanf_rom_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);

	// device-level overrides
	virtual void device_start() {}
	virtual void device_reset() {}

	UINT8 common_read_2102(UINT32 offset);
	UINT8 common_read_3853(UINT32 offset);
	void common_write_2102(UINT32 offset, UINT8 data);
	void common_write_3853(UINT32 offset, UINT8 data);
	
	// reading and writing
	virtual DECLARE_READ8_MEMBER(read_rom);

	
protected:
	// used for RAM chip in Hangman & Maze
	UINT8 m_latch[2];		// PORT A & PORT B
	UINT16 m_addr_latch, m_addr;
	int m_read_write, m_data0;
};

// ======================> chanf_maze_device

class chanf_maze_device : public chanf_rom_device
{
public:
	// construction/destruction
	chanf_maze_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
	
	// device-level overrides
	virtual void device_start();
	virtual void device_reset();
	
	// reading and writing
	virtual DECLARE_READ8_MEMBER(read_ram) { return common_read_2102(offset); }
	virtual DECLARE_WRITE8_MEMBER(write_ram) { common_write_2102(offset, data); }
};


// ======================> chanf_hangman_device

class chanf_hangman_device : public chanf_rom_device
{
public:
	// construction/destruction
	chanf_hangman_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
	
	// device-level overrides
	virtual void device_start();
	virtual void device_reset();
	
	// reading and writing
	virtual DECLARE_READ8_MEMBER(read_ram) { return common_read_2102(offset); }
	virtual DECLARE_WRITE8_MEMBER(write_ram) { common_write_2102(offset, data); }
};


// ======================> chanf_chess_device

class chanf_chess_device : public chanf_rom_device
{
public:
	// construction/destruction
	chanf_chess_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
	
	// reading and writing
	virtual DECLARE_READ8_MEMBER(read_ram) { return common_read_3853(offset); }
	virtual DECLARE_WRITE8_MEMBER(write_ram) { common_write_3853(offset, data); }
};


// ======================> chanf_multi_old_device

class chanf_multi_old_device : public chanf_rom_device
{
public:
	// construction/destruction
	chanf_multi_old_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
	
	// device-level overrides
	virtual void device_start();
	virtual void device_reset();
	
	// reading and writing
	virtual DECLARE_READ8_MEMBER(read_rom);
	virtual DECLARE_READ8_MEMBER(read_ram) { return common_read_3853(offset); }
	virtual DECLARE_WRITE8_MEMBER(write_ram) { common_write_3853(offset, data); }
	virtual DECLARE_WRITE8_MEMBER(write_bank);

private:
	int m_base_bank;
};


// ======================> chanf_multi_final_device

class chanf_multi_final_device : public chanf_rom_device
{
public:
	// construction/destruction
	chanf_multi_final_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
	
	// device-level overrides
	virtual void device_start();
	virtual void device_reset();
	
	// reading and writing
	virtual DECLARE_READ8_MEMBER(read_rom);
	virtual DECLARE_READ8_MEMBER(read_ram) { return common_read_3853(offset); }
	virtual DECLARE_WRITE8_MEMBER(write_ram) { common_write_3853(offset, data); }
	virtual DECLARE_WRITE8_MEMBER(write_bank);
	
private:
	int m_base_bank, m_half_bank;
};


// device type definition
extern const device_type CHANF_ROM_STD;
extern const device_type CHANF_ROM_MAZE;
extern const device_type CHANF_ROM_HANGMAN;
extern const device_type CHANF_ROM_CHESS;
extern const device_type CHANF_ROM_MULTI_OLD;
extern const device_type CHANF_ROM_MULTI_FINAL;


#endif