1 // license:BSD-3-Clause
2 // copyright-holders:Luca Elia
3 /***************************************************************************
4 
5     Blomby Car
6 
7 ***************************************************************************/
8 
9 #include "video/gaelco_wrally_sprites.h"
10 #include "emupal.h"
11 #include "tilemap.h"
12 
13 class blmbycar_state : public driver_device
14 {
15 public:
blmbycar_state(const machine_config & mconfig,device_type type,const char * tag)16 	blmbycar_state(const machine_config &mconfig, device_type type, const char *tag) :
17 		driver_device(mconfig, type, tag),
18 		m_maincpu(*this, "maincpu"),
19 		m_gfxdecode(*this, "gfxdecode"),
20 		m_palette(*this, "palette"),
21 		m_sprites(*this, "sprites"),
22 		m_vram(*this, "vram_%u", 0U),
23 		m_scroll(*this, "scroll_%u", 0U),
24 		m_spriteram(*this, "spriteram"),
25 		m_okibank(*this, "okibank"),
26 		m_pot_wheel_io(*this, "POT_WHEEL"),
27 		m_opt_wheel_io(*this, "OPT_WHEEL")
28 	{
29 	}
30 
31 	void watrball(machine_config &config);
32 	void blmbycar(machine_config &config);
33 
34 	void init_blmbycar();
35 
36 private:
37 	/* devices */
38 	required_device<cpu_device> m_maincpu;
39 	required_device<gfxdecode_device> m_gfxdecode;
40 	required_device<palette_device> m_palette;
41 	required_device<gaelco_wrally_sprites_device> m_sprites;
42 
43 	/* memory pointers */
44 	required_shared_ptr_array<uint16_t, 2> m_vram;
45 	required_shared_ptr_array<uint16_t, 2> m_scroll;
46 	required_shared_ptr<uint16_t> m_spriteram;
47 
48 	required_memory_bank m_okibank;
49 	optional_ioport m_pot_wheel_io;
50 	optional_ioport m_opt_wheel_io;
51 
52 	/* video-related */
53 	tilemap_t     *m_tilemap[2];
54 
55 	/* input-related */
56 	uint8_t       m_pot_wheel;    // blmbycar
57 	uint8_t       m_old_val;  // blmbycar
58 	int         m_retvalue; // waterball
59 
60 	// common
61 	void okibank_w(uint8_t data);
62 	template<int Layer> void vram_w(offs_t offset, uint16_t data, uint16_t mem_mask = ~0);
63 
64 	// blmbycar
65 	void blmbycar_pot_wheel_reset_w(uint8_t data);
66 	void blmbycar_pot_wheel_shift_w(uint8_t data);
67 	uint16_t blmbycar_pot_wheel_r();
68 	uint16_t blmbycar_opt_wheel_r();
69 
70 	// waterball
71 	uint16_t waterball_unk_r();
72 
73 	template<int Layer> TILE_GET_INFO_MEMBER(get_tile_info);
74 
75 	virtual void video_start() override;
76 	DECLARE_MACHINE_START(blmbycar);
77 	DECLARE_MACHINE_RESET(blmbycar);
78 	DECLARE_MACHINE_START(watrball);
79 	DECLARE_MACHINE_RESET(watrball);
80 
81 	uint32_t screen_update(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
82 	void draw_sprites( screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect );
83 	void blmbycar_map(address_map &map);
84 	void blmbycar_oki_map(address_map &map);
85 	void common_map(address_map &map);
86 	void watrball_map(address_map &map);
87 };
88