1 // license:BSD-3-Clause
2 // copyright-holders:Carlos A. Lozano
3 /*************************************************************************
4 
5     Cops 01
6 
7 *************************************************************************/
8 #ifndef MAME_INCLUDES_COP01_H
9 #define MAME_INCLUDES_COP01_H
10 
11 #pragma once
12 
13 #include "machine/gen_latch.h"
14 #include "machine/nb1412m2.h"
15 #include "emupal.h"
16 #include "tilemap.h"
17 
18 class cop01_state : public driver_device
19 {
20 public:
cop01_state(const machine_config & mconfig,device_type type,const char * tag)21 	cop01_state(const machine_config &mconfig, device_type type, const char *tag) :
22 		driver_device(mconfig, type, tag),
23 		m_bgvideoram(*this, "bgvideoram"),
24 		m_spriteram(*this, "spriteram"),
25 		m_fgvideoram(*this, "fgvideoram"),
26 		m_maincpu(*this, "maincpu"),
27 		m_audiocpu(*this, "audiocpu"),
28 		m_gfxdecode(*this, "gfxdecode"),
29 		m_palette(*this, "palette"),
30 		m_soundlatch(*this, "soundlatch")
31 	{ }
32 
33 	/* memory pointers */
34 	required_shared_ptr<uint8_t> m_bgvideoram;
35 	required_shared_ptr<uint8_t> m_spriteram;
36 	required_shared_ptr<uint8_t> m_fgvideoram;
37 
38 	/* video-related */
39 	tilemap_t        *m_bg_tilemap;
40 	tilemap_t        *m_fg_tilemap;
41 	uint8_t          m_vreg[4];
42 
43 	/* sound-related */
44 	int            m_pulse;
45 	int            m_timer; // kludge for ym3526 in mightguy
46 
47 	/* devices */
48 	required_device<cpu_device> m_maincpu;
49 	required_device<cpu_device> m_audiocpu;
50 	required_device<gfxdecode_device> m_gfxdecode;
51 	required_device<palette_device> m_palette;
52 	required_device<generic_latch_8_device> m_soundlatch;
53 
54 	void cop01_sound_command_w(uint8_t data);
55 	uint8_t cop01_sound_command_r();
56 	void cop01_irq_ack_w(uint8_t data);
57 	uint8_t cop01_sound_irq_ack_w();
58 	void cop01_background_w(offs_t offset, uint8_t data);
59 	void cop01_foreground_w(offs_t offset, uint8_t data);
60 	void cop01_vreg_w(offs_t offset, uint8_t data);
61 	template <int Mask> DECLARE_READ_LINE_MEMBER(mightguy_area_r);
62 	void init_mightguy();
63 	TILE_GET_INFO_MEMBER(get_bg_tile_info);
64 	TILE_GET_INFO_MEMBER(get_fg_tile_info);
65 	virtual void machine_start() override;
66 	virtual void machine_reset() override;
67 	virtual void video_start() override;
68 	void cop01_palette(palette_device &palette) const;
69 	uint32_t screen_update_cop01(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
70 	void draw_sprites( bitmap_ind16 &bitmap, const rectangle &cliprect );
71 	void cop01(machine_config &config);
72 	void audio_io_map(address_map &map);
73 	void cop01_map(address_map &map);
74 	void io_map(address_map &map);
75 	void sound_map(address_map &map);
76 };
77 
78 class mightguy_state : public cop01_state
79 {
80 public:
mightguy_state(const machine_config & mconfig,device_type type,const char * tag)81 	mightguy_state(const machine_config &mconfig, device_type type, const char *tag) :
82 		cop01_state(mconfig, type, tag),
83 		m_prot(*this, "prot_chip")
84 	{ }
85 
86 	void mightguy(machine_config &config);
87 
88 private:
89 	void mightguy_io_map(address_map &map);
90 	void mightguy_audio_io_map(address_map &map);
91 
92 	required_device<nb1412m2_device> m_prot;
93 };
94 
95 #endif // MAME_INCLUDES_COP01_H
96