1 // license:GPL-2.0+
2 // copyright-holders:Jarek Burczynski
3 #ifndef MAME_INCLUDES_TAITO_B_H
4 #define MAME_INCLUDES_TAITO_B_H
5 
6 #pragma once
7 
8 #include "machine/mb87078.h"
9 #include "machine/taitoio.h"
10 #include "video/hd63484.h"
11 #include "video/tc0180vcu.h"
12 #include "emupal.h"
13 #include "screen.h"
14 
15 class taitob_state : public driver_device
16 {
17 public:
taitob_state(const machine_config & mconfig,device_type type,const char * tag)18 	taitob_state(const machine_config &mconfig, device_type type, const char *tag) :
19 		driver_device(mconfig, type, tag),
20 		m_maincpu(*this, "maincpu"),
21 		m_audiocpu(*this, "audiocpu"),
22 		m_ym(*this, "ymsnd"),
23 		m_hd63484(*this, "hd63484"),
24 		m_tc0180vcu(*this, "tc0180vcu"),
25 		m_tc0640fio(*this, "tc0640fio"),
26 		m_tc0220ioc(*this, "tc0220ioc"),
27 		m_tc0510nio(*this, "tc0510nio"),
28 		m_mb87078(*this, "mb87078"),
29 		m_screen(*this, "screen"),
30 		m_palette(*this, "palette"),
31 		m_audiobank(*this, "audiobank"),
32 		m_eepromout_io(*this, "EEPROMOUT"),
33 		m_trackx_io(*this, "TRACKX%u", 1U),
34 		m_tracky_io(*this, "TRACKY%u", 1U)
35 	{ }
36 
37 	void spacedx(machine_config &config);
38 	void rambo3(machine_config &config);
39 	void ashura(machine_config &config);
40 	void silentd(machine_config &config);
41 	void tetrista(machine_config &config);
42 	void spacedxo(machine_config &config);
43 	void rambo3p(machine_config &config);
44 	void rastsag2(machine_config &config);
45 	void qzshowby(machine_config &config);
46 	void sbm(machine_config &config);
47 	void tetrist(machine_config &config);
48 	void pbobble(machine_config &config);
49 	void masterw(machine_config &config);
50 	void ryujin(machine_config &config);
51 	void viofight(machine_config &config);
52 	void crimec(machine_config &config);
53 	void selfeena(machine_config &config);
54 
55 	void init_taito_b();
56 
57 protected:
58 	void player_12_coin_ctrl_w(uint8_t data);
59 
60 	void sound_map(address_map &map);
61 
62 	void bankswitch_w(uint8_t data);
63 	template<int Player> uint16_t tracky_hi_r();
64 	template<int Player> uint16_t tracky_lo_r();
65 	template<int Player> uint16_t trackx_hi_r();
66 	template<int Player> uint16_t trackx_lo_r();
67 	uint16_t eep_latch_r();
68 	void eeprom_w(offs_t offset, uint16_t data, uint16_t mem_mask = ~0);
69 	uint16_t player_34_coin_ctrl_r();
70 	void player_34_coin_ctrl_w(offs_t offset, uint16_t data, uint16_t mem_mask = ~0);
71 	void spacedxo_tc0220ioc_w(offs_t offset, uint16_t data, uint16_t mem_mask = ~0);
72 	void mb87078_gain_changed(offs_t offset, uint8_t data);
73 	virtual void video_start() override;
74 	uint32_t screen_update_taitob(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
75 
76 	void crimec_map(address_map &map);
77 	void masterw_map(address_map &map);
78 	void masterw_sound_map(address_map &map);
79 	void pbobble_map(address_map &map);
80 	void qzshowby_map(address_map &map);
81 	void rambo3_map(address_map &map);
82 	void rastsag2_map(address_map &map);
83 
84 	void sbm_map(address_map &map);
85 	void selfeena_map(address_map &map);
86 	void silentd_map(address_map &map);
87 	void spacedx_map(address_map &map);
88 	void spacedxo_map(address_map &map);
89 	void tetrist_map(address_map &map);
90 	void tetrista_map(address_map &map);
91 	void viofight_map(address_map &map);
92 	void viofight_sound_map(address_map &map);
93 
94 	virtual void machine_start() override;
95 	virtual void machine_reset() override;
96 
97 	/* video-related */
98 	std::unique_ptr<bitmap_ind16> m_pixel_bitmap;
99 
100 	uint16_t        m_pixel_scroll[3];
101 
102 	int            m_b_fg_color_base;
103 
104 	/* misc */
105 	uint16_t        m_eep_latch;
106 	uint16_t        m_coin_word;
107 
108 	/* devices */
109 	required_device<cpu_device> m_maincpu;
110 	required_device<cpu_device> m_audiocpu;
111 	required_device<device_t> m_ym;
112 	optional_device<hd63484_device> m_hd63484;
113 	required_device<tc0180vcu_device> m_tc0180vcu;
114 	optional_device<tc0640fio_device> m_tc0640fio;
115 	optional_device<tc0220ioc_device> m_tc0220ioc;
116 	optional_device<tc0510nio_device> m_tc0510nio;
117 	optional_device<mb87078_device> m_mb87078;
118 	required_device<screen_device> m_screen;
119 	required_device<palette_device> m_palette;
120 
121 	required_memory_bank m_audiobank;
122 	optional_ioport m_eepromout_io;
123 	optional_ioport_array<2> m_trackx_io;
124 	optional_ioport_array<2> m_tracky_io;
125 };
126 
127 class taitob_c_state : public taitob_state
128 {
129 public:
130 	using taitob_state::taitob_state;
unemulated_features()131 	static constexpr feature_type unemulated_features() { return feature::CAMERA; }
132 	void realpunc(machine_config &config);
133 
134 	DECLARE_INPUT_CHANGED_MEMBER(realpunc_sensor);
135 
136 protected:
137 	void realpunc_output_w(uint16_t data);
138 	void realpunc_video_ctrl_w(offs_t offset, uint16_t data, uint16_t mem_mask = ~0);
139 
140 	void realpunc_map(address_map &map);
141 	void realpunc_hd63484_map(address_map &map);
142 
143 	virtual void video_start() override;
144 	uint32_t screen_update_realpunc(screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect);
145 
146 private:
147 	std::unique_ptr<bitmap_ind16> m_realpunc_bitmap;
148 	uint16_t        m_realpunc_video_ctrl;
149 };
150 
151 class hitice_state : public taitob_state
152 {
153 public:
hitice_state(const machine_config & mconfig,device_type type,const char * tag)154 	hitice_state(const machine_config &mconfig, device_type type, const char *tag) :
155 		taitob_state(mconfig, type, tag),
156 		m_pixelram(*this, "pixelram")
157 	{ }
158 
159 	void hitice(machine_config &config);
160 
161 protected:
162 	virtual void video_start() override;
163 	virtual void video_reset() override;
164 
165 private:
166 	void pixelram_w(offs_t offset, uint16_t data, uint16_t mem_mask = ~0);
167 	void pixel_scroll_w(offs_t offset, uint16_t data, uint16_t mem_mask = ~0);
168 
169 	void hitice_map(address_map &map);
170 
171 	void clear_pixel_bitmap();
172 
173 	required_shared_ptr<uint16_t> m_pixelram;
174 };
175 
176 #endif // MAME_INCLUDES_TAITO_B_H
177