1 // license:BSD-3-Clause
2 // copyright-holders:Sebastien Monassa
3 /*************************************************************************
4 
5     Atari Video Pinball hardware
6 
7 *************************************************************************/
8 #ifndef MAME_INCLUDES_VIDEOPIN_H
9 #define MAME_INCLUDES_VIDEOPIN_H
10 
11 #pragma once
12 
13 #include "sound/discrete.h"
14 #include "emupal.h"
15 #include "screen.h"
16 #include "tilemap.h"
17 
18 /* Discrete Sound Input Nodes */
19 #define VIDEOPIN_OCTAVE_DATA    NODE_01
20 #define VIDEOPIN_NOTE_DATA      NODE_02
21 #define VIDEOPIN_BELL_EN        NODE_03
22 #define VIDEOPIN_BONG_EN        NODE_04
23 #define VIDEOPIN_ATTRACT_EN     NODE_05
24 #define VIDEOPIN_VOL_DATA       NODE_06
25 
26 
27 class videopin_state : public driver_device
28 {
29 public:
videopin_state(const machine_config & mconfig,device_type type,const char * tag)30 	videopin_state(const machine_config &mconfig, device_type type, const char *tag) :
31 		driver_device(mconfig, type, tag),
32 		m_maincpu(*this, "maincpu"),
33 		m_discrete(*this, "discrete"),
34 		m_gfxdecode(*this, "gfxdecode"),
35 		m_screen(*this, "screen"),
36 		m_palette(*this, "palette"),
37 		m_video_ram(*this, "video_ram"),
38 		m_leds(*this, "LED%02u", 1U)
39 	{ }
40 
41 	void videopin(machine_config &config);
42 
43 protected:
44 	virtual void machine_start() override;
45 	virtual void machine_reset() override;
46 	virtual void video_start() override;
47 	virtual void device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr) override;
48 
49 private:
50 	enum
51 	{
52 		TIMER_INTERRUPT
53 	};
54 
55 	uint8_t misc_r();
56 	void led_w(uint8_t data);
57 	void ball_w(uint8_t data);
58 	void video_ram_w(offs_t offset, uint8_t data);
59 	void out1_w(uint8_t data);
60 	void out2_w(uint8_t data);
61 	void note_dvsr_w(uint8_t data);
62 
63 	TILEMAP_MAPPER_MEMBER(get_memory_offset);
64 	TILE_GET_INFO_MEMBER(get_tile_info);
65 
66 	void main_map(address_map &map);
67 
68 	uint32_t screen_update(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
69 
70 	TIMER_CALLBACK_MEMBER(interrupt_callback);
71 	void update_plunger();
72 	double calc_plunger_pos();
73 
74 	required_device<cpu_device> m_maincpu;
75 	required_device<discrete_device> m_discrete;
76 	required_device<gfxdecode_device> m_gfxdecode;
77 	required_device<screen_device> m_screen;
78 	required_device<palette_device> m_palette;
79 
80 	required_shared_ptr<uint8_t> m_video_ram;
81 	output_finder<32> m_leds;
82 
83 	attotime m_time_pushed;
84 	attotime m_time_released;
85 	uint8_t m_prev;
86 	uint8_t m_mask;
87 	int m_ball_x;
88 	int m_ball_y;
89 	tilemap_t* m_bg_tilemap;
90 	emu_timer *m_interrupt_timer;
91 };
92 
93 /*----------- defined in audio/videopin.c -----------*/
94 DISCRETE_SOUND_EXTERN( videopin_discrete );
95 
96 #endif // MAME_INCLUDES_VIDEOPIN_H
97