1 // license:BSD-3-Clause
2 // copyright-holders:David Haywood
3 /***************************************************************************
4 
5    CPS1 bootleg "Final Crash" hardware
6 
7 ***************************************************************************/
8 
9 #ifndef MAME_INCLUDES_FCRASH_H
10 #define MAME_INCLUDES_FCRASH_H
11 
12 #pragma once
13 
14 #include "includes/cps1.h"
15 
16 class fcrash_state : public cps_state
17 {
18 public:
fcrash_state(const machine_config & mconfig,device_type type,const char * tag)19 	fcrash_state(const machine_config &mconfig, device_type type, const char *tag)
20 		: cps_state(mconfig, type, tag, 1)
21 		, m_msm_1(*this, "msm1")
22 		, m_msm_2(*this, "msm2")
23 		, m_okibank(*this, "okibank")
24 		, m_sgyxz_dsw(*this, { "DSWA", "DSWB", "DSWC" })
25 	{ }
26 
27 	void fcrash(machine_config &config);
28 	void cawingbl(machine_config &config);
29 	void ffightblb(machine_config &config);
30 	void kodb(machine_config &config);
31 	void mtwinsb(machine_config &config);
32 	void sf2m1(machine_config &config);
33 	void sgyxz(machine_config &config);
34 	void wofabl(machine_config &config);
35 	void wofr1bl(machine_config &config);
36 	void varthb(machine_config &config);
37 
38 	void init_cawingbl();
39 	void init_kodb();
40 	void init_mtwinsb();
41 	void init_sf2m1();
42 	void init_wofr1bl();
43 
44 protected:
45 	DECLARE_MACHINE_START(fcrash);
46 	DECLARE_MACHINE_RESET(fcrash);
47 	DECLARE_MACHINE_START(cawingbl);
48 	DECLARE_MACHINE_START(ffightblb);
49 	DECLARE_MACHINE_START(kodb);
50 	DECLARE_MACHINE_START(mtwinsb);
51 	DECLARE_MACHINE_START(sf2m1);
52 	DECLARE_MACHINE_START(sgyxz);
53 	DECLARE_MACHINE_RESET(sgyxz);
54 	DECLARE_MACHINE_START(wofr1bl);
55 
56 	void fcrash_soundlatch_w(offs_t offset, uint16_t data, uint16_t mem_mask = ~0);
57 	void fcrash_snd_bankswitch_w(uint8_t data);
58 	DECLARE_WRITE_LINE_MEMBER(m5205_int1);
59 	DECLARE_WRITE_LINE_MEMBER(m5205_int2);
60 	void fcrash_msm5205_0_data_w(uint8_t data);
61 	void fcrash_msm5205_1_data_w(uint8_t data);
62 	void cawingbl_soundlatch_w(offs_t offset, uint16_t data, uint16_t mem_mask = ~0);
63 	void kodb_layer_w(offs_t offset, uint16_t data);
64 	void mtwinsb_layer_w(offs_t offset, uint16_t data);
65 	void sf2m1_layer_w(offs_t offset, uint16_t data);
66 	void varthb_layer_w(offs_t offset, uint16_t data);
67 	void varthb_layer2_w(uint16_t data);
68 	uint16_t sgyxz_dsw_r(offs_t offset);
69 	void wofr1bl_layer_w(offs_t offset, uint16_t data);
70 	void wofr1bl_layer2_w(uint16_t data);
71 	void wofr1bl_spr_base_w(uint16_t data);
72 
73 	uint32_t screen_update_fcrash(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
74 	void fcrash_update_transmasks();
75 	virtual void bootleg_render_sprites(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
76 	void fcrash_render_layer(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect, int layer, int primask);
77 	void fcrash_render_high_layer(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect, int layer);
78 	virtual void fcrash_build_palette();
79 
80 	void fcrash_map(address_map &map);
81 	void mtwinsb_map(address_map &map);
82 	void sf2m1_map(address_map &map);
83 	void sgyxz_map(address_map &map);
84 	void wofabl_map(address_map &map);
85 	void wofr1bl_map(address_map &map);
86 	void varthb_map(address_map &map);
87 
88 	void fcrash_sound_map(address_map &map);
89 	void ffightblb_sound_map(address_map &map);
90 	void ffightblb_oki_map(address_map &map);
91 	void kodb_sound_map(address_map &map);
92 	void sgyxz_sound_map(address_map &map);
93 
94 	/* sound hw */
95 	int m_sample_buffer1;
96 	int m_sample_buffer2;
97 	int m_sample_select1;
98 	int m_sample_select2;
99 
100 	/* video config */
101 	uint8_t m_layer_enable_reg;
102 	uint8_t m_layer_mask_reg[4];
103 	int     m_layer_scroll1x_offset;
104 	int     m_layer_scroll2x_offset;
105 	int     m_layer_scroll3x_offset;
106 	int     m_sprite_base;
107 	int     m_sprite_list_end_marker;
108 	int     m_sprite_x_offset;
109 	std::unique_ptr<uint16_t[]> m_bootleg_sprite_ram;
110 	std::unique_ptr<uint16_t[]> m_bootleg_work_ram;
111 
112 	optional_device<msm5205_device> m_msm_1;
113 	optional_device<msm5205_device> m_msm_2;
114 
115 	optional_memory_bank m_okibank;
116 
117 	optional_ioport_array<3> m_sgyxz_dsw;
118 };
119 
120 class cps1bl_no_brgt : public fcrash_state
121 {
122 public:
cps1bl_no_brgt(const machine_config & mconfig,device_type type,const char * tag)123 	cps1bl_no_brgt(const machine_config &mconfig, device_type type, const char *tag)
124 		: fcrash_state(mconfig, type, tag)
125 	{ }
126 
127 private:
128 	void fcrash_build_palette() override;
129 };
130 
131 #endif // MAME_INCLUDES_FCRASH_H
132