1 // license:BSD-3-Clause
2 // copyright-holders:Stefan Jokisch
3 #ifndef MAME_INCLUDES_FGOAL_H
4 #define MAME_INCLUDES_FGOAL_H
5 
6 #pragma once
7 
8 #include "machine/mb14241.h"
9 #include "emupal.h"
10 #include "screen.h"
11 
12 class fgoal_state : public driver_device
13 {
14 public:
fgoal_state(const machine_config & mconfig,device_type type,const char * tag)15 	fgoal_state(const machine_config &mconfig, device_type type, const char *tag) :
16 		driver_device(mconfig, type, tag),
17 		m_maincpu(*this, "maincpu"),
18 		m_mb14241(*this, "mb14241"),
19 		m_gfxdecode(*this, "gfxdecode"),
20 		m_screen(*this, "screen"),
21 		m_palette(*this, "palette"),
22 		m_video_ram(*this, "video_ram")
23 	{ }
24 
25 	void fgoal(machine_config &config);
26 
27 	DECLARE_READ_LINE_MEMBER(_80_r);
28 
29 protected:
30 	enum
31 	{
32 		TIMER_INTERRUPT
33 	};
34 
35 	virtual void machine_start() override;
36 	virtual void machine_reset() override;
37 	virtual void video_start() override;
38 
39 private:
40 	/* devices */
41 	required_device<cpu_device> m_maincpu;
42 	required_device<mb14241_device> m_mb14241;
43 	required_device<gfxdecode_device> m_gfxdecode;
44 	required_device<screen_device> m_screen;
45 	required_device<palette_device> m_palette;
46 
47 	/* memory pointers */
48 	required_shared_ptr<uint8_t> m_video_ram;
49 
50 	/* video-related */
51 	bitmap_ind16   m_bgbitmap;
52 	bitmap_ind16   m_fgbitmap;
53 	uint8_t      m_xpos;
54 	uint8_t      m_ypos;
55 	int        m_current_color;
56 
57 	/* misc */
58 	int        m_player;
59 	uint8_t      m_row;
60 	uint8_t      m_col;
61 	int        m_prev_coin;
62 	emu_timer  *m_interrupt_timer;
63 
64 	uint8_t analog_r();
65 	uint8_t nmi_reset_r();
66 	uint8_t irq_reset_r();
67 	uint8_t row_r();
68 	void row_w(uint8_t data);
69 	void col_w(uint8_t data);
70 	uint8_t address_hi_r();
71 	uint8_t address_lo_r();
72 	uint8_t shifter_r();
73 	uint8_t shifter_reverse_r();
74 	void sound1_w(uint8_t data);
75 	void sound2_w(uint8_t data);
76 	void color_w(uint8_t data);
77 	void ypos_w(uint8_t data);
78 	void xpos_w(uint8_t data);
79 
80 	TIMER_CALLBACK_MEMBER(interrupt_callback);
81 
82 	void fgoal_palette(palette_device &palette) const;
83 
84 	uint32_t screen_update(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
85 	static int intensity(int bits);
86 	unsigned video_ram_address();
87 
88 	void cpu_map(address_map &map);
89 
90 	virtual void device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr) override;
91 };
92 
93 #endif // MAME_INCLUDES_FGOAL_H
94