1 // license:BSD-3-Clause
2 // copyright-holders:David Graves
3 /*************************************************************************
4 
5     Slapshot / Operation Wolf 3
6 
7 *************************************************************************/
8 #ifndef MAME_INCLUDES_SLAPSHOT_H
9 #define MAME_INCLUDES_SLAPSHOT_H
10 
11 #pragma once
12 
13 #include "audio/taitosnd.h"
14 #include "machine/taitoio.h"
15 #include "video/tc0360pri.h"
16 #include "video/tc0480scp.h"
17 #include "emupal.h"
18 
19 class slapshot_state : public driver_device
20 {
21 public:
slapshot_state(const machine_config & mconfig,device_type type,const char * tag)22 	slapshot_state(const machine_config &mconfig, device_type type, const char *tag) :
23 		driver_device(mconfig, type, tag),
24 		m_maincpu(*this, "maincpu"),
25 		m_tc0140syt(*this, "tc0140syt"),
26 		m_tc0480scp(*this, "tc0480scp"),
27 		m_tc0360pri(*this, "tc0360pri"),
28 		m_tc0640fio(*this, "tc0640fio"),
29 		m_gfxdecode(*this, "gfxdecode"),
30 		m_palette(*this, "palette"),
31 		m_spriteram(*this,"spriteram"),
32 		m_spriteext(*this,"spriteext"),
33 		m_z80bank(*this,"z80bank"),
34 		m_io_system(*this,"SYSTEM"),
35 		m_io_service(*this,"SERVICE")
36 	{ }
37 
38 	void opwolf3(machine_config &config);
39 	void slapshot(machine_config &config);
40 
41 	void driver_init() override;
42 
43 protected:
44 	enum
45 	{
46 		TIMER_SLAPSHOT_INTERRUPT6
47 	};
48 
49 	virtual void machine_start() override;
50 	virtual void video_start() override;
51 	virtual void device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr) override;
52 
53 private:
54 	struct slapshot_tempsprite
55 	{
56 		u8 gfx;
57 		u32 code,color;
58 		bool flipx,flipy;
59 		int x,y;
60 		int zoomx,zoomy;
61 		u32 primask;
62 	};
63 
64 	/* devices */
65 	required_device<cpu_device> m_maincpu;
66 	required_device<tc0140syt_device> m_tc0140syt;
67 	required_device<tc0480scp_device> m_tc0480scp;
68 	required_device<tc0360pri_device> m_tc0360pri;
69 	required_device<tc0640fio_device> m_tc0640fio;
70 	required_device<gfxdecode_device> m_gfxdecode;
71 	required_device<palette_device> m_palette;
72 
73 	/* memory pointers */
74 	required_shared_ptr<u16> m_spriteram;
75 	required_shared_ptr<u16> m_spriteext;
76 	std::unique_ptr<u16[]>   m_spriteram_buffered;
77 	std::unique_ptr<u16[]>   m_spriteram_delayed;
78 
79 	required_memory_bank m_z80bank;
80 	optional_ioport m_io_system;
81 	optional_ioport m_io_service;
82 
83 	/* video-related */
84 	std::unique_ptr<slapshot_tempsprite[]> m_spritelist;
85 	bool      m_sprites_disabled;
86 	s32       m_sprites_active_area;
87 	s32       m_sprites_master_scrollx;
88 	s32       m_sprites_master_scrolly;
89 	bool      m_sprites_flipscreen;
90 	bool      m_prepare_sprites;
91 	int       m_dislayer[5];
92 
93 	emu_timer *m_int6_timer;
94 
95 	// generic
96 	u16 service_input_r(offs_t offset);
97 	void sound_bankswitch_w(u8 data);
98 	void coin_control_w(u8 data);
99 
100 	u32 screen_update(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
101 	DECLARE_WRITE_LINE_MEMBER(screen_vblank_no_buffer);
102 	void draw_sprites(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect, u32 *primasks, int y_offset);
103 	void handle_sprite_buffering();
104 	void update_sprites_active_area();
105 
106 	INTERRUPT_GEN_MEMBER(interrupt);
107 
108 	void opwolf3_map(address_map &map);
109 	void slapshot_map(address_map &map);
110 	void sound_map(address_map &map);
111 };
112 
113 #endif // MAME_INCLUDES_SLAPSHOT_H
114