1 // license:BSD-3-Clause
2 // copyright-holders:Bryan McPhail, David Graves
3 #ifndef MAME_INCLUDES_UNDRFIRE_H
4 #define MAME_INCLUDES_UNDRFIRE_H
5 
6 #pragma once
7 
8 #include "machine/eepromser.h"
9 #include "video/tc0100scn.h"
10 #include "video/tc0480scp.h"
11 #include "emupal.h"
12 
13 class undrfire_state : public driver_device
14 {
15 public:
undrfire_state(const machine_config & mconfig,device_type type,const char * tag)16 	undrfire_state(const machine_config &mconfig, device_type type, const char *tag) :
17 		driver_device(mconfig, type, tag),
18 		m_maincpu(*this, "maincpu"),
19 		m_subcpu(*this, "sub"),
20 		m_tc0620scc(*this, "tc0620scc"),
21 		m_tc0480scp(*this, "tc0480scp"),
22 		m_eeprom(*this, "eeprom"),
23 		m_ram(*this, "ram"),
24 		m_shared_ram(*this, "shared_ram"),
25 		m_spriteram(*this, "spriteram"),
26 		m_gfxdecode(*this, "gfxdecode"),
27 		m_palette(*this, "palette"),
28 		m_spritemap(*this, "spritemap"),
29 		m_spritemaphi(*this, "spritemaphi"),
30 		m_in_gunx(*this, "GUNX%u", 1U),
31 		m_in_guny(*this, "GUNY%u", 1U),
32 		m_io_fake(*this, "FAKE")
33 	{ }
34 
35 	void undrfire(machine_config &config);
36 	void cbombers(machine_config &config);
37 
38 protected:
39 	enum
40 	{
41 		TIMER_INTERRUPT5
42 	};
43 
44 	virtual void video_start() override;
45 
46 private:
47 	struct uf_tempsprite
48 	{
49 		u8 gfx;
50 		u32 code,color;
51 		bool flipx,flipy;
52 		int x,y;
53 		int zoomx,zoomy;
54 		u32 primask;
55 	};
56 
57 	required_device<cpu_device> m_maincpu;
58 	optional_device<cpu_device> m_subcpu;
59 	required_device<tc0620scc_device> m_tc0620scc;
60 	required_device<tc0480scp_device> m_tc0480scp;
61 	required_device<eeprom_serial_93cxx_device> m_eeprom;
62 	optional_shared_ptr<u32> m_ram;
63 	optional_shared_ptr<u16> m_shared_ram;
64 	u16 m_port_sel;
65 	int m_frame_counter;
66 	std::unique_ptr<uf_tempsprite[]> m_spritelist;
67 	u16 m_rotate_ctrl[8];
68 	u8 m_dislayer[6];
69 	required_shared_ptr<u32> m_spriteram;
70 	required_device<gfxdecode_device> m_gfxdecode;
71 	required_device<palette_device> m_palette;
72 
73 	required_region_ptr<u16> m_spritemap;
74 	optional_region_ptr<u8> m_spritemaphi;
75 
76 	optional_ioport_array<2> m_in_gunx;
77 	optional_ioport_array<2> m_in_guny;
78 	optional_ioport m_io_fake;
79 
80 	void coin_word_w(u8 data);
81 	u16 shared_ram_r(offs_t offset);
82 	void shared_ram_w(offs_t offset, u16 data, u16 mem_mask = ~0);
83 	u32 undrfire_lightgun_r(offs_t offset);
84 	void rotate_control_w(offs_t offset, u16 data);
85 	void motor_control_w(u8 data);
86 	void cbombers_cpua_ctrl_w(u32 data);
87 	DECLARE_READ_LINE_MEMBER(frame_counter_r);
88 	u32 screen_update_undrfire(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
89 	u32 screen_update_cbombers(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
90 	INTERRUPT_GEN_MEMBER(undrfire_interrupt);
91 	void draw_sprites(screen_device &screen, bitmap_ind16 &bitmap,const rectangle &cliprect,const u32 *primasks,int x_offs,int y_offs);
92 	void draw_sprites_cbombers(screen_device &screen, bitmap_ind16 &bitmap,const rectangle &cliprect,const u32 *primasks,int x_offs,int y_offs);
93 
94 	void cbombers_cpua_map(address_map &map);
95 	void cbombers_cpub_map(address_map &map);
96 	void undrfire_map(address_map &map);
97 };
98 
99 #endif // MAME_INCLUDES_UNDRFIRE_H
100