1 // license:BSD-3-Clause
2 // copyright-holders:Joseba Epalza
3 #ifndef MAME_INCLUDES_SPEEDBAL_H
4 #define MAME_INCLUDES_SPEEDBAL_H
5 
6 #pragma once
7 
8 #include "emupal.h"
9 #include "tilemap.h"
10 
11 class speedbal_state : public driver_device
12 {
13 public:
speedbal_state(const machine_config & mconfig,device_type type,const char * tag)14 	speedbal_state(const machine_config &mconfig, device_type type, const char *tag)
15 		: driver_device(mconfig, type, tag)
16 		, m_maincpu(*this, "maincpu")
17 		, m_gfxdecode(*this, "gfxdecode")
18 		, m_palette(*this, "palette")
19 		, m_spriteram(*this, "spriteram")
20 		, m_background_videoram(*this, "bg_videoram")
21 		, m_foreground_videoram(*this, "fg_videoram")
22 		, m_digits(*this, "digit%u", 0U)
23 	{ }
24 
25 	void speedbal(machine_config &config);
26 
27 	void init_speedbal();
28 	void init_musicbal();
29 
30 protected:
31 	virtual void machine_start() override;
32 	virtual void video_start() override;
33 
34 private:
35 	required_device<cpu_device> m_maincpu;
36 	required_device<gfxdecode_device> m_gfxdecode;
37 	required_device<palette_device> m_palette;
38 
39 	required_shared_ptr<uint8_t> m_spriteram;
40 	required_shared_ptr<uint8_t> m_background_videoram;
41 	required_shared_ptr<uint8_t> m_foreground_videoram;
42 	output_finder<73> m_digits;
43 
44 	bool m_leds_start;
45 	uint32_t m_leds_shiftreg;
46 	tilemap_t *m_bg_tilemap;
47 	tilemap_t *m_fg_tilemap;
48 
49 	void coincounter_w(uint8_t data);
50 	void foreground_videoram_w(offs_t offset, uint8_t data);
51 	void background_videoram_w(offs_t offset, uint8_t data);
52 	void maincpu_50_w(uint8_t data);
53 	void leds_output_block(uint8_t data);
54 	void leds_start_block(uint8_t data);
55 	void leds_shift_bit(uint8_t data);
56 
57 	TILE_GET_INFO_MEMBER(get_tile_info_bg);
58 	TILE_GET_INFO_MEMBER(get_tile_info_fg);
59 
60 	uint32_t screen_update(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
61 	void draw_sprites(bitmap_ind16 &bitmap, const rectangle &cliprect);
62 
63 	void main_cpu_io_map(address_map &map);
64 	void main_cpu_map(address_map &map);
65 	void sound_cpu_io_map(address_map &map);
66 	void sound_cpu_map(address_map &map);
67 };
68 
69 #endif // MAME_INCLUDES_SPEEDBAL_H
70