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

    Midway MCR system

**************************************************************************/

#include "cpu/z80/z80.h"
#include "machine/z80daisy.h"
#include "machine/timer.h"
#include "machine/z80ctc.h"
#include "machine/z80pio.h"
#include "machine/z80dart.h"
#include "machine/watchdog.h"
#include "audio/midway.h"
#include "audio/csd.h"
#include "sound/samples.h"

/* constants */
#define MAIN_OSC_MCR_I      XTAL(19'968'000)


class mcr_state : public driver_device
{
public:
	mcr_state(const machine_config &mconfig, device_type type, const char *tag) :
		driver_device(mconfig, type, tag),
		m_maincpu(*this, "maincpu"),
		m_spriteram(*this, "spriteram"),
		m_videoram(*this, "videoram"),
		m_paletteram(*this, "paletteram"),
		m_ctc(*this, "ctc"),
		m_ssio(*this, "ssio"),
		m_cheap_squeak_deluxe(*this, "csd"),
		m_sounds_good(*this, "sg"),
		m_turbo_cheap_squeak(*this, "tcs"),
		m_squawk_n_talk(*this, "snt"),
		m_samples(*this, "samples"),
		m_gfxdecode(*this, "gfxdecode"),
		m_palette(*this, "palette")
	{ }

	DECLARE_WRITE8_MEMBER(mcr_control_port_w);
	DECLARE_WRITE8_MEMBER(mcr_paletteram9_w);
	DECLARE_WRITE8_MEMBER(mcr_90009_videoram_w);
	DECLARE_WRITE8_MEMBER(mcr_90010_videoram_w);
	DECLARE_READ8_MEMBER(twotiger_videoram_r);
	DECLARE_WRITE8_MEMBER(twotiger_videoram_w);
	DECLARE_WRITE8_MEMBER(mcr_91490_videoram_w);
	DECLARE_READ8_MEMBER(solarfox_ip0_r);
	DECLARE_READ8_MEMBER(solarfox_ip1_r);
	DECLARE_READ8_MEMBER(kick_ip1_r);
	DECLARE_WRITE8_MEMBER(wacko_op4_w);
	DECLARE_READ8_MEMBER(wacko_ip1_r);
	DECLARE_READ8_MEMBER(wacko_ip2_r);
	DECLARE_READ8_MEMBER(kroozr_ip1_r);
	DECLARE_WRITE8_MEMBER(kroozr_op4_w);
	DECLARE_WRITE8_MEMBER(journey_op4_w);
	DECLARE_WRITE8_MEMBER(twotiger_op4_w);
	DECLARE_WRITE8_MEMBER(dotron_op4_w);
	DECLARE_READ8_MEMBER(demoderb_ip1_r);
	DECLARE_READ8_MEMBER(demoderb_ip2_r);
	DECLARE_WRITE8_MEMBER(demoderb_op4_w);

	void init_mcr_91490();
	void init_kroozr();
	void init_solarfox();
	void init_kick();
	void init_twotiger();
	void init_demoderb();
	void init_wacko();
	void init_mcr_90010();
	void init_dotrone();
	void init_journey();

