summaryrefslogtreecommitdiffstatshomepage
path: root/src/mame/includes/leland.h
blob: 9503725c877842e3203cd67ed847ac2c45918458 (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
// license:BSD-3-Clause
// copyright-holders:Aaron Giles
/*************************************************************************

    Cinemat/Leland driver

*************************************************************************/
#ifndef MAME_INCLUDES_LELAND_H
#define MAME_INCLUDES_LELAND_H

#pragma once

#include "machine/eepromser.h"
#include "sound/dac.h"
#include "sound/ay8910.h"
#include "emupal.h"
#include "screen.h"
#include "tilemap.h"

#define LELAND_BATTERY_RAM_SIZE 0x4000
#define ATAXX_EXTRA_TRAM_SIZE 0x800


struct vram_state_data
{
	u16  m_addr;
	u8   m_latch[2];
};

class leland_80186_sound_device;

class leland_state : public driver_device
{
public:
	leland_state(const machine_config &mconfig, device_type type, const char *tag)
		: driver_device(mconfig, type, tag)
		, m_master(*this, "master")
		, m_slave(*this, "slave")
		, m_mainram(*this, "mainram")
		, m_master_bankslot(*this, "masterbank_%u", 0U)
		, m_master_base(*this, "master")
		, m_slave_bankslot(*this, "slavebank")
		, m_slave_base(*this, "slave")
		, m_eeprom(*this, "eeprom")
		, m_battery_ram(*this, "battery", 0x3000, ENDIANNESS_LITTLE)
		, m_palette(*this, "palette")
		, m_screen(*this, "screen")
		, m_gfxdecode(*this, "gfxdecode")
		, m_io_in(*this, "IN%u", 0U)
		, m_io_an(*this, "AN%u", 0U)
		, m_dac(*this, "dac%u", 0U)
		, m_ay8910(*this, "ay8910")
		, m_ay8912(*this, "ay8912")
		, m_bg_gfxrom(*this, "bg_gfx")
		, m_bg_prom(*this, "bg_prom")
	{ }

	void leland(machine_config &config);
	void leland_video(machine_config &config);

	void init_dblplay();
	void init_dangerz();
	void init_mayhem();
	void init_alleymas();
	void init_strkzone();
	void init_wseries();
	void init_powrplay();
	void init_basebal2();
	void init_upyoural();
	void init_cerberus();

	void cerberus_bankswitch();
	void mayhem_bankswitch();
	void dangerz_bankswitch();
	void basebal2_bankswitch();
	void redline_bankswitch();

	void offroad_bankswitch();
	void viper_bankswitch();

	u8 raster_r();
	void slave_video_addr_w(offs_t offset, u8 data);
	void slave_large_banksw_w(u8 data);
	void master_video_addr_w(offs_t offset, u8 data);

	TIMER_CALLBACK_MEMBER(ataxx_interrupt_callback);

protected:
	required_device<cpu_device> m_master;
	required_device<cpu_device> m_slave;
	required_shared_ptr<u8> m_mainram;
	required_memory_bank_array<2> m_master_bankslot;
	required_region_ptr<u8> m_master_base;
	required_memory_bank m_slave_bankslot;
	required_region_ptr<u8> m_slave_base;
	required_device<eeprom_serial_93cxx_device> m_eeprom;
	memory_share_creator<u8> m_battery_ram;
	required_device<palette_device> m_palette;
	required_device<screen_device> m_screen;
	required_device<gfxdecode_device> m_gfxdecode;

	optional_ioport_array<4> m_io_in;
	optional_ioport_array<6> m_io_an;

	emu_timer *m_master_int_timer;
	u8 m_battery_ram_enable;

	void rotate_memory(const char *cpuname);

	int dial_compute_value(int new_val, int indx);
	u8 m_dial_last_input[4];
	u8 m_dial_last_result[4];
	u8 m_analog_result;

	int m_dangerz_x;
	int m_dangerz_y;

	void init_master_ports(u8 mvram_base, u8 io_base);
	void (leland_state::*m_update_master_bank)();

	int vram_port_r(offs_t offset, int num);
	void vram_port_w(offs_t offset, u8 data, int num);

	u8 m_wcol_enable;

	u8 master_analog_key_r(offs_t offset);
	void master_analog_key_w(offs_t offset, u8 data);
	u8 dangerz_input_y_r();
	u8 dangerz_input_x_r();
	u8 dangerz_input_upper_r();
	void scroll_w(offs_t offset, u8 data);
	void leland_master_alt_bankswitch_w(u8 data);

	tilemap_t      *m_tilemap;
	u16 m_xscroll;
	u16 m_yscroll;
	std::unique_ptr<u8[]> m_video_ram;
	struct vram_state_data m_vram_state[2];

	void slave_map_program(address_map &map);
	void asylum_slave_map_program(address_map &map);

	TIMER_CALLBACK_MEMBER(leland_delayed_mvram_w);

private:
	optional_device_array<dac_byte_interface, 2> m_dac;
	optional_device<ay8910_device> m_ay8910;
	optional_device<ay8912_device> m_ay8912;

	required_region_ptr<u8> m_bg_gfxrom;
	optional_region_ptr<u8> m_bg_prom;

	u8 m_dac_control;
	u8 *m_alleymas_kludge_mem;
	u8 m_gfx_control;
	u8 m_keycard_shift;
	u8 m_keycard_bit;
	u8 m_keycard_state;
	u8 m_keycard_clock;
	u8 m_keycard_command[3];
	u8 m_top_board_bank;
	u8 m_sound_port_bank;
	u8 m_alternate_bank;
	u8 m_gfxbank;
	u16 m_last_scanline;
	emu_timer *m_scanline_timer;

	u8 cerberus_dial_1_r();
	u8 cerberus_dial_2_r();
	void alleymas_joystick_kludge(u8 data);
	void leland_battery_ram_w(offs_t offset, u8 data);
	u8 leland_master_input_r(offs_t offset);
	void leland_master_output_w(offs_t offset, u8 data);
	void gated_paletteram_w(offs_t offset, u8 data);
	u8 gated_paletteram_r(offs_t offset);
	void slave_small_banksw_w(u8 data);
	void ataxx_slave_banksw_w(u8 data);
	void leland_mvram_port_w(offs_t offset, u8 data);
	u8 leland_mvram_port_r(offs_t offset);
	void leland_svram_port_w(offs_t offset, u8 data);
	u8 leland_svram_port_r(offs_t offset);
	u8 sound_port_r();
	void sound_port_w(u8 data);
	void gfx_port_w(u8 data);

	virtual void machine_start() override;
	virtual void machine_reset() override;
	virtual void video_start() override;

	TILEMAP_MAPPER_MEMBER(leland_scan);
	TILE_GET_INFO_MEMBER(leland_get_tile_info);
	u32 screen_update(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
	INTERRUPT_GEN_MEMBER(leland_master_interrupt);
	TIMER_CALLBACK_MEMBER(leland_interrupt_callback);
	TIMER_CALLBACK_MEMBER(scanline_callback);

	void video_addr_w(offs_t offset, u8 data, int num);

	void update_dangerz_xy();

	void leland_init_eeprom(u8 default_val, const u16 *data, u8 serial_offset, u8 serial_type);
	void ataxx_init_eeprom(const u16 *data);
	int keycard_r();
	void keycard_w(int data);
	void master_map_io(address_map &map);
	void master_map_program(address_map &map);
	void slave_map_io(address_map &map);
	void slave_small_map_program(address_map &map);
};


class redline_state : public leland_state
{
public:
	redline_state(const machine_config &mconfig, device_type type, const char *tag)
		: leland_state(mconfig, type, tag)
		, m_sound(*this, "custom")
	{
	}

	void init_redlin2p();
	void init_quarterb();
	void init_viper();
	void init_teamqb();
	void init_aafb();
	void init_aafbb();
	void init_aafbd2p();
	void init_offroad();
	void init_offroadt();
	void init_pigout();

	void redline(machine_config &config);
	void quarterb(machine_config &config);
	void lelandi(machine_config &config);

private:
	u8 redline_pedal_1_r();
	u8 redline_pedal_2_r();
	u8 redline_wheel_1_r();
	u8 redline_wheel_2_r();
	u8 offroad_wheel_1_r();
	u8 offroad_wheel_2_r();
	u8 offroad_wheel_3_r();
	void redline_master_alt_bankswitch_w(u8 data);

	void master_redline_map_io(address_map &map);
	void slave_large_map_program(address_map &map);

	required_device<leland_80186_sound_device> m_sound;
};


class ataxx_state : public leland_state
{
public:
	ataxx_state(const machine_config &mconfig, device_type type, const char *tag)
		: leland_state(mconfig, type, tag)
		, m_sound(*this, "custom")
		, m_xrom_base(*this, "xrom")
	{
	}

	void init_ataxx();
	void init_ataxxj();
	void init_wsf();
	void init_indyheat();
	void init_brutforc();
	void init_asylum();

	void ataxx(machine_config &config);
	void wsf(machine_config &config);
	void asylum(machine_config &config);

private:
	u8 ataxx_trackball_r(offs_t offset);
	u8 indyheat_analog_r(offs_t offset);
	void indyheat_analog_w(offs_t offset, u8 data);

	void ataxx_battery_ram_w(offs_t offset, u8 data);
	u8 ataxx_master_input_r(offs_t offset);
	void ataxx_master_output_w(offs_t offset, u8 data);
	void paletteram_and_misc_w(offs_t offset, u8 data);
	u8 paletteram_and_misc_r(offs_t offset);
	void ataxx_mvram_port_w(offs_t offset, u8 data);
	void ataxx_svram_port_w(offs_t offset, u8 data);
	u8 ataxx_mvram_port_r(offs_t offset);
	u8 ataxx_svram_port_r(offs_t offset);
	u8 eeprom_r();
	void eeprom_w(u8 data);

	TILEMAP_MAPPER_MEMBER(ataxx_scan);
	TILE_GET_INFO_MEMBER(ataxx_get_tile_info);

	void ataxx_bankswitch();

	virtual void machine_start() override;
	virtual void machine_reset() override;
	virtual void video_start() override;

	void ataxx_video(machine_config &config);

	void master_map_program_2(address_map &map);
	void master_map_io_2(address_map &map);
	void slave_map_io_2(address_map &map);

	required_device<leland_80186_sound_device> m_sound;

	required_region_ptr<u8> m_xrom_base;

	std::unique_ptr<u8[]> m_ataxx_qram;
	u8 m_master_bank;
	u32 m_xrom1_addr;
	u32 m_xrom2_addr;
	std::unique_ptr<u8[]> m_extra_tram;
};


#define SERIAL_TYPE_NONE        0
#define SERIAL_TYPE_ADD         1
#define SERIAL_TYPE_ADD_XOR     2
#define SERIAL_TYPE_ENCRYPT     3
#define SERIAL_TYPE_ENCRYPT_XOR 4

#endif // MAME_INCLUDES_LELAND_H