1 // license:BSD-3-Clause
2 // copyright-holders:K.Wilkins,Stephane Humbert
3 /***************************************************************************
4 
5   Toaplan Slap Fight hardware
6 
7 ***************************************************************************/
8 #ifndef MAME_INCLUDES_SLAPFGHT_H
9 #define MAME_INCLUDES_SLAPFGHT_H
10 
11 #pragma once
12 
13 #include "cpu/z80/z80.h"
14 #include "video/bufsprite.h"
15 #include "machine/taito68705interface.h"
16 #include "emupal.h"
17 #include "screen.h"
18 #include "tilemap.h"
19 
20 class slapfght_state : public driver_device
21 {
22 public:
slapfght_state(const machine_config & mconfig,device_type type,const char * tag)23 	slapfght_state(const machine_config &mconfig, device_type type, const char *tag) :
24 		driver_device(mconfig, type, tag),
25 		m_maincpu(*this, "maincpu"),
26 		m_audiocpu(*this, "audiocpu"),
27 		m_bmcu(*this, "bmcu"),
28 		m_gfxdecode(*this, "gfxdecode"),
29 		m_screen(*this, "screen"),
30 		m_palette(*this, "palette"),
31 		m_spriteram(*this, "spriteram"),
32 		m_videoram(*this, "videoram"),
33 		m_colorram(*this, "colorram"),
34 		m_fixvideoram(*this, "fixvideoram"),
35 		m_fixcolorram(*this, "fixcolorram")
36 	{ }
37 
38 	void tigerh(machine_config &config);
39 	void tigerhb1(machine_config &config);
40 	void tigerhb2(machine_config &config);
41 	void tigerhb4(machine_config &config);
42 	void getstarb2(machine_config &config);
43 	void slapfighb2(machine_config &config);
44 	void getstarb1(machine_config &config);
45 	void perfrman(machine_config &config);
46 	void slapfigh(machine_config &config);
47 	void slapfighb1(machine_config &config);
48 
49 	void init_banks();
50 	void init_getstarb1();
51 	void init_slapfigh();
52 	void init_getstarb2();
53 
54 private:
55 	// devices, memory pointers
56 	required_device<cpu_device> m_maincpu;
57 	required_device<cpu_device> m_audiocpu;
58 	optional_device<taito68705_mcu_device> m_bmcu;
59 	required_device<gfxdecode_device> m_gfxdecode;
60 	required_device<screen_device> m_screen;
61 	required_device<palette_device> m_palette;
62 	required_device<buffered_spriteram8_device> m_spriteram;
63 
64 	required_shared_ptr<uint8_t> m_videoram;
65 	required_shared_ptr<uint8_t> m_colorram;
66 	optional_shared_ptr<uint8_t> m_fixvideoram;
67 	optional_shared_ptr<uint8_t> m_fixcolorram;
68 
69 	/* This it the best way to allow game specific kludges until the system is fully understood */
70 	enum getstar_id
71 	{
72 		GETSTUNK = 0, /* unknown for inclusion of possible new sets */
73 		//GETSTAR,
74 		//GETSTARJ,
75 		GETSTARB1,    /* "good" bootleg with same behaviour as 'getstarj' */
76 		GETSTARB2     /* "lame" bootleg with lots of ingame bugs */
77 	} m_getstar_id;
78 
79 	tilemap_t *m_pf1_tilemap;
80 	tilemap_t *m_fix_tilemap;
81 	uint8_t m_palette_bank;
82 	uint8_t m_scrollx_lo;
83 	uint8_t m_scrollx_hi;
84 	uint8_t m_scrolly;
85 	bool m_main_irq_enabled;
86 	bool m_sound_nmi_enabled;
87 
88 	int m_getstar_status;
89 	int m_getstar_sequence_index;
90 	int m_getstar_status_state;
91 	uint8_t m_getstar_cmd;
92 	uint8_t m_gs_a;
93 	uint8_t m_gs_d;
94 	uint8_t m_gs_e;
95 	uint8_t m_tigerhb_cmd;
96 
97 	uint8_t tigerh_mcu_status_r();
98 	DECLARE_WRITE_LINE_MEMBER(sound_reset_w);
99 	DECLARE_WRITE_LINE_MEMBER(irq_enable_w);
100 	uint8_t vblank_r();
101 	void sound_nmi_enable_w(offs_t offset, uint8_t data);
102 	void videoram_w(offs_t offset, uint8_t data);
103 	void colorram_w(offs_t offset, uint8_t data);
104 	void fixram_w(offs_t offset, uint8_t data);
105 	void fixcol_w(offs_t offset, uint8_t data);
106 	void scrollx_lo_w(uint8_t data);
107 	void scrollx_hi_w(uint8_t data);
108 	void scrolly_w(uint8_t data);
109 	DECLARE_WRITE_LINE_MEMBER(flipscreen_w);
110 	DECLARE_WRITE_LINE_MEMBER(palette_bank_w);
111 
112 	void scroll_from_mcu_w(offs_t offset, uint8_t data);
113 
114 	uint8_t getstar_mcusim_r();
115 	void getstar_mcusim_w(uint8_t data);
116 	uint8_t getstar_mcusim_status_r();
117 	uint8_t getstarb1_prot_r();
118 	uint8_t tigerhb1_prot_r();
119 	void tigerhb1_prot_w(uint8_t data);
120 
121 	virtual void machine_start() override;
122 	virtual void machine_reset() override;
123 
124 	TILE_GET_INFO_MEMBER(get_pf_tile_info);
125 	TILE_GET_INFO_MEMBER(get_pf1_tile_info);
126 	TILE_GET_INFO_MEMBER(get_fix_tile_info);
127 	DECLARE_VIDEO_START(perfrman);
128 	DECLARE_VIDEO_START(slapfight);
129 
130 	void draw_perfrman_sprites(bitmap_ind16 &bitmap, const rectangle &cliprect, int layer);
131 	void draw_slapfight_sprites(bitmap_ind16 &bitmap, const rectangle &cliprect);
132 	uint32_t screen_update_perfrman(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
133 	uint32_t screen_update_slapfight(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
134 
135 	DECLARE_WRITE_LINE_MEMBER(vblank_irq);
136 	INTERRUPT_GEN_MEMBER(sound_nmi);
137 
138 	void getstar_map(address_map &map);
139 	void getstarb1_io_map(address_map &map);
140 	void getstarb2_io_map(address_map &map);
141 	void io_map_mcu(address_map &map);
142 	void io_map_nomcu(address_map &map);
143 	void perfrman_map(address_map &map);
144 	void perfrman_sound_map(address_map &map);
145 	void slapfigh_map(address_map &map);
146 	void slapfigh_map_mcu(address_map &map);
147 	void slapfighb1_map(address_map &map);
148 	void slapfighb2_map(address_map &map);
149 	void tigerh_map(address_map &map);
150 	void tigerh_map_mcu(address_map &map);
151 	void tigerh_sound_map(address_map &map);
152 	void tigerhb1_map(address_map &map);
153 	void tigerhb2_map(address_map &map);
154 };
155 
156 #endif // MAME_INCLUDES_SLAPFGHT_H
157