1 // license:BSD-3-Clause
2 // copyright-holders:Nicola Salmoria
3 /*************************************************************************
4 
5     Universal 8106-A2 + 8106-B PCB set
6 
7 *************************************************************************/
8 #ifndef MAME_INCLUDES_LADYBUG_H
9 #define MAME_INCLUDES_LADYBUG_H
10 
11 #pragma once
12 
13 #include "video/ladybug.h"
14 #include "emupal.h"
15 #include "tilemap.h"
16 
17 
18 class ladybug_base_state : public driver_device
19 {
20 protected:
21 	using driver_device::driver_device;
22 
23 	void palette_init_common(
24 			palette_device &palette, const uint8_t *color_prom,
25 			int r_bit0, int r_bit1,
26 			int g_bit0, int g_bit1,
27 			int b_bit0, int b_bit1) const;
28 };
29 
30 
31 // ladybug platform
32 class ladybug_state : public ladybug_base_state
33 {
34 public:
ladybug_state(const machine_config & mconfig,device_type type,const char * tag)35 	ladybug_state(const machine_config &mconfig, device_type type, const char *tag)
36 		: ladybug_base_state(mconfig, type, tag)
37 		, m_maincpu(*this, "maincpu")
38 		, m_video(*this, "video")
39 		, m_port_dsw0(*this, "DSW0")
40 		, m_p1_control(*this, "CONTP1")
41 		, m_p2_control(*this, "CONTP2")
42 	{ }
43 
44 	DECLARE_CUSTOM_INPUT_MEMBER(ladybug_p1_control_r);
45 	DECLARE_CUSTOM_INPUT_MEMBER(ladybug_p2_control_r);
46 	DECLARE_INPUT_CHANGED_MEMBER(coin1_inserted);
47 	DECLARE_INPUT_CHANGED_MEMBER(coin2_inserted);
48 	void ladybug(machine_config &config);
49 
50 protected:
51 	DECLARE_WRITE_LINE_MEMBER(flipscreen_w);
52 	void ladybug_palette(palette_device &palette) const;
53 	uint32_t screen_update_ladybug(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
54 
55 	void ladybug_map(address_map &map);
56 
57 	required_device<cpu_device> m_maincpu;
58 
59 private:
60 	required_device<ladybug_video_device> m_video;
61 
62 	required_ioport m_port_dsw0;
63 	optional_ioport m_p1_control;
64 	optional_ioport m_p2_control;
65 };
66 
67 
68 // ladybug plus program decryption
69 class dorodon_state : public ladybug_state
70 {
71 public:
dorodon_state(const machine_config & mconfig,device_type type,const char * tag)72 	dorodon_state(const machine_config &mconfig, device_type type, const char *tag)
73 		: ladybug_state(mconfig, type, tag)
74 		, m_decrypted_opcodes(*this, "decrypted_opcodes")
75 	{ }
76 
77 	void init_dorodon();
78 	void dorodon(machine_config &config);
79 
80 protected:
81 	void decrypted_opcodes_map(address_map &map);
82 
83 private:
84 	required_shared_ptr<uint8_t> m_decrypted_opcodes;
85 };
86 
87 
88 // graphics from ladybug, stars from zerohour, plus grid layer
89 class sraider_state : public ladybug_base_state
90 {
91 public:
sraider_state(const machine_config & mconfig,device_type type,const char * tag)92 	sraider_state(const machine_config &mconfig, device_type type, const char *tag)
93 		: ladybug_base_state(mconfig, type, tag)
94 		, m_grid_data(*this, "grid_data")
95 		, m_palette(*this, "palette")
96 		, m_gfxdecode(*this, "gfxdecode")
97 		, m_video(*this, "video")
98 		, m_stars(*this, "stars")
99 	{ }
100 
101 	void sraider(machine_config &config);
102 
103 protected:
104 	uint8_t sraider_8005_r();
105 	void sraider_misc_w(offs_t offset, uint8_t data);
106 	void sraider_io_w(uint8_t data);
107 	void sraider_palette(palette_device &palette) const;
108 	DECLARE_WRITE_LINE_MEMBER(screen_vblank_sraider);
109 	TILE_GET_INFO_MEMBER(get_grid_tile_info);
110 
111 	virtual void machine_start() override;
112 	virtual void machine_reset() override;
113 	virtual void video_start() override;
114 	uint32_t screen_update_sraider(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
115 
116 	void sraider_cpu1_map(address_map &map);
117 	void sraider_cpu2_io_map(address_map &map);
118 	void sraider_cpu2_map(address_map &map);
119 
120 private:
121 	required_shared_ptr<uint8_t> m_grid_data;
122 	required_device<palette_device> m_palette;
123 	required_device<gfxdecode_device> m_gfxdecode;
124 	required_device<ladybug_video_device> m_video;
125 	required_device<zerohour_stars_device> m_stars;
126 
127 	tilemap_t   *m_grid_tilemap;
128 
129 	uint8_t m_grid_color;
130 	uint8_t m_sraider_0x30;
131 	uint8_t m_sraider_0x38;
132 	uint8_t m_weird_value[8];
133 };
134 
135 #endif // MAME_INCLUDES_LADYBUG_H
136