summaryrefslogtreecommitdiffstatshomepage
path: root/src/mame/includes/superqix.h
blob: 54198e6595817c68792032030f2a939782c870e6 (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
// license:BSD-3-Clause
// copyright-holders:Mirko Buffoni, Nicola Salmoria, Tomasz Slanina
#ifndef MAME_INCLUDES_SUPERQIX_H
#define MAME_INCLUDES_SUPERQIX_H

#pragma once

#include "sound/ay8910.h"
#include "sound/samples.h"
#include "emupal.h"

class superqix_state_base : public driver_device
{
public:
	superqix_state_base(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_bitmapram(*this, "bitmapram")
		, m_bitmapram2(*this, "bitmapram2")
		, m_gfxdecode(*this, "gfxdecode")
		, m_palette(*this, "palette")
		, m_ay1(*this, "ay1")
		, m_mcu(*this, "mcu")
	{ }

	void init_perestro();
	void init_sqix();
	void init_sqixr0();
	void init_pbillian();
	void init_hotsmash();

protected:
	required_device<cpu_device> m_maincpu;
	required_shared_ptr<uint8_t> m_spriteram;
	required_shared_ptr<uint8_t> m_videoram;
	optional_shared_ptr<uint8_t> m_bitmapram;
	optional_shared_ptr<uint8_t> m_bitmapram2;
	required_device<gfxdecode_device> m_gfxdecode;
	required_device<palette_device> m_palette;
	required_device<ay8910_device> m_ay1;
	optional_device<cpu_device> m_mcu;

	// commmon 68705/8751/HLE
	uint8_t m_fromMCU;        // byte latch for 68705/8751->z80 comms
	uint8_t m_fromZ80;        // byte latch for z80->68705/8751 comms
	bool m_Z80HasWritten;   // z80 has written to latch flag
	bool m_MCUHasWritten;   // 68705/8751 has written to latch flag

	//general machine stuff
	bool m_invert_coin_lockout;
	bool m_invert_p2_spinner;
	int m_gfxbank;
	bool m_show_bitmap;
	bool m_nmi_mask;

	std::unique_ptr<bitmap_ind16> m_fg_bitmap[2];
	tilemap_t *m_bg_tilemap;

	DECLARE_READ8_MEMBER(nmi_ack_r);
	DECLARE_WRITE8_MEMBER(superqix_videoram_w);
	DECLARE_WRITE8_MEMBER(superqix_bitmapram_w);
	DECLARE_WRITE8_MEMBER(superqix_bitmapram2_w);
	DECLARE_WRITE8_MEMBER(superqix_0410_w);

	TILE_GET_INFO_MEMBER(sqix_get_bg_tile_info);
	DECLARE_VIDEO_START(superqix);
	DECLARE_PALETTE_DECODER(BBGGRRII);
	uint32_t screen_update_superqix(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
	void superqix_draw_sprites(bitmap_ind16 &bitmap,const rectangle &cliprect);

	void main_map(address_map &map);

	virtual void machine_init_common();
};


class superqix_state : public superqix_state_base
{
public:
	superqix_state(const machine_config &mconfig, device_type type, const char *tag)
		: superqix_state_base(mconfig, type, tag)
		, m_ay2(*this, "ay2")
	{
	}

	void sqix(machine_config &config);
	void sqix_8031(machine_config &config);
	void sqix_nomcu(machine_config &config);

	DECLARE_CUSTOM_INPUT_MEMBER(fromz80_semaphore_input_r);
	DECLARE_CUSTOM_INPUT_MEMBER(frommcu_semaphore_input_r);

private:
	required_device<ay8910_device> m_ay2;

	// 8031 and/or 8751 MCU related
	uint8_t m_bl_port1;
	uint8_t m_bl_fake_port2;
	uint8_t m_port2_raw;
	uint8_t m_bl_port3_out;

	DECLARE_READ8_MEMBER(z80_semaphore_assert_r);
	DECLARE_WRITE8_MEMBER(bootleg_mcu_port1_w);
	DECLARE_WRITE8_MEMBER(mcu_port2_w);
	DECLARE_WRITE8_MEMBER(mcu_port3_w);
	DECLARE_READ8_MEMBER(mcu_port3_r);
	DECLARE_READ8_MEMBER(bootleg_mcu_port3_r);
	DECLARE_WRITE8_MEMBER(bootleg_mcu_port3_w);
	DECLARE_WRITE8_MEMBER(z80_ay1_sync_address_w);
	DECLARE_READ8_MEMBER(z80_ay2_iob_r);
	DECLARE_WRITE8_MEMBER(z80_ay2_iob_w);
	DECLARE_WRITE8_MEMBER(bootleg_flipscreen_w);
	DECLARE_READ8_MEMBER(bootleg_in0_r);
	INTERRUPT_GEN_MEMBER(sqix_timer_irq);
	DECLARE_MACHINE_START(superqix);
	DECLARE_MACHINE_RESET(superqix);

	void sqix_port_map(address_map &map);
	void sqix_8031_map(address_map &map);

	virtual void machine_init_common() override;

	TIMER_CALLBACK_MEMBER(z80_semaphore_assert_cb);
	TIMER_CALLBACK_MEMBER(mcu_port2_w_cb);
	TIMER_CALLBACK_MEMBER(mcu_port3_w_cb);
	TIMER_CALLBACK_MEMBER(z80_ay1_sync_address_w_cb);
	TIMER_CALLBACK_MEMBER(z80_ay2_iob_w_cb);
	TIMER_CALLBACK_MEMBER(bootleg_mcu_port1_w_cb);
};


class hotsmash_state : public superqix_state_base
{
public:
	hotsmash_state(const machine_config &mconfig, device_type type, const char *tag)
		: superqix_state_base(mconfig, type, tag)
		, m_dsw(*this, "DSW%u", 1)
		, m_dials(*this, "DIAL%u", 1)
		, m_plungers(*this, "PLUNGER%u", 1)
		, m_launchbtns(*this, "LAUNCH%u", 1)
		, m_samples(*this, "samples")
		, m_samples_region(*this, "samples")
		, m_samplebuf()
		, m_portB_out(0xff)
		, m_portC_out(0xff)
		, m_dial_oldpos{ 0, 0 }
		, m_dial_sign{ 0, 0 }
	{
	}

	void pbillian(machine_config &config);

	DECLARE_CUSTOM_INPUT_MEMBER(pbillian_semaphore_input_r);

private:
	DECLARE_READ8_MEMBER(hotsmash_68705_portA_r);
	DECLARE_WRITE8_MEMBER(hotsmash_68705_portB_w);
	DECLARE_WRITE8_MEMBER(hotsmash_68705_portC_w);
	DECLARE_WRITE8_MEMBER(hotsmash_Z80_mcu_w);
	DECLARE_READ8_MEMBER(hotsmash_Z80_mcu_r);

	DECLARE_WRITE8_MEMBER(pbillian_sample_trigger_w);
	DECLARE_WRITE8_MEMBER(pbillian_0410_w);

	DECLARE_WRITE_LINE_MEMBER(vblank_irq);

	SAMPLES_START_CB_MEMBER(pbillian_sh_start);

	TILE_GET_INFO_MEMBER(pb_get_bg_tile_info);

	DECLARE_MACHINE_START(pbillian);
	DECLARE_VIDEO_START(pbillian);

	u32 screen_update_pbillian(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);

	void pbillian_port_map(address_map &map);

	virtual void machine_init_common() override;

	int read_inputs(int player);

	void pbillian_draw_sprites(bitmap_ind16 &bitmap, const rectangle &cliprect);

	required_ioport_array<2>        m_dsw;
	required_ioport_array<2>        m_dials;
	optional_ioport_array<2>        m_plungers;
	optional_ioport_array<2>        m_launchbtns;
	optional_device<samples_device> m_samples;
	optional_region_ptr<u8>         m_samples_region;

	std::unique_ptr<s16[]>          m_samplebuf;

	// 68705 related
	u8  m_portA_in;
	u8  m_portB_out;
	u8  m_portC_out;

	// spinner quadrature stuff
	int m_dial_oldpos[2];
	int m_dial_sign[2];
};

#endif // MAME_INCLUDES_SUPERQIX_H