1 // license:BSD-3-Clause
2 // copyright-holders:Tomasz Slanina, Pierpaolo Prazzoli
3 #ifndef MAME_INCLUDES_PITNRUN_H
4 #define MAME_INCLUDES_PITNRUN_H
5 
6 #pragma once
7 
8 #include "cpu/m6805/m68705.h"
9 #include "emupal.h"
10 #include "tilemap.h"
11 
12 class pitnrun_state : public driver_device
13 {
14 public:
pitnrun_state(const machine_config & mconfig,device_type type,const char * tag)15 	pitnrun_state(const machine_config &mconfig, device_type type, const char *tag) :
16 		driver_device(mconfig, type, tag),
17 		m_maincpu(*this, "maincpu"),
18 		m_mcu(*this, "mcu"),
19 		m_gfxdecode(*this, "gfxdecode"),
20 		m_palette(*this, "palette"),
21 		m_videoram(*this, "videoram"),
22 		m_videoram2(*this, "videoram2"),
23 		m_spriteram(*this, "spriteram")
24 	{ }
25 
26 	void pitnrun_mcu(machine_config &config);
27 	void pitnrun(machine_config &config);
28 
29 protected:
30 	virtual void machine_start() override;
31 	virtual void machine_reset() override;
32 	virtual void video_start() override;
33 
34 private:
35 	required_device<cpu_device> m_maincpu;
36 	optional_device<m68705p5_device> m_mcu;
37 	required_device<gfxdecode_device> m_gfxdecode;
38 	required_device<palette_device> m_palette;
39 
40 	required_shared_ptr<uint8_t> m_videoram;
41 	required_shared_ptr<uint8_t> m_videoram2;
42 	required_shared_ptr<uint8_t> m_spriteram;
43 
44 	int m_nmi;
45 	uint8_t m_fromz80;
46 	uint8_t m_toz80;
47 	int m_zaccept;
48 	int m_zready;
49 	uint8_t m_porta_in;
50 	uint8_t m_porta_out;
51 	int m_address;
52 	int m_h_heed;
53 	int m_v_heed;
54 	int m_ha;
55 	int m_scroll;
56 	int m_char_bank;
57 	int m_color_select;
58 	std::unique_ptr<bitmap_ind16> m_tmp_bitmap[4];
59 	tilemap_t *m_bg;
60 	tilemap_t *m_fg;
61 
62 	DECLARE_WRITE_LINE_MEMBER(nmi_enable_w);
63 	DECLARE_WRITE_LINE_MEMBER(hflip_w);
64 	DECLARE_WRITE_LINE_MEMBER(vflip_w);
65 	uint8_t mcu_data_r();
66 	void mcu_data_w(uint8_t data);
67 	uint8_t mcu_status_r();
68 	uint8_t m68705_porta_r();
69 	void m68705_porta_w(uint8_t data);
70 	uint8_t m68705_portb_r();
71 	void m68705_portb_w(uint8_t data);
72 	uint8_t m68705_portc_r();
73 	void videoram_w(offs_t offset, uint8_t data);
74 	void videoram2_w(offs_t offset, uint8_t data);
75 	DECLARE_WRITE_LINE_MEMBER(char_bank_select_w);
76 	void scroll_w(offs_t offset, uint8_t data);
77 	void scroll_y_w(uint8_t data);
78 	void ha_w(uint8_t data);
79 	void h_heed_w(uint8_t data);
80 	void v_heed_w(uint8_t data);
81 	DECLARE_WRITE_LINE_MEMBER(color_select_w);
82 
83 	TILE_GET_INFO_MEMBER(get_tile_info1);
84 	TILE_GET_INFO_MEMBER(get_tile_info2);
85 
86 	INTERRUPT_GEN_MEMBER(nmi_source);
87 	TIMER_CALLBACK_MEMBER(mcu_real_data_r);
88 	TIMER_CALLBACK_MEMBER(mcu_real_data_w);
89 	TIMER_CALLBACK_MEMBER(mcu_data_real_r);
90 	TIMER_CALLBACK_MEMBER(mcu_status_real_w);
91 
92 	void pitnrun_palette(palette_device &palette) const;
93 
94 	uint32_t screen_update(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
95 	void spotlights();
96 	void draw_sprites(bitmap_ind16 &bitmap, const rectangle &cliprect );
97 	void pitnrun_map(address_map &map);
98 	void pitnrun_map_mcu(address_map &map);
99 	void pitnrun_sound_io_map(address_map &map);
100 	void pitnrun_sound_map(address_map &map);
101 };
102 
103 #endif // MAME_INCLUDES_PITNRUN_H
104