1 // license:BSD-3-Clause
2 // copyright-holders:Luca Elia
3 #ifndef MAME_INCLUDES_UNICO_H
4 #define MAME_INCLUDES_UNICO_H
5 
6 #pragma once
7 
8 #include "sound/okim6295.h"
9 #include "machine/eepromser.h"
10 #include "emupal.h"
11 #include "screen.h"
12 #include "tilemap.h"
13 
14 class unico_state : public driver_device
15 {
16 public:
unico_state(const machine_config & mconfig,device_type type,const char * tag)17 	unico_state(const machine_config &mconfig, device_type type, const char *tag) :
18 		driver_device(mconfig, type, tag),
19 		m_maincpu(*this, "maincpu"),
20 		m_palette(*this, "palette"),
21 		m_gfxdecode(*this, "gfxdecode"),
22 		m_oki(*this, "oki"),
23 		m_leds(*this, "led%u", 0U),
24 		m_vram(*this, "vram", 0),
25 		m_scroll(*this, "scroll", 0),
26 		m_spriteram(*this, "spriteram", 0)
27 	{ }
28 
29 	void burglarx(machine_config &config);
30 
31 protected:
32 	static rgb_t unico_R6G6B6X(uint32_t raw);
33 	uint16_t vram_r(offs_t offset);
34 	void vram_w(offs_t offset, uint16_t data, uint16_t mem_mask = ~0);
35 	uint16_t scroll_r(offs_t offset);
36 	void scroll_w(offs_t offset, uint16_t data, uint16_t mem_mask = ~0);
37 	uint16_t spriteram_r(offs_t offset);
38 	void spriteram_w(offs_t offset, uint16_t data, uint16_t mem_mask = ~0);
39 
40 	void burglarx_okibank_w(uint8_t data);
41 	TILE_GET_INFO_MEMBER(get_tile_info);
42 	virtual void machine_start() override;
43 	virtual void video_start() override;
44 	uint32_t screen_update(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
45 	void draw_sprites(screen_device &screen, bitmap_ind16 &bitmap,const rectangle &cliprect);
46 
47 	void burglarx_map(address_map &map);
48 
49 	required_device<cpu_device> m_maincpu;
50 	required_device<palette_device> m_palette;
51 	required_device<gfxdecode_device> m_gfxdecode;
52 	optional_device<okim6295_device> m_oki;
53 	output_finder<2> m_leds;
54 
55 private:
56 	required_shared_ptr<uint16_t> m_vram;
57 	required_shared_ptr<uint16_t> m_scroll;
58 	tilemap_t *m_tilemap[3];
59 	int m_sprites_scrolldx;
60 	int m_sprites_scrolldy;
61 	required_shared_ptr<uint16_t> m_spriteram;
62 };
63 
64 class zeropnt_state : public unico_state
65 {
66 public:
zeropnt_state(const machine_config & mconfig,device_type type,const char * tag)67 	zeropnt_state(const machine_config &mconfig, device_type type, const char *tag) :
68 		unico_state(mconfig, type, tag),
69 		m_okibank(*this, "okibank"),
70 		m_screen(*this, "screen"),
71 		m_gun_axes(*this, { "Y0", "X0", "Y1", "X1" })
72 	{ }
73 
74 	void zeropnt(machine_config &config);
75 
76 protected:
77 	virtual void machine_start() override;
78 
79 	void zeropnt_okibank_leds_w(uint8_t data);
80 	uint16_t gunx_0_msb_r();
81 	uint16_t guny_0_msb_r();
82 	uint16_t gunx_1_msb_r();
83 	uint16_t guny_1_msb_r();
84 
85 	required_memory_bank m_okibank;
86 
87 	required_device<screen_device> m_screen;
88 
89 	void zeropnt_map(address_map &map);
90 	void zeropnt_oki_map(address_map &map);
91 
92 private:
93 	enum { Y0, X0, Y1, X1 }; // gun axis indices
94 
95 	required_ioport_array<4> m_gun_axes;
96 };
97 
98 class zeropnt2_state : public zeropnt_state
99 {
100 public:
zeropnt2_state(const machine_config & mconfig,device_type type,const char * tag)101 	zeropnt2_state(const machine_config &mconfig, device_type type, const char *tag) :
102 		zeropnt_state(mconfig, type, tag),
103 		m_eeprom(*this, "eeprom")
104 	{ }
105 
106 	void zeropnt2(machine_config &config);
107 
108 protected:
109 	virtual void machine_start() override;
110 
111 	uint32_t zeropnt2_gunx_0_msb_r();
112 	uint32_t zeropnt2_guny_0_msb_r();
113 	uint32_t zeropnt2_gunx_1_msb_r();
114 	uint32_t zeropnt2_guny_1_msb_r();
115 	void zeropnt2_okibank(uint8_t data);
116 	void leds_w(uint8_t data);
117 
118 	void eeprom_w(offs_t offset, uint32_t data, uint32_t mem_mask = ~0);
119 
120 	void zeropnt2_map(address_map &map);
121 
122 private:
123 	required_device<eeprom_serial_93cxx_device> m_eeprom;
124 };
125 
126 #endif // MAME_INCLUDES_UNICO_H
127