1 // license:BSD-3-Clause
2 // copyright-holders:David Haywood, R. Belmont, Pierpaolo Prazzoli
3 /*************************************************************************
4 
5     Dragon Ball Z
6 
7 *************************************************************************/
8 #ifndef MAME_INCLUDES_DBZ_H
9 #define MAME_INCLUDES_DBZ_H
10 
11 #pragma once
12 
13 #include "machine/gen_latch.h"
14 #include "machine/k053252.h"
15 #include "machine/timer.h"
16 #include "video/k054156_k054157_k056832.h"
17 #include "video/k053246_k053247_k055673.h"
18 #include "video/k053936.h"
19 #include "video/k053251.h"
20 #include "video/konami_helper.h"
21 #include "tilemap.h"
22 
23 class dbz_state : public driver_device
24 {
25 public:
dbz_state(const machine_config & mconfig,device_type type,const char * tag)26 	dbz_state(const machine_config &mconfig, device_type type, const char *tag) :
27 		driver_device(mconfig, type, tag),
28 		m_bg1_videoram(*this, "bg1_videoram"),
29 		m_bg2_videoram(*this, "bg2_videoram"),
30 		m_maincpu(*this, "maincpu"),
31 		m_audiocpu(*this, "audiocpu"),
32 		m_k053246(*this, "k053246"),
33 		m_k053251(*this, "k053251"),
34 		m_k053252(*this, "k053252"),
35 		m_k056832(*this, "k056832"),
36 		m_k053936_1(*this, "k053936_1"),
37 		m_k053936_2(*this, "k053936_2"),
38 		m_gfxdecode(*this, "gfxdecode"),
39 		m_soundlatch(*this, "soundlatch"),
40 		m_dsw2(*this, "DSW2")
41 	{ }
42 
43 	void dbz(machine_config &config);
44 
45 	void init_dbza();
46 	void init_dbz();
47 	void init_dbz2();
48 
49 private:
50 	/* memory pointers */
51 	required_shared_ptr<uint16_t> m_bg1_videoram;
52 	required_shared_ptr<uint16_t> m_bg2_videoram;
53 
54 	/* video-related */
55 	tilemap_t    *m_bg1_tilemap;
56 	tilemap_t    *m_bg2_tilemap;
57 	int          m_layer_colorbase[6];
58 	int          m_layerpri[5];
59 	int          m_sprite_colorbase;
60 
61 	/* misc */
62 	int           m_control;
63 
64 	/* devices */
65 	required_device<cpu_device> m_maincpu;
66 	required_device<cpu_device> m_audiocpu;
67 	required_device<k053247_device> m_k053246;
68 	required_device<k053251_device> m_k053251;
69 	required_device<k053252_device> m_k053252;
70 	required_device<k056832_device> m_k056832;
71 	required_device<k053936_device> m_k053936_1;
72 	required_device<k053936_device> m_k053936_2;
73 	required_device<gfxdecode_device> m_gfxdecode;
74 	required_device<generic_latch_8_device> m_soundlatch;
75 
76 	required_ioport m_dsw2;
77 
78 	void dbzcontrol_w(offs_t offset, uint16_t data, uint16_t mem_mask = ~0);
79 	void dbz_sound_command_w(uint16_t data);
80 	void dbz_sound_cause_nmi(uint16_t data);
81 	void dbz_bg2_videoram_w(offs_t offset, uint16_t data, uint16_t mem_mask = ~0);
82 	void dbz_bg1_videoram_w(offs_t offset, uint16_t data, uint16_t mem_mask = ~0);
83 	DECLARE_WRITE_LINE_MEMBER(dbz_irq2_ack_w);
84 	TILE_GET_INFO_MEMBER(get_dbz_bg2_tile_info);
85 	TILE_GET_INFO_MEMBER(get_dbz_bg1_tile_info);
86 	virtual void machine_start() override;
87 	virtual void machine_reset() override;
88 	virtual void video_start() override;
89 	uint32_t screen_update_dbz(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
90 	TIMER_DEVICE_CALLBACK_MEMBER(dbz_scanline);
91 	K056832_CB_MEMBER(tile_callback);
92 	K053246_CB_MEMBER(sprite_callback);
93 	void dbz_map(address_map &map);
94 	void dbz_sound_io_map(address_map &map);
95 	void dbz_sound_map(address_map &map);
96 };
97 
98 #endif // MAME_INCLUDES_DBZ_H
99