1 // license:BSD-3-Clause
2 // copyright-holders:Nicola Salmoria
3 /*************************************************************************
4 
5   Sega KO Punch
6 
7 *************************************************************************/
8 #ifndef MAME_INCLUDES_KOPUNCH_H
9 #define MAME_INCLUDES_KOPUNCH_H
10 
11 #pragma once
12 
13 #include "emupal.h"
14 #include "tilemap.h"
15 
16 class kopunch_state : public driver_device
17 {
18 public:
kopunch_state(const machine_config & mconfig,device_type type,const char * tag)19 	kopunch_state(const machine_config &mconfig, device_type type, const char *tag)
20 		: driver_device(mconfig, type, tag)
21 		, m_maincpu(*this, "maincpu")
22 		, m_gfxdecode(*this, "gfxdecode")
23 		, m_vram_fg(*this, "vram_fg")
24 		, m_vram_bg(*this, "vram_bg")
25 		, m_lamp(*this, "lamp0")
26 	{ }
27 
28 	void kopunch(machine_config &config);
29 
30 	DECLARE_INPUT_CHANGED_MEMBER(left_coin_inserted);
31 	DECLARE_INPUT_CHANGED_MEMBER(right_coin_inserted);
32 
33 private:
34 	uint8_t sensors1_r();
35 	uint8_t sensors2_r();
36 	void lamp_w(uint8_t data);
37 	void coin_w(uint8_t data);
38 	void vram_fg_w(offs_t offset, uint8_t data);
39 	void vram_bg_w(offs_t offset, uint8_t data);
40 	void scroll_x_w(uint8_t data);
41 	void scroll_y_w(uint8_t data);
42 	void gfxbank_w(uint8_t data);
43 
44 	INTERRUPT_GEN_MEMBER(vblank_interrupt);
45 
46 	TILE_GET_INFO_MEMBER(get_fg_tile_info);
47 	TILE_GET_INFO_MEMBER(get_bg_tile_info);
48 	void kopunch_palette(palette_device &palette) const;
49 	uint32_t screen_update_kopunch(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
50 
51 	void kopunch_io_map(address_map &map);
52 	void kopunch_map(address_map &map);
53 
54 	virtual void machine_start() override;
55 	virtual void video_start() override;
56 
57 	/* devices */
58 	required_device<cpu_device> m_maincpu;
59 	required_device<gfxdecode_device> m_gfxdecode;
60 
61 	/* memory pointers */
62 	required_shared_ptr<uint8_t> m_vram_fg;
63 	required_shared_ptr<uint8_t> m_vram_bg;
64 
65 	output_finder<> m_lamp;
66 
67 	/* video-related */
68 	tilemap_t *m_bg_tilemap;
69 	tilemap_t *m_fg_tilemap;
70 	uint8_t m_gfxbank;
71 	uint8_t m_scrollx;
72 };
73 
74 #endif // MAME_INCLUDES_KOPUNCH_H
75