1 // license:BSD-3-Clause
2 // copyright-holders:Ernesto Corvi
3 #ifndef MAME_INCLUDES_WC90B_H
4 #define MAME_INCLUDES_WC90B_H
5 
6 #pragma once
7 
8 #include "machine/gen_latch.h"
9 #include "sound/msm5205.h"
10 #include "emupal.h"
11 #include "tilemap.h"
12 
13 class wc90b_state : public driver_device
14 {
15 public:
wc90b_state(const machine_config & mconfig,device_type type,const char * tag)16 	wc90b_state(const machine_config &mconfig, device_type type, const char *tag) :
17 		driver_device(mconfig, type, tag),
18 		m_maincpu(*this, "maincpu"),
19 		m_subcpu(*this, "sub"),
20 		m_audiocpu(*this, "audiocpu"),
21 		m_msm(*this, "msm"),
22 		m_soundlatch(*this, "soundlatch"),
23 		m_palette(*this, "palette"),
24 		m_gfxdecode(*this, "gfxdecode"),
25 		m_fgvideoram(*this, "fgvideoram"),
26 		m_bgvideoram(*this, "bgvideoram"),
27 		m_txvideoram(*this, "txvideoram"),
28 		m_spriteram(*this, "spriteram"),
29 		m_scroll1x(*this, "scroll1x"),
30 		m_scroll2x(*this, "scroll2x"),
31 		m_scroll1y(*this, "scroll1y"),
32 		m_scroll2y(*this, "scroll2y"),
33 		m_scroll_x_lo(*this, "scroll_x_lo")
34 	{ }
35 
36 	void wc90b(machine_config &config);
37 	void eurogael(machine_config &config);
38 
39 	void init_wc90b();
40 
41 	void bgvideoram_w(offs_t offset, uint8_t data);
42 	void fgvideoram_w(offs_t offset, uint8_t data);
43 	void txvideoram_w(offs_t offset, uint8_t data);
44 	void bankswitch_w(uint8_t data);
45 	void sound_command_w(uint8_t data);
46 	DECLARE_WRITE_LINE_MEMBER(adpcm_int);
47 
48 	void sound_cpu(address_map &map);
49 	void wc90b_map2(address_map &map);
50 
51 protected:
52 	virtual void machine_start() override;
53 	virtual void video_start() override;
54 
55 	tilemap_t *m_tx_tilemap;
56 	tilemap_t *m_fg_tilemap;
57 	tilemap_t *m_bg_tilemap;
58 
59 	required_device<cpu_device> m_maincpu;
60 	required_device<cpu_device> m_subcpu;
61 	required_device<cpu_device> m_audiocpu;
62 	required_device<msm5205_device> m_msm;
63 	required_device<generic_latch_8_device> m_soundlatch;
64 	required_device<palette_device> m_palette;
65 	required_device<gfxdecode_device> m_gfxdecode;
66 	required_shared_ptr<uint8_t> m_fgvideoram;
67 	required_shared_ptr<uint8_t> m_bgvideoram;
68 	required_shared_ptr<uint8_t> m_txvideoram;
69 	required_shared_ptr<uint8_t> m_spriteram;
70 
71 
72 	virtual uint32_t screen_update(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
73 	virtual void draw_sprites(bitmap_ind16 &bitmap, const rectangle &cliprect, int priority );
74 
75 private:
76 
77 	optional_shared_ptr<uint8_t> m_scroll1x;
78 	optional_shared_ptr<uint8_t> m_scroll2x;
79 	optional_shared_ptr<uint8_t> m_scroll1y;
80 	optional_shared_ptr<uint8_t> m_scroll2y;
81 	optional_shared_ptr<uint8_t> m_scroll_x_lo;
82 
83 	void wc90b_map1(address_map &map);
84 
85 	int m_msm5205next;
86 	int m_toggle;
87 
88 	void bankswitch1_w(uint8_t data);
89 	void adpcm_data_w(uint8_t data);
90 	void adpcm_control_w(uint8_t data);
91 	uint8_t master_irq_ack_r();
92 	void slave_irq_ack_w(uint8_t data);
93 
94 	TILE_GET_INFO_MEMBER(get_bg_tile_info);
95 	TILE_GET_INFO_MEMBER(get_fg_tile_info);
96 	TILE_GET_INFO_MEMBER(get_tx_tile_info);
97 };
98 
99 
100 class eurogael_state : public wc90b_state
101 {
102 public:
eurogael_state(const machine_config & mconfig,device_type type,const char * tag)103 	eurogael_state(const machine_config &mconfig, device_type type, const char *tag) :
104 		wc90b_state(mconfig, type, tag),
105 		m_bgscroll(*this, "bgscroll")
106 	{ }
107 
108 	void eurogael(machine_config &config);
109 
110 protected:
111 	virtual uint32_t screen_update(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect) override;
112 	virtual void draw_sprites(bitmap_ind16 &bitmap, const rectangle &cliprect, int priority ) override;
113 
114 private:
115 	void master_irq_ack_w(uint8_t data);
116 	required_shared_ptr<uint8_t> m_bgscroll;
117 
118 	void map1(address_map &map);
119 };
120 
121 
122 #endif // MAME_INCLUDES_WC90B_H
123