	uint32_t screen_update_mcr(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
	TIMER_DEVICE_CALLBACK_MEMBER(mcr_interrupt);

	void mcr_91490_tcs(machine_config &config);
	void mcr_91490_snt(machine_config &config);
	void mcr_91490(machine_config &config);
	void mcr_90009(machine_config &config);
	void mcr_90010_tt(machine_config &config);
	void mcr_91475(machine_config &config);
	void mcr_90010(machine_config &config);
	void cpu_90009_map(address_map &map);
	void cpu_90009_portmap(address_map &map);
	void cpu_90010_map(address_map &map);
	void cpu_90010_portmap(address_map &map);
	void cpu_91490_map(address_map &map);
	void cpu_91490_portmap(address_map &map);
protected:
	virtual void machine_start() override;
	virtual void machine_reset() override;
	virtual void video_start() override;

	TILE_GET_INFO_MEMBER(mcr_90009_get_tile_info);
	TILE_GET_INFO_MEMBER(mcr_90010_get_tile_info);
	TILE_GET_INFO_MEMBER(mcr_91490_get_tile_info);
	void mcr_set_color(int index, int data);
	void journey_set_color(int index, int data);
	void render_sprites_91399(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
	void render_sprites_91464(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect, int primask, int sprmask, int colormask);
	void mcr_init(int cpuboard, int vidboard, int ssioboard);

	int8_t m_mcr12_sprite_xoffs_flip;
	uint8_t m_input_mux;
	uint8_t m_last_op4;
	tilemap_t *m_bg_tilemap;

	uint8_t m_mcr_cocktail_flip;

	required_device<z80_device> m_maincpu;
	optional_shared_ptr<uint8_t> m_spriteram;
	optional_shared_ptr<uint8_t> m_videoram;
	optional_shared_ptr<uint8_t> m_paletteram;

	required_device<z80ctc_device> m_ctc;
	optional_device<midway_ssio_device> m_ssio;
	optional_device<midway_cheap_squeak_deluxe_device> m_cheap_squeak_deluxe;
	optional_device<midway_sounds_good_device> m_sounds_good;
	optional_device<midway_turbo_cheap_squeak_device> m_turbo_cheap_squeak;
	optional_device<midway_squawk_n_talk_device> m_squawk_n_talk;
	optional_device<samples_device> m_samples;
	required_device<gfxdecode_device> m_gfxdecode;
	required_device<palette_device> m_palette;

private:
	uint32_t m_mcr_cpu_board;
	uint32_t m_mcr_sprite_board;

	int8_t m_mcr12_sprite_xoffs;
};

class mcr_dpoker_state : public mcr_state
{
public:
	mcr_dpoker_state(const machine_config &mconfig, device_type type, const char *tag) :
		mcr_state(mconfig, type, tag),
		m_coin_in_timer(*this, "coinin"),
		m_hopper_timer(*this, "hopper"),
		m_lamps(*this, "lamp%u", 0U)
	{ }

	DECLARE_READ8_MEMBER(ip0_r);
	DECLARE_WRITE8_MEMBER(lamps1_w);
	DECLARE_WRITE8_MEMBER(lamps2_w);
	DECLARE_WRITE8_MEMBER(output_w);
	DECLARE_WRITE8_MEMBER(meters_w);

	DECLARE_INPUT_CHANGED_MEMBER(coin_in_hit);

	TIMER_DEVICE_CALLBACK_MEMBER(hopper_callback);
	TIMER_DEVICE_CALLBACK_MEMBER(coin_in_callback);

	void init_dpoker();

	void mcr_90009_dp(machine_config &config);

protected:
	virtual void machine_start() override { mcr_state::machine_start(); m_lamps.resolve(); }

private:
	uint8_t m_coin_status;
	uint8_t m_output;

	required_device<timer_device> m_coin_in_timer;
	required_device<timer_device> m_hopper_timer;
	output_finder<14> m_lamps;
};

class mcr_nflfoot_state : public mcr_state
{
public:
	mcr_nflfoot_state(const machine_config &mconfig, device_type type, const char *tag)
		: mcr_state(mconfig, type, tag),
		m_ipu(*this, "ipu"),
		m_ipu_sio(*this, "ipu_sio"),
		m_ipu_ctc(*this, "ipu_ctc"),
		m_ipu_pio0(*this, "ipu_pio0"),
		m_ipu_pio1(*this, "ipu_pio1") {}

	DECLARE_WRITE_LINE_MEMBER(sio_txda_w);
	DECLARE_WRITE_LINE_MEMBER(sio_txdb_w);
	DECLARE_WRITE8_MEMBER(ipu_laserdisk_w);
	DECLARE_READ8_MEMBER(ipu_watchdog_r);
	DECLARE_WRITE8_MEMBER(ipu_watchdog_w);
	DECLARE_READ8_MEMBER(ip2_r);
	DECLARE_WRITE8_MEMBER(op4_w);

	TIMER_CALLBACK_MEMBER(ipu_watchdog_reset);
	TIMER_DEVICE_CALLBACK_MEMBER(ipu_interrupt);

	void init_nflfoot();

	void mcr_91490_ipu(machine_config &config);
	void ipu_91695_map(address_map &map);
	void ipu_91695_portmap(address_map &map);
protected:
	virtual void machine_start() override;

private:
	int m_ipu_sio_txda;
	int m_ipu_sio_txdb;
	emu_timer *m_ipu_watchdog_timer;

	required_device<cpu_device> m_ipu;
	required_device<z80dart_device> m_ipu_sio;
	required_device<z80ctc_device> m_ipu_ctc;
	required_device<z80pio_device> m_ipu_pio0;
	required_device<z80pio_device> m_ipu_pio1;
};

/*----------- defined in machine/mcr.cpp -----------*/

extern const z80_daisy_config mcr_daisy_chain[];
extern const z80_daisy_config mcr_ipu_daisy_chain[];

extern const gfx_layout mcr_bg_layout;
extern const gfx_layout mcr_sprite_layout;