1 // license:BSD-3-Clause
2 // copyright-holders:David Haywood, Phil Bennett
3 /*************************************************************************
4 
5     Kyuukoukabakugekitai - Dive Bomber Squad
6 
7 *************************************************************************/
8 #ifndef MAME_INCLUDES_DIVEBOMB_H
9 #define MAME_INCLUDES_DIVEBOMB_H
10 
11 #pragma once
12 
13 
14 #include "cpu/z80/z80.h"
15 #include "machine/gen_latch.h"
16 #include "machine/input_merger.h"
17 #include "sound/sn76496.h"
18 #include "video/k051316.h"
19 #include "emupal.h"
20 #include "tilemap.h"
21 
22 #define XTAL1 XTAL(24'000'000)
23 
24 class divebomb_state : public driver_device
25 {
26 public:
divebomb_state(const machine_config & mconfig,device_type type,const char * tag)27 	divebomb_state(const machine_config &mconfig, device_type type, const char *tag)
28 		: driver_device(mconfig, type, tag)
29 		, m_spritecpu(*this, "spritecpu")
30 		, m_fgcpu(*this, "fgcpu")
31 		, m_rozcpu(*this, "rozcpu")
32 		, m_rozbank(*this, "rozbank")
33 		, m_fgram(*this, "fgram")
34 		, m_spriteram(*this, "spriteram")
35 		, m_gfxdecode(*this, "gfxdecode")
36 		, m_palette(*this, "palette")
37 		, m_k051316(*this, "k051316_%u", 1)
38 		, m_fgcpu_irq(*this, "fgcpu_irq")
39 		, m_spr2fg_latch(*this, "spr2fg")
40 		, m_roz2fg_latch(*this, "roz2fg")
41 	{
42 	}
43 
44 	void divebomb(machine_config &config);
45 
46 private:
47 	required_device<cpu_device> m_spritecpu;
48 	required_device<cpu_device> m_fgcpu;
49 	required_device<cpu_device> m_rozcpu;
50 	required_memory_bank m_rozbank;
51 	required_shared_ptr<uint8_t> m_fgram;
52 	required_shared_ptr<uint8_t> m_spriteram;
53 	required_device<gfxdecode_device> m_gfxdecode;
54 	required_device<palette_device> m_palette;
55 	required_device_array<k051316_device, 2> m_k051316;
56 	required_device<input_merger_any_high_device> m_fgcpu_irq;
57 	required_device<generic_latch_8_device> m_spr2fg_latch;
58 	required_device<generic_latch_8_device> m_roz2fg_latch;
59 
60 	tilemap_t *m_fg_tilemap;
61 
62 	uint8_t m_roz_pal;
63 	bool m_roz_enable[2];
64 
65 	DECLARE_MACHINE_RESET(divebomb);
66 	DECLARE_MACHINE_START(divebomb);
67 	DECLARE_VIDEO_START(divebomb);
68 	void divebomb_palette(palette_device &palette) const;
69 
70 	void draw_sprites(bitmap_ind16 &bitmap, const rectangle &cliprect);
71 	static void decode_proms(palette_device &palette, const uint8_t* rgn, int size, int index, bool inv);
72 	uint32_t screen_update_divebomb(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
73 
74 	K051316_CB_MEMBER(zoom_callback_1);
75 	K051316_CB_MEMBER(zoom_callback_2);
76 
77 	TILE_GET_INFO_MEMBER(get_fg_tile_info);
78 
79 	uint8_t fgcpu_comm_flags_r();
80 	void fgram_w(offs_t offset, uint8_t data);
81 
82 	void spritecpu_port00_w(uint8_t data);
83 
84 	void rozcpu_bank_w(uint8_t data);
85 	template<int Chip> void rozcpu_wrap_enable_w(uint8_t data);
86 	template<int Chip> void rozcpu_enable_w(uint8_t data);
87 	void rozcpu_pal_w(uint8_t data);
88 	void divebomb_fgcpu_iomap(address_map &map);
89 	void divebomb_fgcpu_map(address_map &map);
90 	void divebomb_rozcpu_iomap(address_map &map);
91 	void divebomb_rozcpu_map(address_map &map);
92 	void divebomb_spritecpu_iomap(address_map &map);
93 	void divebomb_spritecpu_map(address_map &map);
94 };
95 
96 #endif // MAME_INCLUDES_DIVEBOMB_H
97