1 // license:BSD-3-Clause
2 // copyright-holders:David Haywood
3 #ifndef MAME_INCLUDES_WELLTRIS_H
4 #define MAME_INCLUDES_WELLTRIS_H
5 
6 #pragma once
7 
8 #include "machine/gen_latch.h"
9 #include "video/vsystem_spr2.h"
10 #include "screen.h"
11 #include "tilemap.h"
12 
13 class welltris_state : public driver_device
14 {
15 public:
welltris_state(const machine_config & mconfig,device_type type,const char * tag)16 	welltris_state(const machine_config &mconfig, device_type type, const char *tag) :
17 		driver_device(mconfig, type, tag),
18 		m_maincpu(*this, "maincpu"),
19 		m_audiocpu(*this, "audiocpu"),
20 		m_spr_old(*this, "vsystem_spr_old"),
21 		m_gfxdecode(*this, "gfxdecode"),
22 		m_screen(*this, "screen"),
23 		m_soundlatch(*this, "soundlatch"),
24 		m_spriteram(*this, "spriteram"),
25 		m_pixelram(*this, "pixelram"),
26 		m_charvideoram(*this, "charvideoram")
27 	{ }
28 
29 	void quiz18k(machine_config &config);
30 	void welltris(machine_config &config);
31 
32 	void init_quiz18k();
33 	void init_welltris();
34 
35 protected:
36 	virtual void machine_start() override;
37 	virtual void video_start() override;
38 
39 private:
40 	required_device<cpu_device> m_maincpu;
41 	required_device<cpu_device> m_audiocpu;
42 	required_device<vsystem_spr2_device> m_spr_old;
43 	required_device<gfxdecode_device> m_gfxdecode;
44 	required_device<screen_device> m_screen;
45 	required_device<generic_latch_8_device> m_soundlatch;
46 
47 	required_shared_ptr<uint16_t> m_spriteram;
48 	required_shared_ptr<uint16_t> m_pixelram;
49 	required_shared_ptr<uint16_t> m_charvideoram;
50 
51 	tilemap_t *m_char_tilemap;
52 	uint8_t m_gfxbank[2];
53 	uint16_t m_charpalettebank;
54 	uint16_t m_spritepalettebank;
55 	uint16_t m_pixelpalettebank;
56 	int m_scrollx;
57 	int m_scrolly;
58 
59 	void sound_bankswitch_w(uint8_t data);
60 	void palette_bank_w(offs_t offset, uint16_t data, uint16_t mem_mask = ~0);
61 	void gfxbank_w(offs_t offset, uint16_t data, uint16_t mem_mask = ~0);
62 	void scrollreg_w(offs_t offset, uint16_t data);
63 	void charvideoram_w(offs_t offset, uint16_t data, uint16_t mem_mask = ~0);
64 
65 	TILE_GET_INFO_MEMBER(get_tile_info);
66 	uint32_t screen_update(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
67 	void draw_background(bitmap_ind16 &bitmap, const rectangle &cliprect);
68 	void setbank(int num, int bank);
69 	void main_map(address_map &map);
70 	void sound_map(address_map &map);
71 	void sound_port_map(address_map &map);
72 };
73 
74 #endif // MAME_INCLUDES_WELLTRIS_H
75