1 // license:BSD-3-Clause
2 // copyright-holders:Aaron Giles, Bryan McPhail
3 /***************************************************************************
4 
5     Midway MCR-68k system
6 
7 ***************************************************************************/
8 #ifndef MAME_INCLUDES_MCR68_H
9 #define MAME_INCLUDES_MCR68_H
10 
11 #pragma once
12 
13 #include "machine/timer.h"
14 #include "machine/watchdog.h"
15 #include "audio/midway.h"
16 #include "audio/s11c_bg.h"
17 #include "machine/6840ptm.h"
18 #include "machine/adc0844.h"
19 #include "screen.h"
20 #include "tilemap.h"
21 
22 class mcr68_state : public driver_device
23 {
24 public:
mcr68_state(const machine_config & mconfig,device_type type,const char * tag)25 	mcr68_state(const machine_config &mconfig, device_type type, const char *tag) :
26 		driver_device(mconfig, type, tag),
27 		m_sounds_good(*this, "sg"),
28 		m_turbo_cheap_squeak(*this, "tcs"),
29 		m_bg(*this, "bg"),
30 		m_adc(*this, "adc"),
31 		m_videoram(*this, "videoram"),
32 		m_spriteram(*this, "spriteram") ,
33 		m_maincpu(*this, "maincpu"),
34 		m_gfxdecode(*this, "gfxdecode"),
35 		m_screen(*this, "screen"),
36 		m_ptm(*this, "ptm")
37 	{ }
38 
39 	void mcr68(machine_config &config);
40 	void intlaser(machine_config &config);
41 	void xenophob(machine_config &config);
42 	void spyhunt2(machine_config &config);
43 	void trisport(machine_config &config);
44 	void pigskin(machine_config &config);
45 	void archrivl(machine_config &config);
46 
47 	void init_intlaser();
48 	void init_pigskin();
49 	void init_blasted();
50 	void init_trisport();
51 	void init_xenophob();
52 	void init_archrivl();
53 	void init_spyhunt2();
54 	void init_archrivlb();
55 
56 private:
57 	optional_device<midway_sounds_good_device> m_sounds_good;
58 	optional_device<midway_turbo_cheap_squeak_device> m_turbo_cheap_squeak;
59 	optional_device<s11c_bg_device> m_bg;
60 	optional_device<adc0844_device> m_adc;
61 
62 	required_shared_ptr<uint16_t> m_videoram;
63 	required_shared_ptr<uint16_t> m_spriteram;
64 	uint16_t m_control_word;
65 	uint8_t m_protection_data[5];
66 	attotime m_timing_factor;
67 	uint8_t m_sprite_clip;
68 	int8_t m_sprite_xoffset;
69 	timer_expired_delegate m_v493_callback;
70 	tilemap_t *m_bg_tilemap;
71 	tilemap_t *m_fg_tilemap;
72 	void xenophobe_control_w(offs_t offset, uint16_t data, uint16_t mem_mask = ~0);
73 	void blasted_control_w(offs_t offset, uint16_t data, uint16_t mem_mask = ~0);
74 	uint16_t spyhunt2_port_0_r();
75 	uint16_t spyhunt2_port_1_r();
76 	void spyhunt2_control_w(offs_t offset, uint16_t data, uint16_t mem_mask = ~0);
77 	uint16_t archrivl_port_1_r();
78 	void archrivl_control_w(offs_t offset, uint16_t data, uint16_t mem_mask = ~0);
79 	void pigskin_protection_w(offs_t offset, uint16_t data, uint16_t mem_mask = ~0);
80 	uint16_t pigskin_protection_r();
81 	uint16_t pigskin_port_1_r();
82 	uint16_t pigskin_port_2_r();
83 	uint16_t trisport_port_1_r();
84 	void mcr68_videoram_w(offs_t offset, uint16_t data, uint16_t mem_mask = ~0);
85 
86 	uint16_t archrivlb_port_1_r();
87 	TILE_GET_INFO_MEMBER(get_bg_tile_info);
88 	DECLARE_MACHINE_START(mcr68);
89 	DECLARE_MACHINE_RESET(mcr68);
90 	DECLARE_VIDEO_START(mcr68);
91 	uint32_t screen_update_mcr68(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
92 	TIMER_DEVICE_CALLBACK_MEMBER(scanline_cb);
93 	TIMER_CALLBACK_MEMBER(mcr68_493_off_callback);
94 	TIMER_CALLBACK_MEMBER(mcr68_493_callback);
95 	void mcr68_update_sprites(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect, int priority);
96 	void mcr68_common_init(int clip, int xoffset);
97 	required_device<cpu_device> m_maincpu;
98 	required_device<gfxdecode_device> m_gfxdecode;
99 	required_device<screen_device> m_screen;
100 	std::unique_ptr<uint8_t[]> m_srcdata0;
101 	std::unique_ptr<uint8_t[]> m_srcdata2;
102 
103 	void mcr68_map(address_map &map);
104 	void pigskin_map(address_map &map);
105 	void trisport_map(address_map &map);
106 
107 	required_device<ptm6840_device> m_ptm;
108 };
109 
110 #endif // MAME_INCLUDES_MCR68_H
111