1 // license:BSD-3-Clause
2 // copyright-holders:Nicola Salmoria
3 /***************************************************************************
4 
5     Time Pilot
6 
7 ***************************************************************************/
8 #ifndef MAME_INCLUDES_TIMEPLT_H
9 #define MAME_INCLUDES_TIMEPLT_H
10 
11 #pragma once
12 
13 #include "machine/74259.h"
14 #include "sound/tc8830f.h"
15 #include "emupal.h"
16 #include "screen.h"
17 #include "tilemap.h"
18 
19 class timeplt_state : public driver_device
20 {
21 public:
timeplt_state(const machine_config & mconfig,device_type type,const char * tag)22 	timeplt_state(const machine_config &mconfig, device_type type, const char *tag) :
23 		driver_device(mconfig, type, tag),
24 		m_maincpu(*this, "maincpu"),
25 		m_tc8830f(*this, "tc8830f"),
26 		m_mainlatch(*this, "mainlatch"),
27 		m_gfxdecode(*this, "gfxdecode"),
28 		m_screen(*this, "screen"),
29 		m_palette(*this, "palette"),
30 		m_colorram(*this, "colorram"),
31 		m_videoram(*this, "videoram"),
32 		m_spriteram(*this, "spriteram"),
33 		m_spriteram2(*this, "spriteram2")
34 	{ }
35 
36 	void timeplt(machine_config &config);
37 	void chkun(machine_config &config);
38 	void psurge(machine_config &config);
39 	void bikkuric(machine_config &config);
40 
41 	DECLARE_READ_LINE_MEMBER(chkun_hopper_status_r);
42 
43 private:
44 	required_device<cpu_device> m_maincpu;
45 	optional_device<tc8830f_device> m_tc8830f;
46 	required_device<ls259_device> m_mainlatch;
47 	required_device<gfxdecode_device> m_gfxdecode;
48 	required_device<screen_device> m_screen;
49 	required_device<palette_device> m_palette;
50 
51 	/* memory pointers */
52 	required_shared_ptr<uint8_t> m_colorram;
53 	required_shared_ptr<uint8_t> m_videoram;
54 	required_shared_ptr<uint8_t> m_spriteram;
55 	required_shared_ptr<uint8_t> m_spriteram2;
56 
57 	/* video-related */
58 	tilemap_t  *m_bg_tilemap;
59 
60 	/* misc */
61 	uint8_t    m_nmi_enable;
62 	bool    m_video_enable;
63 
64 	/* common */
65 	DECLARE_WRITE_LINE_MEMBER(coin_counter_1_w);
66 	DECLARE_WRITE_LINE_MEMBER(coin_counter_2_w);
67 	void videoram_w(offs_t offset, uint8_t data);
68 	void colorram_w(offs_t offset, uint8_t data);
69 	DECLARE_WRITE_LINE_MEMBER(flipscreen_w);
70 	uint8_t scanline_r();
71 
72 	/* all but psurge */
73 	DECLARE_WRITE_LINE_MEMBER(nmi_enable_w);
74 	DECLARE_WRITE_LINE_MEMBER(video_enable_w);
75 
76 	/* psurge */
77 	uint8_t psurge_protection_r();
78 
79 	/* chkun */
80 	void chkun_sound_w(uint8_t data);
81 
82 	TILE_GET_INFO_MEMBER(get_tile_info);
83 	TILE_GET_INFO_MEMBER(get_chkun_tile_info);
84 
85 	virtual void machine_start() override;
86 	virtual void machine_reset() override;
87 	virtual void video_start() override;
88 	void timeplt_palette(palette_device &palette) const;
89 	DECLARE_VIDEO_START(chkun);
90 	DECLARE_VIDEO_START(psurge);
91 
92 	uint32_t screen_update(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
93 	void draw_sprites( bitmap_ind16 &bitmap, const rectangle &cliprect );
94 
95 	DECLARE_WRITE_LINE_MEMBER(vblank_irq);
96 
97 	void chkun_main_map(address_map &map);
98 	void psurge_main_map(address_map &map);
99 	void timeplt_main_map(address_map &map);
100 };
101 
102 #endif // MAME_INCLUDES_TIMEPLT_H
103