1 // license:BSD-3-Clause
2 // copyright-holders:Ernesto Corvi, Nicola Salmoria
3 /*
4     buggychl
5 */
6 #ifndef MAME_INCLUDES_BUGGYCHL_H
7 #define MAME_INCLUDES_BUGGYCHL_H
8 
9 #pragma once
10 
11 #include "machine/taito68705interface.h"
12 #include "machine/input_merger.h"
13 #include "machine/gen_latch.h"
14 #include "sound/msm5232.h"
15 #include "sound/ta7630.h"
16 #include "sound/ay8910.h"
17 #include "emupal.h"
18 #include "screen.h"
19 
20 class buggychl_state : public driver_device
21 {
22 public:
buggychl_state(const machine_config & mconfig,device_type type,const char * tag)23 	buggychl_state(const machine_config &mconfig, device_type type, const char *tag) :
24 		driver_device(mconfig, type, tag),
25 		m_charram(*this, "charram"),
26 		m_videoram(*this, "videoram"),
27 		m_spriteram(*this, "spriteram"),
28 		m_scrollv(*this, "scrollv"),
29 		m_scrollh(*this, "scrollh"),
30 		m_audiocpu(*this, "audiocpu"),
31 		m_maincpu(*this, "maincpu"),
32 		m_bmcu(*this, "bmcu"),
33 		m_ta7630(*this, "ta7630"),
34 		m_msm(*this, "msm"),
35 		m_ay1(*this, "ay1"),
36 		m_ay2(*this, "ay2"),
37 		m_gfxdecode(*this, "gfxdecode"),
38 		m_screen(*this, "screen"),
39 		m_palette(*this, "palette"),
40 		m_soundnmi(*this, "soundnmi"),
41 		m_soundlatch(*this, "soundlatch"),
42 		m_soundlatch2(*this, "soundlatch2"),
43 		m_pedal_input(*this, "PEDAL"),
44 		m_led(*this, "led%u", 0U)
45 	{ }
46 
47 	/* memory pointers */
48 	required_shared_ptr<uint8_t> m_charram;
49 	required_shared_ptr<uint8_t> m_videoram;
50 	required_shared_ptr<uint8_t> m_spriteram;
51 	required_shared_ptr<uint8_t> m_scrollv;
52 	required_shared_ptr<uint8_t> m_scrollh;
53 
54 	/* devices */
55 	required_device<cpu_device> m_audiocpu;
56 	required_device<cpu_device> m_maincpu;
57 	required_device<taito68705_mcu_device> m_bmcu;
58 	required_device<ta7630_device> m_ta7630;
59 	required_device<msm5232_device> m_msm;
60 	required_device<ay8910_device> m_ay1;
61 	required_device<ay8910_device> m_ay2;
62 	required_device<gfxdecode_device> m_gfxdecode;
63 	required_device<screen_device> m_screen;
64 	required_device<palette_device> m_palette;
65 	required_device<input_merger_device> m_soundnmi;
66 	required_device<generic_latch_8_device> m_soundlatch;
67 	required_device<generic_latch_8_device> m_soundlatch2;
68 	required_ioport m_pedal_input;
69 
70 	output_finder<1> m_led;
71 
72 	void bankswitch_w(uint8_t data);
73 	void sound_enable_w(uint8_t data);
74 	uint8_t mcu_status_r();
75 	uint8_t sound_status_main_r();
76 	uint8_t sound_status_sound_r();
77 	void buggychl_chargen_w(offs_t offset, uint8_t data);
78 	void buggychl_sprite_lookup_bank_w(uint8_t data);
79 	void buggychl_sprite_lookup_w(offs_t offset, uint8_t data);
80 	void buggychl_ctrl_w(uint8_t data);
81 	void buggychl_bg_scrollx_w(uint8_t data);
82 	void ta7630_volbal_ay1_w(uint8_t data);
83 	void port_b_0_w(uint8_t data);
84 	void ta7630_volbal_ay2_w(uint8_t data);
85 	void port_b_1_w(uint8_t data);
86 	void ta7630_volbal_msm_w(uint8_t data);
87 	virtual void machine_start() override;
88 	virtual void machine_reset() override;
89 	virtual void video_start() override;
90 	void buggychl_palette(palette_device &palette) const;
91 	uint32_t screen_update_buggychl(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
92 	DECLARE_CUSTOM_INPUT_MEMBER( pedal_in_r );
93 
94 	void buggychl(machine_config &config);
95 	void buggychl_map(address_map &map);
96 	void sound_map(address_map &map);
97 private:
98 	void draw_sky( bitmap_ind16 &bitmap, const rectangle &cliprect );
99 	void draw_bg( bitmap_ind16 &bitmap, const rectangle &cliprect );
100 	void draw_fg( bitmap_ind16 &bitmap, const rectangle &cliprect );
101 	void draw_sprites( bitmap_ind16 &bitmap, const rectangle &cliprect );
102 	/* video-related */
103 	bitmap_ind16 m_tmp_bitmap1;
104 	bitmap_ind16 m_tmp_bitmap2;
105 	int         m_sl_bank;
106 	int         m_bg_clip_on;
107 	int         m_sky_on;
108 	int         m_sprite_color_base;
109 	int         m_bg_scrollx;
110 	bool        m_sound_irq_enable;
111 	uint8_t       m_sprite_lookup[0x2000];
112 };
113 
114 #endif // MAME_INCLUDES_BUGGYCHL_H
115