summaryrefslogtreecommitdiffstats
path: root/src/mame/includes/spg2xx.h
blob: 58eed48b69f8e6ec95f6cdc7cbb164111efae605 (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
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
// license:BSD-3-Clause
// copyright-holders:Ryan Holtz, David Haywood
#ifndef MAME_INCLUDES_SPG2XX_H
#define MAME_INCLUDES_SPG2XX_H

#pragma once

#include "cpu/unsp/unsp.h"
#include "machine/i2cmem.h"
#include "machine/spg2xx.h"


#include "screen.h"
#include "softlist.h"
#include "speaker.h"
#include "machine/eepromser.h"
#include "machine/i2cmem.h"


class spg2xx_game_state : public driver_device
{
public:
	spg2xx_game_state(const machine_config &mconfig, device_type type, const char *tag) :
		driver_device(mconfig, type, tag),
		m_maincpu(*this, "maincpu"),
		m_screen(*this, "screen"),
		m_bank(*this, "cartbank"),
		m_io_p1(*this, "P1"),
		m_io_p2(*this, "P2"),
		m_io_p3(*this, "P3"),
		m_io_guny(*this, "GUNY"),
		m_io_gunx(*this, "GUNX"),
		m_i2cmem(*this, "i2cmem")
	{ }

	void spg2xx_base(machine_config &config);
	void spg2xx(machine_config &config);
	void spg2xx_pal(machine_config &config);

	void rad_skat(machine_config &config);
	void rad_skatp(machine_config &config);
	void rad_sktv(machine_config &config);
	void rad_crik(machine_config &config);
	void non_spg_base(machine_config &config);
	void comil(machine_config &config);
	void tvsprt10(machine_config &config);
	void guitarfv(machine_config &config);
	void tmntmutm(machine_config &config);


	void init_crc();
	void init_tvsprt10();
	void init_itvphone();

protected:
	virtual void machine_start() override;
	virtual void machine_reset() override;

	void decrypt_ac_ff(uint16_t* ROM, int size);

	void switch_bank(uint32_t bank);

	void i2c_w(offs_t offset, uint8_t data);
	uint8_t i2c_r(offs_t offset);

	virtual void porta_w(offs_t offset, uint16_t data, uint16_t mem_mask = ~0);
	virtual void portb_w(offs_t offset, uint16_t data, uint16_t mem_mask = ~0);
	virtual void portc_w(offs_t offset, uint16_t data, uint16_t mem_mask = ~0);

	uint16_t base_porta_r(offs_t offset, uint16_t mem_mask = ~0);
	uint16_t base_portb_r(offs_t offset, uint16_t mem_mask = ~0);
	uint16_t base_portc_r(offs_t offset, uint16_t mem_mask = ~0);
	uint16_t base_guny_r();
	uint16_t base_gunx_r();

	required_device<spg2xx_device> m_maincpu;
	required_device<screen_device> m_screen;
	optional_memory_bank m_bank;


	virtual void mem_map_4m(address_map &map);
	virtual void mem_map_2m(address_map &map);
	virtual void mem_map_1m(address_map &map);

	uint32_t m_current_bank;

	required_ioport m_io_p1;
	optional_ioport m_io_p2;
	optional_ioport m_io_p3;
	optional_ioport m_io_guny;
	optional_ioport m_io_gunx;
	optional_device<i2cmem_device> m_i2cmem;
};


class spg2xx_game_pballpup_state : public spg2xx_game_state
{
public:
	spg2xx_game_pballpup_state(const machine_config &mconfig, device_type type, const char *tag) :
		spg2xx_game_state(mconfig, type, tag),
		m_eeprom(*this, "eeprom")
	{ }

	void pballpup(machine_config &config);

private:
	uint16_t porta_r();
	virtual void porta_w(offs_t offset, uint16_t data, uint16_t mem_mask = ~0) override;

	required_device<eeprom_serial_93cxx_device> m_eeprom;
};

class spg2xx_game_comil_state : public spg2xx_game_state
{
public:
	spg2xx_game_comil_state(const machine_config &mconfig, device_type type, const char *tag) :
		spg2xx_game_state(mconfig, type, tag),
		m_porta_data(0),
		m_extra_in(*this, "EXTRA%u", 0U)
	{ }

	void comil(machine_config &config);

private:
	uint16_t porta_r(offs_t offset, uint16_t mem_mask = ~0);
	void porta_w(offs_t offset, uint16_t data, uint16_t mem_mask = ~0) override;
	uint16_t portb_r(offs_t offset, uint16_t mem_mask = ~0);
	uint16_t m_porta_data;
	required_ioport_array<8> m_extra_in;
};

class spg2xx_game_swclone_state : public spg2xx_game_state
{
public:
	spg2xx_game_swclone_state(const machine_config &mconfig, device_type type, const char *tag) :
		spg2xx_game_state(mconfig, type, tag),
		m_porta_data(0),
		m_i2cmem(*this, "i2cmem")
	{ }

	void swclone(machine_config &config);
	void init_swclone();

private:
	uint16_t porta_r();
	void porta_w(offs_t offset, uint16_t data, uint16_t mem_mask = ~0) override;
	uint16_t m_porta_data;

	required_device<i2cmem_device> m_i2cmem;
};

class spg2xx_game_tmntmutm_state : public spg2xx_game_state
{
public:
	spg2xx_game_tmntmutm_state(const machine_config &mconfig, device_type type, const char *tag) :
		spg2xx_game_state(mconfig, type, tag),
		m_i2cmem(*this, "i2cmem")
	{ }

	void tmntmutm(machine_config &config);

private:
	uint16_t guny_r();
	uint16_t gunx_r();

	required_device<i2cmem_device> m_i2cmem;
};

class spg2xx_game_albkickb_state : public spg2xx_game_state
{
public:
	spg2xx_game_albkickb_state(const machine_config &mconfig, device_type type, const char *tag) :
		spg2xx_game_state(mconfig, type, tag)
	{ }

	void ablkickb(machine_config &config);

	void init_ablkickb();

private:
	uint16_t portb_r(offs_t offset, uint16_t mem_mask = ~0);
};

class spg2xx_game_dreamlss_state : public spg2xx_game_state
{
public:
	spg2xx_game_dreamlss_state(const machine_config &mconfig, device_type type, const char *tag) :
		spg2xx_game_state(mconfig, type, tag),
		m_porta_data(0),
		m_portb_data(0),
		m_i2cmem(*this, "i2cmem")
	{ }

	void dreamlss(machine_config &config);

private:
	uint16_t m_porta_data;
	uint16_t m_portb_data;

	uint16_t porta_r();
	uint16_t portb_r();
	virtual void portb_w(offs_t offset, uint16_t data, uint16_t mem_mask = ~0) override;
	virtual void porta_w(offs_t offset, uint16_t data, uint16_t mem_mask = ~0) override;

	required_device<i2cmem_device> m_i2cmem;
};

class spg2xx_game_gssytts_state : public spg2xx_game_state
{
public:
	spg2xx_game_gssytts_state(const machine_config &mconfig, device_type type, const char *tag) :
		spg2xx_game_state(mconfig, type, tag),
		m_upperbank(*this, "upperbank")
	{ }

	void gssytts(machine_config &config);

protected:
	virtual void machine_start() override;
	virtual void machine_reset() override;

	virtual void portc_w(offs_t offset, uint16_t data, uint16_t mem_mask = ~0) override;

	required_memory_bank m_upperbank;

private:

	void mem_map_upperbank(address_map& map);
};

class spg2xx_game_senwfit_state : public spg2xx_game_gssytts_state
{
public:
	spg2xx_game_senwfit_state(const machine_config &mconfig, device_type type, const char *tag) :
		spg2xx_game_gssytts_state(mconfig, type, tag)
	{ }

	void init_senwfit();
protected:

	virtual void portc_w(offs_t offset, uint16_t data, uint16_t mem_mask = ~0) override;

private:
};


class spg2xx_game_senspeed_state : public spg2xx_game_state
{
public:
	spg2xx_game_senspeed_state(const machine_config &mconfig, device_type type, const char *tag) :
		spg2xx_game_state(mconfig, type, tag),
		m_i2cmem(*this, "i2cmem")
	{ }

	void senspeed(machine_config &config);

private:
	uint16_t portb_r();
	void portb_w(offs_t offset, uint16_t data, uint16_t mem_mask = ~0) override;
	required_device<i2cmem_device> m_i2cmem;
};

class spg2xx_game_fordrace_state : public spg2xx_game_state
{
public:
	spg2xx_game_fordrace_state(const machine_config &mconfig, device_type type, const char *tag) :
		spg2xx_game_state(mconfig, type, tag)
	{ }

	void fordrace(machine_config &config);

	DECLARE_CUSTOM_INPUT_MEMBER(wheel_r);
	DECLARE_CUSTOM_INPUT_MEMBER(wheel2_r);

private:
};



class spg2xx_game_wfcentro_state : public spg2xx_game_state
{
public:
	spg2xx_game_wfcentro_state(const machine_config &mconfig, device_type type, const char *tag) :
		spg2xx_game_state(mconfig, type, tag)
	{ }

	void wfcentro(machine_config &config);

protected:
//  virtual void machine_start() override;
//  virtual void machine_reset() override;

//  virtual void portc_w(offs_t offset, uint16_t data, uint16_t mem_mask = ~0) override;

private:

	void mem_map_wfcentro(address_map& map);
};

class spg2xx_game_ordentv_state : public spg2xx_game_state
{
public:
	spg2xx_game_ordentv_state(const machine_config &mconfig, device_type type, const char *tag) :
		spg2xx_game_state(mconfig, type, tag)
	{ }

	void ordentv(machine_config &config);

	void init_ordentv();

protected:

	uint16_t ordentv_portc_r(offs_t offset, uint16_t mem_mask = ~0);
private:
};

class spg2xx_game_hotwheels_state : public spg2xx_game_state
{
public:
	spg2xx_game_hotwheels_state(const machine_config &mconfig, device_type type, const char *tag) :
		spg2xx_game_state(mconfig, type, tag),
		m_porta_dat_hot(0xffff),
		m_io_p1_extra(*this, "P1EXTRA")
	{ }

	void hotwheels(machine_config &config);

protected:

	uint16_t hotwheels_porta_r(offs_t offset, uint16_t mem_mask = ~0);
	virtual void porta_w(offs_t offset, uint16_t data, uint16_t mem_mask = ~0) override;

private:

	uint16_t m_porta_dat_hot;
	required_ioport m_io_p1_extra;
};

class spg2xx_game_doraphone_state : public spg2xx_game_state
{
public:
	spg2xx_game_doraphone_state(const machine_config &mconfig, device_type type, const char *tag) :
		spg2xx_game_state(mconfig, type, tag),
		m_portb_data(0),
		m_io_p1_rows(*this, "P1_ROW%u", 1U)
	{ }

	void doraphone(machine_config &config);

private:
	uint16_t porta_r(offs_t offset, uint16_t mem_mask = ~0);

	void portb_w(offs_t offset, uint16_t data, uint16_t mem_mask = ~0) override;
	uint16_t m_portb_data;

	required_ioport_array<6> m_io_p1_rows;
};



#endif // MAME_INCLUDES_SPG2XX_H