summaryrefslogtreecommitdiffstatshomepage
path: root/src/mame/includes/cischeat.h
blob: 0cad6346e6fd70acc3cfd3bfeccd29ecd58d80f1 (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
// license:BSD-3-Clause
// copyright-holders:Luca Elia
#ifndef MAME_INCLUDES_CISCHEAT_H
#define MAME_INCLUDES_CISCHEAT_H

#pragma once

// TODO: better inheritance, eventually split individual driver files

#include "sound/okim6295.h"
#include "machine/gen_latch.h"
#include "machine/ticket.h"
#include "machine/timer.h"
#include "machine/watchdog.h"
#include "video/ms1_tmap.h"
#include "emupal.h"
#include "screen.h"

class cischeat_state : public driver_device
{
public:
	cischeat_state(const machine_config &mconfig, device_type type, const char *tag)
		: driver_device(mconfig, type, tag)
		, m_tmap(*this, "scroll%u", 0)
		, m_ram(*this, "ram")
		, m_roadram(*this, "roadram.%u", 0)
		, m_f1gpstr2_ioready(*this, "ioready")
		, m_maincpu(*this, "maincpu")
		, m_cpu1(*this, "cpu1")
		, m_cpu2(*this, "cpu2")
		, m_cpu3(*this, "cpu3")
		, m_cpu5(*this, "cpu5")
		, m_soundcpu(*this, "soundcpu")
		, m_screen(*this, "screen")
		, m_watchdog(*this, "watchdog")
		, m_oki1(*this, "oki1")
		, m_oki2(*this, "oki2")
		, m_gfxdecode(*this, "gfxdecode")
		, m_palette(*this, "palette")
		, m_soundlatch(*this, "soundlatch")
		, m_soundlatch2(*this, "soundlatch2")
		, m_leds(*this, "led%u", 0U)
	{}

	DECLARE_WRITE16_MEMBER(scudhamm_motor_command_w);
	DECLARE_WRITE16_MEMBER(scudhamm_leds_w);
	DECLARE_WRITE16_MEMBER(scudhamm_enable_w);
	DECLARE_WRITE16_MEMBER(scudhamm_oki_bank_w);
	DECLARE_READ16_MEMBER(armchmp2_motor_status_r);
	DECLARE_WRITE16_MEMBER(armchmp2_motor_command_w);
	uint8_t armchmp2_analog_r();
	DECLARE_READ16_MEMBER(armchmp2_buttons_r);
	DECLARE_WRITE16_MEMBER(armchmp2_leds_w);
	DECLARE_WRITE16_MEMBER(bigrun_soundbank_w);
	DECLARE_READ16_MEMBER(scudhamm_motor_status_r);
	DECLARE_READ16_MEMBER(scudhamm_motor_pos_r);
	uint8_t scudhamm_analog_r();
	DECLARE_READ16_MEMBER(bigrun_ip_select_r);
	DECLARE_WRITE16_MEMBER(leds_out_w);
	DECLARE_WRITE16_MEMBER(unknown_out_w);
	DECLARE_WRITE16_MEMBER(motor_out_w);
	DECLARE_WRITE16_MEMBER(wheel_out_w);
	DECLARE_WRITE16_MEMBER(ip_select_w);
	DECLARE_WRITE16_MEMBER(ip_select_plus1_w);
	DECLARE_WRITE16_MEMBER(bigrun_comms_w);
	DECLARE_WRITE16_MEMBER(active_layers_w);
	DECLARE_READ16_MEMBER(cischeat_ip_select_r);
	DECLARE_WRITE16_MEMBER(cischeat_soundlatch_w);
	DECLARE_WRITE16_MEMBER(cischeat_comms_w);
	DECLARE_READ16_MEMBER(f1gpstar_wheel_r);
	DECLARE_READ16_MEMBER(f1gpstr2_ioready_r);
	DECLARE_READ16_MEMBER(wildplt_xy_r);
	DECLARE_READ16_MEMBER(wildplt_mux_r);
	DECLARE_WRITE16_MEMBER(wildplt_mux_w);
	DECLARE_WRITE16_MEMBER(f1gpstar_motor_w);
	DECLARE_WRITE16_MEMBER(f1gpstar_soundint_w);
	DECLARE_WRITE16_MEMBER(f1gpstar_comms_w);
	DECLARE_WRITE16_MEMBER(f1gpstr2_io_w);
	DECLARE_WRITE16_MEMBER(cischeat_soundbank_1_w);
	DECLARE_WRITE16_MEMBER(cischeat_soundbank_2_w);
	DECLARE_WRITE_LINE_MEMBER(sound_irq);
	void init_cischeat();
	void init_bigrun();
	void init_f1gpstar();
	uint32_t screen_update_bigrun(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
	uint32_t screen_update_scudhamm(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
	uint32_t screen_update_cischeat(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
	uint32_t screen_update_f1gpstar(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
	TIMER_DEVICE_CALLBACK_MEMBER(bigrun_scanline);
	TIMER_DEVICE_CALLBACK_MEMBER(scudhamm_scanline);
	TIMER_DEVICE_CALLBACK_MEMBER(armchamp2_scanline);
	void prepare_shadows();
	void cischeat_draw_road(bitmap_ind16 &bitmap, const rectangle &cliprect, int road_num, int priority1, int priority2, int transparency);
	void f1gpstar_draw_road(bitmap_ind16 &bitmap, const rectangle &cliprect, int road_num, int priority1, int priority2, int transparency);
	void cischeat_draw_sprites(bitmap_ind16 &bitmap , const rectangle &cliprect, int priority1, int priority2);
	void bigrun_draw_sprites(bitmap_ind16 &bitmap , const rectangle &cliprect, int priority1, int priority2);
	void cischeat_untangle_sprites(const char *region);

	void scudhamm(machine_config &config);
	void armchmp2(machine_config &config);
	void cischeat(machine_config &config);
	void f1gpstr2(machine_config &config);
	void f1gpstar(machine_config &config);
	void bigrun(machine_config &config);
	void armchmp2_map(address_map &map);
	void bigrun_map(address_map &map);
	void bigrun_map2(address_map &map);
	void bigrun_map3(address_map &map);
	void bigrun_sound_map(address_map &map);
	void cischeat_map(address_map &map);
	void cischeat_map2(address_map &map);
	void cischeat_map3(address_map &map);
	void cischeat_sound_map(address_map &map);
	void f1gpstar_map(address_map &map);
	void f1gpstar_map2(address_map &map);
	void f1gpstar_map3(address_map &map);
	void f1gpstar_sound_map(address_map &map);
	void f1gpstr2_io_map(address_map &map);
	void f1gpstr2_map(address_map &map);
	void f1gpstr2_sound_map(address_map &map);
	void scudhamm_map(address_map &map);

protected:
	virtual void machine_start() override { m_leds.resolve(); }
	virtual void video_start() override;

	optional_device_array<megasys1_tilemap_device, 3> m_tmap;
	required_shared_ptr<uint16_t> m_ram;
	optional_shared_ptr_array<uint16_t,2> m_roadram;
	optional_shared_ptr<uint16_t> m_f1gpstr2_ioready;

	uint16_t *m_objectram;
	uint16_t m_active_layers;

	int m_prev;
	int m_armold;
	uint16_t m_scudhamm_motor_command;
	int m_ip_select;
	uint16_t m_wildplt_output;
	uint8_t m_drawmode_table[16];
	int m_debugsprites;
	int m_show_unknown;
	uint16_t *m_spriteram;

	uint8_t m_motor_value;
	uint8_t m_io_value;

	optional_device<cpu_device> m_maincpu; // some are called cpu1
	optional_device<cpu_device> m_cpu1;
	optional_device<cpu_device> m_cpu2;
	optional_device<cpu_device> m_cpu3;
	optional_device<cpu_device> m_cpu5;
	optional_device<cpu_device> m_soundcpu;
	required_device<screen_device> m_screen;
	optional_device<watchdog_timer_device> m_watchdog;
	required_device<okim6295_device> m_oki1;
	required_device<okim6295_device> m_oki2;
	required_device<gfxdecode_device> m_gfxdecode;
	required_device<palette_device> m_palette;
	optional_device<generic_latch_16_device> m_soundlatch;
	optional_device<generic_latch_16_device> m_soundlatch2;

	output_finder<5> m_leds;
};

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

	uint16_t *m_buffer_spriteram;
	std::unique_ptr<uint16_t[]> m_allocated_spriteram;
	void wildplt_map(address_map &map);
	void wildplt(machine_config &config);
	DECLARE_WRITE16_MEMBER(sprite_dma_w);

protected:
	virtual void video_start() override;

private:
	uint16_t m_sprite_dma_reg;
};

class captflag_state : public cischeat_state
{
public:
	captflag_state(const machine_config &mconfig, device_type type, const char *tag)
		: cischeat_state(mconfig, type, tag)
		, m_hopper(*this, "hopper")
		, m_motor_left(*this, "motor_left")
		, m_motor_right(*this, "motor_right")
		, m_oki1_bank(*this, "oki1_bank")
		, m_oki2_bank(*this, "oki2_bank")
	{
		for (int side = 0; side < 2; ++side)
			m_motor_command[side] = m_motor_pos[side] = 0;
		m_captflag_leds = 0;
	}

	void captflag(machine_config &config);
	template <int N> DECLARE_READ_LINE_MEMBER(motor_busy_r);
	template <int N> DECLARE_CUSTOM_INPUT_MEMBER(motor_pos_r);
	void init_captflag();

private:
	DECLARE_WRITE16_MEMBER(motor_command_right_w);
	DECLARE_WRITE16_MEMBER(motor_command_left_w);
	void motor_move(int side, uint16_t data);
	DECLARE_WRITE16_MEMBER(oki_bank_w);

	DECLARE_WRITE16_MEMBER(leds_w);

	TIMER_DEVICE_CALLBACK_MEMBER(captflag_scanline);

	void captflag_map(address_map &map);
	void oki1_map(address_map &map);
	void oki2_map(address_map &map);

	required_device<ticket_dispenser_device> m_hopper;

	required_device<timer_device> m_motor_left;
	required_device<timer_device> m_motor_right;

	required_memory_bank m_oki1_bank;
	required_memory_bank m_oki2_bank;

	uint16_t m_captflag_leds;
	uint16_t m_motor_command[2];
	uint16_t m_motor_pos[2];
};

#endif